akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }
const int INF = 1000000000;

struct UnionFind
{
    vi par;
    vi sizes;

    UnionFind(int n) : par(n), sizes(n,1){
        rep(i,0,n) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return;
        if(sizes[x]<sizes[y]) swap(x,y);
        par[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sizes[find(x)];
    }

};

int main(){
    ll N,M; cin>>N>>M;
    ll a[M],b[M];
    rep(i,0,M){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    } 
    UnionFind uf(N);
    ll rec=N*(N-1)/2;
    ll ans[M+1];
    ans[M]=rec;
    for(int i=M-1;i>=0;i--){
        if(uf.same(a[i],b[i])) ans[i]=rec;
        else{
            rec-=uf.size(a[i])*uf.size(b[i]);
            uf.unite(a[i],b[i]);
            ans[i]=rec;
        }
    }
    rep(i,1,M+1) cout<<ans[i]<<endl;

}

Measured memory_bytes: 4480
import Control.Monad
import Data.Maybe (fromJust)
import Data.List
import Data.Char

solve :: Integer -> Integer -> Integer -> Integer
solve a b x = ans
    where
        a1 = (a `div` x) * x
        a2 = if (a `mod` x) == 0 then a1 else a1 + 1
        b1 = (b `div` x) * x
        ans = ((b1 - a2) `div` x) + 1

main :: IO ()
main = do
    [a,b,x] <- map (read) . words <$> getLine :: IO [Integer]
    print $ solve a b x


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int da=max(a,b)-min(a,b),db=max(a,c)-min(a,c);
  if(da<db) cout << "A" << endl;
  else cout << "B" << endl;
}

Measured memory_bytes: 256
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.weight = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


n, m = map(int, input().split())
lrd = []
for i in range(m):
    l, r, d = map(int, input().split())
    lrd.append((l - 1, r - 1, d))

wuf = WeightedUnionFind(n)

for item in lrd:
    if wuf.same(item[0], item[1]):
        if wuf.diff(item[0], item[1]) != item[2]:
            print('No')
            exit()
    else:
        wuf.union(item[0], item[1], item[2])

print('Yes')


