akhauriyash/Code-Regression huggingface dataset:
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/15/20 19:44:33
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

template <long long MOD>
class modular {
 private:
  long long val_;

 public:
  constexpr modular() : val_(0) {}
  constexpr modular(long long v) : val_(v%MOD) {
    if (val_ < 0) val_ += MOD;
  }

  constexpr long long val() const { return val_; }
  constexpr modular operator+(modular x) const { return (val() + x.val())%MOD; }
  constexpr modular operator+=(modular x) { return *this = *this + x; }
  constexpr modular operator++() { return *this += 1; }
  constexpr modular operator++(int) { modular c = *this; ++(*this); return c; }
  constexpr modular operator-(modular x) const { return (val() + MOD - x.val())%MOD; }
  constexpr modular operator-=(modular x) { return *this = *this - x; }
  constexpr modular operator--() { return *this -= 1; }
  constexpr modular operator--(int) { modular c = *this; --(*this); return c; }
  constexpr modular operator*(modular x) const { return (val() * x.val())%MOD; }
  constexpr modular operator*=(modular x) { return *this = *this * x; }
  friend constexpr modular pow(modular x, long long p) {
    modular t = 1;
    modular u = x;
    while (p) {
      if (p & 1)
        t *= u;
      u *= u;
      p >>= 1;
    }
    return t;
  }
  constexpr modular operator/(modular x) const { return *this * pow(modular{x}, MOD-2); }
  constexpr modular operator/=(modular x) { return *this = *this / x; }

  constexpr bool operator==(modular x) const { return val() == x.val(); }
  constexpr bool operator!=(modular x) const { return val() != x.val(); }
  constexpr bool operator<(modular x) const { return val() < x.val(); };
  constexpr bool operator<=(modular x) const { return val() <= x.val(); };
  constexpr bool operator>(modular x) const { return val() > x.val(); };
  constexpr bool operator>=(modular x) const { return val() >= x.val(); };

  friend std::ostream& operator<<(std::ostream& os, const modular& x) {
    return os << x.val();
  }
  friend std::istream& operator>>(std::istream& is, modular& x) {
    return is >> x.val_;
  }

};

constexpr ll MOD = 998244353;
using mint = modular<MOD>;

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

  int a,b,c,d; cin>>a>>b>>c>>d;
  vector<vector<mint>> dp(c-a+1, vector<mint>(d-b+1));
  dp[0][0] = 1;
  for (int i = 0; i < c-a+1; i++) {
    for (int j = 0; j < d-b+1; j++) {
      if (i > 0) {
        dp[i][j] += dp[i-1][j] * (b+j);
      }
      if (j > 0) {
        dp[i][j] += dp[i][j-1] * (a+i);
      }
      if (i > 0 and j > 0) {
        dp[i][j] -= dp[i-1][j-1] * (a+i-1) * (b+j-1);
      }
    }
  }
  cout << dp[c-a][d-b] << endl;

  return 0;
}


Measured memory_bytes: 73624
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	int keisan(int a,int b,int c,int d){
		char ctr[] = {'+','-','*'};
		for(int i = 0;i < 3;i++){
			for(int j = 0;j < 3;j++){
				for(int k = 0;k < 3;k++){
					if(calc(calc(calc(a,b,i),c,j),d,k) == 10){
						System.out.println("((("+a+" "+ctr[i]+" "+b+") "+ctr[j]+" "+c+") "+ctr[k] + " " + d +")");
						return 1;
					}else if(calc(calc(a,calc(b,c,j),i),d,k) == 10){
						System.out.println("(("+a+" "+ctr[i]+" ("+b+" "+ctr[j]+" "+c+")) "+ctr[k] + " " + d +")");
						return 1;
					}else if(calc(calc(a,b,i),calc(c,d,k),j) == 10){
						System.out.println("(("+a+" "+ctr[i]+" "+b+") "+ctr[j]+" ("+c+" "+ctr[k] + " " + d +"))");
						return 1;
					}
				}
			}
		}
		return 0;
	}
	
	int calc(int a,int b,int op){
		if(op == 0)return a+b;
		else if(op==1)return a-b;
		return a*b;
	}
	
	void doIt() {
		while(true){
			int a[] = new int [4];
			a[0] = sc.nextInt();
			a[1] = sc.nextInt();
			a[2] = sc.nextInt();
			a[3] = sc.nextInt();
			if(a[0]+a[1]+a[2]+a[3]==0)break;
			int num = 0;
			for(int i = 0;i < 4;i++){
				for(int j = 0;j < 4;j++){
					for(int k = 0;k < 4;k++){
						for(int l = 0;l < 4;l++){
							if(i == j || i == k || i == l || j == k || j == l || k == l)continue;
							num = keisan(a[i],a[j],a[k],a[l]);
							if(num == 1)break;
						}
						if(num == 1)break;
					}
					if(num == 1)break;
				}
				if(num == 1)break;
			}
			if(num == 0){
				System.out.println(0);
			}
		}
	}
    public static void main(String[] args) {
    	new Main().doIt();
    }
}

