akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, x, y, z, d[42][2][131072] = {}, p[20] = {1}, w = 0;
    bool b[131072] = {};
    for (int i = 1; i <= 17; i++) p[i] = p[i - 1] + p[i - 1];
    cin >> n >> x >> y >> z; x += y + z; y += z; x--; y--; z--;
    for (int i = 0; i < 131072; i++) if (i & p[x] && i & p[y] && i & p[z]) b[i] = 1;
    for (int i = 0; i < 10; i++) d[1][0][p[i]] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < 131072; j++) {
            for (int k = 1; k <= 10; k++) {
                int l = ((j << k) & 131071) | p[k - 1];
                if (b[l]) {
                    d[i][1][l] += d[i - 1][0][j];
                    if (d[i][1][l] >= mod) d[i][1][l] -= mod;
                } else {
                    d[i][0][l] += d[i - 1][0][j];
                    if (d[i][0][l] >= mod) d[i][0][l] -= mod;
                }
                d[i][1][l] += d[i - 1][1][j];
                if (d[i][1][l] >= mod) d[i][1][l] -= mod;
            }
        }
    }
    for (int i = 0; i < 131072; i++) {
        w += d[n][1][i];
        if (w >= mod) w -= mod;
    }
    cout << w << '\n';
}


Measured memory_bytes: 43520
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

 
int main() {
 ll N,D,X;
  cin>>N>>D>>X;
  ll ans=N;
  for(ll i=0;i<N;i++) {
ll A;
    cin>>A;
    ll count=0;
    ll k=1;
    while(A*k+1<=D) {
count++;
     
      k++;
    }
    ans+=count;
  
  }
  
  cout<<ans+X<<endl;
}
  
  

  
  


Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	s := r.nextString()

	ans := []byte(s)
	if ans[1] == 'B' {
		ans[1] = 'R'
	} else {
		ans[1] = 'B'
	}
	fmt.Fprintln(stdout, string(ans))
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define endl '\n'
const ll N=2e5+5,mod=1000000007,bit=60;
signed main()
{
    fast;
    ll pro=1,temp,t,i,j,l,r,n,m,mid,z,k,x,y,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,next,sum=0,flag=1,i1=-1,i2=-1,u,v;
    cin>>n;
    ld pb=(n+1)/2;
    pb/=(ld)n;
    cout<<fixed<<setprecision(15)<<pb<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var nab = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();

            var n = nab[0];
            var a = nab[1];
            var b = nab[2];

            var count = 0;

            for(int i = 1; i <= n; i++) {
                var s = i / 10000;
                var q = (i - (s * 10000)) / 1000;
                var w = (i - (s * 10000) - (q * 1000)) / 100;
                var e = (i - (s * 10000) - (q * 1000) - (w * 100)) / 10;
                var r = (i - (s * 10000) - (q * 1000) - (w * 100) - (e * 10));
                if(a <= s + q + w + e + r && s + q + w + e + r <= b) {
                    count += i;
                }
            }

            Console.WriteLine(count);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
try:
    N = int(input())
    min_ = 99999
    for a in range(N):
        b = N-a
        if b>0 and a>0:
            j = sum(map(int, str(a)))
            i = sum(map(int, str(b)))
            _ = i + j
            if _<min_:
                min_ = _
    print(min_)
except EOFError:
    pass

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

int main(){
    string M,D;
    cin >> M >> D;
    int ans = 0;

    if(D.size() == 1){
        cout << ans << endl;
        return 0;
    }
    int m = stoi(M);
    int d = stoi(D);
    for(int i = 12; i <= d; i++){
        for(int j = 1; j <= m; j++){
            int d1 = i % 10;
            int d2 = (i/10) % 10;
            if(d1 >= 2 && d2 >= 2 && d1 * d2 == j){
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

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

	int n, a;

	cin >> n; //支払金額
	cin >> a; //一円硬貨a枚所持

	if (n % 500 <= a) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	class DisjointUnionSets {
		int[] rank, parent;
		int n;

		public DisjointUnionSets(int n) {
			rank = new int[n];
			parent = new int[n];
			this.n = n;
			makeSet();
		}

		void makeSet() {
			for (int i = 0; i < n; i++) {

				parent[i] = i;
			}
		}

		int find(int x) {

			if (parent[x] != x) {

				parent[x] = find(parent[x]);

			}

			return parent[x];
		}

		void union(int x, int y) {

			int xRoot = find(x), yRoot = find(y);

			if (xRoot == yRoot) {
				return;
			}

			if (rank[xRoot] < rank[yRoot]) {

				parent[xRoot] = yRoot;
			} else if (rank[yRoot] < rank[xRoot]) {

				parent[yRoot] = xRoot;
			} else {

				parent[yRoot] = xRoot;
				rank[xRoot] = rank[xRoot] + 1;
			}
		}
		
		int count() {
			Set<Integer> parent = new HashSet<Integer>();
			
			for(int i=1; i<n; i++) {
				parent.add(find(i));
			}
			
			return parent.size() - 1;
		}
	}

	public void execute(int input) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		if (input == 1) {
			br = new BufferedReader(new FileReader("test.txt"));
		}


		StringTokenizer st = new StringTokenizer(br.readLine(), " ");

		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		
		DisjointUnionSets disjointUnionSets = new DisjointUnionSets(n + 1);
		for(int i=0; i<m; i++) {
			st = new StringTokenizer(br.readLine(), " ");
			
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			
			disjointUnionSets.union(a, b);		
		}
		
		System.out.println(disjointUnionSets.count());
	}

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

		Main a = new Main();

		a.execute(0);

	}
}

Measured memory_bytes: 53308
#include<stdio.h>
#include<string.h>


int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    //printf("%d,%d,%d\n",A,B,C);
    int five,seven;
    five = seven = 0;
    if(A==5) five++;
    else if(A==7)seven++;
    if(B==5) five++;
    else if(B==7)seven++;
    if(C==5) five++;
    else if(C==7)seven++;
    //printf("%d,%d\n",five,seven);
    if(five==2&&seven==1)
        printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 128
package main
  
import (
    "fmt"
)

func main() {
    var w, h, x, y float64
    fmt.Scan(&w, &h, &x, &y)
    var ct int
    if x*2 == w && y*2 == h {
        ct = 1
    }
    fmt.Printf("%f %d\n", w*h/2, ct)
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    O = input()
    E = input()
    answer = ""
    for i in range(len(O+E)):
        if i%2 == 0:
            answer += O[i//2]
        else:
            answer += E[(i-1)//2]
    print(answer)

    return

if __name__ == '__main__':
    main()


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

int ans[11][410];

void dfs(int dpt, int sum, int bit){
	++ans[dpt][sum];
	for(int i = 0; i < 10; ++i){
		if(bit >> i & 1){
			dfs(dpt + 1, sum + i * (dpt +1), bit ^ (1 << i));
		}
	}
}

int main(){
	dfs(0, 0, 0x3ff);
	int n, s;
	while(scanf("%d%d", &n, &s) != EOF){
		int x = 0;
		if(n <= 10 && s <= 400){ x = ans[n][s]; }
		printf("%d\n", x);
	}
}

Measured memory_bytes: 1044
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int y;
    cin >> y;

    bool yymm = false;
    bool mmyy = false;

    if(y / 100 <= 12 && y /100 >= 1) mmyy = true;
    if(y % 100 <= 12 && y %100 >= 1) yymm = true;

    if(mmyy && yymm) cout << "AMBIGUOUS" << endl;
    else if(mmyy) cout << "MMYY" << endl;
    else if(yymm) cout << "YYMM" << endl;
    else cout << "NA" << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
	int k,s,ans = 0;
	scanf("%d %d",&k,&s);
	FOR(x,0,k+1){
		FOR(y,0,k+1){
			int z = s-x-y;
			if(z >= 0 && z <= k) ans++;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int s,t=0;
  int A[1000000];
  scanf("%d",&s);
  A[0]=s;
  for(int i=1;i<999999;i++){
    if(A[i-1]%2==1){
      A[i]=3*A[i-1]+1;
    }else{
      A[i]=A[i-1]/2;
    }
    for(int j=0;j<i;j++){
      if(A[i]==A[j]){
        printf("%d",i+1);
        t++;
        break;
      }
    }
    if(t==1){
      break;
    }
  }
  return 0;
}


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

int main() {
 int a,b,s=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    int A,B,C,D;
    A=i/10000,D=i%10; 
    if(A!=D) continue;
    B=i%10000/1000,C=i%100/10;
    if(B!=C) continue;
    s++;
  }
  cout<<s<<endl;
}

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

using namespace std;

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

    int n = s.size();
    int k = n;
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] != s[i + 1])
        {
            int m = max(i + 1, n - (i + 1));
            k = min(k, m);
        }
    }
    cout << k << endl;
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    rep(i,m) cin >> l[i] >> r[i];
    int ma = l[0], mi = r[0];
    rep(i,m) {
        ma = max(l[i], ma);
        mi = min(r[i], mi);
    }
    int ans = mi-ma+1;
    if (ans<0) ans = 0;
    if (ans>n) ans = n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3980
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int N;
    while (cin >> N) {
        bool three = true;
        while (N--) {
            string x;
            cin >> x;
            if (x == "Y") {
                three = false;
            }
        }

        if (three == true)
            cout << "Three" << endl;
        else
            cout << "Four" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define llong long long
int n;
llong a[550][550];
llong pri[2020],tot;
bool isprime(int x)
{
    for(int i=1;i<=tot&&pri[i]*pri[i]<=x;++i)
        if(x%pri[i]==0)return 0;
    return 1;
}
llong calc(int x,int y){return pri[(x+y)/2]*pri[(x-y+n+1)/2+(n+n)/2];}
int main()
{
    scanf("%d",&n);
    for(int i=2;tot<=1200;++i)
        if(isprime(i))pri[++tot]=i;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=n;++j)
            if((i+j)&1)printf("%lld ",calc(i-1,j)*calc(i+1,j)+1);
            else printf("%lld ",calc(i,j));
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3200
kind = int(input())

table_1 = input().split(' ')
table_2 = input().split(' ')
table_3 = input().split(' ')
total = 0
for i in range(kind):
    total += int(table_2[i])
    
for j in range(kind-1):
    if int(table_1[j]) == int(table_1[j + 1]) - 1:
        total += int(table_3[int(table_1[j]) - 1])
print(total)

Measured memory_bytes: 9136
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;

typedef complex<double> P;
typedef const P &rP;

#define EPS 1e-7

double dot(rP a, rP b){
	return a.real() * b.real() + a.imag() * b.imag();
}

bool intersectlsc(rP p1, rP p2, rP pc, double r){
	P v12 = p2 - p1;
	P v1c = pc - p1;

	double a = norm(v12);
	double b = -dot(v12, v1c);
	double c = norm(v1c) - r * r;

	double D = b * b - a * c;

	if( D < -EPS ){
		return false;
	}
	else if( D < 0.0 ){
		D = 0.0;
	}

	double t1 = (-b + sqrt(D)) / a;
	double t2 = (-b - sqrt(D)) / a;

	if( (-EPS < t1 && t1 < 1.0 + EPS)
		|| (-EPS < t2 && t2 < 1.0 + EPS)
	){
		return true;
	}
	return false;
}

int n;
P w[100];
double r[100];

const char *solve(rP t, rP s){
	for(int i = 0; i < n; ++i){
		if( intersectlsc(t, s, w[i], r[i]) ){
			return "Safe";
		}
	}
	return "Danger";
}

int main(){
	int m;
	double x, y;
	double tx, ty, sx, sy;
	
	while( scanf("%d", &n), n != 0 ){
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf", &x, &y, &r[i]);
			w[i] = P(x, y);
		}
		
		scanf("%d", &m);
		for(int i = 0; i < m; ++i){
			scanf("%lf%lf%lf%lf", &tx, &ty, &sx, &sy);
			puts( solve( P(tx, ty), P(sx, sy) ) );
		}
	}
}

Measured memory_bytes: 1064
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
    ll int jhogeo = 1;
    rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
    return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}

int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  ll int dp[110][100100]={0};
  ll int N,W; cin>>N>>W;
  vector<ll int> w(N+1);
  vector<ll int> v(N+1);
  rep(i,1,N+1) cin>>w[i]>>v[i];
  w[0]=0;
  v[0]=0;
  rep(i,1,N+1){
    dp[i][w[i]]=max(dp[i-1][w[i]],v[i]);
     rep(j,0,W+1){

      if(j+w[i]<=W){
      if(dp[i-1][j]){
        dp[i][j+w[i]]=max(dp[i][j+w[i]],dp[i-1][j]+v[i]);
      }
      }
              dp[i][j]=max(dp[i-1][j],dp[i][j]);
      
    }
  }
ll int max=-1;
  rep(i,0,W+1){
  if(dp[N][i]>max) max=dp[N][i];
}
  cout<<max;
    
  /*
  rep(j,0,N+1){
  rep(i,0,W+1)cout<<dp[j][i]<<" ";
    cout<<endl;
  }
  */
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 86272
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>

int main() {

    int N, K, X, A, B, tmp1, tmp2, i = 0, ans = 0, cst = 1;

    std::cin >> N >> A >> B;

    if( N * A < B){
        std::cout << N*A << std::endl;
        return 0;
    }
    else{
        std::cout << B << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n,i,j,a[1001],ans=0;
	cin>>m>>n;
	vector<int>v;
	vector<int>::iterator it;
	for(i=0;i<m;i++){
		cin>>a[i];
		v.push_back(a[i]);
	}
	for(i=0;i<n;i++){
		sort(v.begin(),v.end());
		ans+=v[0];
		v.erase(v.begin());
	}
	cout<<ans;
		
	return 0;
}


Measured memory_bytes: 3632
fun main(args: Array<String>) {

    val (n, k) = readLine()!!.split(" ").map(String::toInt).toTypedArray()
    val hn = Array(n) { readLine()!!.toInt() }.sortedArray()

    var result = Integer.MAX_VALUE
    for (i in 0 .. hn.size - k) {
        result = Math.min(result, hn[i + k - 1] - hn[i])
    }
    println(result)


}

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


int main(){
	int checked[27]={};
	string input;
	cin >> input;
	for(int i=0;i<input.size();i++){
		checked[input[i] - 'a'] ++;
	}
	
	for(int i=0;i<26;i++){
		if(checked[i]%2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;

int n,x[100],mx,sm=0;

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
        if(i==0)mx=x[i];
        else mx=max(mx,x[i]);
        sm+=x[i];
    }
    printf("%d\n",sm-mx/2);
}



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

void BubbleSort(int N,int *A){
	int cnt=0;
	for(int i=0; i<N-1; i++){
		for(int j=N-1; j>i; j--){
			if(A[j-1]>A[j]){
				swap(A[j-1],A[j]);
				cnt++;
			}
		}
	}
	for(int i=0; i<N; i++)
		cout << A[i] << ((i<N-1)?" ":"");
	cout << endl;
	cout << cnt << endl;
}

int main(){
	int N; cin >> N;
	int array[N];
	for(int i=0;i<N;i++)
		cin >> array[i];
	BubbleSort(N,array);
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> v (N);
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    v.at(i) = x;
  }
  int total = 0;
  for (int i = 0; i < N; i++) {
    if (2*v.at(i) < K) {
      total += v.at(i);
    }
    else {
      total += max(K-v.at(i), v.at(i)-K);
    }
  }
  cout << total * 2 << endl;
}

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

int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	if((a+b*5+c*10+d*50+e*100+f*500)>=1000){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 1164
n, x, m = map(int, input().split())

lis = [x]
flag = [-1 for i in range(m)]
flag[x] = 0
left = -1
right = -1
for i in range(n-1):
    x = x**2 % m
    if flag[x] >= 0:
        left = flag[x]
        right = i
        break
    else:
        lis.append(x)
        flag[x] = i+1

ans = 0
if left == -1:
    ans = sum(lis)
else:
    ans += sum(lis[0:left])
    length = right - left + 1
    ans += sum(lis[left:]) * ((n-left)//length)
    ans += sum(lis[left:left+((n-left)%length)])
print(ans)

Measured memory_bytes: 13680
#include <iostream>
using namespace std;
int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    if(a%k==0 || b%k==0 || a/k!=b/k)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

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 mod = 1e9 + 7;
const int N = 100007;
const int K = 5000;
int b[N], a[N], c[N];
map < int, int > cnt, ind;
int sqr(int x){
    int l = 1;
    int r = 1e6;
    while(r - l > 1){
        int mid = (r + l) / 2;
        if (mid * mid > x) r = mid; else l = mid;
    }
    if (l * l == x) return l;
    return 1;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    set < int > s, spr;
    vector < int > pr;
    int cube = 0;
    for (int i = 2; i < N; i++){
        if (c[i]) continue;
        pr.pb(i);
        spr.insert(i);
        for (int j = i; j < N; j += i){
            c[j] = 1;
        }
    }
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        for (int j = 2; j * j * j <= a[i]; j++){
            while(a[i] % (j * j * j) == 0){
                a[i] /= (j * j * j);
            }
        }
        if (a[i] == 1) cube++;
        else{
            cnt[a[i]]++;
            if (s.find(a[i]) != s.end()) continue;
            b[i] = 1;
            int x = a[i];
            for (auto j: pr){
                if (j > 10000) break;
                if (x % j != 0) continue;
                if (x % (j * j) == 0){
                    b[i] *= j;
                    x /= (j * j);
                }
                else{
                    b[i] *= j * j;
                    x /= j;
                }
                if (b[i] > 1e10) break;
            }
            if (spr.find(x) != spr.end()){
                if (b[i] * x < 1e10){
                    b[i] = b[i] * x * x;
                } else b[i] = 1e12;
                x = 1;
            }
            if (spr.find(sqr(x)) != spr.end()){
                b[i] = b[i] * sqr(x);
                x = 1;
            }
            if (x != 1) b[i] = 1e12;
            ind[a[i]] = i;
            s.insert(a[i]);
        }
    }
    int ans;
    if (cube) ans = 1; else ans = 0;
    for (auto i: s){
        if (s.find(b[ind[i]]) != s.end() && b[ind[i]] < i) continue;
        ans += max(cnt[b[ind[i]]], cnt[i]);
    }
    cout << ans;
}


Measured memory_bytes: 22528
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
  fastio;
  string s;
  cin >> s;
  bool flag = true;
  for(int i = 0; i < len(s); i++){
    if(i%2 == 0 and (s[i] != 'R' and s[i] != 'U' and s[i] != 'D')){
      flag = false;
    }
    else if(i%2 == 1 and (s[i] != 'L' and s[i] != 'U' and s[i] != 'D')){
      flag = false;
    }
  }
  if(flag) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  ll mx = 0;
  ll index = 0;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
    if(abs(a)>mx){
      mx = abs(a);
      index = i;
    }
  }
  if(mx==0){
    cout << 0 << endl;
    return 0;
  }
  vector<pair<ll,ll> > ans;
  rep(i,0,n){
    if(v[i]*v[index]<0){
      ans.pb(mp(index+1,i+1));
      v[i]+=v[index];
    }
  }
  if(v[index]>0){
    rep(i,0,v.sz-1){
      if(v[i]>v[i+1]){
        v[i+1]+=v[i];
        ans.pb(mp(i+1,i+2));
      }
    }
  }
  else{
    per(i,0,v.sz-1){
      if(v[i]>v[i+1]){
        v[i]+=v[i+1];
        ans.pb(mp(i+2,i+1));
      }
    }    
  }
  cout << ans.sz << endl;
  rep(i,0,ans.sz){
    cout << ans[i].fi << " " << ans[i].se << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(lambda x: int(x)*2, input().split()))
Y = [0]*N
S = sum(A)//2
Y[0] = S - sum(A[i] for i in range(1, N, 2))
for i in range(1, N):
    Y[i] = A[i-1] - Y[i-1]
print(*Y)

Measured memory_bytes: 64996
# coding: utf-8
# Your code here!
n=int(input())
b=input().split()
a=[0]*n
for i in range(n):
    a[i]=int(b[i])-i
a.sort()
c=a[n//2]
ans=0
for i in range(n):
  ans+=abs(a[i]-c)
print(ans)



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

int main() {
    using namespace std;
    unsigned long N, P;
    cin >> N >> P;
    if(P == 2){
        string S;
        cin >> S;
        unsigned long ans{0};
        for(unsigned long i{0}; i < N; ++i)ans += (~S[i] & 1) * (i + 1);
        cout << ans << endl;
        return 0;
    }
    if(P == 5){
        string S;
        cin >> S;
        unsigned long ans{0};
        for(unsigned long i{0}; i < N; ++i)ans += !((S[i] + 2) % 5) * (i + 1);
        cout << ans << endl;
        return 0;
    }
    vector<unsigned long> m(P);
    {
        string S;
        cin >> S;
        reverse(S.begin(), S.end());
        unsigned long rlhs{0};
        m[0] = 1;
        for(unsigned long i{0}, c{1}; i < N; ++i)++m[(rlhs += (S[i] - 48) * ((c *= 10) %= P)) %= P];
    }
    unsigned long ans{0};
    for(const auto& i : m)ans += i * (i - 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int d;
  cin>>d;

  vector<ll> p(26);
  rep(i,26) {
    cin>>p[i];
  }


  vector<vector<ll>> q(d,vector<ll>(26));
  rep(i,d) {
    rep(j,26) {
      cin>>q[i][j];
    }
  }

  ll pre=0;
  vector<int> r(26,0);
  rep(i,d-5){
    ll ans=-INF;
    ll memo;
    rep(j,26){
      ll sum=pre;
      auto last=r;
      sum+=q[i][j];
      last[j]=i+1;
      rep(k,26){
        sum-=5.2*p[k]*(i+1-last[k]);
      }
      if(sum>ans) {
        memo=j;
        chmax(ans,sum);
      }
    }
    cout << memo+1 << endl;
    pre=ans;
    r[memo]=i+1;
  }

  ll answer=-INF;
  ll A,B,C,D,E;
  vector<int> zen(5);
  rep(i,26){
    rep(j,26){
      rep(k,26){
        rep(l,26){
          rep(m,26){
            zen[0]=i;
            zen[1]=j;
            zen[2]=k;
            zen[3]=l;
            zen[4]=m;

            ll sum=0;
            auto last=r;
            rep(n,5){
              sum+=q[d-5+n][zen[n]];
              last[zen[n]]=d-5+n+1;
              rep(o,26){
                sum-=p[o]*(d-5+n+1-last[o]);
              }
            }

            if(sum>answer) {
              A=zen[0];
              B=zen[1];
              C=zen[2];
              D=zen[3];
              E=zen[4];
            }
            chmax(answer,sum);

          }
        }
      }
    }
  }

  cout << A+1 << endl;
  cout << B+1 << endl;
  cout << C+1 << endl;
  cout << D+1 << endl;
  cout << E+1 << endl;
  
}

Measured memory_bytes: 3760
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 500010
using namespace std;
typedef long long ll;
ll pre[MAXN],las[MAXN],fsp[MAXN];
const ll MOD=1000000009ll;
int prel[MAXN],lasl[MAXN];
char s[MAXN];
int n,minlen;
void check(int x,int flag){
	if(flag==0){
		prel[x]=x;
		for(int i=1;i*i<=x;i++)
			if(x%i==0){
				if(((pre[x]-pre[i]*fsp[x-i])%MOD+MOD)%MOD==pre[x-i]%MOD){
					prel[x]=i;
					break;
				}
				if(((pre[x]-pre[x/i]*fsp[x-x/i])%MOD+MOD)%MOD==pre[x-x/i]%MOD){
					prel[x]=x/i;	
				}
			}
	}
	else{
		lasl[x]=x;
		for(int i=1;i*i<=x;i++)
			if(x%i==0){
				if(((las[x]-las[i]*fsp[x-i])%MOD+MOD)%MOD==las[x-i]%MOD){
					lasl[x]=i;	
					break;
				}
				if(((las[x]-las[x/i]*fsp[x-x/i])%MOD+MOD)%MOD==las[x-x/i]%MOD){
					lasl[x]=x/i;	
				}
			}
	}
}
int main(){
	SF("%s",s+1);
	n=strlen(s+1);
	fsp[0]=1;
	for(int i=1;i<=n;i++)
		fsp[i]=fsp[i-1]*12309097ll%MOD;
	for(int i=1;i<=n;i++)
		pre[i]=(pre[i-1]*12309097ll%MOD+(ll)(s[i]-'a'+1))%MOD;
	reverse(s+1,s+n+1);
	for(int i=1;i<=n;i++)
		las[i]=(las[i-1]*12309097ll%MOD+(ll)(s[i]-'a'+1))%MOD;
	for(int i=1;i<=n;i++){
		check(i,0);
		check(i,1);
	}
	if(prel[n]==1){
		PF("%d\n1",n);
		return 0;	
	}
	if(prel[n]==n){
		PF("1\n1");
		return 0;
	}
	int ans=0;
	
	for(int i=1;i<n;i++){
		if(prel[i]==i&&lasl[n-i]==n-i)
			ans++;
	}
	PF("2\n%d",ans);
}

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

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

	while (n--)
	{
		int memo1[1005] = {};
		int memo2[1005] = {};
		string a, b;
		cin >> a >> b;

		for (int i = 1; i <= a.size(); i++)
		{
			for (int j = 1; j <= b.size(); j++)
			{
				if (a[i - 1] == b[j - 1])
					memo2[j] = max({ memo2[j - 1], memo1[j], memo1[j - 1] + 1 });
				else
					memo2[j] = max(memo2[j - 1], memo1[j]);
			}
			swap(memo1, memo2);
			memo2[0] = 0;
		}

		cout << memo1[b.size()] << endl;
	}

	return 0;
}

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

using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<pair<char, char>> v(q);
    for(int i = 0; i < q;i++){
        cin >> v[i].first >> v[i].second;
    }
    int l, r;
    l = -1, r = n;
    while(l+1!=r){
        int m = (l + r) / 2;
        int pos = m;
        for(auto x : v) {
            if(x.first==s[pos]){
                if(x.second == 'L'){
                    pos--;
                }else {
                    pos++;
                }
                if(pos == -1){
                    l = m;
                    break;
                }
            }
        }
        if(l!=m){
            r = m;
        }
    }
    int left = l; // l文字目の位置までは絶対落ちる
    l = -1, r = n;
    while(l+1!=r){
        int m = (l + r) / 2;
        int pos = m;
        for(auto x:v){
            if(x.first==s[pos]){
                if(x.second=='L'){
                    pos--;
                }else{
                    pos++;
                }
            }
            if(pos == n){
                r = m;
                break;
            }
        }
        if(r!=m){
            l = m;
        }
    }
    int right = r; // r文字目の位置は右に絶対落ちる
    //cout << right << endl;
    cout << max(0, n - (left + 1) - (n - right)) << endl;
    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>

using namespace std;

int main(){
  int x1,x2,y1,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3,x4,y3,y4;
  if(x1 <= x2){
    if(y1  <= y2){
      x3 = x2 - (y2 - y1);
      x4 = x1 - (y2 - y1);
      y3 = y2 + (x2 - x1);
      y4 = y1 + (x2 - x1);
    }
    else{
      x3 = x2 + (y1 - y2);
      x4 = x1 + (y1 - y2);
      y3 = y2 + (x2 - x1);
      y4 = y1 + (x2 - x1);
    }
  }
  else{
    if(y1 <= y2){
      x3 = x2 - (y2 - y1);
      x4 = x1 - (y2 - y1);
      y3 = y2 - (x1 - x2);
      y4 = y1 - (x1 - x2);
    }
    else{
      x3 = x2 + (y1 - y2);
      x4 = x1 + (y1 - y2);
      y3 = y2 - (x1 - x2);
      y4 = y1 - (x1 - x2);
    }
  }
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


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

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define REV(i,j,k) for(int i=j;i>=k;i--)
#define FORR(i,j,k,l) for(int i=j;i<=k;i+=l)
#define inf         freopen("in.txt", "r", stdin)
#define outf        freopen("out.txt", "w", stdout)
#define pf          printf
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c)    scanf("%d %d %d", &a, &b, &c)
#define clean(mat,n)   FOR(i,0,n) mat[i].clear()
#define minn          (long long)-1000000000000000000
#define maxx          (long long) 1000000000000000000
#define mod          1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define LL           long long
#define NL '\n'
#define cnd tree[idx]
#define lnd (idx<<1)
#define rnd ((idx<<1)+1)
#define PB push_back
#define F first
#define S second
#define MAX 200010
#define MP make_pair
#define valid(nx,ny)  ((nx >= 0) && (nx < row) && (ny >= 0) && (ny < col))
typedef pair<int,int> PR;

PR ar[MAX];
int n, prin;

int main()
{
    ios::sync_with_stdio(false);
   /// inf;
    //outf;

    cin >> n;
    FOR(i,0,n-1)
    {
        cin >> ar[i].F;
        ar[i].S = i;
    }
    sort(ar, ar + n);

    int c = 1;
    prin = 1;

    FOR(i,1,n-1)
    {
        if(ar[i].S > ar[i - 1].S) c++;
        else c = 1;
        prin = max(prin, c);
    }
    cout << n - prin << endl;

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

const ll MOD = 1e9 + 7;

ll n, res = 0, cnt = 0;
vector<ll> fac;

ll exp(ll a, ll n){
    if(n == 0) return 1;
    ll tmp = exp(a, n/2);
    tmp *= tmp;
    tmp %= MOD;
    if(n%2) tmp *= a;
    tmp %= MOD;
    return tmp;
}

ll inv(ll x){
    return exp(x, MOD - 2);
}

ll cmb(ll c, ll k){
    if(k > c) return 0;
    ll t = inv(fac[c - k]) * inv(fac[k]);
    t %= MOD;
    t *= fac[c];
    t %= MOD;
    return t;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    fac.assign(2e4 + 5, 1);
    for(int i = 1; i < 2e4; ++i){
        fac[i] = fac[i - 1] * i;
        fac[i] %= MOD;
    }
    while(n > 0){
        n -= 3; ++cnt;
        if(n >= 0){
            res += cmb(n + cnt - 1, cnt - 1);
            res %= MOD;
        }
    }
    cout << res;
    return 0;
}

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

int main(int argc, char const* argv[])
{
    char s[19];
    scanf("%s", s);
    for (int i = 0; i < 19; i++) {
        if (s[i] == ',') {
            printf(" ");
        }else {
            printf("%c", s[i]);
        }
    }

    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less{
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first < y.first;
    }
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};

int GCD(int a, int b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}

ll pow_mod(ll a, ll b){
    ll sum =1;
    while(b>0){
        if(b&1){
            sum *= a%MOD;
        }
        a = a* a%MOD;
        b >>= 1;
    }
    return sum;
}



int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s; cin >> s;
    REP(i, s.size()){
        if(s[i]=='1') cout << '9';
        else if(s[i]=='9') cout << '1';
    }
    cout << endl;
    
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
struct Graph
{
    Graph(const std::size_t v) : V{v}, edge(v), rev_edge(v) {}
    void addEdge(const std::size_t from, const std::size_t to) { edge[from].push_back(to), rev_edge[to].push_back(from); }
    const std::size_t V;
    std::vector<std::vector<std::size_t>> edge, rev_edge;
};
int main()
{
    int n;
    std::cin >> n;
    constexpr int N = 26;
    Graph g(N);
    std::vector<int> in(N, 0), out(N, 0);
    for (int i = 0; i < n; i++) {
        std::string s;
        std::cin >> s;
        const int S = s.front() - 'a', T = s.back() - 'a';
        g.addEdge(S, T);
        in[T]++, out[S]++;
    }
    std::vector<bool> ok(N, false);
    std::vector<bool> checked(N, false);
    std::queue<int> q;
    for (int i = 0; i < N; i++) {
        if (in[i] > 0 and out[i] == 0) { checked[i] = ok[i] = true, q.push(i); }
    }
    while (not q.empty()) {
        const int i = q.front();
        checked[i] = true;
        q.pop();
        for (const int to : g.rev_edge[i]) {
            if (out[to] == 1) { q.push(to); }
        }
    }

    for (int i = 0; i < N; i++) {
        if (checked[i]) {
            if (ok[i]) { std::cout << (char)(i + 'a') << std::endl; }
        } else {
            if (in[i] > 0 and out[i] <= in[i]) { std::cout << (char)(i + 'a') << std::endl; }
        }
    }
    return 0;
}



Measured memory_bytes: 3340
fn main(){
    let s: String = read();
    let t: String = read();
    
    let mut ans = "No";
    
    for i in 0..s.len() {
        if rotate(&s, i) == t {
            ans = "Yes";
            break;
        }
    }
    
    println!("{}", ans);
}

fn rotate(s: &String, n: usize) -> String {
    let b = s.clone().into_bytes();
    let t = b.split_at(n);
    let mut f = t.1.to_vec();
    let mut e = t.0.to_vec();
    f.append(&mut e);
    String::from_utf8(f).ok().unwrap()
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep2(i,1,n+1) {
        if(i%2 == 0) continue;
        int cnt = 0;
        rep2(j,1,i+1) if(i%j == 0) cnt++;
        if(cnt == 8) ans++;
    }
    cout << ans << endl;
}

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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  void solve(std::istream& in, std::ostream& out)
  {
    string str;
    in >> str;
    for(int i = str.size() - 2; i >= 0; i -= 2) {
      if(str.substr(0, i / 2) == str.substr(i / 2, i / 2)) {
        out << i << "\n";
        return;
      }
    }
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




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

//(10進法での)桁数
int digsum10(ll n) {
  int res = 0;
  while(n>0) {
    res++;
    n /= 10;
  }
  return res;
}

int F(ll A, ll B) {
  return max(digsum10(A), digsum10(B));
}

int main() {
  ll N;
  cin >> N;
  int ans = F(1, N);
  for (ll i=2; i<=sqrt(N); i++) {
    if (N%i==0) {
      ans = min(ans, F(i, N/i));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)

void ayush(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

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

ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
ll mulmod(ll a, ll b, ll mod) 
{ 
    ll res = 0; 
    a = a % mod; 
    while (b > 0) 
    { 
        if (b % 2 == 1) res = (res + a) % mod; 
        a = (a * 2) % mod; 
        b /= 2; 
    }  
    return res % mod; 
} 

int main(){
    ayush();
    fastio;

    ll t; t=1;
    while(t--){
        ll s,w; cin>>s>>w;
        if(w>=s) cout<<"unsafe";
        else cout<<"safe";
    }
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;

int	card[40320];
vector<int> tmp(10);
queue<vector<int> > qu;

int perm2num(vector<int> perm){
	int num=0;
	for(int i=0;i<8;i++){
		num *= 8-i;
		num += perm[i];
		for(int j=i+1;j<8;j++){
			if(perm[j]>perm[i])perm[j]--;
		}
	}
	return num;
}

void qu_push(int a){
		swap(tmp[tmp[8]],tmp[tmp[8]+a]);			
		tmp[9]++;
		tmp[8]+=a;
		if (card[perm2num(tmp)]==-1){
			qu.push(tmp);
			card[perm2num(tmp)] = tmp[9];
		}
		tmp[9]--;
		tmp[8]-=a;
		swap(tmp[tmp[8]],tmp[tmp[8]+a]);
}

void solve(){
	vector<int> bgn(10);
	for(int i=0;i<8;i++) bgn[i] = i;
	qu.push(bgn);
	while(!qu.empty()){
		tmp = qu.front();
		qu.pop();
		if(tmp[8]<4)qu_push(4);
		else qu_push(-4);
		if(tmp[8]%4>0)qu_push(-1);
		if(tmp[8]%4<3)qu_push(1);
	}
}

int main(){
	card[0] = 0;
	for(int i=1;i<40320;i++) card[i] = -1;
	solve();
	vector<int> perm(8);
	while(true){
		int i=0;
		for(;i<8;i++){
			if(!(scanf("%d",&perm[i])+1))break;
		}
		if(i<8)break;
		cout<<card[perm2num(perm)]<<endl;
	}
	
  return 0;
}

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

int main()
{
  string s;
  for(;cin>>s,s!="#";)
    {
      double sum=0;
      int cnt=1;
      //   for(int i=0;i<s.size();i++)
      for(int i=s.size()-1;i>=0;i--)
	{
	  if(cnt==1)
	    {
	      if(s[i]=='n')
		{
		  sum=0;
		  cnt++;
		}
	      else if(s[i]=='w')
		{
		  sum=90;
		  cnt++;
		}

	    }
	  else
	    {
	      if(s[i]=='n')
		{
		  sum-=90.0/cnt;
		  cnt*=2;
		}
	      else if(s[i]=='w')
		{
		  sum+=90.0/cnt;
		  cnt*=2;
		}
	    }
	}
      // cerr<<"origi:"<<sum<<endl;
      if(((int)sum)-sum==0)
	cout<<sum<<endl;
      else
	{
	  int x=2;
	  sum*=2;
	  while(((int)sum)-sum!=0)
	    {
	      x*=2;
	      sum*=2;
	    }
	  int isum=sum;
	  for(int i=2;i<=x;i++)
	    {
	      if(isum%i==0 && x%i==0)
		{
		  isum/=i;
		  x/=i;
		  i=1;
		}
	    }
	  cout<<isum<<"/"<<x<<endl;
	}
    }
}

Measured memory_bytes: 1264