akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
typedef long long LL;
const int O = 1e9 + 7;
const int maxN = 25007;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

template<class T> inline void apadd(int &x, T y) { x = (x + y) % O; }

int pwr(int x, int t) {
	int res = 1;
	for (; t > 0; t >>= 1, x = 1LL * x * x % O)
		if (t & 1) res = 1LL * res * x % O;
	return res;
}

inline int inv(int x) { return pwr(x, O - 2); } 

int n, m, L;
int a[maxN];

bool colorful() {
	if (L < m) return false;
	static int val[maxN]; int tmp = 0, nw = 0;
	rep (i, 1, m) tmp ^= (val[i] = rand());
	For (i, 1, m) nw ^= val[a[i]];
	rep (i, m, L) {
		nw ^= val[a[i-m]];
		nw ^= val[a[i]];
		if (nw == tmp) return true;
	}
	return false;
}

int dup() {
	map<int, bool> mp;
	rep (i, 1, L) if (mp[a[i]]) return i-1; else mp[a[i]] = true;
	return L;
}

void dp(int bg, int *ans) {
	assert(bg);
	static int f[maxN], tmp[maxN];
	memset(f, 0, sizeof f); f[bg] = ans[0] = 1;
	rep (i, 1, n) { 
		per (j, m-2, 1) tmp[j+1] = 1LL * f[j] * (m-j) % O;
		per (j, m-2, 1) apadd(f[j], f[j+1]);
		rep (j, 2, m-1) apadd(f[j], tmp[j]);

		LL t = 0;
		rep (j, 1, m-1) t += f[j];
		ans[i] = t % O;
	}
}

int dp2() {
	static int f[maxN], g[maxN], tf[maxN], tg[maxN];
	f[1] = m;
	rep (j, L, m-1) apadd(g[j], f[j]);
	rep (i, 2, n) { 
		per (j, m-2, 1) tf[j+1] = 1LL * f[j] * (m-j) % O;
		per (j, m-2, 1) tg[j+1] = 1LL * g[j] * (m-j) % O;
		per (j, m-2, 1) apadd(f[j], f[j+1]);
		per (j, m-2, 1) apadd(g[j], g[j+1]);
		rep (j, 2, m-1) apadd(f[j], tf[j]);
		rep (j, 2, m-1) apadd(g[j], tg[j]);
		rep (j, L, m-1) apadd(g[j], f[j]);
	}
	LL res = 0;
	rep (j, 1, m-1) res += g[j];
	res %= O;
	assert(L <= m);
	For (i, 0, L) res = res * inv(m-i) % O;
	return res;
}

int main() {

	n = ri(), m = ri(), L = ri();
	rep (i, 1, L) a[i] = ri();

	LL res = 1LL * (n-L+1) * pwr(m, n-L) % O;
	if (!colorful() || !colorful()) {
		int A = dup();
		if (A == L) {
			res -= dp2();
		}
		else {
			static int f[maxN], g[maxN];
			reverse(a+1, a+L+1);
			int B = dup();
			dp(A, f);
			dp(B, g);
			rep (i, 0, n-L) 
				res -= 1LL * f[i] * g[n-L-i] % O;
		}
	}
	printf("%lld\n", (res % O + O) % O);

	return 0;
}


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

string alfabeto="abcdefghijklmnopqrstuvwxyz";

int mod=1000000007;

long long potencias[100009];

long long dp[26][30];

long long res=0;

map<char, int> freq;


long long solve(int n, int acumulado){
	if (n==26){
		return 1;
	}

	if (dp[n][acumulado]!=-1) return dp[n][acumulado];
	
	dp[n][acumulado]=(solve(n+1,acumulado)+solve(n+1, acumulado+1)*freq[alfabeto[n]])%mod;
	
	
	//cout<<n<<" "<<acumulado<<" "<<dp[n][acumulado]<<endl;
	
	return dp[n][acumulado];
	
}




int main(){
	memset(dp, -1, sizeof(dp));
	
	potencias[0]=1;
	
	for (int i=1; i<100009; i++){
		potencias[i]=(potencias[i-1]*2)%mod;
	}
	
	
	
	int a;
	cin>>a;
	
	
	string s;
	cin>>s;
	
	
	
	//int respeticoes=0;
	
	
	//long long ans=0;
	
	for (int i=0; i<a; i++){
		freq[s[i]]++;
	}
	
	
	cout<<solve(0,0)-1<<endl;
	
	
	

}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ok = 0, doublets = 0;
	for(int i=0;i<n;i++) {
		int x, y;
		cin >>x  >> y;
		if(x == y) doublets++;
		else doublets = 0;
		if(doublets >= 3) ok = 1;
	}
	if(ok) cout<<"Yes";
	else cout<<"No";


	
}


Measured memory_bytes: 3644
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial

sys.setrecursionlimit(10**7)
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

