akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	bool[char] set;
	foreach (i; 0..N)
		set[RD!char] = true;

	writeln(set.keys.length == 3 ? "Three" : "Four");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
void bit_full_search(int n)
{

    //2^n回ループ
    for (int bit = 0; bit < (1<<n); ++bit) {
        cout << "{";
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) {
                cout << " " << i << " ";
            }
        }
        cout << "}" << endl;
    }
    
}



int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll h, w, k; cin >> h >> w >> k;
    vector<vector<string>> vec(h, vector<string>(w));
    rep(i, h){
        string s; cin >> s;
        rep(j, w){
            vec[i][j] = s[j];
        }
    }

    

    ll ans = 0;
    vector<vector<string>> tmp(h, vector<string>(w));
    for (int bit = 0; bit < (1<<h); ++bit) {
        
        
        vector<ll> gyo;
        
        //cout << "{";
        for (int i = 0; i < h; ++i) {
            if (bit & (1<<i)) {
                //cout << " " << i << " ";
                gyo.push_back(i);
            }
        }
        //cout << "}" << endl;

        for (int bit2 = 0; bit2 < (1<<w); ++bit2) {
            vector<ll> retsu;
            tmp = vec;
            //cout << "[";
            for (int i = 0; i < w; ++i) {
                if (bit2 & (1<<i)) {
                    //cout << " " << i << " ";
                    retsu.push_back(i);
                }
            }
            //cout << "]" << endl;

            //ここ
            
            rep(i, gyo.size()){
                rep(j, w){
                    tmp[gyo[i]][j] = "r";
                }
                //cout << gyo[i] << " ";
            }

            rep(i, retsu.size()){
                rep(j, h){
                    tmp[j][retsu[i]] = "r";
                }
                //cout << retsu[i] << " ";
            }
            

            ll count = 0;
            rep(i, h){
                rep(j, w){
                    //cout << tmp[i][j] << " ";
                    if(tmp[i][j] == "#"){
                        count++;
                    }
                }
            }
            //cout << "count = " << count << endl;
            if(count == k){
                ans++;
            }

        }

        



    }

    cout << ans << endl;

}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;


class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};

int main() {
    ll n, m;
    cin >> n >> m;
    UnionFind uni(2*n);
    for (int i = 0; i < m; ++i) {
        u32 a, b;
        scanf("%d %d", &a, &b);
        uni.unite(a-1, b-1+n);
        uni.unite(a-1+n, b-1);
    }

    if(uni.root(0) == uni.root(n)){
        cout << n*(n-1)/2 - m << "\n";
    }else {
        int c = 1;
        for (int i = 1; i < n; ++i) {
            if(uni.root(0) == uni.root(i)) c++;
        }
        cout << (n-c) * c - m << "\n";
    }
    return 0;
}


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

int main(){
int H, W, K, i, j, c, d; cin >> H >> W >> K; string S[H];
  bool F=false;
for(i=0; i<H; i++){ cin >> S[i]; }
  
i=0; c=0; d=1;
while(S[i]==string(W,'.')){i++;c++;}
string L="";
for(j=0; j<W; j++){
if(S[c][j]=='#'){ if(F){d++;}else{F=true;} }  
L+=to_string(d); if(j<W-1){ L+=" "; }
}
cout << L << "\n";
for(i=0; i<c; i++){ cout << L << "\n"; }

for(i=c+1; i<H; i++){
if(S[i]==string(W,'.')){ cout << L << "\n"; }
else{

L=""; d++; F=false;
for(j=0; j<W; j++){
if(S[i][j]=='#'){ if(F){d++;}else{F=true;} }    
L+=to_string(d); if(j<W-1){ L+=" "; }               
}
cout << L << "\n";
  
}  
}

}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int f(int a,int b){
  int dig_a=0,dig_b=0;
  for(int i=0;i<11;i++){
    dig_a++;
    if(a/10==0)break;
    a/=10;
  }
  for(int i=0;i<11;i++){
    dig_b++;
    if(b/10==0)break;
    b/=10;
  }
  return max(dig_a,dig_b);
}

