akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

struct edge {
    int from, to;
    int cost;
}; 

int n, m;
long d[1000];
bool jf[1000], jb[1000];
edge e[2000];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        e[i].from = a - 1;
        e[i].to = b - 1;
        e[i].cost = c;
    }
    
    jf[0] = true;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < m; j++) {
            if (jf[e[j].from]) jf[e[j].to] = true;
        }
    }
    jb[n - 1] = true;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < m; j++) {
            if (jb[e[j].to]) jb[e[j].from] = true;
        }
    }
    
    for (int i = 1; i < n; i++) d[i] = -1e18;
    bool update = true;
    int cnt = 0;
    while (update) {
        if (++cnt == n + 1) {
            printf("inf\n");
            return 0;
        }
        update = false;
        for (int i = 0; i < m; i++) {
            if (jf[e[i].from] && jb[e[i].to] && d[e[i].from] + e[i].cost > d[e[i].to]) {
                d[e[i].to] = d[e[i].from] + e[i].cost;
                update = true;
            }
        }
    }

    printf("%ld\n", d[n - 1]);
    return 0;
}


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

int main(){
    int a, b; cin>>a>>b;
    cout<<a*b<<" "<<a*2 + b*2<<endl;
}



Measured memory_bytes: 3080
//マイナーチェンジ版
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<int, int> P;

int n, m;
vector<int> Q(101010, -1);

int main(){
  cin >> n >> m;
  int ac = 0, wa = 0;
  rep(i, m){
    int p;
    string s;
    cin >> p >> s;
    if(Q[p] > 0) continue;
    if(s == "WA"){
      Q[p]--;
    }else{
      Q[p] *= -1;
      ac++;
      wa += Q[p] - 1;
    }
  }
  cout << ac << " " << wa << endl;
  return 0;
}

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

int cts(unsigned int*,unsigned int*,int,int);

int main(int argc, const char * argv[]) {
    int n;
    int i;
    unsigned int A[2000000];
    unsigned int B[2000000];
    scanf("%d",&n);
    scanf("%d",&A[1]);
    int k=A[1];
    for( i=2;i<=n;i++){
        scanf("%d",&A[i]);
        if(A[i]>=k) k=A[i]; 
    }
    cts(A,B,k,n);
    
    for(i=1;i<=n;i++){
        printf("%d",B[i]);
        if(i!=n) printf(" ");
        else printf("\n");
    }
    
    return 0;
}

int cts(unsigned int A[],unsigned int B[], int k, int n){
    int C[10000];
    int i;
    for(i=0;i<=k;i++){
        C[i]=0;
    }
    for(i=1;i<=n;i++){
        C[A[i]]=C[A[i]]+1;        
    }
    for(i=1;i<=k;i++){
        C[i]=C[i]+C[i-1];
    }
    for(i=n;i>=1;i--){
        B[C[A[i]]]=A[i];
        C[A[i]]=C[A[i]]-1;
    }
    return 100;
}


