akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<n;i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=k;i<n;i++)
#define REPEACH(itr,k) for(auto itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;
typedef pair<double,int> P;


int main(){
  string s;
  cin >> s;
  int a=0;
  int b=0;
  int c=0;
  REP(i,3){
    if(s[i]=='a'){
      a++;
    }
    else if(s[i]=='b'){
      b++;
    }
    else if(s[i]=='c'){
      c++;
    }
  }
  if(a==1&&b==1&&c==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

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

    long long ans = 0;

    if (n<b){
        ans = (long long)(a*n/b) - a*(long long)(n/b);
    }else{
        if (n%b==0){
            ans = (long long)(a*(n-1)/b) - a*(long long)((n-1)/b);
        }else{
            ans = (long long)(a*(n-n%b-1)/b) - a*(long long)((n-n%b-1)/b);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
import sys, math,os
from io import BytesIO, IOBase
#data = BytesIO(os.read(0,os.fstat(0).st_size)).readline
# from bisect import bisect_left as bl, bisect_right as br, insort
# from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
# from decimal import Decimal
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
#sys.setrecursionlimit(100000 + 1)
INF = 10**9
mod = 998244353

N=int(data())
out((1000-N%1000)%1000)








Measured memory_bytes: 65384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 301;
double dp[N][N][N];
int n;
// 3,2,1
double ans(int a, int b, int c){
	if(a < 0 || b < 0 || c < 0)return 0;
	if(a == 0 && b == 0 && c == 0)return 0;
	else if(dp[a][b][c] == 0){
		int z = n - a - b - c;
		double ones = c * ans(a,b,c-1);
		double twos = b * ans(a,b-1,c+1);
		double tres = a * ans(a-1,b+1,c);
		dp[a][b][c] = (double)n/(n-z) * (1 + (ones + twos + tres)/n);
	}
	return dp[a][b][c];
}


int main(){
	fast_io();
	cin >> n;
	int x;
	vector<int> cnt(4);
	cu(i,0,n){
		cin >> x;	
		++cnt[x];
	}
	cout.precision(13);
	cout << ans(cnt[3],cnt[2],cnt[1]) << endl;
}
	

Measured memory_bytes: 213248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    string s; cin >> s; s = s + 'T';
    int x, y; cin >> x >> y;
    vector<int> v1,v2;
    bool d = true;
    int cnt = 0;
    REP(i,s.size()){
        if (s[i]=='F') cnt++;
        if (s[i]=='T'){
            if(d)v1.push_back(cnt);
            else v2.push_back(cnt);
            cnt = 0;
            d = !d;
        }
    }
    int m = v1.size(), n = v2.size();
    vector<bitset<16005>> dp1(m+1), dp2(n+1);
    dp1[0][8000] = 1; dp2[0][8000]= 1;
    REP(i,m){
        dp1[i+1] |= dp1[i]<<v1[i];
        if(i)dp1[i+1] |= dp1[i]>>v1[i];
    }
    REP(i,n){
        dp2[i+1] |= dp2[i]<<v2[i];
        dp2[i+1] |= dp2[i]>>v2[i];
    }
    bool f = (dp1[m][8000+x] && dp2[n][8000+y]);
    cout << (f ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define IN freopen("input.txt","r",stdin);
#define MAX5 100005
#define MAX6 1000005
#define MAX7 1000005
#define sf scanf
#define pf printf
#define pb push_back
#define all(x) x.begin(),x.end()
typedef long long int ll;
int TEST=1,CASE=1;
struct vpair{
    int a;
    int b;
    vpair(int a,int b){this->a=a;this->b=b;}
};
bool cmp(vpair &a,vpair &b){
    if(a.b<b.a)return true;
    else if(a.a==b.a){
        if(a.b<b.a)return true;
        else return false;
    }else return false;
}
int a,b,c,n;
int main(void){
    scanf("%d %d",&a,&b);
    n=a+b;
    if(n%3==0 || a%3==0 || b%3==0){
        printf("Possible\n");
    }else{
        printf("Impossible\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  string acgt[4] = {"A", "C", "G", "T"};
  vector<string> str;
  map<string, int> id;
  int cnt = 0;
  REP(i, 4) {
    REP(j, 4) {
      REP(k, 4) {
        string s = acgt[i] + acgt[j] + acgt[k];
        id[s] = cnt;
        str.push_back(s);
        cnt++;
      }
    }
  }
  int n;
  cin >> n;
  vector<vector<ll>> dp = vector<vector<ll>>(n + 1, vector<ll>(cnt, 0));
  REP(i, 4) {
    REP(j, 4) {
      REP(k, 4) {
        string s = acgt[i] + acgt[j] + acgt[k];
        if (s != "AGC" && s != "ACG" && s != "GAC") {
          dp[3][id[s]] = 1LL;
        }
      }
    }
  }
  //////////////////////////////////////////////
  for (int i = 3; i < n; i++) {
    REP(j, cnt) {
      if (str[j] == "AGC" || str[j] == "ACG" || str[j] == "GAC") continue;
      REP(k, 4) {
        string tmp = str[j] + acgt[k];
        // cout << tmp << endl;
        if ((tmp[0] == 'A' && tmp.substr(2, 2) == "GC") ||
            (tmp[3] == 'C' && tmp.substr(0, 2) == "AG")) {
          continue;
        }
        string tmp2 = tmp.substr(1);
        if (tmp2 == "ACG" || tmp2 == "AGC" || tmp2 == "GAC") continue;
        dp[i + 1][id[tmp2]] += dp[i][j];
        dp[i + 1][id[tmp2]] %= MOD;
      }
    }
  }
  ll ans = 0;
  REP(i, cnt) {
    ans += dp[n][i];
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
# D - Multiple of 2019

from collections import Counter

s = input()

r = [0]
for d in map(int, s):
    r.append((r[-1] * 10 + d) % 2019)

e = 1
for i in range(len(r) - 1, -1, -1):
    r[i] = r[i] * e % 2019
    e = e * 10 % 2019

def choose2(x):
    return x * (x - 1) // 2

counter = Counter(r)
print(sum(choose2(counter[i]) for i in counter))

Measured memory_bytes: 77744
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M;
	while(cin>>N>>M) {
		vector<PII> A(N); ll ans=0;
REP(i, N) cin>>A[i].first>>A[i].second;
sort(ALL(A));

REP(i, N) {
ll buy=min(A[i].second, M);
M-=buy;
ans+=buy*A[i].first;
}
cout<<ans<<endl;
		
		
	}
	
	return 0;
}


Measured memory_bytes: 1792
# すべてを str型として読み込み、Kのみ int型に変換
N, Kstr = map(str, input().split()) # N: 元の数, K: NG数の数
K = int(Kstr)
D = list(map(str, input().split())) # D: NG数のリスト

# N = str(1000)
# K = 8
# D = ('1', '3', '4', '5', '6', '7', '8', '9')

def getMinimumOK():
# NGではない最小の数字を求める
    for i in range(0, 9):
        for j in range(1, K):
            if D[j - 1] == str(i):
                break
            else:
                return str(i)

def getFirstNG():
# Nの中の最初のNG数までの文字数を返す
# getFirstNG()を呼ぶ前にisOK(N)を呼んでいるので N の中に NG数 が必ず有る
    for i in range(0, len(N)):
        for ng in D:
            if ng == N[i]:
                return i + 1

def isOK(number):
# NG数が含まれなければ True, 含まれていれば False を返す
    strNumber = str(number)
    strlen = len(strNumber)
    for i in range(strlen):
        if strNumber[i] in D: # i桁目の数が D の中にあれば
            return False      # number に NG数 が含まれる
    return True

def makeUpperHalf(upperHalf_org):
# 引数：最初のNG数より上位の桁の数（str型）
# 戻り値：NG数を含まない上位の数（str型）
    numUpper = int(upperHalf_org)
    while True:
        numUpper += 1
        if isOK(numUpper): # NG数が無くなるまで numUpper を増やしていく
            break
    return str(numUpper)

if isOK(int(N)): # N に　NG数 が含まれていなければ
    print(N)     # N を表示して終了
else:
    minimumOK = getMinimumOK() # 最小のOK数字（文字列型）
    firstNG = getFirstNG()     # 上位から数えて最初のNG数が出てくる桁

    upperHalf = N[:firstNG] # 先頭から最初のNG数まで
    lowerHalf = N[firstNG:] # 最初のNG数の次から末尾まで
    upper = makeUpperHalf(upperHalf)
    lower = minimumOK * len(lowerHalf) # 下半分はNGでない最小の数を桁数分、並べる
    print(upper + lower)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int n;
    while(cin>>n){
        cout<<"3C";
        int a=n%39;
        
        if(a==0)
        a=39;
        
        if(a<10)
        cout<<0;
        
        cout<<a<<endl;
    }
}



Measured memory_bytes: 3000
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
#define N 200200
#define fi first
#define se second
#define pii pair<int, int>
using namespace std;

int n, a[N], top;
pii stk[N];

inline bool check(int mid) {
    stk[0] = make_pair(0, 0);
    stk[top = 1] = make_pair(1, a[1]);
    for (int i = 2; i <= n; ++i) {
        if (a[i] > a[i - 1]) {
            while (top && stk[top].fi == 1) 
                --top;
            stk[++top] = make_pair(1, a[i]);
        } else {
            int now = 0;
            while (top && stk[top].se >= a[i])
                now = stk[top--].fi;
            if (now < mid) {
                if (stk[top].se != a[i] - 1)
                    stk[++top] = make_pair(now, a[i] - 1);
                else while (top && stk[top].fi == now + 1) --top;
                stk[++top] = make_pair(now + 1, a[i]);
            } else {
                if (!top) return false;
                now = stk[top].fi;
                int pos = stk[top].se;
                if (stk[top - 1].se == pos - 1) {
                    if (top) for (--top; top && stk[top].fi == now + 1; --top);
                    stk[++top] = make_pair(now + 1, pos);
                } else stk[top].se--, stk[++top] = make_pair(now + 1, pos);
                stk[++top] = make_pair(1, a[i]);
            }
        }
    }
    return true;
}

int main() {
#ifdef isLOCAL
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;
    bool chk = 1;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        if (a[i] <= a[i - 1]) chk = false;
    }
    if (chk) return puts("1"), 0;

    int l = 2, r = n - 1, res = n;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) r = (res = mid) - 1;
        else l = mid + 1;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
p = list(map(int, input().split())) 

e = []
max_ = 0
sum_ = 0
f = []
e = [(1+p[i])/2  for i in range(n)]
for i in range(n):
    if i < k:
        sum_ += e[i]
        max_ = sum_
    else:
        sum_ = sum_ + e[i] - e[i - k]
        max_ = max(max_, sum_)

print(max_)

Measured memory_bytes: 25060
import math

def gcd(a,b):
    if a % b == 0:
        return b
    return gcd(b, a%b)

A, B, C, D = map(int, input().split())

CD = int(C*D / gcd(C, D))

B_cnt = B//C + B//D - B//CD
A_cnt = (A-1)//C + (A-1)//D - (A-1)//CD

print((B-A+1) - (B_cnt - A_cnt))



Measured memory_bytes: 8992
# coding: utf-8

n, m = list(map(int, input().split()))

inlist = []
for i in range(m):
	inlist.append(list(map(int, input().split())))

graph = [[0 for i in range(n)] for j in range(n)]

for i in inlist:
	graph[i[0]-1][i[1]-1] = 1
	graph[i[1]-1][i[0]-1] = 1

visited = []
visited.append(0)
count = 0
def dfs(cur):
	if len(visited) == n:
		global count
		count += 1
		return
	for i in range(n):
		if graph[cur][i] == 1 and i not in visited:
			visited.append(i)
			dfs(i)
			visited.pop()
	return

dfs(0)

print(count)


Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
from itertools import chain


def solve(N: int, A: "List[int]"):
    s = [0 for _ in range(N)]
    for Ai in A:
        s[Ai - 1] += 1

    return "\n".join(map(str, s))


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    A = [
        int(next(tokens)) for _ in range(N - 2 + 1)
    ]  # type: "List[int]"
    answer = solve(N, A)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47608
#include<stdio.h>

int main(){
	int n,ans=0;
	scanf("%d",&n);
	if(n>=105)ans++;
	if(n>=135)ans++;
	if(n>=165)ans++;
	if(n>=189)ans++;
	if(n>=195)ans++;
	printf("%d\n",ans);
	return 0;
}

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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#ifdef DEBUG
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
#else
#define DEBUG_PRINT(...)
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

int n, a[100000];
int maxa;

bool comb_comp(const int a, const int b){
  if(maxa%2){
    int tmpa = maxa/2, tmpb = maxa/2+1;
    int aa = min(abs(a-tmpa), abs(a-tmpb));
    int bb = min(abs(a-tmpa), abs(b-tmpb));
    return aa>bb;
  }else{
    return abs(a-maxa/2)>abs(b-maxa/2);
  }
}

int main(){
  scanf("%d", &n);
  REP(n){
    scanf("%d", &a[i]);
  }
  sort(a, a+n);
  maxa = a[n-1];
  sort(a, a+n, comb_comp);
  REP(n){
    DEBUG_PRINT("%d ", a[i]);
  }
  DEBUG_PRINT("\n");
  int addr = n-1;
  if(a[n-1] == maxa)addr--;
  printf("%d %d\n", maxa, a[addr]);

  return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int lmax,rmin,n,rule,l,r,i;
    scanf("%d %d",&n,&rule);
    rmin=1000000;
    lmax=-1;
    for(i=0;i<rule;i++){
        scanf("%d %d",&l,&r);
        if(lmax<l){
            lmax=l;
        }
        if(rmin>r){
            rmin=r;
        }
    }
    if(rmin-lmax>-1){
        printf("%d\n",rmin-lmax+1);
    }else{
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 998244353;
    long inv2 =1;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        main.solve();
//        out.println(main.solve());
        out.flush();
    }
    void solve() throws IOException {
        int n = sc.nextInt(), S = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) a[i] = sc.nextInt();
        long[][] dp = new long[n][S+1];
        inv2 = power(2, mod-2);
        if(a[0]<=S) dp[0][a[0]] = power(2, n-1);
        for(int i=1; i<n; i++){
            int cur = a[i];
            for(int j=1; j<=S; j++) dp[i][j] = dp[i-1][j];
            if(cur<=S){
                dp[i][cur] = (dp[i][cur]+power(2,n-1))%mod;
            }
            for(int j=cur+1; j<=S; j++){
                dp[i][j] += dp[i-1][j-cur]*inv2%mod;
                dp[i][j] %= mod;
            }
        }
        long ans = dp[n-1][S];
        out.println(ans);
    }
    long power(long base, long p){
        long ans = 1;
        while(p>0){
            if(p%2==1) ans = ans*base%mod;
            base = base*base%mod;
            p /= 2;
        }
        return ans;
    }
}

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

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

int main(){
  ll n;  cin >> n;
  int a,b;  cin >> a >> b;
  vi c(n+1);
  rep(i,n+1){
    int x = 0;
    int j = i;
    while (0 < j) {
      x += j%10;
      j /= 10;
    }
    if(a <= x and x <= b){
      c[i] = i;
    }
  }
  int ans = 0;
  rep(i,n+1){
    ans += c[i];
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
X,Y=map(int,input().split())
n=0
if X==1:
    n+=300000
if X==2:
    n+=200000
if X==3:
    n+=100000
if Y==1:
    n+=300000
if Y==2:
    n+=200000
if Y==3:
    n+=100000
if X==1 and Y==1:
    n+=400000
print(n)


Measured memory_bytes: 3060
#include<iostream>

int main(){
 int a, b, c, t;
 std::cin >> a >> b >> c ;
 if(a > b){ t = a; a=b; b=t; }
 if(b > c){ t = b; b=c; c=t; }
 if(a > b){ t = a; a=b; b=t; }

 std::cout<<a<<" "<<b<<" "<<c<<"\n";

 return 0;
}
  

Measured memory_bytes: 3116
a = [[0]*3]*3
for i in range(3):
  a[i] = list(map(int,input().split()))

n = int(input())

for _ in range(n):
  m = int(input())
  for i in range(3):
    for j in range(3):
      if m == a[i][j]:
        a[i][j] = -1
        
for i in range(3):
  if a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1:
    print("Yes")
    exit(0)
  if a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1:
    print("Yes")
    exit(0)
if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
  print("Yes")
  exit(0)
if a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
  print("Yes")
  exit(0)
print("No")

Measured memory_bytes: 3064
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;



void main() {
    double a, b, x;
    scan(a, b, x);

    double ans;

    if (a^^2 * b / 2 < x) {
        ans = atan(2 * (a^^2 * b - x) / a^^3);
    }
    else {
        ans = atan((a * b^^2) / (2 * x));
    }

    ans = ans / PI * 180;
    writefln("%.12f", ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}

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

b = list(map(int, input().split()))
a=[0]*n
a[0]=b[0]
a[n-1]=b[n-2]

for i in range(1, n-1):
	if b[i]>=b[i-1]:
		a[i]=b[i-1]
	else:
		a[i]=b[i]
s = 0
for i in range(n):
	s += a[i]
	
print(s)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
int mark[1000];
int main()
{
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<4;i++)
    {
           mark[s[i]]++;
    }
    for(int i='A';i<='Z';i++)
    {
        if(mark[i]==1||mark[i]==3||mark[i]==4)
        {
            
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import collections
def ip(): return [int(i) for i in stdin.readline().split()]
def sp(): return [str(i) for i in stdin.readline().split()]


n = int(input())
ans = 0
for i in range(1, n):
    for j in range(1, n):
        if i*j >= n: break
        ans += 1
print(ans)

Measured memory_bytes: 73808
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int n, T; cin >> n >> T;
	vector<int> c (n), t (n);
	int mini = 100000;
	forn(i, n){
		cin >> c[i] >> t[i];
		if(t[i] <= T && c[i] < mini){
			mini = c[i];
		}
	} 
	if(mini == 100000) {
		cout << "TLE" << endl;
		return 0;
	}
	cout << mini << endl;
}


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e5 + 100;


ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  ll ans = 1;
  for(int i = 1; i <= k; i++)
  {
    ans = (ans * n) % mod;
    n--;
  }
  ans = (ans * inv[k]) % mod;
  return ans;
}


int main()
{
  inv[0] = fat[0] = 1;
  for(int i = 1; i < maxn ; i++)
  {
    fat[i] = (fat[i-1] * i) % mod;
    inv[i] = exp(fat[i], mod-2);
  }
  ios::sync_with_stdio(0);
  int n,a,b;
  cin >> n >> a >> b;

  auto ans = (exp(2, n) - 1 + mod) % mod;
  auto val = (C(n, a) + C(n, b)) % mod;
  ans = (ans - val + mod) % mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int k,r;
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>k;
  if(k%2==0 || k%5==0)
  { cout<<"-1\n";
    return 0;
  }
  if(k==1)
  { cout<<"1\n";
    return 0;
  }
  if(k==3)
  { cout<<"3\n";
    return 0;
  }
  if(k==7)
  { cout<<"1\n";
    return 0;
  }
  r=0;
  for(int i=1;i<=k;i++)
  { r=(r*10+7)%k;
    if(r==0)
    { cout<<i<<'\n';
      return 0;
    }
  }
  cout<<"-1\n";
  return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	ll n;
	cin >> n;
	string ans = "";
	while(n != 0){
		int now = n % 26;
		if(n % 26 == 0) {
			n /= 26;
			n--;
		} else {
			n /= 26;
		}
		if(now == 0) now = 26;
		char c = 'a' + (now-1);
		ans.push_back(c);
		
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const long long mod=998244353;
long long C[5005][5005];
int n,k;
long long calc(int n, int k)
{
    if (n<0 || k<0 || k>n) return 0;
    return C[n][k];
}
int main()
{
	scanf("%d%d",&k,&n);
	for (int i=0;i<=5001;i++)
	{
		C[i][0]=C[i][i]=1;
		for (int j=1;j<i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for (int x=2;x<=k+k;x++)
	{
		//k-(x-(k+1))+1
		//int i=(x>k+1)?k+k-x+2:x,;
		int i=x,u=min(k,i/2),v=max(1,i-k);
		long long ans=0;
		for (int j=0;j<=u-v+1;j++)
			ans=(ans+calc(u-v+1,j)*calc(n+k-j-j-1,n-j-j)*((j%2==0)?1:-1)%mod)%mod;
		printf("%lld\n",(ans+mod)%mod);
	}
	return 0;
}

Measured memory_bytes: 194048
import java.util.Scanner;

public class Main { //?????§??¬?´???°(ALDS1_1_B)

	static int bmp(int x,int y){
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] gcd = in.nextLine().split(" ");
		int x = Integer.parseInt(gcd[0]);
		int y = Integer.parseInt(gcd[1]);
			if(x<y){
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			}
			else{
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			}
		}
}

Measured memory_bytes: 25960
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	ll mi = min({a,b,c,d,e});
	ll ans = (n + mi - 1) / mi + 4;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, k; cin>>n>>k;
    int R, S, P; cin>>R>>S>>P;
    string t; cin>>t;

    vector<char> hand(n, '-');
    for(int i=0; i<n; i++){
        if(i < k){
            if(t[i] == 'r') hand[i] = 'p';
            else if(t[i] == 's') hand[i] = 'r';
            else hand[i] = 's';
        }
        else{
            if((t[i] == t[i-k] && hand[i-k] == '-') || t[i] != t[i-k]){
                if(t[i] == 'r') hand[i] = 'p';
                else if(t[i] == 's') hand[i] = 'r';
                else hand[i] = 's';
            }
        }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        if(hand[i] == 'r') ans += R;
        if(hand[i] == 's') ans += S;
        if(hand[i] == 'p') ans += P;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
INFTY=float('inf')

def warshallFloyd(l,n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                l[i][j]=min(l[i][j],l[i][k]+l[k][j])
    return l

n,e=map(int,input().split())
l=[[INFTY for i in range(n)] for i in range(n)]
for i in range(n):
    l[i][i]=0

for i in range(e):
    a,b,c=map(int,input().split())
    l[a][b]=c

distance=warshallFloyd(l,n)

negative=False

for i in range(n):
    if l[i][i]<0:
        negative=True
        break

if negative:
    print("NEGATIVE CYCLE")
else:
    for i in range(n):
        for j in range(n):
            if j:
                print(" ",end='')
            if l[i][j]==INFTY:
                print("INF",end='')
            else:
                print(l[i][j],end='')
        print()


Measured memory_bytes: 6812
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Problems 1224
2001年 アジア地区予選 函館大会 問題A Starship Hakodate-maru
"""
while True:
    balls = int(input())
    ans = 0
    if balls == 0: # ボールの数が0個なら終了する
        break
    for cs in range(54):
        for ts in range(96):
            if pow(cs,3) <= balls:
                ans = max(ans, pow(cs,3))
            if ts*(ts+1)*(ts+2)//6 <= balls:
                ans = max(ans, ts*(ts+1)*(ts+2)//6)
            if pow(cs,3) + ts*(ts+1)*(ts+2)//6 <= balls:
                ans = max(ans, pow(cs,3) + ts*(ts+1)*(ts+2)//6)
    print(ans)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define int long long int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

int m;
int mod(int x) {
   return ((x % m) + m) % m;
}

template<typename T> class BIT
{
   private:
      vector<T> bit;
      int len;
   public:
      BIT(int n=0) {
         len = n+1;
         bit.resize(len);
      }
      void add(int i, T x) {
         i += 1;
         while (i < len) {
            bit[i] += x;
            i += i & -i;
         }
      }
      int sum(int i) {
         i += 1;
         T s = 0;
         while (i > 0) {
            s += bit[i];
            i -= i & -i;
         }
         return s;
      }
};
template<typename T> class CircleCumulativeSum
{
   private:
      BIT<T> bit;
   public:
      CircleCumulativeSum(int n) {
         bit = BIT<T>(n);
      }
      void add(int a, int b, int x) {
         // add x in [a, b)
         bit.add(a, x);
         bit.add(b, -x);
         if (a > b) bit.add(0, x);
      }
      int val(int i) {
         return bit.sum(i);
      }
};

signed main()
{
   int n; cin >> n >> m;
   V<int> a(n);
   REP(j, n) {
      cin >> a[j]; a[j]--;
   }

   V<int> dist(n-1);
   REP(j, n-1) {
      dist[j] = mod(a[j+1] - a[j]);
   }
   DUMP(dist)

   V<int> cost(m);
   REP(j, n-1) {
      int d = mod(0 - a[j]);      // distance to the favorite point 0
      if (d == 0 || dist[j] < d) {
         cost[0] += dist[j];
      } else {
         cost[0] += dist[j] - d + 1;
      }
   }

   CircleCumulativeSum<int> diff(m);
   REP(j, n-1) {
      if (dist[j] == 0) continue;

      diff.add(a[j+1], mod(a[j+1]+1), dist[j]-1);
      diff.add(mod(a[j]+1), a[j+1], -1);
   }


   REP(i, m-1) {
      cost[i+1] = cost[i] + diff.val(i);
   }
   DUMP(cost)
   SORT(cost);
   cout << cost[0] << endl;

   return 0;
}


Measured memory_bytes: 3328
import std.stdio, std.array, std.string, std.conv, std.algorithm;

int H, W;
auto dy = [0, 0, 1, -1], dx = [1, -1, 0, 0];
char[][] board;

void main(){
	for(;init;){
		writeln(solve);
	}
}

bool init(){
	auto input = map!(to!int)(readln.chomp.split);
	H = input[0];
	W = input[1];
	
	board = new char[][](H);
	foreach(ref line; board){
		line = to!(char[])(readln.chomp);
	}
	return H > 0;
}

int solve(){
	int ans = 0;
	foreach(y; 0..H){
		foreach(x; 0..W){
			if(board[y][x] != '.'){
				++ans;
				dfs(y, x, board[y][x]);
			}
		}
	}
	return ans;
}

void dfs(int y, int x, char col){
	board[y][x] = '.';
	foreach(k; 0..4){
		int ny = y + dy[k], nx = x + dx[k];
		if(0<=ny && ny<H && 0<=nx && nx<W && board[ny][nx] == col){
			dfs(ny, nx, col);
		}
	}
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  
  int N, K, cnt = 0;
  cin >> N >> K;
  double ans = 0.0, p = 1.0;
  for (int n = N; n > 0; --n) {
    while (n*(1<<cnt) < K) {
      ++cnt;
      p *= 0.5;
    }
  	ans += p;
  }
  cout << ans/N << "\n";
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let x = scan!(usize);
    for i in 1.. {
        if x <= i * (i + 1) / 2 {
            println!("{}", i);
            return;
        }
    }
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
A_list = []
B_list = []
for _ in range(N):
    A_list.append(list(input()))
for _ in range(M):
    B_list.append(list(input()))
    

whole_flag = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        flag = 0
        for k in range(M):
            if B_list[k] == A_list[i+k][j:j+M]:
                flag += 1
            else:
                pass
        if flag == M:
            whole_flag += 1
            
if whole_flag == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
<?php
$input = fgets(STDIN);
$input = (int)$input;
if (400<=$input && $input<600){
    echo '8';
}
if (600<=$input && $input<800){
    echo '7';
}
if (800<=$input && $input<1000){
    echo '6';
}
if (1000<=$input && $input<1200){
    echo '5';
}
if (1200<=$input && $input<1400){
    echo '4';
}
if (1400<=$input && $input<1600){
    echo '3';
}
if (1600<=$input && $input<1800){
    echo '2';
}
if (1800<=$input && $input<2000){
    echo '1';
}
?>


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


int main() {
    int n;
    cin >> n;
    set<string> gacha;
    rep(i,n){
        string str;
        cin >> str;
        gacha.insert(str);
    }
    cout << gacha.size() << endl;
    return 0;
}



Measured memory_bytes: 19204
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

const long long MOD = 998244353;

int n;
int d[100010];
int dCount[100010];

long long pow(int base, int pows)
{
	long long ans = 1;
	for (int i = 1 ; i <= pows ; i++)
		ans = (ans * base) % MOD;
		
	return ans;
}

int main()
{
	scanf("%d", &n);
	
	memset(dCount, 0, sizeof(dCount));
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d", &(d[i]));
		dCount[d[i]]++;
	}
	
	if ((d[0] != 0) || (dCount[0] != 1))
	{
		printf("0\n");
		return 0;
	}
	
	long long ans = 1;
	for (int i = 1 ; i <= n ; i++)
	{
		ans = ans * pow(dCount[i - 1], dCount[i]) % MOD;	//次方数不会超过n 
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


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

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

    bool f=true;
    int moji=0;
    int cnt=0;

    if(s[0] != 'A'){
        f = false;
    }
    for(int i=2;i <= s.size()-2;i++){
        if(s[i] == 'C'){
            cnt++;
        }
    }
    for(int i=0;i < s.size();i++){
        if(s[i] >= 'a' && s[i] <= 'z'){
            moji++;
        }
    }
    if(f && cnt == 1 && moji == s.size()-(cnt+1) ){
        cout << "AC" << endl;
    }
    else cout << "WA" << endl; 
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <bitset>
#include <iostream>

using namespace std;

constexpr int BITMAP_CENTER = 8001;

int main() {
    string s;
    int gx, gy;
    cin >> s >> gx >> gy;

    // create move array
    bool x_dir = true;
    bool first = true;
    vector<int> x, y;
    int count = 0;
    for (char c: s) {
        if (c == 'T') {
            if (count > 0 || first) {
                if (x_dir) {
                    x.push_back(count);
                } else {
                    y.push_back(count);
                }
            }
            x_dir = !x_dir;
            count = 0;
            first = false;
        } else {
            count++;
        }
    }
    if (count > 0 || first) {
        if (x_dir) {
            x.push_back(count);
        } else {
            y.push_back(count);
        }
    }

    // solve
    bitset<BITMAP_CENTER * 2> x_map, y_map;
    x_map[BITMAP_CENTER] = y_map[BITMAP_CENTER] = true;
    for (auto x_itr = x.begin(); x_itr != x.end(); ++x_itr) {
        if (x_itr == x.begin()) {
            x_map <<= *x_itr;
        } else {
            x_map = (x_map << *x_itr) | (x_map >> *x_itr);
        }
    }
    for (auto y_itr = y.begin(); y_itr != y.end(); ++y_itr) {
        y_map = (y_map << *y_itr) | (y_map >> *y_itr);
    }

    cout << (x_map[BITMAP_CENTER + gx] && y_map[BITMAP_CENTER + gy] ? "Yes" : "No") << endl;
    return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    bool can = false;
    for (int i=1; i <= 9; i++) {
        for (int j=1; j <= 9; j++) {
            if (i * j == N) {
                can = true;
                break;
            }
        }
    }

    if (can) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

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

long maximum(long a, long b)
{
  if(a>b)
    return a;
  return b;
}

int main(){
  int n,W;
  cin >> n >> W;
  long w[n],v[n];
  for(int i=0;i<n;i++)
    cin >> w[i] >> v[i];
  long dp[n+1][W+1];
  for(int i=0;i<=n;i++) {
      for(int j=0;j<=W;j++) {
          dp[i][j] = 0;
      }
  }
  for(int i=1;i<=n;i++) {
      for(int j=0;j<=W;j++){
          dp[i][j] = dp[i-1][j];
          if(j>=w[i-1]){
              dp[i][j] = maximum(dp[i][j], v[i-1]+dp[i-1][j-w[i-1]]);
          }
      }
  }
  cout << dp[n][W] << endl;
  return 0;
}

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

const ll mod = 1e9 + 7;
vector<ll> com;
const ll maxk = 2e5 + 1;

ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x); // 再帰的に解く
	y -= a / b * x;
	return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long Mod(long long a, long long m) {
	return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
	long long x, y;
	extGCD(a, m, x, y);
	return Mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	com.push_back(1);
	for (ll i = 1; i < maxk; ++i) {
		com.push_back(com[i - 1] * (n - i + 1));
		com[i] %= mod;
		com[i] *= modinv(i, mod);
		com[i] %= mod;
	}
	ll ans = modpow(2, n);
	ans -= com[a] + com[b] + 1;
	ans += 10 * mod;
	ans %= mod;
	cout << ans << endl;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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 main(){

    string s;cin>>s;
    int sum=0;
    int ans=0;
    rep(i,3){
        if(s[i]=='R'){
            sum+=1;

        }
        else sum=0;
        ans = max(ans,sum);

    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>

using namespace std;

int Time[64], Lap[64], Ans;

struct Event {
	int TimeStamp, who, where;
	Event() {}
	Event(int t, int who, int where) :
		TimeStamp(t), who(who), where(where) {}
	inline bool operator< (const Event& comp) const {
		if(TimeStamp != comp.TimeStamp) return TimeStamp > comp.TimeStamp;
		if(where != comp.where) return where > comp.where;
		if(Time[who] != Time[comp.who]) return Time[who] > Time[comp.who];
		return who > comp.who;
	}
};

priority_queue<Event> Q;
int n, Arrive[2];

template<class T> inline bool _max(T& data, const T& update) {
	if(data < update) {
		data = update;
		return true;
	}
	return false;
}

int main(void) {
	while(scanf("%d", &n), n) {
		register int i;
		Ans = 0;
		Arrive[0] = Arrive[1] = 0;
		for(i = 0; i < n; ++ i) scanf("%d%d", Time + i, Lap + i);
		for(i = 0; i < n; ++ i) Q.push(Event(Time[i], i, 1)), _max(Arrive[1], Time[i]);
		while(Q.size()) {
			const Event &ev = Q.top();
			int nextSide = !ev.where, nextTime = max(Arrive[nextSide], ev.TimeStamp + Time[ev.who]);
			_max(Arrive[nextSide], nextTime); _max(Ans, nextTime);
			if (!nextSide) -- Lap[ev.who];
			if (Lap[ev.who] > 0) {
				Q.push(Event(nextTime, ev.who, nextSide));
			}
			Q.pop();
		}
		printf("%d\n", Ans);
	}
}

Measured memory_bytes: 1032
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

const int INF = 1e9;
const long long LINF = 1e18;

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

    cout << max(A + B, max(A - B, A * B));

    return 0;
}


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

double n,k;

int suc_calc(int a,int b){
    if(a>=k) return 0;
    return suc_calc(a*2,b) +1;
}

int main(){
    cin>>n>>k;
    double ans=0.0;

    for(double i=1;i<=min(n,k-1);i++){
        ans+= 1/n * pow(0.5,suc_calc(i,k));
    }

    if(k<=n){
        for(double i=k;i<=n;i++){
            ans+=1.0/n;
        }
    }

    printf("%.13f\n", ans);
}

Measured memory_bytes: 512