int main(){
  long int n;
  int res=1000,mindig,m;
  cin >> n;
  string ans = "No";
  int j;
  for(long int i=1;i<1000000;i++){
    if(n%i==0){
      j=n/i;
      mindig=f(i,j);
      res=min(mindig,res);
    }
    if(i*i>n)break;
  }
  cout << res <<endl;
}


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

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long last;
    cin >> last;
    for(long long i = 0; i < n - 1; ++i){
        long long cur; cin >> cur;
        if(last - cur >= 2){
            cout << "No";
            return 0;
        }
        last = max(last, cur);
    }
    cout << "Yes";

    return 0;

}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n), x(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        x[i] = b[i] - a[i] + 1;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (n % 2 == 0) {
        ll mi = a[n / 2 - 1] + a[n / 2];
        ll ma = b[n / 2 - 1] + b[n / 2];
        cout << ma - mi + 1 << endl;
    } else {
        ll mi = a[n / 2];
        ll ma = b[n / 2];
        cout << ma - mi + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 7988
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	cout << a << ' ' << b << ' ' << -a-b+3*c << endl;
	cout << -2*a-b+4*c << ' ' << c << ' ' << 2*a+b-2*c << endl;
	cout << a+b-c << ' ' << -b+2*c << ' ' << -a+2*c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
    R int res=1;
    for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
    return res;
}
const int N=1e6+5,L=1e6;
bitset<N>vis;int p[N],mu[N],cnt[N],a[N],st[N],c[N],s[N],top,n,m,res;
void init(int n=L){
    mu[1]=1;
    fp(i,2,n){
        if(!vis[i])p[++m]=i,mu[i]=-1;
        for(R int j=1;j<=m&&i*p[j]<=n;++j){
            vis[i*p[j]]=1;
            if(i%p[j]==0)break;
            mu[i*p[j]]=-mu[i];
        }
    }
    fp(i,1,n)upd(mu[i],P);
    fp(i,1,n)for(R int j=i;j<=n;j+=i)upd(s[j],mul(i,mu[i]));
}
int main(){
//  freopen("testdata.in","r",stdin);
    scanf("%d",&n);
    init();
    fp(i,1,n)scanf("%d",&a[i]),++cnt[a[i]];
    fp(T,1,L){
        R int sum=0;
        for(R int j=T;j<=L;j+=T)upd(sum,mul(j/T,cnt[j]));
        sum=mul(sum,sum),sum=mul(sum,mul(T,s[T]));
        upd(res,sum);
    }
    fp(i,1,n)res=dec(res,a[i]);
    res=mul(res,(P+1)>>1);
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 18816
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  bool f = false;
  re(i, 3) if(s[i]=='7') f = true;
  std::cout << (f?"Yes":"No") << '\n';
  return 0;
}


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

#define int int64_t
#define rep(i,a,n) for(int i=(a); i<(n); ++i)
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define re(s) reverse((s).begin(),(s).end())
#define ll long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3fLL;
const int mod = 1000000007;
using namespace std;

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

    int a,b,c;
    cin>>a;
    b = a/100;
    c = a%100;

    if(1 <= b && 12 >= b){
        if(1 <= c && 12 >= c) cout<<"AMBIGUOUS\n";
        else cout<<"MMYY\n";
    }else if(1 <= c && 12 >= c) cout<<"YYMM\n";
    else cout<<"NA\n";
}

Measured memory_bytes: 256
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

memo = [-1]*(110000)
def rec(n):
    if n==0:
        return 0
    if memo[n] != -1:
        return memo[n]
    res = n
    pow6,pow9 = 1,1
    while pow6 <=n:
        res = min(res,rec(n-pow6)+1)
        pow6 *= 6
    while pow9 <= n:
        res = min(res,rec(n-pow9)+1)
        pow9 *= 9
    memo[n] = res
    return memo[n]

N = int(input())
print(rec(N))


Measured memory_bytes: 90316
from collections import defaultdict
import sys
sys.setrecursionlimit(100000)

