akhauriyash/Code-Regression huggingface dataset:
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def yn(f) return (f)? "Yes": "No" end
def ynb(f) return (f)? "YES": "NO" end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
h = inp
c = 0

h.max.times do |i|
  j = false
  h.each do |d|
    if d > i
      unless(j)
        c += 1
        j = true
      end
    else
      j = false
    end
  end
end
p c

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

int main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]!='s')
    cout<<(s+"s")<<endl;
    else
    cout<<(s+"es")<<endl;
    return 0;
    
}

Measured memory_bytes: 3632
# coding: utf-8
# Your code here!
import sys, collections, bisect, math, itertools
from fractions import gcd 
#input = sys.stdin.readline #文字列入力のときは注意

n = int(input())
s = input()
#a = [int(i) for i in input().split()]
#m = [[int(i) for i in input().split()] for j in range(n)] # 縦「n」行

b = [0]*(n+1)
for i in range(n):
    b[i+1] += b[i] + (1 if s[i]=="#" else 0)

w = [0]*(n+1)
for i in range(n):
    w[i+1] += w[i] + (1 if s[i]=="." else 0)
#print(b,w)
ans = n
for i in range(n):
    if i != 0:
        p = b[i-1]
    else: p=0
    q = w[n]-w[i]
#    print(p,q)
    ans = min(ans,p+q)

print(min(ans,b[n]))        
        
        
        
        

