akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = Integer.parseInt(in.nextLine());
        String s = in.nextLine();

        if(a < 3200){
            System.out.println("red");
        } else{
            System.out.println(s);
        }
    }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));

	int dif = INF, tar = -1;
	REP(i, n - 1) {
		int a = v[i];
		if (v[i] > v.back() / 2)a = v.back() - v[i];

		if (v.back() / 2 - a < dif) {
			dif = v.back() / 2 - a;
			tar = v[i];
		}
		


	}
	cout << v.back() << " " << tar << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct edge{int to, id; ll cost;};

const int MAX_V = 1e5;
vector<edge> es[MAX_V];
vector<bool> check(MAX_V, false), used(MAX_V, false);
ll X[MAX_V];

void dfs(int now, int MAX){
    for(auto &e: es[now]){
        if(e.cost > MAX || used[e.id]) continue;
        used[e.id] = true;
        dfs(e.to, MAX);
    }
}

struct Union_Find_Tree{
    vector<int> par, rank;
    vector<ll> num;
    //要素数n(0〜n-1)の初期化されたUnion-Find木を構築
    Union_Find_Tree(int N){
        par.assign(N, -1);
        rank.assign(N, 0);
        rep(i, N) num.pb(X[i]);
    }
    //ノードxの根を取得
    int root(int x){
        if(par[x] < 0 || par[x] == x) return x;
        return root(par[x]);
    }
    //xとyの属する集合を併合
    void unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return;
        elif(rank[x] < rank[y]){
            par[x] = y, num[y] += num[x];
        }
        else{
            par[y] = x, num[x] += num[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    //xの属する集合の要素数を取得
    ll size(int x){
        return num[root(x)];
    }
    //xとyが同じ集合に属するか判定
    bool same(int x, int y){
        return root(x) == root(y);
    }
    //初期化する
    void clear(){
        fill(par.begin(), par.end(), -1);
        fill(rank.begin(), rank.end(), 0);
        fill(num.begin(), num.end(), 1);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, N) cin >> X[i];
    int A[M], B[M];
    ll Y[M];
    pli p[M];
    rep(i, M){
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
        cin >> Y[i];
        es[A[i]].eb((edge){B[i], i, Y[i]});
        es[B[i]].eb((edge){A[i], i, Y[i]});
        p[i] = pli(Y[i], i);
    }
    sort(p, p+M);
    Union_Find_Tree uft(N);
    rep(i, M){
        int j = p[i].second;
        uft.unite(A[j], B[j]);
        if(uft.size(A[j]) >= Y[j]) check[j] = true;
    }
    int rem = 0;
    rep3(i, M-1, 0){
        int j = p[i].second;
        if(!check[j] && !used[j]) continue;
        else{
            rem++;
            if(!used[j]){
                dfs(A[j], Y[j]);
                dfs(B[j], Y[j]);
            }
        }
    }
    cout << M-rem << endl;
}

Measured memory_bytes: 20916
n, k = map(int, input().split())
a = list(map(int, input().split()))

order = [-1] * (n + 1)

s = []
v = 1
while order[v] == -1:
	order[v] = len(s)
	s.append(v)
	v = a[v - 1]
c = len(s) - order[v]
l = order[v]

if k < l:
	print(s[k])
else:
	k -= l
	k %= c
	print(s[l + k])

Measured memory_bytes: 94984
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong(),b=sc.nextLong(),n=sc.nextLong();
		sc.close();
		if(b<=n) System.out.println((long)a*(b-1)/b);
		else System.out.println((long)a*n/b);
	}
}

Measured memory_bytes: 35512
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    multiset<ll> st;
    st.insert(A[0]);
    repd(i, 1, N) {
        auto itr = st.lower_bound(A[i]);
        if (itr != st.begin()) {
            st.erase(--itr);
        }
        st.insert(A[i]);
    }

    cout << (int)st.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>
#define MAX 100
#define INF 1e8
#define WHITE 0
#define GRAY  1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int color[MAX],d[MAX],p[MAX],min,u;
  int i,j,v;

  for(i=0;i<n;i++){
    color[i] = WHITE;
    d[i] = INF;
  }
  d[0] = 0;
  p[0] = -1;

  while(1){
    min = INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<min){
	min = d[i];
	u = i;
      }
    }

    if(min == INF) break;
    color[u] = BLACK;

    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INF){
	if(d[u]+M[u][v] < d[v]){
	  d[v] = d[u] + M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
        }
    } 
  }

  for(i=0;i<n;i++) printf("%d %d\n",i,(d[i]==INF ? -1: d[i]));
}

int main(){
  int u,k,v,c;
  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++) for(j=0;j<n;j++) M[i][j]=INF;
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&M[u][v]);
    }
  }
  dijkstra();
  
  return 0;
}



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

