akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    vector<int> D(K);
    for(int i = 0 ;i < K;i++)cin >> D[i];
    sort(D.begin(),D.end());
    set<int> C;
    for(int i = 0;i < 10;i++){
        bool frag = 1;
        for(int j = 0;j < K;j++){
            if(i == D[j]) frag = 0;
        }
        if(frag) C.insert(i);
    }
    int c = 0;
    
    vector<int> C1(C.begin(),C.end());
    for(int i = N;i < (N * 10 + 1);i++){
        bool frag = 1;
        string S = to_string(i);
        for(int j = 0;j < D.size();j++){
            char a = '0' + D[j];
            int b = count(S.begin(),S.end(),a);
            if(b >= 1){
                frag = 0;
            }
        }
        if(frag){
            cout << i << endl;
            break;
        }
    }
} 


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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;
    vector<vector<int>> a(n);
    for(int i = 0; i < n; i++) {
        int m; cin >> m;
        for(int j = 0; j < m; j++) {int t; cin >> t; a[i].push_back(t);}
    }
    priority_queue<int> que;
    ll sum = 0;
    for(int i = n - 1; i >= 0; i--) {
        for(auto j : a[i])que.push(j);
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
}


Measured memory_bytes: 19136
use std::cmp::min;

fn main() {
    let (h, w) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.trim().split_whitespace();
        let h: usize = iter.next().unwrap().parse().unwrap();
        let w: usize = iter.next().unwrap().parse().unwrap();
        (h, w)
    };
    let mut map: Vec<Vec<u8>> = Vec::new();
    for _y in 0..h {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line = line.trim().to_string();
        map.push(line.as_bytes().to_vec());
    }
    let mut dp = vec![vec![9999999; w]; h];
    if map[0][0] == 0x23 {
        dp[0][0] = 1;
    } else {
        dp[0][0] = 0;
    }
    for y in 0..h {
        for x in 0..w {
            if y < h - 1 {
                if map[y + 1][x] == map[y][x] || map[y + 1][x] != 0x23 {
                    dp[y + 1][x] = min(dp[y + 1][x], dp[y][x])
                } else {
                    dp[y + 1][x] = min(dp[y + 1][x], dp[y][x] + 1)
                }
            }
            if x < w - 1 {
                if map[y][x + 1] == map[y][x] || map[y][x + 1] != 0x23{
                    dp[y][x + 1] = min(dp[y][x + 1], dp[y][x])
                } else {
                    dp[y][x + 1] = min(dp[y][x + 1], dp[y][x] + 1)
                }
            }
        }
    }
    println!("{}", dp[h - 1][w - 1]);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,w;
	cin>>n>>w;
	vector<long int>dp(100001,INT_MAX);
	dp[0]=0;
	int w1;
	long v1;
	for(int i=1;i<=n;i++){
		cin>>w1>>v1;
		// vector<bool>visited(w+1,0);
		for(int j=100000;j>=v1;j--){
			dp[j]=min(dp[j],dp[j-v1]+w1);
		}
	}
	long res=0;
	for(int i=0;i<100001;i++){
		if(dp[i]<=w)
			res=i;
	}
	// cout<<endl;
	cout<<res;
	return 0;
}

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

int main(void) {
	int *i,*j;
	i = (int *)calloc(1,sizeof(int));
	j = (int *)calloc(1,sizeof(int));
	for (i[0]=1;i[0]<=9;i[0]++) {
		for (j[0]=1;j[0]<=9;j[0]++) printf("%dx%d=%d\n",i[0],j[0],i[0]*j[0]);
	}
	free(j);
	free(i);

	return 0;
}

Measured memory_bytes: 540
# coding: utf-8
import math

(n, m) = [int(i) for i in input().rstrip().split(" ")]

ans = 0
divList = []
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i == 0:
        j = m / i
        divList.append(i)
        divList.append(j)
divList = sorted(divList)
for i in divList:
    if i < n:
        continue
    ans = m / i
    break

print(int(ans))


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
	int k;
	string s;
	cin >> s;
	cin >> k;

	for (int i = 0; i < s.length(); i++) {
		char c = s.at(i);
		if (k==0) {
			cout << (char) c;
			continue;
		}
		if (i == s.length() - 1) {
			int cc = c - 'a';
			cout << (char) ((cc + k) % 26 + 'a');
			k = 0;
			continue;
		}

		if (c == 'a') {
			cout << c;
			continue;
		}
		int cc = c - 'a';
		int need_change = 26 - cc;
		if (k < need_change) {
			cout << c;
			continue;
		}

		k -= need_change;
		cout << "a";

	}
	cout << endl;	
	return 0;
} 

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		int period = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in), 32).readLine());
		int val = 100;//壱百千円
		for (; 0 < period; period--) {
			val = val * 105 % 100 == 0 ? (int) (val * 1.05) : (int) (val * 1.05) + 1;
		}
		System.out.println(val * 1000);
	}
}

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