Measured memory_bytes: 21632
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
    stack<int> S1;
    stack<pair<int,int> > S2;
    char ch;
    int sum=0;
    for(int i=0;cin>>ch;i++)
    {
        if(ch=='\\')
        {
            S1.push(i);
        }
        else if(ch=='/'&&S1.size()>0)
        {
            int j=S1.top();
            S1.pop();
            sum+=i-j;
            int a=i-j;
            while(S2.size()>0&&S2.top().first>j)
            {
                a+=S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }

    vector<int> ans;
    while(S2.size()>0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout<<sum<<endl;
    cout<<ans.size();
    for(int i=0;i<ans.size();i++)
    {
        cout<<" "<<ans[i];
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3208
import java.util.*;

public class Main {
  public static long MOD = (long)Math.pow(10, 6) + 3;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long[] kai = new long[(int)MOD];
//    long[] inkai = new long[(int)MOD];
//    long[] in = new long[(int)MOD];
    kai[0] = 1;
    kai[1] = 1;
//    inkai[0] = 1;
//    inkai[1] = 1;
//    in[1] = 1;
    for(long i = 2; i < MOD; i++) {
      kai[(int)i] = (i * kai[(int)i - 1]) % MOD;
//      inkai[(int)i] = func(kai[(int)i], MOD - 2);
//      in[(int)i] = func(i, MOD - 2);
    }
    int q = sc.nextInt();
    for(int i = 0; i < q; i++) {
      long x = sc.nextLong();
      long d = sc.nextLong();
      long n = sc.nextLong();
      long ans = 0;
      if(d == 0) {
        if(x == 0) {
          ans = 0;
        } else {
          ans = func(x, n % (MOD - 1));
        }
      } else {
        long inv = func(d, MOD - 2);
        x = (x * inv) % MOD;
        if(x == 0) {
          ans = 0;
        } else {
          if((int)(x + n - 1) >= MOD) {
            ans = 0;
          } else {
            long t = func(d, n % (MOD - 1));
            long invkai = func(kai[(int)x - 1], MOD - 2);
            ans = (((kai[(int)(x + n - 1)] * invkai) % MOD) * t) % MOD;
          }
        }
      }
      System.out.println(ans);
    }
  }
  public static long func(long a, long x) {
    if(x == 0) return 1;
    if(x >= 1) {
      if(x % 2 == 0) {
        long t = func(a, x / 2);
        return (t * t) % MOD;
      } else {
        long t = func(a, x - 1);
        return (a * t) % MOD;
      }
    }
    return 0;
  } 
}

Measured memory_bytes: 101488
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


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

  cin >> a >> b >> c;
	if(a!=b||b!=c||a!=c){
		cout << "No" << endl;
		return 0;
	}

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


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

#define ll long long
#define ull unsigned long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define pii pair<int, int>

const int t = 100005;
int n, h[t];
int memo[t];

int solve(int id) {
    if (id >= n) return INF;
    if (id == n - 1) return 0;
    int &ans = memo[id];
    if (ans != -1)
        return ans;
    ans = min(solve(id + 1) + abs(h[id] - h[id + 1]), solve(id + 2) + abs(h[id] - h[id + 2]));
    return ans;
}

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

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    memset(memo, -1, sizeof memo);
    cout << solve(0) << "\n";
    
    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> s(N),mul10;
    rep(i,N){
        cin >> s[i];
        if(s[i]%10!=0)mul10.push_back(s[i]);
    }
    sort(All(mul10));
    int res = 0;
    rep(i,N)res+=s[i];
    if(res%10==0){
        if(mul10.size()!=0)res-=mul10[0];
        else res=0;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def solve(cumsum, prev_plus):
    cnt = 0
    total_sum = 0
    for i, c in enumerate(cumsum):
        c = c + total_sum
        if prev_plus:
            # if minus, ignore
            if c < 0:
                pass
            else:
                cnt += (c - (-1))
                total_sum -= (c - (-1))
        else:
            if c > 0:
                pass
            else:
                cnt += (1 - c)
                total_sum += (1 - c)
        prev_plus = not prev_plus
    return cnt


def main():
    N = I()
    A = LI()
    cumsum = [0]
    for i in range(N):
        cumsum.append(A[i] + cumsum[i])
    cumsum = cumsum[1:]
    prev_plus = cumsum[0] > 0
    a1 = solve(cumsum, True)
    a2 = solve(cumsum, False)
    print(min(a1, a2))

main()



Measured memory_bytes: 16736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int n;

int chain(vector<int> chara, int s, int color) {
	chara[s] = color;
	int size = n;
	bool change = true;
	while (change) {
		change = false;
		for (int i = 0, j = 0; j < size; i = j) {
			while (j < size && chara[i] == chara[j])
				j++;
			if (j - i >= 4) {
				chara.erase(chara.begin() + i, chara.begin() + j);
				change = true;
				size = chara.size();
				break;
			}
		}
	}

	return chara.size();
}

int main() {
	while (cin >> n && n != 0) {
		vector<int> chara(n);
		int ans = n;
		for (int i = 0; i < n; ++i) {
			cin >> chara[i];
		}

		chain(chara, 5, 2);

		for (int i = 0; i < n; ++i) {
			for (int j = 1; j <= 3; ++j) {
				if (chara[i] != j)
					ans = min(ans, chain(chara, i, j));
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3156
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int s, w;
    cin >> s >> w;
    if (s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#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() {
    int a, b, c;
    cin >> a >> b >> c;
    string ans;
    if (a + b >= c) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
}

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

int main() {
	int n,d,temp=0,count=0;
  	cin>>n>>d;
  	temp=(2*d)+1;
  	count=n/temp;
  	if(n%temp)
  	    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 < n;i++)

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << 10 * max({A, B, C}) + A + B + C - max({A, B, C}) << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
for i in range(1,n):
    b.append(b[-1]+a[i])
s=sum(a)
ans=10**20
for i in range(n-1):
    ans=min(ans,abs(s-2*b[i]))
print(ans)


Measured memory_bytes: 30632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args)throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		String check;
		int[] a = new int[2];
		int sum = 0, sums = 0;
		float ave = 0, n = 1f;
		while((check = bf.readLine()) != null){
			String[] temp = check.split(",");
			for(int i = 0; i < 2; i++){
				a[i] = Integer.parseInt(temp[i]);
			}
			sum += a[0] * a[1];
			sums += a[1];
			ave = sums / n;
			if(ave % 1 > 0.4) ave++;
			n++;
		}
		out.println(sum + "\n" + (int)ave);
		out.flush();
	}
}

Measured memory_bytes: 24252
#include <bits/stdc++.h>
 
using namespace std;
 
int n, ptr;
string s;
int cnt[1000] = {};
 
int dfs()
{
  if(s[ptr] == '[') {
    ++ptr;
    int latte = dfs();
    ++ptr;
    int malta = dfs();
    ++ptr;
    if(cnt[latte] > 0) {
      --cnt[latte];
      return (latte);
    } else {
      --cnt[malta];
      return (malta);
    }
  } else {
    return (s[ptr++]);
  }
}
 
int main()
{
  cin >> s;
 
  for(int i = 0; i < s.size(); ++i) {
    if('a' <= s[i] && s[i] <= 'z') n++;
  }
 
  for(int i = 0; i < n; ++i) {
    char c;
    cin >> c;
    cin >> cnt[c];
  }
 
  dfs();
  for(int i = 0; i < 1000; i++) {
    if(cnt[i] != 0) {
      cout << "No" << endl;
      return (0);
    }
  }
 
  cout << "Yes" << endl;
}

Measured memory_bytes: 3200
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	long a,b,c,d,e;
	scanf("%ld%ld%ld",&a,&b,&c);
	d=(c-a-b)*(c-a-b);
	e=4*a*b;
	if(c-a-b<=0) printf("No");
	else printf(d>e?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int a[N];
int sum = 0;
for(int i = 0;i < N;i++){
  cin >> a[i];
  sum += a[i];
}
sort(a,a+N);

int b = sum - a[N-1];
if(a[N-1] < b){
  cout <<"Yes" <<endl;
}
else{
  cout << "No" <<endl;
}
}



Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, x = sc.nextInt

    val result =
      if (500 * n >= x) {
        "Yes"
      } else {
        "No"
      }

    println(result)
  }
}


Measured memory_bytes: 25900
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
    	
    	Scanner scanner = new Scanner(System.in);
    	int a = scanner.nextInt();
    	int b = scanner.nextInt();
    	
    	int x = a/b;
    	int y = a%b;
    	double z = 1.0*a/b;

      	System.out.println(x +" " +y+" "+String.format("%.5f",z));
    	
    }

}

Measured memory_bytes: 26556
object Main {
  def solve(result: Array[Array[Int]]): (Array[Int], Array[Boolean]) = {
    val rank = result.map(res => res.map(s => (if (s != -1) 1 else 0)).sum)
    val time = result.map(_.sum)
    val ret = rank.zipWithIndex.sortWith((p, q) =>
      (if (p._1 == q._1)
        if (time(p._2) == time(q._2)) p._2 > q._2
        else time(p._2) < time(q._2)
       else p._1 > q._1)).map(p => p._2 + 1)
    val eq = ret.init.zip(ret.tail).map(p =>
      rank(p._1 - 1) == rank(p._2 - 1) && time(p._1 - 1) == time(p._2 - 1))
    (ret, eq)
  }

  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var f = true
    while(f) {
      val m, t, p, r = sc.nextInt
      if(m == 0 && t == 0 && p == 0 && r == 0) f = false
      else {
        val result = Array.fill[Int](t, p)(-1)
        val penalty = Array.ofDim[Int](t, p)
        for(_ <- 1 to r) {
          val mm, tt, pp, j = sc.nextInt
          if (j == 0) result(tt - 1)(pp - 1) = mm + penalty(tt - 1)(pp - 1) * 20
          else penalty(tt - 1)(pp - 1) += 1
        }
        val (rank, eq) = solve(result)
        rank.init.zip(eq).foreach( x => if (x._2) print (x._1 + "=")
                                        else print (x._1 + ","))
        println(rank.last)
      }
    }
  }
}

