akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e3+10;

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

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#define INF 100000000
int num[15];
int d[15];
int w[15];
double dp[15][1<<15];
int bfr[15][1<<15];
int n;
double dfs(int used,int pos,int weight){
	if(used==(1<<n)-1)return 0;
	if(dp[pos][used]!=-1)return dp[pos][used];
	int i;
	double res=INF;
	for(i=0;i<n;i++){
		if(!((used>>i)&1)){
			double p=0;
			if(used!=0)p=(double)abs(d[i]-d[pos])/2000*(70+weight);
			double next=dfs(used|1<<i,i,weight+w[i])+p;
			if(next<res){
				res=next;
				bfr[pos][used]=i;
			}
		}
	}
	return dp[pos][used]=res;
}
int main(){
	scanf("%d",&n);
	int i,j;
	for(i=0;i<1<<n;i++)for(j=0;j<n;j++)dp[j][i]=-1;
	for(i=0;i<n;i++)bfr[i][(1<<n)-1]=-1;
	for(i=0;i<n;i++){
		scanf("%d %d %d",&num[i],&d[i],&w[i]);
		w[i]*=20;
	}
	double ans=INF;
	dfs(0,0,0);
	int p=0;
	int used=0;
	while(bfr[p][used]!=-1){
		int next=bfr[p][used];
		printf("%d",num[next]);
		used|=1<<next;
		p=next;
		if(bfr[p][used]!=-1)printf(" ");
	}
	printf("\n");
	return 0;
}

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

int main()
{
    int n;
    std::cin >> n;

    std::vector<std::vector<int>> a(n, std::vector<int>(n - 1));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            std::cin >> a[i][j];
            a[i][j]--;
        }
        std::reverse(a[i].begin(), a[i].end());
    }

    std::vector<std::pair<int, int>> queue;

    auto check = [&](int idx) {
        if (!a[idx].size()) {
            return;
        }

        int opponent = a[idx].back();

        if (!a[opponent].size()) {
            return;
        }

        if (a[opponent].back() != idx) {
            return;
        }

        if (idx > opponent) {
            std::swap(idx, opponent);
        }
        std::pair<int, int> p = std::make_pair(idx, opponent);
        queue.push_back(p);
    };

    for (int i = 0; i < n; i++) {
        check(i);
    }

    int day = 0;
    while (queue.size()) {
        day++;
        std::sort(queue.begin(), queue.end());
        queue.erase(std::unique(queue.begin(), queue.end()), queue.end());
        std::vector<std::pair<int, int>> past_queue;
        swap(past_queue, queue);
        for (auto p : past_queue) {
            int first = p.first, second = p.second;

            a[first].pop_back();
            a[second].pop_back();

            check(first);
            check(second);
        }
    }

    for (int i = 0; i < n; i++) {
        if (a[i].size()) {
            puts("-1");
            return 0;
        }
    }

    std::cout << day << std::endl;
}


Measured memory_bytes: 4224
#include<cstdint>
 
template<std::uint_fast32_t MODULO>
struct modint {
private:
	using uint32 = std::uint_fast32_t;
	using uint64 = std::uint_fast64_t;
 
public:
	uint32 a;
	modint() :a(0) {}
	modint(const std::int_fast64_t &x) :a(set(x%MODULO + MODULO)) {}
	static uint32 set(const uint32 &x) { return(x<MODULO) ? x : x - MODULO; }
	static modint make(const uint32 &x) { modint ret;ret.a = x;return ret; }
	modint operator+(const modint &o)const { return make(set(a + o.a)); }
	modint operator-(const modint &o)const { return make(set(a + MODULO - o.a)); }
	modint operator*(const modint &o)const { return make((uint64)a*o.a%MODULO); }
	modint operator/(const modint &o)const { return make((uint64)a*~o%MODULO); }
	modint &operator+=(const modint &o) { return *this = *this + o; }
	modint &operator-=(const modint &o) { return *this = *this - o; }
	modint &operator*=(const modint &o) { return *this = *this * o; }
	modint &operator/=(const modint &o) { return *this = *this / o; }
	modint &operator^=(const uint32 &o) { return *this = *this^o; }
	modint operator~ ()const { return *this ^ (MODULO - 2); }
	modint operator- ()const { return make(set(MODULO - a)); }
	modint operator++() { return *this = make(set(a + 1)); }
	modint operator--() { return *this = make(set(a + MODULO - 1)); }
	bool operator==(const modint &o)const { return a == o.a; }
	bool operator!=(const modint &o)const { return a != o.a; }
	bool operator< (const modint &o)const { return a <  o.a; }
	bool operator<=(const modint &o)const { return a <= o.a; }
	bool operator> (const modint &o)const { return a >  o.a; }
	bool operator>=(const modint &o)const { return a >= o.a; }
	explicit operator bool()const { return a; }
	explicit operator uint32()const { return a; }
	modint operator^(uint32 x)const {
		uint64 t = a, u = 1;
		while (x) { if (x & 1) u = u*t%MODULO;t = (t*t) % MODULO;x >>= 1; }
		return make(u);
	}
};
 
