akhauriyash/Code-Regression huggingface dataset:
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> H(N);
    FOR(i, 0, N){
        cin >> H[i];
    }

    vector<int> A(M), B(M);
    FOR(i, 0, M){
        cin >> A[i] >> B[i];
    }

    vector<bool> state(N, true);
    FOR(i, 0, M){
        if(H[A[i]-1]>H[B[i]-1])
            state[B[i]-1] = false;
        else if (H[A[i]-1]<H[B[i]-1])
            state[A[i]-1] = false;
        else
            state[A[i]-1] = state[B[i]-1] = false;
    }

    auto num = count(state.begin(), state.end(), true);

    cout << num << endl;

}


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

using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int n,m,x,y,visit[100001],dp[100001],ans;
vector <int> v[100001];
int dfs(int i)
{
    visit[i]=1;
    for(int j=0;j<v[i].size();j++)
    {
        if(visit[v[i][j]])ans=dp[v[i][j]]+1;
        else
        {
        ans=dfs(v[i][j])+1;
        }
         dp[i]=max(dp[i],ans);
    }
    return dp[i];
}

int main()
{
    cin>>n>>m;
    memset(dp,0,n);
    
    while(m--)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    int ans1=0;
  //  cout<<dfs(1);
    for(int i=1;i<=n;i++)
    {
        if(!visit[i])
       ans1=max(dfs(i),ans1);
    }

    cout<<ans1;

}



Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int n,k,x,y; cin>>n>>k>>x>>y;
    if(n>k){
        cout<<k*x+(n-k)*y<<endl;
    }else{
        cout<<n*x<<endl;
    }
    
}


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


void solve() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    int ans = 0;
    if(k <= a) ans = k;
    else if(k <= a+b) ans = a;
    else {
        ans = a - (k - a - b);
    }
    cout << ans << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    // cin >> T;
    for(int i=1; i<=T; i++) {
        solve();
    }
    return 0;
}

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

int main() {
  //宣言
  int N, K;
  int ans = 1;
  
  //入力
  cin >> N >> K;
  
  //処理
  for(int i = 0;i < N; i++){
    if(ans < K){
      ans += ans;
    }else{
      ans += K;
    }
  }
  
  //出力
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

bool dp[1001][2001];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        vi r(n),w(n);
        rep(i,n){
            cin >> r[i] >> w[i];
        }
        int sm = accumulate(all(r),0);
        int mx = *max_element(all(r));
        sort(all(w));
        if(sm >= 2*mx){
            cout << sm + accumulate(all(w),0) << "\n";
        }else{
            rep(i,n){
                rep(j,2*mx-sm+1){
                    dp[i][j] = false;
                }
            }
            dp[0][0] = true;
            rep(i,n-1){
                rrep(j,2*mx-sm+1){
                    if(dp[i][j]){
                        dp[i+1][j] = true;
                    }
                    if(j >= w[i] && dp[i][j-w[i]]){
                        dp[i+1][j] = true;
                    }
                }
            }
            int num = 0;
            rep(i,2*mx-sm+1){
                if(dp[n-1][i]){
                    num = i;
                }
            }
            cout << 2*mx + accumulate(all(w),0) - num << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 5036
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int a, b;
    cin >> a >> b;
    a--; b--;
    int group[] = { 0,2,0,1,0,1,0,0,1,0,1,0 };
    YESNO(group[a] == group[b], "Yes", "No");
    return 0;
}

Measured memory_bytes: 256
def main():
  N = int(input())
  A = list(map(int, input().split()))

  if 0 in A:
    print(0)
    return
  
  num = 1
  max_num = 10**18
  for i in A:
    num *= i
    
    if num > max_num:
      print(-1)
      return
  
  print(num)
  
main()

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

int main() {

  int N;
  cin >> N;

  vector<int> number(100100);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    number[a]++;
  }

  int mod = 1000000000 + 7;
  
  bool valid = true;

  if (N % 2 != 0) {
    if (number[0] != 1) {
      valid = false;
    } else {
      for (int i = 1; i < N; i++) {
        if (i % 2 == 0) {
          if (number[i] != 2) {
            valid = false;
            break;
          }
        } else {
          if (number[i] != 0) {
            valid = false;
            break;
          }
        }
      }
    }
  } else {
    if (number[0] != 0) {
      valid = false;
    } else {
      for (int i = 1; i < N; i++) {
        if (i % 2 == 0) {
          if (number[i] != 0) {
            valid = false;
            break;
          }
        } else {
          if (number[i] != 2) {
            valid = false;
            break;
          }
        }
      }
    }
  }

  if (valid){

    int count = 1;

    for (int i = 1; i <= N / 2; i++) {
      count = (count * 2) % mod;
    }

    cout << count << endl;

  } else {

    cout << 0 << endl;
  
  }

}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define D double
#define int long long


