akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// 1-indexed
template <class T, class E>
struct SegmentTreeLaze {
  // a,b:T c,d:E e:E(unit)
  // g(f(a,b),c) = f(g(a,c),g(b,c))
  // g(g(a,c),d) = g(a,h(c,d))
  // g(a,e) = a
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  int n, height;
  F f;
  G g;
  H h;
  T tunit;
  E eunit;
  vector<T> dat;
  vector<E> laz;
  SegmentTreeLaze(){};
  SegmentTreeLaze(int newn, F f, G g, H h, T nt, E ne)
      : f(f), g(g), h(h), tunit(nt), eunit(ne) {
    init(newn);
  }
  void init(int newn) {
    n = 1, height = 0;
    while(n < newn) n <<= 1, ++height;
    dat.assign(n << 1, tunit);
    laz.assign(n << 1, eunit);
  }

  inline T reflect(int k) {
    return laz[k] == eunit ? dat[k] : g(dat[k], laz[k]);
  }

  inline void eval(int k) {
    if(laz[k] == eunit) return;
    laz[k << 1] = h(laz[k << 1], laz[k]);
    laz[(k << 1) | 1] = h(laz[(k << 1) | 1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = eunit;
  }

  inline void thrust(int k) {
    for(int i = height; i; --i) eval(k >> i);
  }

  void recalc(int k) {
    while(k >>= 1)
      dat[k] = f(reflect(k << 1), reflect((k << 1) | 1));
  }
  // [a,b)
  void update(int a, int b, E newdata) {
    thrust(a += n);
    thrust(b += n - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l], newdata), l++;
      if(r & 1) --r, laz[r] = h(laz[r], newdata);
    }
    recalc(a);
    recalc(b);
  }

  void set_val(int k, T newdata) {
    thrust(k += n);
    dat[k] = newdata;
    laz[k] = eunit;
    recalc(k);
  }

  // [a,b)
  T query(int a, int b) {
    thrust(a += n);
    thrust(b += n - 1);
    T vl = tunit, vr = tunit;
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, reflect(l++));
      if(r & 1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }
};

long long n, q;

int main() {
  cin >> n >> q;
  using P = pair<long long, long long>;
  auto f = [](P l, P r) {
    return P(l.first + r.first, l.second + r.second);
  };
  auto g = [](P l, long long r) {
    return P(r * l.second, l.second);
  };
  auto h = [](long long l, long long r) { return r; };
  SegmentTreeLaze<P, long long> seg(n, f, g, h, P(0, 0),
                                    -100000);
  for(int i = 0; i < n; ++i)
    seg.set_val(i, P(2147483647, 1));
  for(int i = 0; i < q; ++i) {
    long long c, s, t, x;
    cin >> c >> s;
    if(c) { cout << seg.query(s, s + 1).first << endl; }
    else {
      cin >> t >> x;
      seg.update(s, t + 1, x);
    }
  }
  return 0;
}