Measured memory_bytes: 88160
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<double,double>P;

int main()
{
    ll n;
    cin>>n;
    map<ll,int>h;
    vector<ll> can;
    rep(i,n)
    {
        ll t;
        cin>>t;
        h[t]++;
    }
    for(auto itr=h.begin();itr!=h.end();itr++)
    {
        if(itr->second>=2)
        {
            can.push_back(itr->first);
        }
        if(itr->second>=4)
        {
            can.push_back(itr->first);
        }
    }
    
    if(can.size()<2)
    {
        cout<<0<<endl;
        return 0;
    }
    sort(can.begin(),can.end(),greater<ll>());
    cout<<can[0]*can[1]<<endl;

}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define For(i, s, e) for(int i = s;i <= e;i++)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    ll n,ans = 0,A = 0,B = 0, AB = 0;
    cin >> n;
    string s;
    rep(i,n) {
        cin >> s;
        rep(j,s.size()-1) {
            if(s[j] == 'A' && s[j+1] == 'B') ans++;
        }
        if(s[0] == 'B' && s[s.size() -1] == 'A') {
            AB++;
        } else if(s[0] == 'B') {
            B++;
        } else if(s[s.size()-1] == 'A') {
            A++;
        }
    }
    if(AB == 0) {
        ans += min(A,B);
    } else if (A+B == 0){
        ans += AB-1;
    } else {
        ans += min(A+AB,B+AB);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
	int N, i, H[100005], max, flag = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}
	max = H[0];
	for (i = 0; i < N; i++) {
		if (H[i] - 1 >= max) {
			max = H[i] - 1;
		}
		else if (H[i] >= max) {
			max = H[i];
		}
		else if (H[i] - 1 < max){
			puts("No");
			break;
		}
	}
		if(i == N) {
			puts("Yes");
		}
	return 0;
}