long long N;
long long A[100005], D[100005], O[100005], maxD = -1000000000;
long long v[100005];
int main() {
	scanf("%lld", &N);
	if (N == 1) {
		printf("YES\n");
		return 0;
	}
	for (int i = 0; i < N; i++) scanf("%lld", &O[i]);
	long long sum = 0, v0 = 0;
	for (int i = 0; i < N; i++){
		D[i] = (O[(i + 1) % N] - O[i]);
		maxD = max(maxD, D[i]);
	}
	for (int i = 0; i < N; i++) D[i] = abs(D[i] - maxD);
	for (int i = 0; i < N; i++) {
		if (D[i] % N != 0) {
			printf("NO\n");
			return 0;
		}
		else D[i] /= N;
		sum += D[i];
		v0 += D[i] * (N - i);
	}
	v[0] = v0;
	for (int i = 1; i < N; i++) {
		v[i] = v[i - 1] + sum - D[i - 1] * N;
	}
	set<long long> s;
	for (int i = 0; i < N; i++) {
		if (O[i] < v[i] || ((O[i] - v[i]) % (N * (N + 1) / 2) != 0)) {
			printf("NO\n");
			return 0;
		} else s.insert((O[i] - v[i]));
	}
	if (s.size() == 1) printf("YES\n");
	else printf("NO\n");
	
}


Measured memory_bytes: 2560
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string S,T;
	ll cnt=0;
	cin>>S>>T;
	for(ll i=0;i<3;i++)
	{
	    if(S[i]==T[i])
	    {
	        cnt++;
	    }
	}
	cout<<cnt<<endl;
	return 0;
}

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



int main()
{

    ll n,i,o,e;
    double x;
    cin>>n;
    if(n%2==0)
    {
        o=n/2;
        e=n/2;
    }
    else if(n%2==1)
    {
        o=n/2 + 1;
        e=n/2;
    }
    //cout<<o<<endl;
    //cout<<e<<endl;

    x=(o*1.00)/n;
    cout<<fixed<<setprecision(10)<<x<<endl;

}


