akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let v: Vec<i32> = (0..n).map(|_| read()).collect();
    let c: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut ans = 0;
    for i in 0..n {
        let rieki = v[i] - c[i];
        if rieki > 0 {
            ans += rieki;
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
package main

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

var sc = bufio.NewScanner(os.Stdin)

type review struct {
	index int
	city  string
	point int
}

type reviews []*review

func (r reviews) Len() int {
	return len(r)
}

func (r reviews) Less(i, j int) bool {
	if r[i].city < r[j].city {
		return true
	}

	if r[i].city == r[j].city {
		if r[i].point > r[j].point {
			return true
		}
		return false
	}
	return false

}
func (r reviews) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	n := oneInt()

	rs := make(reviews, n)

	for i := 0; i < n; i++ {
		rs[i] = &review{index: i}
		rs[i].city, rs[i].point = oneStr(), oneInt()
	}

	sort.Sort(rs)

	for i := 0; i < n; i++ {
		//fmt.Println(rs[i].city)
		//fmt.Println(rs[i].point)
		fmt.Println(rs[i].index + 1)
	}

}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func oneStr() string {
	sc.Scan()
	return sc.Text()
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner cin=new Scanner(System.in);
		int n=cin.nextInt();
		int a=cin.nextInt();
		int b=cin.nextInt();
		int c=cin.nextInt();
		int d=cin.nextInt();
		int min=1<<30;
		int[][] pos=new int[4][2];
		for(int w=1;w<=n;w++){
			int x,y;
			x=y=0;
			int cnt=1;
			while(true){

				if(cnt==a){
					pos[0][0]=x;
					pos[0][1]=y;
				}
				if(cnt==b){
					pos[1][0]=x;
					pos[1][1]=y;
				}
				if(cnt==c){
					pos[2][0]=x;
					pos[2][1]=y;
				}
				if(cnt==d){
					pos[3][0]=x;
					pos[3][1]=y;
				}
				x = (x+1)%w;
				if(x==0)y++;
				cnt++;
				if(cnt==n*n)break;
			}
			int d1=Math.abs(pos[0][0]-pos[1][0])+Math.abs(pos[0][1]-pos[1][1]);
			int d2=Math.abs(pos[2][0]-pos[3][0])+Math.abs(pos[2][1]-pos[3][1]);
//			System.out.println(d1+d2);
			min=Math.min(d1+d2,min);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 20136
#include<stdio.h>
int main()
{
    int A,B,T,C,E;
    scanf("%d %d %d",&A,&B,&T);
    if(1<=A&&A<=20&&1<=B&&B<=20&&1<=B&&B<=20)
    {
        C=(T+.5)/A;
        E=B*C;
        printf("%d",E);
    }
    return 0;
}


Measured memory_bytes: 128
/**
 *    Author:   Jay Sabale
 *	       
**/

#include<bits/stdc++.h>

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
typedef vector <lli> vl;
typedef vector <string> vs;
typedef vector < pair <long, long> > vll;

// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(lli i=0; i<n; i++)
#define rep(i,k,n) for (lli i = k; i < n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

// Printing Data :
#define pvec(v) forz(i,v.si) cout<<v[i]<<" "; cout<<endl;
#define parr(arr, n) forz(i,n) cout<<arr[i]<<" "; cout<<endl;
#define p1(i) cout<<i<<endl;
#define p2(i, j) cout<<i<<" "<<j<<endl;
#define p3(i, j, k) cout<<i<<" "<<j<<" "<<k<<endl;
#define p4(i, j, k, l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;

typedef pair <lli,lli> pll;
 
// CODE BEGINS :

int main()
{
    kira;

    lli n, k; cin>>n>>k;
    lli res = 0, max_l=-1, max_r=-1;

    for(lli i=k; i<=n+1; i++)
    {
        max_l = ((i-1)*(i))/2;
        max_r = i*n - ((i-1)*(i))/2;

        res = (res%mod + (max_r-max_l+1)%mod)%mod;
    }

    cout<<res%mod<<endl;

    return 0;
}




















































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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;

const ll MAX_N=131072;
vector<int> G[1000010];
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N, Q;
struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1,INT_MAX);
        lazy.resize(2*n-1, -1);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    // k 番目のノードについて遅延評価を行う
    void eval(int k, int l, int r) {
        // 遅延配列が空でない場合、自ノード及び子ノードへの
         // 値の伝播が起こる
        if(lazy[k] != -1) {
            node[k] = lazy[k];
            // 最下段かどうかのチェックをしよう
            // 子ノードは親ノードの 1/2 の範囲であるため、
            // 伝播させるときは半分にする
            if(r - l > 1) {
                lazy[2*k+1] = lazy[k] ;
                lazy[2*k+2] = lazy[k] ;
            }
            // 伝播が終わったので、自ノードの遅延配列を空にする
            lazy[k] = -1;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        // k 番目のノードに対して遅延評価を行う
        eval(k, l, r);
        // 範囲外なら何もしない
        if(b <= l || r <= a) return;
        // 完全に被覆しているならば、遅延配列に値を入れた後に評価
        if(a <= l && r <= b) {
            lazy[k] =  x;
            eval(k, l, r);
        }
        // そうでないならば、子ノードの値を再帰的に計算して、
        // 計算済みの値をもらってくる
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1],node[2*k+2]);
        }
    }
    void get(){
      rep(i,node.size()){
        cout<<node[i]<<" ";
      }
      cout<<endl;
      rep(i,lazy.size()){
        cout<<lazy[i]<<" ";
      }
      cout<<endl;
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        // 関数が呼び出されたら評価！
        eval(k, l, r);
        if(b <= l || r <= a) return INT_MAX;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};
