akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut dict = HashMap::new();
    for i in 0..n {
        *dict.entry(a[i]).or_insert(0) += 1;
    }

    let mut v = vec![0; 2];
    for (k, v_) in dict {
        if v_ % 2 == 0 {
            v[1] += 1;
        } else {
            v[0] += 1;
        }
    }
    println!("{}", v[0] + if v[1] % 2 == 0 { v[1] } else { v[1] - 1 });
}


Measured memory_bytes: 12540
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    char s[20];
    while(cin>>a>>b)
    {
        cin>>s;
        int flag=1;
        for(int i=0;i<a;i++)
         if(s[i]<'0'||s[i]>'9')
                flag=0;
        if(s[a]!='-')
            flag=0;
        for(int i=a+1;i<=a+b;i++)
            if(s[i]<'0'||s[i]>'9')
            flag=0;
        if(flag)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(long long i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)
using Graph = vector<vector<int>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a*2<=b and b<=4*a and b%2==0){
    cout<<"Yes";
  }
  else cout<<"No";
}

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

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

    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
using namespace std;

int top, s1[1000];
void push(int x)
{
    s1[++top] = x;
}
int pop()
{
    top--;
    return s1[top+1];
}
int main()
{
    int b, c;
    top = 0;
    char s[200];
    while(scanf("%s",s))
    {
        if(s[0] == '+')
        {
            c = pop();
            b = pop();
            push(c+b);
        }
        else if(s[0] == '-')
        {
            b = pop();
            c = pop();
            push(c-b);
        }
        else if(s[0] == '*')
        {
            c = pop();
            b = pop();
            push(c*b);
        }
        else
        {
            push(atoi(s));
        }
        int a = getchar();
        if(a == 0xa)   break;
    }
    printf("%d\n",pop());
    return 0;
}

Measured memory_bytes: 2728
long m=1e9+7,D[41][1<<17]={1};
X,i,j,k,T,M=1<<17;
main(s,n){
	scanf("%d%d%d%d",&n,&j,&k,&T);
	for(X=((1<<j|1)<<k|1)<<T-1;i++<n;s=s*10L%m)
		for(j=k=0;k<M?:(k=0,j++<9);k++)
			if(T=k+k+1<<j,~T&X)
				D[i][T&=M-1]+=D[i-1][k],D[i][T]%=m;
	for(;M--;)s=(s-D[n][M]+m)%m;
	printf("%d",s);
}

Measured memory_bytes: 41088
def main():
    X = int(input())
    A = [False]*(110000)
    A[100] = True
    A[101] = True
    A[102] = True
    A[103] = True
    A[104] = True
    A[105] = True
    for i in range(100,X+1):
        if A[i]:
            A[i+100] = True
            A[i+101] = True
            A[i+102] = True
            A[i+103] = True
            A[i+104] = True
            A[i+105] = True
    if A[X]:
        print(1)
    else:
        print(0)
    return 

main()

Measured memory_bytes: 3828
/**
 *
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author b
 *
 */
