akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll ans = 0;
    vector<ll> rec(n), acc(n+1, 0);
    rep(i, 0, n) {
        auto itr = upper_bound(c.begin(), c.end(), b[i]);
        rec[i] = n - (itr - c.begin());
    }
    rep(i, 0, n) acc[i+1] = acc[i] + rec[i];
    rep(i, 0, n) {
        auto itr = upper_bound(b.begin(), b.end(), a[i]);
        auto pos = itr - b.begin();
        ans += acc[n] - acc[pos];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7172
#include<cstdio>
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

int main(){
  double ans;
  int n,m,p[20];

  while(scanf("%d %d",&n,&m) && (n||m)){
    for(int i=0;i<m;i++)scanf("%d",&p[i]);

    ans = (double)(n+1)*n/ 2;

    int num = 0;
    for(int i=1;i<(1<<m);i++){
      int bit = 0;
      for(int j=i;j!=0;j>>=1)bit += j&1;
      int tmp = 1;
      for(int j=0;j<m;j++)
	if(i>>j & 1)tmp = lcm(tmp,p[j]);

      if(bit&1){
	num += n/tmp;
	ans -= (double)(n/tmp+1)*n/2;
      }else{
	num -= n/tmp;
	ans += (double)(n/tmp+1)*n/2;
      }
    }

    if(num==n)printf("0.00000000\n");
    else printf("%.8lf\n",ans/(n-num));
  }
}

Measured memory_bytes: 796
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int F[21][21];

int main(){
    int n,m,x,y,d,cnt;
    string c;
    while(1){
        cin>>n;
        if(!n) break;
        cnt=0;
        for(int i=0;i<21;i++) for(int j=0;j<21;j++) F[i][j]=0;
        for(int i=0;i<n;i++){
            cin>>x>>y;
            F[y][x]=1;
        }
        cin>>m;
        x=y=10;
        for(int i=0;i<m;i++){
            cin>>c>>d;
            if(c=="N"){
                for(int j=0;j<=d;j++){
                    if(F[y+j][x]){
                        cnt++;
                        F[y+j][x]=0;
                    }
                }
                y+=d;
            }
            else if(c=="S"){
                for(int j=0;j<=d;j++){
                    if(F[y-j][x]){
                        cnt++;
                        F[y-j][x]=0;
                    }
                }
                y-=d;
            }
            else if(c=="W"){
                for(int j=0;j<=d;j++){
                    if(F[y][x-j]){
                        cnt++;
                        F[y][x-j]=0;
                    }
                }
                x-=d;
            }
            else if(c=="E"){
                for(int j=0;j<=d;j++){
                    if(F[y][x+j]){
                        cnt++;
                        F[y][x+j]=0;
                    }
                }
                x+=d;
            }
        }
        if(cnt==n) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}



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

#define MAX_N 3
#define MAX_M 5

int main() {
    int N, M, s[MAX_M], c[MAX_M];
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> s[i] >> c[i];
    }

    // N > 1のとき、先頭が0ではいけない
    if (N > 1) {
        for (int i = 0; i < M; i++) {
            if (s[i] == 1 && c[i] == 0) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    // i桁目の暫定の値
    int a[MAX_N];
    for (int i = 0; i < N; i++) {
        a[i] = -1; // 未指定の桁は-1としておく
    }

    // ある桁について異なる値を指定してはいけない
    for (int i = 0; i < M; i++) {
        // まだ指定されていない桁ならば
        if (a[s[i]-1] == -1) {
            a[s[i]-1] = c[i];
        }
        // 既に指定されている桁ならば
        else {
            // 異なる値を指定してはいけない
            if (a[s[i]-1] != c[i]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if (N == 1) {
        if (a[0] == -1) {
            cout << 0 << endl;
        } else {
            cout << a[0] << endl;
        }
        return 0;
    }

    int ans;
    if (a[0] == -1) {
        ans = 1;
    } else {
        ans = a[0];
    }

    for (int i = 1; i < N; i++) {
        ans *= 10;
        if (a[i] != -1) {
            ans += a[i];
        }
    }

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

Measured memory_bytes: 256
K = int(input())
S = input()
N = len(S)
MOD = 10 ** 9 + 7


# 逆元の前計算
factorial = [1, 1]
inverse = [1, 1]
invere_base = [0, 1]
for i in range(2, K + N + 1):
    factorial.append((factorial[-1] * i) % MOD)
    invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD)
    inverse.append((inverse[-1] * invere_base[-1]) % MOD)


def nCr(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


ans = 0
for i in range(K + 1):
    ans += pow(25, i, MOD) * nCr(i + N - 1, N - 1) * pow(26, K - i, MOD) % MOD
    ans %= MOD
print(ans % MOD)


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

int main(){
  int N;
  cin >> N;
  vector<char> S(N);
  bool ans = false;
  for (int i = 0; i < N; i++){
    cin >> S.at(i);
    if (S.at(i) == 'Y') ans = true;
  }
  if (ans) cout << "Four" << endl;
  else cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	long long k;
	cin >> k;
	cout << 50 << endl;
	if(k <= 50)
	{
		for(int i = 1; i <= k; i ++)
		{
			cout << 50 << " ";
		}
		for(int i = k + 1; i <= 50; i ++)
		{
			cout << 0 << " ";
		}
	}
	else
	{
		long long a = k % 50, b = k / 50;
		for(int i = 1; i <= a; i ++)
		{
			cout << 50 + b << " ";
		}
		for(int i = a + 1; i <= 50; i ++)
		{
			cout << 50 + b - a - 1 << " ";
		}
	}
	return 0;
}

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

unsigned long solve(const unsigned long t[],int len,int n)
{
	if(len == n+1){
		unsigned long sum=0;
		for(int i=0;i<len;i++){
			sum+=t[i];
		}

		return sum;
	}else{
		unsigned long u[len-1];
		int j=0;
		for(int i=0;i<len-1;i++){
			if(j==n){
				u[i] = 10*t[j]+t[j+1];
				j+=2;
			}else{
				u[i] = t[j++];
			}
		}

		return solve(t,len,n+1)+solve(u,len-1,n);
	}
}

int main()
{
	string s;

	cin >> s;

	int len = s.size();
	unsigned long t[len],ans = 0;

	for(int i = 0;i < len;i++){
		t[i] = s[i]-'0';
	}

	ans = solve(t,len,0);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
digits = Array.new(n, 0)
digits[0] = 1 if n > 1
decided = Array.new(n, false)
ok = true
m.times do
  s, c = gets.split.map(&:to_i)
  if !decided[s-1]
    if n > 1 && s == 1 && c == 0
      ok = false
    else
      digits[s-1] = c
      decided[s-1] = true
    end
  else
    ok = false if digits[s-1] != c
  end
end
puts (ok) ? digits.join : -1


Measured memory_bytes: 1788
#include<cstdio>

long n;
int cnt[1000000];

int main() {
    int p = -1;
    scanf("%ld", &n);
    for (int i = 2; static_cast<long>(i) * i <= n; i++) {
        if (n % i == 0) p++;
        while(n % i == 0) {
            cnt[p]++;
            n /= i;
        }
    }
    if (n > 1) cnt[++p] = 1;
    int ans = 0;
    for (int i = 0; i <= p; i++) {
        int j;
        for (j = 1; j * (j + 1) <= cnt[i] * 2; j++) continue;
        ans += j - 1;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1692
#include <iostream>
using namespace std;
int main(void){
  int n, k;
  long long zohe = 0, ehoz = 0;
  
  cin >> n >> k;

  zohe = n / k;
  
  if (k % 2 == 0)
    for (int i = 1; k * i - k / 2 <= n; i++)
      ehoz++;
  
  cout << zohe * zohe * zohe + ehoz * ehoz * ehoz << endl;
}


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

using namespace std;

int cnt[1000][1000];
int c_sum[1000][1000];

int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> L(M), R(M);
    for(int i = 0; i < M; ++i){
        cin >> L[i] >> R[i];
    }
    vector<int> p(Q), q(Q);
    for(int i = 0; i < Q; ++i){
        cin >> p[i] >> q[i];
    }
    
    for(int i = 0; i < M; ++i){
        cnt[L[i]][R[i]]++;
    }
    
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= N; ++j){
            c_sum[i][j] = c_sum[i][j - 1] + cnt[i][j];
        }
    }
    
    for(int i = 0; i < Q; ++i){
        int ans = 0;
        
        for(int j = p[i]; j <= q[i]; ++j){
            ans += c_sum[j][q[i]] - c_sum[j][p[i]-1];
        }
        
        cout << ans << endl;
    }
}

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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}
template<typename T>T power(T a,T b){
  T tmp = 1;
  rep(i,b){
    tmp *= a;
  }
  return tmp;
}
int main(){
  string s;
  cin>>s;
  int ans = 0;
  bool black = s[0] == 'B';
  rep(i,s.size()){
    if(black && s[i] != 'B'){
      ans++;
      black = false;
    }
    if(!black && s[i] != 'W'){
      ans++;
      black = true;
    }
  }
  print(ans)
  return 0;
}


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

using namespace std;

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

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

  bool so = true;
  for(int i = 0; i < n-1; i++){
    if(a[i] == a[i+1]){
      so = false;
      break;
    }
  }
  if(so) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;

}


Measured memory_bytes: 1400
#include<stdio.h>
int main(void){
   int i,j,n,m;
   char a[1000];
   gets(a);
   for(i=0;i<1000;i++){
      int f=0;
      if(a[i]=='p')if(a[i+1]=='e')if(a[i+2]=='a')if(a[i+3]=='c')if(a[i+4]=='h')f=1;

      if(f==1){
         a[i]='a';
         a[i+1]='p';
         a[i+2]='p';
         a[i+3]='l';
         a[i+4]='e';
         i+=4;
         continue;
      }
       if(a[i]=='a')if(a[i+1]=='p')if(a[i+2]=='p')if(a[i+3]=='l')if(a[i+4]=='e')f=1;
      if(f==1){
         a[i]='p';
         a[i+1]='e';
         a[i+2]='a';
         a[i+3]='c';
         a[i+4]='h';
         i+=4;
      }
   }
   printf("%s\n",a);

   return 0;

}

Measured memory_bytes: 524
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const ll inf=1e9;
const int MAX = 510000;
const ll MOD = 998244353;

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

int main(){
  string s;cin>>s;
  ll n=s.size();
  vll c(3,0);
  rep(i,0,n){
    c[s[i]-'a']++;
  }
  ll m=max(c[0],max(c[1],c[2]));
  ll w=min(c[0],min(c[1],c[2]));
  if(m-w<=1)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}






Measured memory_bytes: 3752
#!/mnt/c/Users/moiki/bash/env/bin/python

c = [ list(map(int, input().split())) for _ in range(3)]


b = [False, False, False, False]

if len( list( filter(lambda x: x==(c[1][0] - c[0][0]), [ c[1][j]  - c[0][j] for j in range(3)]))) == 3:
    # print(list( filter(lambda x: x==(c[1][0] - c[0][0]), [ c[1][j]  - c[0][j] for j in range(3)])))
    b[0] = True
if len( list( filter(lambda x: x==(c[2][0] - c[1][0]), [ c[2][j]  - c[1][j] for j in range(3)]))) == 3:
    b[1] = True
if len( list( filter(lambda x: x==(c[0][0] - c[0][1]), [ c[i][0]  - c[i][1] for i in range(3)]))) == 3:
    b[2] = True
if len( list( filter(lambda x: x==(c[0][2] - c[0][1]), [ c[i][2]  - c[i][1] for i in range(3)]))) == 3:
    b[3] = True

if len( list(filter(lambda x: x, b))) == 4:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    ll now = 2, ans = 1;
    for(int i = 1; i < n; i++){
        if(now == 2){
            if(a[i-1] < a[i]) now = 3;
            else if(a[i-1] > a[i])now = 1;
        }
        else if(a[i-1] < a[i] && now == 1){
            ans++;
            now = 2;
        }
        else if(a[i-1] > a[i] && now == 3){
            ans++;
            now = 2;
        }
    }
    cout << ans << endl;
}      

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1e9+7;

int main(){
    int n;
    cin >> n;
    map<int, ll> mp;
    vi v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        mp[v[i]]++;
    }
    ll ans = 0;
    for (auto it : mp) {
        ans += it.S * (it.S-1)/2;
    }
    for (int j = 0; j < n; ++j) {
        ll t = mp[v[j]];
        cout << ans - t*(t-1)/2 + (t-1)*(t-2)/2 << endl;
    }
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
int n,a[200100],b[200100],cnt[200100],res[200100],f[400100],g[200100],nxt[200100];
void kmp(){
	for(int i=2,j=0;i<=n;i++){
		while(j&&g[j+1]!=g[i])j=nxt[j];
		if(g[j+1]==g[i])j++;
		nxt[i]=j;
	}
	for(int i=1,j=0;i<2*n;i++){
		while(j&&g[j+1]!=f[i])j=nxt[j];
		if(g[j+1]==f[i])j++;
		if(j==n)cnt[i-n+1]++,j=nxt[j];
	}
}
bool ok[200100];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),res[i]=0;
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=0;i<30;i++){
		for(int j=1;j<=n;j++)f[j]=f[j+n]=(a[j]&(1<<i))>0,g[j]=(b[j]&(1<<i))>0,cnt[j]=ok[j]=0;
		kmp();
//		for(int j=1;j<=2*n;j++)printf("%d",f[j]);puts("");
//		for(int j=1;j<=n;j++)printf("%d",g[j]);puts("");
//		printf("%d1:",i);for(int j=1;j<=n;j++)printf("%d ",cnt[j]);puts("");
		for(int j=1;j<=n;j++){
			g[j]^=1;
			if(res[j]!=-1&&cnt[j])ok[j]=true;
			cnt[j]=0;
		}
		kmp();
//		printf("%d2:",i);for(int j=1;j<=n;j++)printf("%d ",cnt[j]);puts("");
		for(int j=1;j<=n;j++)if(res[j]!=-1&&cnt[j])res[j]|=(1<<i),ok[j]=true;
		for(int j=1;j<=n;j++)if(!ok[j])res[j]=-1;
	}
	for(int i=1;i<=n;i++)if(res[i]!=-1)printf("%d %d\n",i-1,res[i]);
	return 0;
}

Measured memory_bytes: 9856
// Problem : 
// 			B - Comparing Strings
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 152
// URL : https://atcoder.jp/contests/abc152/tasks/abc152_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)             (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)         cout << #x << " = " << x << endl
#define trace(x)         cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	int a,b; cin>>a>>b;
	string x = "", y = "";
	fo(i,b) x += (char)(a+'0');
	fo(i,a) y += (char)(b+'0');
	cout<<min(x,y);
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<float> a(n);
  float sum=0;
  REP(i,n){
    cin >> a[i];
	sum+=a[i];
  }
  float ave = sum/n;
  float min=INF;
  int ans;
  
  REP(i,n){
    if(min>abs(a[i]-ave)){
      min = abs(a[i]-ave);
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x, vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1, s) + f(x - 2, s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
void press(string& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

int main() {
	int a[3][3];
	rep(i, 0, 3)rep(j, 0, 3)cin >> a[i][j];
	int n;
	cin >> n;
	hei(int) b(n);
	rep(i, 0, n)cin >> b[i];
	char s[3][3]={'x'};
	rep(i, 0, 3)rep(j, 0, 3) {
		rep(k, 0, n) {
			if (a[i][j] == b[k]) {
				s[i][j] = 'o';
				break;
			}
		}
	}
	rep(i, 0, 3) {
		if (s[i][1] == s[i][2] && s[i][0] == s[i][1] && s[i][0] == 'o') {
			cout << "Yes" << endl;
				return 0;
		}
	}
	rep(i, 0, 3) {
		if (s[1][i] == s[2][i] && s[0][i] == s[1][i] && s[0][i] == 'o') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (s[0][0] == s[1][1] && s[1][1] == s[2][2] && s[0][0] == 'o') {
		cout << "Yes" << endl;
		return 0;
	}
	if (s[2][0] == s[1][1] && s[1][1] == s[0][2] && s[1][1] == 'o') {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {

int n,a,b;
string s;
cin>>n>>a>>b>>s;
int foreign=0,japan=0,sum=0;
Vec vec(n,0);
for(int i=0;i<n;i++){
    if(sum>=a+b){
        break;
    }
    if(s.at(i)=='a'){
        sum++;
        japan++;
        vec.at(i)=1;
    }
    else if(s.at(i)=='b' && foreign<b){
        foreign++;
        sum++;
        vec.at(i)=1;
    }

}
for(int i=0;i<n;i++){
    if(vec.at(i)==0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}
 
}

Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n;
  cin >> n;
  string s;
  cin >> s;
  if (n & 1) {
    cout << "No" << endl;
    return 0;
  }
  bool ok = true;
  rep(i, n / 2) {
    if (s[i] != s[n / 2 + i]) ok = false;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 888
#include <cstdio>

typedef long long int ll;

ll h;

ll getans(ll x) {
    if (x == 0) {
        return 0;
    }
    else if (x == 1) {
        return 1;
    }
    else {
        return (getans(x >> 1) << 1) + 1;
    }
}

int main() {
    scanf("%lld", &h);
    printf("%lld", getans(h));
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>


#define ZERO(p) memset(p, 0, sizeof(p))

int main() {
    int N;
    std::cin >> N;
    int MAXNUM = 100000;
    int max=0;
    int counter[MAXNUM+2];
    ZERO(counter);
    for(int i=0;i<N;i++) {
        int a;
        std::cin >> a;
        //counter[i]はi+1の数
        counter[a] = counter[a] + 1;
        counter[a+1] = counter[a+1] + 1;
        counter[a+2] = counter[a+2] + 1;
        int candidate;
        if(max < counter[a] ) {
            max = counter[a];
        }
        if(max < counter[a+1] ) {
            max = counter[a+1];
        }
        if(max < counter[a+2] ) {
            max = counter[a+2];
        }
    }
    std::cout << max << std::endl;
}

Measured memory_bytes: 640
def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i-1
        while j>=0 and A[j]>v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join(map(str,A)))
        
n = int(input())
a = list(map(int, input().split()))

print(" ".join(map(str, a)))
insertionSort(a, n)


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

int n,ans;
char s[30005];
bool t[1000][3];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    cin>>s+1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=99;j++){
            if(t[j][1])t[j*10+s[i]-'0'][2]=true;
        }
        for(int j=0;j<=9;j++){
            if(t[j][0])t[j*10+s[i]-'0'][1]=true;
        }
        t[s[i]-'0'][0]=true;
    }
    for(int j=0;j<=999;j++){
        ans+=t[j][2];
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }else if (A + B > C + D){
    cout << "Left" << endl;}
  
 
  else {
    cout << "Right" << endl;
  }
}

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

// Defines 

#define all(v) v.begin(),v.end()
#define int long long int

// Global Constants

const int N = 1e5 + 10;
const int mod = 1e6 + 3;

// Template Functions 

int mul(int a,int b)
{
	return (a*b)%mod;
}

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

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

int binpow(int a,int b)
{
	int res = 1;
	while(b)
	{
		if(b&1) res *= a;
		a *= a;
		b >>= 1;
	}
	return res;
}

int modpow(int a, int b,int mod)
{
	int res = 1;
	while(b)
	{
		if(b&1) res = (res*a)%mod;
		a = (a*a)%mod;
		b >>= 1;
	}
	return res%mod;
}
int gcd(int a, int b)
{
	while(b)
	{
		a%=b;
		swap(a,b);
	}
	return a;
}

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

vector<int> primes(N+1,true);

void seive()
{
	primes[0] = primes[1] = false;
	for(int i=2;(long long)i*i<=N;++i)
	{
		if(primes[i])
		{
			for(int j=i*i;j<=N;j+=i)
			{
				primes[j] = false;
			}
		}
	}
}

int modinv(int p,int mod)
{
	return modpow(p,mod-2,mod);
}
// Global Variables 

int pref[mod + 3];

// Functions for program

	int solve()
	{
		int x,d,n;
		cin >> x >> d >> n;
		if(n == 0) return 1;
		if(x == 0) return 0;
		if(d == 0) return modpow(x,n,mod);
		x = mul(x,modinv(d,mod));
		if(x + n - 1 >= mod) return 0;
		int res = mul(pref[x+n-1],modinv(pref[x-1],mod));
		res = mul(res,modpow(d,n,mod));
		return res;		
	}			
// Main ...........................................................


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	pref[0] = 1;
	
	for(int i = 1; i < mod; ++i)
			pref[i] = mul(pref[i-1],i);
			
	int q;
	cin >> q;
	while(q--)
		cout << solve() << '\n';
	return 0;
}


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

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

    vector<int> w(n);

    rep(i,n){
        cin >> w[i];
    }

    int mini = INF;
    
    rep(i,n){
        int mae=0;
        int usiro=0;
        rep(j,i){
            mae +=w[j];
        }
        for(int j=i;j<n;j++){
            usiro +=w[j];
        }
        
        mini = min(mini,abs(mae-usiro));
        
    }

    cout << mini << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int h1, m1, h2, m2, k; scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
  h1 = h1*60+m1;
  h2 = h2*60+m2;
  h2 -= k;
  printf("%d", max(h2-h1, 0));
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3848
class Lagrange:
  def __init__(self, lst):
    self.lst = lst
    self.mod = mod

  def prd(self, j, x):
    tmp = 1
    for i, (xi, yi) in enumerate(self.lst):
      if j != i:
        tmp *= (x - xi)
        tmp %= self.mod
    return tmp

  def pln(self, x):
    tmp = 0
    for i, (xi, yi) in enumerate(self.lst):
      tmp += yi * (self.prd(i, x) *
                   pow(self.prd(i, xi), self.mod - 2, self.mod))
      tmp %= self.mod
    return tmp

MAX = 40
mod = 10**9+7
fact = [1]*(MAX+1)
for i in range(1, MAX+1):
    fact[i] = (fact[i-1]*i) % mod

inv = [1]*(MAX+1)
for i in range(2, MAX+1):
    inv[i] = inv[mod % i]*(mod-mod//i) % mod

fact_inv = [1]*(MAX+1)
for i in range(1, MAX+1):
    fact_inv[i] = fact_inv[i-1] * inv[i] % mod

def comb(n, k):
    if n < k:
        return 0
    return fact[n] * fact_inv[n-k] * fact_inv[k] % mod

def f(n):
  tmp = 0
  for x in range(n):
    tmp += comb(x+4,4)*comb(n-2*x+5,10)
    tmp %= mod
  return tmp

c0 = [(i*2, f(i*2)) for i in range(16)]
c1 = [(i*2+1, f(i*2+1)) for i in range(16)]

a0 = Lagrange(c0)
a1 = Lagrange(c1)

t = int(input())
for _ in range(t):
  n = int(input())
  if n % 2 == 0:
    print(a0.pln(n))
  else:
    print(a1.pln(n))

Measured memory_bytes: 74064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod = 1000000007;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    int n;
    map<int,int> a_mp;
    a_mp[-1] = 0;
    map<int,int> b_mp;
    b_mp[-1] = 0;
    map<int,int>::iterator itr;
    cin >> n;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        if(i%2==0){
            // a_mp
            itr = a_mp.find(tmp);
            if(itr!=a_mp.end()){
                // すでに入ってる
                a_mp[tmp] += 1;
            }
            else{
                a_mp[tmp] = 1;
            }
        }
        else{
            // b_mp
            itr = b_mp.find(tmp);
            if(itr!=b_mp.end()){
                b_mp[tmp] += 1;
            }
            else{
                b_mp[tmp] = 1;
            }
        }
    }

    // a,bそれぞれ
    int a_num = 0;
    int a_1;
    for(itr = a_mp.begin(); itr!=a_mp.end(); itr++){
        if(a_num < itr->second){
            a_1 = itr->first;
            a_num = itr->second;
        }
    }
    int a_num_second = 0;
    int a_2;
    for(itr = a_mp.begin(); itr!=a_mp.end(); itr++){
        if(a_num_second <= itr->second && itr->first !=  a_1) {
            a_2 = itr->first;
            a_num_second = itr->second;
        }
    }

    int b_num = 0;
    int b_1;
    for(itr = b_mp.begin(); itr!=b_mp.end(); itr++){
        if(b_num < itr->second){
            b_1 =  itr->first;
            b_num = itr->second;
        }
    }
    int b_num_second = 0;
    int b_2;
    for(itr = b_mp.begin(); itr!=b_mp.end(); itr++){
        if(b_num_second <= itr->second && itr->first != b_1){
            b_2 =  itr->first;
            b_num_second = itr->second;
        }
    }

    int ans = 0;
    int ans_1=0,ans_2=0;
    if(a_1==b_1){
        ans_1 += (n/2)-a_num;
        ans_1 += (n/2)-b_num_second;

        ans_2 += (n/2)-a_num_second;
        ans_2 += (n/2)-b_num;

        ans = min(ans_1, ans_2);
    }
    else{
        ans += (n/2)-a_num;
        ans += (n/2)-b_num;
    }
    cout << ans;
    return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;

    int ans = (A + B) / 2;

    if ((A + B) % 2 == 0) {
        cout << ans << endl;
    }
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  ll l,r; cin >> l >> r;

  r = min(r,l+2019);

  ll mod = 2019;
  ll ans = INF_LL;
  for(ll i = l;i<=r;i++){
    for(ll j = i+1;j<=r;j++){
      if(i>=j) continue;
      
      ll tmp = i*j;
      tmp %= mod;
      ans = min(ans,tmp);
    }
  }

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


Measured memory_bytes: 3632
N, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())))[::-1]

## 修行前の最短: M
M = max([a*f for a, f in zip(A, F)])

## 積の最小をxにできるか。
## x//f以下である必要がある。
def is_possible(x):
    return sum([max(0, a-x//f) for a, f in zip(A, F)]) <= K

## 2分探索
left = -1
right = M
while left + 1 < right:
    mid = (left + right)//2
    if is_possible(mid):
        right = mid
    else:
        left = mid

print(right)

Measured memory_bytes: 136824
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

vector<vector<int>> dp;
vector<pair<int,int>> A;


int main()
{
    int N,T;
    cin >> N >> T;
    A.resize(N);
    rep(i,N) cin >> A[i].first >> A[i].second;
    dp.assign(N+1,vector<int>(T+1,0));
    sort(all(A));
    for (int i = 0; i < N-1; i++) {
        for (int j = 0; j < T; j++) {
            if(j < A[i].first) dp[i+1][j] = dp[i][j];
            else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-A[i].first]+A[i].second);
            }
        }
        dp[i+1][T] = max(dp[i][T], dp[i+1][T-1]+A[i+1].second);
    }
    
    
       
    cout << dp[N-1][T] << endl;
    
    return 0;
}



Measured memory_bytes: 35584
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<deque>
using namespace std;
#define ll long long
#define rg register
#define inf 0x3f3f3f3f
#define MX 100005
#define fi first
#define se second
typedef pair<int,int> PA;
deque<PA> que;
int dis[MX];
int n;
int main(){

    scanf("%d",&n);
    memset(dis,inf,sizeof(dis));
    que.push_front(make_pair(1,1));
    while(1)
    {
        PA x=que.front();que.pop_front();
        if(dis[x.fi]<=x.se) continue;
        else dis[x.fi]=x.se;
        if(x.fi==0) break;
        if(x.fi%10!=9) que.push_back(make_pair(x.fi==n-1?0:x.fi+1,x.se+1));
        que.push_front(make_pair(x.fi*10%n,x.se));
    }
    printf("%d\n",dis[0]);
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  if(n%(a+b)==0)cout<<a*(n/(a+b))<<endl;
  else{
    if(n%(a+b)<=a)cout<<a*(n/(a+b))+n%(a+b)<<endl;
    else{
      cout<<a*(1+(n/(a+b)))<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$K) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
//$H = explode(" ",trim(fgets(STDIN)));

function combine() {
    $args = func_get_args();

    $a = array_shift($args);
    $b = array_shift($args);

    $result = array();
    foreach ($a as $val1) {
        foreach ($b as $val2) {
            $result[] = array_merge((array)$val1, (array)$val2);
        }
    }

    if (count($args) > 0) {
        foreach ($args as $arg) {
            $result = combine($result, $arg);
        }
    }

    return $result;
}
$p = [3,5,7];
$n=0;
switch(strlen($N)) {
case 9:
  $n+=ncnt(combine($p,$p,$p,$p,$p,$p,$p,$p,$p));
case 8:
  $n+=ncnt(combine($p,$p,$p,$p,$p,$p,$p,$p));
case 7:
  $n+=ncnt(combine($p,$p,$p,$p,$p,$p,$p));
case 6:
  $n+=ncnt(combine($p,$p,$p,$p,$p,$p));
case 5:
  $n+=ncnt(combine($p,$p,$p,$p,$p));
case 4:
  $n+=ncnt(combine($p,$p,$p,$p));
case 3:
  $n+=ncnt(combine($p,$p,$p));
}
printf("%d\n",$n);

function ncnt($a) {
  global $N;
  $l = array();
  foreach($a as $v) {
    $s = implode("",$v);
    if ((strpos($s,"3")!==false)
    && (strpos($s,"5")!==false)
    && (strpos($s,"7")!==false)) {
      if ($s <= $N) {
        $l[]=$s;
      }
    }
  }
  return count($l);
}


Measured memory_bytes: 36084
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num[]=new int[100];
        while(sc.hasNext()){
        	int n=sc.nextInt();
        	num[n-1]++;
        }
        int max=0;
        for(int i=0;i<num.length;i++){
        	if(max<num[i])max=num[i];
        }
        int ans[]=new int[100];
        int cnt=0;
        for(int i=0;i<num.length;i++){
        	if(max==num[i]){
        		ans[cnt]=i+1;
        		cnt++;
        	}
        }
        for(int i=0;i<cnt;i++){
        	System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 18272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 5e5 + 7;
const int mod = 1e9 + 7;
int sum[maxn<<2];
void pushup(int rt){
	sum[rt] = sum[rt << 1]|sum[rt << 1|1];
	return;
}
void build(int rt,int l,int r){
	if(l == r){
		char ch; cin >> ch;
		sum[rt] = (1 << (ch - 'a'));
		return;
	}
	int m = (l+r)/2;
	build(rt<<1,l,m);
	build(rt<<1|1,m+1,r);
	pushup(rt);
	return;
}
void update(int rt,int pos,int l,int r,int w){
	if(l == r){
		sum[rt] = w;
		return;
	}
	int m = (l+r)/2;
	if(pos<=m) update(rt<<1,pos,l,m,w);
	else update(rt<<1|1,pos,m+1,r,w);
	pushup(rt);
	return;
}
int query(int rt,int L,int R,int l,int r){
	if(L <= l && r <= R) return sum[rt];
	int ans = 0;
	int m = (l+r) >> 1;
	if(L <= m) ans |= query(rt << 1,L,R,l,m);
	if(R > m) ans |= query(rt << 1|1,L,R,m+1,r);
	return ans;
}
int cal(int k){
	int ans = 0;
	while(k){
		k -= k & (-k);
		ans++;
	}
	return ans;
}
int main(){
	int n;
	scanf("%d",&n);
	build(1,1,n);
	int q; scanf("%d",&q);
	while(q--){
		int d; scanf("%d",&d);
		if(d == 1){
			int idx; char ch;
			scanf("%d %c",&idx,&ch);
			update(1,idx,1,n,(1<<(ch-'a')));
		}
		if(d == 2){
			int l,r;
			scanf("%d %d",&l,&r);
			printf("%d\n",cal(query(1,l,r,1,n)));
		}
	}
	return 0;
}

Measured memory_bytes: 6400
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
list=input().split(" ")
num1=int(list[0])
num2=int(list[1])


probability_i=[]

for i in range(1,num1+1):
    count=0
    point=i
    while point<num2:
        point+=point
        count+=1
    prob=1/num1*(1/2)**count
    probability_i.append(prob)
ans=0
for j in probability_i:
    ans+=j
if ans>1:
    ans=1
print(ans)

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

#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  int N;
  cin >> N;
  long long int r = 1;
  REP(i, N){
    r = MOD7(r*(i+1));
  }
  cout << r << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first 
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n<0)return 0;if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(),x.end()
#define Return(x) {cout << x << endl; return 0;}

int__ main() {
    int n,k,c; cin >> n >> k >> c;
    string s; cin >> s;

    const int nax = 2e5 + 10;

    int l[nax]={},r[nax]={};

    int last = -3e5;

    for(int i=1;i<=n;i++) {
        if(s[i-1]=='o' and last + c < i) {
            last = i;
            l[i] = l[i-1] + 1;
        }
        else l[i] = l[i-1];
    }

    last = 3e5;
    for(int i=n;i>0;i--) {
        if(s[i-1]=='o' and last - c > i) {
            last = i;
            r[i] = r[i+1] + 1;
        }
        else r[i] = r[i+1];
    }

    for(int i=1;i<=n;i++) {
        if(l[i-1]+r[i+1] < k) cout << i << endl;
    }

}

Measured memory_bytes: 4996
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;

int main(){
    int x,y;
    int gx=0,gy=0;
    cin >> x >> y;
    vector<int> g1 ={1,3,5,7,8,10,12};
    vector<int> g2 = {4,6,9,11};

    for(auto a : g1){
        if(x == a) gx = 1;
        if(y == a) gy = 1;
    }
    for(auto a : g2){
        if(x == a) gx = 2;
        if(y == a) gy = 2;
    }
    if(x == 2) gx = 3;
    if(y == 2) gy = 3;

    if(gx == gy){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		int result = 1000000;
		for(int i = 1; i < 101; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				sum += (X[j] - i) * (X[j] - i);
			}
			result = Math.min(result, sum);
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 23636
a=int(input())

b=0
c=0
d=0
e=0

for i in range(a):
  name=input()

  if name=='AC':
    b+=1
  elif name=='WA':
    c+=1
  elif name=='TLE':
    d+=1
  elif name=='RE':
    e+=1

print('AC'+' x '+str(b))
print('WA'+' x '+str(c))
print('TLE'+' x '+str(d))
print('RE '+' x '+str(e))



Measured memory_bytes: 9208
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		String[] c = s.split("");

		int ans = 0;
		boolean isAns = false;
		for(int i = c.length / 2 - 1; i >= 1; i--){
			if(c[0].equals(c[i])){
				isAns = true;
				for(int j = 1; j < i - 1; j++){
					if(!c[j].equals(c[i + j])){
						isAns = false;
					}
				}
				if(isAns){
					ans = i * 2;
					break;
				}
			}
		}

		System.out.print(ans);
	}
}


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

bool isSame(vector<int> &D) {
    return (D[0] == D[1]) && (D[1] == D[2]);
}

int main() {
    vector<int> D(3);
    cin >> D[0] >> D[1] >> D[2];
    sort(D.begin(), D.end());

    int op = 0;
    while (D[1] < D[2]) {
        ++D[0];
        ++D[1];
        ++op;
    }
    if (isSame(D)) {
        cout << op << endl;
        return 0;
    }

    while (D[0] < D[1]) {
        D[0] += 2;
        ++op;
    }
    if (isSame(D)) {
        cout << op << endl;
        return 0;
    }

    // 超えたら最後に辻褄合わせ
    ++D[1];
    ++D[2];
    ++op;
    cout << op << endl;

}


Measured memory_bytes: 3480
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int N;
int F[100][5][2];
int P[100][11];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) { 
        for (int j = 0; j < 5; j++) {
            for (int k = 0; k < 2; k++) {
                cin >> F[i][j][k];
            }
        }
    }
    for (int i = 0; i < N; i++) { 
        for (int j = 0; j <= 10; j++) {
            cin >> P[i][j];
        }
    }
    int res = -1000000000;
    for (int s = 1; s < (1 << 10); s++) {
        int tmp = 0;
        for (int shop = 0; shop < N; shop++) {
            int c = 0;
            for (int d = 0; d < 10; d++) {
                if (((1 << d) & s) > 0 && F[shop][d%5][d/5] == 1) c++;
            }
            tmp += P[shop][c];
        }
        
        chmax(res,tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<ll> a(n);
    read(a);
    sort(all(a));
    __int128_t sum = 1, m = 1000000000000000000LL;
    for (int i = 0; i < n; i++) {
        sum *= __int128_t(a[i]);
        if (sum > m) {
            cout << -1 << newl;
            return 0;
        }
    }
    cout << ll(sum) << newl;
}

Measured memory_bytes: 3992
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

cin>>t;

 map<string,ll>mp;

 string str;

   for(i=0; i<t; i++)
   {
       cin>>str;

       sort(vll(str));

       mp[str]++;

       ans+=mp[str]-1;


   }

   cout<<ans<<endl;











}



Measured memory_bytes: 11336
#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define LINF 9223372036854775807
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define all(a) a.begin(),a.end()
#define sz(a) (int)a.size()
#define F first
#define S second
#define LOCAL_JUDGE 1 //remember to change
using namespace std;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	int res=a[2]-a[1];
	//cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<res<<endl;
	a[0]+=res;
	if((a[2]-a[0])%2) res+=(a[2]-a[0])/2+2;
	else res+=(a[2]-a[0])/2;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256