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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    cout << setprecision(20);
    ll x, y;
    cin >> x >> y;

    ll s = 0;
    if(x<=3) s += 400000 - x*100000;
    if(y<=3) s += 400000 - y*100000;
    if(x==1&&y==1) s += 400000;

    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int n, h[1000];
    cin >> n;
    for(Int i=0; i<n; i++){
        cin >> h[i];
    }
    Int sum = 1;
    Int marker = h[0];
    for(Int i=1; i<n; i++){
        if(h[i] >= marker){
            sum++;
        }
        marker = h[i] > marker ? h[i] : marker;
    }
    cout << sum << endl;

    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<char>> A(200, vector<char>(200));
  vector<vector<char>> B(M, vector<char>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) cin >> A[i][j];
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) cin >> B[i][j];
  }
  
  bool can = false;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[i][j] != B[0][0]) continue;
      bool can2 = true;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (A[i+k][j+l] != B[k][l]) can2 = false;
        }
      }
      if (can2) can = true;
    }
  }
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
const ll mo=1e9+7;
ll a[2005],cn[2005],cn1[2005];
ll go(ll a,ll b){
  ll re=1;
  while(b){
   if(b & 1) re*=a,re%=mo;
    a*=a,a%=mo;
    b/=2;
  }
  return re;
}
int main(){
  ll i,j,k,n,m,t;
  cin>>n>>k;
  for(i=1;i<=n;i++){
   cin>>a[i]; 
  }
  ll in2=go(2,mo-2);
  for(i=1;i<=n;i++){
   ll c=0;
    for(j=i+1;j<=n;j++){
      c+=(a[i]>a[j]); 
    }
    cn[i]=c;
    c=0;
    for(j=1;j<=n;j++){
     c+=(a[i]>a[j]); 
    }
    cn1[i]=c;
  }
  ll ans=0;
  for(i=1;i<=n;i++){
    ans=(ans+(cn[i]*k)%mo)%mo;
    ll cv=(((k*(k-1))%mo)*in2)%mo;
    ans=(ans+(cv*cn1[i])%mo)%mo;
  }
  cout<<ans<<"\n";
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Rep(i,j,n) for(int i=j; i<n; i++)
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    int ans=0;
    for(int i=1; i<n; i++){
        ans+=(n-1)/i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
line = input().split(" ")
n = int(line[0])
x = int(line[1])
a = [int(n) for n in input().split(" ")]

ret = max(0,a[0]-x)
a[0] = min(a[0],x)
for i in range(1,n):
    if a[i-1]+a[i]>x:
        r = (a[i-1]+a[i])-x
        if a[i]>=r:
            a[i] -= r
        else:
            a[i-1] -= (r-a[i])
            a[i] = 0
        ret += r

print(ret)
# print(a)


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

int main(){

  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;

  if(x>=r && x<=W-r && y>=r && y<=H-r){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

struct Card { char suit, value; };

void bubble ( struct Card A[], int N ) { 
    for ( int i = 0; i < N; i++ ) {
        for ( int j = N-1; j > i; j-- ) {
            if ( A[j].value < A[j-1].value){
                struct Card t = A[j];
                A[j] = A[j-1];
                A[j-1] = t;
            }
        }
    }
}



void section ( struct Card A[], int N ) {
    for ( int i = 0; i < N; i++ ) {
        int minj = i;
        for ( int j = i+1; j < N; j++ ) {
            if ( A[j].value < A[minj].value )
                minj = j;
        }
        struct Card t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}






bool isStable ( struct Card A1[], struct Card A2[], int N ) {
    for ( int i = 0; i < N; i++ ) {
        if ( A1[i].suit != A2[i].suit )
            return false;
    
    }
    return true;
}



int main () {
    int i, N;
    struct Card A1[100], A2[100];
    
    cin >> N;
    for ( i = 0; i < N; i++ ) {
        cin >> A1[i].suit >> A1[i].value;
    }
    for ( i = 0; i < N; i++ )
        A2[i] = A1[i];

    

    bubble(A1, N);
    section(A2, N);

    for ( i = 0; i < N; i++ ) {
        if ( i != 0) cout << " ";
        cout << A1[i].suit << A1[i].value;
    }

    cout << endl;
    cout << "Stable" << endl;

    for ( i = 0; i < N; i++ ) {
        if ( i != 0 ) cout << " ";
        cout << A2[i].suit << A2[i].value;
    }
    cout << endl;
    if ( isStable(A1, A2, N) )
        cout << "Stable" << endl;
    else 
        cout << "Not stable" << endl;

   return 0;


}












Measured memory_bytes: 3112
#!/usr/bin/env python3

n = int(input())
ans = [0] * (n+1)
m = int(n**(1/2)) + 1
for x in range(1, m):
    for y in range(1, m):
        for z in range(1, m):
            res = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if res <= n:
                ans[res] += 1
for i in ans[1:]:
    print(i)

Measured memory_bytes: 75100
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        if (a.substring(a.length()-1).equals(b.substring(0, 1)) && (b.substring(b.length()-1).equals(c.substring(0, 1)))) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>

int main() {
    int s;
    cin >> s;
    int a = s;
    int i =0;
    vector<int> x(10000000);
    int ans =0 ;
    bool flag = false;
    while(!flag){
        x[i] = a;
        if (a % 2 == 0){
            a = a/2;
        }
        else{
            a = 3*a+1;
        }
        i++;
        for(int j=0;j<i;j++){
            if(x[j] == a){
                flag = true;
            }
        }
    }
    
    cout << i+1 << endl;

} 


Measured memory_bytes: 39296
#include<bits/stdc++.h>
using namespace std;
main(){
	string str;
	cin>>str;
	int k;
	cin>>k;
	int ans = 1;
	for(int i=0;i<k;i++){
		//cout<<str[i]-'0'<<" ";
		if(str[i] - '0' != 1){
			ans = str[i] - '0';
			break;
			
		}
	}
	cout<<ans;
}

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

class P
{
    static void Main()
    {
        Console.WriteLine(Console.ReadLine().Split().Select(x => int.Parse(x)).Aggregate((x, y) => x * y) % 2 == 0 ? "Even":"Odd");
    }
}


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

template<int MOD> struct modint{
    int val;
    constexpr modint(int v): val(v % MOD){
        if(val < 0) val += MOD;
    }
    constexpr int getmod(){
        return MOD;
    }
    constexpr modint operator-(){
        return val? MOD - val : 0; 
    }

    constexpr modint operator+(const modint& r){
        return modint(*this) += r;
    }
    constexpr modint operator-(const modint& r){
        return modint(*this) -= r;
    }
    constexpr modint operator*(const modint& r){
        return modint(*this) *= r;
    }
    constexpr modint operator/(const modint& r){
        return modint(*this) /= r;
    }


    constexpr modint& operator+=(const modint &r){
        val += r.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    constexpr modint& operator-=(const modint& r){
        val -= r.val;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr modint& operator*=(const modint& r){
        val = (val * r.val) % MOD;
        return *this;
    }
    constexpr modint& operator/=(const modint& r){
        // ax + bz = a, ay + bw = b からスタートして
        // 右辺について互除法して係数を変えていく
        // (x, y) -> (y, x-y*(a/b)), (z, w) -> (w, z-w*(a/b))
        // 最終的に ax + bz = gcd(a, b) となるので a, b が互いに素なら x が逆元
        // z と w を覚えておく必要はない
        int a = r.val, b = MOD, x = 1, y = 0;
        while(b){
            x -= y * (a/b); swap(x, y);
            a -= b * (a/b); swap(a, b);
        }
        val = (val * x) % MOD;
        if(val < 0) val += MOD;
        return *this;
    }

    constexpr bool operator==(const modint& r){
        return val == r.val;
    }
    constexpr bool operator!=(const modint& r){
        return val != r.val;
    }

    constexpr modint modpow(int e){
        modint ans = 1, n = *this;
        while(e){
            if(e & 1) ans *= n;
            n *= n;
            e /= 2;
        }
        return ans;
    }

    friend constexpr ostream& operator<<(ostream &os, const modint<MOD>& x){
        return os << x.val;
    }
};

const int MOD = 1000000007;
using mint = modint<MOD>;

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;

    cout << mint(10).modpow(n) - mint(9).modpow(n) * 2 + mint(8).modpow(n) << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const LL N = 1000000007;

LL n,m;

struct edge{
	LL u,v,w;
}s[2005]; LL in[2005] = {0};
bool cmp(edge x,edge y){
	return x.w < y.w;
}

LL pwr(LL x,LL y){
	LL ret = 1LL;
	while(y --) ret = (ret * x) % N; return ret;
}

LL ec = 0, to[8005],nxt[8005],hed[4005] = {0},we[8005],wv[4005];
void add_edge(LL f,LL t,LL cst){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec; we[ec] = cst;
}

LL ffa[4005];
LL getf(LL x){
	if(x == ffa[x]) return x;
	return ffa[x] = getf(ffa[x]);
}

LL kruscal(){
	LL ret = 0;
	for(LL i = 1;i <= n;i ++) ffa[i] = i;
	for(LL i = 1;i <= m;i ++){
		if(getf(s[i].u) == getf(s[i].v)) continue;
		ffa[getf(s[i].u)] = getf(s[i].v);
		ret += s[i].w; in[i] = 1;
		add_edge(s[i].u,s[i].v,s[i].w);
		add_edge(s[i].v,s[i].u,s[i].w);
	}
	return ret;
}

LL dep[4005] = {0},fa[4005] = {0};
void dfs(LL u,LL f){
	fa[u] = f;
	dep[u] = dep[f] + 1;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		wv[v] = we[i];
		dfs(v,u);
	}
}

LL path_max(LL x,LL y){
	LL ret = 0;
	if(dep[x] < dep[y]) swap(x,y);
	while(dep[x] > dep[y]){
		ret = max(ret,wv[x]);
		x = fa[x];
	}
	while(x != y){
		ret = max(ret,max(wv[x],wv[y]));
		x = fa[x]; y = fa[y];
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	LL k,mst,equ = 0,cnt = 0,ans;
	cin >> n >> m >> k;
	for(LL i = 1;i <= m;i ++) cin >> s[i].u >> s[i].v >> s[i].w;
	sort(s + 1,s + 1 + m,cmp); mst = kruscal();
	dfs(1,0);
	
	if(k < mst){
		cout << 0 << endl;
		return 0;
	}
	if(k == mst){
		equ = n - 2;
		for(LL i = 1;i <= m;i ++){
			if(in[i]) continue;
			LL val = s[i].w - path_max(s[i].u,s[i].v);
			if(mst + val == k) equ ++;
			if(mst + val > k) cnt ++;
		}
		ans = (((2LL * pwr(2LL,cnt)) % N) * (pwr(2LL,equ) + N - 1LL)) % N;
	}
	if(k > mst){
		for(LL i = 1;i <= m;i ++){
			if(in[i]) continue;
			LL val = s[i].w - path_max(s[i].u,s[i].v);
			if(mst + val == k) equ ++;
			if(mst + val > k) cnt ++;
//			cout << mst << ' ' << val << endl;
		}
//		cout << cnt << ' ' << equ << endl;
		ans = (((2LL * pwr(2LL,cnt)) % N) * (pwr(2LL,equ) + N - 1LL)) % N;
	}
//	if(!flg) ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.function.Function;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());

      Function<String,double[]> lineSpliteThenArray =
        s -> Stream.of(s.split(" "))
          .mapToDouble(Double::parseDouble)
          .toArray();

      double[][] vecter =
        br.lines()
          .limit(2)
          .map( lineSpliteThenArray )
          .toArray(double[][]::new);

      double p1 =
        IntStream.range(0, n)
          .mapToDouble(i -> Math.abs(vecter[0][i] - vecter[1][i]) )
          .sum();

      double p2 = Math.sqrt(
        IntStream.range(0, n)
          .mapToDouble(i -> Math.pow( vecter[0][i] - vecter[1][i], 2))
          .sum() );

      double p3 = Math.pow(
        IntStream.range(0, n)
        .mapToDouble(i -> Math.pow( Math.abs(vecter[0][i] - vecter[1][i]), 3d))
        .sum() , 1d/3d );

      double p00 =
        IntStream.range(0, n)
          .mapToDouble(i -> Math.abs(vecter[0][i] - vecter[1][i]))
          .max()
          .getAsDouble();

      System.out.printf("%.8f\n%.8f\n%.8f\n%.8f\n", p1,p2,p3,p00);
    }
  }

}


Measured memory_bytes: 32072
array_length = int(input())
array_sum = 0
fizzbuzz_list = [3,5,15]

for i in range(array_length):
    loop_num = i + 1
    flag = 0
    for n in fizzbuzz_list:
        if loop_num % n == 0:
            flag = 1
    if flag == 0:
        array_sum = array_sum + loop_num

print(array_sum)

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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 2e5 + 10, inf = 1e9;
struct node {
	int c, w, u;
	bool operator < (const node &z) const {
		return w > z.w;
	}
};
priority_queue<node> q;
vector<int> e[N];
map<int, vector<int> > E[N];
int n, m;
map<int, int> f[N];
void dijkstra() {
	while (!q.empty()) {
		node u = q.top(); q.pop();
		if (f[u.u][u.c] != u.w) continue;
		if (f[u.u][0] > u.w)
			f[u.u][0] = u.w,  q.push((node) {0, u.w, u.u});
		if (!u.c) {
			for (auto v : e[u.u])
				if (f[u.u][v] > u.w + 1)
					f[u.u][v] = u.w + 1, q.push((node) {v, u.w + 1, u.u});
		}
		else {
			for (auto v : E[u.u][u.c])
				if (f[v][u.c] > u.w) f[v][u.c] = u.w, q.push((node) {u.c, u.w, v});
		}
	}
	return ;
}
int main() {
	read(n), read(m);
	for (int i = 1, p, q, c; i <= m; i++) {
		read(p), read(q), read(c);
		e[p].push_back(c); e[q].push_back(c);
		E[p][c].push_back(q); E[q][c].push_back(p);
		f[p][c] = f[q][c] = inf;	
	}
	for (int i = 2; i <= n; i++) f[i][0] = inf;
	f[1][0] = 0;
	q.push((node) {0, 0, 1});
	dijkstra();
	int ans = inf;
	for (auto i : f[n]) ans = min(ans, i.second);
	printf("%d\n", ans > n ? -1 : ans);
	return 0;
}


Measured memory_bytes: 98288
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * \
                modinv[self.mod % i] % self.mod
        return modinv


def main():
    n, k = MI()

    if k == 1:
        print(n-k+1)
        return

    num_b = k
    num_r = n - k

    comb = Combination(max(num_r + 1, num_b - 1))

    ans = num_r + 1

    print(ans)
    for i in range(2, num_b + 1):
        if i > num_r + 1:
            print(0)
            continue
        ans = comb(num_r + 1, i) * comb(num_b - 1, i-1)
        ans %= 10**9 + 7
        print(ans)


main()


Measured memory_bytes: 74872
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i=a; i<b; i++)
typedef long double ld;
typedef complex<ld> pt;
#define LAR(a, b) ((a)=max((a), (b)))

int n;
pt p[305];

int cnt(pt c, int x, int y){
	int ret=0;
	REP(i, n){
		if(i==x || i == y) ret++;
		else ret+=(abs(c-p[i])<1);
	}
	return ret;
}

int main(){
	while(scanf("%d", &n), n){
		REP(i, n){
			ld x, y; scanf("%Lf%Lf", &x, &y);
			p[i]=pt(x, y);
		}
		int ans=1;
		REP(i, n){
			FOR(j, i+1, n){
				if(abs(p[i]-p[j])>2) continue;
				pt r = (p[j]-p[i])/2.0L;
				pt s = r * (pt)1il;
				s *= sqrt(1 - abs(r)*abs(r)) / abs(s);
				LAR(ans, cnt(p[i]+r+s, i, j));
				LAR(ans, cnt(p[i]+r-s, i, j));
			}
		}
		printf("%d\n", ans);
	}
}




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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int H,W,K;
  cin>>H>>W>>K;
  vector<string>S(H);
  for(int i=0;i<H;i++)cin>>S[i];
  //分割してホワイトチョコレートをそれぞれKマス以下にする
  //9*999->だいたい10000通りの割り方
  //1024*10*1000
  int ans=INT_MAX;
  int bit=pow(2,H-1);
  for(int b=0;b<bit;b++){
    vector<vector<int>>a;
    vector<int>c(W);
    for(int i=0;i<=H;i++){
      if(i==H){
        a.push_back(c);
        continue;
      }
      if(i!=0&&(b>>(i-1)&1)){
        a.push_back(c);
        fill(rng(c),0);
      }
      for(int j=0;j<W;j++){
        if(S[i][j]=='1')c[j]++;
      }
    }
    int res=0;
    bool ok=true;
    vector<int>C(a.size(),0);
    for(int i=0;i<W;i++){
      bool ng=false;
      for(int j=0;j<a.size();j++){
        if(a[j][i]>K){
          ok=false;
          break;
        }
        if(C[j]+a[j][i]>K)ng=true;
      }
      if(ng){
        for(int j=0;j<a.size();j++)C[j]=a[j][i];
        res++;
        ng=false;
      }
      else{
        for(int j=0;j<a.size();j++)C[j]+=a[j][i];
      }
    }
    if(ok)ans=min(ans,res+__builtin_popcount(b));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
using namespace std;


set<int> v;
bool hai(int n){
	if(v.find(n)!=v.end()){
		return false;
	}
	return true;
}

bool valid(int n){
	while(n){
		if(!(hai(n%10))){
			return false;
		}
		n/=10;
	}
	return true;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	
	
	int n;cin>>n;
	cout<<(n*(n+1))/2<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

// K-Q+Ai>0なら生き残る

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K, Q;
  cin >> N >> K >> Q;
  int A[N+1];
  FOR(i,0,N+1) {
    A[i] = 0;
  }
  FOR(i,0,Q) {
    int a;
    cin >> a;
    A[a]++;
  }
  FOR(i,1,N+1) {
    cout << (K-Q+A[i]>0?"Yes":"No") << endl;
  }
  
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 2000000
int size,A[MAX+1];
void maxHeapify(int i){
  int l,r,largest,t;
  l=2*i;
  r=2*i+1;
  if(l<=size && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=size && A[r]>A[largest])largest=r;
  if(largest!=i){
    t=A[i]; A[i]=A[largest];A[largest]=t;
    maxHeapify(largest);      
  }
}

int main(){
  scanf("%d",&size);
  int i;
  for(i=1;i<=size;i++)scanf("%d",&A[i]);
  for(i=size/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=size;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
}



Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    int N;
    cin >> N;
    vector<int> D(N);
    REP(i, N) cin >> D[i];
    sort(ALL(D));
    D.erase(unique(ALL(D)), D.end());
    cout << D.size() << LF;
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
n = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
ans = 0

def calc_double(n):
    return n * 0.5

for i in range(10**9):
    for i in range(n):
        if a[i] <= 0 or a[i] % 2 == 1:
            print(ans)
            exit()
        else:
            pass
    a = list(map(calc_double, a))
    ans = ans + 1


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= 9; ++i){
        for(int j = 1; j <= 9; ++j){
            if(i * j == N){
                cout << "Yes" << endl;
              return 0;
            }
        }
    }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
d=list(map(int,input().split()))
c=list(input())

class dice(object):
	def __init__(self, d):
		self.d = d

	def roll(self,com):
		a1,a2,a3,a4,a5,a6=self.d
		if com=="E":
			self.d = [a4,a2,a1,a6,a5,a3]
		elif com=="W":
			self.d = [a3,a2,a6,a1,a5,a4]
		elif com=="S":
			self.d = [a5,a1,a3,a4,a6,a2]
		elif com=="N":
			self.d = [a2,a6,a3,a4,a1,a5]

dice1=dice(d)	
for com in c:
	dice1.roll(com)
print(dice1.d[0])

Measured memory_bytes: 7696
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 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; }

void solve(long long L, long long R, long long d){
    ll ans = 0;
    for(ll i = L; i <= R; i++){
        if(i % d == 0) ans ++;
    }
    cout<<ans<<endl;
}
int main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    long long d;
    scanf("%lld",&d);
    solve(L, R, d);
    return 0;
}


Measured memory_bytes: 3232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        int a = scanner.nextInt();
        final int b = scanner.nextInt();
        int c = scanner.nextInt();
        final int d = scanner.nextInt();

        while (true) {
            c -= b;
            if (c <= 0) {
                System.out.println("Yes");
                return;
            }

            a -= d;
            if (a <= 0) {
                System.out.println("No");
                return;
            }
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

signed main() {
    LCIN(N, A, B);
    cout << min(A * N, B) << "\n";
}


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

using namespace std;

int main()
{
     int h,w;
     cin>>h>>w;
     char gr[h][w];
     for(int i=0;i<h;i++)
     {
         for(int j=0;j<w;j++)
         {
             cin>>gr[i][j];
         }
     }
     long long int dp[h][w];
     int flag =0;
     for(int i=0;i<h;i++)
     {
         if(gr[i][0] =='#')
         {
             dp[i][0]=0;
             flag =1;
         }
         else if( flag ==0 && gr[i][0] =='.')
         {
             dp[i][0]=1;
         }
         else
         {
             dp[i][0]=0;
         }
     }
     flag =0;
      for(int i=0;i<w;i++)
     {
         if(gr[0][i] =='#')
         {
             dp[0][i]=0;
             flag =1;
         }
         else if(flag ==0 && gr[0][i]=='.')
         {
             dp[0][i]=1;
         }
         else
         {
             dp[0][i]=0;
         }
     }
     dp[1][1] =1;
     for(int i=1;i<h;i++)
     {
         for(int j=1;j<w;j++)
         {
             if(gr[i][j] == '#')
             {
                 dp[i][j]=0;
                 continue;
             }
             else
             {
                 dp[i][j]=dp[i-1][j] +dp[i][j-1];
                 dp[i][j] %=1000000007;
             }
         }
     }
   /*  for(int i=0;i<h;i++)
     {
         for(int j=0;j<w;j++)
         {
             cout<<dp[i][j]<<" ";
         }
         cout<<endl;
     }
*/
     cout<<dp[h-1][w-1];
}


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

int main(){
    using namespace std;

    unsigned long N;
    cin >> N;

    vector<unsigned long> A(N + 1);
    for(auto&& i : A)cin >> i;

    vector<unsigned long> down(N + 1), up(N + 1);

    down[0] = 1;
    for(unsigned long i{0}; i < N; ++i){
        if(down[i] <= A[i])return 0 & puts("-1");
        down[i + 1] = 2 * (down[i] - A[i]);
    }

    partial_sum(rbegin(A), rend(A), rbegin(up));

    if(down.back() < up.back())return 0 & puts("-1");

    unsigned long ans{0};
    for(unsigned long i{0}; i <= N; ++i)ans += min(down[i], up[i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5568
a=[int(input()) for _ in range(5)]
b=0
c=[10]
for i in range(5):
    if (b+a[i])%10==0:
        b+=a[i]
    else:
        b+=(a[i]//10+1)*10
for i in range(5):
    if a[i]%10!=0:
        c.append(a[i]%10)
print(b+min(c)-10)



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

using namespace std;
int main()
{
    long int x, r, q;
    double n = 1000000;
    cin >> x;
    if(x / 100 < 1){
        cout << 0 << endl;
        return 0;
    }
    r = x % 100;
    q = x / 100;
    for(int i=0;i<q;i++)
    {
        if(r == 0)
            break;
        if(r-5 >= 0)
            r-=5;
        else if(r-4 >= 0)
            r-=4;
        else if(r-3 >= 0)
            r-=3;
        else if(r-2 >= 0)
            r-=2;
        else if(r-1 >= 0)
            r-=1;
    }
    if(r == 0)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let (n, a, b): (usize, usize, usize) = (read(), read(), read());
    let s: Vec<char> = read::<String>().chars().collect();
    let mut count = 0;
    let mut fcnt = 0;
    for i in 0..n {
        let mut ok = false;
        if s[i] == 'a' {
            if count < a + b {
                count += 1;
                ok = true;
            }
        } else if s[i] == 'b' {
            fcnt += 1;
            if count < a + b && fcnt <= b {
                count += 1;
                ok = true;
            }
        }
        println!("{}", if ok { "Yes" } else { "No" });
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4732
#include <stdio.h>

int sum;
void a(int x,int y){
    if(x % y)
        return;
    sum++;
    a(x/y,y);
}

int main(void){
    int num;
    for(;sum=0,scanf("%d",&num),num;){
        while(num){
            a(num,5);
            num--;
        }
        printf("%d\n",sum);
    }
    return 0;
}

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

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;

#define pb push_back

const int N = 2e6;

int lp[N], a[N], g;
vector<int> p;
bool was[N];

bool factorize(int x, bool pairwise = 1) {
	vector<int> f;
	while (x > 1) {
		if (was[lp[x]]) pairwise = 0;
		f.pb(lp[x]);
		x /= lp[x];
	}
	for (auto x : f) was[x] = 1;
	return pairwise;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
   for (int i = 2; i < N; i++) {
   	if (lp[i] == 0) {
   		lp[i] = i;
   		p.pb(i);
   	}
   	for (int j = 0; j < p.size() && p[j] <= lp[i] && p[j] * i < N; j++)
   		lp[p[j] * i] = p[j];
   }
   int n;
   cin >> n;
   for (int i = 1; i <= n; i++) {
   	cin >> a[i];
   	g = __gcd(g, a[i]);
   }
   if (g != 1) cout << "not coprime", exit(0);
   factorize(a[n]);
   bool ok = 1;
   for (int i = n - 1; i; i--) { 
   	if (!factorize(a[i])) {
   		ok = 0;
   		break;
   	}
   }
   cout << (ok ? "pairwise coprime" : "setwise coprime");
   return 0;
}

Measured memory_bytes: 15752
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[][][] home = new int[4][3][10];
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
            home[b-1][f-1][r-1] += v;
        }

        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 10; k++){
                    System.out.print(" " + home[i][j][k]);
                }
                System.out.println();
            }
            if(i != 3) System.out.println("####################");
        }

        sc.close();
    }
}



Measured memory_bytes: 29032
while True:
    H , W = map(int,input().split())
    if W == 0 and H == 0:
        break
    for i in range(W):
        print("#" , end="")
    print()
    for i in range(H-2):
        print("#" , end="")
        for i in range(W-2):
            print(".", end="")
        print("#")
    for i in range(W):
        print("#" , end="")
    print()
    print()


Measured memory_bytes: 6996
N = int(input())
F=0
FF=0
FFF=0
FFFF = 0
if(N>=500):
    F=N/500
    FFF = int(F)
FFFF = (N-(500*FFF))
if(FFFF>5):
    FF=int(FFFF/5)
print((int(F)*1000)+FF*5)
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
typedef long long ll;
int K;
int F[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> K;
	cout << F[K-1] << nl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
#define int long long
signed main(){

	int N, K;
	cin>>N>>K;
	vll A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	sort(A.begin(), A.end(), greater<int>());

	int sum=0;
	for(int i=0;i<N;i++){
		if(i>=K)
			sum+=A[i];
	}
	cout<<sum<<endl;

	return 0;
}

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

int n, k, c, j;
string s;
int l[200000], r[200000];

int main()
{
    cin >> n >> k >> c >> s;

    j = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'o') {
            l[j] = i;
            j++;
            i += c;
        }
    }

    j = 0;

    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'o') {
            r[k - 1 - j] = i;
            j++;
            i -= c;
        }

        if (k - 1 - j < 0)
            break;
    }

    for (int i = 0; i < k; i++)
        if(l[i] == r[i])
            cout << l[i] + 1 << endl;
}


Measured memory_bytes: 3332
#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main(void){
    int n;
    cin >> n;
    
    string p = "";
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        p += to_string(a);
    }
    
    string q = "";
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        q += to_string(a);
    }
    
    
    map<string, int> mp;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++) v[i] = i+1;
    
    int counter = 1;
    
    do{
        string temp = "";
        
        for(int x : v){
            temp += to_string(x);
        }
        mp[temp] = counter;
        counter++;
        
    }while(next_permutation(v.begin(), v.end()));
    
    int index_a = mp[p];
    int index_b = mp[q];
    
    int ans = abs(index_a - index_b);
    cout << ans << endl;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	string n;
 	cin >> n;
 	int ans=0;
 	for (int i = 1; i < n.size(); i++){
 		if(n[i-1]==n[i]){
 			ans++;
 			
 			if(n[i]=='1'){
 				n[i]='0';
 			}else{
 				n[i]='1';
 			}
 		}
 	}
 	cout << ans << endl;
 }

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a+b>a-b){
    if(a+b>a*b){
      cout << a+b << endl;
    }else{cout << a*b << endl;}
  }else{
    if(a-b>a*b){
      cout << a-b << endl;
    }else{
      cout << a*b << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
	const char SHARP = '#';
	const char DOT = '.';
	int h, w;
	while(std::cin >> h >> w)
	{
		if(h == 0 && w == 0) break;
		for(int y=0; y<h; y++){
			if(y % 2 == 1){
				for(int x=0; x<w; x++){
					if(x % 2 == 1){
						std::cout << SHARP;
					} else {
						std::cout << DOT;
					}
				}
				std::cout << '\n';
			} else {
				for(int x=0; x<w; x++){
					if(x % 2 == 1){
						std::cout << DOT;
					} else {
						std::cout << SHARP;
					}
				}
				std::cout << '\n';
			}
		}
		std::cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 1120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<int> v;

ll dp[100][100100];

int main(void){
	int n,k,i,j,m;
	cin >> n >> k;
	for(i=1; i*i<=n; ++i){
		v.push_back(i);
		v.push_back(n/i+1);
		if((i+1)*(i+1)>n && (i != (n/i))){
			v.push_back(i+1);
		}
	}
	sort(v.begin(),v.end());
	m = v.l_ength() - 1;
	for(j=0; j<m; ++j){
		dp[0][j] = v[j+1]-v[j];
		dp[0][j] %= MOD;
	}
	for(j=1; j<m; ++j){
		add_mod(dp[0][j],dp[0][j-1]);
	}
	for(i=1; i<k; ++i){
		for(j=0; j<m; ++j){
			dp[i][j] = dp[i-1][m-j-1];
			mul_mod(dp[i][j],(v[j+1]-v[j])%MOD);
		}
		for(j=1; j<m; ++j){
			add_mod(dp[i][j],dp[i][j-1]);
		}
	}
	cout << dp[k-1][m-1] << endl;
	return 0;
}


Measured memory_bytes: 77948
#include<iostream>
#include<vector>
using namespace std;
#define MAX_N 114514
vector<int> X[MAX_N];int Group[MAX_N], N, Q, A, B, C;
int main() {
	cin >> N >> Q;
	for (int i = 0; i < MAX_N; i++) { X[i].push_back(i); Group[i] = i; }
	for (int i = 0; i < Q; i++) {
		cin >> A >> B >> C;
		int D = Group[B], E = Group[C];
		if (A == 0 && D != E) {
			if (X[D].size() >= X[E].size()) {
				for (int j = 0; j < X[E].size(); j++) {
					Group[X[E][j]] = D; X[D].push_back(X[E][j]);
				}
				X[E].clear();
			}
			else if (X[D].size() < X[E].size()) {
				for (int j = 0; j < X[D].size(); j++) {
					Group[X[D][j]] = E; X[E].push_back(X[D][j]);
				}
				X[D].clear();
			}
		}
		if (A == 1) {
			if (D == E) { cout << "1" << endl; }
			else { cout << "0" << endl; }
		}
	}
	return 0;
}


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

int main(){
  int A[3][3];
  int N;
  int B;
  rep(i,3){
    rep(j,3){
      cin >> A[i][j];
    }
  }
  cin >> N;
  rep(i, N){
    cin >> B;
    rep(k,3){
      rep(j,3){
        if(A[k][j] == B) A[k][j] = 0;
      }
    }
  }

  int flag = 0;
  rep(i,3){
    if(A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0)flag = 1;
    if(A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0)flag = 1;
  }
  if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0)flag = 1;
  if(A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0)flag =1;

  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int[][] masu=new int[H][W];
		int[][] buri=new int[H*W][4];
		int b_c=0;

		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				masu[i][j]=sc.nextInt();
			}
		}
		int muki=1;

		for(int i=0; i<H; i++) {
			for(int j=0; j<W-1; j++) {
				if(muki==1) {
					if(masu[i][j]%2==1) {
						masu[i][j+1]++;
						masu[i][j]--;
						buri[b_c][0]=i+1;
						buri[b_c][1]=j+1;
						buri[b_c][2]=i+1;
						buri[b_c][3]=j+2;
						b_c++;
					}
					else {
						//
					}
				}

				else if(muki==-1) {
					if(masu[i][W-1-j]%2==1) {
						masu[i][W-j-2]++;
						masu[i][W-j-1]--;
						buri[b_c][0]=i+1;
						buri[b_c][1]=W-j;
						buri[b_c][2]=i+1;
						buri[b_c][3]=W-j-1;
						b_c++;
					}
					else {
						//
					}
				}
			}
			if(i<H-1 && muki==1) {
				if(masu[i][W-1]%2==1) {
					masu[i][W-1]--;
					masu[i+1][W-1]++;
					buri[b_c][0]=i+1;
					buri[b_c][1]=W;
					buri[b_c][2]=i+2;
					buri[b_c][3]=W;
					b_c++;
				}
				muki*=-1;
			}

			else if(i<H-1 && muki==-1) {
				if(masu[i][0]%2==1) {
					masu[i][0]--;
					masu[i+1][0]++;
					buri[b_c][0]=i+1;
					buri[b_c][1]=1;
					buri[b_c][2]=i+2;
					buri[b_c][3]=1;
					b_c++;
				}
				muki*=-1;
			}
		}
		System.out.println(b_c);
		for(int i=0; i<b_c; i++) {
			System.out.println(buri[i][0]+" "+buri[i][1]+" "+buri[i][2]+" "+buri[i][3]);
		}
	}
}

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