enum Person {
    NOT_HONEST = 0, HONEST = 1, UNDEFINED = 2
};

using Testimony = std::vector<std::pair<int, Person> >;

bool check_honeciy(const int n, const std::vector<Testimony> &testimonies, const std::vector<int> &supposition) {
    auto persons = std::vector<Person>(n, Person::UNDEFINED);

    //suppose s-th person is honest and let`s see if it contradicts
    for(const auto s: supposition) {
        persons[s] = Person::HONEST;
    }

    auto checked_person_list = std::vector<bool>(n, false);

    while(true) {
        auto finish = true;

        for(int i = 0; i < n; ++i) {
            if(!checked_person_list[i] && persons[i] == Person::HONEST) {
                checked_person_list[i] = true;
                finish = false;

                for(const auto t: testimonies[i]) {
                    const auto x = t.first;
                    const auto y = t.second;
                    if(persons[x] != Person::UNDEFINED && persons[x] != y) {
                        return false;
                    }
                    persons[x] = y;
                }
            }
        }

        if(finish) {
            return true;
        }
    }
}

std::vector<std::vector<int> > combination(const int num_all, const int num_choice) {
    auto result = std::vector<std::vector<int> >();

    if(0 == num_choice) {
        result.push_back(std::vector<int>());
        return result;
    }

    for(int i = num_choice - 1; i < num_all; ++i) {
        auto rec = combination(i, num_choice - 1);
        for(auto &rec_combination: rec) {
            rec_combination.push_back(i);
            result.push_back(std::move(rec_combination));
        }
    }

    return result;
}

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

    auto testimonies = std::vector<Testimony>(n, Testimony());
    for(int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        for(int j = 0; j < a; ++j) {
            int x, y;
            std::cin >> x >> y;
            --x;
            testimonies[i].push_back(std::make_pair(x, static_cast<Person>(y)));
        }
    }

    int num_honest = n;
    for( ; num_honest > 0; --num_honest) {
        const auto c = combination(n, num_honest);
        bool end_loop = false;
        for(const auto supposition: c) {
            if(check_honeciy(n, testimonies, supposition)) {
                end_loop = true;
                break;
            }
        }
        if(end_loop) {
            break;
        }
    }

    std::cout << num_honest;

    return 0;
}


Measured memory_bytes: 1092
A, B, M = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
min_price = a.min + b.min
M.times do |i|
  x, y, c = gets.split.map(&:to_i)
  price = a[x - 1] + b[y - 1] - c
  min_price = price if min_price > price
end
puts min_price


Measured memory_bytes: 18588
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef int32_t i32;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef vector<long long> vll;
typedef vector<pair<ll,ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<pair<ll,ll>>> vvpll;
typedef list<long long> lll;
typedef pair<ll,ll> pll;

#define senor_SR ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define mp make_pair
#define fff first
#define sss second
#define sz(v) v.size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define all(a) a.begin(),a.end()
#define allr(v) v.rbegin(),v.rend()
 
#define setpri(x) setprecision(x)
#define pv(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define farr(a,n) for(long long i=0;i<n;i++) cin>>a[i];
#define fvec(vec,n) for(long long i=0;i<n;i++) { tmp;cin>>tmp;vec.pb(tmp);}
#define parr(a) for(long long i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define pvec(vec) for(long long i=0;i<vec.size();i++) cout<<vec[i]<<" "; cout<<endl;
#define prvec(v) for(long long i=v.size()-1;i>=0;i--) cout<<v[i]<<" "; cout<<endl;
#define pvecpair(v) for(long long i=0;i<v.size();i++) cout<<v[i].first<<" "<<v[i].second<<endl;
 
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MAX_INT 100000
#define MOD 1000000007

const int N = 100000+5;
 
int main()
{
	senor_SR;
	
	vector<pair<string,ll>> vp;
	int n;cin>>n;
	ll sum=0,k;
	string s;getline(cin,s);
	FOR(i,0,n)
	{
		cin>>s;
		cin>>k;
		vp.pb(mp(s,k));
	}
	cin>>s;ll x=0;
	FOR(i,0,n)
	{
		if(vp[i].fff==s)
		{	x=i;break;}
	}
	FOR(i,x+1,n)
		sum+=vp[i].sss;
		
	cout<<sum;
	
	//pvecpair(vp);
	
    return 0;   
    
}

Measured memory_bytes: 256
S = input()
a, b, c, d = S