Measured memory_bytes: 8908
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    long ans = long.MaxValue;
    void solve()
    {
        N = cin.nextint;
        var A = cin.scanlong;
        calc(A, 1);
        calc(A, -1);

        WriteLine(ans);
    }
    void calc(long[] A, int mode)
    {
        long sum = 0;
        long cnt = 0;
        for (int i = 0; i < N; i++)
        {
            sum += A[i];
            if (mode == 1)
            {
                if (sum <= 0)
                {
                    cnt += 1 - sum;
                    sum = 1;
                }
            }
            else
            {
                if (sum >= 0)
                {
                    cnt += 1 + sum;
                    sum = -1;
                }
            }
            mode *= -1;
        }
        ans = Math.Min(cnt, ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
int n;
vector<char> V;
void print(int len, int mx){
  //cout<<len<<" "<<mx<<endl;
  if(len==n){
    trav(a,V)cout<<a;
    cout<<endl;
    return;
  }
  //cout<<len<<" "<<mx<<endl;
  rep(i,0,mx){
    V.push_back('a'+i);
    print(len+1,mx);
    V.pop_back();
  }
  //cout<<len<<" "<<mx<<endl;
  if(mx<26){
    V.push_back('a'+mx);
    print(len+1,mx+1);
    V.pop_back();
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n;
  print(0,0);
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  string s, t; cin >> s >> t;
  string k = t.substr(0, t.size() - 1);
  // cout << k << endl;
  if (k == s)
  puts("Yes");
  else
  puts("No");

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> h(n);rep(i,n)cin>>h[i];
  vector<int> now(n,0);
  int ans = 0;
 
  while(1){
    bool isFirst = true;
    
    rep(i,n){
      if(now[i] == h[i] && isFirst)continue;
      if(now[i] == h[i] && !isFirst)break;
      isFirst = false;
      ++now[i];
    }
    if(isFirst)break;
    ++ans;
    bool isFinished = true;
    
    rep(i,n){
      isFinished &= now[i] == h[i];
    }
 
    if(isFinished)break;
  }
 
  print(ans);
  return 0;
}

Measured memory_bytes: 256
S = list(input())

ans = [0]
ans_ = 0
for s in S:
    if s == "A" or s == "C" or s == "G" or s == "T":
        ans_ += 1
    else:
        ans.append(ans_)
        ans_ = 0
ans.append(ans_)
print(max(ans))


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

int main(){
    int n,m;
    cin >> n >> m;
    int ans = min(n,m);
    int other = max(n,m);
    rep(i, other) cout << ans;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<stdio.h>

using namespace std;

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

   // if (N < 1000) printf("ABC%03d\n", N);
   // else printf("ABD%03d\n", N%1000);
   
   if (N < 1000) printf("ABC\n");
   else printf("ABD\n");
   
   return 0;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

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

  int a,b;cin>>a>>b;
  int res=0;
  for(int i=a;i<=b;i++){
    string s = to_string(i);
    if(s[0]==s[4]&&s[1]==s[3])res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<pll> bc(m);
  for(ll i = 0; i < n; i++) cin >> a[i];
  for(ll i = 0; i < m; i++) cin >> bc[i].second >> bc[i].first;

  sort(all(a));
  sort(all(bc), greater<pll>());

  ll ans = 0;
  ll index = 0;
  for(ll i = 0; i < m; i++){
    for(ll j = 0; j < bc[i].second; j++){
      if(index >= n) break;
      ans += max(bc[i].first, a[index]);
      index++;
    }
  }
  for(ll i = index; i < n; i++) ans += a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(grid):  # fix inputs here
    console("----- solving ------")

    target_set = set([tuple(xy) for xy in grid])

    c1 = Counter([x for x,y in grid])
    c2 = Counter([y for x,y in grid])

    cx = sorted(c1.items(), key=lambda x:x[1])[::-1]
    cy = sorted(c2.items(), key=lambda x:x[1])[::-1]

    max_c1 = max(c1.values())
    max_c2 = max(c2.values())

    cxk = [k for k,v in cx if v == max_c1]
    cyk = [k for k,v in cy if v == max_c2]

    if max_c1 == 1:
        return min(len(grid), 1+max(c2.values()))
    if max_c2 == 1:
        return min(len(grid), 1+max(c1.values()))

    console(max(c1), max(c2))
    console(cx)
    console(cy)
    console(cxk)
    console(cyk)
    console(target_set)

    for x in cxk:
        for y in cyk:
            if (x,y) not in target_set:
                console(x,y)
                return max_c1 + max_c2
    return max_c1 + max_c2 - 1


def console(*args):  # the judge will not read these print statement
    # print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    # k = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    _,_,nrows = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    grid = []
    for _ in range(nrows):
        grid.append(list(map(int,input().split())))

    res = solve(grid)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

const int oo = 1e9;

bool used[E5];

void solve() {	
	int N;
	vector<tuple<int,int,int>> vec;
	cin >> N;
	
	for (int i = 0; i < 2*N; ++i) {
		int a,b,c;
		cin >> a >> b;
		c = (i < N);
		vec.pb(make_tuple(a,b,c));
	}
	
	sort(ALL(vec));
	int ans = 0;
	set<int> s;
	for (int i = 0; i < 2*N; ++i) {
		if (get<2>(vec[i])) {
			s.insert(get<1>(vec[i]));
		} else if (!s.empty() && get<1>(vec[i]) > *s.begin()) {
			++ans;
			auto it = lower_bound(ALL(s), get<1>(vec[i]));
			--it;
			s.erase(it);
		}
	}

	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char *argv[])
{
	string s,t;
	cin >> s >> t;
	int x = s.size(), y =t.size();
	auto dp = make_v<LL>(x+1,y+1);
	fill_v(dp, 0);
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (s[i] == t[j]) {
				dp[i+1][j+1] = dp[i][j] + 1;
			} else {
				dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
			}
		}
	}
	LL len = dp[x][y];
	string ans;
	int i = x-1, j = y-1;
	while (len > 0) {
		if (s[i] == t[j]) {
			ans.push_back(s[i]);
			i--;
			j--;
			len--;
		} else if (dp[i+1][j+1] == dp[i][j+1]) {
			i--;
		} else {
			j--;
		}
	}
	reverse(ALL(ans));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 70784
import java.util.*;

public class Main {
 	
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    sc.close();
	
    int[] map = new int[26];
    for (int c : s.toCharArray()) {
    	map[c-'a']++;
    }
    for (int freq : map) {
     	if (freq % 2 != 0) {
         	System.out.println("No");
          	return;
        }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 35596
import sys
import math
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    r = int(input())

    
    print(2*math.pi*r)


if __name__ == "__main__":
	main()

Measured memory_bytes: 61936
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int h,w; cin >> h >> w;
    int dh[4] = {1,0,-1,0}, dw[4] = {0,1,0,-1};
    char map[h][w];
    for(int i = 0; i<h; ++i)for(int j = 0; j<w; j++)cin >> map[i][j];

    for(int i = 0; i<h; ++i){
        for(int j = 0; j<w; ++j){
            if(map[i][j] == '#'){
                bool is_incor = true;
                for(int d = 0; d<4; ++d){
                    int x = j+dw[d], y = i+dh[d];
                    if(y>=0 && y<=h-1 && x>=0 && x<=w-1){
                        if(map[y][x] == '#')is_incor = false;
                    }
                }
                if(is_incor) {cout << "No" << endl; return 0;}
            }
        }
    }
    cout << "Yes" << endl; return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[100010] = {}, f[100010];
double syo = 0, su = 0;
long long   mur=0, kmr=0, yju=0, counto[5003],counto1[5003];
char fir='z',sec='z',mado[5010];
string rik,tok[25003];
bool mazi[110], gi[110],zi,manji;
pair<int, int>n[110];
vector<int> aa[50] = {}, cc;
vector<string> bb;
map<int, int>pos;
int gcd(int a,int b) {
	int d;
	if (a > b) {
		int t = b;
		b = a;
		a = t;
	}
	while ((d = b % a) != 0) {
		b = a;
		a = d;
	}
	return a;
}
int main() 
{
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> e[i];
		if (e[i] % 4 == 0) {
			b++;
		}
		else if (e[i] % 2 == 0) {
			c++;
		}
		
		//cout << "ok" << endl;
	}
	c -= 1;
	d = a - max(0,c);
	
	
		if (d/2 <= b) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	

	//偶数の時と奇数の時で分けておく
	return 0;
}

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

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

  int n, k;
  cin >> n >> k;
  vector<double> v(n);
  rep(i, 1, n + 1) {
    int mul_val = i, pow_val = 0;
    while (mul_val < k) {
      pow_val++;
      mul_val = i * pow(2, pow_val);
    }

    v[i - 1] = (1.0 / n) * pow(1 / 2.0, pow_val);
  }

  cout << fixed << setprecision(12) << accumulate(v.begin(), v.end(), 0.0)
       << endl;
}


Measured memory_bytes: 1024
#include<iomanip>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
int n,m,S,c[55],d[55];
long long dis[55][2505],ans[55],minn[55];
struct E{
	int to,time,cost;
};
struct Node{
	int now,money;
	long long dis;
	bool operator <(const Node yy) const {
		return dis==yy.dis?money>yy.money:dis>yy.dis;
	}
};
vector<E> g[50];
int main(){
	cin>>n>>m>>S;
	S=min(S,2500); 
	for(int i=1;i<=m;i++){
		int x,y,z,w;
		cin>>x>>y>>z>>w;
		g[x].push_back({y,w,z});
		g[y].push_back({x,w,z});
	}
	for(int i=1;i<=n;i++)cin>>c[i]>>d[i],c[i]=min(c[i],2500);
	memset(dis,0x3f,sizeof(dis));
	memset(ans,0x3f,sizeof(ans));
	memset(minn,0x3f,sizeof(minn));
	dis[1][S]=0,minn[1]=-1ll*S*c[1];
	priority_queue<Node> q;
	q.push({1,S,0}); 
	while(!q.empty()){
		Node t=q.top();
		q.pop();
		if(t.dis!=dis[t.now][t.money])continue;
		for(E v:g[t.now]){
			int y=v.to;
			if(t.money-v.cost>=0){
				if(dis[y][t.money-v.cost]>t.dis+v.time){
					dis[y][t.money-v.cost]=t.dis+v.time;
					q.push({y,t.money-v.cost,t.dis+v.time});
					ans[y]=min(ans[y],t.dis+v.time);
				}
			}
		}
		for(int i=t.money+c[t.now],j=1,ii;i<=2500+t.money;i+=c[t.now],j++){
			//if(i%1000==0)cout<<i<<' '<<t.now<<endl;
			if(i>2500)ii=2500;
			else ii=i;
			//if(ii%1000==0)cout<<dis[t.now][ii]<<' '<<t.dis+1ll*j*d[t.now]<<' '<<i<<' '<<t.now<<endl;
			if(dis[t.now][ii]>t.dis+1ll*j*d[t.now]){
				dis[t.now][ii]=t.dis+1ll*j*d[t.now];
				q.push({t.now,ii,dis[t.now][ii]});
			}
			else break;
		}
	}
	for(int i=2;i<=n;i++)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 69540
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int max=a[0],ans=1;
  for(int i=1;i<n;i++){
    if(max<=a[i]) ans++;
    if(max<a[i]) max=a[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 00:51:17
*/

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


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans=a+b;
    ans = min(b+c,ans);
    ans = min(c+a,ans);
    cout << ans << endl;
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;

    ll min = INF;
    {
        ll m = 0;
        REP(i, S.length())
        {
            if ((S[i] - '0') == i % 2)
                m++;
        }
        min = std::min(min, m);
    }

    {
        ll m = 0;
        REP(i, S.length())
        {
            if ((S[i] - '0') != i % 2)
                m++;
        }
        min = std::min(min, m);
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    int n, q;
    long long k;
    cin >> n >> k >> q;
    vector<int> a(n, 0);
    for (int i = 0; i < q; i++)
    {
        int temp;
        cin >> temp;
        temp--;
        a[temp]++;
    }

    for (int i = 0; i < n; i++)
    {
        if (k + a[i] > q)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
object Main {
  def inputCount(s: String, c: Char): Int = {
    (for(i <- s if i.toLower == c) yield i).length
  }

  def main(args: Array[String]): Unit = {
    val input = scala.io.Source.stdin.getLines.toSeq.mkString("")
    val aToZ = for(i <- 'a' to 'z') yield i
    for(i <- aToZ) println(i + " : " + inputCount(input, i))
  }
}

Measured memory_bytes: 44796
import numpy as np

N,M,C=map(int,input().split())
b=np.array([i for i in map(int,input().split())])
a=np.zeros((N,M))
for i in range(N):
    a[i,:]=np.array([i for i in map(int,input().split())])
print((((a*b).sum(axis=1)+C)>0).sum())

Measured memory_bytes: 21920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
const ll mx = 1e5 + 5;

ll n, k;
ll a[mx], dp[mx];

ll fn(ll i)
{
	if(dp[i] != -1)
		return dp[i];
	if(i == n)
		return 0;
	if(i > n)
		return 1e18;
	ll res = 1e18;
	for(ll j=1; j<=k; j++)
	{
		res = min(res, fn(j+i) + abs(a[j+i] - a[i]));
	}
	return dp[i] = res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> k;
	for(ll i=1; i<=n; i++)
	{
		cin >> a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << fn(1) << "\n";

	return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
int main()
{
    int a,b,c,i,count=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
        count++;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2144
#include <stdio.h>
int main(void)
{
	int x;
	int i = 1;
	while(1){
		scanf("%d", &x);
		if(x == 0){
			// ????????§?????¬?????????
			break;
		}
		printf("Case %d: %d\n",i, x);
		i++;
	}
	return 0;
}

Measured memory_bytes: 2676
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, T;
	cin >> n >> T;
	int ans = 1001;
	rep(i,n){
		int c, t;
		cin >> c >> t;
		if(t <= T) chmin(ans, c);
	}
	if(ans == 1001) cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e=0;
    cin>>a>>b>>c>>d;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(i*500+j * 100+k * 50 == d) e++;
            }
        }
    }
    cout<<e<<endl;
}


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

int main() {
  vector<int> data;
  int A,B,C;
  cin>>A>>B>>C;
  data.push_back(A);
  data.push_back(B);
  data.push_back(C);
  
  sort(data.begin(),data.end());
  cout<<data.at(0)+data.at(1)+data.at(2)*10<<endl;
}


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

int main() {
int n,t,a[100000],b[100000],c=0;
map<int,int> m;
cin>>n>>t>>a[0];
b[0]=a[0];

for(int i=1;i<n;i++){
    cin>>a[i];
    b[i]=min(a[i-1],b[i-1]);
    if(a[i]-b[i]>=c){
        c=a[i]-b[i];
        m[c]++;
    }
}

cout<<m[c]<<endl;
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstring>
using namespace std;
const int N = 100000 + 10;
char s[N]; int ans = 0;
int main() {
    scanf("%s", s+1);
    int n = strlen(s+1);
    int pos = (n + 1) / 2;
    for (int i = 1; i <= pos; i ++)
        if (s[i] == 'p') ans --;
    for (int i = pos+1; i <= n; i ++)
        if (s[i] == 'g') ans ++;
    printf("%d\n", ans);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define pqb         priority_queue<int>
#define pqs         priority_queue<int,vi,greater<int> >
#define MOD         1000000007
#define PI          3.1415926535897932384626
#define ps(x,y)     fixed<<setprecision(y)<<x
#define sortall(x)  sort(all(x))
#define w(x)        int x; cin>>x; while(x--)
#define fo(i,n)     for(ll i=0;i<n;i++)
#define fastio      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main() {
  fastio;
  ll n;
  cin >> n;
  ll a[n];
  fo (i,n) cin >> a[i];

  ll prevHeight = a[0], stools = 0;
  for (ll i=1; i<n; i++) {
      if (a[i] >= prevHeight) {
          prevHeight = a[i];
      }
      else {
          stools += prevHeight - a[i];
      }
  }

  cout << stools << "\n";
  return 0;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int func(int x,int y,int z){
    return x*x+y*y+z*z+x*y+y*z+z*x;
}
int main()
{
    int n;
    cin >> n;
    vector<int> ans(n+1,0);
    int max = sqrt(double(n));
    max++;
    for(int i=1;i<=max;i++){
        for(int j=1;j<=max;j++){
            for(int k=1;k<=max;k++){
                if(func(i,j,k)<=n){
                    ans[func(i,j,k)]++;
                }
            }
        }
    }
    REP(i,n){
        int j=i+1;
        cout << ans[j] << endl;
    }
}


Measured memory_bytes: 3628
#include<stdio.h>

void trace(int A[],int N){
    int i;
    for(i=0;i<N;i++){
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}
void insertionSort(int A[],int N){
    int j,i,v;
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(){
    int N,i,j;
    int A[100];
    
    scanf("%d",&N);
    for(i=0;i<N;i++)scanf("%d",&A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    
    return 0;
}



Measured memory_bytes: 2064
from math import factorial

N,M = map(int,input().split())

pdic={}

p=2
while M>1:
    c=0
    while M%p==0:
        c+=1
        M//=p
    if c>0:
        pdic[p]=c
    p+=1

ans=1
tmp=factorial(N-1)

for p in pdic.keys():
    e=pdic[p]
    ans*=factorial(N+e-1)//(factorial(e)*tmp)

print(ans%(10**9+7))


Measured memory_bytes: 83164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    int n, a, b;
    cin(n); cin(a); cin(b);

    print(min(n * a, b));
    return 0;
}

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


typedef std::vector<int> vi;


int main() {
	int n;
	scanf("%d",&n);
	vi ans(3);
	
	for(int day=0;day<n;day++)
	{
	    vi c(3);
	    for(int i=0;i<3;i++)
	    {
	        scanf("%d",&c[i]);
	    }
	    
	    vi dp(3,0);
	    for(int i=0;i<3;i++)
	    {
	        for(int j=0;j<3;j++)
	        {
	            if(i!=j)
	            {
	                dp[j]=max(dp[j],ans[i]+c[j]);
	            }
	        }
	    }
	    
	    ans=dp;
	}
	
	cout<<max({ans[0],ans[1],ans[2]});
	return 0;
}

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

using namespace std;

vector<int> ans;

int main(){
	while(1){
		int N;
		vector<vector<int> > P;
		cin >> N;
		
		if(N == 0)break;
		
		for(int i = 0;i < N;i++){
			int num;
			cin >> num;
			vector<int> tP;
			for(int j = 0;j < num;j++){
				int M;
				cin >> M;
				tP.push_back(M);
			}
			P.push_back(tP);
		}
		
		int K;
		cin >> K;
		vector<int> l;
		for(int i = 0;i < K;i++){
			int tl;
			cin >> tl;
			l.push_back(tl);
		}
		
		vector<int> sus;
		for(int i = 0;i < N;i++){
			sus.push_back(i);
		}
		
		for(int i = 0;i < K;i++){
			vector<int> nsus;
			for(int j = 0;j < sus.size();j++){
				vector<int> tP = P[sus[j]];
				vector<int>::iterator itr = find(tP.begin(),tP.end(),l[i]);
				if(itr != tP.end()) nsus.push_back(sus[j]);
			}
			sus = nsus;
		}
		
		int tans = 0;
		if(sus.size() == 1){
			tans = sus[0]+1;
		}else{
			tans = -1;
		}
		
		ans.push_back(tans);
	}
	
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,p;
  cin>>n;
  int x[n],a[n*n],u[n];
  vector<P> v;
  for(int i=0;i<n*n;i++) a[i]=0;
  for(int i=0;i<n;i++){
    cin>>x[i];
    u[i]=1;
    a[x[i]-1]=i+1;
    v.push_back(P(x[i]-1,i+1));
  }
  sort(v.begin(),v.end());
  bool f=1;
  p=0;
  for(int i=0;i<n;i++){
    int c=v[i].second;
    while(u[c-1]<c){
      if(a[p]){
	p++;
	continue;
      }
      if(p>v[i].first){
	f=0;
	break;
      }
      a[p]=c;
      u[c-1]++;
    }
  }
  reverse(v.begin(),v.end());
  p=n*n-1;
  for(int i=0;i<n;i++){
    int c=v[i].second;
    while(u[c-1]<n){
      while(a[p]) p--;
      if(p<v[i].first){
	f=0;
	break;
      }
      a[p]=c;
      u[c-1]++;
    }
  }

  //assertion
  if(f){
    for(int i=1;i<=n;i++){
      int t=0;
      for(int j=0;j<n*n;j++){
	if(a[j]==i) t++;
	if(i==t) {
	  f&=(j+1==x[i-1]);
	  break;
	}
      }
    }
  }
  if(f){
    for(int i=1;i<=n;i++){
      int t=0;
      for(int j=0;j<n*n;j++){
	if(a[j]==i) t++;
      }
      //cout<<i<<" "<<t<<endl;
      f&=(t==n);
    }
  }
  if(!f){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
    for(int i=0;i<n*n;i++) cout<<a[i]<<" \n"[i==n*n-1];
    //for(int i=0;i<n*n;i++) cout<<i<<":"<<a[i]<<endl;
  }
  return 0;
}


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

using namespace std;

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int a, b, x;
	cin >> a >> b >> x;

	cout << ((a + b - a) + a >= x && a <= x ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
s=str(input())
k=int(input())
s=list(s)
s2=s+s
cnt=0
temp1=0
temp2=0
l=0
for i in range(1,len(s)):
  if s[i]==s[i-1]:
    cnt=cnt+1
    l=l+1
  if s[i]!=s[i-1]:
    temp1=temp1+(cnt+1)//2
    cnt=0
temp1=temp1+(cnt+1)//2
cnt=0
for i in range(1,len(s2)):
  if s2[i]==s2[i-1]:
    cnt=cnt+1
  if s2[i]!=s2[i-1]:
    temp2=temp2+(cnt+1)//2
    cnt=0
temp2=temp2+(cnt+1)//2
cnt=0
if l==len(s)-1:
  print(k*len(s)//2)
elif k==1:
  print(temp1)
else:
  print(temp1+(temp2-temp1)*(k-1))

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

//#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int X[N], Y[N], FEN[N];
vector<pii> P;
vector<int> C;

bool CMP(pii a, pii b) { return a.first == b.first ? a.second > b.second : a.first < b.first; }
void Add(int p, int x) { for (p++; p < N; p += p & -p) FEN[p] = (FEN[p] + x) % MOD; }
int Get(int p) {
	int res = 0;
	for (; p > 0; p -= p & -p) res = (res + FEN[p]) % MOD;
	return res;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> X[i];
	for (int i = 0; i < m; i++) cin >> Y[i];
	for (int i = 0; i < n; i++) {
		int e = lower_bound(Y, Y + m, X[i]) - Y;
		if (e == 0 || e == m) continue;
		int l = X[i] - Y[e - 1], r = Y[e] - X[i];
		P.push_back(make_pair(l, r));
		C.push_back(r);
	}
	sort(all(C)), sort(all(P), CMP);
	C.resize(unique(all(C)) - C.begin());
	P.resize(unique(all(P)) - P.begin());
	Add(0, 1);
	for (auto [l, r] : P) {
		int rc = lower_bound(all(C), r) - C.begin() + 1;
		Add(rc, Get(rc));
	}
	cout << Get(N - 1) << endl;


	return 0;
}


Measured memory_bytes: 5892
N, Y = map(int, input().split())

A = 10000
B = 5000
C = 1000

x = -1
y = -1
z = -1

for a in range(N+1):
    for b in range(N+1):
        if a + b > N:
            continue
        else:
            total = A*a + B*b + C*(N - (a + b))
            if total == Y:
                x = a
                y = b
                z = N - (a + b)
                break

print(x, y, z)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int even = sc.nextInt();
        int odd = sc.nextInt();
        int result = 0;
        for (int i = even - 1; i > 0; i--){
            result = result + i;
        }
        for (int i = odd - 1; i > 0; i--){
            result = result + i;
        }
        System.out.println(result);

    }
}


Measured memory_bytes: 22612
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=input()
    tmp=0
    for i in range(len(S)-1):
        tmp+=(S[i+1]!=S[i])
    print(tmp)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using Graph = vector<vector<int>>;
 
int main(){
  int N; cin>>N;
  int ans[N+1] = {0};
  bool flag = false;
  FOR(i,1,N){
  	FOR(j,i,N){
      FOR(k,j,N){
        int n=(i+j+k)*(i+j+k)-(i*j+j*k+k*i);
        if(n <= N){
          if(i==j && j==k) ans[n]=ans[n]+1; //flag=true; break;
          else if(i==j || j==k ||i==k) ans[n]=ans[n]+3;
          else ans[n]=ans[n]+6;
        }
        else break;
      }
      if(flag) break;
    }
    if(flag) break;
  }
  FOR(i,1,N+1) cout<<ans[i]<<endl;
}


Measured memory_bytes: 3668
def main():
    N, K = map(int, input().split())
    XY = [tuple(map(int, input().split())) for _ in range(N)]
    X, Y = [], []
    for x, y in XY:
        X.append(x)
        Y.append(y)
    X.sort()
    Y.sort()
    Xm = {x: i for i, x in enumerate(X)}
    Ym = {y: i for i, y in enumerate(Y)}
    Xr = {i: x for i, x in enumerate(X)}
    Yr = {i: y for i, y in enumerate(Y)}
    cXY = [(Xm[x], Ym[y]) for x, y in XY]
    m = 10 ** 40
    for l in range(N):
        for r in range(l + 1, N):
            for b in range(N):
                for t in range(b + 1, N):
                    k = 0
                    for x, y in cXY:
                        if l <= x <= r and b <= y <= t:
                            k += 1
                    if k >= K:
                        m = min(m, (Xr[r] - Xr[l]) * (Yr[t] - Yr[b]))
    return m
print(main())


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

vector<vector<int>> g;
vector<int> ans;
vector<int> add;

void dfs(int v, int p = -1, int plus = 0) {
    plus += add[v];
    ans[v] = plus;
    for (int i : g[v])
        if (i != p)
            dfs(i, v, plus);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    g.resize(n);
    ans.resize(n);
    add.resize(n);

    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 0; i < m; ++i) {
        int u, val;
        cin >> u >> val;
        --u;
        add[u] += val;
    }
    dfs(0);
    for (int i : ans)
        cout << i << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 25856
# -*- coding: utf-8 -*-
n,k,q = map(int, input().split())
p = [0]*n

for _ in range(q):
    ai = int(input())-1
    p[ai] += 1

for a in p:
    if k-(q-a)>0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4680
S = input()

def is_keyence(S):
    key = "keyence"
    for i in range(len(key)):
        #print(key[:i], key[i:])
        if (S.startswith(key[:i]) and S.endswith(key[i:])):
            return True
    return False


if is_keyence(S):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main implements Runnable {
	public static void main(String[] args) {
		new Main().run();
	}

	final long MOD = 1_000_000_000 + 7;

	class Edge {
		int src;
		int dst;
		long cost;

		public Edge(int src_, int dst_, long cost_) {
			src = src_;
			dst = dst_;
			cost = cost_;
		}
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int S = sc.nextInt();
		int T = sc.nextInt();
		--S;
		--T;
		ArrayList<Edge>[] g = new ArrayList[N];
		for (int i = 0; i < N; ++i) {
			g[i] = new ArrayList();
		}
		long[][] es = new long[M][];
		for (int i = 0; i < M; ++i) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			long d = sc.nextLong();
			--u;
			--v;
			g[u].add(new Edge(u, v, d));
			g[v].add(new Edge(v, u, d));
			es[i] = new long[] { u, v, d };
		}
		long[][] a = Dijkstra(S, g);
		long[][] b = Dijkstra(T, g);
		long ans = a[1][T] * b[1][S] % MOD;
		long DIST = a[0][T];
		long sub = 0;
		for (int i = 0; i < M; ++i) {
			int u = (int) es[i][0];
			int v = (int) es[i][1];
			long d = es[i][2];
			if (DIST == a[0][u] + d + b[0][v]
					&& 2 * a[0][u] < DIST && DIST < 2 * (a[0][u] + d)) {
				long x = a[1][u] * b[1][v] % MOD;
				x = x * x % MOD;
				sub = (sub + x) % MOD;
			}
			if (DIST == a[0][v] + d + b[0][u] && 2 * a[0][v] < DIST
					&& DIST < 2 * (a[0][v] + d)) {
				long x = a[1][v] * b[1][u] % MOD;
				x = x * x % MOD;
				sub = (sub + x) % MOD;
			}
		}
		for (int i = 0; i < N; ++i) {
			if (DIST == a[0][i] + b[0][i] && a[0][i] == b[0][i]) {
				sub += a[1][i] * b[1][i] % MOD * (a[1][i] * b[1][i] % MOD) % MOD;
				sub %= MOD;
			}
		}
		ans = (ans - sub + MOD) % MOD;
		System.out.println(ans);
	}

	long[][] Dijkstra(int src, ArrayList<Edge>[] g) {
		class S implements Comparable<S> {
			int v;
			long dist;

			public S(int v_, long dist_) {
				v = v_;
				dist = dist_;
			}

			public int compareTo(S arg0) {
				return Long.compare(dist, arg0.dist);
			};
		}

		PriorityQueue<S> pq = new PriorityQueue();
		long[] d = new long[g.length];
		long[] comb = new long[g.length];
		boolean[] vis = new boolean[g.length];
		Arrays.fill(d, Long.MAX_VALUE / 2);
		Arrays.fill(comb, -Long.MAX_VALUE / 2);
		d[src] = 0;
		comb[src] = 1;
		pq.add(new S(src, 0));
		while (!pq.isEmpty()) {
			S s = pq.poll();
			if (vis[s.v])
				continue;
			vis[s.v] = true;
			for (Edge e : g[s.v]) {
				if (d[e.dst] > d[e.src] + e.cost) {
					d[e.dst] = d[e.src] + e.cost;
					comb[e.dst] = comb[e.src];
					pq.add(new S(e.dst, d[e.dst]));
				} else if (d[e.dst] == d[e.src] + e.cost) {
					comb[e.dst] += comb[e.src];
					comb[e.dst] %= MOD;
				}
			}
		}
		long[][] ret = new long[2][];
		ret[0] = d;
		ret[1] = comb;
		return ret;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 203628
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <string>
#include <cmath>
using namespace std;

int main(void){
	vector<int> arr(3);
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr.begin(),arr.end());
	cout << arr[0] << " " << arr[1] << " " << arr[2] << endl;
	return 0;
}


Measured memory_bytes: 3156
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		long ans = N % K;
		
		/*if(ans==N) {
			System.out.println(N);
		}*/
		while(ans>Math.abs(ans-K)) {
			ans = Math.abs(ans-K);
		}
		
		
		System.out.println(ans);
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> d(100000);
    ll sum=0;
    for(int i = 0; i < n; i++) {
        sum += a[i];
        d[a[i]-1]++;
    }

    int q;
    cin >> q;
    for(int i = 0; i < q; i++) {
        int b,c;
        cin >> b >> c;
        sum += (c-b)*d[b-1];
        d[c-1] += d[b-1];
        d[b-1] = 0;

        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3936
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int a,b;
    while((scanf("%d %d",&a,&b)) != EOF){
        a += b;
        int i = 0;
        while(a > 0){
            a /= 10;
            i++;
        }

        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 0