class E :
    def __init__ (self) :
        self.MOD = int(1e9+7)

    def e(self, n, k) :
        if k == 1 :
            return (n*(n+1))//2 
        
        ans = 0

        dp = dict()
        for i in range(1, n+1) :
            dp[i] = pow( n//i, k, self.MOD)

        for i in range(1, n+1)[::-1] :
            for j in range(i+i,n+1,i) :
                dp[i] -= dp[j]
            
        for i in range(1, n+1) : 
            ans = (ans + dp[i]*i) % self.MOD
        
        return ans

if __name__ == "__main__" :
    k, n = map(int, input().split(" "))
    print(E().e(n, k))


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

int main(int argc, const char * argv[]) {
    string s;
    while (getline(cin, s)){
        if(s.size() == 2){
            cout << s << "\n";    
        }else{
            cout << s[2] << s[1] << s[0] << "\n";
        }
    }
    return 0;
}

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

int64_t Con(int a, int b){
  int64_t Ans=1;
  for(int i=0; i<b; i++){
    Ans*=a-i;
    Ans/=i+1;
  }
  return Ans;
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  vector<int64_t> V(N);
  for(int i=0; i<N; i++){
    cin >> V.at(i);
    V.at(i)*=-1;
  }
  sort(V.begin(), V.end());
  for(int i=0; i<N; i++){
    V.at(i)*=-1;
  }
  double Ave=0;
  for(int i=0; i<A; i++){
    Ave+=(double)V.at(i)/(double)A;
  }
  cout << setprecision(20) << Ave << endl;
  int first=0;
  int count=0;
  int t=0;
  for(int i=0; i<N; i++){
    if(V.at(i)==V.at(A-1)){
      if(t==0){
        first=i;
        t=1;
      }
      count++;
    }
  }
  int64_t Ans=0;
  for(int i=A-first; i<=B-first; i++){
    Ans+=Con(count, i);
  }
  if(V.at(0)==V.at(A-1)){
    cout << Ans << endl;
  }
  else{
    cout << Con(count, A-first) << endl;
  }
}

Measured memory_bytes: 384
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import bisect
from collections import defaultdict

def main():
	s=RD()
	t=RD()
	d=defaultdict(list)

	for i,ss in enumerate(s):
		d[ss].append(i)
	#print(d)

	now=-1
	cnt=0

	for tt in t:
		if d[tt]==[]:
			print(-1)
			exit()
		else:
			i=bisect.bisect_right(d[tt],now)
			if len(d[tt])==i:
				cnt+=1
				now=d[tt][0]
			else:
				now=d[tt][i]
		#print(tt,i,now,cnt)
	print(len(s)*cnt+now+1)

























if __name__ == "__main__":
	main()


Measured memory_bytes: 14104
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int N, W;
	cin >> N >> W;
	int v[101], w[101];
	for (int i = 0; i <= N; i++)
		cin >> v[i] >> w[i];
	int dp[10001] = {};
	for (int i = 0; i < N; i++)
		for (int j = w[i]; j <= W; j++)
			dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 1208
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n;
  cin>>n;
  vector<ll>v(n,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  vector<ll>v2=v;
  sort(v2.begin(),v2.end());
  ll k=v2[n-1];
  ll k2=v2[n-2];
  for(ll i=0;i<n;i++){
    if(v[i]==k)cout<<k2<<endl;
    else cout<<k<<endl;
  }
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;char st;
    cin>>n;
    string str;
    for(int i=0;i<=n;i++){
        getline(cin,str);
        bool kawa=0;
        for(int j=1;j<50&&!kawa;j++){
            for(int k=1;k<50&&!kawa;k++){
                string strin=str;
                for(int l=0;strin[l]!='\0';l++)if(strin[l]-'a'>=0&&strin[l]-'z'<=0)strin[l]=(j*(strin[l]-'a')+k)%26+'a';
                for(int l=0;strin[l]!='\0';l++){
                    if(strin[l]=='t'&&strin[l+1]=='h'&&(strin[l+2]=='a'&&strin[l+3]=='t'||strin[l+2]=='i'&&strin[l+3]=='s')){
                        cout<<strin<<endl;
                        kawa=1;
                        break;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 1208
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	minC = max(C)
	minCn = 0
	for i,val in enumerate(C):
		if val == minC:
			minCn = i+1

	for i,val in enumerate(S):
		tmp = max(val)
		mins = 0
		for j,vol in enumerate(val):
			if tmp == vol:
				mins = j+1
				break
		if i <= D//2:
			ans.append(mins)
		else:
			ans.append(minCn)

	for i in range(D):
		print(ans[i])

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 78456
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$K) =  explode(" ",trim(fgets(STDIN)));
//$W = explode(" ",trim(fgets(STDIN)));

//一人１つづ配ったあまり
$amari = $N - $K;
if ($K==1) $amari=0;
printf("%d\n",$amari);


Measured memory_bytes: 4728
from math import sqrt

while True:
        n = int(raw_input())

        if n == 0:
                break

        x = [0 for i in range(n)]
        y = [0 for i in range(n)]
        v = [0 for i in range(n)]

        for i in range(n):
                (x[i], y[i], v[i]) = map(int, raw_input().split())

        px = 0.0
        py = 0.0
        d  = 1000.0

        def dist(x1, y1, x2, y2):
                return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

        ans = 100000
        while d > 0.1 ** 8:
                mx = (0, 0)
                for i in range(n):
                        mx = max(mx, (dist(px, py, x[i], y[i]) / v[i], i))

                ans = mx[0]
                px += d / ans * (x[mx[1]] - px)
                py += d / ans * (y[mx[1]] - py)
                d /= 1.01

        print "%.8f" % ans

Measured memory_bytes: 4472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  ll res = 0;
  rep(i, n) {
    ll tmp = v.at(i);
    ll count = 1;
    while (i < n) {
      if (v.at(i)<=tmp+l && count<=m) {
        i++;
        count++;
      } else {
        break;
      }
    }
    res++;
    if (i == n) break;
    i--;
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int x, a;
	cin >> x >> a;
	if (x < a)
	{
		cout << 0 << endl;
	}
	else
		cout << 10 << endl;
	return 0;
}

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

int main(){
  char a,b;
  cin >> a >> b;
  if(a == b){
    cout << '=' << endl;
  } else if(a > b){
    cout << '>' << endl;
  } else {
    cout << '<' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a := intScanner()
	b := intScanner()
	c := intScanner()
	fmt.Println(larger(c-(a-b), 0))
}


Measured memory_bytes: 1772
// AOJ ALDS1_13_B 8 Puzzle
// 2018.5.8 bal4u

#include <stdio.h>

typedef unsigned char uchar;

#define HASHSIZ 543217
typedef struct { unsigned s; char x, v; } HASH;
HASH hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int lookup(unsigned s, int x)
{
	long long t = ((long long)x << 32) + s;
	HASH *hp = hash + (int)(t % HASHSIZ);
	while (hp->s) {
		if (hp->s == s && hp->x == x) return hp->v;
		if (++hp == hashend) hp = hash;
	}
	return 0;
}

void insert(unsigned s, int x, char v)
{
	long long t = ((long long)x << 32) + s;
	HASH *hp = hash + (int)(t % HASHSIZ);
	while (hp->s) {
		if (hp->s == s && hp->x == x) { hp->v = v; break; }
		if (++hp == hashend) hp = hash;
	}
	hp->s = s, hp->x = x, hp->v = v;
}

#define QMAX 30000
typedef struct { unsigned s; char x, v; } T;
T s[QMAX+3]; int top, end;
int hi[9] = {2,3,2,3,4,3,2,3,2};
int to[9][4] = {{1,3},{0,2,4},{1,5},{0,4,6},{1,3,5,7},{2,4,8},{3,7},{4,6,8},{5,7}};

void toArray(char *nine, unsigned s, int x)
{
	int i;
	
	for (i = 8; i >= 0; i--) {
		if (i == x) nine[i] = 0;
		else nine[i] = s & 0xf, s >>= 4;
	}
}

unsigned swap(char *nine, int zero, int nx)
{
	int i;
	unsigned res;
	
	res = 0;
	for (i = 0; i < 9; i++) {
		if      (i == zero) res <<= 4, res |= nine[nx];
		else if (i != nx)   res <<= 4, res |= nine[i];
	}
	return res;
}

#define MAGIC 21

int main()
{
	int i, x, nx, v, nv, t;
	unsigned a, na;
	unsigned gs; int gx;	// goal
	char nine[9];
	
	gs = 0; for (i = 0; i < 9; i++) {
		scanf("%d", &t);
		if (t == 0) gx = i;
		else gs <<= 4, gs |= t;
	}
	s[0].s = 0x12345678, s[0].x = 8;
	s[1].x = -1;
	top = 0, end = 2;
	insert(s[0].s, s[0].x, 0);
	v = 0;
	while (top != end) {
		a = s[top].s, x = s[top].x;
		if (++top == QMAX) top = 0; 
		if (x < 0) {
			if (v == MAGIC) break;
			v++;
			s[end].x = -1; if (++end == QMAX) end = 0;
			continue;
		}
		if (x == gx && a == gs) goto done;
		if (lookup(a, x) < v) continue;

		toArray(nine, a, x);
		for (i = 0; i < hi[x]; i++) {
			nx = to[x][i];
			na = swap(nine, x, nx), nv = v+1;
			t = lookup(na, nx);
			if (!t || nv < t) {
				s[end].s = na, s[end].x = nx;
				if (++end == QMAX) end = 0;
				insert(na, nx, nv);
			}
		}
	}

	s[0].s = gs, s[0].x = gx, s[1].x = -1;
	top = 0, end = 2;
	v = 0;
	while (top != end) {
		a = s[top].s, x = s[top].x;
		if (++top == QMAX) top = 0; 
		if (x < 0) {
			v++;
			s[end].x = -1; if (++end == QMAX) end = 0;
			continue;
		}
		if ((t = lookup(a, x)) > 0) { v += t; break; }

		toArray(nine, a, x);
		for (i = 0; i < hi[x]; i++) {
			nx = to[x][i];
			na = swap(nine, x, nx), nv = v+1;
			t = lookup(na, nx);
			if (!t || nv < t) {
				s[end].s = na, s[end].x = nx;
				if (++end == QMAX) end = 0;
			}
		}
	}
done:
	printf("%d\n", v);
	return 0;
}



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

class Program
{
    static void Main()
    {
        var nc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var D = new int[nc[1], nc[1]];
        var C = new int[nc[0], nc[0]];
        for (int i = 0; i < nc[1]; i++)
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            for (int j = 0; j < nc[1]; j++) D[i, j] = inp[j];
        }
        for (int i = 0; i < nc[0]; i++)
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            for (int j = 0; j < nc[0]; j++) C[i, j] = inp[j];
        }
        var group0 = new List<int>();
        var group1 = new List<int>();
        var group2 = new List<int>();
        for (int i = 0; i < nc[0]; i++)
        {
            for (int j = 0; j < nc[0]; j++)
            {
                if ((i + j) % 3 == 0) group0.Add(C[i, j]);
                else if ((i + j) % 3 == 1) group1.Add(C[i, j]);
                else if ((i + j) % 3 == 2) group2.Add(C[i, j]);
            }
        }
        var group = new List<int>[] { group0, group1, group2 };

        var ans = new int[3, nc[1]];//groupNo,colors
        for (int i = 0; i < 3; i++)//group
        {
            for (int j = 0; j < nc[1]; j++)//color
            {
                int dif = 0;
                for (int k = 0; k < group[i].Count(); k++)
                {
                    dif += D[group[i][k] - 1, j];
                }
                ans[i, j] = dif;
            }
        }
        int minDif = int.MaxValue;
        for (int i = 0; i < nc[1]; i++)
        {
            for (int j = 0; j < nc[1]; j++)
            {
                for (int k = 0; k < nc[1]; k++)
                {
                    if (i == j || j == k || k == i) continue;
                    minDif = Math.Min(minDif, ans[0, i] + ans[1, j] + ans[2, k]);
                }
            }
        }
        Console.WriteLine(minDif);
    }
}

Measured memory_bytes: 19284
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

// ref : https://tt-conpetitive.hatenablog.com/entry/2020/01/03/221433

ll n, m;
vector<ll> a;

bool check(ll x){
    ll cnt = 0;
    rep(i, n){
        ll pos = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
        cnt += (n - pos);
    }
    return cnt < m;
}

ll binary_search() {
    ll ng = 0;
    ll ok = LINF;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    return ng;
}

int main(){
    cin >> n >> m;
    rep(i, n) {
        ll b;
        cin >> b;
        a.push_back(b);
    } 
    sort(a.begin(), a.end());

    vector<ll> acc(n+1, 0);
    rep(i, n) acc[i+1] = acc[i] + a[i];
    
    ll x = binary_search();
    ll ans = 0;
    rep(i, n){
        ll pos = upper_bound(a.begin(), a.end(), x - a[i]) - a.begin();
        ans += (n - pos) * a[i] + (acc[n] - acc[pos]);
        m -= (n - pos);
    }
    ans += m * x;

    cout << ans << endl;

    return 0;
}


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

int N, K;

int main() {
    cin >> N >> K;
    int h;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> h;
        if (h < K) continue;
        ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
class Euclid_Gojyohou{
    public:
    long long int gcd(long long int a, long long int b) {
        long long int tmp;
        long long int r = 1;
        if (b > a) {
            tmp = a;
            a = b;
            b = tmp;
        }
        r = a % b;
        while (r != 0) {


            a = b;
            b = r;
            r = a % b;

        }
        return b;
    }
};

//階乗先に計算
class Kaizyou{
    public:
    long long int *kaizyou;
    Kaizyou(){};
    Kaizyou(long long int n,long long int mod){
        kaizyou=new long long int[n+1];
        kai(1,n,mod);
        return;
    }

    long long int kai(long long int a, long long int b, long long int mod) {
        long long int tmp = 1;
        for (long long int i = a; i <= b; i++) {
            tmp *= i;
            tmp %= mod;

            kaizyou[i] = tmp;
        }
        return tmp;
    }
};

//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
class Ruizyou{
    public:
    long long int rui(long long int a, long long int b, long long mod) {
        int memo[65] = {};
        long long int A[65] = {};
        long long int tmp = 1;
        for (int i = 0; i < 65; i++) {
            memo[i] = b % 2;
            b /= 2;
        }

        A[0] = a;
        A[0] %= mod;

        for (int i = 1; i < 65; i++) {
            A[i] = A[i - 1] * A[i - 1];
            A[i] %= mod;
        }
        for (int i = 0; i < 65; i++) {
            if (memo[i] == 1) {
                tmp *= A[i];
                tmp %= mod;
            }
        }
        tmp %= mod;
        return tmp;
    }
};

long long int LCMs[1000005]={};
int main() {
	cout << fixed << setprecision(18);
	long long int N,A[10005],lcm=1,res=0,tmp2;
	cin>>N;
	Euclid_Gojyohou euc;
	Ruizyou ruizyou;
	for(int i=0;i<N;i++){
		cin>>A[i];
		long long int tmp=A[i];
		tmp2=tmp;
		for(long long int j=2;j*j<=tmp2;j++){
			long long int Counter=0;
			while(tmp%j==0){
				Counter++;
				tmp/=j;
			}
			LCMs[j]=max(LCMs[j],Counter);
		}
		if(tmp!=1){
			LCMs[tmp]=max(LCMs[tmp],1LL);
		}
	}
	for(long long int i=2;i<=1000000;i++){
		for(long long int j=0;j<LCMs[i];j++){
			lcm=i*lcm;
			lcm%=mod;
		}
	}
	for(int i=0;i<N;i++){
		res+=lcm*ruizyou.rui(A[i],mod-2,mod);
		res%=mod;
	}
	cout<<res;
} 

Measured memory_bytes: 6656
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a + b >= c) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 21972
# 12月30日のM時から次の年になるまでは何時間か求めろ

# M 時 を標準入力
M = int(input())
# print(M)

# 次の年になる x を求める
# 30日の0時から次の年まで48時間
# M時間過ぎているので、残りは　（48 - M）時間

x = 48 - M
# print(x)

# 答えを代入
answer = x
print(answer)


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

int main() {
	string n;
	cin >> n;
	int sum = 0;
	rep (i, n.size()) {
		sum += (int) (n[i] - '0');
	}
	if (sum%9==0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

namespace myApp
{
    class Program
    {
        static void Main()
        {
            switch(Console.ReadLine())
            {
                case "A":
                    Console.WriteLine("T"); 
                    break;
                case "T":
                    Console.WriteLine("A");
                    break;
                case "G":
                    Console.WriteLine("C");
                    break;
                case "C":
                    Console.WriteLine("G");
                    break;
            }
        }
    }
}

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

int main(){
  int n, ans, a;
  ans = 0;
  cin >> n;
  a = n;
  while(a > 0){
    ans += a % 10;
    a /= 10;
  }
  if(n % ans == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
n = gets.to_i
rice_cakes = []

n.times do
  rice_cakes << gets.to_i
end

kagamimochi = rice_cakes.sort
count = 0

(0...kagamimochi.length - 1).each do |i|
  if kagamimochi[i] != kagamimochi[i + 1]
    count += 1
  end
end

puts count + 1

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), d = in.nextInt(), x = in.nextInt();
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            sum += (d - 1) / a + 1;
        }
        System.out.println(x + sum);
    }
}

Measured memory_bytes: 21972
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
    ll x; cin >> x;
    ll ans = x/11*2;
    x %= 11;
    if( x == 0 );
    else if( x <= 6 ) ans++;
    else ans += 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  VEC<int> a(n);
  int one, two, four;
  one = two = four = 0;
  REP(i, 0, n) {
    int b;
    cin >> b;
    if (b % 4 == 0)
      four++;
    else if (b % 2 == 0)
      two++;
    else
      one++;
  }
  
  if(four>=one){
    cout << "Yes" << endl;
  }else {
    int d = one - four;
    if(d>1){
      cout << "No" << endl;
    }else{
      if(two==0)
        cout << "Yes" << endl;
        else
          cout << "No" << endl;
    }
  }

  return 0;
}


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

const int mxN = 1e5 + 2, MOD = 1e9 + 7;
int n;
long long dp[mxN][2];
vector<int> adj[mxN], children[mxN];

void dfs(int node, int p)
{
    for (auto &v : adj[node])
    {
        if (v != p)
        {
            children[node].push_back(v);
            dfs(v, node);
        }
    }
}

long long recurse(int node, bool useRoot)
{
    if (dp[node][useRoot] != -1)
        return dp[node][useRoot];

    long long ways = 1;
    if (useRoot)
    {
        for (auto &c : children[node])
        {
            ways *= recurse(c, false);
            ways %= MOD;
        }
    }
    else
    {
        for (auto &c : children[node])
        {
            ways *= (recurse(c, true) + recurse(c, false));
            ways %= MOD;
        }
    }

    dp[node][useRoot] = ways;
    return ways;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        dp[i][0] = dp[i][1] = -1;
    }
    for (int i = 0; i < n - 1; i++)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(0, -1);
    long long ret = 0;
    ret += recurse(0, true);
    ret += recurse(0, false);
    ret %= MOD;
    cout << ret << endl;
}

Measured memory_bytes: 22988
#include <bits/stdc++.h>
using namespace std;
#define vd vector <double>
int main() {
    int n;
    cin>>n;
    vd prb(n+1,0);
    prb[0]=0;
    for(int i=1;i<=n;i++){
        cin>>prb[i];
    }
    vd dp(n+1,0);
    dp[0]=1;
    for(int i=1;i<=n;i++){
    double prev;
    for(int j=0;j<=i;j++){
    double use=prev;
    prev=dp[j];
    if(j==0)dp[j]=dp[j]*(1-prb[i]);
    else dp[j]=use*prb[i]+dp[j]*(1-prb[i]);
    }}
    //for(int i=0;i<=n;i++)cout<<dp[i]<<" ";
    //cout<<endl;
    double ans=0;
    for(int i=(n+1)/2;i<=n;i++)ans+=dp[i];
    cout<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static int debt(int n){
		int x = 100000;
		while( n > 0 ){
			x *= (1 + 0.05);
			if( x%1000 != 0 ){
				x = x - x%1000 + 1000;
			}
			n--;
		}
		return x;
	}

	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();

		System.out.println(debt(n));
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a(3);
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int K;
    cin >> K;
    for(int i = 0; i < K; i++){
        a[2]*=2;
    }
    int b = 0;
    for(int i = 0; i < 3; i++){
        b += a[i];
    }
    cout << b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b);

int main() {
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    if(a > b) {
        swap(&a, &b);
    }
    if(b > c) {
        swap(&b, &c);
    }
    if(a > b) {
        swap(&a, &b);
    }
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}

void swap(int *a, int *b) {
    int tmp;
    
    tmp = *a;
    *a = *b;
    *b = tmp;
}


Measured memory_bytes: 2108
N,P=map(x->parse(Int,x),split(readline()))
if N==1
	println(P)
	exit()
end
ans=1
i=2
while i*i<=P
	if P%i==0
		c=0
		while P%i==0
			P=div(P,i)
			c+=1
		end
		ans*=i^div(c,N)
	end
	i+=1
end
println(ans)


Measured memory_bytes: 170020
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		
		char[] ss=s.toCharArray();
		char[] tt=t.toCharArray();
		
		int count=0;
		for(int i=0;i<s.length();i++) {
			if(ss[i]!=tt[i]) {
				count++;
			}
		}
		
		System.out.println(count);
 		
		sc.close();
	}
}


Measured memory_bytes: 42200
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  string s;
  int n;
  cin>>n;
  cin>>s;
  int mi = MOD;
  s = "?" + s + "?";
  int lb[n+2];
  int rw[n+2];
  rep(i,n+2) {
    lb[i] = 0;
    rw[i] = 0;
  }
  FOR(i,1,n+2) {
    if(s[i] == '#') {
      lb[i] = lb[i-1] + 1;
    } else {
      lb[i] = lb[i-1];
    }
  }
  repr(i,n) {
    if(s[i] == '.') {
      rw[i] = rw[i+1] + 1;
    } else {
      rw[i] = rw[i+1];
    }
  }
  rep(i,n+1) {
    mi = min(mi, lb[i] + rw[i+1]);
  }
  cout << mi << endl;

  return 0;
}


