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

#define _GLIBCXX_DEBUG

int main() {
  int n, z, ans, count_a = 0, count_b = 0;
  vector<int> a;
  
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> z;
    a.push_back(z);
  }
  
  sort(a.begin(), a.end());
  
   for(int i = 0; i < n; i++) {
     if(i % 2 == 0) count_a += a[i];
     else count_b += a[i];
  }
  
  int x = max(count_a, count_b);
  int y = min(count_a, count_b);
  ans = x - y;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int a[110], b[110];
int sum[110] = { 0 }, sum1[110] = { 0 };
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i != 0) {
			sum[i] += sum[i - 1];
		}
		sum[i] += a[i];
	}
	for (int j = 0; j < n; j++) {
		cin >> b[j];
	}
	for (int k = n - 1; k >= 0; k--) {
		if (k != n - 1) {
			sum1[k] = sum1[k + 1];
		}
		sum1[k] += b[k];
	}
	int max = 0;
	for (int l = 0; l < n; l++) {
		if (sum[l] + sum1[l] >= max) {
			max = sum[l] + sum1[l];
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

ll calc_gcd(ll x, ll y) {
    if (y == 0) {
        return x;
    }
    return calc_gcd(y, x % y);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    set<ll> cnt;
    rep(i, 0, N) {
        ll now_cnt = 0;
        ll a = A[i];
        while (a % 2 == 0) {
            ++now_cnt;
            a /= 2;
        }
        cnt.insert(now_cnt);
    }
    if (cnt.size() > 1) {
        cout << 0 << endl;
        return 0;
    }
    ll lcm = A[0] / 2;
    rep(i, 1, N) {
        lcm = (lcm * (A[i] / 2)) / calc_gcd(lcm, A[i] / 2);
    }
    cout << (M / lcm + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

typedef long long ll;
using namespace std;
const long long INF = 3e18;

ll mul(ll a, ll b) {
    if (a == 0 || b == 0) return 0;
    if (a > INF / b) return INF;
    return a * b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    long long acu = 1;
    long long max_p = pow(10, 18);
    bool ok = 0;
    for (int i = 0; i < n; ++i) {
        long long in; cin >> in;
        acu = mul(acu, in);
    }

    if ( acu > ll(1e18) ) cout << -1 << '\n';
    else cout << acu << '\n';
    return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;
using li = __int128;
using uli = unsigned __int128;

#define fi first
#define se second

template <typename T> void s_min(T& a, T b) {
	if (a > b) a = b;
}

template <typename T> void s_max(T& a, T b) {
	if (a < b) a = b;
}

const int MAXN = 1e5 + 5;
vector<int> adj[MAXN];
int N, M;
ll dp[MAXN];

int solve(int u) {
	if (dp[u] != -1) return dp[u];
	int ret = 0;
	for (int v : adj[u]) {
		s_max(ret, 1 + solve(v));
	}
	return dp[u] = ret;
}

int main() {
	ios_base::sync_with_stdio(0);

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		adj[x].push_back(y);
	}
	int ans = 0;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < N; i++) {
		s_max(ans, solve(i));
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 11856
#include <stdio.h>
int main(void){
    int i,N[7],a,b,c,t;
    char s[102];
    for(i=1;i<7;i++)scanf("%d",&N[i]);
    scanf("%s",s);
    for(a=1,b=2,c=3,i=0;s[i];i++){
        switch(s[i]){
            case'N':t=a,a=b,b=7-t;break;
            case'E':t=c,c=a,a=7-t;break;
            case'S':t=b,b=a,a=7-t;break;
            case'W':t=a,a=c,c=7-t;break;
        }
    }
    printf("%d\n",N[a]);
}

Measured memory_bytes: 1860
sx,sy,tx,ty = map(int,input().split())
Xd = tx - sx
Yd = ty - sy
print("R" * Xd,end = "")
print("U" * Yd,end = "")
print("L" * Xd,end = "")
print("D" * Yd,end = "")
print("D",end = "")
print("R" * (Xd + 1),end = "")
print("U" * (Yd + 1),end = "")
print("L",end = "")
print("U",end = "")
print("L" * (Xd + 1),end = "")
print("D" * (Yd + 1),end = "")
print("R")

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

int A[3][3];
int a[3][3];

int main(){
	rep(i,3){
		rep(j,3){
			cin >> A[i][j];
			a[i][j] = 0;
		}
	}
	int N;
	cin >> N;
	rep(i,N){
		int b;
		cin >> b;
		rep(j,3){
			rep(k,3){
				if(A[j][k] == b) a[j][k] = 1;
			}
		}
	}
	rep(i,3){
		if(a[i][0]  + a[i][1]  + a[i][2] == 3){
			cout << "Yes" << endl;
			return 0;
		}
		if(a[0][i] + a[1][i] + a[2][i] == 3){
			cout << "Yes" << endl;
			return 0;
		}

	}
	if(a[0][0] + a[1][1] +  a[2][2] == 3){
		cout << "Yes" << endl;
		return 0;
	}
	if(a[0][2] + a[1][1] + a[2][0] == 3){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;

			

}












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

int main()
{
    string s,t;
    int i,sum=0;
    cin>>s>>t;
  for(i=0;i<s.length();i++)
  {
    if(s[i]!=t[i])
      sum++;
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 3868
N = int(input())

# 104以下に条件を満たす数は無いらしいので飛ばす
if N <= 104:
    print(0)
else:
    ans = 0
    for n in range(105, N+1, 2):
        d_list = []
        for i in range(1, n//2):
            if n%i == 0:
                d_list.append(i)
        if len(d_list) == 7:
            ans += 1
    print(ans)

Measured memory_bytes: 3060
/********************************************//**
 ****** Handle: techno_phyle    *****************
 ***********************************************/

#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;
#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
#define endline "\n"
#define in(x) scanf("%d",&x);
const ll INF = 1e18L + 5;
const int inf = 1e9 + 5;
typedef pair<double, long> key;
struct comp {
	bool operator()(pair<int, int> p1, pair<int, int> p2) {
		if (p1.first < p2.first) return false;
		if (p2.first < p1.first) return true;
		return p1.second < p2.second;
	};
};
//greater<pair<int,int> , greater<int>>
ll a[M];


int main() {
	
	int test = 1;
	//cin >> test;
	while (test--) {
		int n, x, t;
		cin >> n >> x >> t;
		int res = (n + x - 1) / x;
		res = res * t;
		cout << res << endl;
	}




	return 0;

}


Measured memory_bytes: 3632
#include<string>
using namespace std;
#include <stdio.h>
#include <limits.h>
#include "bits/stdc++.h"
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
int h, w;
string str;
int main()
{
	cin >> h >> w;
	char t[h+1][w+1];
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j  < w + 1 ;j++) {
			cin >> t[i][j];
		}
	}
	str = "Yes";
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			if (t[i][j] == '#') {
				if (t[i - 1][j] == '.' && t[i + 1][j] == '.' && t[i][j - 1] == '.' && t[i][j + 1] == '.') {
					str = "No";
				}
			}
		}
	}
	cout << str;
	return 0;

}


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
use std::cmp::*;
//use std::num;

fn main() {
    input! {
        n:u64
    }
    // root n 以下の約数の列aを求める。
    // 各a[i]について、Fを計算する。
    // …しても良いけど、n以下で最大になるxを求めれば良いはず。
    // というか
    let mut ans = 10;
    let r: u64 = (n as f64).sqrt() as u64 + 1;
    for i in (1..(r + 1)).rev() {
        if n % i == 0 {
            ans = min(ans, max(getKeta(i), getKeta(n / i)));
            break;
        }
    }
    println!("{}", ans);
}
fn getKeta(i: u64) -> u64 {
    if i < 10 {
        1
    } else {
        getKeta(i / 10) + 1
    }
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
using u64 = uint_fast64_t;
using i64 = int_fast64_t;
#define rep(i, n) for(u64 i = 0; i < n; ++i)

u64 gcd(u64 a, u64 b){
  while(b) swap(a %= b, b);
  return a;
}

int main(){
  u64 a, b;
  cin >> a >> b;
  u64 c = gcd(a, b);
  u64 ans = 0;
  for(u64 p = 2; p * p <= c; ++p){
    if(!(c % p)){
      ++ans;
      do{
        c /= p;
      }while(!(c % p));
    }
  }
  if(c != 1){
    ++ans;
  }
  cout << ans + 1 << endl;
}


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

int main(void) {
	char str[1001]={};
	char replace[8]={}, reverse[8]={}, print[8]={};
	int n, a, b;
	scanf("%s", str);
	scanf("%d", &n);
	strcpy(replace, "replace");
	strcpy(reverse, "reverse");
	strcpy(print, "print");
	int i;
	for (i=1; i<=n; i++)
	{
		char command[8]={};
		scanf("%s", command);
		if (strcmp(command, replace)==0)
		{
			char rep[1001]={};
			scanf("%d%d%s", &a, &b, rep);
			int j;
			for (j=a; j<=b; j++)
			{
				str[j]=rep[j-a];
			}
			
		} else if (strcmp(command, reverse)==0)
		{
			scanf("%d%d", &a, &b);
			char rev[1001]={};
			int j;
			for (j=b; j>=a; j--)
			{
				rev[b-j]=str[j];
			}
			for (j=a; j<=b; j++)
			{
				str[j]=rev[j-a];
			}
			
		} else if (strcmp(command, print)==0)
		{
			scanf("%d%d", &a, &b);
			int j;
			for (j=a; j<=b; j++)
			{
				printf("%c", str[j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){return *(int*)a-*(int*)b;}
int main(){
    int n;
    scanf("%d",&n);
    int p[n],q[n];
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
        q[i]=p[i];
    }
    qsort(q,n,sizeof(int),cmp);
    int count=0;
    for(int i=0;i<n;i++)
        if(p[i]!=q[i])
            count++;
    if(count==2||count==0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long min = n-1;
        sc.close();
        for(long i=2;i*i<=n;i++){
            if(n%i==0){
                long x = i;
                long y = n/i;
                min = Math.min(min,x-1+y-1);
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 21844
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };

signed main() {
	int x, a; cin >> x >> a;
	if (x < a)puts("0");
	else cout << 10 << endl;
}

Measured memory_bytes: 764
num=list(map(int,input().split()))
sheet=[[0 for i in range(num[1])]for j in range(num[0]+1)]
for k in range(num[0]):
	sum=0
	kazu=list(map(int,input().split()))
	for l in range(num[1]):
		sheet[k][l]=kazu[l]
		sum+=kazu[l]
	sheet[k].append(sum)	
sum_ma=0
for m in range(num[1]):
	sum_b=0
	for n in range(num[0]):
		sum_b+=sheet[n][m]
	sheet[num[0]][m]=sum_b
	sum_ma+=sheet[num[0]][m]
sheet[num[0]].append(sum_ma)
for o in range(num[0]+1):
	for p in range(num[1]+1):
		print(sheet[o][p],end='')
		if p==(num[1]):
			print('')
		else:
			print(' ',end='')
		


Measured memory_bytes: 6680
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

string binlist[4097];

void dobin(void){
    for(ll i=0;i<4096;i++){
        string s="";
        ll j=i;
        while(j>0){
            if((j&1)==1){
                s=s+"1";
            }
            else{
                s=s+"0";
            }
            j>>=1;
        }
        while(s.length()<12){
            s=s+"0";
        }
        binlist[i]=s;
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    dobin();
    ll n,m,x;
    cin>>n>>m>>x;
    vector<ll> v;
    ll arr[n][m];
    for(int i=0;i<n;i++){
        ll c;
        cin>>c;
        v.pb(c);
        for(int j=0;j<m;j++){
            cin>>arr[i][j];
        }
    }
    ll ans=-1;

    for(int i=0;i<(1<<n);i++){
        string t=binlist[i];

        vector<ll> c(m,0);
        ll cost=0;
        for(int j=0;j<n;j++){

            if(t[j]=='1'){
                cost+=v[j];
                for(int p=0;p<m;p++){
                    c[p]+=arr[j][p];
                }
            }
        }
        int ok=1;
        for(int p=0;p<m;p++){
            if(c[p]<x){
                ok=0;
            }
        }
        if(ok==1){
            if(ans==-1){
                ans=cost;
            }
            else{
                if(cost<ans){
                    ans=cost;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
long long binpow(long long a,long long b)
{
    if (b == 1) return a;
    long long res = binpow(a, b/2)%MOD;
    if (b % 2) return (res*((res*a)%MOD))%MOD;
    else return (res * res)%MOD;
}

long long int fact(long long int a)
{
    if(a==0||a==1)
        return 1;
    long long int ans = 1;
    for(int i=a;i>=1;i--)
        ans = (ans * i)% MOD;
    return ans;
}

long long int ivmod(long long int a)
{
    return binpow(a,MOD-2);
}
 
long long int summ[1000005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int x;
    cin>>x;
    int temp = x;
    long long int finale = 0;
    for(int i=0;i<1000000;i++)
    {
        summ[i] = (i*(i+1))/2;
        if(summ[i]>=x)
        {
            temp = min(temp,i);
            // finale = sum[i];
            break;
        }
    }
    cout<<temp<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

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

  int ans[2] = {0, 1};
  std::string s; std::cin >> s;

	for(int i=0; i<sz(s); i++) {
    int n = s[i]-'0';
    int a0 = std::min(ans[0] + n,     ans[1] + 10 - (n)    );
		int a1 = std::min(ans[0] + n + 1, ans[1] + 10 - (n + 1));

		ans[0] = a0;
		ans[1] = a1;
	}
  std::cout << ans[0] << std::endl;
  return 0;
}


Measured memory_bytes: 1948
N,M=map(int,input().split())
switches=[]
for i in range(M):
  switch=list(map(int,input().split()))
  switch=switch[1:]
  switches.append(switch)
P=list(map(int,input().split()))
ans=0
def check_d(bottun):
  for i in range(M):
    b_c=0
    for j in switches[i]:
      if (bottun>>(j-1)) & 1 == 1:
        b_c+=1
    if b_c%2!=P[i]:
      return 0
  return 1
    
for bottun in range(2**N):
  ans+=check_d(bottun)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<math.h>
typedef long long int lli;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    long int n,temp;
    cin>>n;
    temp=sqrt(n);
    cout<<temp*temp;
	return 0;
}

Measured memory_bytes: 256
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());

function main(chunk){
    var lines = chunk.split("\n");
    for(var i=0;i<lines.length;){
        var line = lines[i++];
        var n = Number(line.split(" ")[0]);
        var m = Number(line.split(" ")[1]);
        if(n==0&&m==0) break;

        var arr = new Array(m);
        for(var j=0;j<m;j++){
            arr[j] = {idx:1+j,sum:0};
        }
        for(var j=0;j<n;j++){
            line = lines[i++];
            for(var k=0;k<m;k++){
                var a = line.split(" ")[k];
                if(a==1){
                    arr[k].sum += 1;
                }
            }
        }
        arr.sort(function(a,b){
            return (a.sum-b.sum!=0)?(b.sum-a.sum):(a.idx-b.idx);
        });
        var ans = "";
        for(var j=0;j<m;j++){
            ans += arr[j].idx + " ";
        }
        console.log(ans.trim());
    }
}

Measured memory_bytes: 20196
<?php
$cnt = [0, 0, 0, 0];
for ($i = 0; $i < 3; ++$i) {
    list($a, $b) = ints();
    ++$cnt[--$a];
    ++$cnt[--$b];
}
echo max($cnt) <= 2 ? 'YES' : 'NO';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) V vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m;
  cin>>n>>m;
  V l(m),r(m);
  rep(i,m)cin>>l[i]>>r[i];

  V imos(n+2,0);
  rep(i,m){
    imos[l[i]]++;
    imos[r[i]+1]--;
  }
  reps(i,n)imos[i]+=imos[i-1];
  
  int ans=0;
  reps(i,n){
    if(imos[i]>=m)ans++;
  }
  //call(imos);
  cout<<ans<<endl;
  
  
  
  
  return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <string>

using namespace std;
typedef long long ll;

int main() {
    ll N,A,B; cin >> N >> A >> B;
    string S;
    cin >> S;
    ll sum=0,absum=0;
    for(int i=0;i<N;i++){
        if(S[i]=='a'){
            if(sum<A+B) {
                cout << "Yes" << endl;
                sum++;
            }
            else cout << "No" << endl;
            
        }
        else if(S[i]=='b'){
            if(sum<A+B && absum<B) {
                cout << "Yes" << endl;
                sum++;
                absum++;
            }
            else cout << "No" << endl;
            
        }
        else cout <<"No" << endl;
    }
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){

	unsigned long long N;
	unsigned long long X;
	unsigned long long Y;
	cin >> N >> X >> Y;

	unsigned long long dis = Y - X;
	vector<unsigned long long> ans(N - 1, 0);
	unsigned long long k;

	for (unsigned long long i = 1; i <= N - 1; i++) {
		for (unsigned long long j = i + 1; j <= N; j++) {
			if (i <= X && Y <= j) {
				k = j - i - dis + 1;
				ans[k - 1] += 1;
			}
			else if (X < i && Y <= j) {
				k = min(j - i, i - X + j - Y + 1);
				ans[k - 1] += 1;
			}
			else if (i <= X && j < Y) {
				k = min(j - i, Y - j + X - i + 1);
				ans[k - 1] += 1;
			}
			else if (X < i && j < Y) {
				k = min(j - i, i - X + Y - j + 1);
				ans[k - 1] += 1;
			}
			else {
				k = j - i;
				ans[k - 1] += 1;
			}
		}
	}

	for (unsigned long long i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}

	return 0;
}



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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int x[N+1];
    x[0] = 0;

    int t = 0;
    for(int i = 1; i <= N; i++) {
        if(S[i-1] == 'I') {
            t = x[i-1];
            x[i] = ++t;
        }
        else {
            t = x[i-1];
            x[i] = --t;
        }
    }

    sort(x, x+N+1);

    cout << x[N];

    cout << endl;
    return 0;
}

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

int N;
vector<string> g;
int used[128],x1[128],x2[128],y1[128],y2[128];
vector<int> p;

vector<char> v;
bool bt(){

	for(int k=0;k<p.size();k++){
		for(int i=y1[p[k]];i<=y2[p[k]];i++){
			for(int j=x1[p[k]];j<=x2[p[k]];j++){
				char c = g[i][j];
				if(c == '.')return false;
				if(find(p.begin(),p.end(),p[k]) > find(p.begin(),p.end(),c)){
					return false;
				}
			}			
		}
	}
	for(int k=0;k<v.size();k++){
		if(!used[v[k]]){
			used[v[k]] = true;
			p.push_back(v[k]);
			if( bt() ) return true;
			p.pop_back();
			used[v[k]] = false;
		}
	}
	return p.size() == v.size();
}
int main(){
	int T;
	
	cin >> T;
	while(T--){
		int W,H;
		cin >> H >> W;
		vector<string> data(H);
		for(int i=0;i<H;i++)
			cin >> data[i];
			
		g = data;
		
		int check[128];
		
		for(int i=0;i<128;i++)
			x1[i] = x2[i] = y1[i] = y2[i] = used[i] = check[i] = 0;

		for(int i=0;i<128;i++)
			x1[i] = y1[i] = 9999;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				char c = data[i][j];
				if(c != '.'){
					check[c] = true;
					x1[c] = min(j,x1[c]);
					x2[c] = max(j,x2[c]);
					y1[c] = min(i,y1[c]);
					y2[c] = max(i,y2[c]);
				}
			}
		}
		
		v.clear();
		p.clear();
		
		for(int i=0;i<128;i++)
			if(check[i])v.push_back(i);

			
		cout << ( bt() ? "SAFE" : "SUSPICIOUS") << endl;
	}
}

Measured memory_bytes: 940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
#define MOD 1e9+7
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

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

struct edge {int to, cost;};
vector< vector<edge> > es;
const int MAX_N = 10010;
int n;

struct UnionFind {
    vi par, rank, siz;
    UnionFind(int N) : par(N), rank(N), siz(N) {
        REP(i, N) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }

    int find(int x) {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (rank[y] < rank[x]) {
            par[y] = x;
            siz[x] += siz[y];
        } else {
            par[x] = y;
            siz[y] += siz[x];
            if (rank[x] == rank[y]) rank[y]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return siz[find(x)];
    }

};

int main() {
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);

    REP(i, q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com) {
            if (uf.same(x, y)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        } else {
            if (!uf.same(x, y)) {
                uf.unite(x, y);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;

int main(void) {
    int n; cin >> n;
    string N = to_string(n);
    string answer = "";
    for (int i=0; i<3; i++) {
        if (N[i] == '1') {
            answer = answer + "9";
        } else if(N[i] == '9') {
            answer = answer + "1";
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int a,b;
	cin>>a>>b;
	if(a<=9&&b<=9)
	{
		cout<<a*b<<endl;
	}
	else cout<<"-1\n";
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int a,b;cin >> a >> b;
  if(a<=0 && b>=0) cout << "Zero" << endl;
  else if(a>0) cout << "Positive" << endl;
  else if((b-a)&1) cout << "Positive" << endl;
  else cout << "Negative" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int len1, len2;
char a[105] ,b[105];
void swap(char &a, char &b)
{
	char t;
	t = a;
	a = b;
	b = a;
}
bool cmp(char a,char b)
{
	return a > b;
}
int main()
{
	scanf("%s",a);
	scanf("%s",b);
	int len1 = strlen(a);
	int len2 = strlen(b);
		sort(a,a + len1);
		sort(b,b + len2,cmp);
		if(strcmp(a, b) < 0) printf("Yes\n");
		else printf("No\n");
		/*
		int flag = 0;
		for(int k = 0;k < min(len1,len2);k++){
			if(b[k] > a[k])
			{
				cout << "Yes" << endl;
				return 0;
			}
			if(b[k] == a[k]) flag++;
	//		printf("%d\n",flag);
		}
		if(strcmp(a, b) == 0) cout << "No" << endl;
		else if(flag != min(len1,len2))
			cout << "No" << endl;
		else if(flag < len2)
			cout << "Yes" << endl;
			*/
}

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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  ll ans = 0;
  ll mul = 1;
  while (true) {
    ans += mul;
    mul *= 2;

    if (h == 1) break;
    h /= 2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import math
from sys import exit

n=int(input())
primes = {}
i = 2
ans = 0
square = math.floor(math.sqrt(n))

if n == 1:
    print(0)
    exit()

# while True:
#     if n == 1 or i > square:
#         break
#     if n % i == 0:
#         if i not in primes.keys():
#             primes[i] = 1
#         else:
#             primes[i] += 1
#         n = n // i
#     else:
#         if i == 2:
#             i += 1
#         else:
#             i += 2
#         continue

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

primes = factorization(n)
if len(primes) == 0:
    print(1)
    exit()

for k,v in primes:
    base = v * 2
    root = math.floor(math.sqrt(base))
    if root * (root + 1) > base:
        root -= 1
    ans += root

print(ans)

Measured memory_bytes: 9524
#include <stdio.h>
#include <string.h>

int main(void)
{
	int w,a,b,dis;
	scanf("%d%d%d",&w,&a,&b);
	if(a+w<=b || a>=b+w)
		{
		if(a<b){dis=b-(a+w);}
		else{dis=a-(b+w);}
		}
	else{dis=0;}
	printf("%d",dis);
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        char[] c = sc.next().toCharArray();
        int indA = 1;
        int indB = 0;
        int indC = 0;
        char now = 'a';
        while(indA <= a.length && indB <= b.length && indC <= c.length){
            if(now == 'a'){
                if(indA == a.length){
                    System.out.println("A");
                    return;
                }
                indA++;
                now = a[indA-1];
            }else if(now == 'b'){
                if(indB == b.length){
                    System.out.println("B");
                    return;
                }
                indB++;
                now = b[indB-1];
            }else{
                if(indC == c.length){
                    System.out.println("C");
                    return;
                }
                indC++;
                now = c[indC-1];
            }
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=(LL)1e9+7LL; 

int main(){
    LL N;cin>>N;
    LL res=(N/11LL)*2LL;
    if(N%11LL!=0){
        if(N%11LL<=6)res+=1;
        else res+=2;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int card[3],sum,i,sign;
    for(;sign=0,scanf("%d %d %d",&card[0],&card[1],&card[2])!=EOF;){
        sum=20-card[0]-card[1];
        for(i=sum;i>0;i--)
            if(!(i==card[0]||i==card[1]||i==card[2]))
                sign++;
        if(sign>3)
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}


Measured memory_bytes: 2032
#include <stdio.h>
int main(void)
{
 int A[100000];
 int i,j;
 int X;
 scanf("%d",&X);
 int count = 0;
 for(i=X;i<200000;i++)
  {
   
   for(j=2;j<i;j++)
    {
    if(i%j==0) goto L_Break;
    }
//   A[count] =i;
     printf("%d\n",i);
     return 0;
//   count++;
   L_Break:
   i=i;
  }

 

 for(i=0;i<count;i++)
 {
  printf("%d\n",A[0]);
}
 return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
  using namespace std;
  long long MOD=1000000007;
  int lim=100010;
  #define IOS() ios_base::sync_with_stdio(0); cin.tie(0);
  typedef long long ll;
  #define pb push_back
  typedef pair<int,int> pi;

  
  int main()
  {
    IOS();
    int n;
    cin>>n;
    double p[n+1];

    for (int i = 1; i <=n; ++i)
    {
        cin>>p[i];
    }


    double dp[n+1][n+1];

    for (int i = 0; i <=(n); ++i)
    {
      for (int j = 0; j <=n; ++j)
      {
          dp[i][j]=0;
      }
    }

    dp[1][1]=p[1];
    dp[1][0]=(1-p[1]);


    double f=1;
    for(int i=2;i<=n;i++)
    {
      dp[i][0]=(1-p[i])*dp[i-1][0];
    }



    for(int i=2;i<=n;i++)
    {
      for(int j=1;j<=n;j++)
       dp[i][j]= dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
    }

    // cout<<setprecision(12)<<dp[n][x]<<endl;
    double ans=0;

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


    cout<<setprecision(12)<<ans<<endl;




    return 0;
  }

Measured memory_bytes: 73964
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)


// ------------debug用------------
#define FALSE cout<<"false"<<endl;
#define TRUE cout<<"true"<<endl;
// ------------debug用------------


// ------------計算用------------
#define ALL(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)
// ------------計算用------------


// ------------出力用------------
#define PRINT(x) cout<<x<<endl;
// ------------出力用------------


using namespace std;
typedef long long ll;

int main(){
  int N,X;
  cin>>N>>X;
  vector<int> L(N);
  FOR(N)cin>>L[i]; 
  
  vector<int> D(N);
  D[0] = 0;
  int i;
  for(i = 1;i <= N;i++){
    D[i] = D[i - 1] + L[i - 1];
    if(D[i] > X){break;}
  }
  cout<<i;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int counter[10][10];

int main() {
  int N;

  cin >> N;

  for (int A=1; A<=N; A++) {
    int tmp = A;
    while(tmp >= 10) tmp /= 10;
    counter[tmp][A%10]++;
  }

  ll ans = 0;

  for (int B=1; B<=N; B++) {
    int tmp = B;
    while(tmp >= 10) tmp /= 10;
    ans += counter[B%10][tmp];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<ctype.h>
using namespace std;
const int mod=1e9+7;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int f[1000007];
int main(){
	int n=read(),s=0;
	f[n]=n;f[n-1]=1ll*n*n%mod;
	for(int i=n-2;i>=1;--i){
		s=(s+f[i+3])%mod;
		f[i]=(f[i+1]+1ll*(n-1)*(n-1)+s+i+1)%mod;
	}
	printf("%d\n",f[1]);
	return 0;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int i;
    int ans=0;
    for(i=0;i<3;i++)
    {
        if(s.at(i)==t.at(i))ans++;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
	string line;

	getline(cin, line);

	for (auto& a : line) {
		if (a >= 'a' && a <= 'z') {
			// 大文字のほうがASCIIコード上で小さい値
			a -= 'a' - 'A';
		}
	}

	cout << line << endl;

	return 0;
}

Measured memory_bytes: 1176
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
s=0
def f(n):
    return n*(n-1)//2
for i in c:
    c[i]=(f(c[i]),(f(c[i]-1)))
    s+=c[i][0]
for j in A:
    print(s-c[j][0]+c[j][1])
    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 33900
N = int(input())
A =[int(input()) for i in range(N)]

def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

m = max(A)
maxindexlist = my_index_multi(A,m)

if len(maxindexlist) == 1:
    for i in range(N):
        if i != (maxindexlist[0]):
            print(m)
        else:
            A.pop(maxindexlist[0])
            print(max(A))
else:
    for i in range(N):
        print(m)


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

using namespace std;

# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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 M_DEBUG if (1)

/******************************************************************************
	Main
******************************************************************************/
int main()
{
	int a = 0, b = 0, c = 0;
	cin >> a >> b >> c;
	assert(a >= 0 && a <= 100);
	assert(b >= 0 && b <= 100);
	assert(c >= 0 && c <= 100);

	cout << c << " " << a << " " << b << endl;

	return 0;
}


Measured memory_bytes: 256
// 多分これではTLEする
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

struct Data
{
    ll B;
    ll C;
    bool operator<(const Data &rhs) const
    {
        return C > rhs.C;
    }
};

void solve()
{
    ll N, M;
    cin >> N >> M;
    map<ll, ll> Amap;
    vector<Data> data(M + N);

    for (ll i = 0; i < N; i++)
    {
        // Aの取得
        cin >> data.at(i).C;
        data.at(i).B = 1;
    }

    for (ll i = N; i < M + N; i++)
    {
        cin >> data.at(i).B >> data.at(i).C;
    }

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

    ll count = 0;
    ll num = N;
    for (ll i = 0; i < M + N; i++)
    {
        if (num > data.at(i).B)
        {
            num -= data.at(i).B;
            count += data.at(i).C * data.at(i).B;
        }
        else
        {
            count += data.at(i).C * num;
            break;
        }
    }

    cout << count << endl;

    return;
}

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


Measured memory_bytes: 3328
N=int(input())
shogen=[]
for i in range(N):
  a=int(input())
  ash=[]
  for j in range(a):
    xy=tuple(map(int,input().split()))
    ash.append(xy)
  shogen.append(ash)
cnt="0000"
for i in range(1<<N):
  flag=True
  fact="0"*(N-len(bin(i)[2:]))+bin(i)[2:]
  for j in range(N):
    if fact[j]=='1':
      s=shogen[j]
      for xy in s:
        if fact[xy[0]-1]!=str(xy[1]):
          flag=False
          break
  if flag:
    cnt=fact
ans=0
for c in cnt:
  ans+=int(c)
      
print(ans)

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		switch(reader.nextInt()) {
		    case 25:
		        System.out.println("Christmas");
		        break;
		    case 24:
		        System.out.println("Christmas Eve");
		        break;
		    case 23:
		        System.out.println("Christmas Eve Eve");
		        break;
		    case 22:
		        System.out.println("Christmas Eve Eve Eve");
		        break;
		}
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


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

using namespace std;
const int maxn = 1e5+15;
int pre[maxn],cur[maxn],a[maxn],n;
int main(){
    cin >> n;
    for(int i = 1;i <= n; ++i) cin >> a[i];
    for(int i = 1;i <= n; ++i) pre[i] = __gcd(a[i],pre[i-1]);
    for(int i = n;i >= 1; --i) cur[i] = __gcd(a[i],cur[i+1]);
    int res = 0;
    for(int i = 1;i <= n; ++i) res = max(res,__gcd(pre[i-1],cur[i+1]));
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 1408
N = int(input())
S = input()
ans = 0
snumber = [str(i) for i in range(10)]
for i in snumber:
    for j in snumber:
        for k in snumber:
            a = S.find(i)
            if a == -1:
                break
            b = S.find(j,a+1)
            if b == -1:
                break
            c = S.find(k,b+1)
            if c != -1:
                ans += 1
print(ans)


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

int main(){
    int H, W;
    cin >> H >> W;
    int powers[10][10];
    string c;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c;
            powers[i][j] = stoi(c);
        }
    }
    for (int n = 0; n < 10; n++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                powers[i][j] = min(
                        powers[i][j],
                        powers[i][n] + powers[n][j]);
            }
        }
    }
    int ans = 0;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cin >> c;
            if (c != "-1" and c != "1"){
                int k = stoi(c);
                ans += powers[k][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256