Measured memory_bytes: 512
//Bismillahir rahmanir rahim
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define FastIo ios_base::sync_with_stdio(false);cin.tie(NULL);
double arr[3005];
int n;
double dp[3005][3005];
int vis[3005][3005];
double solve(int pos,int cnt)
{
    if(pos > n && cnt<=(n/2)) return 0;
    if(pos > n) return 1.0;
    double &ret=dp[pos][cnt];
    if(vis[pos][cnt] != -1) return ret;
    vis[pos][cnt]=0;
    ret=0;
    ret += solve(pos+1,cnt+1) * arr[pos];
    ret += solve(pos+1,cnt) * (1.0-arr[pos]);
    return ret;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lf",&arr[i]);
    }
    memset(vis,-1,sizeof(vis));
    double ans = solve(0,0);
    printf("%.10f\n",ans);
    return 0;
}



Measured memory_bytes: 106112
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

 
int main() {
	
int N;
vector<int> G(1001);
cin>>N;
	
fyg(N+1,1){
	int a=y,i=2;
while(a!=1){
	if(a%i==0){
		G.at(i)++;
		//G.at(a/i)++;
		a/=i;
	}else{
		i++;
	}
}

}

ll ans=1;

fyg(N+1,2){
	
	if(G.at(y)!=0){
           ans*=G.at(y)+1;
           ans%=1000000007;
         }
	
}

ce(ans)
	
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		System.out.println(x*x*x);
	}
	
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17156
# -*- coding: utf-8 -*-

list = []
for _ in range(2):
    list.append(input())

S = list[0]
T = list[1]

s = len(S)
t = len(T)


if t == s + 1 and S == T[: -1]:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 8944
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (ll)1e9+7;
ll CaseN=1;

ll tst(ll N)
{
ll ans=0;


return ans;
}


void solve()
{
	ll k,ans=0;
	cin>>k;
	bool ch=false;
	// check all 
	ll p = 1;
	ll sum=0;
	for(ll i=1;i<=1000000;i++)
	{
	sum+=(p*7)%k;
	if(sum%k==0)
	{
		ans = i ;
		ch=true;
		break;
	}
	p = (p*10)%k;	
	}
	
	
	if(ch)
	cout<<ans<<endl;
	else
	cout<<"-1"<<endl;
	//cout<<"Case #"<<CaseN<<": ";	
	CaseN++;
		// print your ans below;		
	
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}
/*
 if(ans)
  {
  cout<<"YES"<<endl; 
  }
  else
   {
  cout<<"NO"<<endl;
  }

*/


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

int main(int argc, char const *argv[]) {
    int a, b;
    cin >> a >> b;
    cout << a/b << ' ' << a%b << ' ' << fixed << setprecision(20) << double(a)/double(b) << endl;

    return 0;
}


Measured memory_bytes: 3276
N, M = (int(i) for i in input().split())
  
dict_rel = dict()
for i in range(M):
  dict_rel[i+1] = [int(j) for j in input().split()][1:]
list_cond = [int(i) for i in input().split()]

#print(dict_rel)
#print(list_cond)

list_pattern = [[] for j in range(2**N)]

for i in range(len(list_pattern)):
  b = bin(i)[2:].zfill(N)
  list_pattern[i] = [int(k) for k in b]

#print(list_pattern)

num_full = 0
for pattern in list_pattern:
  flg = True
  for light in dict_rel.keys():
    num_on = 0
    for i in dict_rel[light]:
      if pattern[i-1] == 1:
        num_on += 1
    if list_cond[light-1] != num_on%2:
      flg = False
      #break
  if flg == True:
    num_full += 1

print(num_full)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string S; cin >> S;
    for (int i = 0; i < S.size()-1; i++) {
        if (S[i] == 'A' && S[i+1] == 'C') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

  vector<long long> w(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  // dp[i+1][j+1] := i番目までの品物からいくつかを選んだとき,
  // 重さがj以下となるときの価値の総和の最大値
  vector<vector<long long>> dp(n + 1, vector<long long>(lim_w + 10, 0LL));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= lim_w; j++) {
      if (j - w[i] >= 0) {
        // i番目の品物を選ぶ
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
      }
      // i番目の品物を選ばない
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    }
  }

  cout << dp[n][lim_w] << endl;

  return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int m,n;
	cin >> m >> n;
	vector<int> p(m),c(n),e(n);
	rep(i,0,m) cin >> p[i];
	rep(i,0,n) cin >> c[i] >> e[i];

	sort(p.rbegin(),p.rend());
	vector<int> sum(m+1);
	rep(i,0,m) sum[i+1]=sum[i]+p[i];

	int ans=max(0,sum[min(c[0],m)]-e[0]);
	static int dp[500][10001];
	fill_n((int*)dp,500*10001,INF);
	rep(i,0,c[0]+1) dp[0][i]=e[0];
	rep(i,1,n){
		rep(j,0,c[i]+1) dp[i][j]=e[i];
		rep(j,0,m+1){
			dp[i][j]=min(dp[i][j],min(dp[i-1][j],dp[i-1][max(0,j-c[i])]+e[i]));
			ans=max(ans,sum[j]-dp[i][j]);
		}
	}

	cout << ans << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 20820