Measured memory_bytes: 2128
n, W = map(int, input().split())
w, v = [0]*(n+1), [0]*(n+1)
for i in range(1, n+1):
    w[i], v[i] = map(int, input().split())

#制約から、品物と価値のdpにする
dp = [[float("inf")]*(sum(v)+1) for _ in range(n+1)]
dp[0][0] = 0
#dp[i][j]はi番目までの品物の中から、価値jを
for i in range(1, n+1):
    for j in range(sum(v) + 1):
        dp[i][j] = dp[i-1][j]
        if j - v[i] >= 0:
            dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i])
ans = 0
for i in range(sum(v)+1):
    if dp[n][i] <= W:
        ans = max(ans, i)
#print(dp[n])
print(ans)


Measured memory_bytes: 251624
N = int(input())

X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key = lambda x: x[1])

cnt = 0
for i in range(N):
    temp = X[i][1]
    cnt += X[i][0]
    if temp < cnt:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 53660
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

MOD = int(1e9) + 7

N = int(input())
A = list(map(int, input().split()))
S = sum(A) % MOD

ans = 0

for a in A:
    ans += a * (S - a + MOD) % MOD
    ans %= MOD
div2 = (MOD + 1) // 2
print(ans * div2 % MOD)

Measured memory_bytes: 31984
lim = 10 ** 5
prime = [1] * (lim + 1) 
like = [0] * (lim + 1)
prime[0] = 0
prime[1] = 0