int main(){
  int N,Q;cin>>N>>Q;
  LazySegmentTree seg(vector<ll>(N,INT_MAX));
  rep(i,Q){
    int query;cin>>query;
    if (query==0){
      int s,t,x;cin>>s>>t>>x;
      seg.add(s,t+1,x);
    }else{
      int s,t;cin>>s>>t;
      cout<<seg.getsum(s,t+1)<<endl;
    }
  }
}



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool ans = false;
  for (int i = 1; i < s.length(); i++) {
    if (s[i - 1] == s[i]) {
      ans = true;
    }
  }
  if (ans) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  return 0;
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);

// 10進数の桁数を求める
int digitsNum(int64_t n) {
  int digit = 0;
  while (n > 0) {
    n /= 10;
    ++digit;
  }
  return digit;
}

// ABC057C - Digits in Multiplication
int main(){
  int64_t N; // 1 <= N <= 1e10
  cin >> N;

  // F(A, B) = 10進数で桁数の大きい方の桁数
  // n^2 <= N
  int minF = INT_MAX;
  for (int64_t i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      const int f =max(digitsNum(i), digitsNum(N/i));
      if (f < minF) {
        minF = f;
      }
    }
  }

  cout << minF << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i == 0 or i % 2 == 0:
                if j % 2 == 0 or j == 0:
                    print("#", end="")
                if j % 2 != 0:
                    print(".", end="")
            else:
                if j % 2 == 0 or j == 0:
                    print(".", end="")
                if j % 2 != 0:
                    print("#", end="")
        print()
    print()





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

#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define all(v) v.begin(),v.end()

