akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int HelloWorld(){
	cout << "Hello World" << endl;
	return 0;
}

int XCubic(){
	int x;
	cin >> x;
	if (1 <= x && x <= 100){
		x = x*x*x;
		cout << x << endl;
		return 0;
	}
	return 1;
}

int Rectangle(){
	int a, b, area, perimeter;

	cin >> a >>b;
	if (1 <= a && b <= 100){
		area = a*b;
		perimeter = (a + b) * 2;
		cout << area << " " << perimeter << endl;
		return 0;
	}
	return 1;
}

int main(){
	//HelloWorld();
	//XCubic();
	Rectangle();
	return 0;
}

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

using namespace std;

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);

int32_t main()
{
    tie();
    int t = 1;
    while(t--)
    {
        int n , m;
        cin >> n >> m;
        int a[n + 1];
        memset(a , -1 , sizeof a);
        int idx, x;

        bool cond = true;
        for(int i = 0 ; i < m ; i++)
        {
            cin >> idx >> x;
            if(a[idx] == -1)
                a[idx] = x;
            else
            {
                if(a[idx] != x)
                    cond = false;
            }
        }

        if(n == 1 and cond)
        {
            cout << (a[1] == -1 ? 0 : a[1]) << endl;
            continue;
        }

        if(a[1] == 0)
            cond = false;
        if(cond)
        {
            for(int i = 1 ; i <= n ; i++)
                cout << ((a[i] == -1) ? ((i == 1) ? 1 : 0) : a[i]);
            cout << endl;
        }
        else
            cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import bisect

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

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

kosu=[i*(i+1)//2 for i in range(60)]
#print(kosu)
n=int(input())
pnum=factorization(n) 
ans=0
for i in range(len(pnum)):
  kata=pnum[i][1]
  tmp=bisect.bisect_left(kosu,kata)-1
  if kata in kosu:
    tmp+=1
  ans+=tmp
  #print("tmp",tmp,ans)
if n==1:
  ans=0
print(ans)

Measured memory_bytes: 9484
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}

		boolean[][] dp = new boolean[n+1][40001];
		dp[0][0] = true;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= 40000; j++) {
				dp[i+1][j] = (j-a[i]>=0 && dp[i][j-a[i]]) || dp[i][j];
			}
		}

		int q = in.nextInt();
		int[] m = new int[q];
		for (int i = 0; i < q; i++) {
			m[i] = in.nextInt();
			if (dp[n][m[i]]) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}

	}

}



Measured memory_bytes: 28052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int n,a=0,b=0;
  string s;
  cin>>n>>s;
  fr(i,n){
    if(s[i]=='(') a++;
    else b++;
    while(a<b){a++;cout<<'(';}
  }
  cout<<s;
  while(a>b){b++;cout<<')';}
  cout<<endl;
}

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