#include<iostream>
#include<string>
using namespace std;
int main(){
	int h,m,s,e,r;
	while(true){
	cin>>h>>m>>s;
	e=60*60*2;
	if(h==-1&&m==-1&&s==-1)
		break;
	e-=60*60*h;
	e-=60*m;
	e-=s;
	r=e*3;
	h=e/3600;
	e-=h*3600;
	m=e/60;
	e-=m*60;
	s=e;
	cout<<"0"<<h<<":";
	if(m<10)
		cout<<"0";
	cout<<m<<":";
	if(s<10)
		cout<<"0";
	cout<<s<<endl;

	h=r/3600;
	r-=h*3600;
	m=r/60;
	r-=m*60;
	s=r;
	cout<<"0"<<h<<":";
	if(m<10)
		cout<<"0";
	cout<<m<<":";
	if(s<10)
		cout<<"0";
	cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
K = int(input())

def dfs(val, digit, all):

    all.append(val)

    if digit == 10:
        return

    for i in range(-1, 2):
        add = val % 10 + i
        if 0 <= add <= 9:
            dfs(val*10 + add, digit+1, all)

all = []

for i in range(1, 10):
    dfs(i, 1, all)

all.sort()

print(all[K-1])

Measured memory_bytes: 12304
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int x, y, z;

string solve() {
    return to_string(z) + " " + to_string(x) + " " + to_string(y);
}

void input() {
    cin >> x >> y >> z;
}

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

    input();
    cout << solve() << endl;
}


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

int main() {
	long long int a, b, n;
	cin >> a >> b >> n;
	long long int z = b - 1;
	if (z > n) z = n;
	int ans = (a * z) / b - a * (z / b);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>

int saikoro1(int a[7],char b[101]) {
	unsigned int x,i;
	for (i = 0; i < strlen(b); i++) {
		if (b[i] == 'N') {
			x = a[0];
			a[0] = a[1];
			a[1] = a[5];
			a[5] = a[4];
			a[4] = x;
		}else if (b[i] == 'E') {
			x = a[0];
			a[0] = a[3];
			a[3] = a[5];
			a[5] = a[2];
			a[2] = x;
		}
		else if (b[i] == 'S') {
			x = a[0];
			a[0] = a[4];
			a[4] = a[5];
			a[5] = a[1];
			a[1] = x;
		}
		else if (b[i] == 'W') {
			x = a[0];
			a[0] = a[2];
			a[2] = a[5];
			a[5] = a[3];
			a[3] = x;
		}
	}
	return a[0];
}

int saikoro2(int a[7],int b,int c){
	int i=0, j=0,k=0;
	
	while (a[0] != b || a[1] != c) {
		for (i = 0; i < 4; i++) {
			saikoro1(a, "N");
			if (a[0] == b && a[1] == c) break;
			for (j = 0; j < 4; j++) {
				saikoro1(a, "E");
				if (a[0] == b && a[1] == c) break;
				for (k = 0; k < 4; k++) {
					saikoro1(a, "N");
					if (a[0] == b && a[1] == c) break;
				}
				if (a[0] == b && a[1] == c) break;
			}
			if (a[0] == b && a[1] == c) break;
		}

	}

	return a[2];
}

struct dice {
	int men[7];
};

int main() {
	int i,q,q1,q2;
	struct dice d1;

	for (i = 0; i < 6; i++) {
		scanf("%d",&d1.men[i]);
	}
	
	scanf("%d", &q);

	for (i = 0; i < q; i++) {
		scanf("%d %d", &q1, &q2);

		printf("%d\n", saikoro2(d1.men,q1,q2));
	}


	

	return 0;
}


Measured memory_bytes: 2036
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) { 
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
const int MOD = 1e9 + 7, INF = 1e9 + 5;
const ll LONG_INF = 1e18 + 10;
inline ll powmod(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)res=res*a%MOD;return res;}
inline ll power(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a)if(b&1)res=res*a;return res;}