#include <iostream>
#include <string>

int main(void) {
	using mint = modint<1000000007>;
	int n;
	std::string s;
	std::cin >> n >> s;
	mint dp[5003][5003] = {};
	dp[0][0] = 1;
	for (int i = 1;i <= n;++i) {
		dp[i][0] = dp[i - 1][1] * 2 + dp[i - 1][0];
		for (int j = 1;j <= i;++j) {
			dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j + 1] * 2;
		}
	}
	std::cout << dp[n][s.length()].a << std::endl;
	return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string c1, c2; cin >> c1 >> c2;

    if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]) {
        puts("YES");
    } else {
        puts("NO");
    }
}

Measured memory_bytes: 256
import math
from itertools import accumulate

def eratosthenes(n):
    prime_list = []
    num_list=[i for i in range(2, n+1)]
    limit = math.sqrt(n)
    while True:
        if limit <= num_list[0]:
            return prime_list + num_list
        prime_list.append(num_list[0])
        num_list = [e for e in num_list if e % num_list[0] != 0]

er_list = eratosthenes(100000)
count = [0]*100000

j = 0
for i in range(er_list[-1]):
    if i == er_list[j]:
        j += 1
        if (i+1)//2 in er_list:
            count[i] = 1 
            
count = list(accumulate(count))
            
Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(count[r]-count[l-1])

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

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

long long int lcm(long long int a, long long int b)
{
  long long int g = gcd(a, b);
  return a / g * b;
}