Measured memory_bytes: 256
//C++初期コード

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main() {
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;
    r0
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n; 
int main () {
	cin >> n;
	bool ans = false;
	for ( int i = 1; i <10 ; i ++) {
		for ( int j = 1 ; j < 10 ; j++) {
			
			if (n == i * j) {
			ans = true;
			}
			
		}
	}
	if(ans) {
 cout<<"Yes"<<endl;
}
  else cout<<"No"<<endl; {
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E15;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

void Max(dd &pos,dd val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
 
int main(){fastio
    ll n,m;cin>>n>>m;
    vector<ll> v[n+1];
    rep(i,1,m){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
    }
    dd p[n+1];
    p[1]=1.0;
    rep(i,2,n)p[i]=0.0;
    rep(i,1,n){
        ll siz=v[i].size();
        for(auto x:v[i]){
            p[x]+=p[i]/(dd)siz;
        }
    }
    //rep(i,1,n)cout<<p[i]<<endl;
    dd a[n+1];
    a[n]=0;
    rep(i,1,n-1)a[i]=1;
    for(ll i=n-1;i>=1;i--){
        ll siz=v[i].size();
        for(auto x:v[i]){
            a[i]+=a[x]/(dd)siz;
        }
    }
    //rep(i,1,n)cout<<a[i]<<endl;
    dd ans=a[1];
    dd res=0;
    rep(i,1,n-1){
        ll siz=v[i].size();
        if(siz<=1)continue;
        vector<dd>k;
        for(auto x:v[i]){
            k.pb(a[x]);
        }
        sort(k.begin(),k.end());
        dd pre=0,post=0;
        rep(i,0,siz-1){
            pre+=k[i];
            if(i<=siz-2)post+=k[i];
        }
        //cout<<pre<<" "<<post<<endl;
        pre/=(dd)siz;
        post/=(dd)(siz-1.0);
        dd q=(pre-post)*p[i];
        Max(res,q);
        //cout<<q<<endl;
    }
    cout<<setprecision(15)<<ans-res<<endl;
    
    return 0;
}


Measured memory_bytes: 2560
k=int(input())
x=[0]*50
k1=k//50
k2=k%50
for i in range(k2):
    x[k2-i-1]=50-i
for i in range(k2+1,50):
    x[i]=i-k2
for i in range(50):
    x[i]+=k1
print(50)
print(" ".join(map(str,x)))


Measured memory_bytes: 3060
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	var n, tot int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
		tot += a[i]
	}
	x, ans := 0, int(1e18)
	for i := 0; i+1 < n; i++ {
		x += a[i]
		y := tot - x
		// fmt.Printf("i %d, tot %d, x %d, y %d, abs(x-y) %d\n", i, tot, x, y, abs(x-y))
		ans = min(ans, abs(x-y))
	}
	fmt.Println(ans)
}


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

int main(){
  ll N,K;
  cin>>N>>K;
  vector<pair<ll,ll>> A(N,pair<ll,ll>(0,0));
  for(int i=0;i<N;i++){
    cin >> A[i].first >> A[i].second;
  }
  sort(A.begin(),A.end());
  ll count=0;
  for(int i=0;i<N;i++){
    if(count + A[i].second <K){
      count += A[i].second;
    }else{
      cout << A[i].first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>

using namespace std;


int pn(int num){

    if(num == 2 || num == 3 || num == 5) return 1;
    if(num < 2 || num % 2 == 0 ) return 0;

    int i = 3;
    while(i <= sqrt(num)){
        if(num % i == 0 ) return 0;
        i+=2;
    }
    return 1;
}

int main(){

    int n;
    int num;
    int cnt=0;
    cin >> n;
    
    for(int i=0; i<n; i++){
       cin >> num;
       cnt += pn(num); 
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3104
C = int(1e9) + 7
h, w, a, b = [int(x) for x in input().split()]

# 1000000005 = 2^29 + 2^28 + 2^27 + 2^25 + 2^24 + 2^23 + 2^20 + 2^19 + 2^17 + 2^15 + 2^14 + 2^11 + 2^9 + 2^2 + 1

def pow(n):
    ans = n
    for i in range(1, 30):
        n = (n * n) % C
        if i in {29, 28, 27, 25, 24, 23, 20, 19, 17, 15, 14, 11, 9, 2}:
            ans = (ans * n) % C
    return ans

fact = [1]
factinv = [1] # dummy
for x in range(1, h + w - 2):
    fact.append((x * fact[x - 1]) % C)
    # factinv.append(pow(x)) # <- this won't work, why?
    factinv.append((pow(x) * factinv[x - 1]) % C)

def nCr(n, r):
    return (fact[n] * factinv[r] * factinv[n - r]) % C

ans = 0
for i in range(b, w):
    ans = (ans + nCr(i + h - a - 1, h - a - 1) * nCr(a - 1 + w - i - 1, a - 1)) % C

print(ans)


Measured memory_bytes: 71260
table = ((?a..?z).to_a + [?., ??, ?!, " "]).each_slice(5).to_a
while gets
    a = $_.chomp.split("").map(&:to_i).each_slice(2).to_a
    ans = ""
    a.each do |i, j|
        if !j || !(1..6).include?(i) || !(1..5).include?(j)
            ans = 'NA'
            break
        end
        ans += table[i-1][j-1]
    end
    puts ans
end

Measured memory_bytes: 8800
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long X, long long A, long long B){
  op((X-A)%B)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(X, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }

    int m;
    cin >> m;
    vector<string> t(m);
    for(int i = 0; i < m; i++){
        cin >> t[i];
    }

    map<string, int> pos, neg;
    for (int i = 0; i < n; i++){
        if (pos.count(s[i]) == 0){
           // pos[s[i]] = 0;
           pos.insert(make_pair(s[i], 0));
        }
    }
    for (int i = 0; i < m; i++){
        if (neg.count(t[i]) == 0){
            // neg[t[i]] = 0;
            neg.insert(make_pair(t[i], 0));
        }
    }

    for (int i = 0; i < n; i++){
        pos[s[i]]++;
    }
    for (int i = 0; i < m; i++){
        neg[t[i]]++;
    }

    // cout << "here" << pos["apple"] << endl;

    int ans = 0;
    for (int i = 0; i < n; i++){
        // int tmp = pos.count(s[i]) - neg.count(s[i]);
        int tmp = pos[s[i]] - neg[s[i]];
        if (tmp > ans){
            ans = tmp;
        }
    }

    cout << ans << endl;


    return 0;
}









Measured memory_bytes: 256
h,w = map(int,input().split())
s = [input() for _ in range(h)]
dp = [[float("inf") for _ in range(w)] for _ in range(h)]
dp[0][0] = 0 if s[0][0] == "." else 1 
for i in range(h):
    for j in range(w):
        if i < h-1:
            if s[i][j] == "." and s[i+1][j] == "#":
                dp[i+1][j] = min(dp[i][j]+1,dp[i+1][j])
            else:
                dp[i+1][j] = min(dp[i][j],dp[i+1][j])
        if j < w-1:
            if s[i][j] == "." and s[i][j+1] == "#":
                dp[i][j+1] = min(dp[i][j]+1,dp[i][j+1])
            else:
                dp[i][j+1] = min(dp[i][j],dp[i][j+1])
print(dp[h-1][w-1])

Measured memory_bytes: 3316
def sieve(n):
    count = [2] * (n+1)
    count[1] = 1

    p = 0
    for i in range(2,n+1):
        p = i
        for j in range(p+p, n+1, p):
            count[j] += 1
    
    return count

def solve():
    N = int(input())
    sieve_res = sieve(N)
    ans = 0
    for i in range(1,N+1):
        ans += i * sieve_res[i]
    print(ans)

if __name__ == '__main__':
    solve()


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

int main()
{
    int n;
    cin >> n;
    vector<int> ans(n);
    int a = sqrt(n);
    for (int x = 1; x <= a; x++)
    {
        for (int y = 1; y <= a; y++)
        {
            for (int z = 1; z <= a; z++)
            {
                int m = x * x + y * y + z * z + x * y + y * z + z * x;
                if (m <= n)
                {
                    ans[m - 1]++;
                }
            }
        }
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<utility>
#include<deque>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<numeric>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

string s;

int main(void) {
	cin >> s;
	string ret;
	if (s[0] == 'S')
		ret = "Cloudy";
	else if (s[0] == 'C')
		ret = "Rainy";
	else
		ret = "Sunny";

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int H,W;
    cin >> H >> W;
    lint A[H][W],B[H][W];
    rep(i,H) rep(j,W) cin >> A[i][j];
    rep(i,H) rep(j,W) cin >> B[i][j];
    lint C[H][W];
    rep(i,H) rep(j,W) C[i][j]=abs(A[i][j]-B[i][j]);
    bool dp[H][W][12801]={};
    dp[0][0][6400+C[0][0]]=true,dp[0][0][6400-C[0][0]]=true;
    rep(i,H) rep(j,W){
        if(i!=0){
            rep(k,12801) if(dp[i-1][j][k]){
                if(k+C[i][j]<12801) dp[i][j][k+C[i][j]]=true;
                if(k-C[i][j]>=0) dp[i][j][k-C[i][j]]=true;
            }
        }
        if(j!=0){
            rep(k,12801) if(dp[i][j-1][k]){
                if(k+C[i][j]<12801) dp[i][j][k+C[i][j]]=true;
                if(k-C[i][j]>=0) dp[i][j][k-C[i][j]]=true;
            }
        }
    }
    int ans=INF;
    rep(i,12801) if(dp[H-1][W-1][i]) ans=min(ans,abs(6400-i));
    cout << ans << endl;
}

Measured memory_bytes: 80384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        h: usize,
        n: usize,
        v: [(usize, usize); n]
    }
    let inf = usize::max_value() >> 1;
    let mut dp = vec![inf; h + 1];
    dp[0] = 0;
    for &(a, b) in &v {
        if h < a {
            for i in 0..h {
                dp[h] = min(dp[h], dp[i] + b);
            }
        } else {
            for i in 0..h - a {
                dp[i + a] = min(dp[i + a], dp[i] + b);
            }
            for i in h - a..h {
                dp[h] = min(dp[h], dp[i] + b);
            }
        }
    }
    println!("{}", dp[h]);
}


Measured memory_bytes: 4352
#解説チラ見
n,m = map(int,input().split())
ans = n
pre = [i for i in range(n)]
for _ in range(m):
  x,y,z = map(lambda x: int(x)-1, input().split())
  X = [x]
  while pre[x] != x:
    x = pre[x]
    X.append(x)
  Y = [y]
  while pre[y] != y:
    y = pre[y]
    Y.append(y)
  if x != y:
    ans -= 1
    for xx in X:
      pre[xx] = y
    for yy in Y:
      pre[yy] = y
    pre[x] = y
print(ans)

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

int main(){
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);

    for(long long i = 0; i < n; i++) cin >> a[i];

    long long sum = 0;
    for(long long i = 0; i < k; i++) sum += a[i];

    vector<long long> b(n ,0);

    b[k-1] = sum;
    for(long long i = 0; i < n; i++){
        if(i <= k-1) continue;

        sum -= a[i-k];
        sum += a[i];
        b[i] = sum;
    }

    vector<string> ans;
    for(long long i = k-1; i < n; i++){

        if(i + 1 < n and b[i] < b[i+1]) ans.push_back("Yes");
        else if(i + 1 < n and b[i] >= b[i+1]) ans.push_back("No");
    }

    for(long long i = 0; i < ans.size(); i++) cout << ans[i] << endl;

    return 0;
}

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


Measured memory_bytes: 2752
#include <iostream>
#include <algorithm>

using namespace std;

void prints(int *a, int n) {
    for(int i=0; i<n; i++) cout << a[i] << " ";
    cout << endl;
}

int main() {
    string s;
    cin >> s;
    if(s.size()<26) {
        for(char c='a'; c<='z'; c++) {
            if(s.find(c) == string::npos) {
                cout << s << c << endl;
                return 0;
            }
        }
    } else {
        int p[26];
        for(int i=0; i<26; i++) p[i] = s[i] - 'a';
        bool has_next = next_permutation(p, p+26);
        if(has_next) {
            string ss(26, ' ');
            for(int i=0; i<26; i++) {
                ss[i] = 'a' + p[i];
            }
            for(int i=0; i<26; i++) {
                if(s[i]==ss[i]) {
                    cout << ss[i];
                } else {
                    cout << ss[i] << endl;
                    return 0;
                }
            }
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template<class T>
inline void out(T a){cout<<a<<endl; }
inline void out(double a){ printf("%.10f\n", a);} 

ll mod = 1000000007;

ll mmul(ll a, ll b) {
	return ((a % mod) * (b % mod)) % mod;
}

ll mpow(ll a, ll b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll d = mpow(a, b / 2);
		return (d * d) % mod;
	}
	return (a * mpow(a, b - 1)) % mod;
}

ll mdiv(ll a, ll b) {
	return mmul(a, mpow(b, mod - 2));
}

int main()
{
    in(n);
    in(k);
    in(q);
	vector<ll> pl(n,k-q);
	repin(a,q);
	rep(i,q){
		pl[a[i]-1]+=1;
	}
	rep(i,n){
		if(pl[i]<=0){
		out("No");
		}else{
		out("Yes");
		}
	}
}

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

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

    int a = n % 10;

    if((a==2) || (a==4) || (a==5) || (a==7)|| (a==9)){
        cout << "hon" << endl;
    }

    else if((a==3)){
        cout << "bon" << endl;
    }

    else{
        cout << "pon" << endl;
    }
}


Measured memory_bytes: 3636
import java.io.*;
public class Main{
	
	public static void main(String[] args)throws IOException{
		
		
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String[] strAry = br.readLine().split(" ");
		
		int num = 0;
		int min = 1000000;
		int max = -1000000;
		long sum = 0;
		
		for(int i=0; i<N; i++){
			num = Integer.parseInt(strAry[i]);
			if(num<min) min = num;
			if(num>max) max = num;
			sum += num;
		}
		System.out.println(min + " " + max +  " " + sum);
	
	}

}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)3e3+1;
int N;
int dp[MAXN][MAXN];


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int x = s.length();
    int y = t.length();
    for(int i=0; i<x; i++)
    {
        for(int j=0; j<y; j++)
        {
            if(s[i] == t[j])
            {
                dp[i][j]++;
                if(i && j)
                    dp[i][j] += dp[i-1][j-1];
            }
            else
            {
                if(i)
                {
                    dp[i][j] = max(dp[i][j], dp[i-1][j]);
                }
                if(j)
                {
                    dp[i][j] = max(dp[i][j], dp[i][j-1]);
                }
            }
        }
    }
    int sind = x-1, tind = y-1;
    string ans = "\0";
    while(sind >= 0 && tind >= 0)
    {
        if(sind == 0 && tind == 0 && s[sind] != t[tind])
        {
            break;
        }
        if(s[sind] == t[tind])
        {
            ans += s[sind];
            sind--;
            tind--;
        }
        else if(sind && tind)
        {
            if(dp[sind-1][tind] > dp[sind][tind-1])
            {
                sind--;
            }
            else
            {
                tind--;
            }
        }
        else
        {
            if(tind > 0)
                tind--;
            if(sind > 0)
                sind--;
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}


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

int main()
{
    long long int n,i,j,k;
    cin>>n;
    long long int dp[n+1][n+1];

    for(i=0;i<=n;i++)
        for(j=0;j<=n;j++)
            dp[i][j]=1e14;

    vector<long long int> v[205];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            char c;
            cin>>c;
            if(i==j)
                dp[i][j]=0;
            else if(c=='1')
            {
                dp[i][j]=1;
                if(dp[j][i]!=1)
                {
                    v[i].push_back(j);
                    v[j].push_back(i);
                }
            }
        }
    }

    long long int clr[n+1];

    for(i=0;i<=n;i++)
        clr[i]=-1;

    queue<long long int> q;
    q.push(1);
    clr[1]=1;
    while(!q.empty())
    {
        long long int top=q.front();
        q.pop();
        long long int si=v[top].size();

        for(i=0;i<si;i++)
        {
            if(clr[v[top][i]]==-1)
            {
                clr[v[top][i]]=1^clr[top];
                q.push(v[top][i]);
            }
            else if(clr[top]==clr[v[top][i]])
            {
                cout<<-1;
                return 0;
            }
        }
    }

    for(k=1;k<=n;k++)
    {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n;j++)
            {
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }

    long long int ans=0;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(dp[i][j]<1e14)
                ans=max(ans,dp[i][j]+1);
        }
    }

    cout<<ans;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const double INF = std::numeric_limits<double>::infinity() ;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main(void){
  ios::sync_with_stdio(false);

  int N ,M;
  cin >> N >> M;
  int p[M];
  string s[M];
  REP(i, M){cin >> p[i];
    cin >> s[i];
  p[i]--;}

  int solved[N];
  REP(i, N){solved[i] = 0;}

  ll pena = 0;
  ll acc = 0;
  REP(i, M){
    string tmp = s[i];
    int num = p[i];
    if (tmp == "AC"){solved[num] = 1;}
  }

  int now_solved[N];
  REP(i, N){now_solved[i] = 0;}

  REP(i, M){
    string tmp = s[i];
    int num = p[i];
    if (tmp == "AC" and now_solved[num] == 0){
      acc++;
      now_solved[num] = 1;
    }

    if (tmp == "WA" and now_solved[num] == 0 and solved[num] == 1){
      pena++;
    }
  }

  cout << acc << endl;
  cout << pena << endl;

  return 0;
}



Measured memory_bytes: 6912
def main():
  import sys
  input = sys.stdin.readline

  N = int(input())
  H = list(map(int, input().split()))


  res = tmp = 0
  for i in range(N-1):
    if H[i] >= H[i+1]:
      tmp += 1
    else:
      tmp = 0
    if tmp > res:
      res = tmp

  print(res)

main()

Measured memory_bytes: 14252
from functools import reduce

def main():
    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    n = int(input().rstrip())
    ans = 0
    for i in range(1,n+1):
        ans = ans + i
    print(ans)    
   
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
/*
	Powered by C++11.
	Author : Alex_Wei.
*/

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

//#pragma GCC optimize(3)
//#define int long long

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

// Templates start.

namespace IO{
	char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
	#ifdef __WIN64
		#define gc getchar()
	#else
		#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
	#endif
	#define pc(x) (*O++=x)
	#define flush() fwrite(obuf,O-obuf,1,stdout)

	inline int read(){
		int x=0,sign=0; char s=getchar();
		while(!isdigit(s))sign|=s=='-',s=getchar();
		while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=getchar();
		return sign?-x:x;
	}
	void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}
}

namespace math{
	const int mod=998244353;
	const int maxn=1e6+5;

	ll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=s*m%mod; m=m*m%mod,b>>=1;} return s;}
	ll inv(ll x){return ksm(x,mod-2);}

	ll fc[maxn],ifc[maxn];
	void init_m(int n){
		fc[0]=1; for(int i=1;i<=n;i++)fc[i]=fc[i-1]*i%mod;
		ifc[n]=inv(fc[n]); for(int i=n-1;i>=0;i--)ifc[i]=ifc[i+1]*(i+1)%mod;
	}
	ll C(ll n,ll m){return fc[n]*ifc[m]%mod*ifc[n-m]%mod;}
}