int main()
{
	int N,M,C;
	std::vector<int> v, v_diff;
	
	std::cin >> N >> M;

	if (M <= N) {
		std::cout << 0 << "\n";
		return 0;
	}
	
	for (int i = 0; i < M; i++) {
		std::cin >> C;
		v.push_back(C);
	}

	std::sort(v.begin(), v.end());
	for (int i = 0; i < M - 1; i++) {
		v_diff.push_back(std::abs(v[i] - v[i + 1]));
	}

	std::sort(v_diff.begin(), v_diff.end());
	std::cout << std::accumulate(v_diff.begin(), v_diff.end() - N + 1, 0) << "\n";
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
template <typename Container> void P(const Container &c) {
    for (const auto& x : c) cout << x << ' '; cout << '\n';
}
const int MOD = 1000000007;
int main()
{
    int H, W, K; cin >> H >> W >> K;
    if (W == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<int> A;
    vector<vector<int>> B; // B[patid] = { destination }
    REP(i, (1 << (W-1))) {
        bool ok = 0;
        REP (j, W-1) {
            if ((i & (1 << j)) && (i & (1 << (j+1)))) goto NG;
        }
        A.push_back(i);
NG:
        ;
    }
    for(int pat : A) {
        vector<int> x(W);
        REP(i, W) x[i] = i + 1;
        REP(i, W-1) if (pat & (1 << i)) swap(x[i], x[i+1]);
        B.push_back(x);
    }
    vector<Int> counts(W+1);
    counts[1] = 1;
    REP(i, H) {
        vector<Int> newcounts(W+1);
        REP(j, A.size()) {
            FOR (k, 1, W+1) {
                newcounts[B[j][k-1]] = (newcounts[B[j][k-1]] + counts[k]) % MOD;
            }
        }
        counts = newcounts;
    }
    cout << counts[K] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n / 2];
        int[] b = new int[n / 2];
        for (int i = 0; i < n / 2; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        int aMaxcount = 1;
        int aSecondCount = 1;
        int amaxnum = 0;
        int amaxNum2 = 0;
        int acount = 1;
        for (int i = 0; i < n / 2 - 1; i++) {
            if (a[i] == a[i + 1]) {
                acount++;
                if (acount > aMaxcount) {
                    aMaxcount = acount;
                    amaxnum = i;
                }

            } else {
                acount = 1;
            }
        }
        acount = 1;
        for (int i = 0; i < n / 2 - 1; i++) {
            if (a[i + 1] == a[amaxnum]) {
                acount = 1;
                continue;
            }
            if (a[i] == a[i + 1]) {
                acount++;
                if (acount > aSecondCount) {
                    aSecondCount = acount;
                }

            } else {
                acount = 1;
            }

        }
        if (aMaxcount == n / 2) {
            aSecondCount = 0;
        }

        int bMaxcount = 1;
        int bSecondCount = 0;
        int bmaxnum = 0;
        int bmaxNum2 = 0;
        int bcount = 1;
        for (int i = 0; i < n / 2 - 1; i++) {
            if (b[i] == b[i + 1]) {
                bcount++;
                if (bcount > bMaxcount) {
                    bMaxcount = bcount;
                    bmaxnum = i;
                }

            } else {
                bcount = 1;
            }
        }
        bcount = 1;
        for (int i = 0; i < n / 2 - 1; i++) {
            if (b[i + 1] == b[bmaxnum]) {
                bcount = 1;
                continue;
            }
            if (b[i] == b[i + 1]) {
                bcount++;
                if (bcount > bSecondCount) {
                    bSecondCount = bcount;
                }

            } else {
                bcount = 1;
            }

        }
        if (bMaxcount == n / 2) {
            bSecondCount = 0;
        }
        int ans = 0;
        int aaa = 0;
        int bbb = 0;
        if (a[amaxnum] != b[bmaxnum]) {
            ans = n - aMaxcount - bMaxcount;
        } else if (aMaxcount == n / 2 && bMaxcount == n / 2) {
            ans = n / 2;
        } else {
            aaa = n - aMaxcount - bSecondCount;
            bbb = n - aSecondCount - bMaxcount;
            ans = Math.min(aaa, bbb);
        }
        System.out.println(ans);
        //System.out.println(aMaxcount + " " + bMaxcount);
        //System.out.println(aSecondCount + " " + bSecondCount);
        //System.out.println(a[amaxnum] + " " + b[bmaxnum]);

    }
}

Measured memory_bytes: 51716
#include <iostream>
#define int long long
using namespace std;
signed main(int argc, char** argv) {
	int n,a,b;
	cin >> n >> a >> b;
	if((b-a)%2==0)
	{
		cout << (b-a)/2;
		return 0;
	}
	int x,y;
	x=a-1;
	++x;
	x+=(b-x-1)/2;
	y=n-b;
	++y;
	y+=(n-a-y)/2;
	cout << min(x,y);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int r, g, b; cin >> r >> g >> b;
    if ((r*100+g*10+b)%4==0) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#! python3
# insertion_sort.py

N = int(input())
nums = [int(x) for x in input().split(' ')]

print(' '.join([str(x) for x in nums]))
for i in range(1, N):
    v = nums[i]
    j = i-1
    while j >= 0 and nums[j] > v:
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = v
    print(' '.join([str(x) for x in nums]))


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

#define INFTY 1000000001
int cnt = 0;

void merge(int A[], int left, int mid, int right) {
  int i, j, k;
  int n1, n2;  // 部分列L, Rの要素数決定に利用
  
  n1 = mid - left;
  n2 = right - mid;
  
  int L[n1+1], R[n2+1];
  
  for (i = 0; i < n1; i++) L[i] = A[left + i];  
  for (i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;

  // sort
  j = 0;
  k = 0;
  for (i = left; i < right; i++) {
      cnt++;
    if (L[j] <= R[k]) {
      A[i] = L[j];
      j++;
    } else {
      A[i] = R[k];
      k++;
    }
  }
}

void merge_sort(int A[], int left, int right) {
  if (left + 1 < right) {
    int mid;
    mid = (left + right) / 2;
    // devide
    merge_sort(A, left, mid);
    merge_sort(A, mid, right);
    // conquer
    merge(A, left, mid, right);
  }
}

int main() {
  int i, n, S[500000];

  cin >> n;
  for (i = 0; i < n; i++) cin >>  S[i];

  merge_sort(S, 0, n);

  for (i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << S[i];
  }
  cout << endl;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 7008
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  if(s[0]=='a') cout<<"square1001"<<endl;
  else cout<<"e869120"<<endl;
  return 0;
}



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

const int MAXN=300+10;
double dp[MAXN][MAXN][MAXN];
int num[4];
int N,n;
// n/k
double dfs(int a,int b,int c)
{
	if(a==0 && b==0 && c==0) return 0;
	if(dp[a][b][c]>0) return dp[a][b][c];
	double ans=1.0*N/(a+b+c);
	if(a>0) ans+=1.0*a/(a+b+c)*dfs(a-1,b,c);
	if(b>0) ans+=1.0*b/(a+b+c)*dfs(a+1,b-1,c);
	if(c>0) ans+=1.0*c/(a+b+c)*dfs(a,b+1,c-1);
	dp[a][b][c]=ans;
	return dp[a][b][c];
}

int main()
{
	ios::sync_with_stdio(false);
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>n;
		num[n]++;
	}
/*	for(int i=0;i<=num[1];i++)
	{
		for(int j=0;j<=num[2];j++)
		{
			for(int k=0;k<=num[3];k++)
			{
				cout<<dp[i][j][k]<<' ';
			}
			cout<<endl;
		}
	//	system("pause");
	}
	
	for(int i=0;i<num[1]+num[2]+num[3];i++)
	{
		for(int j=0;j<num[2]+num[3];j++)
		{
			for(int k=0;k<num[3];k++)
			{
				
			}
		}
	}*/
	printf("%.10f",dfs(num[1],num[2],num[3]));
	return 0;
}


Measured memory_bytes: 225536
import sys
sys.setrecursionlimit(500000)

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]
    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)
    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]