int main()
{
	FIO
	int n;
	cin >> n;
	vector<int> v[n+1];
	vector<int> inc[n+1];
	for(int i=0; i<n; i++) {
		int len;
		cin >> len;
		while(len--) {
			int x, y;
			cin >> x >> y;
			x-=1;
			if(y == 0) {
				v[i].push_back(x);
			} else {
				inc[i].push_back(x);
			}
		}
	}

	int mx = 0;
	for(int i=1; i<(1 << n); i++) {
		int cnt = 0;
		vector<int> tmp(n, 0);
		for(int j=0; j<n; j++) {
			if((i & (1 << j)) == 0)
				continue;
			if(tmp[j] == 2) {
				cnt = -1;
				break;
			}
			cnt+=1;
			tmp[j] = 1;
			for(auto k : v[j]) {
				if(tmp[k] == 1) {
					cnt = -1;
					break;
				}
				tmp[k] = 2;
			}
			if(cnt == -1)
			{
				break;
			}
			for(auto k : inc[j]) {
				if((i & (1 << k)) == 0) {
					cnt = -1;
					break;
				}
			}
			if(cnt == -1)
			{
				break;
			}
		}
		// cout << i << " " << cnt << "\n";
		mx = max(mx, cnt);
	}
	
	cout << mx << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793



int main() {
    int x, y;
    cin >> x;
    cin >> y;
    if ((y - 2 * x)%2 == 1 || (4 * x - y) % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    int a, b;
    a = (4 * x - y) / 2;
    b = (y - 2 * x) / 2;
    if (a<0 || b<0) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void READ() {
#define R READ();
#define INFI 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MEMX(x,num) memset(x,num,sizeof(x))
#define prln(x) cout<<#x<<"="<<x<<endl
#define sz(x) int(x.size())
#define PB(x) push_back(x)
#define LINK(x,y) G[x].PB(y),G[y].PB(x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#ifndef ONLINE_JUDGE
    freopen("A.in", "r", stdin);
#endif
    std::ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(6);
}
//////////////////////////////////////////
const int N = 5 + 5e5;

int n,a[N],s[N],t[N];
LL ans;
int main() {
    
    cin >> n ;
    rep(i,1,n)cin>>a[i];
    rep(i,1,n)s[i]=a[i]^s[i-1],t[i]=a[i]+t[i-1];
    for(int i=1,j=1;i<=n&&j<=n;)
    {
        if(i>j||(a[j]^s[j-1]^s[i-1])==(a[j]+t[j-1]-t[i-1]))
            ans+=j-i+1,j++;
        else {i++;}
    }
    cout<<ans;

    return 0;
}



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

int main() {
    string S, T; cin >> S >> T;
    int t = T.size(), s =S.size();

    int a = -5;

    if (s < t) cout << "UNRESTORABLE" << endl;
    else{
        for (int i = 0; i <= s -t; i++) {
            int b = 0;
            for (int j = 0; j < t; j++) {
                if (S[i + j] == T[j] || S[i + j] == '?') b ++;
            }
            if (b == t) a = i;
        }

        if (a == -5) cout << "UNRESTORABLE" << endl;

        else{
        string ans;
        ans = S;
        for (int i = 0; i < s; i++) {
            if ( S[i] == '?') ans[i] = 'a';
        }
        for (int i = a; i < a + t; i++) ans[i] = T[i - a];
        cout << ans << endl;
        }
    }
}

Measured memory_bytes: 256
from itertools import accumulate
N,X = map(int, input().split())
Ls = [0]+list(map(int, input().split()))
D = list(accumulate(Ls))

flg = False
for i,d in enumerate(D):
    if d>X:
        flg = True
        break
if flg:
    print(i)
else:
    print(i+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#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 SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

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


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

int main()
{
    int n,
        min = 2000000,
        max = -2000000,
        value;
    long long sum = 0;
    cin >> n;
    for (int i = 0; i != n; ++i)
    {
        cin >> value;
        sum += value;
        if (value > max)
        {
            max = value;
        }
        if (value < min)
        {
            min = value;
        }
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}



Measured memory_bytes: 3108
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        int ans = 0;
        boolean f = true;
        while (f) {
            f = false;
            boolean m = true;
            for (int i = 0; i < n; i++) {
                if (h[i] > 0) {
                    h[i]--;
                    ans += (m) ? 1 : 0;
                    f = true;
                    m = false;
                } else {
                    m = true;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;
	if (A + B > N + 1) {
		cout << -1 << endl;
		return 0;
	}
	//cerr << "ok" << endl;
	vector<int> res(N+B, -1);
	vector<int> res2(N+B, -1);
	bool ok = true;
	int st = B;
	int cur = 0;
	int rem = N;
	int k = 0;
	while (true) {
		if (rem + cur == A) {
			break;
		}
		if (rem == 0) {
			ok = false;
			break;
		}
		//cerr << st << " " << k << endl;
		res[st - 1] = k;
		if (st%B == 0) {
			cur++;
		}
		st--;
		rem--;
		k++;
		if (st%B == 0) {
			st += 2 * B;
		}
		
	}
	if (!ok) {
		cout << -1 << endl;
		return 0;
	}
	int t = 0;
	for (int i = 0; i < res.size(); i++) {
		if (res[i] != -1) {
			res2[t] = res[i];
			t++;
		}
	}
	swap(res, res2);
	for (int i = k; i < N; i++) {
		res[i] = i;
	}
	for (int i = 0; i < N; i++) {
		if (i > 0)cout << " ";
		cout << res[i] + 1;
	}
	cout << endl;
}

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

int main()
{
	long long X, Y;
	int count = 0;

	cin >> X >> Y;

	while (X <= Y)
	{
		X *= 2;
		count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#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 dfs(string s,int n){
    if(s.size()==n){
        cout << s << endl;
        return 0;
    }
    else{
        string p;
        p = s;
        char max_c='a';
        rep(i,p.size()){
            if(p[i]>max_c) max_c=p[i];
        }
        for(char c='a';c<=(max_c+1);++c){
            
            dfs(p+c,n);
        }
    }
    return 0;
}

int main(){
    int n;
    cin >> n;
    string res = "a";
    dfs(res,n);

}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    int ct[26]={};
    rep(i,s.size()) ct[s[i]-'a']++;

    int odd=0,even=0;
    rep(i,26)
    {
        if(ct[i]>0)
        {
            if(ct[i]%2==0) ++even;
            else ++odd;
        }
    }

    printf("%d\n",odd/2);
    return 0;
}

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

int a[200005];

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

    rep(i, n) {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }

    int sum = 0;
    for (int i = k; i <= n; i++) sum = max(sum, a[i] - a[i - k]);

    printf("%.12f\n", (sum + k) / 2.0);
    return 0;
}


Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl
ll GCD(ll a, ll b){
    if(b == 0) return a;
    else return GCD(b,a%b);
}

ll LCM(ll a, ll b){
    return (a*b/GCD(a,b));
}

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  ll ans = 0;
  rep(i, N) cin >> A[i];
  rep(i, N){
    rep(j, N){
       ans = max(ans, abs(A[i]-A[j]));
    }
  }
cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}

template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double a,b;
	cin>>a>>b;
	fcout(10)<<a/b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
cin >> S;
int n = S.size();  
int count = 0;
for(int i = 0; i < n;i++){
 if(S[i] != S[n - 1 - i] ) {
     count++;
 }
}
 cout << count / 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(true) {
            int m = scanner.nextInt();
            int f = scanner.nextInt();
            int r = scanner.nextInt();
            if (m == -1 && f == -1 && r == -1) break;
            if (m == -1 || f == -1) {
                System.out.println("F");
            } else if (m + f >= 80) {
                System.out.println("A");
            } else if (m + f >= 65) {
                System.out.println("B");
            } else if (m + f >= 50) {
                System.out.println("C");
            } else if (m + f >= 30) {
                if (r >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else {
                System.out.println("F");
            }
        }
        scanner.close();
    }
}



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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d){
    cout<<"Balanced"<<endl;
  }else if(a+b>c+d){
    cout<<"Left"<<endl;
  }else{
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int head, tail, flow, cap;
} edge;

typedef struct List {
	struct List *next;
	int id;
} list;

int main()
{
	int i, H, W;
	char a[102][102] = {};
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) scanf("%s", &(a[i][1]));
	
	int j, k, m, s, t;
	list *adj[10001] = {}, d[2000001];
	edge e[2000001];
	for (i = 1, m = 2; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (a[i][j] == '.') continue;
			else if (a[i][j] == 'S') s = (i - 1) * W + j;
			else if (a[i][j] == 'T') t = (i - 1) * W + j;
			
			for (k = i + 1; k <= H; k++) {
				if (a[k][j] != '.') {
					e[m].head = (k - 1) * W + j;
					e[m+1].head = (i - 1) * W + j;
					e[m].tail = e[m+1].head;
					e[m+1].tail = e[m].head;
					e[m].flow = 0;
					e[m+1].flow = 0;
					e[m].cap = 1;
					e[m+1].cap = 1;
					d[m].id = m;
					d[m+1].id = m + 1;
					d[m].next = adj[e[m].tail];
					d[m+1].next = adj[e[m+1].tail];
					adj[e[m].tail] = &(d[m]);
					adj[e[m+1].tail] = &(d[m+1]);
					m += 2;
				}
			}
			for (k = j + 1; k <= W; k++) {
				if (a[i][k] != '.') {
					e[m].head = (i - 1) * W + k;
					e[m+1].head = (i - 1) * W + j;
					e[m].tail = e[m+1].head;
					e[m+1].tail = e[m].head;
					e[m].flow = 0;
					e[m+1].flow = 0;
					e[m].cap = 1;
					e[m+1].cap = 1;
					d[m].id = m;
					d[m+1].id = m + 1;
					d[m].next = adj[e[m].tail];
					d[m+1].next = adj[e[m+1].tail];
					adj[e[m].tail] = &(d[m]);
					adj[e[m+1].tail] = &(d[m+1]);
					m += 2;
				}
			}
		}
	}
	if (s % W == t % W || (s - 1) / W == (t - 1) / W) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	int N = H * W, u, w, ans = 0, used[10001] = {}, prev[10001] = {}, q[10001], head, tail;
	list *p;
	q[0] = s;
	while (ans < H + W - 2) {
		for (head = 0, tail = 1; head < tail; head++) {
			u = q[head];
			if (used[u] == 0 || used[e[prev[u]].tail] == 1) {
				for (p = adj[u]; p != NULL; p = p->next) {
					i = p->id;
					w = e[i].head;
					if (prev[w] == 0 && e[i].flow == 0) {
						prev[w] = i;
						q[tail++] = w;
						if (w == t) break;
					}
				}
				if (p != NULL) break;
			} else {
				i = used[u];
				w = e[i].tail;
				if (prev[w] == 0) {
					prev[w] = i ^ 1;
					q[tail++] = w;
					if (w == t) break;
				}
				if (p != NULL) break;
			}
		}
		if (head == tail) break;
		else ans++;
		
		for (u = t; u != s; u = e[prev[u]].tail) {
			i = prev[u];
			if (e[i^1].flow == e[i^1].cap) {
				e[i^1].flow--;
				used[e[i^1].head] = 0;
			} else {
				e[i].flow++;
				used[u] = i;
			}
		}
		for (tail--; tail > 0; tail--) prev[q[tail]] = 0;
	}
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 63736
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void readv(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin >> x;
    ll s = 100;
    for (int i = 1; i <= 10000; i++) {
        s = ll(double(s) * double(1.01));
        if (s >= x) {
            cout << i << '\n';
            return 0;
        }
    }
}

Measured memory_bytes: 3648
'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n');
  const s = tmp[0], t = tmp[1];
  const sl = s.length, tl = t.length;
  const dp = Array(sl+1).fill(0).map( _=>Array(tl+1).fill(''));
  for ( let i = 0; i < sl; i++ ) {
    for ( let j = 0; j < tl; j++ ) {
      if ( t[j] === s[i] ) {
        dp[i+1][j+1] = dp[i][j] + s[i];
      } else {
        dp[i+1][j+1] = dp[i+1][j].length > dp[i][j+1].length ? dp[i+1][j] : dp[i][j+1];
      }
    }
  }
  return dp[sl][tl];
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 453532
#include <iostream>
#include <cmath>
using namespace std;
int main () 
{
int n;
cin>>n;
int a[102];
long long sum=0;
for (int i=1;i<=n;i++){
	cin>>a[i];
	sum+=a[i];
}
long long j=round(double(sum)/n);
int o=0;
for (int i=1;i<=n;i++){
	o+=(a[i]-j)*(a[i]-j);
}
cout<<o;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    ll N;
    cin >> N;
    vl P(N);

    for(ll i=0; i<N; i++){
        cin >> P.at(i);
    }

    ll mini = P.at(0);
    ll sum = 0;
    for(ll i=0; i<N; i++){
        if(P.at(i) <= mini){
            sum++;
        }
        mini = min(P.at(i), mini);
    }

    cout << sum << endl;
}


Measured memory_bytes: 1792
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


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

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;



int main()
{ 

IOS;


ll n;cin>>n;



string s;cin>>s;

ll c=0;

FOR(i,10)
FOR(j,10)
FOR(k,10){
  ll check=i,cnt=0;
for(auto x:s){
if(x-'0'==check){
 // check=j;
  cnt++;
}
if(cnt==1)check=j;
if(cnt==2)check=k;
if(cnt==3)break;
}
if(cnt==3)c++;
}

cout<<c;


//end_routine();

return 0;
 
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
long long n,i,j,a,b,c,k;
int main()
{
  cin>>n;
  a=sqrt(n);
  for(i=1;i<a+1;i++)if(n%i==0)j=n/i;
  for(;j!=0;j/=10)c++;
  cout<<c;
}

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

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        String str=scanner.next();
        int q=scanner.nextInt();
        for(int i=0;i<q;i++){
            String m=scanner.next();
            if(m.equals("print")){
                int a=scanner.nextInt();
                int b=scanner.nextInt();
                System.out.println(str.substring(a,b+1));
            }else if(m.equals("reverse")){
                int a=scanner.nextInt();
                int b=scanner.nextInt();
                str=str.substring(0,a)+(new StringBuffer(str.substring(a,b+1))).reverse().toString()+str.subSequence(b+1,str.length());
            }else{
                int a=scanner.nextInt();
                int b=scanner.nextInt();
                String p=scanner.next();
                str=str.substring(0,a)+p+str.subSequence(b+1,str.length());
            }
        }
    }

}



Measured memory_bytes: 30208
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class WeightedUnionFind {
    int[] parent;
    long[] weightDiff;
    int count;

    public WeightedUnionFind(int size) {
        var b = new int[size];
        for (int i = 0; i < b.Length; i++) {
            b[i] = -1;
        }
        parent = b;
        weightDiff = new long[size];
        count = size;
    }

    int Find(int x) {
        if (parent[x] < 0) {
            return x;
        }
        else {
            var r = Find(parent[x]);
            weightDiff[x] += weightDiff[parent[x]];
            return parent[x] = r;
        }
    }

    long Weight(int x) {
        Find(x);
        return weightDiff[x];
    }

    public long Diff(int x, int y) => Weight(y) - Weight(x);

    public bool Same(int x, int y) => Find(x) == Find(y);

    public void Unite(int x, int y, long w) {
        w += weightDiff[x] - weightDiff[y];
        x = Find(x);
        y = Find(y);
        if (x == y) return;
        count--;
        if (parent[x] > parent[y]) {
            parent[y] += parent[x];
            parent[x] = y;
            weightDiff[x] = -w;
        }
        else {
            parent[x] += parent[y];
            parent[y] = x;
            weightDiff[y] = w;
        }
    }

    public int Size(int x) => -parent[Find(x)];

    public int Count() => count;
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        int M = cin.Int();

        var uf = new WeightedUnionFind(N);
        for (int i = 0; i < M; i++) {
            int L = cin.Int() - 1;
            int R = cin.Int() - 1;
            long D = cin.Long();
            if (uf.Same(L, R)) {
                if (uf.Diff(L, R) != D) {
                    Console.WriteLine("No");
                    return;
                }
            }
            else uf.Unite(L, R, D);
        }
        Console.WriteLine("Yes");
        Console.ReadLine();
    }
}