const int MAXN = 2e5 + 10;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string x;
        cin >> x;
        int rem = 0;
        for(char c : x){
                rem = (rem + (c - '0')) % 9;
        }
        cout << (rem == 0 ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3744
#include<stdio.h>
int main()
{
    int a,b,c;
    char s[101];
    scanf("%s",s);
 for(a=0;a<10;a++){
 if(s[a]=='A'||s[a]=='T'||s[a]=='C'||s[a]=='G'){b++;if(b>c)c=b;}
  else b=0;
 }
 printf("%d",c);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

bool ok=true;
ll k,a[100010],l=2,s=2;

int main(void){
	cin>>k;
	rep(i,k)cin>>a[i];
	irep(i,k){
		if(s<=l/a[i]*a[i] && l/a[i]*a[i]<=l)l=l/a[i]*a[i]+a[i]-1;
		if(s<=s/a[i]*a[i] && s/a[i]*a[i]<=l){
			s=s/a[i]*a[i];
		}else{
			s=(s/a[i]+1)*a[i];
		}
		if(l<s){
			ok=false;
			break;
		}
	}
	if(ok){
		cout<<s<<" "<<l<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            long MOD_NUMBER = 1000000007;

            int item_cnt = getIntParam();
            long[] items = getLongParams();

            long sum = 0;
            long answer = 0;

            for (int i = 0; i < item_cnt; i++)
            {
                sum += items[i];
                sum %= MOD_NUMBER;
            }

            for (int i = 0; i < item_cnt; i++)
            {
                sum -= items[i];
                if (sum < 0)
                {
                    sum += MOD_NUMBER;
                }
                answer += (sum * items[i]);
                answer %= MOD_NUMBER;
            }
            Console.WriteLine(answer);
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


Measured memory_bytes: 47476
# -*- coding: utf-8 -*-

inlist = list(map(int, input().split()))
a = inlist[0] * 100
b = inlist[1] * 100
c = inlist[2]
d = inlist[3]
e = inlist[4]
f = inlist[5]

tupleList = []

for i in range((f//a) + 1):
    for j in range((f - a*i)//b + 1):
        for k in range((f - a*i - b*j)//c + 1):
            for l in range((f - a*i - b*j - c*k)//d + 1):
                if (c*k + d*l)*(100 + e) <= (a*i + b*j + c*k + d*l)*e:
                    tupleList.append([i, j, k, l])
tupleList.remove([0, 0, 0, 0])

def concentration(i, j, k, l):
    return (c*k + d*l)/(a*i + b*j + c*k + d*l)

max_con = concentration(tupleList[0][0], tupleList[0][1], tupleList[0][2], tupleList[0][3])
max_tuple = tupleList[0]

for i in range(len(tupleList) - 1):
    if max_con < concentration(tupleList[i+1][0], tupleList[i+1][1], tupleList[i+1][2], tupleList[i+1][3]):
        max_con = concentration(tupleList[i + 1][0], tupleList[i + 1][1], tupleList[i + 1][2], tupleList[i + 1][3])
        max_tuple = tupleList[i + 1]

print(str(a*max_tuple[0] + b*max_tuple[1] + c*max_tuple[2] + d*max_tuple[3]) \
      + " " + str(c*max_tuple[2] + d*max_tuple[3]))


Measured memory_bytes: 85216
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll llf=1e18;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
char s[maxn];
vector<int>f[maxn];
typedef pair<int,int> pii;
vector<pii>ans;
int cnt[maxn];
void dfs(int u){
	cnt[u]=1;
	for(int x:f[u]){
		ans.push_back(pii(u,x));
		dfs(x); 
		cnt[u]+=cnt[x];
		if(s[n-cnt[x]]=='0'){
			cout<<-1<<endl;
			exit(0);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>s+1;
	n=strlen(s+1);
	if(s[n]=='1'||s[1]=='0'){
		cout<<"-1"<<endl;
		return 0;
	}
	int rt=1,r=3;
	f[rt].push_back(2);
	for(int i=2;i<n;i++){
		if(s[i]=='1'){
			f[r].push_back(rt);
			rt=r;
			r++; 
		}else{
			f[rt].push_back(r++);
		}
	}
	dfs(rt);
	for(pii x:ans) cout<<x.fi<<" "<<x.se<<endl;
	return 0;
}


Measured memory_bytes: 14576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
using ll  = long long;
#define int ll
using pii = pair<int, int>;

gp_hash_table<int, int> dist;
const int INF = 1e18;

int mul(int a, int b) {
	if (a && b > INF / a) {
		return INF;
	}
	return a * b;
}

void solve() {
	dist.clear();
	int n;
	int a;
	int b;
	int c;
	int d;
	cin >> n >> a >> b >> c >> d;
	priority_queue<pii, vector<pii>, greater<pii>> q;
	q.emplace(0, n);
	int ans = INF;
	while (q.size()) {
		int dst;
		int v;
		tie(dst, v) = q.top();
		q.pop();
		if (dist.find(v) != dist.end() && dist[v] <= dst) {
			continue;
		}
		dist[v] = dst;
		if (dst >= ans) {
			break;
		}
		ans = min(ans, dst + mul(d, v));
		q.emplace(dst + d * (v % 2) + a, v / 2);
		q.emplace(dst + d * (2 - v % 2) + a, v / 2 + 1);
		q.emplace(dst + d * (v % 3) + b, v / 3);
		q.emplace(dst + d * (3 - v % 3) + b, v / 3 + 1);
		q.emplace(dst + d * (v % 5) + c, v / 5);
		q.emplace(dst + d * (5 - v % 5) + c, v / 5 + 1);
	}
	cout << ans << "\n";
}

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::sync_with_stdio(0), cin.tie(0);

	int tn;
	cin >> tn;
	while (tn--) {
		solve();
	}

    return 0;
}


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

def floyd_warshall(dist):
    v = len(dist)
    for k in range(v):
        for i in range(v):
            for j in range(v):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
floyd_warshall(c)
A = [list(map(int, input().split())) for _ in range(H)]
ans = 0
for row in A:
    for a in row:
        if a != -1:
            ans += c[a][1]
print(ans)


Measured memory_bytes: 41564
N = int(input())
A = [int(x) for x in input().split()]

def count_negative(A):
    count = 0
    for i in range(len(A)):
        if A[i] < 0:
            count += 1
    return count

def find_zero(A):
    for i in range(len(A)):
        if A[i] == 0:
            return True
    return False

def even(x):
    if x % 2 == 0:
        return True
    return False

def flipping_signs(A):
    A_abs = [abs(x) for x in A]
    sum_A_abs = sum(A_abs)
    if even(count_negative(A)) or find_zero(A):
        print(sum_A_abs)
    else:
        A_abs_min = min(A_abs)
        print(sum_A_abs - 2 * A_abs_min)

flipping_signs(A)

Measured memory_bytes: 14496
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;

int main() {
	ios_base::sync_with_stdio(0);
	int a,b,n,T,cas=0;
	cin>>n;
	int cnt[10][10] = {};
	for(int i=1;i<=n;++i) {
		cnt[i%10][to_string(i)[0]-'0']++;
	}
	long long res=0;
	for(int i=1;i<=9;++i) {
		for(int j=1;j<=9;++j) {
			res+=cnt[i][j]*cnt[j][i];
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int N, T, E, x[102];

int solve() {
  rep(i,N) {
    if ((x[i] >= T) && (T + E >= x[i])) return i + 1;
    int d = T % x[i];
    if ((E >= d) || (E >= x[i] - d)) return i + 1;
  }
  return -1;
}

int main() {
  while (scanf("%d%d%d", &N, &T, &E) != -1) {
    rep(i,N) scanf("%d", x+i);
    printf("%d\n", solve());
  }
  return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;
public class Main{

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

        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int count = 0;
        for (int i = 0; i <= n; i += r) {
            for (int j = 0; i + j <= n; j+= g) {
                if((n - i - j) % b == 0){
                    count++;
                }                
            }
        }
		System.out.println(count);
    }
}


Measured memory_bytes: 22608
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i = int(l); i <= int(r); ++i)
#define SIZE 26     
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const int N = 2e5 + 5;

signed main(){
    fastio;
    int i,n,q,l,r,x,pos;
    char c;
    string str;
    set<int> s[26];
    cin>>n>>str>>q;
    for(i=0;i<n;i++){
        s[str[i]-'a'].insert(i);
    }
    while(q--){
        cin>>x;
        if(x==1){
            cin>>pos>>c;
            s[str[pos-1]-'a'].erase(pos-1);
            s[c-'a'].insert(pos-1);
            str[pos-1]=c;
        }
        else{
            cin>>l>>r;
            int ans=0;
            for(i=0;i<26;i++){
                if(s[i].lower_bound(l-1)!=s[i].end()){
                    auto it=s[i].lower_bound(l-1);
                    if(r-1>=*it) ans++;
                }
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24220
#include <stdio.h>

int main(void)
{
    int n, i = 0, count = 0, s = 0;

    scanf("%d", &n);

    while (n > 0) 
    {
        if (n % 2 != 0)
        {
            count = 0; 
            for (i = 1; i <= n; i++)
            {
                if (n % i == 0)
                {
                    count++;
                }
            }

            
            if (count == 8)
                s = s + 1;
        }
        n--;
    }

    printf("%d\n", s);

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;


main(){
  int n; cin >> n;
  vi s(n); rep(i,n) cin >> s[i];
  sort(all(s));
  int sum = SUM(s);
  if(sum % 10 != 0){
    cout << sum << endl;;
    return 0;
  }else
    rep(i,n)
      if(s[i] % 10 != 0){
	cout << sum - s[i] << endl;
	return 0;
      }

  cout << 0 << endl;
}

Measured memory_bytes: 256
s = input()

s_a = int(s[:2])
s_b = int(s[2:])

if 1 <= s_a <=12 and 1 <= s_b <=12:
  ans = "AMBIGUOUS"
elif not(1 <= s_a <=12) and 1 <= s_b <=12:
  ans = "YYMM"
elif 1 <= s_a <=12 and not(1 <= s_b <=12):
  ans = "MMYY"
else:
  ans = "NA"

print(ans)

Measured memory_bytes: 9032
#include<bits/stdc++.h>
#define MAX 1<<17
#define F 114514810
using namespace std;int dp[MAX];int n,t[20][20];int Fix(int q){int res=1;while(q--)res*=2;return res;}bool Vis(int now,int stage){int r=1;while(stage--)r*=2;if(now%(r*2)<r)return 0;return 1;}int main(){while(cin>>n&&n){for(int i=0;i<n;i++){cin>>t[i][n];for(int j=0;j<n;j++)cin>>t[i][j];}dp[0]=0;for(int i=1;i<Fix(n);i++)dp[i]=F;for(int i=0;i<Fix(n);i++){for(int j=0;j<n;j++){if(!Vis(i,j)){dp[i+Fix(j)]=min(dp[i+Fix(j)],dp[i]+t[j][n]);for(int k=0;k<n;k++)if(Vis(i,k))dp[i+Fix(j)]=min(dp[i+Fix(j)],dp[i]+t[j][k]);}}}cout<<dp[Fix(n)-1]<<endl;}return 0;}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
// const int N = ;
using ll = long long;
using ii = pair <int , int>;

int main() {
	string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
    l.append(input())
l.sort()
l.append('1')
f=1
m=1
for i in range(n):
    if l[i]==l[i+1]:
        f+=1
    else:
        m=max(m,f)
        f=1
ans=[]
for i in range(n):
    if l[i]==l[i+1]:
        f+=1
    else:
        if f==m:
            ans.append(l[i])
        f=1
for i in ans:
    print(i)

Measured memory_bytes: 83352
import math
d,g = map(int, input().split())
l = []
ans = 10**5

for i in range(d):
    l.append(list(map(int, input().split())))

for i in range(2 ** d):
    count = 0
    score = 0
    remain = -1
    for j in range(d):
        if (i >> j) & 1: # j: コンプリートしない問題
            count += l[j][0]
            score += l[j][1] + l[j][0] * 100 * (j+1)
        else:
            remain = j
    if score >= g:
        ans = min(ans, count)
    else:# remain: コンプリートしない問題でもっとも点数の高い問題
        s1 = 100 * (remain+1)
        need_n = math.ceil((g - score) / s1)
        if need_n >= l[remain][0]:
            continue
        count += need_n
        ans = min(ans, count)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

  int a[5];
  int maxDiff = 0;
  int maxIndex = -1;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];

    int q = (a[i] + (10 - 1)) / 10;
    int diff = 10 * q - a[i];
    if (diff > maxDiff) {
      maxDiff = diff;
      maxIndex = i;
    }
  }

  int time = 0;
  for (int i = 0; i < 5; i++) {
    int cur = 0;
    if (i != maxIndex && a[i] % 10 != 0) {
      time += (10 - (a[i] % 10));
    }
    time += a[i];
  }

  cout << time << endl;
}

Measured memory_bytes: 256