Measured memory_bytes: 17388
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class AtCoder
{
  public static void Main()
  {
    var input = Console.ReadLine();
    var a = int.Parse(input[0].ToString());
    var b = int.Parse(input[1].ToString());
    var c = int.Parse(input[2].ToString());
    var d = int.Parse(input[3].ToString());

    var i = 0;
    var v = 0;
    for(i=0; i < 16; i++)
    {
      v = a;      
      v +=  (i & (1 << 2)) > 0 ? b : -b;
      v +=  (i & (1 << 1)) > 0 ? c : -c;
      v +=  (i & (1 << 0)) > 0 ? d : -d;

       if(v == 7) break;
    } 

    var op = new []{ "-", "+"};
    var ans =  
      a + op[i >> 2 & 1] +
      b + op[i >> 1 & 1] +
      c + op[i >> 0 & 1] +
      d + "=7";

    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100100;
ll x[maxn];
ll d[maxn];
ll f[maxn];
ll t;

int main() {
    #ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
    #else
    #endif
    ll n, e;
    cin >> n >> e >> t;
    forn (i, n) {
        cin >> x[i];
        x[i] *= 2;
    }
    forn (i, n + 1)
        d[i] = infl;
    d[0] = 0;
    f[0] = -x[0];
    for (int i = 1; i <= n; ++i) {
        //forn (j, i) {
            //d[i] = min(d[i], d[j] + max(t, x[i - 1] - x[j]));
        //}
        int p = lower_bound(x, x + i, x[i - 1] - t) - x;
        d[i] = min(d[i], d[p] + t);
        if (p > 0)
            d[i] = min(d[i], f[p - 1] + x[i - 1]);
        f[i] = min(f[i - 1], d[i] - x[i]);
    }
    cout << d[n] + e << '\n';
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 998244353;

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

int main(){
  ll x,k,d;cin>>x>>k>>d;
  x=abs(x);
  ll s=min(k,x/d);
  k-=s;x-=s*d;
  if(k%2){
    cout<<d-x<<endl;
    
  }
  else{
    cout<<x<<endl;
  }
}






Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
 
class Program
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NM[0];
        var M = NM[1];
        var L = new int[M];
        var R = new int[M];
        var D = new int[M];
        for (int i = 0; i < M; i++)
        {
            var LRD = ReadLine().Split().Select(int.Parse).ToArray();
            L[i] = LRD[0] - 1;
            R[i] = LRD[1] - 1;
            D[i] = LRD[2];
        }
        var uf = new WeightedMeguruUnionFind(N);
        for (int i = 0; i < M; i++)
        {
            if (uf.Same(L[i], R[i]))
            {
                if (D[i] != uf.Diff(L[i], R[i]))
                {
                    WriteLine("No");
                    return;
                }
            }
            else
            {
                uf.Unite(L[i], R[i], D[i]);
            }
        }
        WriteLine("Yes");
    }
}
 
class WeightedMeguruUnionFind
{
    int[] parent;
    int[] weightDiff;
    int count;
 
    public WeightedMeguruUnionFind(int size)
    {
        var b = new int[size];
        for (int i = 0; i < b.Length; i++)
        {
            b[i] = -1;
        }
        parent = b;
        weightDiff = new int[size];
        count = size;
    }
 
    int Root(int x)
    {
        if (parent[x] < 0)
        {
            return x;
        }
        else
        {
            var r = Root(parent[x]);
            weightDiff[x] += weightDiff[parent[x]];
            return parent[x] = r;
        }
    }
 
    int Weight(int x)
    {
        Root(x);
        return weightDiff[x];
    }
 
    public int Diff(int x, int y) => Weight(y) - Weight(x);
 
    public bool Same(int x, int y) => Root(x) == Root(y);
 
    public void Unite(int x, int y, int w)
    {
        w += weightDiff[x] - weightDiff[y];
        x = Root(x);
        y = Root(y);
        if (x == y) return;
        count--;
        if (parent[x] > parent[y])
        {
            parent[y] += parent[x];
            parent[x] = y;
            weightDiff[x] = -w;
        }
        else
        {
            parent[x] += parent[y];
            parent[y] = x;
            weightDiff[y] = w;
        }
    }
 
    public int Size(int x) => -parent[Root(x)];
 
    public int Count() => count;
}

Measured memory_bytes: 20112
n = int(input())
li = list()
for i in range(n):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])
count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break
if count >= 3: print('Yes')
else: print('No')

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}


int main(){
    int a,b;
    cin>>a>>b;
    int ans=(a+b-3)/(a-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())


ans = 8

if X <= 599:
    print(ans)
elif X >= 600 and X <= 799:
    print(ans-1)
elif X >= 800 and X <= 999:
    print(ans-2)
elif X >= 1000 and X <= 1199:
    print(ans-3)
elif X >= 1200 and X <= 1399:
    print(ans-4)
elif X >= 1400 and X <= 1599:
    print(ans-5)
elif X >= 1600 and X <= 1799:
    print(ans-6)    
elif X >= 1800 and X <= 1999:
    print(ans-7)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> s(m);
  vector<int> c(m);
  int ans=0;
  vector<int> fa(n,0);
  vector<bool> ju(m,false);
  rep(i,m){
    cin>>s[i]>>c[i];
    if((n!=1)&&s[i]==1&&c[i]==0){
      cout<<"-1"<<endl;
      return 0;
    }
    if(ju[s[i]-1]==false){
      ju[s[i]-1]=true;
      fa[s[i]-1]=c[i];
    }
    else if(ju[s[i]-1]){
      if(fa[s[i]-1]==c[i]){
        continue;
      }
      else{
        cout<<"-1"<<endl;
      return 0;
      }
    }
  }
  if(n!=1&fa[0]==0){
    fa[0]=1;
  }
  rep(i,n){
    ans+=pow(10,i)*fa[n-i-1];
  }
  cout<<ans<<endl;    
  return 0;
}

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