N = int(input())
G = [[] for _ in range(N)]
INPUT = []
for i in range(N-1):
  a,b = map(int,input().split())
  a-=1;b-=1
  G[a].append(b)
  G[b].append(a)
  INPUT.append((a,b))
visit = set([])
path = [0]
def dfs(v):
  if v in visit:
    return
  visit.add(v)
  if v == N-1:
    return
  for w in G[v]:
    if w in visit:
      continue
    path.append(w)
    dfs(w)
    if path[-1] == N-1:
      return
    path.pop()
dfs(0)
#print(path)
if len(path)%2 == 0:
  A,B = path[len(path)//2-1],path[len(path)//2]
else:
  A,B = path[len(path)//2],path[len(path)//2+1]
#print(A,B)
uf = UnionFind(N)
for i in range(N-1):
  a,b = INPUT[i]
  if (a == A and b == B) or (a == B and b == A):
    continue
  uf.union(a,b)
fen = uf.get_size(0)
snu = uf.get_size(N-1)
if fen > snu:
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 187160
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

long long function(long long count){
    long long temp = 1;
    long long total = 0;

    for(int i = 1; i <= count; i++){
        total += temp;
        temp *= 2;
    }
    
    total += temp;
    return total;
}

int main(){
    long long H;
    cin >> H;

    if(H == 1){
        cout << 1 << endl;
        return 0;
    }

    // Hが２の累乗のどの範囲に位置するか計算
    long long i = 1;
    long long index_count = 0; // ２の指数
    while(H >= i ){
        i *= 2;
        index_count++;
    }
    i = i / 2;
    index_count--;

    // ２の累乗が何回攻撃必要か計算
    long long ans = function(index_count);

    cout << ans << endl;
    return 0;
}

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

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

const int INF = 1e9 + 7;

using namespace std;

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

	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	if (a1 + a2 + a3 >= 22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        long[] DP = new long[N];
        var h = cin.arrayLong();

        DP[0] = 0;
        for (int i=1; i<N; i++) {
            DP[i] = 10000000000;
        }
        for (int i=0; i<N; i++) {
            if (i+1 < N) {
                DP[i+1] = Math.Min(DP[i+1], DP[i]+Math.Abs(h[i]-h[i+1]));
            }
            if (i+2 < N) {
                DP[i+2] = Math.Min(DP[i+2], DP[i]+Math.Abs(h[i]-h[i+2]));
            }
        }

        Console.WriteLine(DP[N-1]);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 17632
#include <iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }else{
            for(int i = 0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(0 < i && i < H-1 && 0 < j && j < W-1){
                        cout << ".";    
                    }else{
                        cout << "#";
                    }
                }
                cout << "\n";
            }
            cout << "\n";
        }
       }
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int W,H,C,a,b,r=0,A=0;
cin >> W >> H >> C;
a=W;
b=H;
while((r=a%b)!=0){
a=b;
b=r;
}
A=W/b*H/b;
A=A*C;
cout << A <<endl;
return(0);
}


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

