akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np
import itertools
import heapq
import bisect
import math
import queue
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数
from copy import deepcopy #参照で影響されないコピー
from collections import Counter, deque, defaultdict #要素ごとの出現回数、双方向アクセス可能データ型
from functools import reduce
mod = 1000000007
inf = 10**10
sys.setrecursionlimit(1000000)

input = sys.stdin.readline

def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res
 
def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
# template


def main():
    n, w = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(n)]

    dp = np.zeros([n+1, w+1])
    
    for i, itm in enumerate(wv):
        dp[i+1, :itm[0]] = dp[i, :itm[0]]
        dp[i+1, itm[0]:] = np.max([dp[i, itm[0]:], dp[i, :w-itm[0]+1] + itm[1]], axis=0)

    print(int(dp[n, w]))


if __name__ == "__main__":
    main()



Measured memory_bytes: 94668
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
from collections import *
S=input()
dp=[[0 for i in range(13)] for m in range(len(S))]
mod=10**9+7
if S[0]=="?":
    for i in range(10):
        dp[0][i]+=1
else:
    dp[0][int(S[0])]+=1
for i in range(1,len(S)):
    for m in range(13):
        if S[i]=="?":
            for j in range(10):
                dp[i][(m*10+j)%13]+=dp[i-1][m]
        else:
            dp[i][(m*10+int(S[i]))%13]+=dp[i-1][m]
    for m in range(13):
        dp[i][m]%=mod
#print(dp)
print(dp[-1][5]%mod)


Measured memory_bytes: 66268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll pl(ll a, ll b) {
    a %= mod, b %= mod;
    return (a+b) % mod;
}
ll mu(ll a, ll b) {
    a %= mod, b %= mod;
    return (a*b) % mod;
}
ll pow_mod(ll a, ll b) {
    if (b == 0) return 1;
    a %= mod;
    ll k = pow_mod(a, b/2);
    k = mu(k, k);
    if (b & 1) k = mu(k, a);
    return k;
}
ll di(ll a, ll b) {
    a %= mod;
    return mu(a, pow_mod(b, mod-2));
}
ll nCk(ll n, ll k) {
    ll res = 1;
    for (int a = n, b = k; b > 0; a--, b--) {
        res = mu(res, a);
        res = di(res, b);
    }
    return res;
}
int main () {
    ll A[2], K;
    cin >> A[0] >> A[1] >> K;
    ll ans = 0;
    for (int k = 0; k < 2; k++) {
        ll p = A[0], q = A[1];
        for (int i = 1; i <= q-1; i++) {
            ans += mu(mu(mu(p, p), q-i), i);
        }
        swap(A[0], A[1]);
    }
    ans = di(ans, nCk(A[0]*A[1], 2));
    ans = mu(ans, nCk(A[0]*A[1], K));
    ans = mu(ans, nCk(K, 2));
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    auto s = split(readln());
    string res1,res2;
    int c = 0;
    foreach(i ; s){
	int count = -1;
	foreach(j ; s){
	    if(i == j)count++;
	}
	if(c < count) {
	 res1 = i;
	 c = count;
	}
	if(i.length > res2.length) res2 = i;
    }
    writef("%s %s\n",res1,res2);
}

Measured memory_bytes: 2440
n, m =map(int, input().split())

par=[-1]*n

def find(x):
    if par[x]<0: return x
    par[x] = find(par[x])
    return par[x]

def union(x, y):
    p,q=find(x),find(y)
    if p==q: return
    if p>q: p,q=q,p
    par[p] += par[q]
    par[q] = p

def size(x):
    return -par[find(x)]

def same(x,y):
    return find(x)==find(y)

bridge=[0]*m
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    bridge[m-i-1]=(a,b)

sm=(n*(n-1))//2
ans=[0]*m
for i in range(m):
    ans[m-1-i]=sm
    a, b  = bridge[i][0], bridge[i][1]
    p,q=find(a),find(b)
    if p!=q:
        sm -= size(p)*size(q)
    union(a,b)

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

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

#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;

