akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var S = Read();
            var ans = 0;
            foreach (var s in S)
            {
                if (s == '+') ans++;
                else ans--;
            }
            Println(ans);
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
const int MAX = 510000;
int P, Q, A, N;

int dfs(int p, int q, int en, int idx)
{
    if (P * q == p * Q)
        return 1;

    if (P * q < p * Q)
        return 0;
    if (en == N)
        return 0;

    int res = 0;
    for (int i = idx; q * i <= A; i++)
    {
        res += dfs(p * i + q, q * i, en + 1, i);
    }
    return res;
}

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

    while (cin >> P >> Q >> A >> N, P || Q || A || N)
    {
        cout << dfs(0, 1, 0, 1) << endl;
    }

    return 0;
}


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

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

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

int  main()
{
	int a,b,c;
	cin >> a >> b >> c;
	for (int i = 1; i <= b ; i++)
	{
		if ((i*a) % b == c)
		{
			cout << "YES"; return 0;
		}
	}
	cout << "NO" << endl;
	return (0);
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS r = new FS();
		int a = r.nextInt();
		int b = r.nextInt();
		int c = r.nextInt();
		if((a==5&&b==5&&c==7) || (a==5&&b==7&&c==5) || (a==7&&b==5&&c==5)) System.out.println("YES");
		else System.out.println("NO");
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 8020
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
  LL n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int main() {
  ll n;
  cin >> n;
  vec a(n),b(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    b[i]=a[i];
  }
  sort(a.begin(),a.end());
  ll lm=a[n/2-1];
  ll rm=a[n/2];
  for(ll i=0;i<n;i++) {
    if(b[i]<=lm) cout << rm << endl;
    else cout << lm << endl;
  }
}

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

const double eps = 1e-10;
bool dcmp(double d, double d2 = 0) { return abs(d - d2) < eps; }

struct vec {
  double x, y;
  vec(double x, double y) : x(x), y(y) {}
  vec() : x(0), y(0) {}
  const bool operator==(const vec &v) const {
    return dcmp(x, v.x) && dcmp(y, v.y);
  }
  const bool operator!=(const vec &v) const { return !(*this == v); }
  const vec operator+(const vec &v) const { return vec(x + v.x, y + v.y); }
  const vec operator-() const { return vec(-x, -y); }
  const vec operator-(const vec &v) const { return *this + (-v); }
  const vec operator*(const double d) const { return vec(x * d, y * d); }
  const vec operator/(const double d) const { return *this * (1 / d); }
  const vec unit() const { return *this / len(); };
  const double len() const { return sqrt(x * x + y * y); }
  const double dot(const vec &v) const { return x * v.x + y * v.y; }
  const double cross(const vec &v) const { return x * v.y - y * v.x; }
  const bool parallel(const vec &v) const { return dcmp(cross(v)); }
  const bool perpendicular(const vec &v) const { return dcmp(dot(v)); }
};

typedef vec point;

int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    point p0, p1, p2, p3;
    cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
    vec v0 = p1 - p0, v1 = p3 - p2;
    if (v0.parallel(v1))
      puts("2");
    else if (v0.perpendicular(v1))
      puts("1");
    else
      puts("0");
  }
}


Measured memory_bytes: 3208
// Created by the_solver...
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];

void fastio()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