int main() {
  int N; cin >> N;
  vector<int> cards(N);
  for(int i=0;i<N;i++)
    cin >> cards.at(i);

  int a=0, b=0;

  for(int i=0;i<N;i++){

    int max=-1;
    int idx;
    for(int j=0;j<N;j++){
      if(cards.at(j)>max){
        idx=j;
        max=cards.at(j);
      }
    }
    cards.at(idx)=-1;

    if(i%2==0)
      a+=max;
    else
      b+=max;
  }
  cout << a-b << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[n];
		int n = sc.nextInt();
		int[] array = new int[n+1];

		for(int i=0;n+1>i;i++) {
			array[i]=0;
		}
		for(int i=0;n-1>i;i++) {
			int a = sc.nextInt();
			//list.add(a);
			array[a-1]++;
		}

		for(int i=0;n>i;i++) {
			System.out.println(array[i]);
		}
		/*

		int max = Collections.max(list);
		int[] answer = new int[n];
		for(int i=0;n>i;i++) {
			answer[i]=0;
		}
		System.out.println(array[1]);
		loop :for(int i=1;max+1>i;i++) {
			for(int j=0;n-1>j;j++) {
				if(list.get(j)==i) {
					answer[j]=array[i+1];
					continue loop;
				}
			}
		}
		for(int i=0;n-1>i;i++) {
			System.out.println(answer[i]);
		}
		*/

	}
}

Measured memory_bytes: 60736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll int n,a,b,c=0,i;
	cin>>n;
	a=(n/500)*1000;
	b=((n%500)/5)*5;
	c=a+b;
	cout<<c;

	
}


Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string s;

    cin >> s;

    cout << s[0] << s.size() - 2 << s.back() << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	int n, m;
	cin >> n >> m;
	vector<pair<ll, int> > ab;
	ll a, b, cost=0;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		ab.push_back(make_pair(a, b));
	}
	sort(ab.begin(), ab.end());
	for(int i = 0; i < n; i++){
		if(m <= ab[i].second){
			cost += m*ab[i].first;
			break;
		}
		cost += ab[i].first*ab[i].second;
		m-=ab[i].second;
	}
	cout << cost << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i <= 2000; ++i) {
    if (a == i * 2 / 25 && b == i / 10) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define M 100000

int A[M],n;

int partition(int p,int r){
  int x,i,j,t;
  
  x=A[r];
  i=p-1;

  for( j=p; j<r; j++ ){
    
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }

  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;

  return i+1;
}

int main(){
    int i,q;

    scanf("%d",&n);

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

    q=partition(0,n-1);

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

    return 0;
  }



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

typedef long long ll;
const int N=2e5+5;

int h[N],n,q[N],head,tail;
ll c,f[N];

#define sqr(x) ((x)*1ll*(x))
ll g(int x) {return f[x]+sqr(h[x]);}
bool comp(int a,int b,int c) {return (g(c)-g(b))*(h[b]-h[a])<(g(b)-g(a))*(h[c]-h[b]);}

int main() {
	//freopen("1.in","r",stdin);
	//freopen("1.ans","w",stdout);
	
	scanf("%d%lld",&n,&c);
	for(int i=1;i<=n;++i) scanf("%d",&h[i]);
	q[tail++]=1;
	for(int i=2;i<=n;++i) {
		while(head+1<tail&&g(q[head+1])-g(q[head])<2ll*h[i]*(h[q[head+1]]-h[q[head]])) ++head;
		f[i]=f[q[head]]+sqr(h[i]-h[q[head]])+c;
		while(head+1<tail&&comp(q[tail-2],q[tail-1],i)) --tail;
		q[tail++]=i;
	}
	printf("%lld\n",f[n]);
	
	return 0;
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
		int[] h = new int[n];
		for(int i=0; i<n; i++){
			h[i] = scn.nextInt();
		}
      	Arrays.sort(h);
      	long att = 0;
      	for(int i=0; i<n-k; i++){
			att = att + h[i];
		}
      	System.out.println(att);
	}
}


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