int main()
{
  long long int N, M;
  cin >> N >> M;
  vector<long long int> a(N);
  for (int i = 0; i < N; i++)
  {
    long long int b;
    cin >> b;
    b /= 2;
    a[i] = b;
  }
  bool can = true;
  long long int num = 0;
  long long int div = 2;
  while (a[0] % div == 0) {
    num++;
    div *= 2;
  }
  for (int i = 1; i < N; i++)
  {
    long long int tmp = 0;
    div = 2;
    while (a[i] % div == 0) {
      tmp++;
      div *= 2;
    }
    if (tmp != num)
    {
      can = false;
      break;
    }
  }
  if (!can)
    cout << 0 << endl;
  else
  {
    long long int T = a[0];
    for (int i = 1; i < N; i++)
    {
      T = lcm(a[i], T);
    }
    long long int ans = (M / T + 1) / 2;
    cout << ans << endl;
  }
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0016
{
    public class Program

    {
        public static void Main(string[] args)
        {
            double x = 0;
            double y = 0;
            int degrees= 90;

            while (true)
            {
                int[] line = ReadIntAr(',');
                if (line[0] + line[1] == 0) break;

                x += Math.Cos(degrees * Math.PI / 180) * line[0];
                y += Math.Sin(degrees * Math.PI / 180) * line[0];
                degrees -= line[1];
            }

            Console.WriteLine((int)x);
            Console.WriteLine((int)y);
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

int main()
{
    long d, n;
    cin >> d >> n;
    if (n == 100) {
        n = 101;
    }
    long ans;
    if (d == 0) {
        ans = n;
    } else if (d == 1) {
        ans = n * 100;
    } else {
        ans = 100 * 100 * n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t;
int n,m;
int main()
{
	ios::sync_with_stdio(0);
	cin>>s>>t;
	n=s.size();
	m=t.size();
	int ans=1e9;
	for(int i=0;i+m-1<n;++i)
	{
		int cnt=0;
		for(int j=0;j<m;++j)
		cnt+=s[i+j]!=t[j];
		if(cnt<ans)ans=cnt;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long a = 2;
    if(n == 0) {
        cout << a;
        return 0;
    }
    long long  b = 1;
    if(n == 1) {
        cout << b;
        return 0;
    }
    long long  cur;
    for (int i = 2;  i <= n; i++) {
        cur  = a + b;
        a = b;
        b = cur;
    }
    cout << cur;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var res int
	var n int
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		if (i%3 == 0) && (i%5 == 0) {
			continue
		} else if i%3 == 0 {
			continue
		} else if i%5 == 0 {
			continue
		} else {
			res += i
		}
	}
	fmt.Println(res)
}

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

const long long MOD=1e9+7;
long long N,K;
vector<int> g[100100];
long long ans=1;

void solve(int u,int pa=-1){
    long long tmp=K;
    if(pa!=-1) tmp--;
    for(auto v:g[u]){
        if(v==pa) continue;
        tmp--;
        ans*=tmp%MOD;
        ans%=MOD;
        solve(v,u);
    }
}

int main(){
    cin >> N >> K;
    for(int i=0;i<N-1;i++){
        int a,b; cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    solve(0);
    cout << ans*K%MOD << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    int a,b;
    cin>>a>>b;

    cout << (a+b+2-1)/2<<endl;

    return 0;
}


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

#define NMAX 200000
vector<int> cnt(NMAX);

int main(void){
  int n,k,ans;
  scanf("%d%d", &n, &k);
  for (int i=0; i<n; i++){
    int tmp;
    scanf("%d", &tmp);
    cnt[tmp]++;
  }
  sort(cnt.begin(),cnt.end());
  ans = 0;
//for(int i=0; i<NMAX; i++) printf("%d ", cnt[i]);
//puts("");
  for (int i=0; i<NMAX && i<k; i++){
    //printf("(%d)\n", cnt[NMAX-1-i]);
    ans += cnt[NMAX-1-i];
  }
  printf("%d\n", n-ans);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>

using namespace std;

#define MIN first
#define MAX second
constexpr int MAX_S = 252;
constexpr int INF = (1 << 29);

string S;
pair<int, int> mem[MAX_S][MAX_S];

void init(int N)
{
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            mem[i][j] = {+INF, -INF};
        }
    }
}

void update_max(int& l, int r)
{   
    if (l < r) l = r;
}

void update_min(int& l, int r)
{
    if (l > r) l = r;
}

// テ・ツ個コテゥツ鳴禿」ツ?ョpair(MIN, MAX)
pair<int, int> rec(int L, int R)
{
    pair<int, int>& res = mem[L][R];
    if (res != make_pair(+INF, -INF)) {
        return res;
    }

    if (R - L == 0) {
        int v = S[L] - '0';
        return (res = make_pair(v, v));
    }    

    if (S[L] == '(' && R - L > 2) {
        auto r = rec(L + 1, R);
        update_min(res.MIN, r.MIN);
        update_max(res.MAX, r.MAX);
        return res;
    }

    if (S[R] == ')' && R - L > 2) {
        auto r = rec(L, R - 1);
        update_min(res.MIN, r.MIN);
        update_max(res.MAX, r.MAX);
        return res;
    }
    
    for (int i = L + 1; i <= R - 1; i++) {
        char c = S[i];   
        if (c != '+' && c != '-') continue;                 
        
        auto res_l = rec(L, i - 1); // Left
        auto res_r = rec(i + 1, R); // Right

        if (c == '+') {            
            update_min(res.MIN, res_l.MIN + res_r.MIN);
            update_max(res.MAX, res_l.MAX + res_r.MAX);            
        }
        if (c == '-') {           
            update_min(res.MIN, res_l.MIN - res_r.MAX);
            update_max(res.MAX, res_l.MAX - res_r.MIN);
        }
    } 
    return res;
}

void solve()
{
    int N = S.size();
    init(N);
    cout << rec(0, N - 1).MAX << endl;    
}

int main()
{
    cin >> S;
    solve();    
    return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;

int main() {
	string S;
	cin >> S;
	
	vector< lint > cnt(26, 0);
	for (char c : S) cnt[c-'a']++;
	
	lint n = S.size(), sub = 0;
	for_(i,0,26) sub += cnt[i]*(cnt[i]-1)/2;
	
	cout << n*(n-1)/2 - sub + 1 << endl;
}

Measured memory_bytes: 640
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int a,b,c;  cin >> a >> b >> c;
  int x; cin >> x;
  int ans = 0;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(x == (i*500+j*100+k*50)){
          ans++;
        }
      }
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	int N;
	cin >> N;

	int res = N;
	rep(i, 0, N + 1) {
		int tmp = 0;
		int idx = i;
		while(idx > 0) tmp += idx % 6, idx /= 6;
		idx = N - i;
		while(idx > 0) tmp += idx % 9, idx /= 9;
		if(res > tmp) res = tmp;
	}

	cout << res << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main()
{
  int N,W,H,x,y,w,a=0,b=0,flag=0;
  vector<pair<int,int> > X,Y;
  cin>>N>>W>>H;
  for(int k=0;k<N;k++){
    cin>>x>>y>>w;
    X.push_back(make_pair(max(0,x-w),min(x+w,W)));
    Y.push_back(make_pair(max(0,y-w),min(y+w,H)));
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  for(int i=0;i<N;i++){
    if(a<X[i].first)break;
    a=max(a,X[i].second);
    if(i==N-1 && a==W)flag=1;
  }
  for(int i=0;i<N;i++){
    if(b<Y[i].first)break;
    b=max(b,Y[i].second);
    if(i==N-1 && b==H)flag=1;
  }
  if(flag==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;  
  return 0;
}

Measured memory_bytes: 2904
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int Factorial(int k) {
    int sum = 1;
    for(int i = 1; i <= k; ++i) {
        sum *= i;
    }
    return sum;
}

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

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

    int fac = Factorial(n);
    double ave = 0.0;
    for(int i = 0; i < fac; i++) {
        for(int j = 0; j < n - 1; j++) {
            ave += sqrt(pow(x[v[j]] - x[v[j + 1]], 2) + pow(y[v[j]] - y[v[j + 1]], 2));
        }
        next_permutation(v.begin(), v.end());
    }
    printf("%.10f\n", (double)ave / fac);
    return 0;
}


Measured memory_bytes: 3820
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCoder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const int INF = 2000000000; //2e9
const long long INF2 = 3000000000000000000; //3e18
const long double PI = acos(-1);

const int large_P = 1000000007; //1e9 + 7
//const int large_P = 1000000009; //1e9 + 9
//const int large_P = 998244353;





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

	vector<int> leaf(N + 1);
	rep(i, N + 1) cin >> leaf.at(i);

	vector<int> vol(N + 1);
	bool able = true;

	for (int i = 0; i <= N; i++) {
		if (i == 0) {
			vol.at(i) = 1;
			if (leaf.at(i) > 0) {
				able = false;
				break;
			}
		}
		else {
			vol.at(i) = 2 * vol.at(i - 1);
			vol.at(i) -= leaf.at(i);

			if (vol.at(i) < 0 || (i != N && vol.at(i) == 0)) {
				able = false;
				break;
			}

			if (vol.at(i - 1) + leaf.at(i) > INF2 / 2) vol.at(i) = INF2;
		}
	}


	for (int i = N; i >= 0; i--) {
		if (i == N) {
			vol.at(i) = 0;
		}
		else {
			vol.at(i) = min(leaf.at(i + 1) + vol.at(i + 1), vol.at(i));
			if (vol.at(i) <= 0) {
				able = false;
				break;
			}
		}

	}


	int res = 0;
	for (int i = 0; i <= N; i++) {
		res += leaf.at(i) + vol.at(i);
	}


	if (able && N != 0) cout << res << endl;
	//if (able) cout << res << endl;
	else if (N == 0 && leaf.at(0) == 1) cout << "1" << endl;
	else cout << "-1" << endl;

	//rep(i, N + 1) {
		//cout << i << " " << vol.at(i) << endl;
	//}
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,num,i;
    map<int,int>mp;
    map<int,int>::iterator it;
    cin>>N;
    for(i=1;i<N;i++)
    {
        cin>>num;
        mp[num]++;
    }
    for(i=1;i<=N;i++)
    {
        cout<<mp[i]<<endl;
    }
    return 0;
}


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

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

    int d[n];
    map<int, int> m;
    for(int i = 0; i < n; i++){
        cin >> d[i];
        auto itr = m.find(d[i]);
        if(itr == m.end()){
            m[d[i]] = 1;
        }else{
            m[d[i]]++;
        }
    }

    int now = 0;
    int bef = 1;
    ll ans = 1;
    ll q = 998244353;

    for(auto itr = m.begin(); itr != m.end(); ++itr){
        if(itr->first != now){
            ans = 0;
            break;
        }else{
            ll t = 1; 
            for(int i = 0; i < itr->second; i++){
                t *= bef;
                t %= q;
            }
            ans *= t;
            ans %= q;
            bef = itr->second;
            now++; 
        }
    }

    auto itr = m.find(0);
    if(itr != m.end()){
        if(m[0] != 1){
            ans = 0;
        }
    }

    if(d[0] != 0){
        ans = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5376
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    int N;
    scanf("%d",&N);
    string S[N];
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    map<string,int> mp;
    for(int i=0;i<N;i++){
        mp[S[i]]++;
    }

    int max_value=0;
    for(int i=0;i<N;i++){
        max_value = max(mp[S[i]],max_value);
    }
    vector<string> result;
    for(pair<string,int> p:mp){
        if(p.second==max_value)result.push_back(p.first);
    }
    sort(result.begin(),result.end());
    for(int i=0;i<result.size();i++)cout<<result[i]<<"\n";
}

Measured memory_bytes: 28888
#include <stdio.h>

#define MAX 25

typedef struct {
	int parent;
	int left;
	int right;
} node;

node nodes[MAX] = {0};
int H[MAX];


int getDepth(int num) {
	int d = 0;
	while (nodes[num].parent != -1) {
		num = nodes[num].parent;
		++d;
	}
	return d;
}

int getDegree(int num) {
	if (nodes[num].left == -1 && nodes[num].right == -1) return 0;
	if (nodes[num].left != -1 && nodes[num].right != -1) return 2;
	return 1;
}

int getSibling(int num) {
	int parent ;
	parent = nodes[num].parent;
	if (parent == -1) return -1;
	if (nodes[parent].right == num) return nodes[parent].left;
	return nodes[parent].right;
}

int setHeight(int num) {
	int h1, h2;
	h1 = h2 = 0;
	if (nodes[num].right != -1) {
		h1 = setHeight(nodes[num].right) + 1;
	}

	if (nodes[num].left != -1) {
		h2 = setHeight(nodes[num].left) + 1;
	}

	return (h1 > h2) ? h1 : h2;
}

void show_node(int num) {
	int parent = nodes[num].parent;
	if (parent == -1) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n", num, nodes[num].parent, getSibling(num), getDegree(num), getDepth(num), setHeight(num));
	} else if (nodes[num].right == -1 && nodes[num].left == -1) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n", num, nodes[num].parent, getSibling(num), getDegree(num), getDepth(num), setHeight(num));
	} else {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n", num, nodes[num].parent, getSibling(num), getDegree(num), getDepth(num), setHeight(num));
	}
	return;
}

int main(void) {
	int n;
	int i, tmp;
	node init_node;
	init_node.parent = init_node.right = init_node.left = -1;
	for (i = 0; i < MAX; ++i) {
		nodes[i] = init_node;
	}
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d", &tmp);
		scanf("%d", &nodes[tmp].left);
		scanf("%d", &nodes[tmp].right);
		if (nodes[tmp].left != -1) {
			nodes[nodes[tmp].left].parent = tmp;
		}
		if (nodes[tmp].right != -1) {
			nodes[nodes[tmp].right].parent = tmp;
		}
	}

	for (i = 0; i < n; ++i) {
//		setHeight(i);
		show_node(i);
	}
	return 0;
}

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

int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3104
#include <stdio.h>
char s[4];

int main()
{
	//printf("1000<=N<=9999の範囲で好きな整数を一文字ずつ入力して下さい。\n");
	//for (int i = 0;i < 4;i++)
	//{
		scanf("%s", &s);//横に並べてscanfできりゅ！！
	//}
	for (int i = 0;i < 1;i++)
	{
		if (s[i] == s[i + 1] && s[i + 1] == s[i + 2])
		{
			printf("Yes");
		}
		else if (s[i + 1] == s[i + 2] && s[i + 2] == s[i + 3])
		{
			printf("Yes");
		}
		else printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdbool.h>
#define true 1
#define false 0
#define MAX 1000
#define VMAX 10000

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

void sort(int C[]);
int min(int a , int b);
int solve();

int main(void){
	scanf("%d",&n);
	s = VMAX;
	for( int i = 0; i < n; i++){
		scanf("%d",&A[i]);
		s = min(s, A[i]);
	}
	int ans = solve();
	printf("%d\n",ans);
	
	return 0;
}

void sort(int C[]){
	int tmp;
	int flag = 1;
	while(flag == 1){
		flag = 0;
		for( int j = n-1; j >= 1; j--){
			if(C[j] < C[j-1])
			{
				tmp = C[j];
				C[j] = C[j-1];
				C[j-1] = tmp;
				flag = 1;
			}
		}
	}
}


int min(int a , int b){
	if(a < b) return a;
	else return b;
}


int solve(){
	int ans = 0;
	
	bool V[MAX];
	for( int i = 0; i < n; i++){
		B[i] = A[i];
		V[i] = false;
	}
	sort(B);
	for( int i = 0; i < n; i++) T[B[i]] = i;
	for( int i = 0; i < n; i++){
		if(V[i])continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int c = 0;
		while(1){
			V[cur] = true;
			c++;
			int v = A[cur];
			m = min(m,v);
			S += v;
			cur = T[v];
			if(V[cur])break;
		}
		ans += min(S+(c-2)*m, m+S+(c+1)*s);
	} 
	return ans; 
}



Measured memory_bytes: 2140
#include<iostream>
using namespace std;
int main(){
  int t,n,s[11],f[11];
  while(1){
    int sum=0;
    cin>>t;
    if(t==0)break;
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>s[i]>>f[i];   
      sum+=f[i]-s[i];
    }
    if(sum>=t)cout<<"OK"<<"\n";
    else cout<<t-sum<<"\n";
  }
  return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;

int main() {
    vector<int> A(3),B(3),ct(3);
    for(int i=0;i<3;i++){
        cin >> A[i] >> B[i];
        ct[A[i]-1]++;
        ct[B[i]-1]++;
    }
    int jg1=0,jg2=0;
    for(int i=0;i<=3;i++){
        if(ct[i]==1){
            jg1++;
        }
        else if(ct[i]==2){
            jg2++;
        }
    }
    cout << (jg1==2&&jg2==2 ?"YES":"NO") << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

string now,beg,en;
int q,qu,sta;


int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>now;
  cin>>q;  
  while(q--){
    cin>>qu;
    if(qu == 1){
      sta ^= 1;      
    }
    else{
      int f;string c;
      cin>>f>>c;
      if(f == 1){
	if(sta) en+=c;
	else beg=c+beg;	
      }
      else{
	if(sta) beg = c+beg;
	else en+=c;	
      }
    }
  }
  now = beg+now+en;    
  if(sta) reverse(now.begin(),now.end());
  cout<<now<<endl;  
  return 0;
}


Measured memory_bytes: 1316
#Ans
N=str(input())
if N[-1]=="2"or N[-1]=="4"or N[-1]=="5"or N[-1]=="7"or N[-1]=="9":
    print("hon")
elif N[-1]=="0" or N[-1]=="1"or N[-1]=="6"or N[-1]=="8":    
    print("pon")
elif N[-1]=="3":
    print("bon")

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

using namespace std;

 map <string, int> mp;

int main(void)
{
  int n;
  cin >> n;
  string s;
  for(int i = 0; i < n; i++)
  {
    cin >> s;
    mp[s]++;
  }
  cout << "AC " << "x " << mp["AC"] << endl;
  cout << "WA " << "x " << mp["WA"] << endl;
  cout << "TLE " << "x " << mp["TLE"] << endl;
  cout << "RE " << "x " << mp["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int dif = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] != t[i]) ++dif;
    }
    cout << dif;
    return 0;
}


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

using namespace std;

int N;
int s[105];

int ans;
int dp[105][10005];

void solve() {
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10005; j++) {
			dp[i+1][j] |= dp[i][j];
			if (j - s[i] < 0) continue;
			dp[i+1][j] |= dp[i][j - s[i]];
		}
	}
	for (int i = 0; i < 10005; i++) {
		if (i % 10 == 0) continue;
		if (dp[N][i] != 0) ans = i;
	}
	cout << ans << endl;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	solve();
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>

class ITP1_3_B
{
	int i;

public:
	ITP1_3_B();
	~ITP1_3_B() = default;
	void Main();
};

ITP1_3_B::ITP1_3_B()
{
	i = 1;
}


void ITP1_3_B::Main()
{
	int x;
	while (std::cin >> x)
	{
		if (x == 0)
		{
			break;
		}
		/*else if (i != 1)
		{
			std::cout << std::endl;
		}*/
		std::cout << "Case " << i << ": " << x;

		std::cout << std::endl;

		i++;

	}
}



int main()
{

	ITP1_3_B it;
	it.Main();


	return 0;
}


Measured memory_bytes: 3056
n, k = map(int, input().split())
p = list(map(int, input().split()))
dd = [0] * (n + 1)
for i in range(1, n + 1):
    dd[i] = dd[i - 1] + p[i - 1]
total = 0
index = 0
j = 0
while j < n + 1:
    if j + k >= n + 1:
        break
    now = dd[j + k] - dd[j]
    if now > total:
        total = now
        index = j
    j += 1
ans = 0
for i in range(k):
    aa = index + i
    ans += p[index + i] + 1
ans /= 2
print(ans)


Measured memory_bytes: 25172
# solution

data = int(input())

def asd(nim):
  if int(nim) > data:
    return 0
  ret = 1 if all(nim.count(c) > 0 for c in "753") else 0
  for c in "753":
    ret += asd(nim+c)
  return ret

print(asd("0"))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

ll n;
ll ans = 0;

void dfs(ll x, int a, int b, int c) {
	if (x > n)return;
	if (a && b && c)ans++;
	dfs(10 * x + 3, 1, b, c);
	dfs(10 * x + 5, a, 1, c);
	dfs(10 * x + 7, a, b, 1);
}

int main() {
	cin >> n;
	dfs(0, 0, 0, 0);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MX = 10000000;

ll numDiv[MX+1];
ll ans[MX+1];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    for(int i=1; i<=MX; i++)
    {
        for(int j=i; j<=MX; j+=i)
        {
            numDiv[j]++;
        }
    }
    for(ll i=1; i<=MX; i++)
    {
        ans[i] = ans[i-1] + i * numDiv[i];
    }
    int n;
    cin >> n;
    cout << ans[n];
    return 0;
}


Measured memory_bytes: 159908
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;

class Program
{


	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] line = Console.ReadLine().Split(' ');
		int N = int.Parse(line[0]);
		int X = int.Parse(line[1]);
		int Y = int.Parse(line[2]);

		//数値を揃える（0開始にする）
		X --;
		Y --;

		//バケツ
		int[] bucket = new int[N-1];

		//全探索
		for(int i=0; i<N-1; i++){
				for(int j=i+1; j<N; j++){
						//最短距離
						int min = 0;
						//開始地点がXに届かない場合
						if(i < X){
								//終着地点がX以下の場合
								if(j <= X){
										min = j - i;
								}
								//終着地点がXY間の場合
								else if(j < Y){
										int rootA = j - i;
										int rootB = (X-i) + 1 + (Y-j);
										min = Math.Min(rootA, rootB);
								}
								//終着地点がY以上の場合
								else{
										min = (X-i) + 1 + (j-Y);
								}
						}

						//開始地点がXY間の場合
						else if(i < Y){
								//終着地点がXY間の場合
								if(j < Y){
										int rootA = j - i;
										int rootB = (i-X) + 1 + (Y-j);
										min = Math.Min(rootA, rootB);
								}
								//終着地点がY以上の場合
								else{
										int rootA = j - i;
										int rootB = (i-X) + 1 + (j-Y);
										min = Math.Min(rootA, rootB);
								}
						}

						//開始地点がY以上の場合
						else{
								min = j - i;
						}

						bucket[min-1] ++;
				}
		}

		foreach(int num in bucket){
				Console.WriteLine(num);
		}
	}
}



Measured memory_bytes: 11092
s = input().split()
stack = []
for v in s:
    # print("v", v)
    # print("stack", stack)
    if v in ["+", "-", "*"]:
        v1 = stack.pop()
        v2 = stack.pop()
        statement = v2 + v + v1
        r = eval(statement)
        stack.append(str(r))
    else:
        stack.append(v)

assert len(stack) == 1
print(stack[0])


Measured memory_bytes: 5568
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

string s;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
if(s == "SUN"){
	cout << 7 << endl;
}
else if(s == "SAT"){
	cout << 1 << endl;
}
else if(s == "MON"){
	cout << 6 << endl;
}
else if(s == "TUE"){
	cout << 5 << endl;
}
else if(s == "WED"){
	cout << 4 << endl;
}
else if(s == "THU"){
	cout << 3 << endl;
}
else{
	cout << 2 << endl;
}

return 0;
}



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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

#define NIL NULL

Node root;

Node find(Node u,int k){
  while (u != NIL && k != u->key){
    if (k < u->key)
      u = u->left;

    else
      u = u->right;
  }

  return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x;

    if (z->key < x->key)
      x = x->left;

    else
      x = x->right;
  }

  z->parent = y;

  if (y == NIL)
    root = z;

  else if (z->key < y->key)
    y->left = z;

  else
    y->right = z;
}