class BCraneAndTurtle {
public:
    void solve(std::istream &in, std::ostream &out) {
      int x, y;
      in >> x >> y;
      int t = (y - 2 * x) / 2;
      double u = (D) (y - 2 * x) / 2;
      int v = (4 * x - y) / 2;
      if (t >= 0 && v >= 0 && t == u) {
        out << "Yes" << endl;
      } else {
        out << "No" << endl;
      }
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  BCraneAndTurtle solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3652
from math import gcd
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    max_A = max(A) + 10

    CNT = [0] * max_A
    for a in A:
        CNT[a] += 1

    bl = True
    for i in range(2, max_A):
        cnt = 0
        for j in range(i, max_A, i):
            cnt += CNT[j]
        if cnt > 1:
            bl = False
    if bl:
        print("pairwise coprime")
        return

    g = 0
    for i in range(N):
        g = gcd(g, A[i])
    if g == 1:
        print("setwise coprime")
        return

    print("not coprime")


if __name__ == "__main__":
    resolve()


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

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

  int c = 1;
  int ans = 0;
  while (c < b) {
    c += a - 1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,K = (int(x) for x in input().rstrip('\n').split())
red = 1
blue = 1
res = 1
sub = N-K+1
for i in range(1,K+1):
  red = red*(N-K+2-i)//i
  if i==1:
    blue = 1
  else:
    blue = blue*(K+1-i)//(i-1)
  res = red*blue
  print(res%1000000007)
  

Measured memory_bytes: 9068
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;

int dx[] = { -1, 1, 0, 0  };
int dy[] = {  0, 0, 1, -1 };
vector< vector<char> > maze;

int h, w;
int bfs() {
  vector<vector<int>> dist(h, vector<int>(w, -1));
  dist[0][0] = 0;
  queue<pair<int, int>> q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    auto cur = q.front(); q.pop();
    int x = cur.first, y = cur.second;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || ny < 0 || nx >= w || ny >= h) { continue; }
      if (dist[ny][nx] != -1) { continue; }
      if (maze[ny][nx] == '#') { continue; }
      dist[ny][nx] = dist[y][x] + 1;
      q.push(make_pair(nx, ny));
    }
  }
  return dist[h-1][w-1];
}