for i in range(2, lim + 1):
    if prime[i]:
        for j in range(i ** 2, lim + 1, i):
            prime[j] = 0

for i in range(3, lim + 1, 2):
    if prime[i] and prime[(i + 1) // 2]:
        like[i] = 1

for i in range(2, lim + 1):
    like[i] += like[i - 1]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    x = like[r] - like[l - 1]
    print(x)

Measured memory_bytes: 8820
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

int32_t main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n ;
    cin >> n;
    int a[n + 1];
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
    }

    int ans = 0;

    for(int i = 1 ; i <= n ; i++){
        int c = 0;
        while(i + 1 <= n and a[i] >= a[i + 1]){
            c++;
            i++;
        }
        ans = max(c , ans);
    }
    cout << ans << endl;    


    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    string S, T; cin >> S >> T;
    if(S.size() < T.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    else {
        string s = S;
        vector<string> ans;
        for(int i = S.size() - T.size(); i >= 0; i--) {
            bool can = true;
            for(int j = 0; j < T.size(); j++) {
                if(S[i + j] != T[j] && S[i + j] != '?') {
                    can = false;
                    break;
                }
            }
            if(can) {
                for(int j = 0; j < S.size(); j++) {
                    if(s[j] == '?') s[j] = 'a';
                }
                for(int j = 0; j < T.size(); j++) {
                    s[i + j] = T[j];
                }
                ans.push_back(s);
            }
        }
        sort(ans.begin(), ans.end());
        if(ans.size() != 0) cout << ans[0] << endl;
        else cout << "UNRESTORABLE" << endl;
        return 0;
    }
}


