akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int f(long long a){
    int cnt = 0;
    while(a > 0){
        a /= 10;
        cnt++;
    }
    return cnt;
}

int main(){
    long long N; cin >> N;
    int mx = 0;
    int ans = MM;
    for(long long i = 1; i*i <= N; i++){
        if (N % i == 0){
            long long tmp = N/i;
            mx = max(f(tmp),f(i));
            ans = min(ans,mx);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;

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

		LinkedList list = new LinkedList();
		String x = sc.next();

		for(int i = 0;i < x.length();i++){
			if(x.charAt(i) == 'S'){
				list.add('S');
			}else{
				if(list.size() != 0 && (char)list.peekLast() == 'S'){
					list.pollLast();
				}else{
					list.add('T');
				}
			}
		}

		System.out.println(list.size());
	}
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll mn = min({a,b,c,d,e});
  ll ans = n/mn + 5;
  if(n % mn == 0) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 256
import collections

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    H, W = ZZ()
    D = collections.defaultdict(int)
    for i in range(H):
        for c in input(): D[c] += 1

    if 1 in {H, W}:
        if H*W%2 == 0: print('Yes' if all([D[c]%2 == 0 for c in D.keys()]) else 'No')
        else:
            a = 0
            for c in D.keys():
                if D[c]%2 == 1: a += 1
            print('Yes' if a == 1 else 'No')
    else:
        if H%2 == 0 and W%2 == 0: print('Yes' if all([D[c]%4 == 0 for c in D.keys()]) else 'No')
        elif (H*W)%2 == 0:
            if W%2 == 0: H, W = W, H
            x = y = z = 0
            for c in D.keys():
                if D[c]%4 == 0: x += 1
                elif D[c]%4 == 2: y += 1
                else: z += 1
            print('Yes' if y%2 == (H//2)%2 and y <= H//2 and z == 0 else 'No')
        else:
            a = b = 0
            for c in D.keys():
                if D[c]%2 == 1: a += 1
                b += D[c]//4
            print('Yes' if a == 1 and b >= (H//2)*(W//2) and len(D.keys()) <= ((H+1)//2)*((W+1)//2) else 'No')
    return

if __name__ == '__main__':
    main()


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

long long divi(long long a, long long b) {
    return a/b;
}

long long gcd(long long x, long long y) {
    if(y == 0) return x;
    else return gcd(y, x%y);
}

int main() {
    long long A, B, C, D; cin >> A >> B >> C >> D;
    long long divc = divi(B, C) - divi(A-1, C);
    long long divd = divi(B, D) - divi(A-1, D);
    long long divcd = divi(B, C * D / gcd(C, D)) - divi(A-1, C * D / gcd(C, D));
    long long ans = (B - A + 1) - divc - divd + divcd;
    cout << ans << endl;
    return 0;
}

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

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

int main()
{
  int ans, n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)
  {
    cin >> a[i]; 
  }
  ans = a[0];
  for(int i = 1; i < n; i++)
  {
    ans = gcd(ans, a[i]);
  }
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 640
/**
 * @author: shashankchdhry
 * @made:   2020-03-30 20:55:23 
**/
#include <bits/stdc++.h>

using namespace std;

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

    string s;
    cin >> s;

    int n = s.length();

    string ans;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'B' && ans.length())
            ans.erase(ans.length()-1);
        else if (s[i] != 'B')
            ans += s[i];
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
// Score: /200

#include <iostream>
#include <cmath>

using namespace std;

bool is_beki(int num)
{
	if (num == 1)
	{
		return true;
	}
	for (int i = 2; i <= sqrt(num); ++i)
	{
		auto v = log(num) / log(i);
		if (abs(v - round(v)) < 0.00001)
		{
			return true;
		}
	}
	return false;
}

int main()
{
	int X;
	cin >> X;
	for (int i = X; i >= 1; --i)
	{
		if (is_beki(i))
		{
			cout << i;
			break;
		}
	}
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

int N;
int main(){
    cin>>N;
    int pt=0,px=0,py=0;
    string ans="Yes";
    REP(i,0,N){
        int t,x,y;
        cin>>t>>x>>y;
        if((t-pt)>=abs(px-x)+abs(py-y)&&(t-pt)%2==(abs(px-x)+abs(py-y))%2){
            continue;
        }
        ans="No";
    }
    p(ans);
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<int, int> A;
  for(int ii=0; ii<N; ii++){
    int a;
    cin >> a;
    A[a]++;
    if(A[a] != 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
操作の逆順を考える
Codeforcesではscanfを使う
エラー出力は消す
エラー出力を消せ！！！！！
 */

int main() {
    string s;
    cin >> s;
    int n=s.length()+1;
    s[n-1]='<';
    ll sum=0;
    vector<ll> a(n);
    rep(i,n)a[i]=0;
    int mont=0;
    bool clim=false;
    rep(i,n){
        /*if(i==0){
            if(s[0]=='<'){
                a[0]=0;
                clim=true;
            }
            else{
                mont=0;
                clim=false;
            }
        }
        if(i==n-1){
            if(s[i-1]=='<')a[i]=a[i-1]+1;
            else a[i]=0;
        }*/
            if(s[i]=='<'){
                if(clim)a[i]=a[i-1]+1;
                else{
                    a[i]=0;
                    int x=i;
                    while(x>=mont){
                        chmax(a[x],a[x+1]+1);
                        x--;
                    }
                    clim=true;
                }
            }
            else{
                if(clim){
                    mont=i;
                    a[i]=a[i-1]+1;
                    clim=false;
                }
                else continue;
            }
    }
    rep(i,n){
        sum+=a[i];
    }
    cout << sum-n;

    


}

/*



 */



Measured memory_bytes: 4740
import numpy as np
N = int(input())
A = []
i = 2
a = int()
b = int()
ans = 10**12+1
for i in range(2,int(np.sqrt(N))+1):
    if N%i ==0:
        A.append(i)

if len(A) == 0:
    print(N-1)
else:
    for j in range(len(A)):
        a = A[j]-1
        b = (N/A[j])-1
        if a+b <= ans:
            ans = a+b
    print(int(ans))

Measured memory_bytes: 14440
ABs = []

N = int(input())
for _ in range(N):
    ABs.append(tuple(map(int,input().split())))

ABs = sorted(ABs, key=lambda x: x[1])

sum = 0
for A, B in ABs:
    sum += A
    if sum > B:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 39024
#include<iostream>
#include<math.h>
#include<vector>

using namespace std;

int main(void){
  int data1[1000],data2[1000],data3[1000],data4[1000];
  int g,i;
  cin >> g;
  for(i=0;i<g;i++){
    cin >> data1[i] >> data2[i] >> data3[i];
  }
  int m,j;
  i=0;
  for(i=0;i<g;i++){
    for(j=0;j<3;j++){
      if(data1[i] < data2[i]){ m = data2[i]; data2[i] = data1[i]; data1[i] = m;  }
      if(data2[i] < data3[i]){ m = data3[i]; data3[i] = data2[i]; data2[i] = m;  }
    }
    if(pow(data1[i],2) == (pow(data2[i],2)+pow(data3[i],2))) cout << "YES" <<endl;
    else cout << "NO" << endl;
  }

}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
main(){
    int p[3][2],k,flag=1;
    int a[5]={};
    for(int i=0;i<6;i++){
        cin>>k;
        a[k]++;
    }

for(int i=1;i<5;i++){
    if(a[i]==3)flag=0;
    }

    if(flag)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    int n, a[110];

    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
    }

    sort(a, a + n);

    int sum = 1e9;

    for (int i = a[0]; i <= a[n - 1]; i++)
    {
        int sum_ = 0;

        REP(j, n)
        {
            sum_ += (a[j] - i) * (a[j] - i);
        }

        sum = min(sum, sum_);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
KS = [[int(i) for i in readline().split()] for _ in range(m)]
P = [int(i) for i in readline().split()]

import itertools

L = list(itertools.product([0,1], repeat=n))

ans = 0

for l in L:
    for ks, p in zip(KS, P):
        tmp = sum([l[i-1] for i in ks[1:]])
        if tmp%2 == p:
            pass
        else:
            break
    else:
        ans += 1
        
print(ans)

Measured memory_bytes: 9288
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main(){
  int n, count7 = 0, count5 = 0;
  for (int i = 0; i < 3; i++) {
    cin >> n;
    if (n == 5) count5++;
    if (n == 7) count7++;
  }
  if ((count5 == 2) && (count7 == 1)) { cout << "YES" << endl; }
  else { cout << "NO" << endl; }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
w=[input() for i in range(n)]
if len(set(w))==n:
	for i in range(n):
		if i>0:
			if w[i-1][len(w[i-1])-1]!=w[i][0]:
				print('No')
				exit()
else:
	print('No')
	exit()
print('Yes')

Measured memory_bytes: 3060
#include<iostream>
#include <iomanip>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int i, j, k, n;

	cin >> n >> k;
	int *p = new int[n];
	for (i = 0; i < n; i++) {
		cin >> p[i];
	}

	long tmp, ans;
	tmp = 0;
	for (i = 0; i < k; i++) {
		tmp += p[i];
	}
	ans = tmp;

	for (i = k; i < n; i++) {
		tmp = tmp + p[i] - p[i - k];
		ans = max(tmp, ans);
	}

	double outans = (double)(ans + k) / 2.0;
	cout << fixed << setprecision(7) << outans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	if (s == "AKIHABARA") {
		cout << "YES\n";
		return 0;
	}
	if (s == "KIHABARA") {
		cout << "YES\n";
		return 0;
	}
	if (s == "AKIHBARA") {
		cout << "YES\n";
		return 0;
	}
	if (s == "AKIHABRA") {
		cout << "YES\n";
		return 0;
	}
	if (s == "AKIHABAR") {
		cout << "YES\n";
		return 0;
	}
	if (s == "KIHBARA") {
		cout << "YES\n";
		return 0;
	}
	if (s == "KIHABRA") {
		cout << "YES\n";
		return 0;
	}
	if (s == "KIHABAR") {
		cout << "YES\n";
		return 0;
	}
	if (s == "AKIHBRA") {
		cout << "YES\n";
		return 0;
	}
	if (s == "AKIHBAR") {
		cout << "YES\n";
		return 0;
	}
	if (s == "AKIHABR") {
		cout << "YES\n";
		return 0;
	}
	if (s == "KIHBRA") {
		cout << "YES\n";
		return 0;
	}
	if (s == "KIHBAR") {
		cout << "YES\n";
		return 0;
	}
	if (s == "KIHABR") {
		cout << "YES\n";
		return 0;
	}
	if (s == "AKIHBR") {
		cout << "YES\n";
		return 0;
	}
	if (s == "KIHBR") {
		cout << "YES\n";
		return 0;
	}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		ans[i] = -1
	}
	ss := make([]int, m)
	cc := make([]int, m)
	for i := 0; i < m; i++ {
		ss[i] = getNextInt(scanner) - 1
		cc[i] = getNextInt(scanner)
	}

	for i := 0; i < m; i++ {
		if ans[ss[i]] == -1 {
			ans[ss[i]] = cc[i]
			continue
		}
		if ans[ss[i]] != cc[i] {
			fmt.Fprintln(writer, -1)
			return
		}
		ans[ss[i]] = cc[i]
	}
	for i := 1; i < n; i++ {
		if ans[i] == -1 {
			ans[i] = 0
		}
	}
	if n == 1 {
		if ans[0] == -1 {
			ans[0] = 0
		}
	} else {
		if ans[0] == 0 {
			fmt.Fprintln(writer, -1)
			return
		}
		if ans[0] == -1 {
			ans[0] = 1
		}
	}
	for i := 0; i < n; i++ {
		fmt.Fprint(writer, ans[i])
	}
	fmt.Fprintln(writer, "")
}

func maxint(a, b int) int {
	if a < b {
		return b
	}
	return a
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (h >= k) ans++;
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,k;
	LL x[55]={},y[55]={};
	cin>>n>>k;
	FOR(i,0,n){
		cin>>x[i]>>y[i];
	}
	LL ans=-1;
	FOR(l,0,n){
		FOR(r,0,n){
			if(x[l]>=x[r])continue;
			FOR(h,0,n){
				FOR(u,0,n){
					if(y[h]<=y[u])continue;
					int c=0;
					FOR(i,0,n){
						if(x[l]>x[i]||x[i]>x[r])continue;
						if(y[i]>y[h]||y[u]>y[i])continue;
						c++;
					}
					if(c<k)continue;
					LL s=(x[r]-x[l])*(y[h]-y[u]);
					if(ans==-1||s<ans)ans=s;
				}
			}
		}
	}
	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	unsigned long long a;

	// b の整数部分と小数部分
	unsigned long long b_integer, b_decimal;

	// %*c で小数点の 1 文字分をよける
	(void)scanf("%llu%llu%*c%llu", &a, &b_integer, &b_decimal);

	// 小数点以下は 2 桁までしかないので， 100 倍すると整数になる
	unsigned long long b_times_100 = b_integer * 100 + b_decimal;

	printf("%llu\n", a * b_times_100 / 100);

}


Measured memory_bytes: 1732
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;
#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

static int dp[11][1 << 10][331];
int n, s;
int dfs(int m, int state, int sum) {
	if (sum < 0 || m < 0 || sum>330)return 0;
	if (dp[m][state][sum] != -1)return dp[m][state][sum];
	dp[m][state][sum] = 0;
	rep(i, 0, 10) {
		if (((1 << i)&state) != 0)
			dp[m][state][sum] += dfs(m - 1, state - (1 << i), sum - m*i);
	}
	//if (dp[m][state][sum] != 0)cerr << m << " " << state << " " << sum << " " << dp[m][state][sum] << endl;
	return dp[m][state][sum];
}

signed main() {
	fill(dp[0][0], dp[11][0], -1);
	dp[0][0][0] = 1;
	for (; cin >> n >> s;) {
		int sum = 0;
		//rep(i, 0, 11) {
		//	dump(dfs(i, (1 << i) - 1, (sum += i*(i - 1)))); cerr << i << " " << ((1 << i) - 1) << " " << sum << endl;
		//}
		//dump(dfs(1, 0, 0));
		//dump(dfs(1, 0, 0));
		int ans = 0;
		rep(state, 0, 1 << 10) ans += dfs(n, state, s);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 32208
#include <stdio.h>
    int main(void){
        int n;
        scanf("%d",&n);
        
        int a,b,c;
        
        a=n/100;
        b=n/10-a*10;
        c=n-a*100-b*10;
        
        if(a>b){
            printf("%d\n",a*100+a*10+a);
            return 0;
        }else if(a==b){
                if(b>=c){
                    printf("%d\n",a*100+a*10+a);
                    return 0;
                }
        }
                
        a++;
        printf("%d\n",a*100+a*10+a);
            
        
        return 0;
    }

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> a(206);
    vector<ll> b(206);
    a[1]=300000;
    a[2]=200000;
    a[3]=100000;
    b[1]=300000;
    b[2]=200000;
    b[3]=100000;
    ll q,w;
    cin>>q>>w;
    ll ans = 0;
    if(q == w && q == 1) ans = 400000;
    cout<<ans+a[q]+b[w]<<endl;
}

Measured memory_bytes: 256
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 

int sqr(int x){
    return x*x;
}

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

    vector<int> x(n),y(n),p(n);

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

    double sum = 0;
    int count = 0;

    do{
        for(int i=0;i+1<n;++i){
            int curr = sqr( x[p[i+1]] - x[p[i]] ) + sqr( y[p[i+1]] - y[p[i]] );
            sum += sqrt(1.0*curr);
        }
        count += 1;
    }while(next_permutation(p.begin(),p.end()));

    sum = sum/count;

    printf("%.10f\n",sum);
  rr;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a,b;
  cin >> a >> b;
  string ans;
  if(a>b){
    ans ="GREATER";
  }
  else if(a==b){
    ans="EQUAL";
  }
  else{
    ans="LESS";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def bfs(field,H,W,start_x,start_y,tmp_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    que = []
    que.append([start_x,start_y])
    INF = 1000000
    min_path = [[INF] * W for i in range(H)]
    min_path[start_y][start_x] = 0
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] != "X" and min_path[ny][nx] == INF:
                min_path[ny][nx] = min_path[current[1]][current[0]] + 1
                if field[ny][nx] == tmp_N:
                    return nx,ny,min_path[ny][nx]
                else:
                    que.append([nx,ny])

def getField():
    matrix = []
    first = input().strip()
    H,W,N = map(int,first.split())
    for i in range(H):
        row = list(input().strip())
        for j in range(W):
            if row[j].isdigit():
                row[j] = int(row[j])
        matrix.append(row)
    return matrix,H,W,N

def getStart(field):
    for y in range(len(field)):
        for x in range(len(field[0])):
            if field[y][x] == "S":
                return x,y

def main():
    matrix,H,W,N = getField()
    sx,sy = getStart(matrix)
    distance = 0
    tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,sx,sy,1)
    distance += tmp_dist
    tmps = [tmp_x,tmp_y]
    for k in range(N-1):
        tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,tmps[0],tmps[1],k+2)
        distance += tmp_dist
        tmps = [tmp_x,tmp_y]
    print(distance)

if __name__=='__main__':
    main()

Measured memory_bytes: 36960
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int, int> iP;

int n, T, S, a[3333], b[3333], mini = INF;
int dp[3001][3001];
bool used[3333];

int rec(int idx, int now, int g){

  if(idx == n) return 0;
  if(~dp[idx][now]) return dp[idx][now];
  
  int ret = 0;
  if(now + b[idx] <= g)
    ret = rec(idx + 1, now + b[idx], g) + a[idx];
  else if(g == S)
    ret = max(ret, rec(idx, S, T));
  
  ret = max(ret, rec(idx + 1, now, g));
              
  return dp[idx][now] = ret;
}

int main(){
  
  cin >> n >> T >> S;
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
    mini = min(mini, b[i]);
  }
  
  memset(dp, -1, sizeof(dp));
  cout << rec(0, 0, S) << endl;
 
}

Measured memory_bytes: 36564
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
const int INF = 1e9;
using P = pair<int,int>;

int main(){
  int n;
  cin >> n;
  int a[n], b[n];
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  vector<vector<int>> dp(1<<n,vector<int>(51,INF));
  dp[0][0] = 0;
  rep(i,1<<n) {
    int c = 0;
    rep(j,n) {
      if(i & (1<<j)) c++;
    }
    int p = c;
    vector<P> pos;
    rep(j,n) {
       if(!(i & (1<<j))) pos.push_back(P(j,p++));
    }
    rep(l,51) {
      for(auto k : pos) {
        int d;
        if(abs(k.first-c) % 2) d = b[k.first];
        else d = a[k.first];
        if(d >= l) dp[i|(1<<k.first)][d] = min(dp[i|(1<<k.first)][d],dp[i][l]+abs(k.second-c));
      }
    }    
  }
  int ans = INF;
  rep(i,51) ans = min(ans,dp[(1<<n)-1][i]);
  cout << (ans == INF? -1 : ans) << endl;
  return 0;
}

Measured memory_bytes: 65792
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  16:30-
//A 16:36
int solve(void){
	int n,m,t,p,i,wa=0,ans=0,x=0,y=0;cin>>n>>m>>t>>p;
	if(n==0){return 0;}
	int a[3000]={};
	int b[3000]={};
	for(i=0;i<n;i++){a[i]=1;}
	for(i=0;i<m;i++){b[i]=1;}
	while(t--){
		int d,c;cin>>d>>c;
		if(d==1){
			for(i=0;i<c;i++){a[c+c-1-i+x]+=a[i+x];}
			x+=c;
		}else{
			for(i=0;i<c;i++){b[c+c-1-i+y]+=b[i+y];}
			y+=c;
		}
	}
	while(p--){
		int xa,ya;cin>>xa>>ya;
		xa+=x;ya+=y;
		cout<<a[xa]*b[ya]<<endl;
	}
	return 1;
}
int main(void){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>

int main(void){
int a,b,c,i;
int tmp=0;
scanf ("%d%d%d",&a,&b,&c);
for (i=1;i<=10000;i++){
	if ((c%i==0)&&(a<=i&&i<=b)){
		tmp++;}

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

	return 0;}

Measured memory_bytes: 596
program weight
  implicit none
  integer :: n, allsum,partsum, ans, i
  integer,allocatable :: w(:)

  partsum = 0
  read *, n 
  allocate(w(n))
  read *, w
  allsum = sum(w)
  do i = 1, n
    partsum = partsum + w(i)
    if (partsum < allsum-partsum) then
      ans = allsum - 2*partsum
    else
      ans = min(ans, 2*partsum - allsum)
      exit
    end if
  end do
  print '(i0)', ans
end program weight


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll SORT(int n, vector<pair<ll, ll>> &v, int start){
  sort(v.begin()+start, v.end());
  return v[n-1].first;
}


int main(void){
 
  ll n;
  cin>>n;
  map<ll, ll> m;
  vector<ll> x(n), y(n);

  REP(i, n){
    ll a;
    cin>>a;
    x[i] = i+a;
    y[i] = i-a;
  }

  ll ans = 0;

  REP(i, n) m[x[i]]++;
  REP(i, n){
    if(m[y[i]]!=0) ans += m[y[i]];
  }

  cout<<ans<<endl;
  return 0;

}

Measured memory_bytes: 29044
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int R[MAX], N;

main(){
  cin >> N;
  for ( int i = 0; i < N; i++ ) cin >> R[i];

  int minv = R[0];
  int ans = -2000000000;
  for ( int i = 1; i < N; i++ ){
    ans = max(ans, R[i] - minv );
    minv = min(minv, R[i]);
  }

  cout << ans << endl;

}



Measured memory_bytes: 3816
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {
        
        static void Main(string[] args)
        {
            List<char> ch_in_origin = Console.ReadLine().ToList();

            List<char> ch_sub = new List<char>();

            for(int i = 0; i < ch_in_origin.Count(); i++)
            {
                ch_sub.Add(ch_in_origin[i]);
            }

            ch_in_origin.Reverse();

            for(int i = 0; i < ch_in_origin.Count(); i++)
            {
                char ch = ch_in_origin[i];

                if (ch == 'b') ch = 'd';
                else if (ch == 'd') ch = 'b';
                else if (ch == 'p') ch = 'q';
                else if (ch == 'q') ch = 'p';

                ch_in_origin[i] = ch;

            }

            for(int i = 0; i < ch_in_origin.Count(); i++)
            {
                if(ch_in_origin[i] != ch_sub[i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 14432
#include<bits/stdc++.h>
#define i64 long long
#define inf 1000000000000000000
using namespace std;
const int MAXN=319;

i64 ara[MAXN][MAXN];
bool dist[MAXN][MAXN];




int main()
{
    i64 n,x,u,v,w;
    scanf("%lld",&n);



    i64 sum=0;
    for(i64 i=1; i<=n; i++)
    {
        for(i64 j=1; j<=n; j++)
        {
            scanf("%lld",&x);
            ara[i][j]=x;

            if(j>i)
                sum+=x;
        }
    }

  //  cout<<sum<<endl;

    for(i64 k=1; k<=n; k++)
        for(i64 i=1; i<=n; i++)
            for(i64 j=1; j<=n; j++)
            {
                if(ara[i][k]+ara[k][j]<ara[i][j] || ara[i][k]+ara[k][j]<ara[j][i])
                {
                    printf("-1\n");
                    return 0;
                }
            }


    for(i64 k=1; k<=n; k++)
        for(i64 i=1; i<=n; i++)
            for(i64 j=i+1; j<=n; j++)
            {


                if(k==i || k==j) continue;
                if(ara[i][k]+ara[k][j]==ara[i][j])
                {
                    dist[i][j]=true;

                }
            }


     for(int i=1;i<=n;i++)
     {
         for(int j=1;j<=n;j++)
         {
             if(dist[i][j]==true)
                sum-=ara[i][j];
         }
     }



    cout<<sum<<endl;

}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define mod 1000000007
#define INF 2147483647
#define fi first
#define se second
int abs(int a,int b){
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
  return true;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,e=0,f=0;
  int d[100000];
  cin>>a>>b>>c;
  for(int i=0;i<a;i++){
    cin>>d[i];
    if(b%d[i]!=0) f++;
  }
  e=f;
  for(int i=0;i<a;i++){
    e+=b/d[i];
  }
  cout<<e+c<<"\n";
}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

ll dp0[110][5], dp1[110][5];

int main() {
	string s;
	cin >> s;
	int K;
	cin >> K;
	int t = s.length();
	int q = s[0] - '0';
	dp0[1][0] = 1; // 0xxx..
	dp0[1][1] = (s[0] - '0') - 1; //1~s[x]-1xxxx..
	dp1[1][0] = 0;
	dp1[1][1] = 1; //s[0]xxx...
	for(int i=2; i<4; i++) {
		dp0[1][i] = 0;
		dp1[1][i] = 0;
	}
	for(int i=1; i<=t-1; i++) {
		int p = s[i] - '0';
		rep(j, K+1) {
			dp0[i+1][j] += dp0[i][j];
			dp0[i+1][j+1] += dp0[i][j] * 9;
			if(p != 0) {
				dp0[i+1][j+1] += dp1[i][j] * (p-1);
				dp0[i+1][j] += dp1[i][j];
				dp1[i+1][j+1] += dp1[i][j];
			}
			if(p == 0) {
				dp1[i+1][j] += dp1[i][j];
			}
		}
	}
	/*rep(i,t+1) {
		rep(j, K+1) cout << dp0[i][j] << " ";
		cout << endl;
	}
	rep(i,t+1) {
		rep(j, K+1) cout << dp1[i][j] << " ";
		cout << endl;
	}*/
	ll ans = dp0[t][K] + dp1[t][K];
	cout << ans << endl;
  return 0;
}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<int> T(N), A(N);
    for (int i = 0; i < N; i++)
        cin >> T[i] >> A[i];
    int64_t Tn = 1, An = 1;
    for (int i = 0; i < N; i++)
    {
        int64_t Nt = (T[i] + Tn - 1) / T[i];
        int64_t Na = (A[i] + An - 1) / A[i];
        int64_t N = max(Nt, Na);
        Tn = T[i] * N, An = A[i] * N;
    }
    cout << Tn + An;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  string s;
  cin >> s;
  int cnt = 0;
  REP(i, s.size()) {
    cnt += s[i]-'0';
  }
  cout << cnt << endl;

}


Measured memory_bytes: 256
n,a,b=map(int,input().split())

mod=10**9+7

J=pow(2,n,mod)
def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n):
    #0!からn!までの逆元を素数10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n,10**9+7)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist

C=find_inv_power(2*10**5+100)
if  True:
    c=1
    for i in range(a):
        c*=(n-i)
        c=c%mod
    c=c*C[a]
    c=c%mod
    d=1
    for i in range(b):
        d*=(n-i)
        d=d%mod
    d=d%mod
    d=d*C[b]
    print((J-c-d-1)%mod)

Measured memory_bytes: 18804
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test,i,a=0,b=0,c=0,d=0;
    cin>>test;
    char s1[1000];
    while(test--)
    {
        cin>>s1;
        if(s1[0]=='A')
            a++;
        else if(s1[0]=='W')
            b++;
        else if(s1[0]=='T')
            c++;
        else
            d++;
    }
    //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
    cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<b<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<c<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<d<<endl;
    return 0;
}


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

int main(void) {
    int n;
    string s;

    while (1) {
        cin >> n;
        if (n == 0) break;

        int l = 0; int r = 0;
        int f = -1;
        int cnt = 0;

        for (int i = 0; i < n; i++) {
            cin >> s;
            if (s[0] == 'l') {
                l = (l + 1) % 2;
                if (r == l && f == 1) cnt++;
                f = 0;
            }
            else {
                r = (r + 1) % 2;
                if (r == l && f == 0) cnt++;
                f = 1;
            }
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  
  if(A+B==15) cout<<"+"<<endl;
  else if(A*B==15) cout<<"*"<<endl;
  else cout<<"x"<<endl;
}

Measured memory_bytes: 256
# 10**100の桁とそれ以外で分けて考える。
# 10**100の桁はk個選ぶと必ずk*10*100となるので無視
# 0~Nからk個選んだ場合の合計値が何個あるか数える
# 合計値のパターンは最小値から最大値まで連続した値となる
# N=3,K=2の場合、合計値パターンは5パターン：1(最小値),2,3,4,5(最大値)
# k番目の最小値は0,1,2,…k-1 = k*(k-1)/2
# k番目の最大値はn-k+1,n-k+2,n-k+3,…,n = k*(2n-k+1)/2

n,k = [int(x) for x in input().split()]
count=0
mod = 10**9+7
for i in range(k,n+2):
    mink=int(i*(i-1)/2)
    maxk=int(i*(2*n-i+1)/2)
    count+=maxk - mink + 1

print(count%mod)


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

void itoa(int val,int radix){
  unsigned int v = val;
  int n = 1;
  while(v>=radix){
    v/=radix;
    n++;
  }
  cout<< n <<endl;
  
}

int main(){
  int N,K;
  cin>> N >> K;
  string s;
  itoa(N,K);
  cout << s <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int a[100005];
int b[100005];
char c[10000];
int main()
{
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    int n,m,h;
    int ci=0,ct=0;
    scanf("%d%d",&n,&m);
    int i,j;
    for(i=0;i<m;i++)
    {
        scanf("%d%s",&h,c);
        if(c[0]=='W')
        {
            a[h]++;
        }
        else if(c[0]=='A')
        {
            if(b[h]==0)
            {
                b[h]=1;
                ci++;
                ct+=a[h];
            }
        }
    }
    printf("%d %d\n",ci,ct);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef pair<int, int> P;
int main(){
  int N, M;
  cin >> N >> M;

  vector<P> war;

  for(int i=0;i<M;i++){
    int a, b;
    cin >> a >> b;
    war.push_back(make_pair(b,a));
  }

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

  int ans = 0;
  int cut = 0;
  for(int i=0;i<M;i++){
    if(war[i].second>=cut){
      ans ++;
      cut = war[i].first;
    }
  }
  cout << ans <<endl;
  
  return 0;
}

Measured memory_bytes: 1400
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int a, b, k, i;
  scanf("%d%d%d", &a, &b, &k);
  for( i = a; i < min(b, a+k); i++) printf("%d\n", i);
  if((i-1) == b) return 0;
  for(int j = max(i, b-k+1); j <= b; j++) printf("%d\n", j);
}


Measured memory_bytes: 128
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log
from itertools import *
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())


n=input()
a=list(mp())
b=list(mp())
l=[a,b]
ans=0
for i in range(n):
	ans=max(ans,sum(a[:i])+sum(b[i:])+a[i])
print ans

Measured memory_bytes: 6032
#include<bits/stdc++.h>
using namespace std;
int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int64_t cnt=0;
	for (int i=1;i<=n;i++) {
		if (n%i) cnt+=n/i;
		else cnt+=n/i-1;
	}
	cout<<cnt;
}

Measured memory_bytes: 3636
line = input().split(" ")
a = line[0]
b = line[1]

line_a = ""
line_b = ""
dict = []

for i in range(int(a)):
    line_a += b

for i in range(int(b)):
    line_b += a

dict.append(line_a)
dict.append(line_b)
dict.sort()

print(dict[0])


Measured memory_bytes: 3060
n = int(input())
odds = [val for val in range(1, n+1) if val % 2 == 1]

n_eight_devisor = 0
for odd in odds:
    n_divisor = 0
    # Count number of divisor
    for i in range(1, odd+1):
        if odd % i == 0:
            n_divisor += 1
    if n_divisor == 8:
        n_eight_devisor += 1

print(n_eight_devisor)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <bitset>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr int base = 88 * 160;

int h, w, x, a[88][88];
bitset<base * 2> dp[88][88];

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> h >> w;
  REP(i, h) REP(j, w) cin >> a[i][j];
  REP(i, h) REP(j, w) { cin >> x; a[i][j] = abs(x - a[i][j]); }

  dp[0][0][base + a[0][0]] = 1;
  dp[0][0][base - a[0][0]] = 1;
  REP(i, h) REP(j, w) {
   if (i) {
    dp[i][j] |= dp[i - 1][j] >> a[i][j]; 
    dp[i][j] |= dp[i - 1][j] << a[i][j]; 
   }
   if (j) { 
    dp[i][j] |= dp[i][j - 1] >> a[i][j]; 
    dp[i][j] |= dp[i][j - 1] << a[i][j]; 
   }
  }
  
  int ans = base;
  for(int i = 0; i < base * 2; ++i) if (dp[h - 1][w - 1][i]) ans = min(ans, abs(base - i));
  cout << ans;
  return 0;
}

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

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

    vector<int> c(3);
    int d, cnt = 0;

    rep(i, 1000) {
        c.at(0) = i / 100;
        c.at(1) = (i / 10) % 10;
        c.at(2) = i % 10;

        d = 0;
        rep(j, n) {
            if (s.at(j) == (c.at(d) + '0')) {
                d++;
            }
            if (d == 3) {
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = ceil((float) c / b);
    int y = ceil((float) a / d);
    if (x <= y) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3676
N, K = map(int, input().split())
A = list(map(int, input().split()))

numlist = {}
for i in A:
    if i in numlist:
        numlist[i] += 1
    else:
        numlist[i] = 1
numbers = numlist.values()
numbers = sorted(numbers)

change = 0
vari = len(numbers)
for i in range(vari):
    if K >= vari - i:
        break
    change += numbers[i]

print(change)


Measured memory_bytes: 32184
x = int(input())

if 400 <= x < 600:
    print(8)
elif 600 <= x < 800:
    print(7)
elif 800 <= x < 1000:
    print(6)
elif 1000 <= x < 1200:
    print(5)
elif 1200 <= x < 1400:
    print(4)
elif 1400 <= x < 1600:
    print(3)
elif 1600 <= x < 1800:
    print(2)
elif 1800 <= x < 2000:
    print(1)

Measured memory_bytes: 9200