int main() {
  cin >> h >> w;
  maze.assign(h, vector<char>(w, 0));

  int cnt_black = 0;
  for (int y = 0; y < h; y++) {
    string t; cin >> t;
    for (int x = 0; x < t.size(); x++) {
      maze[y][x] = t[x];
      if (t[x] == '#') { cnt_black++; }
    }
  }

  int dist = bfs();

  if (dist == -1) {
    cout << -1 << endl;
  } else {
    cout << h*w-(dist + 1)-cnt_black << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
  const int N=2e5+2;

  int32_t main()
  {
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
       IOS
       int n,d=0,a,b;
       bool last = false, ans = false;
       cin>>n;
       while(n--)
       {
          cin>>a>>b;
          if(a==b)
          {
            if(last)
              d++;
            else
            {
              d=1;

            }
            last = true;
            if(d>=3)
            {  ans = true;
              cout<<"Yes"; return 0;}
          }
          else
            last = false;

          }
       
          cout<<"No";
          return 0;
    }

Measured memory_bytes: 3652
import bisect

def solve():
  n = int(input())
  L = [int(i) for i in input().split()]
  L.sort()
  total = 0
  for s in range(n-2):
    for m in range(s+1, n-1):
      #二分探索モジュールbisect
      l = bisect.bisect_left(L,L[s]+L[m], 0, n)
      if l>m: total += l-m-1
  print(total)

  return 0

if __name__ == "__main__":
  solve()

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

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	int work[n];

	for(int i = 0; i < n-1 ; i++){
		scanf("%d",&a[i]);
	}	
	for(int i = 0; i < n ; i++){
		work[i]=0;	
	}

	for(int i = 0; i < n-1 ; i++){
		work[a[i]-1] += 1;	
	}
	
	for(int i = 0; i < n ; i++){
		printf("%d\n",work[i]); 
	}
}

Measured memory_bytes: 5372
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
	p,s=input().split()
	if(s=="AC"):
		ac[int(p)-1]=1
	else:
		if(ac[int(p)-1]==0):
			wa[int(p)-1]+=1
x=sum(ac)
y=0
for i in range(n):
	y+=ac[i]*wa[i]
print(x,y)

Measured memory_bytes: 4596
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <tuple>
using namespace std;

typedef pair<int,int> P;//駅id,会社id(0は改札外)
map<P,map<P,int>> G;//エッジリスト(キモい)
map<P,int> memo;
const int INF = 1000000000;
typedef tuple<int,int,int> T;//cost,駅id,会社id
priority_queue<T,vector<T>,greater<T>> que;
#define mygc(c) (c)=getchar_unlocked()
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;} }for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}

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

    int N,M;
    //cin>>N>>M;
    reader(&N); reader(&M);
    for(int i=1;i<=N;i++) memo[P(i,0)]=INF;
    for(int i=0;i<M;i++){
        int p,q,c;
        //cin>>p>>q>>c;
        reader(&p); reader(&q); reader(&c);
        G[P(p,c)][P(q,c)]=0;
        G[P(p,c)][P(p,0)]=0;
        G[P(p,0)][P(p,c)]=1;
        G[P(q,c)][P(p,c)]=0;
        G[P(q,c)][P(q,0)]=0;
        G[P(q,0)][P(q,c)]=1;
        memo[P(p,c)]=memo[P(q,c)]=INF;
    }
    memo[P(1,0)]=0;
    que.emplace(0,1,0);
    while(!que.empty()){
        T t = que.top(); que.pop();
        int cost=get<0>(t), station=get<1>(t), company=get<2>(t);
        if(station==N){
            cout<<cost<<endl;
            return 0;
        }
        if(cost>memo[P(station,company)]) continue;
        for(auto &g:G[P(station,company)]){
            const P &p = g.first; int fee=g.second;
            if(cost+fee<memo[p]){
                memo[p]=cost+fee;
                que.emplace(cost+fee,p.first,p.second);
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

typedef long long ll;

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

int main(){
  string S;
  cin >> S;
  if(S.size() < 4){
    cout << "No" << endl;
  }else{
    if(S.substr(0, 4) == "YAKI"){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

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

  int big = 0, hashi = 1;
  for(int i = 2; i <= N; i++) {
    cout << "? 1 " << i << endl;
    int k;
    cin >> k;
    if(big < k) {
      big = k;
      hashi = i;
    }
  }

  vector< int > dist(N);
  dist[0] = hashi;
  for(int i = 1; i <= N; i++) {
    if(i == hashi) continue;
    cout << "? " << hashi << " " << i << endl;
    int k;
    cin >> k;
    dist[k] = i;
  }

  cout << "!";
  for(int i = 0; i < N; i++) {
    cout << " " << dist[i];
  }
  cout << endl;

}

Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var s = ReadLine();
            var N = s.Length;
            var ans = N;
            for (var i = 0; i < N - 1; ++i)
                if (s[i] != s[i + 1])
                    ans = Min(ans, Max(i + 1, N - (i + 1)));
            WriteLine(ans);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 26260
using System;

class Program
{
    static void Main(string[] args)
    {
        var abc = Console.ReadLine().Split(' ');
        var a = int.Parse(abc[0]);
        var b = int.Parse(abc[1]);
        var c = int.Parse(abc[2]);

        var k = int.Parse(Console.ReadLine());

        var max = Math.Max(Math.Max(a, b), c);
        var sum = a + b + c - max + max * Math.Pow(2, k);
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        if(S.equals("ABC")){
            System.out.println("ARC");
        }else {
            System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 35608
import math
N,M = map(int,input().split())

if abs(N-M) >= 2:
    print(0)
    exit()
sum = 1
count = 0
if N == M:
    sum *= N+M
    sum *= int(((N+M)/2))
    N = int((N+M)/2)-1
    M = N
else:
    sum *= max(N,M)

k = math.factorial(min(N,M))
sum *= k**2

print(sum%(10**9+7))



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

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int N, K; cin >> N >> K;
    vector<int> hs(N);
    for (auto& h : hs) {
        cin >> h;
    }
    sort(hs.begin(), hs.end());

    ll ans = INF;
    for (int i = 0; i < N - K + 1; i++) {
        ans = min<ll>(ans, abs(hs[i] - hs[K + i - 1]));
    }
    cout << ans << endl;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int a,b,c;
	cin >> a >> b >> c;
	if (a + b + c > 21) {
		cout << "bust";
	} else {
		cout << "win";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    
    if(a + b < 24) Console.WriteLine(a + b);
    else Console.WriteLine(a + b - 24);
  }
}

Measured memory_bytes: 11092
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
k = 0
s = 0
m = []
l = 0
if sum(B)<=sum(A):
    for i in range(N):
        if A[i] < B[i]:
            k += 1
            s += (B[i]- A[i])
        elif A[i] > B[i]+1:
            m.append(A[i]- B[i])
        elif A[i] == B[i]+1:
            l += (A[i]- B[i])
    if len(m)>1:
        n = sorted(m,reverse = True)
    else:
        n = m
    for j in range(len(m)):
        if s > 0:
            s -= n[j]
            k += 1
        if s <0:
            break
    if (s > 0) and(k > 0):
         k += s
else:
    k = -1
print(k)

Measured memory_bytes: 18652
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, d, x;
	cin>>n>>d>>x;
	double dp1=1, dp2=1.5;
	for(int i=2; i<=n; i++){
		double x=(1+1.0/i)*dp1+1;
		double y=i+0.5+(1+2.0/i)*dp2+3*dp1/(2*i);
		dp1=x, dp2=y;
	}
	printf("%.10lf\n", (d-x)*dp1+x*dp2);
	/*double dp[1010][2010]={};
	dp[1][1]=0.5, dp[1][2]=0.5;
	for(int i=2; i<=n; i++){
		for(int j=1; j<=2*i; j++){
			dp[i][j]=(2*i-j)*dp[i-1][j]/(2*i)+(dp[i-1][j-1]+1)/(2*i);
			if(j>1) dp[i][j]+=(j-1)*dp[i-1][j-2]/(2*i);
		}
	}
	double ans=0;
	for(int i=1; i<=2*n; i++){
		ans+=d*dp[n][i];
		d+=x;
	}
	printf("%.10lf\n", ans);*/
	return 0;
}

Measured memory_bytes: 256
main::IO()
main=do
  abcdc<-getLine
  let a:b:c:d:[]= map read (words abcdc)
  putStr (if ((abs (a-c)) <= d) || ( (abs (a-b)) <= d && (abs (b-c)) <=d ) then "Yes\n" else "No\n"  ) 

Measured memory_bytes: 508
import fractions

def check(S):
  g = S[0]
  for s in S:
    g = fractions.gcd(g, s)
  if g>1:
    return False
  for s in S:
    if fractions.gcd(s, sum(S)-s)==1:
      return False
  return True

import sys
sys.setrecursionlimit(100000)

N = input()
P = [2,3,5,7]
def BT(S, s):
  for a in xrange(S[-1]+1, 30001):
    ok = False
    for p in P:
      if a%p==0:
        ok = True
        break
    if ok:
      S.append(a)
      s += a
      if len(S)==N:
        if s%210==0:
          print " ".join(map(str, S))
          #print check(S)
          exit(0)
      else:
        BT(S, s)
      S.pop()
      s -= a
BT([2], 2)


Measured memory_bytes: 23848
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int> pii32;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

map <int,int> mp;
int a[maxn];
int n, ans;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mp[a[i]] = i % 2;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i += 2)
		if (i % 2 != mp[a[i]])
			ans++;
	cout << ans << "\n";
}


Measured memory_bytes: 5376
h,w = map(int,input().split())
lis = [str(input()) for i in range(h)]
dp = [[0] * w for i in range(h)]
dp[0][0] = 1
for i in range(h):
  for j in range(w):
    if i == 0:
      if j != 0:
        if lis[i][j] == "." and lis[i][j-1] == ".":
          dp[i][j] += dp[i][j-1]
    elif j == 0:
      if i != 0:
        if lis[i][j] == "." and lis[i-1][j] == ".":
          dp[i][j] += dp[i-1][j]
    else:
      if lis[i][j] == "." and lis[i][j-1] == ".":
        dp[i][j] += dp[i][j-1]
      if lis[i][j] == "." and lis[i-1][j] == ".":
        dp[i][j] += dp[i-1][j]
    dp[i][j] %= 10**9+7
print(dp[h-1][w-1])

Measured memory_bytes: 43668
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(a>b){
        for(int i=0; i<a; i++){
        System.out.print(b);
}
    }else{
        for(int j=0; j<b; j++){
        System.out.print(a);
        }
    }
}
}


Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < N-2; i++){
        if(s[i] == 'A'){
            if(s[i+1] == 'B'){
                if(s[i+2] == 'C'){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

struct Node{
    int key;
    Node *prev, *next;
};

Node *nil;

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int k){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = k;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* listSearch(int k){
    Node *cur = nil->next;
    while( cur != nil && cur->key != k){
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t){
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

int main(){
    int N;
    scanf("%d", &N);
    init();
    rep(i, N){
        char S[20];
        scanf("%s", S);
        if(S[0] == 'i'){
            int x;
            scanf("%d", &x);
            insert(x);
        }
        else if(S[6] == 'F'){
            deleteFirst();
        }
        else if(S[6] == 'L'){
            deleteLast();
        }
        else{
            int x;
            scanf("%d", &x);
            deleteNode(listSearch(x));
        }
    }

    Node *tmp = nil->next;
    int j = 0;
    while(tmp != nil){
        if(j) printf(" ");
        printf("%d", tmp->key);
        tmp = tmp->next;
        j++;
    }
    printf("\n");
}


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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long ans = 0;
		//最初は表で裏の数（ans）を求める
		if(n == 1l || m == 1l) {
			if(n == 1l && m == 1l) ans = 1l;
			else ans = n + m - 3l;
		}else {
			long sq = n * m;
			long eg = 2*(m+n-2);
			ans = sq - eg;
		}
		System.out.println(ans);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void permutation(String q, String ans) { //Call permutation(String, "",) from outside
		if (q.length() <= 1)
			System.out.println(ans + q); //Fill in processing
		else
			for (int i = 0; i < q.length(); i++)
				permutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i));
	}

	public static void combination(String q, String ans, int k) { //Call combination(String, "", n) from outside (nCr)
		if (ans.length() == k)
			System.out.println(ans); //Fill in processing
		else
			while (q.length() > 0) {
				combination(q.substring(1), ans + q.charAt(0), k);
				q = q.substring(1);
			}
	}

	long combination(int n, int r, int m) { //nCr mod m
		long[][] Combination = new long[n + 1][n + 1];
		for (int i = 0; i <= n; i++) {
			Combination[i][0] = 1;
			for (int j = 1; j <= i; j++)
				Combination[i][j] = (Combination[i - 1][j - 1] + Combination[i - 1][j]) % m;
		}
		return Combination[n][r];
	}

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

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

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

		int max = 1;
		int sum = 0;
		for (int i = 0; i < 3; i++) {
			int tmp = sc.nextInt();
			sum += tmp;
			if (tmp > max) {
				max = tmp;
			}
		}
		sum -= max;

		int k = sc.nextInt();
		for (int i = 0; i < k; i++) {
			max *= 2;
		}

		System.out.println(sum + max);

		sc.close();
	}
}


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

#define speed 			    ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n)		    for(ll i=a;i<n;i++)
#define even(x) 	            (((x)%(2))==(0))
#define odd(x) 			    (((x)%(2))==(1))
#define meme(x) 		    memset(x, 0, sizeof(x))
#define mod       		    1000000007

#define pb              	    push_back
#define mp                          make_pair
#define ff 			    first
#define ss 			    second
#define all(x)                      (x).begin(),(x).end()

typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;

int main()
{
    speed
    int n;cin>>n;
    int a[n];

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

    int cnt=0;

    for(int i=0;i<n-2;i++)
    {
	    for(int j=i+1;j<n-1;j++)
	    {
		    for(int k=j+1;k<n;k++)
		    {
			    if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i] &&a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
			    {
				    cnt++;
			    }
		    }
	    }
    }

    cout<<cnt<<endl;

}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >>N>>K;
  vector<int64_t> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  if(N<=K){
    cout <<0 <<endl;
  }else{
    sort(a.begin(),a.end());
    int64_t sum=0;
    for(int i=0;i<N-K;i++){
      sum+=a[i];
    }
    cout <<sum <<endl;
  }
}

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

int main(){
    int n;  cin>>n;
    char c[n];  for(int i=0;i<n;i++)cin>>c[i];


    int p=0;
    int w=0;
    int g=0;
    int y=0;

    for(int i=0;i<n;i++){
        if(c[i]=='P')p=1;
        if(c[i]=='W')w=1;
        if(c[i]=='G')g=1;
        if(c[i]=='Y')y=1;
    }

    string ans;
    if(p+w+g+y==1)ans="One";
    if(p+w+g+y==2)ans="Two";
    if(p+w+g+y==3)ans="Three";
    if(p+w+g+y==4)ans="Four";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from math import ceil
n=int(input())
p=list(map(int,input().split()))
l=[]
for i in range(n):
  if p[i]-1==i:
    l.append(i)
if len(l)==0 or len(l)==1:
  print(len(l))
else:
  cnt=1
  lis=[]
  for i in range(len(l)-1):
    if l[i]+1==l[i+1]:
      cnt+=1
    else:
      lis.append(ceil(cnt/2))
      cnt=1
  lis.append(ceil(cnt/2))
  print(sum(lis))

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

int main() {
  int n; cin >>n;
  vector<int>a;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(x==0){
      int b;cin>>b;
      a.push_back(b);
    }else if(x==1){
      int c;cin>>c;
      cout<<a[c]<<endl;
    }else{
      a.pop_back();
    }
  }
  return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int N;
    cin >> N;
    long long power = 1;
    long long c;
    long long d;
    for(int i = 1; i <= N; i++){
        power *= i;   
        power %= 1000000007;
    }
    cout << power  << endl;
    return 0;
}

Measured memory_bytes: 3640
N, T = map(int,input().split())
t = list(map(int,input().split()))
res = 0
now = 0
for i in range(N-1):
    if t[i+1]-t[i] <= T:
        res += t[i+1]-t[i]
    else:
        res += T
print(res+T)



Measured memory_bytes: 25196
#include <iostream>
#include <algorithm>

using namespace std;

int d[100001];

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

	int N, M; cin >> N >> M;

	for (int i = 1; i <= N - 1; ++i) {
		int s; cin >> s;
		d[i] = s + d[i - 1];
	}

	int ans = 0;

	int now = 0;

	for (int i = 0; i < M; ++i) {
		int a; cin >> a;
		int nxt = now + a;
		ans += d[max(now, nxt)] - d[min(now, nxt)];
		ans %= 100000;
		now = nxt;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1584
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<time.h>
#include<utility>
#include<vector>
using namespace std;
const long mod = 1000000007;
//include<kyawa>
//--------------------

int main() {

	string res = "Yes";
	long N, n; cin >> N; n = N;
	vector<pair<long, long>> task;
	while (n--) { int i, j; cin >> i >> j; task.push_back(make_pair(j, i)); }

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

	long now = 0;

	for (int i = 0; i < N; i++) { now += task[i].second; if (now > task[i].first) res = "No"; }

	cout << res << endl;
}

Measured memory_bytes: 6384
s = input()
a = int(s[0:2])
b = int(s[2:])
a_month = False
b_month = False
if(a <= 12 and a > 0):
    a_month=True
if(b <= 12 and b > 0):
    b_month = True
if(a_month and b_month):
    print("AMBIGUOUS")
elif(a_month):
    print("MMYY")
elif(b_month):
    print("YYMM")
else:
    print("NA")

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

Graph Friends(100010);
Graph Block(100010);
vector<int> group(100010, -1);
void dfs(int v, int group_number, int& cnt)
{
    group[v] = group_number;
    cnt++;
    for (int nv : Friends[v]) {
        if (group[nv] != -1)
            continue;
        dfs(nv, group_number, cnt);
    }
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        Friends[a].push_back(b);
        Friends[b].push_back(a);
    }

    rep(i, k)
    {
        int c, d;
        cin >> c >> d;
        c--, d--;
        Block[c].push_back(d);
        Block[d].push_back(c);
    }

    int group_number = 0;
    map<int, int> group_member_num;
    rep(i, n)
    {
        if (group[i] == -1) {
            int cnt = 0;
            dfs(i, group_number, cnt);
            group_member_num[group_number] = cnt;
            group_number++;
        }
    }

    for (int i = 0; i < n; i++) {
        int ans = group_member_num[group[i]] - 1 - Friends[i].size();
        for (int v : Block[i]) {
            if (group[v] == group[i])
                ans--;
        }
        cout << ans << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 13440
import sys
import math
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()


def main():
    def COMinit(n,MOD):
        fac,finv,inv=[0]*(n+1),[0]*(n+1),[0]*(n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
        
    def COM(n, k, MOD):
        fac,finv,inv=COMinit(n,MOD)
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    
    X,Y=map(int,input().split())
    if (X+Y)%3==0:
        z=(X+Y)//3
        a_x=X-z
        a_y=Y-z
        print(COM(a_x+a_y,a_x,MOD))
    else:
        print(0)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 54384
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def kai(n):
  x = 1
  i = 1
  while i <= n:
    x *= i
    i += 1
  return x

#print(kai(5))

def number(X):#Xの辞書順を求める関数
  N = len(X)
  s = 1
  num_list = [1] * N#0,1,2,3,4,5..に対応
  for i in range(N):
    x = X[i]
    sub = sum(num_list[:x - 1])
    s += sub * kai(N - i - 1)  
    num_list[x - 1] = 0
  return s

#print(number(P), number(Q))
print(abs(number(P) - number(Q)))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int str(int x){if(x==1)return 14;return x;}
int main(){
 	int a,b;cin>>a>>b;
  a=str(a),b=str(b);
  cout<<(a<b?"Bob":a==b?"Draw":"Alice")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
int n,c;
int a[405],b[405];
long long sum[405];
long long dp[405][405];
const int Mod=1e9+7;
void pre(int a,int b){
	memset(sum,0,sizeof(sum));
	for (int i=a;i<=b;i++){
		long long t=1;
		for (int j=0;j<=c;j++){
			sum[j]=sum[j]+t;
			sum[j]%=Mod;
			t*=i;
			t%=Mod;
		}
	}
}
int main(){
	scanf("%d%d",&n,&c);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	dp[0][0]=1;
	for (int i=1;i<=n;i++){
		pre(a[i],b[i]);
		for (int j=0;j<=c;j++){
			for (int k=0;k<=j;k++){
				dp[i][j]=(dp[i][j]+dp[i-1][j-k]*sum[k])%Mod;
			}
		}
	}
	printf("%lld",dp[n][c]);
	return 0;
}

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

public class Main
{

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

    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String[] sl;

    s = r.readLine();
    long n = Long.parseLong(s);

    int k = 0;
    for(k = 0; k * (k - 1) / 2 < n; k++);
    
    if(k * (k - 1) / 2 > n)
    {
      System.out.println("No");
      System.exit(0);
    }
    System.out.println("Yes");
    System.out.println(k);
    
    int a[][] = new int[500][500];
    
    int z[] = new int[500];
    int w[] = new int[500];
    
    int v = 1;
    
    StringBuilder sb = new StringBuilder();
    
    for(int i = 0; i < k; i++)
    {
      for(int j = 0; j < i; j++)
      {
        a[i][z[i]] = a[j][w[j]];
        z[i]++;
        w[i]++;
        w[j]++;
      }
      while(z[i] < k - 1)
      {
        a[i][z[i]] = v;
        z[i]++;
        v++;
      }
    }
    
    for(int i = 0; i < k; i++)
    {
      sb.append(z[i]);
      for(int j = 0; j < z[i]; j++)
      {
        sb.append(" ");
        sb.append(a[i][j]);
      }
      sb.append("\n");
    }
    
    System.out.println(sb);
  }

}

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

int main(){
  int n; ll k;
  cin >> n >> k;
  ll a[n];
  rep(i,n) cin >> a[i];
  bool update;
  vector<int> bitk(40,0);
  vector<int> bita(40,0);
  vector<ll> pow2(40,0);
  int j = 39;
  while(j >= 0){
    if(j == 39) pow2[j] = 1;
    else pow2[j] = pow2[j+1]*2;
    rep(i,n){
      if(a[i] % 2) bita[j]++;
      a[i] /= 2;
    }
    bitk[j] = k % 2;
    k /= 2;
    j--;
  }
  vector<vector<ll>> dp(41, vector<ll>(2,0));
  bool can = false;
  rep(i,40){
      if(bitk[i]) dp[i+1][1] = max(dp[i+1][1], dp[i][0]+pow2[i]*bita[i]);
      if(can) dp[i+1][1] = max(dp[i+1][1], dp[i][1] + pow2[i]*max(bita[i],n-bita[i]));
      if(bitk[i]) dp[i+1][0] = dp[i][0] + pow2[i]*(n-bita[i]);
      else dp[i+1][0] = dp[i][0] + pow2[i]*bita[i];
      if(bitk[i]) can = true;
  }
  cout << max(dp[40][0],dp[40][1]) << endl;
  return 0;
}


Measured memory_bytes: 1024
n=int(input())
d=dict()
for i in range(1,int(n**0.5)+1):
    cnt=0
    while n%(i+1)==0:
        n//=i+1
        cnt+=1
    d[i+1]=cnt
if n>1:
    if n in d:
        d[n]+=1
    else:
        d[n]=1
ans=0
d=list(d.items())
for i,r in d:
    for j in range(1,44):
        if j*(j+1)//2>r:
            ans+=j-1
            break
print(ans)

Measured memory_bytes: 212100
import java.util.Scanner;

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

        int R = sc.nextInt();
        int D = sc.nextInt();
        int X = sc.nextInt();

        for (int i = 0; i < 10; i++) {
            X = R * X - D;
            System.out.println(X);
        }
    }
}

Measured memory_bytes: 21332
n = int(input())

amari = 0
made = 0
cnt = 0
for i in range(1, n+1):
    cnt += i
    if cnt >= n:
        made = i
        amari = cnt - n
        break

ans = []
for i in range(1, made+1):
    if i == amari:
        continue
    ans.append(str(i))
print("\n".join(ans))


Measured memory_bytes: 39280
use std::cmp::min;
use std::cmp::max;

fn main() {
    let (n, t) = read_tuple();
    let mut foods: Vec<(_, _)> = (0..n).map(|_| read_tuple::<usize>()).collect();
 
    foods.sort_by_key(|f| f.0);

    let mut dp: Vec<Vec<usize>> = vec![vec![0; t + 1]; n + 1];
    for i in 0..n {
        for j in 0..t {
            let k = min(j + foods[i].0, t);
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            dp[i + 1][k] = max(dp[i + 1][j], dp[i][j] + foods[i].1);
        }

        dp[i + 1][t] = max(dp[i + 1][t], dp[i][t]);
    }

    println!("{}", dp[n][t]);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}



Measured memory_bytes: 90364
#include<bits/stdc++.h>
using namespace std;
int pas=-1,x;
long long ans;
bool p=true;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		if(x-pas>1||x>i)p=false;
		if(x!=0)ans++;
		if(x!=0&&x!=pas+1)ans+=x-1;
		pas=x;
	}
	if(p)printf("%lld",ans);
	else printf("-1");
}




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