int main(){
    long long  n; cin >> n;
    long long min = 1000000000000;

    for(long long i = 1;i*i <= n; ++i){
        if(n%i != 0) continue;
        long long j  = n/i;
        if(i+j-2 < min) min = i+j-2;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int a[92][92] = {0};
int m;
int n;

int kansu( int x, int y, int c, int s ) {
	a[x][y] = 0;
	s = max( s, c );
	if ( a[x+1][y] == 1 ) {
		s = kansu( x+1, y, c+1, s );
	}
	if ( a[x-1][y] == 1 ) {
		s = kansu( x-1, y, c+1, s );
	}
	if ( a[x][y+1] == 1 ) {
		s = kansu( x, y+1, c+1, s );
	}
	if ( a[x][y-1] == 1 ) {
		s = kansu( x, y-1, c+1, s );
	}
	a[x][y] = 1;
	return s;
}

int main(){
	while(true) {
		cin >> m >> n;
		if ( m == 0 ) break;
		for ( int i = 0; i < n+2; i++ ) {
			for ( int j = 0; j < m+2; j++ ) {
				if ( i == 0 || i == n+1 || j == 0 || j == m+1 ) {
					a[j][i]=0;
				}else {
					cin >> a[j][i];
				}
			}
		}
		int s = 0;
		for ( int i = 1; i < n+1; i++ ) {
			for ( int j = 1; j < m+1; j++ ) {
				if ( a[j][i]==1 ) s = max( s, kansu( j, i, 1, s ) );
			}
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main(){
	long N;
	vector<long> tp(5);
	cin >> N;
	int minTp = 0;
	for(int i = 0; i < 5; i++){
		cin >> tp.at(i);
		if(tp.at(i) <= tp.at(minTp))
			minTp = i;
	}
	long t = N/tp.at(minTp)+4;
	if(N%tp.at(minTp))
		t++;
	
	cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,0,-1,1,-1,-1,1,2,0,-2,0};
const int dy[]={0,1,-1,0,1,1,-1,-1,0,2,0,-2};
const int INF = 1<<30;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
int main(){
	int N,Q;
	while(scanf("%d%d",&N,&Q),(N|Q)){
		int s[128]={0};
		int length = 0;
		rep(i,N){
			int c;
			scanf("%d",&c);
			rep(j,c){
				int t;
				scanf("%d",&t);
				s[t]++;
				length = max(length,t);
			}
		}
		length++;
		int ans = 0;
		int index = 0;
		rep(i,length){
			if(s[i]>=Q && ans < s[i]){
				ans = s[i];
				index = i;
			}
		}
		printf("%d\n",index);
	}
	return 0;
}

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

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

using namespace std;

int main(){
	string s,t; cin>>s>>t;
	if(s.length()+1==t.length()){
		t.pop_back();
		puts(s==t?"Yes":"No");
	}
	else{
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.ArrayList;

public class Main {

  public static void main(String[] args) throws IOException {
	  Scanner in = new Scanner(System.in);
	  int a = in.nextInt();
      int b = in.nextInt();
      int c = in.nextInt();
      int k = in.nextInt();
      int sum = Math.min(a, k);
      if(a<k) {
    	  k-=a;
    	  if(b<k) {
    		  k-=b;
    		  sum -= k;
    	  }
      }
      System.out.print(sum);
  }
}

Measured memory_bytes: 35728
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	char c; cin >> c;
	if (c >= 'a' && c <= 'z') { cout << 'a' << endl; }
	else { cout << 'A' << endl; }

	return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  int A[N], odd[N/2], sorted[N];
  rep(i, N) {
    in(A[i]);
    sorted[i] = A[i];
    if (i % 2 == 1)
      odd[i / 2] = A[i];
  }

  sort(sorted, sorted + N);
  sort(odd, odd + N/2);

  int count = 0;
  rep(i, N) {
    if ((binary_search(odd, odd + N/2, sorted[i])) == (i % 2 == 1))
      continue;
    ++count;
  }
  out(count/2);

  return 0;
}


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

template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
if (!v.empty()) {
    out << '[';
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, l;
    cin >> n >> l;
    vector<string> ss(n);
    for(int i = 0; i < n; i++){
        cin >> ss[i];
    }
    //cout << ss << endl;
    sort(ss.begin(), ss.end());
    string ans = "";
    for(int i = 0; i < n; i++){
        ans += ss[i];
    }
    cout << ans << endl;
    return 0;
}

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

lst=[0]*87
def lucas(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    elif lst[n]:
        return lst[n]
    else:
        lst[n]=lucas(n-1)+lucas(n-2)
        return lucas(n-1)+lucas(n-2)


print(lucas(N))

Measured memory_bytes: 3060
import Control.Monad
import Data.Char
import Data.List
import Data.Maybe

main = sol <$> getN <*> getD >>= print

getN = fmap read . words <$> getLine :: IO [Int]

getD = filter isDigit <$> getLine

sol (n:_) ds = fromJust $ find (null . intersect ds . show) [n..]

Measured memory_bytes: 1020
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
d = 0
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    d += C[A[i]-1]
print(sum(B)+d)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int,int> pii;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;


void bin(int n){
    string ans;
    while(n){
        ans = to_string(n%2) + ans;
        n/=2;
    }
    cout << ans << endl;
}


int mod2[2][200001];

void init(int minus,int plus){
    int vm = 1;
    int vp = 1;
    
    if(minus) mod2[0][0] = 1%minus;
    mod2[1][0] = 1%plus;
    
    for(int i = 1; i < 200001; i++){
        if(minus)vm *=2;
        vp *=2;
        if(minus) vm%=minus;
        vp%= plus;
        mod2[0][i] = vm;
        mod2[1][i] = vp;
    }
}


int subsolve(int n, int c){
    while(n){
        n %= __builtin_popcount(n);
        c++;
    }
    return c;
}
void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ones  = 0;
    for(auto e:s){
        if (e=='1') ones++;
    }
    
    int plus = ones+1;
    int minus = ones-1;
    
    init(minus,plus);

    int vm = 0;
    int vp = 0;
    
    for(int i = 0; i < n; i++){
        if (s[n-1-i] == '1'){
            vm += mod2[0][i];
            vp += mod2[1][i];
            if(minus) vm%= minus;
            vp%= plus;
        }
    }
    

    for(int i = 0; i < n; i++){
        
        if (s[i] == '0'){
            int temp = vp;
            temp += mod2[1][n-1-i];
            temp%=plus;
            int ans = subsolve(temp,1);
            cout << ans << endl;
            
        }
        else{
            int temp = vm;
            temp -= mod2[0][n-1-i];
            if (minus == 0){
                cout << 0 << endl;
                continue;
            }
            temp %= minus;
            temp = (temp + minus)%minus;
            int ans = subsolve(temp,1);
            cout << ans << endl;
            
        }
    }
}

int main(){
    int T;
    T = 1;
    //cin >> T;
    while(T--){
        solve();
        cout << endl;
    }
}






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

using int64 = long long;

int64 comb_[55][55];
int64 Comb(int64 n, int64 r) {
  if (comb_[n][r])
    return comb_[n][r];
  if (n == r || r == 0)
    return comb_[n][r] = 1;
  return comb_[n][r] = Comb(n - 1, r) + Comb(n - 1, r - 1);
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<int64> v(N);
  for (int i = 0; i < N; ++i)
    cin >> v[i];
  sort(v.begin(), v.end());

  double average = 0;
  for (int i = N - 1; i >= N - A; --i)
    average += v[i];
  average /= A;
  cout << fixed << setprecision(10) << average << "\n";

  int even = lower_bound(v.begin(), v.end(), v[N - A]) - v.begin();
  int above = upper_bound(v.begin(), v.end(), v[N - A]) - v.begin();
  even = above - even;
  above = N - above;

  int64 ret = 0;
  if (v[N - A] == v[N - 1]) {
    for (int r = A; r <= B && r <= even; ++r)
      ret += Comb(even, r);
  } else {
    ret = Comb(even, A - above);
  }
  cout << ret << "\n";

  return 0;
}


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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =998244353;
const int N = 1e6+7;



int main()
{
    ll n,k;
    lscf(n);lscf(k);

    vector<ll>v;
    map<ll,ll>m;

    rep(i,0,k)
    {
        ll l,r;
        lscf(l);lscf(r);
        
        rep(j,l,r+1)
        {
            if(m[j]==0)
            {   
                v.pb(j);
                m[j]++;
            }
        }
    }

    sort(all(v));

    vector<pair<int,int>>range;
    int l,r;
    l=v[0];

    rep(i,0,v.size()-1)
    {
        if(v[i+1]-v[i]>1)
        {
            r=v[i];
            range.pb({l,r});
            l=v[i+1];
        }
    }
    r=v[v.size()-1];
    range.pb({l,r});
    

    ll dp[n+1]={0};

    dp[1]=1;
    
    ll temp[n+1]={0};

    ll sum=0;

    rep(i,1,n)
    {
        rep(j,0,range.size())
        {
            if(i+range[j].F<=n)
            temp[i+range[j].F]=(temp[i+range[j].F]+dp[i])%M;
            if(i+range[j].S+1<=n)
            temp[i+range[j].S+1]=(temp[i+range[j].S+1]-dp[i]+M)%M;
        }

        sum=(sum+temp[i+1])%M;
        dp[i+1]=sum;
    }
    

    lprin(dp[n]);
return 0;
}

Measured memory_bytes: 20440
pattern = list(input())
failure_counter = False

for x in range(len(pattern)):
  if (x + 1) % 2 == 0:
    ## 偶数番目にRがあっちゃだめ
    if pattern[x] == "R":
      failure_counter = True
  else:
    ## 奇数番目にLがあっちゃだめ
    if pattern[x] == "L":
      failure_counter = True
if failure_counter:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, n-1):
    #print("p[{}], p[{}], p[{}] = {}, {}, {}".format(i-1, i, i+1, p[i-1], p[i], p[i+1]))
    if min([p[i-1], p[i], p[i+1]]) < p[i] < max([p[i-1], p[i], p[i+1]]):
        count += 1

print(count)

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,j,k,n;
	cin>>n>>k;
	vector<intl> ar(n);
	for(i=0;i<n;i++){
		cin>>ar[i];
	}
	intl sum=0;
	sort(ar.begin(),ar.end());
	for(i=0;i<k;i++){
		sum+=ar[i];
	}
	cout<<sum<<"\n";
}


Measured memory_bytes: 3664
#include <cstdio>
#include <algorithm>

using namespace std;

int l;
int a, b, c, d;
int taken;
int ans;

int main() {
    scanf("%d", &l);
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);

    taken = max(a/c + (a%c != 0), b/d + (b%d != 0));
    ans = max(0, l-taken);
    printf("%d\n", ans);
}

Measured memory_bytes: 1024
H, W, K = map(int, input().split())
c = []
for _ in range(H):
  c.append(input())

ans = 0  
for h in range(2 ** H):
  for w in range(2 ** W):
    b = 0
    for i in range(H):
      for j in range(W):
        if (h >> i) & 1 == 0 and (w >> j) & 1 ==0:
          if c[i][j] == '#':
            b += 1
    if b == K:
      ans += 1
print(ans)

Measured memory_bytes: 9184
s = input()
K = int(input())
str_len = len(s)
substrings = []

def get_substrings(substr_len):
    if substr_len == K + 1:
        return
    else:
        for i in range(0, str_len + 1 - substr_len):
            sub_s = s[i:i+substr_len]
            if not(sub_s in substrings):
                substrings.append(sub_s)
        get_substrings(substr_len + 1)

get_substrings(1)
substrings.sort()

print(substrings[K - 1])

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    vector<ll> a(3);
    cin >> a[0] >> a[1] >> a[2];
    if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0){
        cout << 0 << endl;
        return 0;
    }

    sort(a.begin(),a.end());
    cout << a[0]*a[1] << endl;

    return 0;
}

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

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#define fi first
#define se second
#define pb push_back
#define last(s) (s)[(s).size()-1]
#define all(a) (a).begin(),(a).end()
#define elif else if
#define left asdasd
#define next zaza
#define prev azaz
#define cclear cout<<flush;
#define x0 kerker
#define time chas
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define files freopen("little.in", "r", stdin);freopen("little.out", "w", stdout);

using namespace std;

using llong = long long;
using ld = long double;
using itn = int;
using ii = pair<int,int>;\
using ull = unsigned long long;
using pll = pair<llong, llong>;
using psi = pair<string, int>;
using ll = pair<llong, llong>;

const llong over999 = 1e9;
const ld over999ld = 1e18+1;
const llong md = 1e9+7;
const ld eps = 1e-9;
const ld Pi = acos(-1);
const llong nich = 0;
const llong mnogo = 300;

/**/
llong n, k, ans, t[1000010];

int check(llong x){
    int res = 0;
    cout << x << endl;
    for(llong i = 1; i * i <= x; i++){
        if(x % i < k && x % ((x/i) + (x %i>0)) < k)continue;
        // res += (i >= k);
        // res += (x/i >= k);
        // cout << x << " " << i << endl;
        res += (x % i >= k) + (x % ((x/i) + (x %i>0)) >= k);
    }
    return res;
}

int32_t main() {
    kchay;
    
    cin >> n >> k;
    // ans = (n-k)*(n-k+1)/2;
    
    for(int i = k + 1; i <= n; i++){
        for(int j = i; j-i <= n; j += i){
            t[j]--;
            t[j-i+k]++;
        }
    }
    
    for(int i = 1; i <= n; i++){
        t[i] += t[i-1];
        ans += t[i];
    }
    
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
D, X = map(int, input().split())

eat = 0
for _ in range(1, N+1):
  a = int(input())
  for i in range(D + 10):
    if (i * a) + 1 <= D:
      eat += 1
    else:
      break
print(eat + X)

Measured memory_bytes: 3060
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;
const int mod = 1e9+7;


struct mint {
  long long x; // typedef long long long long;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


mint modpow(long long N, long long P) {
  if (P == 0)
    return 1;
  if (P % 2 == 0) {
    mint t = modpow(N, P / 2);
    return t * t;
  }
  mint t = modpow(N, P - 1);
  t *= N;
  return t;
}


mint choose(int n, int a) {
    mint x = 1, y = 1;
    for (int i=0; i<a; i++) {
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}


int main() {
    int n, a, b; cin >> n >> a >> b;
    mint ans = modpow(2, n) - 1;
    ans -= choose(n, a);
    ans -= choose(n, b);

    cout << ans.x << endl;
}


Measured memory_bytes: 888
using System;

public static class Program
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int minValue = 1 << 30;
		int ans = -(1 << 30);
		for (int i = 0; i < n; i++)
		{
			int a = int.Parse(Console.ReadLine());
			if (i >= 1)
			{
				ans = Math.Max(ans, a - minValue);
			}
			minValue = Math.Min(a, minValue);
		}
		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 9232
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let x: i64 = input();
    let a: Vec<i64> = (0..n).map(|_| input()).collect();

    let mut y = std::cmp::max(0, a[0] - x);
    let mut ans = y;
    for i in 1..n {
        let s = a[i - 1] - y + a[i];
        y = std::cmp::max(0, s - x);
        ans += y;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm> // next_permutationを使うため
#include <iomanip> // fixed << setprecision()を使うため

using namespace std;

class Town{
    private:
        int x, y;

    public:
        // コンストラクタ
        Town(const int arg_x, const int arg_y);
        int get_x();
        int get_y();
        double distance_between(Town t);
};
int factorial(int n);

int main() {
    int number_of_towns;
    vector<Town> towns;
    // 読み込み部
    cin >> number_of_towns;
    for(int i = 0; i < number_of_towns; i++) {
        int arg_x, arg_y;
        // 町iの座標を取得
        cin >> arg_x >> arg_y;
        // 町iのインスタンスを生成し、townsに格納
        towns.push_back(Town(arg_x, arg_y));
    }

    // 距離の計算部
    double total_length_of_routes;
    vector<int> order_to_visit(towns.size());
    for(int i = 0; i < towns.size(); i++) {
        order_to_visit[i] = i + 1;
    }
    // ある1つの経路の長さを求める
    do {
        for(int i = 0; i < towns.size() - 1; i++) {
            total_length_of_routes += towns[order_to_visit[i]-1].distance_between(towns[order_to_visit[i+1]-1]);
        }
    } while(next_permutation(order_to_visit.begin(), order_to_visit.end()));
    double total_routes = factorial(number_of_towns);
    cout << fixed << setprecision(10);
    cout << total_length_of_routes / total_routes << endl;

    return 0;
}

Town::Town(const int arg_x, const int arg_y) {
    x = arg_x;
    y = arg_y;
}

int Town::get_x() {
    return this->x;
}

int Town::get_y() {
    return this->y;
}

inline double Town::distance_between(Town t) {
    double distance;

    // 各座標の差の2乗を求める
    distance = pow(this->x-t.x, 2) + pow(this->y-t.y, 2);
    // 上で求めたものの平方根を取る
    distance = sqrt(distance);

    return distance;
}

int factorial(int n) {
    if(n == 1) {
        return 1;
    } else {
        return n * factorial(n-1);;
    }
}

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

int INF = 1001001001;
const int MAX_V = 15;
int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V = 10;

void dijkstra(int s) {
    fill(d, d + V, INF);
    fill(used, used + V, false);
    d[s] = 0;

    while (true) {
        int v = -1;
        for (int u = 0; u < V; u++) {
            if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
        }
        if (v == -1) break;
        used[v] = true;
        for (int u = 0; u < V; u++) {
            d[u] = min(d[u], d[v] + cost[v][u]);
        }
    }
}

int main() {
    int h, w;
    cin >> h >> w;
    rep(i,V) rep(j,V) cin >> cost[j][i];  // [i][j]じゃなくて[j][i]にすることで単一始点最短経路から単一終点最短経路になる
    int a[h][w];
    rep(i,h) rep(j,w) cin >> a[i][j];
    int64_t ans = 0;
    dijkstra(1);
    rep(i,h) {
        rep(j,w) {
            if (a[i][j] == -1) continue;
            ans += d[a[i][j]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

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

  scanf("%d %d %d",&a,&b,&c);

  if(a == b)
    if(b == c)
      printf("1\n");

  if(a == b)
    if(b != c)
      printf("2\n");

  if(a != b)
    if(b == c)
      printf("2\n");

  if(a == c)
    if(a != b)
      printf("2\n");

  if(a != b)
    if(b != c)
      if(a != c)
        printf("3\n");

  return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

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

	vector<p> A(N);
	ll C, R, S, T;

	rep(i, N){
		cin >> C >> R;
		S = C - R;
		T = C + R;
		A[i].first = T;
		A[i].second = S;
	}

	sort(A.begin(), A.end());

	ll tmp = -1e9, ans = 0;

	rep(i, N) {
		if (tmp <= A[i].second) {
			ans++;
			tmp = A[i].first;
		}
	}

	cout << ans;

	return 0;
}


ll gcd(ll a, ll b) {
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
#define fixed thgrerde
#define f(i,f, t)  for(int i = f; i <  t; i++)
#define fr(i,f, t) for(int i = f; i >= t; i--)

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

const int infint = INT_MAX;
const ll infll   = LLONG_MAX;
int sum[2][100];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    memset(sum, 0, sizeof(sum));
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            cin >> sum[i][j];
        }
    }
    for(int i = 0; i < 2; i++){
        for(int j = 1; j < n; j++){
            sum[i][j] += sum[i][j-1];
        }
//        cout << "\n";

    }
    for(int i = 0; i < 2; i++){
        for(int j = 1; j < n; j++){
           // cout << sum[i][j] << " ";
        }
        //cout << "\n";

    }
    int mx = 0;
    int thefuck = sum[0][3] + sum[1][4];
    //cout << sum[0][3] << " " << sum[1][4]<< " ???";
    //return 0;
    for(int i = 0; i < n; i++){
        if(i == 0){
            mx = sum[0][0] + sum[1][n - 1];
        }else{
            mx = max(mx, sum[0][i] + sum[1][n-1] - sum[1][i - 1]);
        }
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	if scanner.Scan() {
		s := scanner.Text()

		if len(s) != 3 {
			fmt.Print(s)
		} else {
			fmt.Print(string(s[2]), string(s[1]), string(s[0]))
		}
	} else {
		panic(1)
	}
}


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

using namespace std;

#define ll long long
#define endl "\n"
#define rep(i, n) for(__typeof(n) i = 0; i < n; i++)
#define per(i, n) for(__typeof(n) i = n - 1; i >= 0; i--)
#define loop(i, a, b) for(__typeof(a) i = a; i <= b; i++)
#define set(a, val) memset(a, val, sizeof(a))
#define f first
#define s second
#define all(x) x.begin(), x.end()

const int mod = 1000000007;


int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    cout << min(c, b/a) << endl;
}


Measured memory_bytes: 256
in1 = input()
in2 = input()
res = True

if len(in1) < 1 or len(in1) > 10 :
    res = False

if in1.islower() and in1.isalpha() :
    pass
else :
    res = False


if in2.islower() and in2.isalpha():
    if in1 in in2[:len(in2)-1] :
        if len(in2) - len(in1) == 1 :
            pass
        else :
            res = False
    else :
        res = False
else :
    res = False

if res :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 9136
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) break;
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					if(i == 0 || j == 0 || i == H-1 || j == W-1) System.out.print("#");
					else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 36960
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	for h := 1; h <= 3500; h++ {
		for n := 1; n <= 3500; n++ {
			if 4*h*n-N*h-N*n <= 0 {
				continue
			}
			if N*h*n%(4*h*n-N*h-N*n) == 0 {
				fmt.Println(h, n, N*h*n/(4*h*n-N*h-N*n))
				return
			}
		}
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>u,v,w;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n;
    k=0;
    for(i=1;i<=n;i++)
    {
        cin>>o;
        if(i%2==1){v.PSB(o);}
        if(i%2==0){u.PSB(o);}
    }
    if(n%2==0)
    {
        for(i=u.SZ-1;i>=0;i--)
        {
            cout<<u[i]<<" ";
        }
        for(i=0;i<v.SZ;i++)
        {
            cout<<v[i]<<" ";
        }
    }
    else
    {
       for(i=v.SZ-1;i>=0;i--)
        {
            cout<<v[i]<<" ";
        }
        for(i=0;i<u.SZ;i++)
        {
            cout<<u[i]<<" ";
        }
    }
    cout<<endl;



    return 0;

}


Measured memory_bytes: 3948
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
int abs(int x)
{
    return x >= 0 ? x : -x;
}
//------------------------------------------------------------------------------
void _main()
{
    int H, W, D;
    cin >> H >> W >> D;
    vector<pair<int, int>> coords(H * W + 1);
    int A;
    rep(r, 0, H) rep(c, 0, W)
    {
        cin >> A;
        coords[A] = make_pair(r, c);
    }

    vector<ll> dist(H * W + 1);
    for (int i = 1; i <= D; ++i)
    {
        dist[i] = 0;

        for (int j = 1; i + D * j <= H * W; ++j)
        {
            const int from = i + D * (j - 1);
            const int to = i + D * j;
            dist[to] = dist[from] + abs(coords[to].first - coords[from].first) + abs(coords[to].second - coords[from].second);
        }
    }

    int Q;
    cin >> Q;
    int L, R;
    rep(i, 0, Q)
    {
        cin >> L >> R;
        cout << dist[R] - dist[L] << endl;
    }
}


Measured memory_bytes: 2560
import java.util.*;

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();
        int d = sc.nextInt();

        int rectangle01 = a * b;
        int rectangle02 = c * d;

        if (rectangle01 < rectangle02) {
            System.out.println(rectangle02);
        } else {
            System.out.println(rectangle01);            
        }
    }
}


Measured memory_bytes: 22612
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let n=t.n()
  let a=t.n(n)
  let ans=0
  for(let i=1;i<n-1;i++)if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))ans++
  t.o(ans)
}
main()


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