Measured memory_bytes: 124120
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    int cx = 0, cy = 0;
    int ct = 0;
    REP(i, n)
    {
        int t, x, y;
        cin >> t >> x >> y;
        int dist = abs(x - cx) + abs(y - cy);
        int dt = t - ct;
        if (not(dt >= dist and (dt - dist) % 2 == 0))
        {
            Yes(0);
            return 0;
        }
        cx = x;
        cy = y;
        ct = t;
    }
    Yes(1);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char s[10000];
    cin >> s;
    int j =0;
    while(s[j] != '\0')
        j++;
    int l = j;
    int check = 0;
    rep(i,l){
        if(check == 0  && s[i] == 'C')
            check ++;
        if(check == 1 && s[i] == 'F')
            check++;
    }
    if(check == 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  ll x, y;
  cin >> x >> y;
  int ans = 1;
  while((x = x << 1) <= y) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
N,L,T = LI()
X = []
W = []
for _ in range(N):
    x,w = LI()
    X.append(x)
    W.append(1 if w == 1 else -1)

# 最終の位置計算
Y = []
for i in range(N):
    y = (X[i] + T * W[i]) % L
    Y.append(y)

# 蟻1が何回すれ違うか
r = T // L
m = T % L

kai = r * W.count(-W[0]) * 2

# m秒以内にすれ違う蟻
for i in range(1,N):
    if W[0] != W[i]:
        d = ((X[i] - X[0]) * W[0]) % L
        if d < m * 2:
            kai += 1
            if (L - d) < (m - d) * 2:
                kai += 1

# Y[0]のNoを求める
Num = (kai * W[0]) % N

# Yをソート
y0 = Y[0]
Y.sort()
p = Y.index(y0)
if W[0] > 0:
    p = bisect.bisect_left(Y,y0)
else:
    p = bisect.bisect_right(Y, y0) - 1
s = (p-Num) % N

for _ in range(N):
    print (Y[s])
    s = (s + 1) % N



Measured memory_bytes: 60120
#include<iostream>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if((x-r)>=0 && (y-r)>=0 && (x+r)<=W && (y+r)<=H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main() {
        int n;
        scanf("%d", &n);
        vector<int> c(n);
        rep(i, n) {
                scanf("%d", &c[i]);
                c[i] --;
        }
        vector<int> pos(2 * 1e5, -1);
        vector<long long> dp(n);
        dp[0] = 1;
        pos[c[0]] = 0;
        const int mod = 1e9 + 7;
        for (int i = 1; i < n; i ++) {
                dp[i] = dp[i - 1];
                if (pos[c[i]] != -1 && c[i] != c[i - 1]) {
                        (dp[i] += dp[pos[c[i]]]) %= mod;
                }
                pos[c[i]] = i;
        }
        printf("%lld\n", dp[n - 1]);
        return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = ReadInts();
            double ans = 0;
            for (int i = 1; i <= nk[0]; i++)
            {
                double tmp = 1.0 / nk[0];
                int now = i;
                while (now < nk[1])
                {
                    now *= 2;
                    tmp /= 2;
                }
                ans += tmp;
            }
            WriteLine(ans);
        }
        public static int x(long k, long a)
        {
            var ans = 0;
            while (true)
            {
                ans++;
                a = a * 2;
                if (k < a)
                {
                    return ans;
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 11092
x = 0
mask = 2**64 - 1
def test(i):
    global x
    print(+((x & (1 << i)) != 0))
def Set(i):
    global x
    x |= 1 << i
def clear(i):
    global x
    x &= mask - (1 << i)
def flip(i):
    global x
    x ^= 1 << i
def all():
    global x
    print(+(x == mask))
def any():
    global x
    print(+(x != 0))
def none():
    global x
    print(+(x == 0))
def count():
    global x
    print(bin(x).count('1'))
def val():
    global x
    print(x)
    
f = [test, Set, clear, flip, all, any, none, count, val].__getitem__
for _ in range(int(input())):
    op, *i = map(int, input().split())
    f(op)(*i)


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

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

    int N, K;
    cin >> N >> K;
    map<int, int> mp;
    for (int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int A;
            cin >> A;
            mp[A]++;
        }
    }
    cout << N - mp.size() << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
using namespace std; 

int func(int n){
	if(n%2==0) return n/2;
	return 3 * n + 1;
}

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

	int sum = 0;
	int max = 0;

	for(int i = 0; i < N; i++){
        int tmp;
		cin >> tmp;
		if(max < tmp) max = tmp;
		sum += tmp;
	}

	cout << sum - max/2 << endl;
}

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

int main(){
  ll n,l;
  cin >> n >> l;
  vector<ll>a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  
  int start=0;
  for(int i=0; i<n-1; i++) {
    if(a[i]+a[i+1]>=l){
      start=i+1;
      break;
    }
  }
  
  if(start==0){
    cout << "Impossible" << endl;
    return 0;
  }
  
  cout << "Possible" << endl;
  for(int i=1; i<start; i++) cout << i << endl;
  for(int i=n-1; i>start; i--) cout << i << endl;
  cout << start << endl;
  
}
  
  
  
  


Measured memory_bytes: 1664
<?php

$n = fgets(STDIN);
$a = explode(' ', fgets(STDIN));

$reigai = 1000000000000000000;
$multi = 1;
foreach ($a as $hoge) {
    if ((int)$hoge == 0) {
        echo 0;
        return;
    }
}

foreach ($a as $hoge) {
    $multi = $multi * (int)$hoge;
    if ($reigai < $multi) {
        echo -1;
        return;
    }
}
echo $multi;


Measured memory_bytes: 25648
#include<iostream>
using namespace std;
int bubbleSort(int arr[],int n)
{
   int times = 0;
   for(int i = 0;i<n;i++)
    for(int j = n-1;j>i;j--)
        if(arr[j]<arr[j-1])
        {
            int temp = arr[j];
            arr[j] = arr[j-1];
            arr[j-1] = temp;
            times++;
        }
    return times;
}
void show(int arr[],int n)
{
    for(int i = 0;i< n;i++)
    {
        cout<<arr[i];
        if(i<n-1)
            cout<<" ";
    }
    cout<<endl;
}
int main()
{
    int n;
    cin>>n;
    int *arr = new int[n+1];
    for(int i = 0;i<n;i++)
        cin>>arr[i];
    int times = bubbleSort(arr,n);
    show(arr,n);
    cout<<times<<endl;
    return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<(n);i++)
#define end(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){
    
    int i,j,n,m,c;
    cin>>n>>m>>c;
    int b[m],a[n][m],ans=0,sum;
    for(i=0;i<m;i++)cin>>b[i];
    for(i=0;i<n;i++)for(j=0;j<m;j++)cin>>a[i][j];
//    for(i=0;i<n;i++)for(j=0;j<m;j++)cout<<a[i][j]<<endl;;
    
    for(i=0;i<n;i++){//a決め 
    	sum=0;
		for(j=0;j<m;j++){
    		sum+=a[i][j]*b[j];
		}
//		cout<<sum<<endl;
		if(sum+c>0)ans++;
	}
    cout<<ans<<endl;
    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    
    cout << (n*(n-1))/2;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<i64>();
    let n = v[0];
    let k = v[1];

    if k % 2 !=0 {
        let ks = n / k;
        println!("{}", ks*ks*ks);
    } else {
        let ks = n / k;
        let ks_rem = {
            if n >= (n/k) * k + k / 2 {
                n / k + 1
            } else {
                n / k
            }
        };
        println!("{}", ks*ks*ks+ks_rem*ks_rem*ks_rem);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define LL long long
#define db long double

using namespace std;
const int N=1e6+10,inf=1e9;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int to[N],nt[N],c[N],hd[N],tot=1;
void adde(int x,int y,int z)
{
    ++tot,to[tot]=y,nt[tot]=hd[x],c[tot]=z,hd[x]=tot;
    ++tot,to[tot]=x,nt[tot]=hd[y],c[tot]=0,hd[y]=tot;
}
int ps,pt,lv[N],nhd[N];
queue<int> q;
bool bfs()
{
    memset(lv,0,sizeof(int)*(pt+1));
    lv[ps]=1,q.push(ps);
    while(!q.empty())
    {
	int x=q.front();
	q.pop();
	for(int i=hd[x];i;i=nt[i])
	{
	    int y=to[i];
	    if(c[i]>0&&!lv[y])
		lv[y]=lv[x]+1,q.push(y);
	}
    }
    return lv[pt];
}
int dfs(int x,int fw)
{
    if(x==pt) return fw;
    int an=0;
    for(int &i=nhd[x];i;i=nt[i])
    {
	int y=to[i];
	if(c[i]>0&&lv[y]==lv[x]+1)
	{
	    int dt=dfs(y,min(c[i],fw));
	    c[i]-=dt,c[i^1]+=dt;
	    fw-=dt,an+=dt;
	    if(!fw) break;
	}
    }
    return an;
}
int dinic()
{
    int an=0;
    while(bfs())
    {
	memcpy(nhd,hd,sizeof(int)*(pt+1));
	an+=dfs(ps,inf);
    }
    return an;
}
int n,an[N][2],ta,fe[N],mat[N],mk[N];
bool v[N];
void dd(int x)
{
    v[x]=1;
    for(int i=hd[x];i;i=nt[i])
    {
	int yy=to[i]-n,y=mat[to[i]];
	if(!y||v[y]||c[i]) continue;
	++ta,an[yy][0]=x,an[yy][1]=y;
	dd(y);
    }
}

int main()
{
///
    n=rd();
    ps=0,pt=n+n;
    for(int i=1;i<n;++i)
    {
	adde(ps,i+n,1);
	int t=rd();
	while(t--) adde(i+n,rd(),1);
    }
    for(int i=1;i<=n;++i) adde(i,pt,1),fe[i]=tot;
    if(dinic()<n-1){puts("-1");exit(0);}
    for(int i=1;i<n;++i)
    {
	for(int j=hd[i+n];j;j=nt[j])
	{
	    int y=to[j];
	    if(!c[j]&&y>=1&&y<=n){mat[i+n]=y,mk[y]=1;break;}
	}
    }
    int rt=1;
    while(mk[rt]) ++rt;
    dd(rt);
    if(ta<n-1){puts("-1");return 0;}
    for(int i=1;i<=ta;++i) printf("%d %d\n",an[i][0],an[i][1]);
    return 0;
}
 


Measured memory_bytes: 33536
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	seconds := nextInt(sc)
	fmt.Println(formatTime(seconds))
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func formatTime(seconds int64) string {
	a := seconds / 60
	h := a / 60
	m := a - h*60
	s := seconds - m*60 - h*3600
	return fmt.Sprintf("%d:%d:%d", h, m, s)
}



Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m; cin >> n >> m;
    vector<vector<int>> s(m);
    rep(i, m)
    {
        int k; cin >> k;
        rep(j, k)
        {
            int a; cin >> a; --a;
            s[i].push_back(a);
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];

    ll res = 0;
    rep(bit, 1<<n)
    {
        bool ok = true;
        rep(i, m)
        {
            int c = 0;
            for (auto v : s[i])
            {
                if (bit >> v & 1) c++;
            }
            if (c % 2 != p[i]) ok = false;
        }
        if (ok) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 384
a, b, n = map(int,input().split())
for i in range(a, a + n + 1):
    if i > b - n:
        break
    if i <= a + n - 1:
        print(i)
    
for j in range(b - n, b + 1):
    if i > b:
        break
    if j >= b - n + 1 and a <= j:
        print(j)

Measured memory_bytes: 38768
#include <cstdio>
#include <cctype>
#include <map>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
	_typer init = 0;
	char ch = getchar(), k = 0;
	for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
	for ( ; isdigit(ch); ch = getchar()) init = (init << 3) + (init << 1) + (ch ^ 48);
	return k ? -init : init;
}
const ll N = 0, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

map < char, int > mp;

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	rep (i, 0, 3) {
		if (!mp[s[i]]) ++cnt;
		if (cnt > 2) {
			puts("No");
			return 0;
		}
		++mp[s[i]];
	}
	if (cnt < 2) {
		puts("No");
	} else puts("Yes");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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 / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll h, w, a, b;
    cin>>h>>w>>a>>b;


    for(ll i=0;i<b;++i){
        for(ll j=0;j<a;++j){
            cout<<1;
        }
        for(ll j=a;j<w;++j){
            cout<<0;
        }
        cout<<endl;
    }
    for(ll i=b;i<h;++i){
        for(ll j=0;j<a;++j){
            cout<<0;
        }
        for(ll j=a;j<w;++j){
            cout<<1;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;

  if (a1 + a2 + a3 >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;

  return 0;
}


Measured memory_bytes: 256
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
S = input()
T = []
c = 0
left = 0
right = 0
for s in S:
	if c == 0:
		if s == "R":
			left += 1
		else:
			c = 1
			right += 1
	else:
		if s == "R":
			T.append([left,right])
			left = 1
			right = 0
			c = 0
		else:
			right += 1
T.append([left,right])
Ans = [0]*len(S)
cur = 0
for t in T:
	Ans[cur+t[0]-1] += t[0]-int(t[0]/2)
	Ans[cur+t[0]] += int(t[0]/2)
	Ans[cur+t[0]] += t[1]-int(t[1]/2)
	Ans[cur+t[0]-1] += int(t[1]/2)
	cur += t[0]+t[1]
Ans = [str(a) for a in Ans]
print(" ".join(Ans))

Measured memory_bytes: 16272
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N, AC = 0, WA = 0, TLE = 0, RE = 0;
  cin >> N;
  REP(i, N) {
    string S;
    cin >> S;

    if (S == "AC")
      AC++;
    else if (S == "WA")
      WA++;
    else if (S == "TLE")
      TLE++;
    else
      RE++;
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int n,m;
    cin>>n>>m;
    int a[m][2];
    for(int i=0;i<m;i++)cin>>a[i][0]>>a[i][1];
    int l=a[0][0],r=a[0][1];
    for(int i=0;i<m;i++)
    {
        l=max(l,a[i][0]);
        r=min(r,a[i][1]);
    }
    cout<<max(0,r-l+1)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


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

int angka [10], brpkali, total;

int main (){
	for (int i=1; i<=3; i++){
		cin>>angka[i];
	}
	cin>>brpkali;
	for (int i=1; i<=3; i++){
		for (int j=1; j<=3; j++){
			if (j==i){
			}else if (angka [i]>angka [j]){			//sort;
				swap(angka [i], angka [j]);
			}
		}
	}
	for (int i=1; i<=brpkali; i++){				//multipy big num
		angka [1]*=2;
	}
	for (int i=1; i<=3; i++){					//sum total
		total+=angka [i];
	}
	cout<<total<<endl;
}

Measured memory_bytes: 3584
fun main(args:Array<String>) {
  val(n, k) = readLine()!!.split(" ").map{it.toInt()}
  val a = if (n % 2 == 0) {
    n / 2
} else {
  n / 2 + 1
}
  if (k <= a) {
    println("YES")
  } else {
    println("NO")
  }
}

Measured memory_bytes: 37924
//外積を使う

#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;

typedef struct{
	double x;
	double y;
}Vector;

Vector sub_vector(Vector a, Vector b){
	Vector ret;
	ret.x = a.x - b.x;
	ret.y = a.y - b.y;
	return ret;
}

int main(){
	
	Vector A, B, C,P;

	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &A.x,&A.y,&B.x,&B.y,&C.x,&C.y,&P.x,&P.y) != EOF){
		Vector AB = sub_vector(B, A);
		Vector BP = sub_vector(P, B);

		Vector BC = sub_vector(C, B);
		Vector CP = sub_vector(P, C);

		Vector CA = sub_vector(A, C);
		Vector AP = sub_vector(P, A);

		double c1 = AB.x * BP.y - AB.y * BP.x;
		double c2 = BC.x * CP.y - BC.y * CP.x;
		double c3 = CA.x * AP.y - CA.y * AP.x;

		if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 <0 && c2 < 0 && c3 < 0)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N, Z, W;
   cin >> N >> Z >> W;
   int a[N];
   for (int i = 0; i < N; i++) cin >> a[i];

   if (N == 1) cout << abs(a[0] - W) << endl;
   else {
      cout << max(abs(a[N - 1] - a[N - 2]), abs(a[N - 1] - W)) << 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;

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  k--;
  
  if(s.at(k) == 'A') s.at(k) = 'a';
  else if(s.at(k) == 'B') s.at(k) = 'b';
  else s.at(k) = 'c';
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

void solve() {
    string x, y;
    cin >> x >> y;
    ll lx = len(x), ly = len(y);
    vector<vector<ll>> dp(lx + 1, vector<ll>(ly + 1, 0));
    rep(i, lx) {
        rep(j, ly) {
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            if (x[i] == y[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
        }
    }
    cout << dp[lx][ly] << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll t;
    cin >> t;
    rep(i, t) solve();
    return 0;
}



Measured memory_bytes: 10840
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N,K,Q,A[100000+10]={},wa=0;
  cin >> N >> K >> Q;
  rep(i,Q){
    int a;
    cin >> a;
    A[a]++;
    wa++;
  }
  for(int i=1;i<=N;i++){
    wa-=A[i];
    wa+=A[i-1];
    if(K-wa<=0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num;
    cin >> num;
    array<int, 25> arr;
    for(int i=0;i<num;i++){
        cin >> arr[i];
    }
    
    int ans =0;
    for(int i=0;i<num-2;i++){
        if((arr[i]<arr[i+1])&&(arr[i+1]<=arr[i+2])){
            ans ++;
        }else if((arr[i+2]<arr[i+1])&&(arr[i+1]<=arr[i])){
            ans ++;
        }
    }

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

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int table[100][100];
int main(){
  int n,x,y,s,t;
  int w,h;
  while(cin >> n,n){
    memset(table, 0, sizeof(table));
    cin >> w >> h;
    //int table[w*2][h*2]={};
    rep(i,n) {
      cin >> x >> y;
      x--; y--;
      table[x][y]=1;
    }
    cin >> s >> t;
    int ans = 0;
    rep(i,w-s+1){
      rep(j,h-t+1){
        int count=0;
        for(int a=i; a<s+i; a++){
          for(int b=j; b<t+j; b++){
            if(table[a][b]==1) count++;
          }
        }
        ans = max(count,ans);
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3112
from operator import itemgetter

n = int(input())
sp = [[] for _ in range(n)]
for i in range(n):
    s, p = input().split()
    p = -int(p)
    sp[i] = [s, p, i + 1]

sp.sort(key=itemgetter(0, 1))
for i in range(n):
    print(sp[i][2])


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  string s, t;
  cin >> s >> t;
  string ta = t.substr(0, s.size());
  if (s == ta) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <numeric>
using ll = long long;
using namespace std;
ll mod=1e9;

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

//最大公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


int main(){

  int N,M;
  string S,T;
  cin>>N>>M>>S>>T;
  vector <pair<int,char>> tmp;
	ll ans = lcm(N,M);
  for (int i(0);i<N;i++){
    tmp.push_back({1+i*ans/N,S[i]});
  }
  for (int i(0);i<M;i++){
    tmp.push_back({1+i*ans/M,T[i]});
  }
  sort(tmp.begin(),tmp.end());
  for (int i(0);i<tmp.size()-1;i++){
    if (tmp[i].first == tmp[i+1].first && tmp[i].second != tmp[i+1].second) {
			//cout << tmp[i].first << " " << tmp[i].second << endl;
			//cout << tmp[i+1].first << " " << tmp[i+1].second << endl;
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2744
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

typedef long long int ll;

const int N = (int) 1e5 + 10;
const ll oo = 1e18;

int n;

void solve() {
  int ans = 0;
  cin >> n;
  for(int i = 1; i <= n; ++i) {
    int digits = 0;
    int x = i;
    while(x) {
      digits++;
      x /= 10;
    }
    ans += digits % 2;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  
  scanf("%d", &n);
  
  while(n>0){
    if(n%10 == 7){
      printf("Yes");
      break;
    }
    n = n/10;
  }
   
  if(n == 0)
    printf("No");
  
  return 0;
}


Measured memory_bytes: 1692
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [0] + [int(item) for item in input().split()] + [0]
    
    all_sum = 0
    prev = 0
    for i in range(N+2):
        all_sum += abs(As[i] - prev)
        prev = As[i]

    prev = As[0]
    for i in range(N):
        print(all_sum + abs(As[i] - As[i+2]) - (abs(As[i]-As[i+1]) + abs(As[i+1] - As[i+2])))

if __name__ == "__main__":
    resolve()


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

#define debug(x) cout << #x << " = " << x << endl

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> P;


int main(){
   int K,T;
   cin >> K >> T;
   int a[T];
   for(int i=0; i<T; i++) cin >> a[i];

   int cnt = 0;
   int prev1 = -1;
   for(int i=0; i<K; i++){
	  int Max = -1;
	  int nowprev1 = prev1;
	  for(int j=0; j<T; j++){
		 if(a[j] == 0 || prev1 == j)continue;
		 if(Max < a[j]){
			Max = a[j];
			nowprev1 = j;
		 }
	  }
	  if(prev1 == nowprev1) cnt++;
	  prev1 = nowprev1 ;
	  a[nowprev1]--;
   }
   cout << cnt << endl;
   return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final long MOD = 1000000007;
			
			int fst = 0, snd = 0, thd = 0;

			long answer = 1;
			
			for(int i = 0; i < N; i++) {
				final int val = sc.nextInt();
				
				if(fst == val && snd == val && thd == val) {
					fst += 1; answer *= 3; answer %= MOD;
				}else if(fst == val && snd == val) {
					fst += 1; answer *= 2; answer %= MOD;
				}else if(snd == val && thd == val) {
					snd += 1; answer *= 2; answer %= MOD;
				}else if(thd == val && fst == val) {
					fst += 1; answer *= 2; answer %= MOD;
				}else if(fst == val) {
					fst += 1;
				}else if(snd == val) {
					snd += 1;
				}else if(thd == val) {
					thd += 1;
				}else {
					answer = 0;
				}
			}

			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 34368
# Millennium

ans = []
n = int(input())
for j in range(n):
    y, m, d = map(int, input().split())
    day = 0

    for i in range(m, 11):
        if y % 3 == 0:
            day += 20
        else:
            if i % 2 == 0:
                day += 19
            else:
                day += 20
    day -= d


    for i in range(y + 1, 1000):

        if i % 3 == 0:
            day += 200
        else:
            day += 195

    ans.append(day + 1)

for i in ans:
    print(i)



Measured memory_bytes: 5608
// @author: Liz
 
#include <bits/stdc++.h>
using namespace std;
 
int k, s;
 
void solve(){
    int cnt = 0;

    for (int i = 0; i <= k; i++)
        for (int j = 0; j <= k; j++)
            if (i + j <= s && s <= k + i + j) cnt++;
 
    printf("%d\n", cnt);
}
 
int main(void){
    cin >> k >> s;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible\n";
    } else {
        cout << "Impossible\n";
    }
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(int(i+n/i-2))
    return divisors
ans = float("inf")
for i in make_divisors(int(input())):
    
    ans = min(ans,i)
print(ans)

Measured memory_bytes: 3060
# km + k = N
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


N = int(input())
i = 1
ans = 0
for i in make_divisors(N)[:-1]:
    m = ((N - i) // i)
    if N // m != N % m:
        break
    ans += m
print(ans)


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using i64 = long long int;

int main(){
    i64 cnt = 0;
    i64 n;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        if(i % 2) ++cnt;
    }
    cout << ((double)cnt) / (double(n)) << endl;
}

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

typedef long long ll;

#include <iostream>
#include <map>
#include <vector>
using namespace std;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

int main() {
  int n;
  cin >> n;
  vector<int> la(3*n);
  for (int i = 0; i < 3*n; ++i) {
    cin >> la[i];
  }
  priority_queue<int> que;
  ll sum = 0;
  vector<ll> left;
  for (int i = 0; i < 2*n; ++i) {
    if (i >= n) left.push_back(-sum);
    int a = -la[i];
    if (i < n) {
      sum += a;
      que.push(a);
    }
    else {
      int a_min = que.top();
      if (a < a_min) {
        sum += a-a_min;
        que.pop();
        que.push(a);
      }
    }
  }
  left.push_back(-sum);
  priority_queue<int> que2;
  ll sum2 = 0;
  vector<ll> right;
  for (int i = 3*n-1; i >= n; --i) {
    if (i < 2*n) right.push_back(sum2);
    int a = la[i];
    if (i >= 2*n) {
      sum2 += a;
      que2.push(a);
    }
    else {
      int a_max = que2.top();
      if (a < a_max) {
        sum2 += a-a_max;
        que2.pop();
        que2.push(a);
      }
    }
  }
  right.push_back(sum2);
  // cout << left << endl;
  // cout << right << endl;
  ll ans = left[0] - right[n];
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, left[i]-right[n-i]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
    int n; cin >> n;
    ll ans=100000;
    for(int i=0;i<n;i++){
        ans*=1.05;
        if(ans%1000!=0){
            ans/=1000;
            ans++;
            ans*=1000;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  cout << (int)s.size() / 2 - count(s.begin(), s.end(), 'p') << endl;
}


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

using namespace std;

int main() {
	string table[4] = { "dream", "dreamer", "erase", "eraser" };
	string str;

	cin >> str;

	queue<int> que;
	que.push(0);

	while (!que.empty()) {
		for (int i = 0, size = que.size(); i < size; ++i) {
			int s = que.front();
			que.pop();

			if (s == str.size()) {
				cout << "YES" << endl;
				return 0;
			}

			for (int j = 0; j < 4; ++j) {
				if (str.find(table[j], s) == s) {
					que.push(s + table[j].size());
				}
			}
		}
	}

	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <list>

class Edge{
public:
    int from, to;
    long long cost;
    Edge(): from(0), to(0), cost(0){};
    Edge(int u, int v, long long w): from(u), to(v), cost(w){};
    ~Edge(){};
};

// Dijkstra's Algorithm
void Dijkstra(std::vector<Edge> &edge, int N, int start, std::vector<long long> &distance)
{
    typedef std::pair<long long, int> P;
    const long long infty = 1e+18;

    // initialize
    distance.clear();
    for(int i=0; i<N; i++) distance.push_back(infty);
    distance[start] = 0;
    std::priority_queue<P, std::vector<P>, std::greater<P> > q;
    q.push(P(0, start));

    std::vector<std::list<P> > edge_list(N);
    for(auto &&itr = edge.begin(); itr != edge.end(); itr++){
        edge_list[itr->from].push_back(P(itr->cost, itr->to));
    }

    // update
    while(!q.empty()){
        int d = q.top().first;
        int u = q.top().second;
        q.pop();
        if(distance[u] < d) continue; // not updated

        for(auto &&itr = edge_list[u].begin(); itr != edge_list[u].end(); itr++){
            int v = itr->second;
            long long w = itr->first;
            if(distance[u] + w < distance[v]){
                distance[v] = distance[u] + w;
                q.push(P(distance[v], v));
            }
        }
    }
}

// directed graph -> undirected graph
void to_undirected(std::vector<Edge> &edge)
{
    int M = edge.size();
    for(int i=0; i<M; i++){
        edge.push_back(Edge(edge[i].to, edge[i].from, edge[i].cost));
    }
}

int main()
{
    int N;
    scanf("%d", &N);
    std::vector<Edge> edge(N);
    for(int i=0; i<N-1; i++){
        scanf(" %d %d", &(edge[i].from), &(edge[i].to));
        edge[i].from--; edge[i].to--; edge[i].cost = 1;
    }

    to_undirected(edge);
    std::vector<long long> d_Fennec, d_Snuke;
    Dijkstra(edge, N, 0, d_Fennec);
    Dijkstra(edge, N, N-1, d_Snuke);
    int count = 0;
    for(int i=0; i<N; i++){
        if(d_Fennec[i] * 2 < d_Snuke[i] * 2 + 1) count++;
    }
    if(count * 2 > N) std::cout << "Fennec" << std::endl;
    else std::cout << "Snuke" << std::endl;
}

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

typedef long long ll;

const int Maxn = 3005;

int p;
int a[Maxn];
int ign;

int toPower(int a, int pw)
{
    int res = 1;
    while (pw) {
        if (pw & 1) res = ll(res) * a % p;
        pw >>= 1; a = ll(a) * a % p;
    }
    return res;
}

int Inv(int x) { return toPower(x, p - 2); }

vector <int> Mult(const vector <int> &A, const vector <int> &B)
{
    if (A.empty()) return B;
    if (B.empty()) return A;
    vector <int> C(int(A.size()) + int(B.size()) - 1, 0);
    for (int i = 0; i < A.size(); i++)
        for (int j = 0; j < B.size(); j++)
            C[i + j] = (C[i + j] + ll(A[i]) * B[j]) % p;
    return C;
}

vector <int> Div(vector <int> X, int val)
{
    vector <int> res;
    for (int i = int(X.size()) - 1; i > 0; i--) {
        res.push_back(X[i]);
        X[i - 1] = (ll(X[i - 1]) + ll(val) * X[i]) % p;
    }
    reverse(res.begin(), res.end());
    return res;
}

vector <int> Solve(int l, int r)
{
    if (l == r) return {(p - l) % p, 1};
    else {
        int m = l + r >> 1;
        return Mult(Solve(l, m), Solve(m + 1, r));
    }
}

int main()
{
    scanf("%d", &p);
    vector <int> all = Solve(0, p - 1);
    vector <int> res(p, 0);
    for (int i = 0; i < p; i++) {
        scanf("%d", &a[i]);
        if (a[i] == 1) {
            vector <int> got = Div(all, i);
            int mult = 1;
            for (int j = 0; j < p; j++) if (j != i) {
                int coef = (i - j + p) % p;
                mult = ll(mult) * coef % p;
            }
            mult = Inv(mult);
            for (int j = 0; j < got.size(); j++)
                res[j] = (res[j] + ll(mult) * got[j]) % p;
        }
    }
    for (int i = 0; i < p; i++)
        printf("%d%c", res[i], i + 1 < p? ' ': '\n');
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
    int H,W,i,j;
    
    while(1){
        scanf("%d%d",&H,&W);
        if(H==0 && W==0)break;
    
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if((i+j)%2==0)printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2052