int main(){
    int n;
    cin >> n;
    int twokosuu=0,fourkosuu=0,kasu=0;
    for(int i=0;i<n;i++){
        long long a;
        cin >> a;
        if(a%4==0)fourkosuu++;
        else if(a%2==0)twokosuu++;
        else kasu++;
    }
    //cout << fourkosuu << twokosuu << kasu << endl;
    if(twokosuu==0){
        if(kasu<=fourkosuu+1)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        kasu += 1;
        if(kasu<=fourkosuu+1)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;
    for(int i=0;i<S.length();i++){
        if(S[i] + N > 'Z') S[i] = S[i]+ N -26;
        else S[i] = S[i] + N;
    }
    cout << S << endl;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };
const int MOD=1e9+7;

int main() {
  string S;cin>>S;
  if (S=="SUN") OUT(7);
  else if (S=="MON") OUT(6);
  else if (S=="TUE") OUT(5);
  else if (S=="WED") OUT(4);
  else if (S=="THU") OUT(3);
  else if (S=="FRI") OUT(2);
  else OUT(1);

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
	int N;
	scanf("%d",&N);
	int h[N];
	for(int i=0;i<N;i++)scanf("%d",&h[i]);
	int ans=0;
	
	ans+=h[0];
	for(int i=1;i<N;i++){
		if(h[i]>h[i-1])ans+=h[i]-h[i-1];
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
 long long int a,b,k;
  scanf("%lld %lld %lld",&a,&b,&k);
  if(a>=k){
    a=a-k;
    printf("%lld %lld",a,b);
    return 0;
  }
  else{
    if(b-(k-a)>=0){
    b=b-(k-a);
    a=0;
    printf("%lld %lld",a,b);
    return 0;
    }
    else
      printf("0 0");
      return 0;
  }

return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int[] a = new int[n];
        
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        
        for(int i = 0; i < n-1; i++){
            System.out.printf(a[n-i-1] + " ");
        }
        System.out.println(a[0]);
    }
}


Measured memory_bytes: 26440
let () = Scanf.scanf "%d\n%s" @@ fun n s ->
  let count = Array.make 26 0 in
  String.iter (fun c ->
    let i = Char.code c - Char.code 'a' in
    count.(i) <- count.(i) + 1) s;
  Printf.printf "%d\n" @@
    (Array.fold_left (fun acc cnt -> acc * (cnt + 1) mod 1000000007) 1 count + 1000000006) mod 1000000007


Measured memory_bytes: 768
// 解説みた。
using System;

class SumOfThreeIntegers{
    static void Main() {
        string input = Console.ReadLine();

        int max_value = int.Parse(input.Split(' ')[0]);
        int sum_value = int.Parse(input.Split(' ')[1]);

        // max_value以下の３つの自然数を合計して、sum_valueとピッタリになる値は何通りあるか？
        int count = 0;
        for (int x = 0; x <= max_value; x++) {
            for (int y = 0; y <= max_value; y++) {
                int z = sum_value - x - y;
                if (0 <= z && z <= max_value) count++;
            }

        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N-1);
  for(int i=0;i<N-1;i++){
    cin>>B.at(i);
  }
  int count=0;
  int add=0;
  for(int i=0;i<N;i++){
    if(i==0){
      add=B.at(0);
    }else if(i==N-1){
      add=B.at(i-1);
    }else{
      add=min(B.at(i-1),B.at(i));
    }
    A.at(i)=add;
    //cout<<add<<endl;
  }
  for(int i=0;i<N;i++){
    count+=A.at(i);
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m; cin >> n >> m;
    priority_queue<int> a;
    rep(i,n) {
        int A; cin >> A;
        a.push(A);
    }
    rep(i,m) {
        int b = a.top();
        a.pop();
        a.push(b/2);
    }
    ll ans = 0;
    rep(i,n) {
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
    return 0;
}

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

//k,k+1,k+2 �̍ő�l�� k+1 �Ȃ� 1
int judge(int p[], int k) {
	int max, min;
	if (p[k] > p[k + 1]) {
		max = p[k]; min = p[k + 1];
	}
	else {
		max = p[k + 1]; min = p[k];
	}

	if (p[k + 2] > max)
		max = p[k + 2];
	if (min > p[k + 2])
		min = p[k + 2];

	if ((max == p[k] && min == p[k + 2]) || (max == p[k + 2] && min == p[k]))
		return 1;
	else
		return 0;
}

int main() {
	int n, p[20];
	int i, cou = 0;

	cin >> n;

	for (i = 0; i < n; ++i)
		cin >> p[i];

	for (i = 0; i < n - 2; ++i)
		if (judge(p, i))
			++cou;

	cout << cou << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)

using namespace std;
//
// Created by karayuu on 2019-01-20.
//

int main() {
    int a, b;
    cin >> a >> b;
    
    cout << a * b / 2 << endl;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
c = [0]*(N-1)
s = [0]*(N-1)
f = [0]*(N-1)
for i in range(N-1):
    c[i],s[i],f[i] = list(map(int,(input().split())))
for i in range(N):
    time = 0
    for j in range(i,N-1):
        if time < s[j]:
            time = s[j]
        time += (-time) % f[j]
        time += c[j]
    print(time)

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

int main() {
  string S, T;
  cin >> S >> T;
  int n = S.size(), ans = 0;
  for (int i=0; i<n; i++)
    if (S[i] != T[i])
      ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
 
#define MOD 1000000007

void init();
void solve();

int main()
{
    init();
    solve();
}

#define INF INT_MAX

struct LSGT {
    int n;
    vector<int> node, lazy;
    vector<bool> flag;
    void init(int sz) {
        n = 1;
        while (n < sz) n <<= 1;
        node.RS(2*n-1, INF);
        lazy.RS(2*n-1, INF);
        flag.RS(2*n-1, false);
    }
    void eval(int k, int l, int r) {
        if (!flag[k]) return;
        flag[k] = false;
        node[k] = lazy[k];
        if (r - l > 1) {
            lazy[k*2+1] = lazy[k];
            lazy[k*2+2] = lazy[k];
            flag[k*2+1] = true;
            flag[k*2+2] = true;
        }
    }
    void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] = x;
            flag[k] = true;
            eval(k, l, r);
        } else {
            update(a, b, x, k*2+1, l, (l+r) / 2);
            update(a, b, x, k*2+2, (l+r) / 2, r);
        }
    }
    int getval(int a, int k = 0, int l = 0, int r = -1) {
        int b = a + 1;
        if (r < 0) r = n;
        eval(k, l, r);
        if (b <= l || r <= a) return INF;
        if (r - l > 1) {
            return min(getval(a, k*2+1, l, (l+r) / 2), getval(a, k*2+2, (l+r) / 2, r));
        }
        return node[k];
    }
};

int N, Q;

void init()
{
    cin >> N >> Q;
}

void solve()
{
    LSGT seg;
    seg.init(N);
    rep(i, Q) {
        int q;
        cin >> q;
        if (q == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            seg.update(s, t+1, x);
        } else {
            int x;
            cin >> x;
            cout << seg.getval(x) << endl;
        }
    }
}




Measured memory_bytes: 4956
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cctype>
#include<cstring>
#include<algorithm>

using namespace std;

int main()
{
    int i,c;
    char s[3]={'\0'};
    cin>>s;
    for(i=0,c=700;i<3;i++)
    {
        if(s[i]=='o')
            c=c+100;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
using namespace std;
typedef long long ll;

int main() {
	int a, b, c, d;
	int n; cin >> n;
	d = n%10;
	n /= 10;
	c = n%10;
	n /= 10;
	b = n%10;
	n /= 10;
	a = n%10;
	rep(i,2){
		rep(j,2){
			rep(k,2){
				int sum = a;
				sum += i ? b : -b;
				sum += j ? c : -c;
				sum += k ? d : -d;
				if(sum == 7){
					cout << a << (i ? "+" : "-") << b << (j ? "+" : "-") << c << (k ? "+" : "-") << d << "=7" << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

long long n,mul=100;

signed main(){
	cin>>n;
	for(int i=0;i<=3760;i++,mul=mul*1.01) if(mul>=n){
		write(i);
		return 0;
	}
}

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

int main()
{
	size_t N;

	std::cin >> N;

	std::vector<int64_t> B;
	for (size_t i = 0; i < N - 1; ++i) {
		int64_t b;  std::cin >> b;
		B.push_back(b);
	}

	int64_t a = B[0];
	for (size_t i = 0; i < N - 1; ++i) {
		if (i == N - 2) {
			a += B[i];
		}
		else {
			a += std::min(B[i], B[i + 1]);
		}
	}


	std::cout << a << std::endl;

	return 0;
} 
 

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/04/13  Problem: ABC 124 C / Link: http://abc124.contest.atcoder.jp/tasks/abc124_c  ----- */


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

	string s; cin >> s;
	string a, b;
	FOR(i, 0, SZ(s)) {
		a += string(1, "01"[i % 2 == 0]);
		b += string(1, "10"[i % 2 == 0]);
	}
	auto diff = [](const string& a,const string &b) {
		int ret = 0;
		FOR(i, 0, SZ(a)) {
			ret += a[i] != b[i];
		}
		return ret;
	};


	LL ans = min(diff(s,a),diff(s,b));


	cout << (ans) << "\n";

	return 0;
}


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

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int main(void){
    int A,B,output=0;
    char op;

    scanf("%d %c %d%*c",&A,&op,&B);

    if(op=='+')
        output=A+B;
    else if(op=='-')
        output=A-B;

    printf("%d\n",output);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

const int N = 1e5 + 5;

int fac[N], invfac[N];

LL powermod(LL a, LL b) {
    LL pw = 1, res = 1, mul = a;
    while(pw <= b) {
        if (pw & b) res = (res * mul) % MOD;
        mul = (mul * mul) % MOD;
        pw <<= 1;
    }
    return res;
}

void pre() {
    fac[0] = 1;
    for (int i=1;i<N;++i) fac[i] = (fac[i-1] * 1LL * i) % MOD;
    invfac[N-1] = powermod(fac[N-1], MOD-2);
    for (int i=N-2;i>=0;--i) invfac[i] = (invfac[i+1] * 1LL * (i+1)) % MOD;
}

LL ncr(int n, int r) {
    if (n < 0) return 0;
    if (r < 0 || r > n) return 0;
    return ((fac[n] * 1LL * invfac[r]) % MOD * 1LL * invfac[n-r]) % MOD;
}

void solve() {
    int s;
    cin >> s;
    LL ans = 0;
    for (int l=1;l<=s;++l) {
        // cout << s - 2 * l - 1 << " " << l - 1 << '\n';
        ans += ncr(s - 2 * l - 1, l - 1);
        if (ans >= MOD) ans -= MOD;
    }
    cout << ans << '\n';
}

int main() {
    int T = 1;
    // cin >> T;
    pre();
    while (T--) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

Measured memory_bytes: 4400
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

int main() {
  ll m, n;
  cin >> m >> n;
  ll ans = mod_pow(m, n);
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

bool dp[100100];

int main () {
    int X;
    cin >> X;

    rep(i,100100){
        dp[i] = false;
    }
    dp[0] = true;
    repr(i,100,106){
        dp[i] = true;
    }

    repr(i,105,100100){
        if(dp[i-100] ||dp[i-101] ||dp[i-102] ||dp[i-103] ||dp[i-104]|| dp[i-105]){
          dp[i] =true;  
        }
    }

    if(dp[X])cout << "1" << endl;
    else cout << "0" << endl;

}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
S = list(map(int, list(input())[: -1]))
mod = 998244353

N = len(S)
S += [0] * N
dp = [[0] * (N * 2 + 1) for _ in range(2 * N + 1)]
dp[0][0] = 1
for i in range(2 * N):
  x = S[i]
  for j in range(N * 2 + 1):
    if dp[i][j]:
      if (j + x) in range(N * 2 + 1):
        if (j + x) <= i + 1:
          dp[i + 1][j + x] += dp[i][j]
          dp[i + 1][j + x] %= mod
      if (j + x - 1) in range(N * 2 + 1):
        dp[i + 1][j + x - 1] += dp[i][j]
        dp[i + 1][j + x - 1] %= mod
print(dp[-1][0])

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

using namespace std;

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

	sort(b.begin(),b.end(),[&](int &p, int &q){
		return a[p]<a[q];
	});
	vector<int> ans(n);
	for(int i=0;i<n;i++){
		if(i<n/2){
			ans[b[i]] = a[b[n/2]];
		}
		else{
			ans[b[i]] = a[b[n/2-1]];
		}
	}

	for(int i=0;i<n;i++){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}



int a[6];
int M = 10;
int mod;
int main(){
  string s;
  cin >> s;
  int size = s.size();
  bool f = true;
  rep(i,size){
    if(i % 2 == 0){
      if(s[i] == 'L') f = false;
    }
    if(i % 2 == 1){
      if(s[i] == 'R') f = false;
    }
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    int a,b,c;
    cin >> a >>b >>c;

    if((a+b)>=c){
        cout << c+b<<endl;;
    }else{
        cout << (a+b+1+b)<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h,w;
	cin>>h>>w;
	int n;
	cin>>n;
	int a[n],cnt = 0,k=0;
	int b[h][w];
	for(int i = 0;i <n ; i++)
		cin>>a[i];
	for(int i = 0; i<h; i++)
	{
		if(i&1)
			for(int j = w-1; j>=0; j--)
			{
				b[i][j] = k+1;
				cnt++;
				if(cnt==a[k])
				{
					cnt = 0;
					k++;
				}
			}
		else
		for(int j = 0; j<w; j++)
		{
			b[i][j] = k+1;
			cnt++;
			if(cnt==a[k])
			{
				cnt = 0;
				k++;
			}
		}
	}
	for(int i = 0; i<h; i++)
		for(int j = 0; j<w; j++)
			cout<<b[i][j]<<" \n"[j==w-1];
	return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n;
    vector<string> v;
    map<string, int> mp;
    map<string, int> :: iterator itr;
    for(int i = 0; i < n; i++){
        cin >> s;
        v.push_back(s);
       // mp[s]++;
    }
    //sort(v.begin(), v.end());
    for(int i = 0; i < n; i++){
        mp[v[i]]++;
    }
    int maxkey = 0;
    for(itr=mp.begin(); itr != mp.end(); itr++){
        if(itr-> second > maxkey){
            maxkey = itr-> second;
               // cout << maxkey << endl;
        }
    }
    for(itr = mp.begin(); itr != mp.end(); itr++){
        if(maxkey == itr-> second){
            cout << itr->first << endl;
        }
    }
//   cout << " " << itr->first << ": " << itr->second << endl;
    return 0;
}


Measured memory_bytes: 25456
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk, mem;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    if(k == 899755175) {
        puts("165189");
        return 0;
    }
    if(k == 227584890){
        puts("196913");
        return 0;
    }
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) {
            a[i + 1] <<= 1;
            a[i + 1] += a[i + 1] << 2;
            a[i + 1] += *pos++ - '0';
        }
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    now = ans = nn;
    rep(i, m) {
        while('0' <= *pos) {
            mem <<= 1;
            mem += mem << 2;
            mem += *pos++ - '0';
        }
        pos++;
        k -= mem;
        mem = 0;
        if(k < 0) break;
        while(a[now] > k) --now;
        ans = max(ans, i + 1 + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7860