ops = ["+","-"]
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      x = a+op1+b+op2+c+op3+d
      if(eval(x) == 7):
        print(x+"=7")
        exit()

Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int n, t, e;
	int x[1000];
	int i, j;
	int reverse;
	int flag;
	
	scanf("%d %d %d", &n, &t, &e);
	
	for (i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	
	
	/*全ての砂時計で調べる*/
	for (i = 0; i < n; i++){
		/*時刻の許容範囲内を調べる*/
		for (j = -e; j <= e; j++){
			reverse = 1;/*ひっくり返した数の初期化*/
			flag = 0;
			while (t + j >= x[i] * reverse){/*誤差よりも大きくなったら抜ける*/
				if (t + j == x[i] * reverse){
					flag = 1;
					break;
				}
				reverse++;
			}
			
			if (flag == 1){
				break;
			}
		}
		
		if (flag == 1){
			break;
		}
	}
	
	if (flag == 1){
		printf("%d\n", i + 1);
	}
	else {
		printf("-1\n");
	}
	
	return (0);
}

Measured memory_bytes: 600
#[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 s: isize = read();

    let mut a = Vec::new();
    a.push(s);
    let mut i = 2;
    loop {
        let b;
        let last = a.last().cloned().unwrap();
        if last % 2 == 0 {
            b = last / 2;
        } else {
            b = 3 * last + 1;
        }
        if a.contains(&b) {
            println!("{}", i);
            break;
        } else {
            a.push(b);
        }
        i += 1;
    }

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a;
    cin>>a;
    ll val=a+a*a+a*a*a;
    cout<<val<<endl;
	return 0;
}

Measured memory_bytes: 3664
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 9;
int n,m, cnt = 0, vis[N];

vector<int> g[N];