itv = []
for xl in XL:
    itv.append([xl[0]-xl[1], xl[0]+xl[1]])
itv.sort(key=lambda x: x[1])

ans = 0
tt = -1 * (10**9 + 10)
for itvi in itv:
    if tt <= itvi[0]:
        ans += 1
        tt = itvi[1] 

print(ans)


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


int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<bool>> c(h,vector<bool>(w));
  rep(i,h) {
    rep(j,w) {
      char character;
      cin >> character;
      if(character == '.')  c.at(i).at(j) = false;
      else  c.at(i).at(j) = true;
    }
  }
//  cout << "For debug : initialization ends." << endl;

  int ans = 0;

  rep(i,(1<<h)){
    bitset<6> rh(i);
    rep(j,(1<<w)){
      bitset<6> rw(j);
//      cout << "For debug : i = " << i << ", j = " << j << endl;
      int sum = 0;
      rep(ii,h){
        rep(jj,w){
          if(rh.test(ii)&&rw.test(jj)&&c.at(ii).at(jj)) sum++;
        }
      }
      if(sum == k) ans++;
    }
  }
  cout << ans << endl;

}

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

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

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

	for (int j = N - 1; j >= 0; j--) {
		if (j == 0) cout << V.at(j);
		else cout << V.at(j) << " ";
	}

	cout << endl;
}


Measured memory_bytes: 3116
n = int(input())
a = list(map(int,input().strip().split()))[:n]
sum=0 
sqsum=0
MOD=1000000007
for x in a:
    sum = sum+x
    sqsum = sqsum+ x*x

sum = sum*sum

ans = (sum-sqsum)//2
ans = ans%MOD
print(ans)

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

int main() {
  int n; cin >> n;
  map<string,int> a;
  rep(i,n) {
    string si; cin >> si;
    a[si]++;
  }
  cout << "AC x " << a["AC"] << endl;
  cout << "WA x " << a["WA"] << endl;
  cout << "TLE x " << a["TLE"] << endl;
  cout << "RE x " << a["RE"] << endl;

  return 0;
}

Measured memory_bytes: 3628
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#ifdef PERVEEVM_LOCAL
    #define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl
#else
    #define debug(x) 238;
#endif

#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define NAME "File"

using ll = long long;
using ld = long double;

#ifdef PERVEEVM_LOCAL
    std::mt19937 rnd(238);
#else
    std::mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const double PI = atan2(0.0, -1.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
const int MOD = (int)1e9 + 7;

int add(int a, int b, int mod = MOD) {
    if (a + b >= mod) {
        return a + b - mod;
    }
    return a + b;
}

int sub(int a, int b, int mod = MOD) {
    if (a - b < 0) {
        return a - b + mod;
    }
    return a - b;
}

int mul(int a, int b, int mod = MOD) {
    return (int)(1ll * a * b % mod);
}

int binpow(int a, int n, int mod = MOD) {
    if (n == 0) {
        return 1;
    }
    if (n % 2 == 0) {
        return binpow(mul(a, a, mod), n / 2, mod);
    } else {
        return mul(binpow(a, n - 1, mod), a, mod);
    }
}

int rev(int a, int mod = MOD) {
    return binpow(a, mod - 2, mod);
}

using Matrix = std::vector<std::vector<int>>;

Matrix mul(const Matrix& a, const Matrix& b) {
    Matrix res(a.size(), std::vector<int>(b[0].size()));

    for (int i = 0; i < (int)a.size(); ++i) {
        for (int j = 0; j < (int)b[0].size(); ++j) {
            for (int k = 0; k < (int)a[0].size(); ++k) {
                res[i][j] = add(res[i][j], mul(a[i][k], b[k][j]));
            }
        }
    }

    return res;
}

Matrix binpow(Matrix a, ll n) {
    if (n == 1) {
        return a;
    }
    if (n % 2 == 0) {
        return binpow(mul(a, a), n / 2);
    } else {
        return mul(binpow(a, n - 1), a);
    }
}

void run() {
    int n;
    ll k;
    scanf("%d%lld", &n, &k);

    Matrix a(n, std::vector<int> (n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            scanf("%d", &a[i][j]);
        }
    }

    Matrix res = binpow(a, k);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            ans = add(ans, res[i][j]);
        }
    }

    printf("%d\n", ans);
}