Measured memory_bytes: 17308
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

map<int,int> primefact(int n) {
	map<int,int> ret;
	for(int i = 2;i*i <= n;i++) while(n % i == 0) ret[i]++,n/=i;
	if(n>1) ret[n]++;
	return ret;
}
 
long long power(long long n, long long k, long long m) {
	if (k == 0) {
		return 1;
	}
	else if (k % 2 == 1) {
		return power(n, k - 1, m)*n%m;
	}
	else {
		long long t = power(n, k / 2, m);
		return t*t%m;
	}
}
 
LL extgcd(LL a, LL b, LL &x, LL &y) {
    LL g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

// mod m ?? a ? ??
LL mod_inverse(LL a, LL m){
    LL x, y;
    extgcd(a, m, x, y);
    return (m + x%m)%m;
}

int n;
LL a[10101];
int max_v[1010101];
map<int, int> mp[10101];
const int mod = 1e9 + 7;
int main(){
    cin >> n;
    REP(i, n)cin >> a[i];
    REP(i, n){
        mp[i] = primefact(a[i]);
        for(auto it = mp[i].begin();it != mp[i].end();it++){
            max_v[it->first] = max(max_v[it->first], it->second);
        }
    }
    LL LCM = 1;
    REP(i, 1010101)(LCM *= power(i, max_v[i], mod)) %= mod;
    LL ans = 0;
    REP(i, n){
        (ans += LCM * mod_inverse(a[i], mod)) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}



//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
 ll N;
  cin>>N;
  if(N%2==1)cout<<0<<endl;
  else{
    vl num(30);
    
    num[1] =N/10;
    ll an=50;
    int h=2;
    while(N/an>0){ 
     num[h]=N/an;
      an*=5;
      num[h-1] -=num[h];
      h++;
    }ll ans=0;
    rep(i,30){
      ans += num[i]*(ll)i;
    }
  
  cout<<ans<<endl;

  }

}






Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int dp[101][10001]={};
int main(){
	int N,W,v[101],w[101];
	cin>>N>>W;
	for(int i=1;i<=N;i++)cin>>v[i]>>w[i];
	for(int i=1;i<=N;i++)for(int j=1;j<=W;j++){
		if(j>=w[i])dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
		else dp[i][j]=dp[i-1][j];
	}
	cout<<dp[N][W]<<"\n";
	return 0;
}

Measured memory_bytes: 7016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(a % 2 == 1 && b % 2 == 1 && c % 2 == 1){
    cout << min({a*b,b*c,a*c}) << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3596
n = int(input())
sum = 0
s = []
for i in range(n) :
    x = int(input())
    sum += x
    if x%10 != 0 :
        s.append(x)


if sum %10 != 0 :
    print(sum)
    exit()

while len(s)>0 :
    m = min(s)
    sum -= m
    if sum%10 != 0 :
        print(sum)
        exit()

print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100

int N,D;
int A[100];
int X;
// int H;
// vector<int> thrower;

// int Rx[MAX];
// int Ry[MAX];
// int Bx[MAX];
// int By[MAX];
// int dp[1000000001];

int main(void){
    // Your code here!
    cin >> N >> D >> X;
    
    int ans = 0;
    REP(i,0,N) {
        cin >> A[i];
        for(int j = 0; j*A[i] + 1 <= D; j++) {
            ans += 1;
        }
    }
    
    
    cout << ans + X << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <iomanip>

using namespace std;
int main() {
    int n ;
    cin >> n;
    double arr[n];
    for(int i =0 ; i< n; i ++){
        cin >> arr[i];
    }
    double dd[n + 1][n + 1];
    memset(dd , 0 , sizeof dd);
    dd[0][1] = arr[0];
    dd[0][0] = 1 - arr[0];
    for(int i = 1 ;i < n; i ++){
        for(int j = 0; j <= n ;j ++){
            if(j == 0){
                dd[i][j] = dd[i-1][j]*(1 -arr[i]);
            }else
            dd[i][j] = dd[i-1][j]*(1 - arr[i]) + dd[i-1][j-1] * arr[i];
        }
    }
    double ans = 0;
    for(int i = n / 2 + 1 ; i <= n; i++){
        ans += dd[n - 1][i];
    }
    cout << fixed << setprecision(9) << ans;
}


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

taro = 0
hanako = 0

for idx in range(n):
    cc = input().split()

    if cc[0] == cc[1]:
        taro += 1
        hanako += 1
    elif cc[0] < cc[1]:
        hanako += 3
    else:
        taro += 3

print(taro, hanako)



Measured memory_bytes: 5600
from collections import deque
H, W = map(int, input().split())
m = []
for i in range(H):
  m.append(input())
#白の個数数える(スタートゴール以外)
cnt0 = -2
for ma in m:
  for n in ma:
    if n == ".":
      cnt0 += 1
q = deque([(0,0)])
v = [[float("inf")]*W for i in range(H)]
v[0][0] = 0
g = (H-1, W-1)
move = ((0,1), (1,0), (0,-1), (-1,0))  
#ゴールの白個数はカウントしないから-1スタート
cnt1 = -1
#ここからBFS
while q:
  s = q.popleft()
  for mo in move:
    ns = (s[0]+mo[0], s[1]+mo[1])
    if 0<=ns[0]<=H-1 and 0<=ns[1]<=W-1 and v[ns[0]][ns[1]]==float("inf") and m[ns[0]][ns[1]]==".":
      q.append(ns)
      if v[ns[0]][ns[1]]>v[s[0]][s[1]]+1:
        v[ns[0]][ns[1]] = v[s[0]][s[1]]+1
    if ns == g:
      cnt1 += v[g[0]][g[1]]
      break
  if ns == g:
    break

if v[g[0]][g[1]]==float("inf"):
  print(-1)
else:
  print(cnt0-cnt1)

Measured memory_bytes: 74468
N = int(input())
if N >=400 and N < 600:
  print(8)
elif N >=600 and N <800:
  print(7)
elif N >=800 and N <1000:
  print(6)
elif N >=1000 and N <1200:
  print(5)
elif N >=1200 and N <1400:
  print(4)
elif N >=1400 and N <1600:
  print(3)
elif N >=1600 and N <1800:
  print(2)
elif N >=1800 and N <2000:
  print(1)

Measured memory_bytes: 61672
// B - Greedy Takahashi
#include <bits/stdc++.h>
using namespace std;

int main(){
	long long A,B,K; cin>>A>>B>>K;
	if(A > K) A -= K;
	else{
		B = K-A>B? 0:B-K+A;
		A = 0;
	}
	cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
void fill(int** mat,int ox,int oy,int k){
  if(k==1){
    mat[oy+0][mat[oy+0][0]++] = ox+1;
    mat[oy+1][mat[oy+1][0]++] = ox+1;
  } else {
    for(int i=0;i<k;i++) mat[oy+0][mat[oy+0][0]++] = ox+i+1;
    for(int i=0;i<k;i++) mat[oy+1+i][mat[oy+1+i][0]++] = ox+i+1;
    fill(mat,ox+k,oy+1,k-1);
  }
}
int main() {
  int n;
  cin >> n;
  int k=0;
  int ni = 0;
  for(int i=1;i<=n;i++){
    ni += i;
    k++;
    if(ni==n) break;
    if(ni>n){
      cout << "No" << endl;
      return 0;
    }
  }
  //if(n==1 || k==1){
  //  cout << "No" << endl;
  //  return 0;
  //} else {
  //  cout << "Yes" << endl;
  //  cout << k+1 << endl;
  //}
  cout << "Yes" << endl;
  cout << k+1 << endl;
  int** mat = new int*[500];
  for(int i=0;i<500;i++) {
    mat[i] = new int[500];
    mat[i][0] = 1;
  }
  fill(mat,0,0,k);
  for(int i=0;i<k+1;i++){
    cout << k << " ";
    for(int j=0;j<k;j++) cout << mat[i][j+1] << " ";
    cout << endl;
  }


  
  return 0;
}


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

int main(void){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
  }else if(s[2] == s[3] && s[1] == s[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256