void solve()
{
	
	int n,k;cin>>n>>k;
	int a[n],dp[n+1];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<=n;i++)dp[i] = mod;
	dp[0] = 0;
	// dp[1] = abs(a[1]-a[0]);
	// dp[2] = min((dp[1]+abs(a[2]-a[1])),abs(a[2]-a[0]));
	int i,j;
	for(int i=1;i<n;i++)
	{
		for(i-k<0?j=0:j=i-k;j<i;j++){//dont know why j<=i got accepted and j<i not!!!
		dp[i] = min((dp[j]+abs(a[j]-a[i])),dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;
}


int32_t main()
{
    
    //fastio();
    // int t;cin>>t;
    // while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back

int main() {
  ll n,h;
  cin >> n >> h;

  vector<ll> b(n,0),a(n,0);
  rep(i,n) {
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  auto itr = upper_bound(b.begin(), b.end(), a.back());
  ll st = itr - b.begin();

  ll ans = 0;
  for (int i = b.size()-1; i >= st; --i) {
    if (h <= 0) break;
    ans++;
    h -= b[i];
  }
  if (h > 0) {
    ans += h / a.back();
    ans += (h % a.back() > 0) ? 1 : 0;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll,int> mp;
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(a.rbegin(),a.rend());
  int ans = 0;
  rep(i,n){
    if(mp.count(a[i])<=0) continue;
    ll b = 1;
    while(b<=a[i]) b*=2;
    ll pe = b - a[i];
    if(mp.count(pe)){
      if(pe==a[i]&&mp[a[i]]==1) continue;
      if(mp[a[i]]<=0||mp[pe]<=0) continue;
      mp[pe]--;
      mp[a[i]]--;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    string ans = t + s;

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

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

int main(int args, char *argv[])
{
  int a, b;
  cin >> a;
  cin >> b;

  if (a * b % 2 == 0)
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
}


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

public class PictureMatching
    {
        private static int[] item;

        public static void Main(string[] args)
        {
            Input();
            Method();
        }

        private static void Input()
        {
            System.Console.ReadLine();
            item = ToIntArray(System.Console.ReadLine().Split(' '));
        }

        private static void Method()
        {
                ConsoleWrite(item);
            for (int i = 1; i < item.Length; i++)
            {
                for (int j = i - 1; j >= 0; j--)
                {
                    if (item[j+1] < item[j])
                    {
                        var temp = item[j + 1];
                        item[j + 1] = item[j];
                        item[j] = temp;
                    }
                }
                ConsoleWrite(item);
            }
        }

        private static void ConsoleWrite(int[] nums)
        {
            for (int i = 0; i < nums.Length; i++)
            {
                System.Console.Write(nums[i]);
                if (i != nums.Length - 1)
                {
                    System.Console.Write(" ");
                }
            }
            System.Console.WriteLine("");
        }

        private static int[] ToIntArray(string[] str)
        {
            IEnumerable<int> intArray = str.Select(x => int.Parse(x));
            return intArray.ToArray();
        }
    }

Measured memory_bytes: 9704
#include<bits/stdc++.h>
#define R(n)for(L i=0;i<n;i++)
#define M make_pair
typedef long long L;using namespace std;int main(){L n,k,s,t,a[50];cin>>n>>k>>s>>t;R(n)cin>>a[i];map<pair<L,L>,L> p[50];R(n){for(L j=k-2;j+1;j--)for(auto&l:p[j])p[j+1][M(l.first.first&a[i],l.first.second|a[i])]+=l.second;p[0][M(a[i],a[i])]=1;}n=0;R(k)n+=p[i][M(s,t)];cout<<n;}


Measured memory_bytes: 154036
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
//
#define forn(i, n)for(ll i=0;i<n;i++)
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(ll j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll a,b,t;
int main(){FAST;
cin>>a>>b>>t;
ll bis = t/a;
cout<<bis*b;
return 0;
}




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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define pb push_back

using namespace std;

const int N = 100010;

vector<int> G[N];
int n;
int leaf[N][2];
bool ans;

void DFS(int o, int f){
	if(G[o].size() == 1){
		leaf[o][1] = true;
		return;
	}
	for(int v : G[o]){
		if(v == f) continue;
		DFS(v, o);
		For(i, 0, 1) leaf[o][i] += leaf[v][i ^ 1];
	}
	if(leaf[o][0] > 1) ans = true;
	if(leaf[o][1] > 1 && !f && G[o].size() == 2) ans = true;
	For(i, 0, 1) leaf[o][i] = bool(leaf[o][i]);
	if(G[o].size() > 2 && leaf[o][0]) leaf[o][1] = false;
}

int main(){
	scanf("%d", &n);

	if(n == 2){
		puts("Second");
		return 0;
	}

	For(i, 2, n){
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].pb(v), G[v].pb(u);
	}

	int rt = 0;
	For(i, 1, n) if(G[i].size() != 1) rt = i;
	DFS(rt, 0);

	puts(ans ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 6656
object Main {

    def main(args: Array[String]): Unit = {
      import scala.io.StdIn._
      val Array(r, g, b, n) = readLine().split(" ").map(_.toInt)

      val rMax = n / r
      var c = 0
      for {
        i <- 0 to rMax
        rR = r * i
        gMax = (n - rR) / g
        j <- 0 to gMax
        gG = g * j
        if (n - rR - gG) % b == 0
      } c += 1

      println(c)
    }

}

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

int main(void) {
	char tmp[1000];
	//????????¢????¨??????????????????§?¨?x,y???????????\???
	fgets(tmp, sizeof(tmp), stdin);
	int width = atoi(strtok(tmp," "));
	int height = atoi(strtok(NULL, " "));
	int circleX = atoi(strtok(NULL, " "));
	int circleY = atoi(strtok(NULL, " "));
	int radius = atoi(strtok(NULL, " "));

	if (circleX - radius >= 0 && circleY - radius >= 0 && width >= circleX + radius&&radius&&height >= circleY + radius) printf("Yes\n");
	else printf("No\n");

	return 0;
}

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

int main() {
  int a,b,c,x,k;
  cin >> a >> b >> c >> x;
  k = 0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int l=0;l<=c;l++){
        if(500*i + 100*j + 50*l == x){
          k++;
        }
      }
    }
  }
  
  cout << k << endl;
}


Measured memory_bytes: 256
from fractions import gcd
a,b = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
y = sorted(make_divisors(gcd(a,b)))
r = []
for i in y[1:]:
    y_y = make_divisors(i)
    f = True
    for j in y_y:
        if j in r:
            f = False
            break
    if f:
        r.append(i)
print(len(r)+1)

Measured memory_bytes: 67048
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):
    def step(t, i):
        """i -> i+1 at t"""
        s = S[i] if t < S[i] else math.ceil(t / F[i]) * F[i]
        d = s + C[i]
        return d
    for i in range(N):
        t = 0
        for j in range(i, N-1):
            t = step(t, j)
        print(t)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int()] * (N-1)  # type: "List[int]" 
    S = [int()] * (N-1)  # type: "List[int]" 
    F = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)

if __name__ == '__main__':
    main()


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

int main(){
    int t; cin>>t;
    vector<int> v(t);
    for(int i=1;i<=t;i++) cin>>v[i];
    int n; cin>>n;
    while(n--){
        int index,val;
        cin>>index>>val;
        int sum=0;
        for(int i=1;i<=t;i++){
            if(i==index) sum+=val;
            else sum+=v[i];
        }
        cout<<sum<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
list_H  = list(map(int, input().split()))

#右の数字よりもおっきいときに１，ちっさいときに０
list_H_01 = []
for i in range(n-1):
    if list_H[i] >= list_H[i+1]:
        list_H_01.append(1)
    else:
        list_H_01.append(0)
        
count = 0
list_result=[]
for i in list_H_01:
    
    if i == 0:
        list_result.append(count)
        count = 0
    if i == 1:
        count = count+1
        
list_result.append(count)
        
print(max(list_result))

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

vi a;

int main()
{
    int n, k;
    cin >> n >> k;
    REP(i, n)
    {
        int h;
        cin >> h;
        a.push_back(h);
    }

    sort(ALL(a));
    ll ans = INF;

    REP(i, n - k + 1)
    {
        ans = min(ans, a[i + k - 1] - a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>
using namespace std;
int main() {
	string a;
	int m; 
	cin>>a;
	m=0;
	for(int i=0;i<a.size();i++) {
		if(a[i]=='+') {
			m++;
		}else if(a[i]=='-') {
			m--;
		}
	}
	cout<<m;
} 

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

int main(){
    int N,M,sum=0;
    cin>>N>>M;
    vector<int>A(M);
    for(int i=0;i<M;i++){
        cin>>A.at(i);
        sum += A.at(i);
    }
    if(sum>N){
        cout<<-1<<endl;
    }else{
        cout<<N-sum<<endl;
    }

}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    const ll n = s.size();
    vector<ll> cnt(26, 0);
    rep(i, n) cnt[s[i]-'a']++;
    if (s.size() < 26) {
        rep(i, 26) if (!cnt[i]) {
            cout << s << char('a'+i) << endl;
            break;
        }
    }
    else {
        rrep(i, n) {
            --cnt[s[i]-'a'];
            rep(j, s[i]-'a'+1, 26) {
                if (cnt[j] == 0) {
                    cout << s.substr(0, i) << char('a'+j) << endl;
                    return 0;
                }
            }
        }
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
import sys
from collections import deque

n = int(input())
matches = [None] + [list(map(int, line.split())) for line in sys.stdin]
q = deque(range(1, n + 1))
depth = [0] * (n + 1)
waiting = [-1] * (n + 1)

while q:
    a = q.popleft()
    b = matches[a].pop()
    if waiting[b] == a:
        depth[a] = depth[b] = max(depth[a], depth[b]) + 1
        if matches[a]:
            q.append(a)
        if matches[b]:
            q.append(b)
    else:
        waiting[a] = b

if any(matches):
    print(-1)
else:
    print(max(depth))


Measured memory_bytes: 35336
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b&&b==c) {
        cout << "No" << endl;
    } else if(a!=b&&b!=c&&c!=a){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
//#define sort(nums) sort(nums.begin(),nums.end())
#include <bits/stdc++.h>
#define mod 1000000007
#define deb(x) cout<<#x<<" "<<x<<endl
using namespace std;
using ll = long long int;
double dp[3001][3001];
void jets(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

double solve(vector<double>& coins,int i,int x){
	if(x==0)
		return 1;
	if(i<0)
		return 0;
	if(dp[i][x]>-0.9)
		return dp[i][x];
	return dp[i][x]=coins[i]*solve(coins,i-1,x-1) + (1-coins[i])*solve(coins,i-1,x);
}


int main(){
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    jets();
    int n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    vector<double> coins(n);
    for(int i=0;i<n;i++)
    	cin>>coins[i];
    cout<<fixed<<setprecision(10)<<solve(coins,n-1,(n+1)/2);


    return 0;
}

Measured memory_bytes: 74416
#include <cstdio>
#define MAXN 3000
using namespace std;

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

void solve() {
    dp[1][0] = 1. - p[1];
    dp[1][1] = p[1];
    for (int i = 3; i <= n; i += 2) {
        for (int j = 0; j <= i; ++j) {
            if (j >= 2)
                dp[i][j] += dp[i - 2][j - 2] * p[i - 1] * p[i];
            if (j >= 1)
                dp[i][j] += dp[i - 2][j - 1] * ((p[i - 1] * (1 - p[i])) + ((1 - p[i - 1]) * p[i]));
            dp[i][j] += dp[i - 2][j] * ((1 - p[i - 1]) * (1 - p[i]));
        }
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%lf", p + i);
    }
    solve();
    double ans = 0;
    for (int j = (n >> 1) + 1; j <= n; ++j)
        ans += dp[n][j];
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 68352
import Control.Monad.Trans.Writer.Strict

main = interact $ concat . map (unlines . execWriter . insertionSort . (map read) . words) . tail . lines

insertionSort xs = sorted [[], xs]

sorted [xs, []] = return [xs, []]
sorted [xs, (y:ys)] = (insert [xs, (y:ys)]) >>= sorted

insert [xs, (y:ys)] =
    let xs' = insertElem y xs
    in writer([xs', ys], [(unwords . map show) $ concat [xs', ys]])

insertElem :: Int -> [Int] -> [Int]
insertElem x [] = [x]
insertElem x (y:ys) = if (x < y) then (x:(y:ys)) else (y : (insertElem x ys))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int x,t; cin>>x>>t;
	if(x<=t) cout<<0;
	else cout<<x-t;
	
	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++)  //(i, 10) i=0～i=9まで

int main() {
    // 入力
    int a;
    cin >> a;

    string                       in;
    pair<pair<string, int>, int> p[110];

    rep(i, a) {
        int t;
        cin >> in >> t;
        string tmp = in;

        // 要素を追加 make_pair(キー、値)
        p[i] = make_pair(make_pair(in, -t), i);
    }

    sort(p, p + a);

    // 出力
    rep(i, a) { cout << p[i].second + 1 << endl; }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,s[100000];
int main(void){
    cin>>n;
    for(ll i=1;i<100000;i++){
        s[i]=s[i-1]+i;
      if(n<=s[i]){
        cout<<i<<endl;
        return 0;
      }
    }
}


Measured memory_bytes: 640
from itertools import product
H,W=map(int,input().split())
S=[input() for i in range(H)]
 
isOK=True
 
for y,x in product(range(H),range(W)):
    if S[y][x]=='.':
        continue
    sum=0
 
    if 0<x:
        if S[y][x-1]=='#':sum+=1
    
    if x<W-1:
        if S[y][x+1]=='#':sum+=1
    
    if 0<y:
        if S[y-1][x]=='#':sum+=1
    
    if y<H-1:
        if S[y+1][x]=='#':sum+=1
    
    if sum==0:
        isOK=False
 
if isOK:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9232
def li():
    return list(map(int, input().split()))


def mi():
    return map(int, input().split())


def ii():
    return int(input())


N, A, B = mi()

S = input()
oversea = 0
passes = 0

for i in range(len(S)):
    if S[i] == "a":
        if passes < (A + B):
            print("Yes")
            passes += 1
        else:
            print("No")
    elif S[i] == "b":
        oversea += 1
        if passes < (A + B) and oversea <= B:
            print("Yes")
            passes += 1
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4144
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 30000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 998244353LL
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long powering(long long now, long long now_go) {
	long long ans = 1;
	while (now_go != 0) {
		if (now_go % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		now_go /= 2;
	}
	return ans;
}
vector<long long> calc(vector<long long> a, vector<long long> b) {
	long long k = sqrt(a.size());
	vector<long long> ans;
	for (int i = 0; i < k; ++i) {
		for (int q = 0; q < k; ++q) {
			long long geko = 0;
			for (int t = 0; t < k; ++t) {
				geko += a[i * k + t] * b[t * k + q];
				geko %= MAX_MOD;
			}
			ans.push_back(geko);
		}
	}
	return ans;
}
vector<long long> powered(vector<long long> a, long long n) {
	vector<long long> ans = a;
	n--;
	while (n != 0) {
		if (n % 2 == 1) {
			ans = calc(ans, a);
		}
		a = calc(a, a);
		n /= 2;
	}
	return ans;
}
long long inv(long long now) {
	return powering(now, MAX_MOD - 2LL);
}
long long dp[5001 * 5001] = {};
int main() {
#define int long long
	int n;
	cin >> n;
	int a[2], b[2], c[2];
	REP(i, 2) {
		cin >> a[i] >> b[i] >> c[i];
	}
	for (int te = 0; te < 2; ++te) {
		dp[n] = 0;
		for (int q = 0; q < n; ++q) {
			dp[q] = -LONG_INF;
		}
		for (int q = n; q > 0; --q) {
			dp[q - 1] = max(dp[q - 1], dp[q]);
			if (q >= a[te]) {
				dp[q - a[te]] = max(dp[q - a[te]], dp[q] + (a[(te + 1) % 2] - a[te]));
			}
			if (q >= b[te]) {
				dp[q - b[te]] = max(dp[q - b[te]], dp[q] + b[(te + 1) % 2] - b[te]);
			}
			if (q >= c[te]) {
				dp[q - c[te]] = max(dp[q - c[te]], dp[q] + c[(te + 1) % 2] - c[te]);
			}
		}
		n += dp[0];
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long n,i,j,k,ans;
	ans=0;
	cin>>n;
	for (i=1;i*i<=n;i++)
	{
		j=n-i;
		if (i*i==n)
		{
			break;
		}
		if (j%i==0)
		{
			if (n%(j/i)==0)
			{
				break;
			}
			ans=ans+j/i;	
		}
	}
	cout<<ans<<endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	ll N, ans=0;
	int A[100005];

	cin >> N;
	rep(i,N) cin >> A[i];
	int mx=1;
	rep(i,N){
		//cout << " " << A[i] << "mx=" << mx << endl;
		int sum = A[i] / mx;
		A[i] %= mx;
		if( A[i] == 0 ){
			A[i] = mx;
			sum--;
		}
		if( sum > 0 ){
			A[i] = 1;
		}
		ans += sum;
		mx = max( mx, A[i]+1 );
		//cout << "ans=" << ans << endl;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int t[13];
int res = 0;
void licz(int kt,vector<int> pom){
  if(kt == 13){
    sort(ALL(pom));
    pom.PB(24);
    int ak = 1e9;
    R(i,SZ(pom)-1){
      mini(ak,pom[i+1] - pom[i]);
    }
    maxi(res,ak);
    return;
  }
  if(t[kt] == 0){
    licz(kt+1,pom);
  }else if(t[kt] == 1){
    pom.PB(kt);
    licz(kt+1,pom);
    pom.back() = 24 - kt;
    licz(kt+1,pom);
  }else{
    pom.PB(kt);
    pom.PB(24 - kt);
    licz(kt+1,pom);
  }
}
int n;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n){
    int pom;
    cin >> pom;
    t[pom]++;
    if(pom == 0 || t[pom] == 3){
      cout << "0\n";
      return 0;
    }
  }
  licz(1,{0});
  cout << res << "\n";
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
N, M = min(N, M), max(N, M)

mod = 10 ** 9 + 7

def factorial(n):
    ans = 1
    for i in range(1, n + 1):
        ans = ans * i % mod
    return ans


if N == M:
    ans = 2 * factorial(N) * factorial(M) % mod
elif N + 1 == M:
    ans = factorial(N) * factorial(M) % mod
else:
    ans = 0

print(ans)


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

int INF = 2000000000;

int n, ans=-INF, counts=0;
vector<long int> f(200, 0);
vector< vector<int> > p(200, vector<int>(20, 0));

int main() {
    cin >> n;
    for (int j = 0; j < n; ++j)
    {
        for (int i = 0; i < 10; ++i) {
            int bit;
            cin >> bit;
            f.at(j) |= (bit<<(i));
        }
    }
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i <= 10; ++i) cin >> p.at(j).at(i);
    }
    
    for (int bit = 1; bit < (1<<10); ++bit) // bit != '0000...'
    {
        int sum = 0;
        for (int i = 0; i < n; ++i)
        {
            sum += p.at(i).at(__builtin_popcount(f.at(i)&bit));
        }

        ans = max(ans, sum);
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    long long asum = 0;
    long long bsum = 0;
    vector<pair<long long, pair<long long, long long>>> v;

    for (int i = 0; i < N; i++)
    {
        long long a, b;
        cin >> a >> b;
        bsum += b;
        v.push_back(make_pair(a + b, make_pair(a, b)));
    }

    sort(v.rbegin(), v.rend());

    for (int i = 0; i < N; i += 2)
    {
        asum += v[i].second.first;
        bsum -= v[i].second.second;
    }

    cout << asum - bsum << endl;
}

Measured memory_bytes: 4980
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

vector<ll> ones(60,1LL);

ll solve2(vector<ll> &cand, const int idx, const ll sum, const int K) {
  if(idx < 0) return sum;
  vector<ll> cand2;
  //    REP(i,cand.size()) cout << cand[i] << " "; cout << endl;
  REP(i,cand.size()) {
    if(cand[i] & ones[idx]) {
      cand2.push_back(cand[i]);
    }
  }
  ll ans = 0;
  if(cand2.size() >= K) {
    ans = solve2(cand2, idx-1, sum + ones[idx], K);
  } else {
    ans = solve2(cand, idx-1, sum, K);
  } 
  return ans;
}

ll solve(vector<ll> &s, const int K) {
  const int n = s.size();
  ll max = 0;
  REP(i,n) {
    if(s[i] > max) max = s[i];
  }
  int left = 0;
  REP(i,60) {
    if(max & ones[i]) left = i;
  }
  //  sort(s.begin(), s.end());
  //  reverse(s.begin(), s.end());
#ifdef DEBUG
  REP(i,s.size()) {
    cout << s[i] << " " ;
  }
  cout << endl;
#endif
  ll ans = 0;
  for(int i = left; i >= 0; i--) {
    int cnt = 0;
    vector<ll> cand;
    REP(j,s.size()) {
      if(s[j] & ones[i]) {
	cnt++;
	cand.push_back(s[j]);
      }
    }
    if(cnt >= K) {
      //      cout << "OK" << " " << i << " " << cnt << endl;
      ans = solve2(cand, i-1, ones[i], K);
      break;
    }
  }
  return ans;
}

int main() {
  for(int i = 1; i < ones.size(); i++) {
    ones[i] = ones[i-1] * 2LL;
    //    cout << ones[i] << endl;
  }
  int N; cin>>N;
  int K; cin>>K;
  vector<ll> a(N); 
  vector<ll> s;
  s.reserve(N*(N-1)/2);
  REP(i,N) cin>>a[i];
  for(int i = 0; i < N; i++) {
    ll sum = 0;
    for(int j = i; j < N; j++) {
      sum += a[j];
      s.push_back(sum);
    }
  }
  ll ans = solve(s, K);
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int break_num = 0;
    int a[n];
    bool break_flg[n];
    for ( int i = 0; i < n; i++ ) {
        cin >> a[i];
        break_flg[i] = false;
    }

    int index_num = 0;
    for ( int i = 1; i <= n; i++ ) {
        if ( i - break_num != a[i-1] ) {
            break_num++;
        }
    }

    if ( break_num == n ) {
        cout << -1 << endl;;
    }
    else {
        cout << break_num << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

double A[3005], dp[3005][3005], ans = 0;
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> A[i];
	}
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			if(j == 0)
			{
				dp[i][j] = dp[i - 1][j] * (1 - A[i]);
				continue;
			}
			dp[i][j] = dp[i - 1][j - 1] * A[i] + dp[i - 1][j] * (1 - A[i]);
		}
	}
	for (int i = n / 2 + 1; i <= n; ++i)
	{
		ans = ans + dp[n][i];
	}
	printf("%0.10lf\n", ans);
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll r[110000], r2[110000];
ll n, l;
int main() {
	cin >> n >> l;
	vector<P> s(n);
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		s[i] = P(a, b);
	}
	sort(ALL(s));
	REP(i, n) {
		ll cost = s[i].first - i - 1;
		if (s[i].second == 1) cost *= -1;
		r[i + 1] = r[i] + cost;
	}
	REPR(i, n - 1) {
		ll cost = l - s[i].first - (n - i - 1);
		if (s[i].second == 0) cost *= -1;
		r2[i] = r2[i + 1] + cost;
	}
	ll ans = 0;
	REP(i, n + 1) ans = max(ans, r[i] + r2[i]);
	cout << ans << endl;
}


Measured memory_bytes: 5908
MAX = 10**9 + 7

def mod_inv(i, mod):
    return pow(i, mod-2, mod)

def combination(_N, _K):
    if _K > (_N/2):
        _K = _N - _K
    up = 1
    low = 1
    for i in range (_K):
        up = up * (_N - i) % MAX
        low = low * (i + 1) % MAX
    ret = up * mod_inv(low, MAX) % MAX
    return ret

def solve():
    N, M, K = [int(_) for _ in raw_input().split()]
    disSum = (M*N* ((M*(N+1)*(N-1))%MAX + (N*(M+1)*(M-1)) % MAX)) % MAX
    disSum *= mod_inv(6, MAX) % MAX
    ret = disSum * combination(M*N-2, K-2) % MAX
    print ret

if __name__ == '__main__':
    solve()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll mod_pow(ll x, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n % 2) 
            ret *= x;
        x *= x;
        ret %= mod;
        x %= mod;
        n >>= 1;
    }
    return ret;

    //ll ret = 1;
    //while(n > 0){
    //    ret *= x;
    //    ret %= mod;
    //    n--;
    //}
    //return ret;
}


int main(){
    ll N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    ll ans = 0;
    if(P == 2){
        REP(i,N){
            int x = S[i] - '0';
            if(x % 2 == 0)
                ans += N-i;
        }
    }
    else if(P == 5){
        REP(i,N){
            int x = S[i] - '0';
            if(x % 5 == 0)
                ans += N-i;
        }
    }
    else{
        map<ll, ll> ma;
        ma[0]++;
        ll last = 0;
        REP(i,N){
            ll x = S[i] - '0';
            ll y = last + mod_pow(10, i, P) * x;
            last = y % P;
            ma[last]++;
        }

        for(auto&& p : ma)
            ans += p.second * (p.second-1) / 2;
    }


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


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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;
  vll A(N);
  ll sum = 0;
  for (auto& a : A) {
    cin >> a;
    sum += a;
  }

  int ret = 0;
  for (auto x : A) {
    if (x*4*M >= sum) {
      ret++;
    }
  }

  if (ret >= M) {
    cout << "Yes" <<endl;
  } else {
    cout << "No" <<endl;
  }

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256