void inorder(Node u){
  if (u == NIL)
    return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if (u == NIL)
    return;

  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }

    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

    else if (com[0] == 'f'){
      scanf("%d",&x);
      
      if (find(root,x) != NIL)
	printf("yes\n");

      else
	printf("no\n");
    }
  }

  return 0;
}



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

using namespace std;

int main(){
    long long int N,T,a,b,ans=0;
    cin >> N >> T;
    cin >> a >> b;

    if(b-a<T){
        ans += b-a;
    }else{
        ans += T;
    }

    for(int i=2;i<N;i++){
        a = b;
        cin >> b;
        if(b-a<T){
            ans += b-a;
        }else{
            ans += T;
        }
    }
    ans += T;
    if(N==1){
        cout << T;
    }else{
        cout << ans;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct S{
  int d,h,w;
  bool operator<(const S&a)const{
    return d-a.d?d<a.d:h<a.h;
  }
};
int c,i,j,h,w,r;
S d[22801];
main(){
  for(i=1;i<151;++i)for(j=i+1;j<151;++c,++j)d[c]=(S){i*i+j*j,i,j};
  sort(d,d+22801);
  while(cin>>h>>w,h){
    r=w*w+h*h;
    for(i=0;r>d[i].d;++i);
    while(d[i].h<=h){
      ++i;
      if(d[i].d>r)break;
    }
    cout<<d[i].h<<' '<<d[i].w<<endl;
  }
}

Measured memory_bytes: 3368
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	int n;
	cin >> n;
	bool ok = true;
	int x;
	forn(i, n){
		cin >> x;
		if(x&1) continue;
		ok &= ((x%5 == 0) || (x%3 == 0));
	}
	if(ok) cout << "APPROVED";
	else cout <<"DENIED";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


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


int main(){

 long long int N;
  scanf("%lld",&N);

/*
  char A[];
  scanf("%s",A);
  */

  
  long long int A[N];
  int i;
  for(i=0;i<N-1;i++){
   scanf("%lld",&A[i]);
   }

  long long int B[N];
  for(i=0;i<N;i++){
   B[i]=0;
   }
   
  for(i=0;i<N-1;i++){
   B[A[i]-1]+=1;
   }


  for(i=0;i<N;i++){
    printf("%lld\n",B[i]);
   }




 return(0);
 }


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

int main() {
  string s;
  cin >> s;
  if(s == "Sunny") cout << "Cloudy" << endl;
  if(s == "Cloudy") cout << "Rainy" << endl;
  if(s == "Rainy") cout << "Sunny" << endl;
}


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

const int MOD1=1000000007;
const int MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const int dx[]={0,1,0,-1,1,-1,1,-1};
const int dy[]={1,0,-1,0,1,1,-1,-1};

#define lint boost::multiprecision::cpp_int;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

#define unless(a) if(!(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(n);i++)
#define bitrep(i,s,n) for(int i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long cutup(long long a,long long b){return (a+b-1)/b;}
long long popcnt(long long a){return __builtin_popcountll(a);}
template<class T,class U> inline bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template<class T,class U> inline bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

template<typename t>
constexpr t mpow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}

template<typename t>
constexpr t nCr(t n,int r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(int i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

void vin(auto &a){
    for(int i=0;i<a.size();i++)cin>>a[i];
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vl A(n);
    vin(A);
    ll res=MAXLL;
    for(int i=-100;i<=100;i++){
        ll s=0;
        rep(j,n){
            s+=mpow(A[j]-i,2);
        }
        chmin(res,s);
    }
    cout<<res<<endl;
}

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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll ;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define NP next_permutation
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------





ll pow(ll x,ll y,ll m){
    ll res = 1 ;
    if(y>0){
        res = pow(x,y/2,m) ;
        if(y%2==0){
            res = (res*res)%m ;
        }
        else{
            res = (((res*res)%m)*x)%m ;
        }
    }
    return res ;
}

ll nCk(ll n, ll k, ll m){
    ll res = 1 ;
    REP(i,k){
        res *= (n-i) ;
        res %= m ;
    }
    ll tmp = 1 ;
    REP(i,k){
        tmp *= (i+1) ;
        tmp %= m ;
    }
    tmp = pow(tmp,m-2,m) ;
    res *= tmp ;
    res %= m ;
    return res ;
}












//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, a, b ;
  cin >> n >> a >> b ;
  ll ans = 0 ;
  ans = pow(2,n,MOD) ;
  ans += (MOD - 1) ;
  ans %= MOD ;
  ans -= nCk(n,a,MOD) ;
  ans += MOD ;
  ans %= MOD ;
  ans -= nCk(n,b,MOD) ;
  ans += MOD ;
  ans %= MOD ;
  cout << ans <<endl ;
    
  
  
  
  return 0 ;
}

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

int main() {
  int W,H,N;
  cin >> W >> H >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> a(N);
  vector<vector<int>> S(W,vector<int>(H,1));

  for (int i = 0;i<N;i++) {
    cin >> x.at(i) >> y.at(i) >> a.at(i);
    if(a.at(i) == 1) {
      for (int j = 0;j<x.at(i);j++) {
        for(int k = 0;k<H;k++) S[j][k] = 0;
      }
    }
    if(a.at(i) == 2) {
      for (int j = x.at(i);j<W;j++) {
        for(int k = 0;k<H;k++) S[j][k] = 0;
      }
    }
    if(a.at(i) == 3) {
      for (int j = 0;j<W;j++) {
        for(int k = 0;k<y.at(i);k++) S[j][k] = 0;
      }
    }
    if(a.at(i) == 4) {
      for (int j = 0;j<W;j++) {
        for(int k = y.at(i);k<H;k++) S[j][k] = 0;
      }
    }
  }

  int res = 0;
  for (int i = 0;i<W;i++) {
    for (int j = 0;j<H;j++) {
      res = res + S[i][j];
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a : i32 = read();
    let b : i32 = read();
    let c : i32 = read();
    let x : i32 = read();
    let mut ans = 0;
    for anum in 0..a+1 {
        for bnum in 0..b+1 {
            let remaining = x - (anum * 500 + bnum * 100);
            if remaining >= 0 && remaining / 50 <= c {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


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

#define ll long long int

int N;
int dias[100005][3];
ll memo[100005][3];

ll solve(int dia, int act){
	if(!dia) return dias[dia][act];
	if(memo[dia][act]) return memo[dia][act];
	return memo[dia][act] = 
		dias[dia][act]+max(solve(dia-1, (act+1)%3), solve(dia-1, (act+2)%3));
}

ll solve(){
	for(int i = 0; i < 3; i++)
		memo[0][i] = dias[0][i];
	for(int i = 1; i<N; i++)
		for(int j = 0; j<3; j++)
			memo[i][j] = dias[i][j]+
							max(memo[i-1][(j+1)%3], 
								memo[i-1][(j+2)%3]);
	ll maxi = 0;
	for(int i = 0; i < 3; i++)
		maxi = max(maxi, memo[N-1][i]);
	return maxi;
}

int main() {
	cin>>N;
	for(int i = 0; i< N; i++)
		cin>>dias[i][0]>>dias[i][1]>>dias[i][2];
	cout<<solve()<<"\n";
	return 0;
}

Measured memory_bytes: 7120
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<deque>

using namespace std;
vector<vector<int>> e;
vector<int> pre;

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    e = vector<vector<int>>(n + 1);
    pre = vector<int>(n + 1, 0);
    map<int, int> mp;
    for(int i = 0; i < n + m - 1; i++){
        int x, y;
        cin >> x >> y;
        e[x].emplace_back(y);
        mp[y]++;
    }
    deque<int> dq;
    for(int i = 1; i <= n; i++){
        if(mp[i] == 0) dq.push_back(i);
    }
    while(dq.size()){
        int x = dq.front();
        dq.pop_front();
        for(auto&& j : e[x]){
            pre[j] = x;
            mp[j]--;
            if(mp[j] == 0) dq.push_back(j);
        }
    }
    for(int i = 1; i <= n; i++){
        cout << pre[i] << endl;
    }
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	int state = 0;
	int dir = 0;
	int ans = 0;
	for(char c: s){
		if(c == 'L'){
			dir = (dir+3) %4;
			state--;
			if(dir == 0) state = 0;
		}else{
			dir = (dir+1) %4;
			state++;
			if(dir == 0){
				if(state == 4){
					ans++;
				}
				state = 0;
			}
		}
	}
	cout << ans << endl;
    return 0;
}


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

int main() {
   int A, B;
   cin >> A >> B;
  int count = 0;
  for(int i = A; i < B+1; i++){
   string N = to_string(i);
    string t =  N;
    reverse(N.begin(), N.end());
    if(t == N){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        int[] atk = new int[N];
        int[] mp = new int[N];
        int[] dp = new int[H + 1];
        for (int i = 0; i < N ; i++) {
            int a = sc.nextInt();
            int m = sc.nextInt();
            atk[i] = a;
            mp[i] = m;
        }
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 0; i < H ; i++) {
            if(dp[i]!=Integer.MAX_VALUE){
                for(int j=0;j < N; j++){
                    dp[Math.min(i+atk[j],H)]=
                            Math.min(
                                    dp[i]+mp[j],
                                    dp[Math.min(i+atk[j],H)]
                            );
                }
            }
        }
        System.out.println(dp[H]);
    }
}

Measured memory_bytes: 26412