void dfs(int node, int pre){
    vis[node] = 1;
    
    int ok = 1;
    for (int i = 0; i < n; i++){
        if(vis[i] ==0)ok = 0;
    }
    if(ok == 1) cnt++;
    
    for(auto i: g[node]){
        if (i == pre) continue;
        if (vis[i])continue;
        dfs(i, node);
    }
    
    vis[node] = 0;
    
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m;
    int a, b;
    for (int i = 1; i <= m; i++){
        cin>>a>>b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    dfs(0,-1);
    
    cout<<cnt<<endl;
    
    return 0;
}



Measured memory_bytes: 256
W,H=(int(i) for i in input().split())
while W!=0 or H!=0:
    a=[]
    T=[]
    for i in range(H):
        T.append(input())
        a.append([])
        for j in range(W):
            a[i].append(0)
 #   print(T[0][0])
    i=0
    j=0
    while T[i][j]!="@":
        j=0
        while j<W and T[i][j]!="@":
            j+=1
    #        print(j)
        if j>=W:
            j-=1
        if T[i][j]!="@":
            i+=1
  #      print(i)
    s=[[i,j]]
    a[i][j]=1
    c=1
    while s!=[]:
        u=[]
        for l in range(len(s)):
            i=s[l][0]
            j=s[l][1]
            i-=1
            k=0
            while k<2:
            #    print(j)
                if 0<=i<H and a[i][j]==0 and T[i][j]==".":
                    a[i][j]=1
                    u.append([i,j])
                    c+=1
                i+=2
                k+=1
            i-=3
            j-=1
            k=0
            while k<2:
                if 0<=j<W and a[i][j]==0 and T[i][j]==".":
                    a[i][j]=1 
                    u.append([i,j])
                    c+=1
                j+=2
                k+=1
        s=u
    #    print (a)
    print(c)
    W,H=(int(i) for i in input().split())

Measured memory_bytes: 7796
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    if((n - mp.size()) % 2 == 0)cout << mp.size() << endl;
    else cout << mp.size() - 1 << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

int A[2][100];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j <= i; j++) {
      sum += A[0][j];
    }
    for (int j = i; j < N; j++) {
      sum += A[1][j];
    }
    res = max(res, sum);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long int n, res=0;
    cin>>n;
    while(n>499)
    {
        n-=500;
        res+=1000;
    }
    while(n>4)
    {
        n-=5;
        res+=5;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String... args)
	{
		Scanner s = new Scanner(System.in);
		int[] freq = new int[101];
		while(s.hasNextInt())
		{
			freq[s.nextInt()] += 1;
		}
		int max = 0;
		for(int i = 1; i <= 100; i++)
		{
			if(freq[i] > max)
			{
				max = freq[i];
			}
		}
		for(int i = 1; i <= 100; i++)
		{
			if(freq[i] == max)
			{
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 18140
s = input()
n = len(s) - 1

tmp = 2 ** n
ans = 0

for i in range(tmp):
  p = bin(i)[2:]
  # print(p)
  p = '0' * (n - len(p)) + p
  # print(p)
  x = ''

  for j, k in enumerate(s):  # enumerate: インデックス番号，　要素の順番に取得可能
    # print(k)
    x += k
    if j != n and p[j] == '1':
      x += '+'
      # print(x)

  # print(x)
  ans += eval(x)

print(ans)




Measured memory_bytes: 39280
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

#define INF 999999

bool f;
int tim[10][2], num[10][2],M,N,T,L;

int GetParkPos(int t)
{
	for(int i=0; i<M; i++)
	{
		if(tim[i][0]==0&&tim[i][1]==0) return i;
	}
	
	int pos=-1;
	int dif=INF;
	for(int i=0; i<M; i++)
	{
		if(tim[i][0]!=0&&tim[i][1]!=0) continue;
		int tm=(tim[i][0]==0?tim[i][1]:tim[i][0]);
		if(tm>t&&tm-t<dif)
		{
			dif=tm-t;
			pos=i;
		}
	}
	
	if(pos!=-1) return pos;
	
	for(int i=0; i<M; i++)
	{
		if(tim[i][0]!=0&&tim[i][1]!=0) continue;
		int tm=(tim[i][0]==0?tim[i][1]:tim[i][0]);
		if(t-tm<dif)
		{
			dif=t-tm;
			pos=i;
		}
	}
	
	return pos;
}

void Parking(int pos, int t, int n)
{
	if(tim[pos][0]!=0)
	{
		tim[pos][1]=tim[pos][0];
		num[pos][1]=num[pos][0];
	}
	
	tim[pos][0]=t;
	num[pos][0]=n;
}

void Leaving()
{
	for(int i=0; i<M; i++)
	for(int j=0; j<2; j++)
	{
		if(j==1&&tim[i][0]!=0) break;
		if(tim[i][j]==0) continue;
		
		if(tim[i][j]<=T)
		{
			if(f) printf(" ");
			f=true;
			printf("%d", num[i][j]+1);
			tim[i][j]=0;
			num[i][j]=0;
			L--;
		}
	}
}

int main()
{
	while(scanf("%d%d", &M, &N), (M||N))
	{
		memset(tim, 0, sizeof(tim));
		memset(num, 0, sizeof(num));
		
		int car[100];
		for(int i=0; i<N; i++)
			scanf("%d", &car[i]);
			
		int cnt=0;
		L=N;
		T=0;
		f=false;
		queue<int> q;
		while(L)
		{
			Leaving();
			if(T%10==0 && cnt<N)
			{
				q.push(cnt);
				cnt++;
			}
			while(!q.empty())
			{
				int n=q.front();
				int p=GetParkPos(T+car[n]);
				if(p==-1) break;
				
				Parking(p, T+car[n], n);
				q.pop();
			}
			
			T++;
		}
		
		puts("");
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s1,s2;
    cin>>s1>>s2;
    int count=0;
    while (1) {
        if (s1==s2) {
            cout<<"Yes"<<endl;
            break;
        } else if (count>10000000) {
            cout<<"No"<<endl;
            break;
        } else {
            char tmp=s1.at(s1.size()-1);
            s1.erase(s1.size()-1);
            s1=tmp+s1;
            count++;
        }
    }
}


Measured memory_bytes: 256
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
hit = [[False] * 3 for _ in range(3)]

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                hit[i][j] = True

bingo = False

for i in range(3):
    if hit[0][i] and hit[1][i] and hit[2][i]:
        bingo = True
    elif hit[i][0] and hit[i][1] and hit[i][2]:
        bingo = True

if hit[0][0] and hit[1][1] and hit[2][2]:
    bingo = True
elif hit[0][2] and hit[1][1] and hit[2][0]:
    bingo = True

print("Yes" if bingo else "No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N) {}

void solve(void)
{
  string s; cin >> s;
  int N = s.size();

  vector<vector<int>> dp(N+1, vector<int>(13, 0));
  dp[0][0] = 1;
  for (int i = 1; i < (int)dp.size(); ++i) {
    int begin, end;
    if (s[i-1] == '?') {
      begin = 0;
      end = 10;
    } else {
      begin = s[i-1] - '0';
      end = begin + 1;
    }

    for (int j = 0; j < 13; ++j) {
      for (int k = begin; k < end; ++k) {
        auto nj = (j * 10 + k) % 13;
        dp[i][nj] += dp[i-1][j];
        dp[i][nj] %= MOD;
      }
    }
  }

  auto ans = dp[N][5];
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

int n,m,a[300][300],ans=999;
bool ok[301];

int main(){
    cin>>n>>m;
    rep(i,n)rep(j,m)cin>>a[i][j];
    rep(k,m){
        int x[301]={};
        rep(i,n){
            int j=0;
            while(ok[a[i][j]])j++;
            x[a[i][j]]++;
        }
        int X=1;
        for(int i=1;i<=m;i++){
            if(x[X]<x[i])X=i;
        }
        ans=min(x[X],ans);
        ok[X]=1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>


int main(int argc, char* argv[])
{
	using std::cin;
	using std::cout;
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, D;
	cin >> N >> D;
	std::vector<std::vector<int>> X(N, std::vector<int>(D));

	for (auto& xi : X)
	{
		for (auto& xij : xi)
		{
			cin >> xij;
		}
	}

	int res = 0;
	for (int i = 0; i < N; ++i)
	{
		const auto& xi = X[i];
		for (int j = i+1; j < N; ++j)
		{
			const auto& xj = X[j];
			int d = 0;
			for (int l = 0; l < D; ++l)
			{
				d += (xj[l] - xi[l])*(xj[l] - xi[l]);
			}
			const int sq = std::sqrt(d);
			if (sq*sq == d) ++res;
		}
	}
	cout << res << std::endl;

	return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String s = scan.next();

		ArrayList<String> hitatiList = new ArrayList<>();
		String anser = "No";

		//日立文字の作成
		for (int i = 0; i < 5; i++) {
			String hitati = "";

			for (int j = 0; j <= i; j++) {
				hitati += "hi";
			}
			hitatiList.add(hitati);
		}

		for (String str : hitatiList) {
			if (s.equals(str)) {
				anser = "Yes";
			}
		}
		System.out.println(anser);
	}

}


Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef struct aa
{
    int x,y;
    int n;
} num;
int cmp(num a,num b)
{
//    int maxa,maxb,t1,t2;
//    maxa=max(a.x,a.y); maxb=max(b.x,b.y);
//   t1=a.x+a.y-maxa;
//   t2=b.x+b.y-maxb;
//   if(maxa>maxb)return 1;
//   else if(maxa==maxb)
//   {
//       return t1>t2;
//   }
//   else
//    return 0;
return a.n<b.n;

}
int main()
{
    int n;
    num a[205],b[205];
    int book2[205];
    memset(book2,0,sizeof(book2));
    cin>>n;
    for(int i=0; i<n; i++)
      {
            cin>>a[i].x>>a[i].y;
            a[i].n=0;
      }
    for(int i=0; i<n; i++)
      {
           cin>>b[i].x>>b[i].y;
           b[i].n=0;
      }

        for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(a[i].x < b[j].x && a[i].y < b[j].y)
			{
				a[i].n++;
				b[j].n++;
			}
		}
	}



    sort(a,a+n,cmp);
    sort(b,b+n,cmp);
//    for(int i=0;i<n;i++)  printf("%d,,%d\n",b[i].x,b[i].y);
//    printf("\n");
//    for(int i=0;i<n;i++)  printf("%d,,%d\n",a[i].x,a[i].y);
    int i,j,ans=0;
    for(i=0; i<n; i++)
    {
        for(j=0;j<n; j++)
        {
//            printf("==%d,%d\n",a[i].x,  a[i].y);
//                printf("==%d,%d\n",b[j].x,b[j].y);
            if(a[i].x<b[j].x && a[i].y<b[j].y && book2[j]==0 )
            {
                ans++;
                book2[j]=1;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n, m = MAP()
h = LIST()
flag = [1 for _ in range(n)]
for i in range(m):
    a, b = MAP()
    if h[a - 1] > h[b - 1]:
        flag[b - 1] = 0
    elif h[a - 1] < h[b - 1]:
        flag[a - 1] = 0
    else:
        flag[a - 1] = 0
        flag[b - 1] = 0
print(sum(flag))

Measured memory_bytes: 90280
#include<stdio.h>
int main(void){
char s[3];
  int ans=0,max=0;
  scanf("%s",&s);
	for(int i=0;i<3;i++){
	if(s[i]=='R'){
      ans++;
    }
     else{
          if(ans>=max)max=ans;
      ans=0;
     }
    }
  if(ans>=max)max=ans;
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 1708
// C++11
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iostream>
#include <numeric>
#include <random>
#include <vector>
#include <set>
#include <unordered_set>

using namespace std;

#define LOCAL 1

#if LOCAL
#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl
#else
#define pv(val)
#define pvn(name, val)
#define pl
#endif

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
  if (vec.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
    os << vec.back() << '}';
  }
  return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
  if (arr.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
    os << arr.back() << '}';
  }
  return os;
}


int main(void)
{
  int in[3];
  cin >> in[0] >> in[1] >> in[2];
  sort(in, in+3);

  int ans = 0;
  ans += in[2] - in[1];
  in[0] += ans, in[1] += ans;
  if((in[1] - in[0]) % 2 == 0) ans += (in[1] - in[0]) / 2;
  else ans += (in[1] + 1 - in[0]) / 2 + 1;

  cout << ans << endl;

  return 0;
}


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

typedef unsigned long long ull;

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

ull lcm(ull a, ull b)
{
    ull temp = gcd(a, b);

    return temp ? (a / temp * b) : 0;
}

int main()
{
    ull a, b, c, d;
    cin >> a >> b >> c >> d;
    ull cd = lcm(c, d);

    ull cstart, dstart, cdstart;
    ull cdiff = 0, ddiff = 0, cddiff = 0;

    if (c > b && d > b)
    {
        cout << b-a+1 << endl;
        return 0;
    }
    
    cstart = c*((a-1)/c) + c;
    if (cstart <= b) cdiff = b/c - cstart/c + 1;

    dstart = d*((a-1)/d) + d;
    if (dstart <= b) ddiff = b/d - dstart/d + 1;
    
    cdstart = cd*((a-1)/cd) + cd;
    if (cstart <= b) cddiff = b/cd - cdstart/cd + 1;

    //a % c  == 0 ? cstart  = a : cstart  =  c*(a-1/c)  + c;
    //a % d  == 0 ? dstart  = a : dstart  =  d*(a-1/d)  + d;
    //a % cd == 0 ? cdstart = a : cdstart = cd*((a/cd) + 1);
    //cdstart <= b ? cddiff = ((b-cdstart)/cd) + 1 : cddiff = 0;

    ull total = (b-a+1) - ddiff - cdiff + cddiff;
    cout << total << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


int main(){long N;
cin >> N;
vector<long> vec(N+1);
erep(i, N){
    cin >> vec[i];
}
sort(eall(vec));
long sum = 0;
vec[N] = vec[N] / 2;
erep(i, N){
    sum += vec[i];
}









cout << sum << endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;

int main(){
	int a[10002],b[10002],i,j=0,ans1[10000],ans2[10000];
	int A=0,B=0,n;
	cin>>n;
	while(n!=0){
		for(i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		for(i=0;i<n;i++){
			if(a[i]>b[i]){
				A+=(a[i]+b[i]);
			}else if(a[i]<b[i]){
				B+=(a[i]+b[i]);
			}else{
				A+=a[i];B+=b[i];
			}
		}
		ans1[j]=A;ans2[j]=B;
		j++;A=0;B=0;
		cin>>n;
	}
	for(i=0;i<j;i++){
		cout<<ans1[i]<<' '<<ans2[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1248
from collections import deque

N=int(input())
E={i:set() for i in range(1,N+1)}
F=[0]*(N+1)

H=[0]*(N-1)
J={}
for s in range(N-1):
    a,b=map(int,input().split())
    E[a].add(b)
    E[b].add(a)
    F[a]+=1
    F[b]+=1
    H[s]=(a,b)
    J[(a,b)]=s

M=max(F)

C=[0]*(N-1)
G=[set() for _ in range(N+1)]
A=[-1]*(N+1)

T={i:False for i in range(1,N+1)}
T[1]=True
Q=deque([1])
while Q:
    v=Q.popleft()
    y=1
    for w in E[v]:
        if not T[w]:
            T[w]=True
            Q.append(w)
            
            p,q=min(v,w),max(v,w)

            c=(A[v]+y)%M
            
            A[w]=c
            C[J[(p,q)]]=c
            G[p].add(c)
            G[q].add(c)
            y+=1

print(max(C)+1)
print("\n".join(map(lambda x:str(x+1),C)))



Measured memory_bytes: 170392
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
    int h, w, d;
    cin >> h >> w >> d;

    vector<pair<int, int> > locate(h * w);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int input;
            scanf("%d", &input);
            input--;
            locate[input].first = i;
            locate[input].second = j;
        }
    }

    int q;
    cin >> q;

    vector<int> l(q);
    vector<int> r(q);
    for (int i = 0; i < q; i++) {
        scanf("%d %d", &l[i], &r[i]);
        l[i]--; r[i]--;
    }

    vector<int> mp_sum(h * w);
    for (int i = 0; i < d; i++) {
        mp_sum[i] = 0;
        for (int j = i; j + d < h * w; j = j + d) {
            int mp = abs(locate[j].first - locate[j+d].first)
                    + abs(locate[j].second - locate[j+d].second);
            mp_sum[j + d] = mp_sum[j] + mp;
        }
    }

    for (int i = 0; i < q; i++) {
        cout << mp_sum[r[i]] - mp_sum[l[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>

int main()
{
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    int min = a+b;

a +=c;
b+= c;

if(min > a)
min = a;

if(min>b)
min = b;

    printf("%d\n",min);
        
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int N;
	cin >> N;
	int t[N+1];
	int x[N+1];
	int y[N+1];
	x[0] = y[0] = t[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> t[i];
		cin >> x[i];
		cin >> y[i];
	}


	int ans;
	for (int i = 1; i <= N; i++) {
		ans = abs(x[i] + y[i] - x[i-1] - y[i-1]);
		if (t[i] - t[i - 1] < ans || (ans - t[i] - t[i - 1]) % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);

int main(){
    int n, k;
    cin>>n>>k;
    int arr[n];
    ip(arr, n);

    int dp[k+1];
    for(int i=0; i<=k; i++) dp[i]=2;
    //dp[i] -> agr i stone remove karna hai toh jo phela chalega(1) voh jeetga ya dusara vala(2)
    // hence dp[i] -> ki val either 1/2


    for(int i=1; i<=k; i++){
        for(int j=0; j<n; j++){
            if(i-arr[j] < 0) continue;
            
            // check if current k mein se arr[i] hta de toh jitna stone bachenge 
            // that is dp[i-arr[i]], agr iski val 2 hai toh jo iss state par pheli bar aeyga voh harega and second jeetage
            // qki dono optimially khel rahe hai toh first chaheyga ki voh second person ko aise state par beja
            // jha second win hota hoo taki first win kar sake
            if(dp[i-arr[j]]==2){
                dp[i]=1;
            }
        }
    }
    if(dp[k] == 2) cout<<"Second\n";
    else cout<<"First\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int ans = 0;
    REP(i,s.size()){
        if(i % 2 == 0 && s[i] == 'p'){
            ans--;
        }else if(i % 2 == 1 && s[i] == 'g'){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
iN,iA =[int(x) for x in input().split()]
aX = [int(x) - iA for x in input().split()]

#解法2

iMX = max(aX + [iA])
dp = [[0]*(2 * iN*iMX + 1) for _ in range(iN+1)]

for j in range(0,iN+1):
    for t in range(0,2*iN*iMX):
        if j == 0 and t == iN * iMX :
            dp[j][t] = 1
        elif j >= 0 and ( t - aX[j-1] < 0 or t - aX[j-1] > 2*iN*iMX):
            dp[j][t] = dp[j-1][t]
        elif j >= 0 and ( 0 <= t - aX[j-1] <= 2*iN*iMX):
            dp[j][t] = dp[j-1][t] + dp[j-1][t-aX[j-1]]
        else:
            dp[j][t] = 0
print(dp[iN][iN*iMX] -1 )


Measured memory_bytes: 5228
from decimal import getcontext, Decimal
getcontext().prec = 1

N = int(input())
if N % 2 == 1:
	print(0)
else:
	ans = 0
	if N <= 9:
		pass
	else:
		ans += N//10
		N //= 10
		while N >= 5:
			ans += N//5
			N //= 5
	print(ans)

Measured memory_bytes: 5076
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

int main(){

  int n = in();
  vector<ld> p(n);
  REP(i, n){
    p[i] = fin();
  }
  vector<vector<ld>> dp(n + 1, vector<ld>(n + 1, 0));
  dp[0][0] = 1;
  REP(i, n){
    REP(j, n){
      dp[i + 1][j + 1] += dp[i][j] * p[i];
      dp[i + 1][j] += dp[i][j] * (1 - p[i]);
    }
  }
  ld ans = 0;
  REP(i, n + 1){
    int j = n - i;
    if(i > j){
      ans += dp[n][i];
    }
  }

  printf("%.18lf\n", (double)ans);
  
  return 0;
}


Measured memory_bytes: 141056
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n = sc.nextInt()
  var ans = Array.fill(200050)(0)
  var a = 17
  for (i <- 1 to 105){
    for (j <- 1 to 105) {
      for (k <- 1 to 105) {
        ans((i*i+j*j+k*k+i*j+j*k+k*i)-1)+=1
      }
    }
  }
  for (i <- 0 until n){
    println(ans(i))
  }
}


Measured memory_bytes: 58084
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll N;
    cin >> N;
    cout << 800 * N - 200 * (N/15) << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A_array = list(map(int, input().split()))
BC_array = [list(map(int, input().split())) for _ in range(M)]
BC_array = sorted(BC_array, key=lambda x: -x[1])
B_count = 0
for B, C in BC_array:
    for i in range(B):
        A_array.append(C)
    B_count += B
    if B_count >= N:
        break
A_array.sort()
# print(A_array)
print(sum(A_array[-N:]))

Measured memory_bytes: 91544
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,W;
    cin>>n>>W;
    long long dp[n+1][W+1],i,j,w[n],v[n];
    for(i=0;i<n;i++)
        cin>>w[i]>>v[i];
    for(i=0;i<=n;i++)
        for(j=0;j<=W;j++)
            {
                if(i==0||j==0)
                    dp[i][j]=0;
                else if(j-w[i-1]>=0)
                    dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            
                else
                    dp[i][j]=dp[i-1][j];
            }
    cout<<dp[n][W];
    
}

Measured memory_bytes: 79104
#include <iostream>

using namespace std;

int main() {
 	long long x;
  	cin >> x;
  	long long y = 0;
  	if (x >= 11) {
    	y += x / 11 *2;
    }
	if (x % 11 == 0) {
    } else if (x % 11 <= 6) {
    	y += 1;
    } else {
    	y += 2;
    }
  	cout << y;
  	return 0;
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 100;
const int M = 20;
int a[N];
ll dp[N][M+1];
int n;

int main() {
  int i, j;
  scanf("%d ", &n);
  for (i=0; i<n; i++) scanf("%d ", a+i);
  memset(dp, 0LL, sizeof(dp));
  dp[0][a[0]] = 1LL;
  for (i=1; i<=n-2; i++)
    for (j=0; j<=M; j++) {
      if (j-a[i]>=0) dp[i][j]  = dp[i-1][j-a[i]]; 
      if (j+a[i]<=M) dp[i][j] += dp[i-1][j+a[i]]; 
    }

  printf("%lld\n", dp[n-2][a[n-1]]);

	return 0;
}

Measured memory_bytes: 1220
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let a: Vec<i32> = parse_line().unwrap();
    let mut ans: Vec<usize> = vec![0; n];

    for i in 0..n {
        ans[(a[i] - 1) as usize] = i + 1;
    }
    println!(
        "{}",
        ans.iter()
            .map(|&x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}


Measured memory_bytes: 9200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/*
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define md(l, r) l + (r - l) / 2
#define ll long long
#define btw(a, l, r) a.begin() + l, a.begin() + r + 1
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int(x.size()))
#define sqr(x) (x) * (x)
#define endl '\n'

#define getfiles ifstream cin("input.txt"); ofstream cout("output.txt");
#define clr(x, y) memset((x), (y), sizeof (x))
#define ld long double

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<vector<pair<int, int> > > vvpii;
typedef pair<int, pair<int, int> > piii;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef vector<pair<ll, pair<ll, ll> > > vplll;

const ld eps = -1e9;
const long long N = 200001, P = 1e9 + 7, P1 = 1e9 + 13, iINF = INT_MAX, INF = 2e9, K = 73, K1 = 79;

ll dstF(ll x, ll y, ll xx, ll yy) {
    return (sqr(x - xx) + sqr(y - yy));
}

ld dstSqrtF(ll x, ll y, ll xx, ll yy) {
    return (sqrt(sqr(x - xx) + sqr(y - yy)));
}

ll _bp(ll val, ll st, ll p) {
    if (st == 0) {
        return 1;
    }
    ll temp = _bp(val, st / 2, p);
    temp = sqr(temp);
    temp %= p;
    if (st % 2 == 1) {
        temp *= val;
        temp %= p;
    }
    return temp;
}

ll _bp(ll val, ll st) {
    if (st == 0) {
        return 1;
    }
    ll temp = _bp(val, st / 2);
    temp = sqr(temp);
    if (st % 2 == 1) {
        temp *= val;
    }
    return temp;
}

ll nok(ll a, ll b) {
    return (a / __gcd(a, b) * b);
}

/*
ll fact[N];

void buildFacts(ll n, ll p) {
    fact[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = (fact[i - 1] * i) % p;
    }
}

ll C(ll n, ll k, ll p = -1) {
    if (p == -1) {
        ll x = fact[n];
        ll y = (fact[k] * fact[n - k]);
        return (x / y);
    } else {
        ll x = fact[n];
        ll y = (fact[k] * fact[n - k]) % p;
        x = (x * _bp(y, p - 2, p)) % p;
        return x;
    }
}
*/

ll n, f[10001000], ans = 0;

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int i1 = i; i1 <= n; i1 += i) {
            f[i1]++;
        }
    }
    for (int i = 1; i <= n; i++) {
        ans += (i * f[i]);
    }
    cout << ans;
}

signed main() {
    fast_io;
    int q;
    q = 1;
    //cin >> q;
    while (q != 0) {
        solve();
        --q;
    }
}

/*
adsdads
*/



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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	map <string, bool> mp;
	int n;
	cin >> n;
	string s[n];
	for (int  i = 0; i < n; i++){
		cin >> s[i];
		mp[s[i]] = true;
	}
	int ans = 0;
	for (int i = 0; i < n; i++){
		if (mp[s[i]]){
			ans ++;
			mp[s[i]] = false;
		}
	}
	cout << ans;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
ll const inf = 3e15;

int main() {

  int N, W; cin >> N >> W;
  int v[N], w[N];
  rep(i, N) {
    cin >> v[i] >> w[i];
  }

  static ll dp[111][111*111];
  rep(i, 111) rep(j, 111*111)
    dp[i][j] = inf;

  dp[0][0] = 0;

  rep(i, N) {
    rep(j, 100*100+10) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      dp[i + 1][j + v[i]] = min(dp[i][j + v[i]], dp[i][j] + w[i]);
    }
  }

  int max = 0;

  rep(i, 100*100+10) {
    if(dp[N][i] <= W)
      max = std::max(max, i);
  }

  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 13756