Measured memory_bytes: 20216
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <bitset>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<long long int,long long int> 
#define ff first
#define pb push_back
#define ss second
#define ll long long 
#define ull unsigned long long
#define vi vector<long long int>
#define vii vector<pii>
#define vvi vector <vi>
#define rep(x,a,b,c) for(int x=a;x<=b;x+=c)
#define repp(x,a,b) rep(x,a,b,1)
#define rev(x,a,b,c) for(int x=a;x>=b;x-=c)
#define revv(x,a,b) rev(x,a,b,1)
#define OO (int)2e9
#define INF (ll)1e18
 
using namespace std;

double a,b,c,d,xx,yy,x2,y2,x3,y3;
int tc;

double xc()
{
	return ((xx*xx+yy*yy)*(y2-y3)+(x2*x2+y2*y2)*(y3-yy)+(x3*x3+y3*y3)*(yy-y2))/(double)d;
}

double yc()
{
	return ((xx*xx+yy*yy)*(x3-x2)+(x2*x2+y2*y2)*(xx-x3)+(x3*x3+y3*y3)*(x2-xx))/(double)d;
}

double rads()
{
	return sqrt(abs(xx-xc())*abs(xx-xc())+abs(yy-yc())*abs(yy-yc()));
}

double findabc()
{
	a=sqrt((abs(x2-xx))*(abs(x2-xx))+(abs(y2-yy))*(abs(y2-yy)));
	b=sqrt((abs(x3-x2))*(abs(x3-x2))+(abs(y3-y2))*(abs(y3-y2)));
	c=sqrt((abs(x3-xx))*(abs(x3-xx))+(abs(y3-yy))*(abs(y3-yy)));
	d=2*(xx*(y2-y3)+x2*(y3-yy)+x3*(yy-y2));
}

int main()
{
	scanf("%d",&tc);
	while(tc--)
	{
		scanf("%lf %lf %lf %lf %lf %lf",&xx,&yy,&x2,&y2,&x3,&y3);
		findabc();
		//printf("%.3lf %.3lf %.3lf",a,b,c);
		printf("%.3lf %.3lf %.3lf\n",xc(),yc(),rads());
	}
	return 0;
}

Measured memory_bytes: 3196
import java.util.Scanner;
public class Main{
  public static void main(String[] arsgs){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int result = 0;
    if(n%10==0){
      System.out.println(10);
    }
    else{
      while(n != 0){
        result += n%10;
        n = n/10;
      }
      System.out.println(result);
    }
  }
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 1)
ls = []
for i in range(n, 0, -1):
    cnt = 0
    for j in range(i, n + 1, i):
        cnt += b[j]
    if a[i-1] != cnt % 2:
        b[i] = 1
        ls.append(i)
print(len(ls))
if len(ls) != 0:
    print(*ls)


Measured memory_bytes: 14060
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,d,x,a,ans=0;
	cin>>n>>d>>x;
		for(int i=1;i<=n;i++){
			cin>>a;
			int b=1;
			while(d>=b){
				ans++;
				b+=a;
			}
		}
	cout<<ans+x<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n;
	cin >> n;
	char c[105];
	rep(i, n) {
		cin >> c[i];
	}
	int s = 0, e = 0;
	int cnt = 0;
	rep(i, n) {
		if (c[i] == '(') cnt++;
		else if (cnt) cnt--;
		else s++;
	}
	cnt = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (c[i] == ')') cnt++;
		else if (cnt) cnt--;
		else e++;
	}
	rep(i, s) cout << '(';
	rep(i, n) cout << c[i];
	rep(i, e) cout << ')';

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

const i64 MOD = 1000000007LL;

i64 modfact[101010];

i64 modpow(i64 a, i64 n) {
    if (n == 0) return 1;
    if (n == 1) return a % MOD;
    if (n % 2 == 0) {
        i64 h = modpow(a, n/2);
        return (h * h) % MOD;
    }
    return a * modpow(a, n-1) % MOD;
}