int main(void)
{
	priority_queue<int> que;

	while (1) {
		char cmd[8] = "\0";
		int key;
		cin >> cmd;
		if (cmd[2] == 'd') break;
		if (cmd[2] == 's') {
			cin >> key;
			que.push(key);
		}
		else if (cmd[2] == 't') {
			cout << que.top() << endl;
			que.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 6992
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const n = +(await sc.getLine());
    const L = (await sc.getLine()).split(' ').map((x) => +x);
    L.sort((a, b) => {
      if (a > b) return 1;
      else return -1;
    }).reverse();
    const sum = (array: any[]) => {
      return array.reduce((prev, current, i, arr) => {
        return prev + current;
      });
    };
    if (L[0] >= sum(L) - L[0]) {
      console.log('No');
    } else {
      console.log('Yes');
    }
    sc.close();
  }

  slove();
}


Measured memory_bytes: 7628
n,a,b = map(int, input().split())
if abs(a-b)%2 ==0:
    print(abs(a-b)//2)
else:
    to_one_or_n = min(min(a,b) -1, n - max(a,b))
    wait = 1
    face_to_face = (abs(a-b) - 1)//2
    print(to_one_or_n + wait + face_to_face)
    

Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>

using namespace std;

char ans1[1000001],ans2[1000001];

int main(){
    int t[181];
    
    for(int i = 1;i <= 180;++i)
        t[i] = i * (i + 1) * (i + 2) / 6;
    
    ans1[0] = ans2[0] = 0;
    
    for(int i = 1;i <= 1000000;++i){
        ans1[i] = 5;
        ans2[i] = 40;
    }
    
    for(int i = 1;i <= 180;++i)
        for(int j = i;j <= 180 && t[i] + t[j] <= 1000000;++j)
            for(int k = j;k <= 180 && t[i] + t[j] + t[k] <= 1000000;++k)
                ans1[ t[i] + t[j] + t[k] ] = 3;
    
    for(int i = 1;i <= 180;++i)
        for(int j = i;j <= 180 && t[i] + t[j] <= 1000000;++j)
            ans1[ t[i] + t[j] ] = 2;
    
    for(int i = 1;i <= 180;++i)
        ans1[ t[i] ] = 1;
    
    for(int i = 1;i <= 1000000;++i){
        if(ans1[i] == 3){
            for(int j = 1;j <= 180 && i + t[j] <= 1000000;++j)
                if(ans1[i + t[j]] == 5) ans1[i + t[j]] = 4;
        }
    }
    
    for(int i = 1;i <= 180;++i){
        int x = t[i];
        
        if(x & 1)
            for(int j = x;j <= 1000000;++j)
                if(1 + ans2[j - x] < ans2[j]) ans2[j] = 1 + ans2[j - x];
    }
    
    int n;
    
    while(true){
        scanf("%d",&n);
        
        if(n == 0) break;
        
        printf("%d %d\n",ans1[n],ans2[n]);
    }
    
    return 0;
}

Measured memory_bytes: 4620
// 問題名: Dinner
// URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2642&lang=jp
// 所要時間: 40分
// --感想--
//「自炊パワーは行動に依らず毎日-1変動することにしたときの幸福度の総和と、実際の幸福度の総和との差」は全体を通して自炊した回数
// のみによって決まることに気づくのにかなり時間を要した。一見するとO(N^2)の動的計画法が浮かぶが、少し考察を練ると割と平易な
// アルゴリズムで高速に求められる良問だった。

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n, p, q, c[500010], a[500010];
    cin >> n >> p >> q;
    for (int i = 0; i < n;i++)
        cin >> c[i];
    long long ans = 0;
    // 毎日食堂で食べたときの幸福度の総和を求める
    for (int i = 0; i < n;i++)
        ans += c[i];
    // a[i]:= i日目を食堂から自炊へ切り替えた時の幸福度の変化
    // 自炊パワーは行動に依らず毎日-1されることにする...(@)
    for (int i = 0; i < n; i++)
        a[i] = p * (q - i) - c[i];
    sort(a, a + n);
    reverse(a, a + n);
    long long sum = 0, M = 0;
    // 自炊をi日したときの幸福度の変化の最大値を順次求め、その最大値Mを記録
    // 自炊をk日したとき、(@)のルール変更による幸福度の総和の変化は-k*(k-1)*p
    for (int i = 0; i < n; i++){
        sum += a[i] + i * 2 * p;
        M = max(M, sum);
    }
    ans += M;
    cout << ans << endl;
}


Measured memory_bytes: 10968
#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

int main(void)
{
	int input;
	int answer = 0;
	int sum = 0;

	while( input = getchar(),input != EOF ){
		if( input >= '0' && input <= '9' ){
			answer *= 10; answer += input - '0';
		} else {
			sum += answer;
			answer = 0;
		}

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

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

void trip(int nw,int a,int b,vector<vector<int>>&mp,vector<bool>&w){
	w.at(nw)=true;
	for(auto&i:mp.at(nw)){
		if((nw==a&&i==b)||(i==a&&nw==b))continue;
		if(!w.at(i))trip(i,a,b,mp,w);
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<int>v(n+1,0);
	vector<vector<int>>mp(n+1);
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b;
		++v.at(a),++v.at(b);
		mp.at(a).emplace_back(b),mp.at(b).emplace_back(a);
	}
	int ans=0;
	for(int i=0;i<mp.size();++i){
		for(int j=0;j<mp.at(i).size();++j){
			vector<bool>w(n+1,false); w.front()=true;
			trip(1,i,mp.at(i).at(j),mp,w);
			if(any_of(w.begin(),w.end(),[](auto a){return !a;}))++ans;
		}
	}
	cout<<ans/2<<"\n"s;
}

Measured memory_bytes: 256
N,W,*L=map(int,open(0).read().split())
dp=[float("inf")]*10001
dp[0]=0
for v,w in zip(*[iter(L)]*2):
	for i in range(10000,v-1,-1):
		dp[i]=min(dp[i],dp[i-v]+w)
ans=0
for v in range(10001):
	if dp[v]<=W:
		ans=max(ans,v)
print(ans)


Measured memory_bytes: 5720
<?php
fscanf(STDIN, "%d", $N);
$h = array_map("intval", explode(" ", trim(fgets(STDIN))));
$ans = 0;
while(array_sum($h) !== 0) {
    $l = $r = null;
    foreach ($h as $k => $v) {
        if (is_null($l)) {
            if ($v !== 0) {
                $l = $k;
                $mmin = $v;
            }
        } else {
            // echo "B" . PHP_EOL;
            if (is_null($r)) {
                if ($v === 0) {
                    $r = $k - 1;
                    break;
                }
            } else {
            }
            // echo "C" . PHP_EOL;
            $mmin = min($mmin, $v);
            // printf("%d %d\n", $k, $mmin);
        }
    }
    if (is_null($r)) {
        $r = $N - 1;        
    }
    // printf("%d %d %d", $l, $r, $mmin);
    for ($i = $l; $i <= $r; $i++) {
        $h[$i] -= $mmin;
    }
    $ans += $mmin;
}
echo $ans;


Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  string S;
  cin >> S;

  if(S[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }

  int pos = S.find("C");
  if(pos < 2 || pos > S.length()-2 || pos == string::npos){
    cout << "WA" << endl;
    return 0;
  }

  if(S.find_first_of("C") != S.find_last_of("C")){
    cout << "WA" << endl;
    return 0;
  }

  int big=0;
  for(int i=1; i < S.length(); ++i){
    if(i != pos){
      if((S[i]>= 'A') && (S[i]<='Z')){
        ++big;
      }
    }
  }

  if(big > 0){
    cout << "WA" << endl;
    return 0;
  }

  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub 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")
}

use std::collections::HashMap;

fn factors(n: i64) -> HashMap<i64, i64> {
    let mut a = n;
    let mut f = 2;
    let mut map: HashMap<i64, i64> = HashMap::new();
    while a > 1 && f * f <= n {
        while a % f == 0 {
            let current = map.entry(f).or_insert(0);
            *current += 1;
            a /= f;
        }
        f += 1;
    }
    if a != 1 {
        let current = map.entry(a).or_insert(0);
        *current += 1;
    }
    return map;
}

fn main() {
    let n: i64 = read();
    let mut a: Vec<usize> = vec![1];
    let mut ans = 0;
    for i in 2..=50 {
        for j in 0..i - 1 {
            a.push(i - 1);
        }
        a.push(i)
    }

    let map = factors(n);
    // println!("{:?}", map);
    for (_, v) in map {
        ans += a[v as usize - 1];
    }
    println!("{}", ans);
    // println!("{:?}", factors(n));
}


Measured memory_bytes: 2144
#include<cstdio>
#include<cstring>
#include<algorithm>
int n,c[15],ans=1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]);
	for(int i=1;i<=n;i++) ans=ans*3;
	int tmp=1;
	for(int i=1;i<=n;i++)if(!(c[i]&1)) tmp*=2;
	printf("%d\n",ans-tmp);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  int n;
  int cnt[6] = {0};
  double a;

  cin >> n;
  while(n--){
    cin >> a;
    if(a < 165) cnt[0]++;
    else if(a < 170) cnt[1]++;
    else if(a < 175) cnt[2]++;
    else if(a < 180) cnt[3]++;
    else if(a < 185) cnt[4]++;
    else cnt[5]++;
  }

  for(int i = 0 ; i < 6 ; i++){
    cout << i+1 << ":";
    for(int j = 0 ; j < cnt[i] ; j++){
      cout << "*";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1232
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e6+5;
const ll INF = 1e18+5;

vector<int> parent(MAX,-1);
vector<int> sze(MAX,0);
void make_set(int i)
{
	parent[i]=i;
	sze[i]=1;
}

int find_set(int i)
{
	if(parent[i]==i) return i;
	else return parent[i]=find_set(parent[i]);
}

void union_set(int i,int j)
{
	i=find_set(i);
	j=find_set(j);
	if(i!=j)
	{
		if(sze[i]>sze[j]) swap(i,j);
		parent[i]=j;
		sze[j]+=sze[i];
	}
}

int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++) make_set(i);

	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		union_set(x,y);
	}
	int ans = 0;
	for(int i=1;i<=n;i++)
	{
		ans = max(ans,sze[find_set(i)]);
	}
	cout<<ans<<endl;
}	