#define REP(i, n) for(int i = 0; i < n; i++)

const int MAX_N = 50;
int w, h; // wは横の個数 hは縦の個数
int c[MAX_N][MAX_N]; //マップ
int dx[] = { 1, -1, 0 }, dy[] = { 1, -1, 0 }; //移動単位
int island; //記憶

void sch(int x, int y) { //ひとつ前のx座標とy座標

	c[x][y] = 0;
	REP(i, 3) {
		REP(j, 3) {
			int xx = x + dx[i];
			int yy = y + dy[j];
			if (xx < h && xx >= 0 && yy < w && yy >= 0 && c[xx][yy] == 1) {
				sch(xx, yy);
			}

		}
	}
	return;
}

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

	while (1) {
		island = 0;
		cin >> w >> h;
		if (w == 0 && h == 0) break;

		REP(i, h) {
			REP(j, w) cin >> c[i][j];
		}

		REP(i, h) {
			REP(j, w) if (c[i][j] == 1) {
				sch(i, j);
				island++;
			}
		}

		cout << island << "\n";
	}
	return 0;
}


Measured memory_bytes: 3388
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n>=195)
	{
		cout<<5;
	}
	else if(n>=189)
	{
		cout<<4;
	}
	else if(n>=165)
	{
		cout<<3;
	}
	else if(n>=135)
	{
		cout<<2;
	}
	else if(n>=105)
	{
		cout<<1;
	}
	else cout<<0;
}

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

using namespace std;

int main(){ 
	// int t; cin >> t;
	// while(t--) {
		int N, X, T;
		cin >> N >> X >> T;
		cout << T * ((N + (X - 1)) / X) << endl;
	// }
	return 0;
}

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


int main(){
  int x,y[100],j=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
		y[j-2]=y[j-2]+y[j-1];
    	j--;
    } else if ( s[0] == '-' ){
		y[j-2]=y[j-2]-y[j-1];
    	j--;
    } else if ( s[0] == '*' ){
		y[j-2]=y[j-2]*y[j-1];
    	j--;
    } else {
		x = atoi(s);
		y[j]=x;
    	j++;
    }
  }
	
	printf("%d\n",y[j-1]);

  return 0;
}


Measured memory_bytes: 2092