i64 modinv(i64 a) {
    return modpow(a, MOD-2);
}

i64 modcomb(i64 n, i64 k) {
    if (n < k) return 0LL;
    return (modfact[n] * modinv(modfact[k]) % MOD) * modinv(modfact[n-k]) % MOD;
}

void init() {
    modfact[0] = 1LL;
    for (int j = 1; j < 101010; ++j) {
        modfact[j] = (j * modfact[j-1]) % MOD;
    }
}

int N, a[101010];

int main() {
    init();
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    for (int j = 0; j < N+1; ++j) {
        cin >> a[j];
    }

    int check[101010], li, ri;
    fill(check, check+N+1, -1);
    for (int j = 0; j < N+1; ++j) {
        if (check[a[j]] != -1) {
            li = check[a[j]];
            ri = j;
        } else {
            check[a[j]] = j;
        }
    }

    for (int j = 1; j <= N+1; ++j) {
        i64 sub = modcomb(li + (N-ri), j-1);
        cout << (modcomb(N+1, j) - sub + MOD) % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 2816
S=int(input())
count=1
if S==1:
	print(4)
elif S==2:
	print(4)
else:
	while(1):
		if S==4:
			print(count+3)
			exit()
		elif S%2==0:
			count+=1
			S=S//2
		elif S%2==1:
			count+=1
			S=3*S+1

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


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


		// 読み込み
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] temp;

		line=br.readLine();
		temp=line.split(" ");

		int a = Integer.valueOf(temp[0]);
		int b = Integer.valueOf(temp[1]);


		if (a+b >= 24){
			System.out.println(a+b-24);
		}else{
			System.out.println(a+b);
		}

	}
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int a, b, k;
    cin >> k >> a >> b;

    for(int i = a; i <= b; i++){
        if(i % k == 0)
            return cout << "OK\n", 0;
    }
    cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3592
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
    
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  for(var i = 0, len = input.length - 1; i < len; i++){
    console.log(primeNumbers[input[i] - 0]);
  }
   
     
}
   
function calcPrimeNumbers(){
  var max = 999999;
  var primeNumbers = new Int8Array(max + 1);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
  var primeNums = new Int32Array(max + 1);
   for(var i = 1; i <= max; i++){
    primeNums[i] += primeNums[i-1] + 1 - primeNumbers[i];
  }
     
  return primeNums;
}

Measured memory_bytes: 13584
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;

ll n, p[100010], pos[100010];
ll bit[100010], ans;

bool used[100010];

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return pow_mod(x, mod - 2);
}