Measured memory_bytes: 11084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		sc.close();


		int nedan=700;
		String[] strArray = s.split("");

		for(int i=0;i<3;i++) {
			if(strArray[i].equals("o"))
				nedan+=100;
		}

		System.out.print(nedan);

	}

}


Measured memory_bytes: 21716
PRIME = 1000231


def main():
    n = int(input())
    d = MyDict()
    for _ in range(n):
        command, v = input().split(' ')
        if command == 'insert':
            d.add(v)
        else:
            if d.find(v):
                print('yes')
            else:
                print('no')




class MyDict:

    def __init__(self, n=PRIME):
        self.n = n
        self.store = [None]*n

    def add(self, v):
        key = self._hash(v)
        while self.store[key] is not None:
            key += 1
        self.store[key] = v

    def find(self, v):
        key = self._hash(v)
        while self.store[key] is not None and self.store[key] != v:
            key += 1
        return self.store[key]

    def _hash(self, v):
        return hash(v) % self.n


if __name__ == '__main__':
    main()



Measured memory_bytes: 47736
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

#include<bits/stdc++.h>
using namespace std;

int main() {
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<int> res;
    vector<int> L(N , 0);
    for (int i = 0; i < N; i++) {
        if (S[i] == 'o') L[i] = i >= C + 1 ? L[i - C - 1] + 1 : 1;
        L[i] = max(i == 0 ? 0 : L[i - 1], L[i]);
    }
    vector<int> R(N, 0);
    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == 'o') R[i] = i + C + 1 < N ? R[i + C + 1] + 1 : 1;
        R[i] = max(R[i], i == N - 1 ? 0 : R[i + 1]);
    }
    // for (int i = 0; i < N; i++) cout << L[i] << " ";
    // cout << endl;
    // for (int i = 0; i < N; i++) cout << R[i] << " ";
    // cout << endl;
    vector<int> bad(N, 0);
    for (int i = 0; i < N; i++) {
        int before = i == 0 ? 0 : L[i - 1];
        int after = i == N - 1 ? 0 : R[i + 1];
        if (before + after < K) res.push_back(i + 1);
        // if (!bad[L[i]]) {
        //     res.push_back(i + 1);
        //     bad[L[i]] = 1;
        // } else if (!res.empty() && L[i] == L[res.back() - 1]) {
        //     res.pop_back();
        // }
        // for (auto v: res) cout << v << " ";
        // cout << endl;
    }
    // vector<int> nxto(N, 0);
    // int cur = N;
    // for (int i = N - 1;i >= 0 ;i--) {
    //     if (S[i] == 'o') {nxto[i] = i; cur = i;}
    //     else nxto[i] = cur;
    // }

    // vector<int> seen(N + 1, 0);
    // deque<int> q;
    // for (int i = 0; i < N; i++) {
    //     if (S[i] == 'x') break;
    //     q.push_back(i);
    //     seen[i] = 1;
    // }

    // while (!q.empty()) {
    //     if (q.size() == 1) res.push_back(q.front() + 1);
    //     deque<int> nxtq;
    //     while (!q.empty()) {
    //         int cur = q.front(); q.pop_front();
    //         if (nxto[cur] == N) continue;
    //         if (!seen[nxto[cur]]) {
    //             seen[nxto[cur]] = 1;
    //             nxtq.push_back(nxto[cur]);
    //         }
    //     }
    // }
    if (res.empty()) cout << endl; 

    for (auto v: res) {
        cout << v << endl;
    }

    return 0;
}