using namespace std;

#define fo(i,CApiTaL_N) for(int i=0; i<CApiTaL_N; i++)
#define Fo(i,k,CApiTaL_N) for(int i=k; i<CApiTaL_N; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int t=1;
const int mxW=1e5, mxN=1e2, mxV=1e9;
int n,w;
vl wi(mxN+1),v(mxN+1),dp(mxW+1);

void test_case(){
    cin>>n>>w;
    Fo(i,1,n+1){
        cin>>wi[i]>>v[i];
    }
    Fo(j,1,n+1){
        for(int i=w; i>=0; i--){
            if(i-wi[j]<0)continue;
            // cout<<i<<" "<<j<<" "<<dp[i]<<" "<<i-wi[j]<<" "<<dp[i-wi[j]]<<" "<<v[j]<<endl;
            dp[i]=max(dp[i],dp[i-wi[j]]+v[j]);
        }
    }
    cout<<dp[w]<<endl;
}

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

    // cin>>t;
    while(t--){
        test_case();
    }
    
    return 0;
}

Measured memory_bytes: 3892
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll> 
#define mll map<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ing(m,ad) rep(i,m){ int u,v; cin>>u>>v; u--;v--; ad[u].pb(v); ad[v].pb(u);}
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100001;
int spf[MAXN];
int gcd(int x, int y){ return y?gcd(y,x%y):x; }

void precal(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,k,t=1;
    // cin>>t;
    while(t--){
        cin>>n>>k;
        arrin(a,n);
        for(int i=k;i<n;i++){
            if(a[i-k]<a[i]) cout<<"Yes\n";
            else cout<<"No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 4696