Measured memory_bytes: 3596
import copy
import sys
import time

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, C] = [long(input_raw[0]), long(input_raw[1])]
    grid = []
    D = []

    for i in range(C):
        input_raw = read_func().strip().split()
        row = [long(input_raw[i]) for i in range(len(input_raw))]
        D.append(row)

    for i in range(N):
        input_raw = read_func().strip().split()
        row = [long(input_raw[i]) for i in range(len(input_raw))]
        grid.append(row)

    grid_color_dic = {}
    for i in range(3):
        grid_color_dic[i] = [0 for j in range(C)]

    for i in range(N):
        for j in range(N):
            grid_color_dic[(i + j) % 3][grid[i][j] - 1] += 1

    score = [[0 for i in range(C)] for j in range(3)]
    for g in range(3):
        for now_color in range(len(grid_color_dic[g])):
            for next_color in range(C):
                #if grid_color_dic[g][now_color] > 0:
                score[g][next_color] += D[now_color][next_color] * grid_color_dic[g][now_color]



    order = [[0,1,2],[0,2,1],[1,0,2],[1,2,0],[2,0,1],[2,1,0]]
    s_min = sys.maxint
    for o in order:
        min_score=[sys.maxint for i in range(3)]
        arg_min_score =[0 for i in range(3)]
        for g in o:
            for color in range(C):
                if min_score[g] > score[g][color] and color != arg_min_score[(g + 1) % 3] and color != arg_min_score[(g - 1) % 3]:
                    min_score[g] = score[g][color]
                    arg_min_score[g] = color

        s = 0
        for i in range(len(min_score)):
            s += min_score[i]
        if s < s_min:
            s_min = s

    print s_min

if __name__ == '__main__':
    main()

Measured memory_bytes: 12976