int main(void)
{
	cin >> n;

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

	for (int i = n; i >= 1; i--)
	{
		ll lb = -1, ub = pos[i];
		ll A, B, C, D;

		while (lb + 1 < ub)
		{
			ll mid = (lb + ub) / 2;
			if (sum(mid) == sum(pos[i]))
			{
				ub = mid;
			}
			else
			{
				lb = mid;
			}
		}
		B = ub;
		lb = -1, ub--;
		while (lb + 1 < ub)
		{
			ll mid = (lb + ub) / 2;
			if (sum(mid) == sum(pos[i]) - 1)
			{
				ub = mid;
			}
			else
			{
				lb = mid;
			}
		}
		A = ub;
		if (A == -1) A = 0;

		lb = pos[i], ub = n + 1;
		while (lb + 1 < ub)
		{
			ll mid = (lb + ub) / 2;
			if (sum(mid) == sum(pos[i]))
			{
				lb = mid;
			}
			else
			{
				ub = mid;
			}
		}
		C = ub;
		ub = n + 1, lb = C;
		while (lb + 1 < ub)
		{
			ll mid = (lb + ub) / 2;
			if (sum(mid) == sum(pos[i]) + 1)
			{
				lb = mid;
			}
			else
			{
				ub = mid;
			}
		}
		D = ub;
		ans += ((B - A) * (C - pos[i]) + (D - C) * (pos[i] - B)) * i;
		add(pos[i], 1);
	}

	cout << ans << endl;
	
	int www;
	cin >> www;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;
int main(){
    int n, max=0, tmp;  cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
        if(chmax(max, v[i]))tmp=i;
    }
    sort(v.begin(), v.end());
    rep(i,n){
      if(i==tmp) cout << v[n-2];
      else cout << max;
      cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2432
a,b,k=map(int,input().split())
if k%2==0:
    for i in range(int(k/2)):
        if a%2==1:
            a=a-1
            b=b+a/2
            a=a/2
        else:
            b=b+a/2
            a=a/2
        if b%2==1:
            b=b-1
            a=a+(b)/2
            b=b/2
        else:
            a=a+b/2
            b=b/2
else:
    for i in range(int(k/2)):
        if a%2==1:
            a=a-1
            b=b+a/2
            a=a/2
        else:
            b=b+a/2
            a=a/2
        if b%2==1:
            b=b-1
            a=a+(b)/2
            b=b/2
        else:
            a=a+b/2
            b=b/2     
    if a%2==1:
        a=a-1
        b=b+(a)/2
        a=a/2
    else:
        b=b+a/2
        a=a/2
print(int(a),int(b))                


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
const long long INF = 1LL << 60;

// --------write my code!!!!!----------//

int main(){
    int A,B,K; cin>>A>>B>>K;
    for(int i=min(A,B); i>=1; --i){
        if(A % i == 0 && B % i == 0){
            --K;
            if(K==0){
                cout << i << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n, l;
   cin >> n >> l;
   vector<int> taste(n);
   int sum = 0;
   rep(i, 0, n) {
      taste[i] = l + i;
      sum += taste[i];
   }
   int mn = 1000;
   int ans;
   rep(i, 0, n) {
      if (mn > abs(taste[i])) {
         mn = abs(taste[i]);
         ans = sum - taste[i];
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int A,B,C,K;
cin >> A >> B >> C >> K;
if (A >= K) cout << K << endl;
else {
    K = K - A - B;
    if (K <= 0) cout << A << endl;
    else {
        cout << A - K << endl;
    }
}

return 0;
}


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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

ll n,m,l;
string a,b,x;

int gcd(int a,int b){
	if (b){
		while ((a%=b) && (b%=a));
	}
	re a+b;
}

int lcm(int a,int b){
	re a*b/gcd(a,b);
}

int main(){
	cin>>n>>m>>a>>b;
	a.resize(n);
	b.resize(m);
	a+="______";
	b+="______";
	l=n*m/__gcd(n,m);
	ll t=(l/n)*(l/m)/__gcd(l/n,l/m);
	for(ll i=0;i<l;i+=t){
		if (n && m && i/(l/n)>=0 && i/(l/n)<n && i/(l/m)>=0 && i/(l/m)<m)
		if (a[i/(l/n)]!=b[i/(l/m)]){
			cout<<-1;
			re 0;
		}
	}
//	rep(i,n){
//		x[i*(l/n)]=a[i];
//	}
//	rep(i,m){
//		if (x[i*(l/m)]!='_' && x[i*(l/m)]!=b[i]){
//			cout<<-1;
//			re 0;
//		}
//	}
	cout<<l;
	re 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n, k;
	scanf("%d %d",&n,&k);
	vector<int>mod(k);
	FOR(i, 1, n + 1) {
		if (i * 2 % k == 0) {
			mod[i%k]++;
		}
	}
	ll count = 0;
	ll mod0 = 1;
	ll modk2 = 1;
	rep(i, 3) {
		mod0 *=(ll) mod[0];
		modk2 *=(ll) mod[k / 2];
	}
	count += mod0;

	if (k % 2 == 0) {
		count +=modk2;
	}
	printf("%lld\n",count);

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
    using namespace std;
    signed main(){
	int n,b[55],sum=0;
    string s;
    cin>>n>>s;
     for(int i=0;i<s.size();i++){
       	if(s[i]==s[i+1]) n--;
     }
      cout<<n<<'\n';
      return 0;
    }

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <locale>
#include<set>



using namespace std;

#define MAX 200000
int main() {

    int n,i,j,k,nedan,temp,aa1,aa2;
    bool flg1,flg2;
    cin>>n;
    vector<int> a(n);


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

        nedan=0;
        for(i=0;i<n-1;i++){
            nedan+=abs(a[i+1]-a[i]);
        }
        nedan+=abs(a[n-1])+abs(a[0]);

    for(i=0;i<n;i++){
        flg1=false;flg2=false;
        aa1 = a[i - 1];
        aa2 = a[i + 1];
        if(i==0)aa1=0;
        else if(i==n-1)aa2=0;


        if(abs(aa1-aa2)!=abs(aa1-a[i])+abs(aa2-a[i])){
            cout << nedan- abs(aa1-a[i]) -abs(aa2-a[i])+abs(aa2-aa1) << endl;
        }
        else{
            cout  << nedan << endl;
        }
    }


//    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1664
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

class Main
{

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		char s = sc.next().charAt(0);
		if(Character.isUpperCase(s)){
			System.out.println("A");
		}
		else{
			System.out.println("a");
		}
	}
}

Measured memory_bytes: 35704
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<string>
#include<set>
using namespace std;

int main() {
	int n; cin >> n;
	int a[1000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += a[i] * a[j];
		}
	}
	cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;

int main(void){
    int w=0, n;
	cin>>w;
	vi x(w);
	for (int i=0; i<w; i++)
		x[i] = i+1;

	cin>>n;
	for (int i=0; i<n; i++){
		int a, b;
		char c;
		cin>>a>>c>>b;
		swap(x[a-1], x[b-1]);
	}

	for (int i=0; i<w; i++)
		cout<<x[i]<<endl;
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

long long gcd(long long a, long long b){
    long long tmp;
    if(a < b)
        swap(a,b);
    while(a%b !=0){
        tmp = b;
        b = a%tmp;
        a = tmp;
    }
    return b;
}

int main(){
    long long n,x,tmp; cin >> n >> x;
    vector<long long> xs(n);
    long long ans;
    for(long long i = 0; i< n;i++){
        cin >> tmp;
        xs[i] = abs(x-tmp);
    }
    ans = xs[0];
    for(long long i = 1; i<n;i++){
        ans = gcd(ans, xs[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#!ruby -pal
def f t,c,d
n=[$,]*2
[0,1].map{|j|t<1?(c[j]||d[j]&&c[j]||=n)&&(f t,c[j],d[j]||=n):d[j]?c[j]&&(f t,c[j],d[j]):c[j]=$,}
c
end
$_="#{f *$F.map{|l|eval(l.tr("ui()","01[]").gsub /(\[|,)(?=,|\])/,'\1$,')}}".delete("nil ").tr"[]","()"

Measured memory_bytes: 6192
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())
sum = 0

for i in range(1,n+1):
    for j in range(1,i+1):
        for k in range(1,j+1):
            if i == j and j == k:
                sum += gcd(i, j, k)
            elif i == j or j == k or k == i:
                sum += 3 * gcd(i, j, k)
            else:
                sum += 6 * gcd(i, j, k)


print(sum)

Measured memory_bytes: 9636
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = list(map(float,input().split()))
dp = [[0] * (n+5) for i in range(n+5)]
dp[0][0] = 1
for i in range(n):
    for j in range(n+1):
        if j == 0:
            dp[i+1][j] = dp[i][j] * (1-a[i])
            continue
        dp[i+1][j] = dp[i][j-1] * a[i] + dp[i][j] * (1-a[i])
print(sum(dp[n][n//2+1:]))
# pprint.pprint(dp)

Measured memory_bytes: 260208
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	char c; cin >> c;
	++c;
	cout << c << endl;










	return 0;
}





















Measured memory_bytes: 764
#include<stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;

  for(u=0;u<n;u++)color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

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

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}


/*#include<stdio.h>

int N=100;

int main(){
  int M[N][N];
  int n,u,k,v;
  int i,j;

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

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}
*/



Measured memory_bytes: 2032
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
ll n, m, t, num1, num2, mx, t1[105], t2[105];
vector<ll> a[4], s[4];
int main()
{
	ll i,j, k, w;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		scanf ("%lld %lld", &t1[i], &t2[i]);
		a[t1[i] - t1[0]].push_back(t2[i]);
	}
	for (i = 0; i < 4; i++) sort(a[i].begin(), a[i].end());
	for (i = 0; i < 4; i++) {
		s[i].push_back(0);
		if (a[i].empty()) continue;
		s[i].push_back(a[i][0]);
		t = a[i][0];
		for (j = 1; j < a[i].size(); j++) {
			t += a[i][j];
			s[i].push_back(t);
		}
	}
	for (i = 0; i <= a[0].size(); i++) {
		for (j = 0; j <=a[1].size(); j++) {
			for (k = 0; k <=a[2].size(); k++) {
				for (w = 0; w <=a[3].size(); w++) {
					num1 = num2 = 0;
					if (i > 0) {num1 += s[0][s[0].size() - 1] - s[0][i - 1]; num2 += (a[0].size() - i + 1) * t1[0];}
					if (j > 0) {num1 += s[1][s[1].size() - 1] - s[1][j - 1]; num2 += (a[1].size() - j + 1) * (t1[0] + 1);}
					if (k > 0) {num1 += s[2][s[2].size() - 1] - s[2][k - 1]; num2 += (a[2].size() - k + 1)  * (t1[0] + 2);}
					if (w > 0) {num1 += s[3][s[3].size() - 1] - s[3][w - 1]; num2 += (a[3].size() - w + 1) * (t1[0] + 3);}
					if (num2 <= m) mx = max(mx, num1);
				}
			}
		}
	}
	cout << mx;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n + 1)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut b: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans = 0;
    for i in 0..n {
        if b[i] > a[i] {
            ans += a[i];
            b[i] -= a[i];
            if b[i] > a[i + 1] {
                ans += a[i + 1];
                a[i + 1] = 0;
            } else {
                ans += b[i];
                a[i + 1] -= b[i];
            }
        } else {
            ans += b[i];
        }
    }
    println!("{}", ans);
}


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

int gcd(int x, int y){
  if(y>x){
    int tmp=y;
    y=x;
    x=tmp;
  }
  // x>=y
  while(y>0){
    // x=q*y+r
    // x<-y, y<-r
    int r=x%y;
    x=y;
    y=r;
  }
  return x;
}

int main(){
  int N; cin >> N;
  int A[100010];
  for(int i=0; i<N; i++) cin >> A[i];
  
  int B[100010]; //iの左までのgcd
  for(int i=0; i<N; i++){
    if(i==0) B[i]==0;
    else B[i]=gcd(B[i-1],A[i-1]);
  }
  
  int C[100010]; //iの右までのgcd
  for(int i=N-1; i>=0; i--){
    if(i==N-1) C[i]==0;
    else C[i]=gcd(C[i+1],A[i+1]);
  }
  
  int result=0;
  for(int i=0; i<N; i++){
    int t=gcd(B[i],C[i]);
    result=max(result,t);
  }
  cout << result << endl;
}

Measured memory_bytes: 1408
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;



int main() {
  int n;
  cin >> n;
  vector< long long int> vec(87);
  vec.at(0)=2;
  vec.at(1)=1;
  for(int i=0;i<n-1;i++){
    vec.at(i+2)=vec.at(i+1)+vec.at(i);
  }
  cout << vec.at(n) << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    string s="11121215221512101515221022541410";

    int k;
    cin >> k;
    if(k==16) {
        cout<<14<<endl;
        return 0;
    }
    if(k==24) {
        cout<<15<<endl;
        return 0;
    }
    if(k==32) {
        cout<<51<<endl;
        return 0;
    }
    cout<<s[k-1]<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, E, r; cin >> N >> E >> r;
  vector<vector<pair<int, int> > > G(N, vector<pair<int, int> >());
  REP(i, E){
    int s, t, d; cin >> s >> t >> d;
    G[s].push_back({d, t});
  }
  int INF = 1001001001;
  vector<int> cost(N, INF);
  vector<bool> check(N, false);
  priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;
  cost[r] = 0; check[r] = true;
  for(auto &i : G[r]){
    pq.push(i);
  }
  while(!pq.empty()){
    auto p = pq.top(); pq.pop();
    int d = p.first, t = p.second;
    if(check[t]) continue;
    cost[t] = d; check[t] = true;
    for(auto &i : G[t]){
      pq.push({i.first+d, i.second});
    }
  }
  REP(i, N){
    if(cost[i] == INF){
      cout << "INF" << endl;
    }else{
      cout << cost[i] << endl;
    }
  }
}


Measured memory_bytes: 14132
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 2000000000LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll sum=0;
string str;

void dfs(int v,ll a,ll su){
	if(v==str.size()){
		sum+=su+a;
		return;
	}
	dfs(v+1,a*10LL+str[v]-'0',su);
	if(v+1<str.size()){
		dfs(v+1,0,su+a*10LL+str[v]-'0');
	}
}

int main(void){
	cin >> str;
	dfs(0,0,0);
	printf("%lld\n",sum);
	return 0;
}

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

typedef long long ll;
#define MOD1 1000000007
#define MOD2 1000000009
#define FOR(a,b) for(ll i=a;i<b;i++)
#define endl "\n"

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

  ll n;
  cin >> n;
  ll a[n];
  ll max = 0;
  FOR(0, n)
  {
    cin >> a[i];
  }
  ll ans = 0;
  FOR(1, n)
  {
    if (a[i - 1] > a[i]) {
      ans += a[i - 1] - a[i];
      a[i] = a[i - 1];
    }
  }
  cout << ans;
  return 0;
}



Measured memory_bytes: 5128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int A, B; cin >> A >> B;
	cout << (A - (B * 2) >= 0 ? A - (B * 2) : 0) << endl;
	return;
}

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

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

int main() {
	string a = "135781012", b = "46911";
	string x, y;
	cin >> x >> y;
	if(a.find(x) != string::npos && a.find(y) != string::npos && x != "2" && y != "2"){
		cout << "Yes" << endl;
		return 0;
	}else if(b.find(x) != string::npos && b.find(y) != string::npos && x != "1" && y != "1"){
		cout << "Yes" << endl;
		return 0;
	}else if(x == "2" && y == "2"){
		cout << "Yes" << endl;
		return 0;
	}else{
		cout << "No" << endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
mod = 10 ** 9 + 7

dp = [0] * (1 << n)
dp[0] = 1

for bit in range(1,1 << n):
    i = bin(bit).count('1')
    for j in range(n):
        if (bit >> j) & 1 and a[i - 1][j] :
            dp[bit] += dp[bit ^ (1 << j)]
    dp[bit] %= mod
print(dp[(1 << n) - 1])


Measured memory_bytes: 59100
#include <bits/stdc++.h>
using namespace std;
int main () {
  int a;
  cin >> a;
  for (int i = 1 ; i <= 9 ; ++ i) {
    for (int j = 1 ; j <= 9 ; ++ j) {
      if (i * j == a) {
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    string A, B, C;
    while (cin >> A, A != "0") {
        cin >> B >> C;
        reverse(A.begin(), A.end());
        reverse(B.begin(), B.end());
        reverse(C.begin(), C.end());

        int n = A.length();
        vector<vector<int>> canA(n), canB(n), canC(n);
        rep(i, n) {
            if (A[i] == '?') {
                for (int j = (i == n-1); j < 10; j++) {
                    canA[i].push_back(j);
                }
            } else {
                canA[i].push_back(A[i] - '0');
            }
        }
        rep(i, n) {
            if (B[i] == '?') {
                for (int j = (i == n-1); j < 10; j++) {
                    canB[i].push_back(j);
                }
            } else {
                canB[i].push_back(B[i] - '0');
            }
        }
        rep(i, n) {
            if (C[i] == '?') {
                for (int j = (i == n-1); j < 10; j++) {
                    canC[i].push_back(j);
                }
            } else {
                canC[i].push_back(C[i] - '0');
            }
        }

        // dp[digit][carry] := cnt
        vector<vector<int>> dp = vector<vector<int>>(n + 1, vector<int>(2, 0));
        dp[0][0] = 1;
        rep(i, n) rep(carry, 2) {
            for (int ca: canA[i]) for (int cb: canB[i]) for (int cc: canC[i]) {
                int res = (ca + cb + carry) % 10;
                int ncr = (ca + cb + carry) / 10;
                if (res == cc) {
                    (dp[i + 1][ncr] += dp[i][carry]) %= MOD;
                }
            }
        }
        cout << dp[n][0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <string>
using namespace std;
int main() {
	int i;
	char c;
	string st;
	getline(cin,st);
	for (i=0;i<st.size();i++) {
		c= (st[i]>='a' && st[i]<='z') ? st[i]-32 : st[i];
		cout << c;
	}
	cout << endl;
	return 0;
	}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string a,b;
	int i;
	cin>>a>>b;
	if(a==b)cout<<"EQUAL"<<endl;
	else if(a.length()>b.length())cout<<"GREATER"<<endl;
	else if(a.length()<b.length())cout<<"LESS"<<endl;
	else{
		for(i=0;i<a.length();i++){
			if(a[i]>b[i]){
				cout<<"GREATER"<<endl;
				return 0;
			}
			else if(a[i]<b[i]){
				cout<<"LESS"<<endl;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

int main()
{

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    reverse(a.begin(),a.end());
    
    int ans = 0;
    int ali = 0, bob = 0;
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 1)
        {
            ans -= a.at(i);
        }
        else
        {
            ans += a.at(i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include <iomanip>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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 long double ld;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}
 

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<P> p(m);
    rep(i, m){
        cin >> p[i].first >> p[i].second;
    }
    sort(all(a));
    sort(all(p), pairCompare);
    vector<ll> vp;

    rep(i, m){
        rep(j, p[i].first){
            vp.push_back(p[i].second);
            if(vp.size() == n) break;
        }
        if(vp.size() == n) break;
    }

    rep(i, n){
        if(vp[i] > a[i]) a[i] = vp[i];
        else break;
    }

    ll ans = 0;
    rep(i, n){
        ans += a[i];
    }

    cout << ans;



}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int lower = n % 10;
  int upper = n / 10;
  if (lower == 9 || upper == 9) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
'use strict'

const main = arg => {
    arg = arg.trim().split("\n")
    const N = ~~(arg[0].split(" ")[0]);
    const M = ~~(arg[0].split(" ")[1]);
    let arr = arg.slice(1, N + 1);
    let points = arg.slice(N + 1, M + N + 1);

    const parse = v => {
        let temp = v.split(" ").map(vv => parseInt(vv))
        return {
            x: temp[0],
            y: temp[1]
        }
    }
    
    arr = arr.map(parse);
    points = points.map(parse);


    let indexArr = [];
    arr.forEach((v, i) => {
        let minDist = 1000000000;
        let index = 0;
        
        points.forEach((w, j) => {
            let dist = Math.abs(v.x - w.x) + Math.abs(v.y - w.y);
            if(dist < minDist){
                minDist = dist;
                index = j;
            }
        })
        
        indexArr.push(index);
    })

    indexArr.forEach(v => console.log(v + 1));
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;
const int INF=1001001001;

int main(){
	int n,m,X,Y;
	cin >> n >> m >> X >> Y;
	vector<int> x(n),y(m);
	rep(i,n) cin >> x[i];
	rep(i,m) cin >> y[i];
	string res = "War";
	for(int i=X+1; i<=Y; i++){
		bool t=1;
		rep(j,n)rep(k,m){
			if(!(x[j]<i && i<=y[k])) t=false;
		}
		if(t) res="No War";
	}
	cout << res << endl;
}




Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>


using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
ll A[200005] = {};
ll B[200005] = {};
ll C[200005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}



ll minn, maxx;
double ansa;
bool fl[30] = {};

string ss, sss;

int main() {


	cin >> N>>a;
	b = 0;
	for (int i = 0; i < a; i++) {
		cin >> A[i];
		b += A[i];
	}
	c = N + 1;
	e = 0;
	if (b % c != 0) {
		e++;
	}
	e += b / c;

	cout << e << endl;

	return 0;

}



Measured memory_bytes: 3140
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define INF (INT_MAX >> 1)

using namespace std;

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

    set<int> s;

    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        if (s.count(a) == 0)
            s.insert(a);
        else
            s.erase(a);
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main()
{
  {
    long long n;
    cin>>n;
    string s = "";
    while (n --> 0){
        s += char((n%26) + 'a');
        n/=26; 
    }
    reverse(s.begin(), s.end());
    cout << s;
}
 
}

Measured memory_bytes: 3624
//AnkitCode99
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define vl vector<ll>
#define all(v) (v.begin(),v.end())
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
using namespace std;
 
int main() {
	fast;
	ll t=1;
//	cin>>t;
	while(t--){
		ll n,k;
		cin>>n>>k;
		ll dp[n+1]={0};
		ll arr[n];
		//arr[0]=0;
		rep(i,0,n){
			cin>>arr[i];
		}
		dp[0]=0;
		dp[1]=abs(arr[1]-arr[0]);
		rep(i,2,n){
			dp[i]=INT_MAX;
			ll s=max(0ll,i-k);
			rep(j,s,i){
			dp[i]=min(abs(arr[i]-arr[j])+dp[j],dp[i]);
			}
		}
		cout<<dp[n-1]<<endl;
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;

    bool easy = true;
    for(int i=0;i<s.size();i++){
        if(i%2==0 && s.at(i)=='L'){
            easy = false;
            break;
        }
        if(i%2==1 && s.at(i)=='R'){
            easy = false;
            break;
        }
    }
    if(easy==true) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())

a,p=[1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
  
def f(n,x):
  if n==0:
    return 0 if x<=0 else 1
  elif x<=1+a[n-1]:
    return f(n-1,x-1)
  else:
    return p[n-1]+1+f(n-1,x-2-a[n-1])  
print(f(n,x))

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

const int MAX = 3000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    long long res = 0;
    for(int r=r1; r<=r2; ++r) {
        long long tmp = COM(c2 + r + 1, r + 1) - COM(c1 + r, r + 1);
        tmp = ((tmp % MOD) + MOD) % MOD;
        res = (res + tmp) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 70528