public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner();
		PrintWriter writer = new PrintWriter(System.out);
		solve(scanner, writer);
		writer.close();
	}

	private static void solve(Scanner scanner, PrintWriter writer) {

		String num = scanner.next();
		int sum = 0;

		for (char c : num.toCharArray()) {
			sum += c - '0';
		}

		if (sum % 9 == 0) {
			writer.println("Yes");
		} else {
			writer.println("No");
		}

	}

	// Props to SecondThread
	static class Scanner {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tokenizer = new StringTokenizer("");

		String next() {
			while (!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return tokenizer.nextToken();
		}

		long[] nextLongArr(int num) {
			long[] vals = new long[num];
			for (int i = 0; i < num; i++)
				vals[i] = nextLong();
			return vals;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArr(int numberOfElements) {
			int[] values = new int[numberOfElements];
			for (int i = 0; i < numberOfElements; i++)
				values[i] = nextInt();
			return values;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 37252
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
typedef pair<int, int> P;
long long ans=0;
void dfs(long long n,long long x, long long s3, long long s5, long long s7){
    if(n<x){
        return;
    }
    else{
        if (s3&&s5&&s7) ans+=1;
        dfs(n,x*10+3,1,s5,s7);
        dfs(n,x*10+5,s3,1,s7);
        dfs(n,x*10+7,s3,s5,1);
    }
}
int main(){
   long long n;
   cin>>n;
   dfs(n,0,0,0,0);
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int last[40];
int s[400][400];
int c[26];
int d;
int calc(vector<int> &t){
    int ret = 0;
    
        rep(i,d){
            //use t[i];
            ret += s[i][t[i]-1];
            last[t[i]-1] = i+1;
            rep(j,26){
                ret -= c[j]*(i+1-last[j]);
            }
            
    
    
    
                    
        }
        return ret;

}
signed main(){
    cin >> d;
    rep(i,26)cin >> c[i];
    vector<int> ans(d);
    vector<int> t(d);
    rep(i,d)rep(j,26)cin >> s[i][j];
    int cnt = 0;
    int res = 0;
    int mx[400];
    rep(i,d){
        P v = P(0,0);
        rep(j,26){
            v = max(v,P(s[i][j],j));
        }
        mx[i] = v.second + 1;
    }
    while(cnt < 10000){
        rep(i,d){
            if(i >= cnt%d && i <= cnt%d + 30)t[i] = mx[i];
            else t[i] = (cnt+i)%26+1;
        }
        
        if(res < calc(t)){
            res = max(res,calc(t));
            rep(i,d)ans[i] = t[i];
        }
        cnt++;
    }
    rep(i,d)cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4752
import collections
n=int(input())
A=[]
AA=[]
B=[]
C=[]
X=[]
mod=277078100995604201
for i in range(n):
  a,b=map(int,input().split())
  if a<0:
    a=a*-1
    b=b*-1
  if a*b>0:
    A.append(b*pow(a,mod-2,mod)%mod)
  elif a*b<0:
    AA.append(a*pow((-b),mod-2,mod)%mod)
  else:
    if a==0 and b==0:
      X.append(i)
    elif a==0:
      B.append(i)
    else:
      C.append(i)
mod = 10**9+7
D=collections.Counter(A)
DD=collections.Counter(AA)
E=set(list(D)+list(DD))
a=1
for i in E:
  a=(a*(2**D[i]+2**DD[i]-1))%mod
a=(a*(2**len(B)+2**len(C)-1)-1)%mod
print((a+len(X))%mod)

Measured memory_bytes: 167360
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int n, q;
    cin >> n >> q;
    vi a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i, q)
    {
        lint x;
        cin >> x;
        lint cc = 0;
        int right = 0;
        lint sum = 0;
        rep(left, n)
        {
            while (right < n && (sum + a[right]) <= x){
                sum += a[right];
                right++;
            }
            cc += (right - left);
            if(left==right){
                right++;
            }else{
                sum -= a[left];
            }
        }
        cout << cc << endl;
    }
    return 0;
}


Measured memory_bytes: 3192
import queue

N, K = map(int, input().split())
P = list(map(lambda v: v-1, map(int, input().split())))
C = list(map(int, input().split()))

visited = [False] * N
q = queue.Queue()
lists = list()

for i in range(N):
    q.put(dict(index=i, l=None))
    while not q.empty():
        d = q.get()
        if visited[d['index']]:
            continue
        visited[d['index']] = True
        l = d['l']
        if l is None:
            l = list()
            lists.append(l)
        l.append(C[d['index']])
        q.put(dict(index=P[d['index']], l=l))

maxv = -float('inf')

for l in lists:
    summ = sum(l)
    if summ > 0:
        score = summ * (K//len(l))
        rest = K % len(l)
        if rest == 0:
            score -= summ
            rest = len(l)
        for i in range(len(l)):
            v = 0
            for j in range(rest):
                v += l[i+j if i+j < len(l) else i+j-len(l)]
                maxv = max(maxv, score+v)
    else:
        for i in range(len(l)):
            v = 0
            for j in range(len(l)):
                v += l[i+j if i+j < len(l) else i+j-len(l)]
                maxv = max(maxv, v)
print(maxv)


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

void Main()
{
    int n, m;
    cin >> n >> m;
    vector<int> wa(n), ac(n);
    for (int i = 0; i < m; i++)
    {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(ac[p] == 0) {
            if (s == "WA") wa[p]++;
            if (s == "AC") ac[p]++;
        }
    }
    int tac = 0, twa = 0;
    for (int i = 0; i < n; i++)
    {
        if(ac[i] > 0){
            tac++;
            twa += wa[i];
        }
    }
    
    cout << tac << " " << twa << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3992
using System;
 
class Program
{
    static void Main(string[] args)
    {
        int[] aryCount = new int[26];
        string alpha = "abcdefghijklmnopqrstuvwxyz";
 
        while (true)
        {
            string inputData = Console.ReadLine();
 
            if (inputData == null || inputData.Length == 0)
            {
                break;
            }
 
            for (int i = 0; i < inputData.Length; i++ )
            {
                if (char.IsLower(inputData[i]))
                {
                    int num = inputData[i] - 'a';
                    aryCount[num]++;
                }
                else if (char.IsUpper(inputData[i]))
                {
                    int num = inputData[i] - 'A';
                    aryCount[num]++;
                }
            }
        }
 
        for (int i = 0; i < aryCount.GetLength(0); i++)
        {
            Console.WriteLine(alpha[i] + " : " + aryCount[i]);
        }
 
    }
}


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

const int mxN = 3010;
int N, a[mxN];
ll dp[mxN][mxN][2];

ll rec(int l, int r, int t) {
	if (l > r) {
		return 0;
	}
	if (dp[l][r][t] != -1) {
		return dp[l][r][t];
	}
	if (t == 0) {
		return dp[l][r][t] = max(a[l] + rec(l + 1, r, 1), a[r] + rec(l, r - 1, 1));
	} else {
		return dp[l][r][t] = min(-a[l] + rec(l + 1, r, 0), -a[r] + rec(l, r - 1, 0));
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	ll ans = rec(0, N -1, 0);
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 145492
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	int I = 4, J = 3, K = 10;
	int N;
	cin >> N;
	int b, f, r, v;
	vector<vector<vector<int>>> B(I, vector<vector<int>>(J, vector<int>(K)));
	rep(t, N) {
		cin >> b >> f >> r >> v;
		B[b-1][f-1][r-1] += v;
	}
	rep(i, I) {
		rep(j, J) {
			rep(k, K) {
				cout <<' '<< B[i][j][k];
			}
			cout << endl;
		}
		if(i!=I-1)cout << "####################" << endl;
	}
}


Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005


/*nまでの素数を列挙して配列に保持*/
vector<ll> Eratosthenes(ll n,vector<ll>& arr){
    
    for(ll i = 0; i < n;i++){
        arr[i] = 1;
    }
    arr[0] = arr[1] = 0;
    for(ll i = 2; i < sqrt(n); i++){
        if(arr[i]){
            for(ll j = 0; i * (j + 2) < n; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    return arr;
}

int main(){

    ll tmp = 500000;
    ll n;
    vector<ll> a(tmp);
    a = Eratosthenes(tmp,a);

    REP(i,tmp){
        a[i+1] += a[i];
    }

    while(cin >> n,n){
        cout << a[2*n] - a[n] << endl;
    }

    return 0;
}


Measured memory_bytes: 10600
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] cnt = new int[4];
        
        for(int i=0; i<N; i++){
            String str = sc.next();
            if(str.equals("AC")){
                cnt[0]++;
            }else if(str.equals("WA")){
                cnt[1]++;
            }else if(str.equals("TLE")){
                cnt[2]++;
            }else if(str.equals("RE")){
                cnt[3]++;
            }
        }
        System.out.println("AC x "+cnt[0]);
        System.out.println("WA x "+cnt[1]);
        System.out.println("TLE x "+cnt[2]);
        System.out.println("RE x "+cnt[3]);
    }
}

Measured memory_bytes: 58300
#include <iostream>

using namespace std;

bool compare(int a, int b){
    if(a >= b){
        return true;
    } else {
        return false;
    }
}

int main(){
    int ans = 0;
    int maxAns = 0;
    int len = 0;
    cin >> len;

    int *board = new int[len];

    for (int i = 0; i < len; i++){
        cin >> board[i];
    }

    int index = len - 1;

    //if(compare(board[index-ans-1], board[index-ans]) == true){printf("aaaaaaa");}
    
    
    while(index > 0){
        //printf("index:%d\n", index);
        while(compare(board[index-ans-1], board[index-ans]) == true){

            ans += 1;
            //printf("ans:%d\n", ans);
            
            
        }
        if (ans > maxAns){
            maxAns = ans;
        }
        if (ans == 0){ index -= 1;}

        index = index - ans;
        
        ans = 0;
    }
    

    cout << maxAns << endl;

}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
#define N 1010
#define X 5010
ll n,h[N],w[N];
vector<ll> g[N];
bool dp[X];
bool dfs(ll x,ll from){
    vector<ll> c; ll base=0,sum=0;
    for(auto y:g[x])if(y!=from){
        if(dfs(y,x)==0)return 0;
        base+=h[y],sum+=(w[y]-h[y]);
        c.push_back(w[y]-h[y]);
    }
    if(base>h[x])return 0;
    for(int i=0;i<X;i++)dp[i]=0;
    dp[0]=1;
    for(auto cc:c){
        for(int i=X-5-cc;i>=0;i--){
            dp[i+cc]|=dp[i];
        }
    }
    ll ma=0;
    for(int i=0;i<=h[x]-base;i++){
        if(dp[i])ma=i;
    }
    w[x]=sum-ma+base;
    if(w[x]<h[x])swap(w[x],h[x]);
    return 1;
}
int main(){
  cin>>n;
  for(int i=2;i<=n;i++){
      ll a; cin>>a;
      g[a].push_back(i);
      g[i].push_back(a);
  }
  for(int i=1;i<=n;i++){
      cin>>h[i];
  }
  if(dfs(1,0)==0)cout<<"IM";
  cout<<"POSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 384
s = input()
l = len(s)
val = []
for i in range(2 ** (l-1)):
	div = [0]
	for j in range((l-1)):
		if (i >> j) & 1:
			div.append(j+1)
	v = 0
	for d in range(len(div)-1):
		v += int(s[div[d]:div[d+1]])
	v += int(s[div[-1]:])

	val.append(v)

print(sum(val))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
// constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

using Umap = unordered_map<int, ll>;

int main(void){
    Cin(int, n, a);
    Vec2(Umap, n+1, n+1, dp);
    dp[0][0][0] = 1;
    For(i, n){
        Cin(int, x);
        For(j, i+1) for(auto e : dp[i][j]){
            dp[i+1][j][e.first] += e.second;
            if(e.first + x <= 50*50) dp[i+1][j+1][e.first + x] += e.second;
        }
    }
    ll ans = 0;
    for(int j = 1; j <= n; j ++) ans += dp[n][j][j*a];
    Cout(ans);
}


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

ll f(ll x){
  ll res=0;
  while(x){
    res+=x%10;
    x/=10;
  }
  return res;
}

main(){

  ll a,n,m;
  cin>>a>>n>>m;

  ll ans=0;
  for(ll x=1;pow(x,n)<=m;++x){
    ll y=f(pow(x,n));
    ll res=pow(y+a,n);
    if(pow(x,n)==res)ans++;
  }
  cout<<ans<<endl;

}


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

N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
Z=[]

def z(n):
    return V[n]-C[n]

for i in range(N):
    if z(i)>0:
        Z.append(z(i))

ans=sum(Z)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  // 前処理
  //COMinit();

  string A;
  cin>>A;

  if(A[0]==A[1] && A[2]==A[1]){
    cout<<"Yes"<<endl;
    return 0;
  }

  if(A[3]==A[1] && A[2]==A[1]){
    cout<<"Yes"<<endl;
    return 0;
  }

  cout<<"No"<<endl;

  return 0;
 
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	while (1) {
		int n, x, i, min_a, max_a, cnt = 0;
		scanf("%d %d", &n, &x);

		if (n == 0 && x == 0) break;
		else {
			if (x - 3 < n) max_a = x - 3;
			else max_a = n;

			min_a = x / 3 + 1;
		}

		for (i = min_a; i <= max_a; i++) {
			int min_b, max_b;

			max_b = (i - 1 < x - i - 1) ? (i - 1) : (x - i - 1);
			min_b = (x - i) / 2 + 1;

			cnt += (max_b - min_b + 1);
		}

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

	return 0;
}

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

using namespace std;

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

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int n,m;
    cin>>n>>m;
    vi v(n);
    for(auto &z : v)
    {
        cin >> z;
        z/=2;
    }

    ll nzs = (ll)v[0];

    bool jelNula = false;

    for(int i = 1; i < n; i++)
    {
        ll nzd = __gcd(nzs,(ll)v[i]);
        nzs = (nzs * v[i]) / nzd;
        if(nzs > m)
        {
            jelNula = true;
            break;
        }
    }

    if(jelNula)
    {
        cout << 0 << '\n';
        return 0;
    }
    else
    {
        for(int i = 0; i < n; i++)
        {
            if((nzs/v[i])%2==0)
            {
                cout << 0 << '\n';
                return 0;
            }
        }

        int resenje =  (m/nzs+1)/2;
        cout << resenje << '\n';
    }

    return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
     
      if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
        System.out.println("Yes");
      else 
        System.out.println("No");
         
   }
}

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

int N, M, Q;
vector< vector<int> > graph;
vector< int > group;

void dfs(int u, int num) {
    group[u] = num;
    for (int v : graph[u])
        if (group[v] == -1) dfs(v, num);
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    graph.resize(N+1); group.resize(N+1);
    for (int j = 0; j < M; ++j) {
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    fill(begin(group), end(group), -1);
    int group_num = 0;
    for (int j = 1; j <= N; ++j) {
        if (group[j] == -1) dfs(j, group_num++);
    }

    cin >> Q;
    for (int j = 0; j < Q; ++j) {
        int u, v; cin >> u >> v;
        cout << (group[u] == group[v] ? "yes" : "no") << endl;
    }

    return 0;
}

Measured memory_bytes: 11688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	int a;
	cin >> a;
	cout << a+a*a+a*a*a << endl;
	return 0;
}

Measured memory_bytes: 3616
// ABC148-E
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll n;
    cin>>n;
    if(n%2==0){
        int sisu=0;
        while(0<n/ll(pow(5,sisu))){
            //cout<<n/ll(pow(10,sisu))<<endl;
            sisu+=1;
        }   
        sisu=sisu-1;
        //cout<<sisu<<endl;
        ll bef=0;
        vector<ll> baisu(sisu+1,0);
        for(int i=sisu;i>=1;i=i-1){
            ll num=n/ll(pow(5,i))/2-bef;
            bef=n/ll(pow(5,i))/2;
            baisu[i]=num;
        }
        ll ans=0;
        for(int i=1;i<=sisu;i++){
            ans+=baisu[i]*i;
        }
        //cout<<baisu<<endl;
        cout<<ans<<endl;
    }else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct PrimalDual{
  const int INF = 1<<28;
  typedef pair<int,int> P;
  struct edge{
    int to,cap,cost,rev;
    edge(){}
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<int> h,dist,prevv,preve;

  PrimalDual(){}
  PrimalDual(int sz):n(sz),G(sz),h(sz),dist(sz),prevv(sz),preve(sz){}
  
  void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,G[to].size()));
    G[to].push_back(edge(from,0,-cost,G[from].size()-1));
  }

  int min_cost_flow(int s,int t,int f){
    int res=0;
    fill(h.begin(),h.end(),0);
    while(f>0){
      priority_queue<P,vector<P>,greater<P> > que;
      fill(dist.begin(),dist.end(),INF);
      dist[s]=0;
      que.push(P(0,s));
      while(!que.empty()){
	P p=que.top();que.pop();
	int v=p.second;
	if(dist[v]<p.first) continue;
	for(int i=0;i<(int)G[v].size();i++){
	  edge &e=G[v][i];
	  if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
	    dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
	    prevv[e.to]=v;
	    preve[e.to]=i;
	    que.push(P(dist[e.to],e.to));
	  }
	}
      }
      if(dist[t]==INF){
	return -1;
      }
      for(int v=0;v<n;v++) h[v]+=dist[v];

      int d=f;
      for(int v=t;v!=s;v=prevv[v]){
	d=min(d,G[prevv[v]][preve[v]].cap);
      }
      f-=d;
      res+=d*h[t];
      for(int v=t;v!=s;v=prevv[v]){
	edge &e=G[prevv[v]][preve[v]];
	e.cap-=d;
	G[v][e.rev].cap+=d;
      }
    }
    return res;
  }
};
//END CUT HERE

int main(){
  int v,e,f;
  cin>>v>>e>>f;
  PrimalDual pd(v);
  for(int i=0;i<e;i++){
    int u,v,c,d;
    cin>>u>>v>>c>>d;
    pd.add_edge(u,v,c,d);
  }
  cout<<pd.min_cost_flow(0,v-1,f)<<endl;
  return 0;
}
/*
verified on 2017/06/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B&lang=jp
*/

Measured memory_bytes: 3136
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>
#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  string sa,sb,sc;cin>>sa>>sb>>sc;

  namespace mp = boost::multiprecision;
  using Bint = mp::cpp_int;
  Bint a(sa);
  Bint b(sb);
  Bint c(sc);

  if( (c-a-b>0) && 0<(c-a-b)*(c-a-b)-4*a*b )cout<<"Yes";
  else cout<<"No";

  return 0;
}


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n, l; cin >> n >> l;

  vector<string> v(n);
  rep(i, n) cin >> v[i];

  sort(all(v));
  rep(i, n) cout << v[i];
  cout << endl;
  
  return (0);
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];

    vector<int> diff(N);
    int res = 0;
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        diff[i] = A[i] - B[i];
        if (diff[i] < 0) {
            res++;
            sum += -diff[i];
        }
    }

    sort(diff.begin(), diff.end(), greater<int>());

    int i = 0;
    while (sum > 0) {
        if (diff[i] <= 0) {
            cout << -1 << endl;
            return 0;
        }
        sum -= diff[i];
        res++;
        i++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
def main():
    N = int(input())
    steps = [list(map(int, input().split())) for _ in range(N)]
    steps.insert(0, [0, 0, 0])
    ans = "Yes"
    for i in range(1, N+1):
        t_diff = steps[i][0] - steps[i-1][0]
        x_diff = abs(steps[i][1] - steps[i-1][1])
        y_diff = abs(steps[i][2] - steps[i-1][2])
        if x_diff + y_diff > t_diff or (t_diff - x_diff - y_diff) % 2 != 0:
            ans = "No"
            break
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
  int n, l;
  cin >> n >> l;
  string s[n];
  for(int i=0; i<n; i++)
    cin >> s[i];

  sort(s, s+n);
  string ans = "";
  for(int i=0; i<n; i++)
    ans += s[i];

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;
 
const int N = 1LL << 50;
 
signed main() {
 
    int n; cin >> n;
    
    int a, b, c;
    int dp[n + 1][3];
    for(int i = 0; i <= n; i++)
        for(int j = 0; j < 3; j++)
            dp[i][j] = -N;
    dp[0][0] = dp[0][1] = dp[0][2] = 0LL;
    for(int i = 1; i <= n; i++) {
        cin >> a >> b >> c;
        dp[i][0] = max({dp[i][0], dp[i-1][1], dp[i-1][2]}) + a;
        dp[i][1] = max({dp[i][1], dp[i-1][0], dp[i-1][2]}) + b;
        dp[i][2] = max({dp[i][2], dp[i-1][0], dp[i-1][1]}) + c;
    }
    
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
 
    return 0;
}

Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            double d = 0;
            for (int i = 0; i < n; i++) {
                double cur = in.nextInt();
                d += 1 / cur;
            }
            double ans = 1 / d;
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22228
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int n,a,b,c;
int main(int argc, char const *argv[])
{
	unsigned long v=1;
	cin >> n;
	REP(i,n){
		v *= (i+1);
		v %= (1000000007);
	}
	cout << v << endl;
	return 0;
}

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

int main(){
    int A,B; cin >> A >> B;
    int ans=0; 
    for (int a=1; a<10; a++){
        for (int b=0; b<10; b++){
            for (int c=0; c<10; c++){
                int x=10001*a+1010*b+100*c;
                if(x>=A && x<=B) ans++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vr vector
#define pb push_back
 int main()
 {

  //ll t;
  //cin>>t;

  //while(t--)
  {
      ll n,base;
      cin>>n>>base;
    ll dig = (ll)(floor( log(n) /
                         log(base)) + 1);
    cout<<dig<<endl;
   }
    return 0;
}





Measured memory_bytes: 512
n = int(input())
s = input()
c = 0
list_s = [sorted(list(set(s[:i]))) for i in range(1,n)]
list_l = [sorted(list(set(s[i:]))) for i in range(1,n)]
print(max([sum([1 if list_s[j][i] in list_l[j] else 0 for i in range(len(list_s[j]))]) for j in range(n-1)]))

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] n = sc.next().toCharArray();
        int k = sc.nextInt();
        int[] a = new int[n.length+1];
        for (int i = 0; i < n.length; i++) {
            a[i+1] = (int)(n[i] - '0');
        }
        long[][] dp1 = new long[a.length][k+1];
        long[][] dp2 = new long[a.length][k+1];
        dp2[0][0] = 1;
        for (int i = 1; i < a.length; i++) {
            if(a[i] == 0){
                for (int j = 0; j <= k; j++) {
                    dp1[i][j] += dp1[i-1][j];
                    dp2[i][j] += dp2[i-1][j];
                    if(0<j){
                        // set any
                        dp1[i][j] += dp1[i-1][j-1] * 9;
                    }
                }
            }else{
                for (int j = 0; j <= k; j++) {
                    // set 0
                    dp1[i][j] += dp1[i-1][j] + dp2[i-1][j];
                    if(0 < j){
                        // set max
                        dp2[i][j] += dp2[i-1][j-1];
                        // set any
                        dp1[i][j] += dp1[i-1][j-1] * 9 + dp2[i-1][j-1] * (a[i]-1);
                    }
                }
            }
        }
        System.out.println(dp1[a.length-1][k] + dp2[a.length-1][k]);
        sc.close();

    }

}



Measured memory_bytes: 23252
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        s: chars,
    }
    let n = s.len();
    let mut r = s.clone();
    r.reverse();
    let a = s[..(n - 1) / 2].iter().cloned().collect::<Vec<_>>();
    let b = s[(n + 3) / 2 - 1..].iter().cloned().collect::<Vec<_>>();
    let mut ar = a.clone();
    ar.reverse();
    let mut br = b.clone();
    br.reverse();

    if s == r && a == ar && b == br {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

typedef long long ll;

int main(void)
{
    int a[5];

    for(int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < 5; i++)
    {
        if(a[i] == 0)
        {
            cout << i+1 << "\n";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>
#include <math.h>

using namespace std;
        
int main(){
    long int n,z,w;
    cin>>n>>z>>w;
    vector<long int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    long int ans=0;
    if(n==1){
        ans=abs(v[0]-w);
    }else{
        ans=max(abs(v[n-1]-w),abs(v[n-2]-v[n-1]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ll A, B, C;
    while(cin >> A >> B >> C){
        vll u{A,B,C};
        ll ans = LLONG_MAX;
        rep(i, 3){
            ll val = abs(u[i] / 2 * 2 - u[i]);
            rep(j, 3)if(j != i)val *= u[j];
            smin(ans, val);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256