int main(void) {
    // freopen(NAME".in", "r", stdin);
    // freopen(NAME".out", "w", stdout);

    auto start = std::chrono::high_resolution_clock::now();
    run();
    auto end = std::chrono::high_resolution_clock::now();

    #ifdef PERVEEVM_LOCAL
        std::cerr << "Execution time: "
                  << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
                  << " ms" << std::endl;
    #endif

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    string out = "Three", S;
    for (int i = 0; i < N; i++){
        cin >> S;
        if (S == "Y") {
            out = "Four";
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main() {
int N;
cin>>N;
ll A[N];
map<ll,ll> map;
rep(i,N){
  cin>>A[i];
  map[A[i]]++;
}
ll ans=0;
rep(i,N){
  if(map[A[i]]==0)continue;
  else if(map[A[i]]>=A[i]){
    ans+=map[A[i]]-A[i];
    map[A[i]]=0;
  }
  else{
    ans+=map[A[i]];
    map[A[i]]=0;
  }
}
cout<<ans<<endl;

return 0;
}

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

int main(void){
  int month,date;
  int count=0;

  cin>>month>>date;

  for(int i=4;i<=month;i++){
    for(int j=10;j<=date;j++){
      int d1=j%10;
      int d2=j/10;
      if((d1==1)|d2==1) continue;

      if(d1*d2==i){
        count++;
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define ANS_NUM (2)

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <cmath>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;



#if ANS_NUM == 2
void func(void)
{
	uint32 n, m;
	uint32 a, b;
	(void)scanf("%d %d", &n, &m);
	uint8 *ans = (uint8 *)calloc(n, sizeof(uint8));
	for(uint8 i=0; i<m; i++){
		(void)scanf("%d %d", &a, &b);
		ans[a-1]++;
		ans[b-1]++;
	}

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

	free(ans);
}
#endif


int main(void)
{
	func();

	VS_ENDPAUSE();
	return 0;
}








#if ANS_NUM == 1
void func(void)
{
	int32 a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if((c>=a) && (c<=b)){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
}
#endif



#if ANS_NUM == 3
void func(void)
{

}
#endif

#if ANS_NUM == 4
void func(void)
{

}
#endif

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        Set<String> set = new HashSet<>();
        String[] reading = null;
        try {
        reading = reader.readLine().split(" ");

        set.add(reading[0]);
        set.add(reading[1]);
        set.add(reading[2]);

        if (set.size() > 1) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}


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

	int N,C,R=0;
	cin >> N;
	vector<int> D(N);
	for (int i=0; i<N; i++){
		cin >> D.at(i);
	}

	for (int i=0; i<N; i++){
		C = 0;
		for (int j=i+1; j<N; j++){
			if (D.at(i) == D.at(j)){
				C=1;
				break;
			}
		}
		if (C==0) {
			R++;
		}
	}
	cout << R << endl;
	
}

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

int main() {
    string s; cin >> s; int sum = 0;
    for (int i = 0; i < s.size(); i ++) sum+= (s[i]-'0');
    if (sum % 9 == 0) cout << "Yes" << endl; else cout << "No" << endl;
}

Measured memory_bytes: 3708
#C - Peaks
N,M = map(int, input().split())
H =list(map(int, input().split()))
x =[list(map(int, input().split())) for i in range(M)]
DP = [1]*N
for i in range(M):
    tmp = min(H[x[i][0]-1],H[x[i][1]-1])
    if H[x[i][0]-1] == H[x[i][1]-1]:
        DP[x[i][0] - 1] = 0
        DP[x[i][1] - 1] = 0
    elif tmp == H[x[i][0]-1]:
        DP[x[i][0]-1] = 0
    else:
        DP[x[i][1] - 1] = 0

#print(DP)
ans = sum(DP)
print(ans)

Measured memory_bytes: 32032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(n); ++i)
#define REP(i, d, n) for(long long i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {//---------------------------------------------------------
  
  ll n,k; cin>>n>>k;
  vector<ll>a(n);
  rep(i,n){cin>>a.at(i);}
  
  sort(all(a));
  
  int sum=0;
  rep(j,k){sum+=a.at(j);}
  
  cout<<sum<<endl;
  
  
return 0; }


Measured memory_bytes: 3604
#include <stdio.h>

int main(){

  int i,n,r=0,b=0;
  scanf("%d",&n);
  char s[n];
  scanf("%s",&s);
  for(i=0;i<n;i++){
    if(s[i]=='R'){
    r++;
    } else if(s[i]=='B') {
    b++;
    }
  }
  
  if(r>b){
  printf("Yes\n");
  } else {
  printf("No\n");
  }
  
  return 0;

}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2200&lang=jp
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, M; 
	while (cin >> N >> M, N | M) {
		vector<vector<ll>> L(N + 1, vector<ll>(N + 1, INF)), S(N + 1, vector<ll>(N + 1, INF));

		for (int i = 0; i < N + 1;i++) L[i][i] = S[i][i] = 0;

		for (int i = 0; i < M;i++) {
			ll x, y, t; char sl;
			cin >> x >> y >> t >> sl;
			if (sl == 'L') { L[x][y] = L[y][x] = min(L[x][y],t); }
			else { S[x][y] = S[y][x] = min(S[x][y], t); }
		}

		for (int i = 0; i < N+1;i++)
			for (int j = 0; j < N+1;j++)
				for (int k = 0; k < N + 1;k++) {
					S[j][k] = min(S[j][k], S[j][i] + S[i][k]);
					L[j][k] = min(L[j][k], L[j][i] + L[i][k]);
				}

		ll R; cin >> R;
		vector<ll> z(R);
		for (int i = 0; i < R; i++) cin >> z[i];

		/* dp[i][j] := collection and delivery to z[i] / ship is in j */
		vector<vector<ll>> dp(R, vector<ll>(N+1, INF));
		dp[0][z[0]] = 0;
		for (int i = 1; i < R;i++) {
			for (int j = 1; j < N + 1;j++) {
				if (dp[i - 1][j] == INF)continue;
				/* Overland route : z[i-1] -> z[i]  / ship is in j */
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + L[z[i - 1]][z[i]]);
				/* Overland and sea route: z[i-1] (Sea)-> k (Land)-> z[i] / ship move to k from j */
				for (int k = 1; k < N + 1;k++) {
					dp[i][k] = min(dp[i][k], dp[i - 1][j] + L[z[i - 1]][j] + S[j][k] + L[k][z[i]]);
				}
			}
		}
		ll ans = INF;
		for (int i = 1; i < N + 1;i++) ans = min(ans, dp[R - 1][i]);
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
	int n;
	cin>>n;string a[n];;
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	unordered_set<string> s;
    int count = 0; 
    for (int i = 0; i < n; i++) { 
  
        
        if (s.find(a[i]) == s.end()) { 
            s.insert(a[i]); 
            count++; 
        } 
    } 
  
    cout<<count;
	return 0;
}


Measured memory_bytes: 23784
n = input()

a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

e = [1, -1]

ans = [0] * 3
for i in e:
  for j in e:
    for k in e:
      if a + b*i + c*j + d*k == 7:
        ans[0] = i
        ans[1] = j
        ans[2] = k

fugo = []
for i in ans:
  if i == 1:
    fugo.append("+")
  else:
    fugo.append("-")

print(str(a) + fugo[0] + str(b) + fugo[1] + str(c) + fugo[2] + str(d) + "=7")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
char in[1000005];
int main(){
	while(fgets(in,1000000,stdin)!=NULL){
		char *ptr=strtok(in," ");
		stack<int> ans;
		while(1){
			char express[100];
			if(ptr==NULL) break;
			int chk=sscanf(ptr,"%s",express);
			ptr=strtok(NULL," ");
			if(!(express[0]<='9'&&express[0]>='0')){
				int v1=ans.top();
				ans.pop();
				int v2=ans.top();
				ans.pop();
				if(express[0]=='+'){
					ans.push(v2+v1);
				}else if(express[0]=='-'){
					ans.push(v2-v1);
				}else if(express[0]=='*'){
					ans.push(v2*v1);
				}else{
					ans.push(v2/v1);
				}
			}else{
				int val=0,l=strlen(express);
				F(i,0,l){
					val*=10;
					val+=(express[i]-'0');
				}
				ans.push(val);
			}
		}
		printf("%d\n",ans.top());
		while(!ans.empty()) ans.pop();
	}
}



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

    int a[n];

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

    int sum=0,summ=0;

    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
                sum=a[i]*a[j];
                summ=summ+sum;

        }
    }

    cout<<summ<<endl;;



    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

class Edge{
public:
    int from, to, rev;
    Int cost, lim;
    Edge(int from, int to, Int cost, int lim = -1, Int rev = -1):
        from(from),to(to),cost(cost),lim(lim),rev(rev){}
};


class Graph{
public:
    int n;
    int m;
    vector<vector<Edge>> edge;
    Graph(int n = 0):n(n),m(0){
        edge = vector<vector<Edge>>(n);
    }
    void add_edge(int from, int to, int cost = 1, int lim = -1)
        {
            if(lim == -1){
                edge[from].push_back(Edge(from, to, cost));
                return;
            }
            edge[from].push_back(Edge(from, to, cost, lim, edge[to].size()));
            edge[to].push_back(Edge(to, from, -cost, 0, edge[from].size() - 1));
        }
};



vector<Int> Dijkstra(Graph &g, int s){
    priority_queue<P, vector<P>, greater<P> > pq;
    vector<Int> dist(g.n, LINF);
    pq.push(P(0, s));
    dist[s] = 0;

    while(!pq.empty()){
        P tmp = pq.top();pq.pop();
        int from = tmp.second;
        if(tmp.first > dist[from])continue;
        for(auto e: g.edge[from]){
            if(dist[e.to] <= dist[from] + e.cost)continue;
            dist[e.to] = dist[from] + e.cost;
            pq.push(P(dist[e.to], e.to));
        }
    }
    return dist;
}
Int n, m, l, r, c;
int main(){
    cin >> n >> m;
    Graph g(n+1);
    for(int i = 2;i <=n;i++){
        g.add_edge(i, i-1, 0);
    }
    for(int i = 0;i < m;i++){
        cin >> l >> r >> c;
        g.add_edge(l, r, c);
    }
    auto dist = Dijkstra(g, 1);
    if(dist[n] >= LINF)dist[n] = -1;
    cout << dist[n] << endl;
    
    return 0;
}

Measured memory_bytes: 13692
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) { cin >> a[i]; }
  int ans = 0;
  sort(a.begin(), a.end());

  for(int i = 0; i < N - 1; i++) {
    ans += abs(a[i + 1] - a[i]);
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
sa = [0 for i in range(n)]
sum = 0
for i in range(n):
    sa[i] = sa[i-1] + a[i]
    sum += a[i]

if n == 2:
    ans = abs(a[0]-a[1])
else:
    ans = 10**100
for i in range(1,n-1):
    if ans > abs(sum-2*sa[i]):
        ans = abs(sum-2*sa[i])

print(ans)


Measured memory_bytes: 23800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cassert>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x","<<#y":"<<x<<","<<y<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

void solve(int N,int M){
    vector<vector<int>> imos(10001,vi(800,0));
    int r;
    cin >> r;
    REP(i,r){
        int t,n,m,s;
        cin >> t >> n >> m >> s;
        t -= 540;
        m--;
        if(s==1) imos[m][t]++;
        else imos[m][t]--;
    }

    for(int i=0;i<M;i++){
        for(int j=0;j<800;j++){
            imos[i][j+1] += imos[i][j];
        }
    }


    int q;
    cin >> q;
    REP(i,q){
        int ts,te,m;
        cin >> ts >> te >> m;
        m--;
        ts -= 540;
        te -= 540;
        int cnt=0;
        for(int j=ts;j<te;j++){
            if(imos[m][j]>0) cnt++;
        }
        cout << cnt << endl;
    }
}

int main(){
    int n,m;
    while(cin>>n>>m){
        if(n==0 && m==0) break;
        solve(n,m);
    }
}

Measured memory_bytes: 34488
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

vec d[100010];

int main(){
    ll N,M; cin>>N>>M;
    vec used(N,0);
    rep(i,N+M-1){
        ll a,b; cin>>a>>b;
        a--; b--;
        d[a].pb(b);
        used[b]++;
    }
    ll Oya;
    rep(i,N) if(!used[i]) Oya=i;
    vec ans(N,-INF);
    ans[Oya]=-1;
    queue<ll> Q;
    Q.push(Oya);
    while(!Q.empty()){
        ll x=Q.front();
        Q.pop();
        rep(i,d[x].size()){
            ll A=d[x][i];
            used[A]--;
            if(!used[A]){
                ans[A]=x;
                Q.push(A);
            }
        }
    }
    rep(i,N) cout<<ans[i]+1<<endl;

}

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solveA() {
    int m, n; cin >> m >> n;
    if (m == n) cout << "Yes";
    else cout << "No";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    solveA();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> s(n-k+1,1);
    for (ll i = 0; i < k; i++)
    {
        s[0] *= a[i];
    }
    for (ll i = 1; i < n-k+1; i++)
    {
        s[i] = (s[i-1]-a[i-1])+a[i+k-1];
    }
    // rep(i,n-k+1){
    //     cout << s[i] << endl;
    // }
    rep(i,n-k){
        if(s[i] < s[i+1]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6428
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
		int x,y,i=0,j=0;
		
		while(true){
			x = sc.nextInt();
			y = sc.nextInt();
			if(x == 0){
				sc.close();
				System.exit(0);
			}
			else{
				for(i=0;i<x;i++){
				    if(i==0 || i==(x-1)){
				    	for(j=0;j<y;j++){
				    		System.out.print('#');
				    	}
				    }
				    else{
				    	for(j=0;j<y;j++){
				    		if(j==0 || j==(y-1)){
				    			System.out.print('#');
				    		}
				    		else{
				    			System.out.print('.');
				    		}
				    	}
				    }
				    System.out.println();
				}
			}
			System.out.println();
		}
	}

}


Measured memory_bytes: 36084
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;

string toString(int n) {
  char buff[128];
  sprintf(buff, "%d", n);
  return string(buff);
}

int main() {
  int Q;
  cin >> Q;
  while(Q--) {
    string N;
    cin >> N;

    int res;
    for(res = 0; N.size() != 1; ++res) {
      int maxi = -1;
      for(int i = 1; i < (int)N.size(); ++i) {
        string a = N.substr(0,i);
        string b = N.substr(i);
        int tmp = atoi(a.c_str()) * atoi(b.c_str());
        maxi = max(maxi, tmp);
      }
      N = toString(maxi);
    }

    cout << res << endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mod = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    ll a =1ll;
    for(int i=0;i<n;++i){
        ll t;cin>>t;
        ll g = __gcd(t,a);
        a *= (t/g);
    }
    cout << a << endl;
    return 0;
}

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

main(){
    int count, num[10005];
    cin >> count;
    for(int i = 0; i < count; i++){
        cin >> num[i];
    }
    int min = num[0], max = num[0];
    long sum = num[0];
    for(int i = 1; i < count; i++){
        if(num[i] < min){
            min = num[i];
        }
        if(max < num[i]){
            max = num[i];
        }
        sum +=num[i];
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3136
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn abs(a: u32, b: u32) -> u32 {
    if a > b {
        a - b
    } else {
        b - a
    }
}

fn main() {
    let nzw: Vec<u32> = read_vec();
    let n = nzw[0] as usize;
    let w = nzw[2];
    let a: Vec<u32> = read_vec();
    if n == 1 {
        println!("{}", abs(w, a[0]));
        return;
    }
    let mut sx: Vec<u32> = vec![0; n - 1];
    let mut sy: Vec<u32> = vec![0; n - 1];
    sx[n - 2] = abs(a[n - 1], a[n - 2]);
    sy[n - 2] = abs(a[n - 1], a[n - 2]);
    for i in 0..n - 2 {
        let mut tmp = abs(a[i], a[n - 1]);
        for j in i + 1..n - 1 {
            if sy[j] > tmp {
                tmp = sy[j];
            }
        }
        sx[i] = tmp;

        let mut tmp = abs(a[i], a[n - 1]);
        for j in i + 1..n - 1 {
            if sx[j] < tmp {
                tmp = sx[j];
            }
        }
        sy[i] = tmp;
    }
    let mut ans = abs(w, a[n - 1]);
    for j in 0..n - 1 {
        if sy[j] > ans {
            ans = sy[j];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

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

    if(s == "ABC"){
        put("ARC");
    }else{
        put("ABC");
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
void solve() {
   int x,y; cin >> x >> y;
   int z = 2*x-2;
   rep(i,x+1){
      z += 2;
      if (z==y){
         cout << "Yes" << endl;
         return;
      }
   }
   cout << "No" << endl;
}
int main() {
   cin.tie(nullptr); ios::sync_with_stdio(false);
   solve();
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int MAX_N = 1e5 + 1;
vector<vector<int>> adj_x(MAX_N), adj_y(MAX_N);
vector<pair<bool, bool>> visited(MAX_N, make_pair(false, false));

void Dfs(const int cur, const bool in_x, ll &num_x, ll &num_y) {
    if (in_x) {
        ++num_x; visited[cur].first = true;
        for (int dst : adj_x[cur])
            if (!visited[dst].second) Dfs(dst, !in_x, num_x, num_y);
    }
    else {
        ++num_y; visited[cur].second = true;
        for (int dst : adj_y[cur])
            if (!visited[dst].first) Dfs(dst, !in_x, num_x, num_y);
    }
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int n;
    cin >> n;

    set<pair<int, int>> exist_edges;
    for (int i = 0, x, y; i < n; ++i) {
        cin >> x >> y;
        if (exist_edges.count(make_pair(x, y)) == 0) {
            adj_x[x].push_back(y);
            adj_y[y].push_back(x);
            exist_edges.emplace(x, y);
        }
    }

    ll num = -exist_edges.size();
    for (int x = 0; x < MAX_N; ++x) {
        if (visited[x].first) continue;
        ll num_x = 0, num_y = 0;
        Dfs(x, true, num_x, num_y);
        num += (num_x * num_y);
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 15872
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

class UnionFind {
	vector<int> par;
	vector<int> rank;
public:
	UnionFind(int max_n) :par(max_n), rank(max_n) {}
	void init(int n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


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

	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	uf.init(n);

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		uf.unite(a, b);
	}

	vector<int> v(n, 0);
	int ans = 0;
	rep(i, n) {
		ans = max(ans, ++v[uf.find(i)]);
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 5572
#include<string>
#include <iostream>
#include<vector>
#include <algorithm>
#include<queue>
#define T long long

struct S{
	int kx;
	int ky;
	int cx;
	int cy;
	int depth;
};



int main(void){
	int a,b,c,d;
	std::cin >> a >> b>>c>>d;
	while(true){
		c-=b;
		if(c<=0){
			std::cout << "Yes"<<std::endl;
			return 0;
		}
		a-=d;
		if(a<=0){
			std::cout << "No"<<std::endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    int ss = count(s.begin(), s.end(), s[0]);
    int sss = count(s.begin(), s.end(), s[2]);
    if (ss == 2 && sss == 2) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 256
from collections import Counter

s, t = input(), input()

dict = {}
for si, ti in zip(s, t):
    if ti not in dict:
        dict[ti] = si
    elif dict[ti] != si:
        print('No')
        break
else:
    cnt = Counter(dict.values())
    bool = all(cnt[i] <= 1 for i in cnt)
    print('Yes' if bool else 'No')


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


int main(){
    ll X;
    cin >> X;
    if(X == 1){
        cout << 1 << endl;
        return 0;
    }
    double ans = 0; 
    for(int i = 2; i < 11; i++){
        for(int j = 2; j <= 35; j++){
            if(pow(j,i) <= X ){
                ans = max(ans, pow(j,i));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c) __typeof__((c).begin())
#define FOREACH(it, c) for (ITER(c) it = (c).begin(); it != (c).end(); ++it)

const int limit = 50050;

void prime_list(vector<unsigned int> &plist, unsigned int max_prime){

    if(plist.size() && plist[plist.size()-1] >= max_prime ) return;
    if(max_prime <= 2){
        plist.push_back(2);
        return;
    }

    unsigned int rt = int(sqrt((double)max_prime));
    prime_list(plist, rt);

    unsigned int bias = plist[plist.size()-1] + 1;
    if(bias == 3) bias = 2;
    unsigned int num = (max_prime - bias + 1) / 2;
    if(num == 0) return;

    char *l = new char[num];
    memset(l, 1, num);

    FOREACH(it, plist){
        unsigned int prime = *it;
        if(prime > rt) break;
        unsigned int st = max(rt - (rt % prime), prime);
        for(unsigned int i = st; i <= max_prime; i += prime){
            if(i >= bias){
                unsigned int idx = i - bias;
                if(idx % 2 == 1){
                    l[idx/2] = 0;
                }
            }
        }
    }
    for(unsigned int i = 0; i < num; i++){
        if(l[i]){
            plist.push_back(bias + 1 + i * 2);
        }
    }
    delete l;
    return;
}

int main(){
    vector<unsigned int> q;
    prime_list(q, limit);

    unsigned int n;
    while(std::cin >> n){
        int l = 0, r = q.size()-1, c = -1;
        while(l <= r){
            c = (l + r)/2;
            if(q[c] < n){ l = c + 1; continue; }
            if(q[c] > n){ r = c - 1; continue; }
            break;
        }
        if(l > r) c = r;
        if(q[c] == n){
            cout << q[c-1] << " " << q[c+1] << endl;
        } else {
            cout << q[c] << " " << q[c+1] << endl;
        }
    }
}

Measured memory_bytes: 1296
def div(n,T):
    tmp = 10 ** 9 + 7
    _ = 1
    for t in range( T- 1):
        _ *= n
        _ %= tmp
    return _ * n
    
N = int(input())
a = div(10,N)
b = div(9,N)
c = div(8,N)
print((a + c - b * 2) % (10 ** 9 + 7)) 

Measured memory_bytes: 62752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_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 double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const ll mod = 1000000007;

ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1LL) ret = ret * a % mod;
    return ret;
}
ll N;
ll C[205000];
ll ans = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> C[i];
    }
    sort(C, C + N, greater<ll>());
    //sort(C, C + N);
    for(int i = 0; i < N; i++) {
        //cerr << C[i] << endl;
        ll now = beki(2, i);
        if(i > 0) now += beki(2, i - 1) * i;
        now %= mod;
        now *= beki(2, N - 1 - i);
        now %= mod;
        now *= C[i];
        now %= mod;
        ans += now;
        ans %= mod;
    }
    ans *= beki(2, N);
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    //ll P , Q , R;
    //cin >> P >> Q  >> R;

    ll A;
    cin >> A;
    
    cout << 3 * pow(A,2) << endl;



    /*
    string v;
    cin >> v;
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    if(v.length() == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    */
}

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

typedef long long ll;
typedef unsigned long long ull;

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(),a.end())
#define NP(a) next_permutation(a.begin(),a.end())

typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//cout<<"input"<<endl;freopen("input.txt","r",stdin);
	//cout<<"output"<<endl;freopen("output.txt","w",stdout);

	ll d,t,s;
	cin>>d>>t>>s;
	if(t*s >= d)
			cout<<"Yes";
	else	cout<<"No";
	cout<<endl;

	return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>qq;
const ll maxn=1e6+5;
ll a[maxn];
ll v[maxn];
int main()
{
    ll n,x,y;
    cin>>n>>x>>y;
    for(ll i=1;i<=n;i++)
        for(ll j=i+1;j<=n;j++)
    {
        if(i<x)
        {if(j<x)
            v[j-i]++;
        else if(j<y)
            v[min(j-i,x-i+1+y-j)]++;
        else
            v[j-i-y+x+1]++;
        }
        else if(i<y)
        {
        if(j<y)
            v[min(j-i,i-x+1+y-j)]++;
        else
            v[min(j-i,i-x+1+j-y)]++;
        }
        else
        {
            v[j-i]++;
        }
    }
    for(ll i=1;i<=n-1;i++)
        cout<<v[i]<<endl;
    return 0;
}
/*
10 6
8 3 7 8 2 9 3 8 2 4


20 20
*/


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(20000000)

n, q = map(int, input().split())
ab = [[] for _ in range(n+1)]
p_num = [0] * (n+1)
ans = [0] * (n+1)

for _ in range(n-1):
    a, b = map(int, input().split())
    ab[a].append(b)
for _ in range(q):
    p, x = map(int, input().split())
    p_num[p] += x

def dfs(num, cur_count):
    cur_count += p_num[num]
    ans[num] = cur_count
    if len(ab[num]) <= 0:
        return
    for v in ab[num]:
        dfs(v, cur_count)

dfs(1, 0)

out = []
for i in range(1, n+1):
    out.append(str(ans[i]))
print(" ".join(out))


Measured memory_bytes: 232968
using static System.Math;
using System.Collections.Generic;
using System;

public class UnionFind
{
    private int[] data;
    public UnionFind(int size)
    {
        data = new int[size];
        for (int i = 0; i < size; i++) data[i] = -1;
    }
    public bool Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);
        if (x != y)
        {
            if (data[y] < data[x])
            {
                var tmp = y;
                y = x;
                x = tmp;
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    public bool IsSameGroup(int x, int y) => Root(x) == Root(y);
    public int Root(int x) => data[x] < 0 ? x : data[x] = Root(data[x]);
    public int getMem(int x) => -data[Root(x)];
}


public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var uf = new UnionFind(n);
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            uf.Unite(int.Parse(line[0]) - 1, int.Parse(line[1]) - 1);
        }
        var d = new Dictionary<int, int>();
        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            var r = uf.Root(i);
            if (d.ContainsKey(r))  d[r]++;  
            else d[r] = 1;
            ans = Max(ans, d[r]);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 49228
#include <iostream>
#include <bits/stdc++.h>
#define endl "\n"
#define int long long
#define pii pair<int,int>
using namespace std;

const int Mod = 1e9+7;

signed main() {
    int X;cin>>X;
    X-=400;
    int ans = X/200;
    ans = 8-ans;
    cout<<ans<<endl;
   	
}

Measured memory_bytes: 3636
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll d;
cin >> d;
vector<ll> contest_variety(26,0);
vector<ll> c(26,0);
rep(i,26){
    cin >> c[i];
}
vector<vector<ll>> calender(d,vector<ll> (26,0));
rep(i,d){
    rep(j,26){
        cin >> calender[i][j];
    }
}

vector<ll> choose(d);

ll ans = 0;
vector<ll> tmp_minus(26,0);
rep(i,d){
    ll tmp = ans;
    ll minus_sum = 0;
    rep(j,26) {
        tmp_minus[j] = c[j] * (i + 1 - contest_variety[j]);
        minus_sum += tmp_minus[j];
    }
    ll ind = 0;
    ll tmp_max = ans;
    rep(j,26){
       if(tmp_max < tmp - minus_sum + tmp_minus[j] + calender[i][j]){
           ind = j;
           tmp_max = tmp - minus_sum + tmp_minus[j] + calender[i][j];
       }
    }
    cout << ind + 1 << endl;
    ans = tmp_max;
    contest_variety[ind] = i + 1;
}
}


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

int a,b;
string str;

int main(void){
	scanf("%d%d",&a,&b);
	cin >> str;
	bool flag=true;
	for(int i=0;i<a;i++){
		if(!isdigit(str[i]))flag=false;
	}
	if(str[a]!='-')flag=false;
	for(int i=a+1;i<a+b+1;i++){
		if(!isdigit(str[i]))flag=false;
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int pow(int x, int k, int res){
  if (k==0) {
    return(res);
  } else {
    return(pow(x, k-1, x * res));
  }
}

int main(){
  int d, n;
  cin >> d >> n;
  if (n == 100) {
    n++;
  }
  cout << n * pow(100, d, 1) << endl;
  return(0);
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a =  gets.chomp.split.map(&:to_i)

h = Hash.new(0)
ans = 0


n.times do |i|
  # k=0を一旦無視
  next if i == 0

  h[a[i]] += 1
  ans += h[a[i]] - 1


end

base_ans = ans
# k = 1でやったあと、しゃくり方の容量でいけそう
#
n.times do |i|
  ans = base_ans
  if i == 0
    puts ans
    next
  end

  if a[i] == a[0]
    puts base_ans
  else
    ans += (h[a[0]])
    ans -= (h[a[i]] - 1)
    puts ans
  end

end

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

int main(void){
    int x,y;
    while(true) {
        cin >> x;
        cin >> y;
        if(x == 0 && y == 0) {
            break; //whileから抜ける
        }
        if (x < y) {
            cout << x << " " << y << endl;
        }
        else {
            cout << y << " " << x << endl;
        }
    }
    
    
}


Measured memory_bytes: 3068
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [map(int, input().split()) for _ in range(Q)]

nums = {}
for a in A:
    nums.setdefault(a, 0)
    nums[a] += 1

s = 0
for a in A:
    s += a

for bc in BC:
    b, c = bc
    if b in nums:
        num = nums[b]
        nums[b] = 0
        nums.setdefault(c, 0)
        nums[c] += num
        s += (c-b)*num
    print(s)




Measured memory_bytes: 61428