namespace BGreateOceanView
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var n = int.Parse(Console.ReadLine());
            var heights = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int maxHeight = 0, oceanViews = 0;
            foreach (var height in heights)
            {
                if (maxHeight <= height)
                {
                    maxHeight = height;
                    oceanViews++;
                }
            }

            // 解答の出力
            Console.WriteLine(oceanViews);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int dp[n];
    dp[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) {
        dp[i] = INT64_MAX;
        for (int j = i + 1; j < min(i + k + 1, n); j++) {
            dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
        }
    }
    cout << dp[0] << "\n";
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

A, B, M = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

ans = min(As) + min(Bs)
for m in range(M):
    x, y, c = map(int, input().split())
    tmp = As[x - 1] + Bs[y - 1] - c
    ans = min(ans, tmp)
print(ans)



Measured memory_bytes: 20972
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

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

typedef pair<string, int> P;

bool cmp(P &a, P &b){
  return a.first < b.first || a.first == b.first && a.second > b.second;
}

int main(){
  int N;
  cin >> N;
  vector<P> SP(N);
  rep(i,N) cin >> SP[i].first >> SP[i].second;
  vector<P> CSP = SP;
  sort(CSP.begin(), CSP.end(), cmp);
  rep(i,N) {
    rep(j,N){
      if (CSP[i] == SP[j]) {
        cout << j+1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  if(S.substr(0, 4) == "YAKI")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    N = ii()
    sa,sb,sc = 0,0,0
    for _ in range(N):
        a,b,c=mis()
        nsa = max(sb,sc)+a
        nsb = max(sc,sa)+b
        nsc = max(sa,sb)+c
        sa,sb,sc = nsa,nsb,nsc
    print(max(sa,sb,sc))

main()


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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N; cin >> N;
    pair<int, int> job[N];
    rep(i, N){
        int a, b; cin >> a >> b;
        job[i] = make_pair(b, a);
    }
    sort(job, job+N);
    int tm = 0;
    rep(i, N){
        tm += job[i].second;
        if(tm > job[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

void solve(){}

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

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

ll mod_inv(ll a, ll md = 1e9 + 7) {
	ll b = md, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= md;
	if (u < 0) u += md;
	return u;
}

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

  LL N, K;
  cin >> N >> K;
  vector<vector<LL>> graph(N, vector<LL>(0));

  // vector<LL> fact(200000, 1);
  // vector<LL> factinv(200000, 1);
  
  // FOR(i,1,200000){
  //   fact[i] = fact[i - 1] * i;
  //   fact[i] %= mod;
  //   factinv[i] = mod_inv(fact[i]);
  // }
  // fact[0] = 0;
  // factinv[0] = 0;

  vector<LL> hoge(200000, 1);
  
  FOR(i,1,200000){
    hoge[i] = (K - i - 1) * hoge[i - 1];
    hoge[i] %= mod;
  }

  REP(i,N-1){
    LL a, b;
    cin >> a >> b;
    a--;
    b--;

    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  vector<bool> visit(N, false);

  visit[0] = true;
  
  queue<LL> q;
  LL num = 1;
  
  REP(i,graph[0].size() + 1){
    num *= K - i;
    num %= mod;
  }
  
  REP(i,graph[0].size()){
    q.push(graph[0][i]);
    visit[graph[0][i]] = true;
  }

  while(!q.empty()){
    LL idx = q.front();
    q.pop();

    num *= hoge[graph[idx].size() - 1];
    num %= mod;

    REP(i,graph[idx].size()){
      if(!visit[graph[idx][i]]){
        q.push(graph[idx][i]);
        visit[graph[idx][i]] = true;
      }
    }
  }

  cout << num << endl;
}


Measured memory_bytes: 8948
def is753(num):
    d = str(num)
    if d.count("3") > 0 and d.count("5") > 0 and d.count("7") > 0:
        return(True)
    else:
        return(False)

def loop753(N, num):
    global counter
    if num <= N:
        if is753(num):
            counter += 1
    else:
        return

    loop753(N, num * 10 + 3)
    loop753(N, num * 10 + 5)
    loop753(N, num * 10 + 7)

counter = 0
NN = int(input())
loop753(NN, 0)
print(counter)

Measured memory_bytes: 3064