// Templates end. Please give me more points.

using namespace IO;
//using namespace math;

string s;

int main(){
	cin>>s;
	if(s[1]=='R')cout<<"ABC";
	else cout<<"ARC";
	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(){
	char arr[355];
	scanf("%[^\n]", &arr);
	int test = 1;
	for(int i=0;arr[i]!='\0';i++){
		if(arr[i]==' '&&arr[i-1]!=arr[i+1]){
			test=0;
			break;
		}
	}
	if(test==1){
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1568
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

vector< vector<int> > a(11);

int dp[2001][2001] = {};

int dfs(int k, int g) {
	if (dp[k][g] != -1)return dp[k][g];
	if (g > 10)return 0;
	int M = 0;
	for (int i = 0; i <= a[g].size(); i++) {
		if (k - i == 0) {
			M = max(
				M,
				a[g][i - 1]
			);
		}
		else if (k - i > 0) {
			//cout << i << " " << k << " " << g << " " << M << " " << a[g].size() << endl;
			int x = 0;
			if (i >= 1)
				x = a[g][i - 1];
			M = max(
				M,
				(dp[k - i][g + 1] = dfs(k - i, g + 1)) + x
			);
		}
	}
	return M;

}

int main() {
	memset(dp, -1, sizeof(dp));
	int N, K; cin >> N >> K;

	for (int i = 0; i < N; i++) {
		int C, G; cin >> C >> G;
		a[G].push_back(C);
	}
	for (int i = 1; i <= 10; i++) {
		sort(a[i].rbegin(), a[i].rend());
		for (int j = 1; j < a[i].size(); j++)
			a[i][j] += a[i][j - 1];
		for (int j = 1; j < a[i].size(); j++)
			a[i][j] += j*(j + 1);
		//for (int j = 0; j < a[i].size(); j++)
		//	cout << i << " " << j + 1 << " " << a[i][j] << endl;
	}
	cout << dfs(K, 1) << endl;

	return 0;
}

Measured memory_bytes: 16880
import collections

n,q= map(int,input().split())
time= collections.deque()
name= collections.deque()
for _ in range(n):
    x,y= input().split()
    name.append(x)
    time.append(int(y))

cur=0
while True:
    if len(time)==0:
        break
    temp= time.popleft()
    if temp<= q:
        cur= temp+cur
        print(name.popleft(),cur)
        
    else:
        name.append(name.popleft())
        time.append(temp-q)
        cur+=q


Measured memory_bytes: 9884
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



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

	string ans;
	set<char> charSet;
	for (int i = 0; i <s.length();i++) {
		string tmp = s.substr(0, i);
		for (int j = 1; j < 26;j++) {
			if (s[i] + j > 'z') {
				break;
				
			}

			if (charSet.find(s[i] + j) == charSet.end()) {
				tmp += s[i] + j;
				
				ans = tmp;
				break;
			}
		}
		charSet.insert(s[i]);
		
	}

	if (charSet.size() < 26) {
		for (int i = 0;i < 26;i++) {
			if (charSet.find('a' + i) == charSet.end()) {
				ans = s;
				ans += 'a' + i;
				break;
			}
		}
	}
	
	if (ans.length() == 0) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const long long mod = 998244353;
int N, S, A[3000];
long long dptable[3000][3001];
long long dp(int i, int j) {
	if (j < 0) return 0;
	if (j == 0) return N - i + 1;
	if (i == N) return 0;
	if (dptable[i][j] != -1) return dptable[i][j];
	return (dptable[i][j] = dp(i + 1, j) + dp(i + 1, j - A[i])) % mod;
}
int main() {
	memset(dptable, -1, sizeof dptable);
	scanf("%d %d", &N, &S);
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	long long ans = 0;
	for (int i = 0; i < N; ++i) ans = (ans + dp(i, S)) % mod;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 70656
n, m, l = map(int, input().split())
As = [list(map(int, input().split())) for i in range(n)]
Bs = [list(map(int, input().split())) for i in range(m)]
Cs = [[0]*l for i in range(n)]

for i in range(n):
    for j in range(l):
        s = 0
        for k in range(m):
            s += As[i][k]*Bs[k][j]
        Cs[i][j] = s
# print(Cs)
for i in range(n):
    print(*Cs[i])


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

int main() {
  char ch;
  int counter[26] = {0};
  while (cin >> ch) {
    if (islower(ch)) {
      counter[ch - 'a']++;
    } else if (isupper(ch)) {
      counter[ch - 'A']++;
    }
  }

  for (int i = 0; i < 26; i++) {
    cout << (char) (i + 'a') << " : " << counter[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1140
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

bool memo[5001];
vector<int> win[5001],sorted;

void dfs(int v){
	if(memo[v]) return;
	memo[v]=true;
	for(int i=0;i<win[v].size();i++){
		dfs(win[v][i]);
	}
	sorted.push_back(v);
}

int main(){
	int N,M,A,B;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>A>>B;
		win[A].push_back(B);
	}
	for(int i=1;i<=N;i++){
		dfs(i);
	}
	bool ans=false;
	for(int i=N-1;i>=0;i--){
		printf("%d\n",sorted[i]);
		if(i!=0){
			bool flag=false;
			for(int j=0;j<win[sorted[i]].size();j++){
				if(win[sorted[i]][j]==sorted[i-1]) flag=true;
			}
			if(flag==false) ans=true;
		}
	}
	if(ans) puts("1");
	else puts("0");
	return 0;
}

Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,temp;
  cin>>a>>b;
  if(b==100){
    temp=a*1000+b;
  }else if(b<10){
    temp=a*10+b;
  }else{
    temp=a*100+b;
  }
  int i=1;
  int judge=0;
  while(1){
    if(i*i>temp) break;
    else if(i*i==temp){
      judge=1;
      break;
    }
    i++;
  }
  if(judge==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
// o o o o o 
// o o o o o
// o o o o o 
signed main() {
    int N,M,K;
    cin >> N >> M >> K;
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= M; j++) {
            if((N-i)*(M-j)+(i*j)== K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x >= k) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define endl "\n"
#define INT long long int
using namespace std;
char C[1010][1010];
int A[1010][1010];
int AA[4]={0,0,1,-1};
int AB[4]={1,-1,0,0};
int BA[20] = {-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2};
int BB[20] = {-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
int h, w;
vector < pair <int, int> > V[2];
void dfs(int c1, int c2, int k){
    int i;
    A[c1][c2] = k;
    V[k%2].push_back({c1,c2});
    for(i=0;i<4;i++){
        if (c1+AA[i]>=0 and c1+AA[i]< h and c2+AB[i]>=0 and c2+AB[i]<w and A[c1+AA[i]][c2+AB[i]]==0 and C[c1+AA[i]][c2+AB[i]]=='.'){
            dfs(c1+AA[i],c2+AB[i],k);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    int  i, c1, c2, d1, d2,j,k,ii,aa,bb;
    cin >> h >> w >> c1 >> c2 >> d1 >> d2;
    for(i=0;i<h;i++) cin >> C[i];
    dfs(c1-1,c2-1,1);
    for(i=1; ;i++){
        if(A[d1-1][d2-1]){
            cout << A[d1-1][d2-1]-1 <<endl;
            return 0;
        }
        if(V[i%2].size()==0) break;
        V[(i+1)%2].clear();
        for(j=0;j<V[i%2].size();j++){
            aa = V[i%2][j].first;
            bb = V[i%2][j].second;
            for(ii=0;ii<20;ii++){
                if(aa+BA[ii]>=0 and aa+BA[ii]<h and bb+BB[ii]>=0 and bb+BB[ii]<w and A[aa+BA[ii]][bb+BB[ii]]==0 and C[aa+BA[ii]][bb+BB[ii]]=='.'){
                    dfs(aa+BA[ii],bb+BB[ii],i+1);
                }
            }
        }
        
    }
    cout << -1 <<endl;
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
ll ans=0;
ll n,m,q;
const ll ma=51;
ll a[ma];
ll b[ma];
ll c[ma];
ll d[ma];

void dfs(vec<ll> A, ll x){
    A.push_back(x);
    if(A.size()==n+1){
        ll ret=0;
        REP(i,q) {
            if(A[b[i]]-A[a[i]]==c[i]) ret+=d[i];
        }
        chmax(ans,ret);
        return;
    }
    for(int i=x;i<=m;i++){
        dfs(A,i);
    }
}

void solve(){
    cin>>n>>m>>q;
    REP(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    vec<ll> A;
    dfs(A,1);
    cout<<ans<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

int main () {
	int n;
	while (cin >> n, n) {
		vector<int> a;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			a.push_back(x);
		}
		sort(a.begin(), a.end());
		unsigned long long wait = 0;
		unsigned long long result = 0;
		for (unsigned i = 0; i < a.size(); i++) {
			result += wait;
			wait += a[i];
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()

int main(){
	double R; cin >> R;
	cout << fixed << setprecision(5) << M_PI * R * 2 << endl;
}

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

// X -> X * 101 / 100

int main() {
    long long X;
    cin >> X;
    long long now = 100;
    long long res = 0;
    while(true){
        now += now/100LL;
        ++res;
        if(now >= X) break;
    }
    cout << res << endl;
    return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < (int)v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};


ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll h,w;
vector<string> s;

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

  cin>>h>>w;
  s.resize(h);
  rep(i,h)cin>>s[i];

  ll res=1;
  if(h%2==1){
    ll mid=h/2;
    bool isp=true;
    rep(j,w)if(s[mid][j]!=s[mid][w-1-j])isp=false;
    if(!isp){
      res*=2;
    }

    vector<string> ns;
    rep(i,h){
      if(i==mid)continue;
      ns.push_back(s[i]);
    }
    s=ns;
    h--;
  }

  if(w%2==1){
    ll mid=w/2;
    bool isp=true;
    rep(i,h)if(s[i][mid]!=s[h-1-i][mid])isp=false;
    if(!isp){
      res*=2;
    }

    vector<string> ns;
    rep(i,h){
      string tmp;
      rep(j,w){
        if(j==mid)continue;
        tmp+=s[i][j];
      }
      ns.push_back(tmp);
    }
    s=ns;
    w--;
  }

  UnionFind uf((h/2)+(w/2));
  rep(i,h/2)rep(j,w/2){
    map<char,ll> cnt;
    cnt[s[i][j]]++;
    cnt[s[i][w-1-j]]++;
    cnt[s[h-1-i][j]]++; 
    cnt[s[h-1-i][w-1-j]]++;

    if(cnt.size()==4){
      uf.unite(i,(h/2)+j);
      res*=mod_pow(2,mod-2);
      res%=mod;
    }

    ll cnta=24;
    for(auto it : cnt){
      rep(k,it.se)(cnta*=mod_pow(k+1,mod-2))%=mod;
    }
    (res*=cnta)%=mod;
  }

  set<ll> comp;
  rep(i,h/2)comp.insert(uf.find(i));
  rep(j,w/2)comp.insert(uf.find((h/2)+j));

  res*=mod_pow(2,(h/2)+(w/2)-comp.size());
  res%=mod;
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 384
import sys
S = input()
k = int(input())
cnt1 = 0
for s in S:
  if s != '1':
    print(int(s))
    sys.exit()
  else:
    cnt1 += 1
    if cnt1 >= k:
      print(1)
      sys.exit()
    continue
print(S[-1])

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int arr[maxn],ans,now,maxv=-1;
inline int read() {
	int x=0,neg=1;char ch=getchar();
	while(!isdigit(ch)) {
		if (ch=='-') neg=-1;
		ch=getchar();
	}
	while(isdigit(ch)) {
		x=x*10+(ch-'0');
		ch=getchar();
	}
	return x*neg;
}
int main() {
	int n=read(),m=read();
	for (int i=1;i<=m;++i) {
		int l=read(),r=read();
		arr[l]++;
		arr[r+1]--;
		maxv=max(maxv,r);
	}
//	cout<<"test\n";
	for (int i=1;i<=maxv;++i) {
//		cout<<i<<'\n';
		now+=arr[i];
		if (now==m) {
			++ans;
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 640