Measured memory_bytes: 4984
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define int long long
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (ll i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((ll)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <ll, ll> pii ;
typedef vector <ll> vi ;
typedef vector <pii> vii ;
typedef queue <ll> qi ;
typedef queue <pii> qii ;
typedef set <ll> si ;
typedef map <ll, ll> mii ;
typedef map <string, ll> msi ;
const ll maxn = 2e6 + 100 ;
const ll inf = 0x3f3f3f3f ;
const ll iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 998244353 ;
const double eps = 1e-7 ;
template <class T = ll> T chmin(T &a, T b) { return a = min(a, b);}
template <class T = ll> T chmax(T &a, T b) { return a = max(a, b);}
template <class T = ll> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

ll n;

signed main()
{
	n = read();
	if(lowbit(n) == n) return puts("No"), 0;
	puts("Yes");
	ll base = n;
	if(!(n & 1))
	{
		ll a = lowbit(n), b = n ^ a ^ 1;
		if(a & 1) a += base;
		if(b & 1) b += base;
		printf("%lld %lld\n%lld %lld\n", n, a, b, n + base);
		n --;
	}
	while(n > 1)
	{
		printf("%lld %lld\n%lld %lld\n%lld %lld\n%lld %lld\n", n, n - 1, n - 1, 1ll, 1ll, n + base, n + base, n - 1 + base);
		n -= 2;
	}
	printf("%lld %lld\n", 1 + base, 3ll);
	return 0;  
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
	long long N;
	cin >> N;
	long long  total = 0;
	for(long long i = 1;i<=N;i++){
		if(i % 3 != 0 && i % 5 != 0){
			total += i;
		}
	}
	
	std::cout << total <<std::endl;
	
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    cin>>s;
    ll sum=0;
    for(ll i=0;i<s.length();i++)
    {
        sum+=s[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else{
       cout<<"No"<<endl;
    }




}


Measured memory_bytes: 3760
#pragma comment(linker, "/stack:200000000")

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

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

const int N = 1e3 + 123 , mod = 1e9 + 7;
int n , m , dp[N][N];
char a[N][N];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> m;
	dp[1][1] = 1;
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			cin >> a[i][j];
			if(a[i][j]=='#' ||(i == 1 && j == 1))
				continue;
			dp[i][j] =(dp[i - 1][j] + dp[i][j - 1])% mod;
		}
	}
	cout << dp[n][m];
}

Measured memory_bytes: 10496
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

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

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var a, b, h, m int

func main() {
	sc.Split(bufio.ScanWords)
	a, b, h, m = nextInt(), nextInt(), nextInt(), nextInt()
	minutes := 60*h + m
	var aAngle, bAngle float64
	//時針
	aAngle = 0.5 * float64(minutes%720)
	//分針
	bAngle = 6.0 * float64(minutes%60)

	tmpdiff := absFloat64(aAngle - bAngle)
	diff := minFloat64(tmpdiff, 360.0-tmpdiff)
	//fmt.Println(diff)

	c2 := float64(a*a+b*b) - 2*float64(a*b)*math.Cos(diff*math.Pi/180)
	fmt.Println(math.Sqrt(c2))

}


Measured memory_bytes: 1756
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var foo = Console.ReadLine().Trim().Split();
            var A = int.Parse(foo[0]);
            var B = int.Parse(foo[1]);
            var C = int.Parse(foo[2]);
            var K = int.Parse(foo[3]);
            if(K < A){
                Console.WriteLine(K);
            }
            else if(K <= A + B){
                Console.WriteLine(A);
            }else{
                Console.WriteLine(A + (K - (A + B)) * -1);
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 17884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
    int n, h, m, s;
    cin >> n;
    h = n / 3600;
    m = (n % 3600) / 60;
    s = (n % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
}


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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    for (int i = 0; i < N; i++) cin >> x[i];
    for (int i = 0; i < M; i++) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    bool warflag = true;
    for (int i = X + 1; i <= Y; i++) {
        if (x.back() < i && i <= y.front()) warflag = false;
    }

    cout << (warflag ? "War" : "No War") << endl;
}

Measured memory_bytes: 888
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
max_a = a[-1]
temp = a[0]
for i in a[1:-1]:
    if abs(i - max_a / 2) < abs(temp - max_a / 2):
        temp = i
print(*[max_a, temp])

Measured memory_bytes: 14052
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String str1 = stdIn.next();
        String str2 = stdIn.next();
        String str = str1 + str2;
        int num = Integer.parseInt(str);
        double sq = Math.sqrt(num);
        int sq2 = (int)sq;
        if(num == sq2*sq2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 22484
#include<cstdio>

int main(){
    int t,n,data[4] = {6000,4000,3000,2000};

    for(int i=0;i<4;i++){
        scanf("%d %d",&t,&n);

        printf("%d\n",data[t-1]*n);
    }

    return 0;
}

Measured memory_bytes: 1028
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let m: usize = read!();
    let mut cities = vec![0; n];
    for _ in 0..m{
        let a: usize = read!();
        let b: usize = read!();
        cities[a-1]+=1;
        cities[b-1]+=1;
    }
    
    for c in cities{
        println!("{}", c);
    }
}

Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pii>
#define vpl vector<pll>
ll mod = 1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
#define openfile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define openfile
#define deb(x...)
#endif
void init()
{
    
}
void solve()
{
    ll a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}
int main()
{
    init();
    // openfile;fastio;
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
}

Measured memory_bytes: 3612
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int N=2999;
int n;
double a[N+1];
double dp[N+1][N+1];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++)for(int j=0;j<=n;j++){
		dp[i][j]=(1-a[i])*dp[i-1][j];
		if(j)dp[i][j]+=a[i]*dp[i-1][j-1];
	}
	double ans=0;
	for(int i=n/2+1;i<=n;i++)ans+=dp[n][i];
	printf("%.100lf",ans);
	return 0;
}
/*1
3
0.30 0.60 0.80
*/
/*2
1
0.50
*/
/*3
5
0.42 0.01 0.42 0.99 0.42
*/

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int K,S;cin >> K >> S;
  int count = 0;
  rep(x,K+1){
    rep(y,K+1) if(x+y<=S && x+y+K>=S)++count;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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;

int main(){
  int n; cin >> n;
  int m = n/2;
  vector<int> a(m), b(m);
  rep(i, m) cin >> a[i] >> b[i];
  sort(all(a));
  sort(all(b));

  int ma1=0, ma2=0, cnta=1;
  int x1 = 0, x2 = 0;
  rep(i, m-1){
    if(a[i] == a[i+1]) cnta++;
    if(a[i] != a[i+1] || i==m-2){
      if(ma1 <= cnta){
        x2 = x1;
        x1 = a[i];
        ma2 = ma1;
        ma1 = cnta;
      }
      else if(ma2 <= cnta){
        x2 = a[i];
        ma2 = cnta;
      }
      cnta = 1;
    }
  }

  int mb1=0, mb2=0, cntb=1;
  int y1 = 0, y2 = 0;
  rep(i, m-1){
    if(b[i] == b[i+1]) cntb++;
    if(b[i] != b[i+1] || i==m-2){
      if(mb1 <= cntb){
        y2 = y1;
        y1 = b[i];
        mb2 = mb1;
        mb1 = cntb;
      }
      else if(mb2 <= cntb){
        y2 = b[i];
        mb2 = cntb;
      }
      cntb = 1;
    }
  }

  int ans;
  if(x1 != y1) ans = n - ma1 - mb1;
  else ans = min(n - ma1 - mb2, n - ma2 - mb1);

  cout << ans << endl;

  return 0;
}


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

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String s=gs();
	    //int b=gi();
	    System.out.print(s.length() - s.replace("1", "").length());
//	    if (a+b==15) {
//	    	System.out.print("+");
//	    }else if(a*b==15) {
//	    	System.out.print("*");
//	    } else {
//	    	System.out.print("x");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 2999 + 5;

double dp[N][N];
double p[N];
int n;

double sol(int i, int hd) {
    if(i == n) {
        if(hd > n - hd) return 1.0;
        return 0;
    }

    double &ret = dp[i][hd];
    if(ret < 1.8) return ret;

    ret = (1 - p[i]) * sol(i + 1, hd);
    ret += p[i] * sol(i + 1, hd + 1);

    return ret;
}

int main(){
    fIO

//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) dp[i][j] = 2.0;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> p[i];

    cout << fixed << setprecision(12) << sol(0, 0) << "\n";
}








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

int N[50];
int M[50];
int comp(const void *c1, const void *c2){
    int *a = (int *)c1;
    int *b = (int *)c2;
    return *a-*b;
}


int main(void){
    int n,n_sum,m,m_sum,i,j;
    while(scanf("%d %d", &n, &m),n||m){
        n_sum=0;
        for(i=0;i<n;i++){
            scanf("%d", &N[i]);
            n_sum+=N[i];
        }
        qsort(N,n,sizeof(int),comp);
        //for(i=0;i<n;i++) printf("N[%d]:%d\n",i,N[i]);
        m_sum=0;
        for(i=0;i<m;i++){
            scanf("%d", &M[i]);
            m_sum+=M[i];
        }
        qsort(M,m,sizeof(int),comp);
        //for(i=0;i<m;i++) printf("M[%d]:%d\n",i,M[i]);
        
        if(n_sum>m_sum){//n_sum-m_sum???n??????m?????????
            for(i=0;i<m;i++){
                for(j=0;j<n;j++){
                    if((N[j]-M[i])*2==n_sum-m_sum){
                        printf("%d %d\n", N[j], M[i]);
                        goto end;
                    }
                }
            }
        }else{//m_sum-n_sum???m??????n?????????
            for(j=0;j<n;j++){
                for(i=0;i<m;i++){
                    if((M[i]-N[j])*2==m_sum-n_sum){
                        printf("%d %d\n", N[j], M[i]);
                        goto end;
                    }
                }
            }
        }
        printf("-1\n");
end:
        ;
    }
    return 0;
}

Measured memory_bytes: 616
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

H, W = getNM()

res = 0
# 縦縦
opt1 = float('inf')
if W % 3 == 0:
    opt1 = 0
else:
    opt1 = H

# 縦横
opt2 = float('inf')
for i in range(1, W + 1):
    opt_a = i * H
    opt_b = (W - i) * (H // 2)
    opt_c = H * W - opt_a - opt_b
    opt = max(opt_a, opt_b, opt_c) - min(opt_a, opt_b, opt_c)
    opt2 = min(opt2, opt)

# 横横
opt3 = float('inf')
if H % 3 == 0:
    opt3 = 0
else:
    opt3 = W

# 横縦
opt4 = float('inf')
for i in range(1, H + 1):
    opt_a = i * W
    opt_b = (H - i) * (W // 2)
    opt_c = H * W - opt_a - opt_b
    opt = max(opt_a, opt_b, opt_c) - min(opt_a, opt_b, opt_c)
    opt4 = min(opt4, opt)

print(min(opt1, opt2, opt3, opt4))

Measured memory_bytes: 83816
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    char a;
    cin >> a;
    if( a - 'a' >= 0 && a - 'a' <= 25 ) cout << 'a';
    else cout << 'A';
}


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

#define LLINF (1LL<<60)
typedef long long ll;

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

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    double W,H,X,Y;
    cin >>W>>H>>X>>Y;
    
    //-----------------------------------
    double ans=W*H/2;

    printf("%.15lf ",ans);
    cout << ((W/2==X && H/2==Y) ? "1" : "0") <<endl;
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  long long a[n],l[n],r[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  l[0]=a[0]; r[n-1]=a[n-1];
  for(int i=0;i<n-1;i++){
    l[i+1]=__gcd(l[i], a[i]);
  }
  for(int i=n-1;i>0;i--){
    r[i-1]=__gcd(r[i], a[i]);
  }
  l[0]=0; r[n-1]=0;
  for(int i=0;i<n;i++){
    ans=max(ans, __gcd(((l[i]==0)?r[i]:l[i]), ((r[i]==0)?l[i]:r[i])));
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.size();
    int m=s2.size();
    int dp[n+1][m+1]={{0}};
    char ans[3500];
    int k=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(s1[i-1]==s2[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=n,j=m;
    k=dp[n][m];
    while(i>0 && j>0){
        if(s1[i-1]==s2[j-1]){
            k--;
            ans[k]=s1[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    for(int i=0;i<dp[n][m];i++)
        cout<<ans[i];
}


Measured memory_bytes: 35584
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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


	cin >> N;
	M = N;
	while (M) {
		K += M % 10;
		M /= 10;
	}
	if (N%K) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}
	return 0;
}


Measured memory_bytes: 256