akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = ['']*n
for i in range(n):
    s[i] = input()

s.sort()
s0 = [s[0]]
s0n = [0]
cnt = 0
for i in range(1, n):
    if s[i] == s0[cnt]:
        s0n[cnt] += 1
    else:
        s0.append(s[i])
        s0n.append(0)
        cnt += 1

#print(s0)
#print(s0n)
max_s0n = max(s0n)
for i in range(cnt+1):
    if s0n[i] == max_s0n:
        print(s0[i])

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

int main() {
  int H,W;
  cin >> H >> W;
  string s;
  char c = 'A';
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> s;
      if (s == "snuke") {
        c += j;
        cout << c << i+1 << endl;
        return 0;
      }
    }
  }
    
  return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut buf = buf.split_whitespace();
    let h: u32 = buf.next().unwrap().parse().unwrap();
    let w: u32 = buf.next().unwrap().parse().unwrap();

    let mut can = "Yes";

    let mut cur = String::new();
    let mut prev = String::new();
    let mut next = String::new();
    for i in 0..h {
        if i == 0 {
            cur = String::new();
            io::stdin().read_line(&mut cur).unwrap();
            cur.trim();
        }

        if i != (h - 1) {
            next = String::new();
            io::stdin().read_line(&mut next).unwrap();
            next.trim();
        }

        for j in 0..w {
            let c = match cur.trim().chars().nth(j as usize) {
                Some(a) => a,
                None => break,
            };

            if c == '#' {
                let mut r = '.';
                let mut l = '.';
                let mut t = '.';
                let mut u = '.';
                // right
                if j != w - 1 {
                    r = match cur.trim().chars().nth((j+1) as usize) {
                        Some(a) => a,
                        None => break,
                    };
                }
                // left
                if j != 0 {
                    l = match cur.trim().chars().nth((j-1) as usize) {
                        Some(a) => a,
                        None => break,
                    };
                }
                // top
                if i != 0 {
                    t = match prev.trim().chars().nth(j as usize) {
                        Some(a) => a,
                        None => break,
                    };
                }
                // under
                if i != (h - 1) {
                    u = match next.trim().chars().nth(j as usize) {
                        Some(a) => a,
                        None => break,
                    };
                }
                if r == '.' && l == '.' && t == '.' && u == '.' {
                    can = "No";
                }
            }
        }
        prev = cur.clone();
        cur = next.clone();
    }

    println!("{}", can);
}

Measured memory_bytes: 4352
#include <stdio.h>
#define SIZE 100000
int main()
{
    int n,a[SIZE],x,i,sum=0,count=0,mn=100000,ans,doug;
    scanf("%d %d",&n, &x);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(mn>a[i]){
            mn=a[i];
        }
        sum+=a[i];
    }
    if(sum==x){
        printf("%d\n",n);
    }
    else{
        ans = x-sum;
        doug = ans/mn+n;
        printf("%d\n",doug);
    }
    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}


int main() {
    int N, M;
    cin >> N >> M;
    vector<long long> divs = divisor(M);
    int i = upper_bound(divs.begin(), divs.end(), N - 1) - divs.begin();
    cout << M / divs[i] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		long[] L = new long[N];
		for(int i=0; i<N; i++) {
			L[i] = sc.nextLong();
		}

		if(L.length < 3) {
			System.out.println(0);
			return;
		}

		long ans = 0;
		for(int i=0; i<N-2; i++) {
			for(int j=i+1; j<N-1; j++) {
				if(L[j] == L[i])
					continue;
				for(int k=j+1; k<N; k++) {
					if(L[k] == L[j] || L[k] == L[i])
						continue;

					if(L[i] < L[j]+L[k] && L[i] > Math.abs(L[j]-L[k])) {
						ans++;
					}
				}
			}
		}

		System.out.println(ans);

	}


}


Measured memory_bytes: 36176
#include <iostream>
using namespace std;
int main() {
int n,i;cin>>n;
  string str;cin>>str;
  int x=str.length();  
  if(n>=x)
    cout<<str;
  else{
  for( i=0;i<n;i++)
    cout<<str[i];
    
      cout<<"...";
  }
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
Int solve(Int H, Int W) {
    if (H == 1 || W == 1) {
        return 1;
    } else if (H % 2 == 1) {
        return solve(H - 1, W) + (W + 1) / 2;
    } else if (W % 2 == 1) {
        return solve(H, W - 1) + (H + 1) / 2;
    } else {
        return H * W / 2;
    }
}
int main() {
    Int H, W; cin >> H >> W;
    cout << solve(H, W) << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut count = 1;
    let mut min = p[0];
    for i in 1..n {
        if p[i] <= min {
            count += 1;
            min = p[i];
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4756
n, m = map(int, input().split())
l, r = map(int, input().split())

for _ in range(m-1):
  templ, tempr = map(int, input().split())
  l = max(l, templ)
  r = min(r, tempr)

if l <= r:
  print(r-l+1)
else:
  print(0)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"strings"
)

func main() {
	var cnt int
	var s, last string
	fmt.Scan(&s)
	b := strings.Split(s, "")
	for _, cell := range b {
		if cell == last {
			continue
		}
		cnt++
		last = cell
	}
	fmt.Println(cnt - 1)
}


Measured memory_bytes: 4196
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
i = 0
inn=[]
for i in sys.stdin:
    i=int(i)
    if i==0 and len(inn)>0:
        print inn[-1]
        inn.pop()
    elif i==0 and len(inn)==0:
        sys.exit()
    elif i!=0:
        inn.append(i)
for i in inn:
    print i

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

#[allow(dead_code)]
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")
}

const MOD: usize = 1e+9 as usize + 7;
fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut dp = vec![vec![vec![0; k + 1]; n + 1]; n + 1];
    dp[0][0][0] = 1;
    for depth in 0..n {
        for rest in 0..n {
            for value in 0..k + 1 {
                let ndepth = depth + 1;
                // nop
                let nrest = rest + 1;
                let nvalue = value + (rest + 1) * 2;
                if nvalue <= k && nrest <= n {
                    dp[ndepth][nrest][nvalue] =
                        (dp[ndepth][nrest][nvalue] + dp[depth][rest][value]) % MOD;
                }
                // use one, use self
                let nrest = rest;
                let nvalue = value + rest * 2;
                if nvalue <= k {
                    let cnt = 1 + 2 * rest;
                    dp[ndepth][nrest][nvalue] =
                        (dp[ndepth][nrest][nvalue] + cnt * dp[depth][rest][value]) % MOD;
                }
                // use both
                if rest > 0 {
                    let nrest = rest - 1;
                    let nvalue = value + (rest - 1) * 2;
                    let cnt = rest * rest;
                    if nvalue <= k {
                        dp[ndepth][nrest][nvalue] =
                            (dp[ndepth][nrest][nvalue] + cnt * dp[depth][rest][value]) % MOD;
                    }
                }
            }
        }
    }
    println!("{}", dp[n][0][k]);
}


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

void Solve() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a < 0 && c < 0) {
        if(b >= 0 && d >= 0) {
            cout << max(a * c, b * d) << endl;
            return;
        }
        cout << a * c << endl;
        return;
    }
    if(a >= 0 && c >= 0) {
        cout << b * d << endl;
        return;
    }
    if(a < 0) {
        if(b >= 0) {
            cout << b * d << endl;
            return;
        }
        cout << b * c << endl;
        return;
    }
    if(c < 0) {
        if(d >= 0) {
            cout << b * d << endl;
            return;
        }
        cout << d * a << endl;
        return;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
   // cin >> t;
    while(t--) {
        Solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,x) for(ll i=0;i<x;++i)
#define rep1(i,x) for(ll i=1;i<=x;++i)
#define rrep(i,x) for(ll i=x-1;i>=0;--i)
#define rrep1(i,x) for(ll i=x;i>=1;--i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rev(a) reverse(all(a))

template<typename T> T get(){T a;cin >> a;return a;}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    vi team(N), rnk(N);

    fill(all(team), 0); fill(all(rnk), 1);

    rep(i, (N*N-N)/2) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        a--; b--;
        if (c > d) team[a]+=3;
        else if (d > c) team[b]+=3;
        else {team[a]++;team[b]++;}
    }

    rep(i, N) rep(j, N) {
        if (team[i] < team[j]) rnk[i]++;
    }

    rep(i, N) cout << rnk[i] << endl;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
	ull a,b,c;
inline ll f(ll x){
	if(-1==x){
		return 0;
	}else{
		return x/c+1;
	}
}
int main(){
	cin>>a>>b>>c;
	cout<<f(b)-f(a-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
n,m=list(map(int,input().strip().split()))
if n-m>1 or n-m<-1:
    print(0)
else:
    ans=1
    for i in range(1,n+1,1):
        ans=ans*i%1000000007
    for i in range(1,m+1,1):
        ans=ans*i%1000000007
    if n==m:
        print(ans*2%1000000007)
    else:
        print(ans)


Measured memory_bytes: 3060
num_list = [int(i) for i in input().split()]
dist_list = [int(i) for i in input().split()]

temp = [(dist_list[-1]-num_list[0])] + dist_list[:-1]
sabun_list = [dist_list[i] - temp[i] for i in range(len(dist_list))]

print(sum(sabun_list) - max(sabun_list))

Measured memory_bytes: 26436
# https://atcoder.jp/contests/abc103/tasks/abc103_d
N, M = map(int, input().split(' '))

I = []
for _ in range(M):
    I.append(tuple(map(int, input().split(' '))))

# bが小さい順にソート
I = sorted(I, key=lambda x:x[1])
for i, tup in enumerate(I):
    a, b = tup
    if i == 0:
        bb = [b-1]
    elif a > bb[-1]:
        bb.append(b-1)
    else:
        pass
print(len(bb))

Measured memory_bytes: 19016
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int h1,h2, m1, m2;
int k;

int main()
{
  int t1, t2;

  cin >> h1 >> m1 >> h2 >> m2 >> k;

  t1 = h1*60+m1;
  t2 = h2*60+m2;

  cout << (t2-t1)-k << endl;
  return 0;
}


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

#define long long long int
using namespace std;

// @author: pashka

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i - 1]) {
            cout << "NO";
            return 0;
        } 
    }
    cout << "YES";

    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));


int main(){
    string s, p;
    cin >> s >> p;
    string round = s + s;
    if(round.find(p) == -1) puts("No");
    else puts("Yes");
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
const int Maxn=100005;
char c[Maxn];
bool del[Maxn];
set<int>e[Maxn];
int d,f1[Maxn],f2[Maxn],val[Maxn];
void dfs(int x,int fa){
    for(int y:e[x]){
        if(y==fa)continue;
        dfs(y,x);
        if(f1[y]>f1[x])f2[x]=f1[x],f1[x]=f1[y];
        else if(f1[y]>f2[x])f2[x]=f1[y];
    }
    f1[x]+=val[x];
    d=max(d,f1[x]+f2[x]);
}
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<n;i++){
        int x,y;scanf("%d%d",&x,&y);
        e[x].insert(y);
        e[y].insert(x);
    }
    scanf("%s",c+1);
    queue<int>Q;
    for(int i=1;i<=n;i++)
        if(e[i].size()<=1&&c[i]=='B')
            Q.push(i);
    while(Q.size()){
        int x=Q.front(),y=e[x].size()?*e[x].begin():0;Q.pop();
        del[x]=true;
        if(e[y].count(x)){
            e[y].erase(x);
            if(e[y].size()==1&&c[y]=='B')
                Q.push(y);
        }
    }
    int rt=-1,cnt=0,ans=0;
    for(int i=1;i<=n;i++)
        if(!del[i]){
            rt=i,cnt++;
            ans+=e[i].size()+((e[i].size()+(c[i]=='W'))&1);
            val[i]=2*((e[i].size()+(c[i]=='W'))&1);
        }
    if(rt==-1){
        cout<<"0\n";
        return 0;
    }
    if(cnt<=1){
        cout<<cnt<<"\n";
        return 0;
    }
    dfs(rt,0);
    cout<<ans-d<<"\n";
    return 0;
}

Measured memory_bytes: 21504
import sys
import itertools

def main():
    l = list(range(10))
    
    while True:
        data = sys.stdin.readline().strip()
        if data is None or data == '':
            break

        num = int(data)
        #print('num:', num)
        cnt = 0
        for elem in itertools.product(l, repeat=4):
            sum = 0
            for i in elem:
                sum += i

            if sum == num:
                cnt += 1

        print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7688
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
using namespace std;
using ll =long long;
int main() {
	int A[3];

	cin >> A[0] >> A[1] >> A[2];
	sort(begin(A), end(A));
	if (A[0] == A[1]) {
		if (A[1] != A[2]) {


			cout << "Yes";
			return 0;
		}



	}
	else if (A[1] == A[2]) {

		cout << "Yes";
		return 0;
	}
	cout << "No";


}

Measured memory_bytes: 256
import sys
n=int(input())

def f(x):
    m=0
    while x>0:
        m+=1
        x=x//10
    return m
m=f(n)

a=[(3**(i+1)-3)//2-6*(2**i-1)+3*i for i in range(1,10)]
a.insert(0,0)
if m==1 or m==2:
    print(0)
    sys.exit()
ans=a[m-1]
def g(x):
    z=[]
    while x>0:
        z.insert(0,x%10)
        x=x//10
    return z
for i in range(3**m):
    x=["" for i in range(m)]
    for j in range(m):
        if i%3==0:
            x[j]="3"
        elif i%3==1:
            x[j]="5"
        else:
            x[j]="7"
        i=i//3
    if int("".join(x))<=n and "3" in x and "5" in x and "7" in x:
        ans+=1
    
print(ans)
        
    
    



    
        
        
        
          


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

char s[55][55];
int main(){
	int h, w;
	cin >> h >> w;
	for (int i = 0;i < 55;i++) {
		for (int j = 0;j < 55;j++) {
			s[i][j] = '.';
		}
	}
	for (int i = 1;i <= h;i++) {
		string in;
		cin >> in;
		for (int j = 1;j <= w;j++) {
			s[i][j] = in[j - 1];
		}
	}

	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			if (s[i][j] == '#') {
				int dx[] = { 0,1,0,-1 };
				int dy[] = { 1,0,-1,0 };
				bool all_white = true;
				for (int k = 0;k < 4;k++) {
					int x = i + dx[k];
					int y = j + dy[k];
					if (s[x][y] == '#') {
						all_white = false;
					}
				}
				if (all_white) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}

	cout << "Yes" << endl;
	

	return 0;
}

Measured memory_bytes: 256
import sys
import math

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n, k = IN()
	#s = input()
	r=0
	for i in range(1, n+1):
		a = math.ceil(math.log2(max(1,(k+i-1)//i)))
		#print(i, a, i*(2**a),k)
		ra = (1/2)**a
		r+=ra
		#print(ra)
		
	return r/n
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(void){
int N,H[100],count = 1;
    
    scanf("%d",&N);
    for(int i = 0; i < N; i++){
        scanf("%d",&H[i]);
    }
    
    for(int i = 1; i < N; i++){
        for(int j = 0; j <= i - 1; j++){
        
            if(H[i] < H[j]){
                break;
                
            }else if(j == i-1){
                count++;
            }
        }
    
        
    }
    
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 256
N, S = map(int, input().split())
A = [0] + list(map(int, input().split()))
mod = 998244353

dp = [0] * (S + 1)
dp2 = [0] * (S + 1)

"""
dp[i][j] = (i個までの数を使ってj点とる組み合わせ)
としたはいいが、f(L, R)をf(1,L)とf(1, R)に分解できずに爆死したのが敗因。

各(L, R)に対してdpするとTLEになるから手詰まりになると思ったわけだけど、
上のdpテーブルを各iに対して使い回しつつ、新たなdpテーブル[1, 0, 0, ...]を
作成して「元のdpテーブルに加算しておけば」dpテーブル一個で1番目スタート、2番目スタート、
..., L番目スタートのdpテーブル全てを考えられる！
（解説放送前半を参考）
"""

# i == 0の時
dp[0] = 1
ans = 0

# i >= 1の時
for i in range(1, N + 1):
    for j in range(S + 1):
        if j - A[i] < 0:
            dp2[j] = dp[j]
        else:
            dp2[j] = dp[j] + dp[j - A[i]]
    ans += dp2[S]
    ans %= mod

    dp = dp2 # deepcopyしなくてもこれで十分なはずだし、ポインタ渡しなので高速？
    dp[0] += 1
    dp2 = [0] * (S + 1)

print(ans)


Measured memory_bytes: 101980
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

A, B = map(int, input().split())

fb = factorization(B)

ans = A
for b, n in fb:
  c = 0
  for i in range(1, n+1):
    if ans % (b**i) == 0:
      c = i
    else:
      break
    
  ans *= (b**(n-c))
  
  
print(ans)

Measured memory_bytes: 3188
/*input
1 2 3 1
*/
#include <iostream>
using namespace std;
 
#define int long long
 
signed main() {
    int a,b,c;
    int k;
    cin >> a >> b >> c >> k;
    if(k%2)cout << b-a;
    else cout << a-b;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    char str[3];
    scanf("%s",str);
    if(str[2]=='\0'){
        cout << str << endl;
    }
    else {
        for(int i=2; i>=0; i--){
            cout << str[i];
        }
        cout <<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun read(): Triple<Int, Int, Array<String>> {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val a = Array<String>(h) { sc.next() }
    return Triple(w, h, a)
}

fun read2(): Triple<Int, Int, Array<String>> {
    val (h, w) = readLine()!!.split(" ").map(String::toInt)
    val a = Array(h){readLine()!!}
    return Triple (w, h, a)
}


fun solve(w: Int, h: Int, a: Array<String>): Int {


    data class Point(val x: Int, val y: Int)

    fun isWithin(p: Point): Boolean {
        return (p.x in 0 until w) && (p.y in 0 until h)
    }

    val open: Queue<Point> = ArrayDeque()
    val infty = w + h
    val dist = Array(h) { Array(w) { infty } }
    val visited = Array(h) { Array(w) { false } }
    for (y in 0 until h) {
        for (x in 0 until w) {
            if (a[y][x] == '#') {
                dist[y][x] = 0
                visited[y][x] = true
                open.add(Point(x, y))
            }
        }
    }

    var maxDist = 0
    fun update(current: Point, next: Point) {
        if (isWithin(next) && !visited[next.y][next.x]) {
            open.add(next)
            visited[next.y][next.x] = true
            dist[next.y][next.x] = dist[current.y][current.x] + 1
            maxDist = Math.max(maxDist, dist[next.y][next.x])
        }
    }
    while (open.isNotEmpty()) {
        val current = open.remove()
        update(current, Point(current.x + 1, current.y))
        update(current, Point(current.x - 1, current.y))
        update(current, Point(current.x, current.y + 1))
        update(current, Point(current.x, current.y - 1))
    }
    return maxDist
}

fun main(args: Array<String>) {
    val (w, h, a) = read2()
    println(solve(w, h, a))
}


Measured memory_bytes: 129392
using System;

public class YYMMorMMYY
    {
        static void Main(string[] args)
        {           
            string line1 = Console.ReadLine().Trim();
            int first = int.Parse(String.Concat(line1[0], line1[1]));
            int second = int.Parse(String.Concat(line1[2], line1[3]));
          
            if (!IsMM(first) && IsMM(second))
            {
                Console.WriteLine("YYMM");
            }
            else if (IsMM(first) && !IsMM(second))
            {
                Console.WriteLine("MMYY");
            }
            else if (IsMM(first) && IsMM(second))
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else if (!IsMM(first) && !IsMM(second))
            {
                Console.WriteLine("NA");
            }
        }
        public static bool IsMM(int target)
        {
            if (target != 0 && target <= 12)
            {
                return true;
            }
            return false;
        }
    }

Measured memory_bytes: 11092
N=int(input())
import math
SQ=int(math.sqrt(N))
minval=10**12
a=1
b=1
for i in range(1,SQ+1):
  if N%i==0:
    newa=i
    newb=N//i
    if abs(newa-newb) < minval:
      minval=abs(newa-newb)
      a=newa
      b=newb

print(a+b-2)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
	val (n, m) = readLine()!!.split(" ").map { it.toInt() }

	val a = arrayListOf<ArrayList<Int>>()
	val b = arrayListOf<Int>()
	val ans = arrayListOf<Int>()

	for (i in 0 until n) {
		a.add(ArrayList())
		val tmp = readLine()!!.split(" ").map { it.toInt() }
		tmp.forEach { t ->
			a[i].add(t)
		}
	}

	for (i in 0 until m) {
		b.add(readLine()!!.toInt())
	}

	for (i in 0 until n) {
		ans.add(0)
		for (j in 0 until m) {
			ans[i] += a[i][j] * b[j]
		}
	}
	println(ans.joinToString("\n"))
}



Measured memory_bytes: 36640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

	//入力表示
	 String S = scanner.next();
	 
	 //文字数を確認
	 S.length();
	 
	 //空の文字列を用意
	 String t = "";

	 //xを文字数の数繰り返す
	 for(int i=0;i<S.length();i++) {
		 
		 t+="x";
		 
	 }
	 System.out.println(t);

		scanner.close();
	}
}


Measured memory_bytes: 22736
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

ans = 0
for i in B:
    ri = bisect.bisect_left(A, i)
    li = N - bisect.bisect_right(C, i)
    ans += ri*li

print(ans)

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

int main()
{
  int n;
  ll t, sum, ans;
  cin >> n >> t;
  vector<ll> T(n);
  for (int i = 0; i < n; i++)
  {
    cin >> T.at(i);
  }

  ans = sum = T.at(0);
  for (int i = 1; i < n; i++)
  {
    if (T.at(i) - sum >= t)
    {
      ans += t;
    }
    else if (T.at(i) - sum < t)
    {
      ans += T.at(i) - sum;
    }

    sum = T.at(i);
  }
  ans += t;
  cout << ans << endl;
}


Measured memory_bytes: 4828
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
r = np.array([0]*(N+1))
for i in range(N):
  r[i+1] = A[i]-r[i]
x = r[N]
#print(r)
r[1::2] = r[1::2]*2-x
r[0::2] = r[0::2]*2+x
r = r[:N]
r = list(map(str,r))
print(" ".join(r))



Measured memory_bytes: 26784
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Tenki(void) {

	string S, T; cin >> S >> T;

	int counter = 0;
	rep(index, 3) if (S[index] == T[index]) counter++;
	
	cout << counter << flush;
	return;
}

void B_Power_Socket(void) {
	
	int A, B; cin >> A >> B;
	
	cout << ceil(double(B - 1) / double(A - 1)) << flush;
	return;
}

void C_Lower(void) {

	int N; cin >> N;
	vector<int> H(N); for (int& it : H)cin >> it;

	int counter = 0;
	int maxCount = 0;
	rep(index, N - 1) {
		if (H[index] >= H[index + 1]) {
			counter++;
		}
		else {
			maxCount = max(maxCount, counter);
			counter = 0;
		}
	}
	maxCount = max(maxCount, counter);
	
	cout << maxCount << flush;
	return;
}

void D_ModSum(void) {

	int N; cin >> N;

	cout << (long long)N * ((long long)N - 1) / 2 << flush;
	return;
}

int main(void) {

	//A_Tenki();
	//B_Power_Socket();
	//C_Lower();
	D_ModSum();
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	answer(n)
}

func answer(n int) {
	for n > 0 {
		if n % 10 == 7 {
			fmt.Println("Yes")
			return
		}
		n = n / 10
	}
	fmt.Println("No")
	return
}


Measured memory_bytes: 1816
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 998244353
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

ll qp(ll a,ll k)
{
    ll res=1;
    while(k)
    {
        if(k&1) res=res*a%mod;
        a=a*a%mod;
        k>>=1;
    }
    return res;
}
int p[maxn+5];

struct BIT
{
    ll a[maxn+5];
    void init()
    {
        memset(a,0,sizeof a);
    }
    void add(int x,ll v)
    {
        for(;x<=maxn;x+=x&-x) a[x]=(a[x]+v+mod)%mod;
    }
    ll ask(int x)
    {
        ll res=0;
        for(;x;x-=x&-x) res=(res+a[x])%mod;
        return res;
    }
}A,B;

int id[maxn+5];

int main()
{
    int n,k; scanf("%d%d",&n,&k);
    rep(i,1,n) scanf("%d",&p[i]),id[i]=i;
    ll invk=qp(k,mod-2),inv2=qp(2,mod-2);
    sort(id+1,id+n+1,[](int a,int b){return p[a]>p[b];});
    ll ans=0;
    ll pr=(1-invk+mod)%mod;
    rep(I,1,n)
    {
        int i=id[I];
        if(i<=k) ans=(ans+inv2*(i-1))%mod;
        if(i>k)
        {
            ans=(ans+A.ask(i))%mod;
            ll tmp=(B.ask(i)-B.ask(k)+mod)*qp(pr,i)%mod;
            ll tmp2=A.ask(k)*qp(pr,i-k)%mod;
            ans=(ans-tmp*inv2%mod+mod)%mod;
            ans=(ans-tmp2*inv2%mod+mod)%mod;
        }
        A.add(i,1);
        B.add(i,qp(qp(pr,i),mod-2));
    }
    A.init(); B.init();
    per(I,1,n)
    {
        int i=id[I];
        if(i>k)
        {
            ll tmp=(B.ask(i)-B.ask(k)+mod)*qp(pr,i)%mod;
            ll tmp2=A.ask(k)*qp(pr,i-k)%mod;
            ans=(ans+tmp*inv2%mod)%mod;
            ans=(ans+tmp2*inv2%mod)%mod;
        }
        A.add(i,1);
        B.add(i,qp(qp(pr,i),mod-2));
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 8364
#include <iostream>
#define MOD 100000
using namespace std;

int main(){
	int w,h;
	int dp[105][105][2][2] = {};//w,h,right(0) or up(1),turn
	while(1){
		cin >> w >> h;
		if(!w) break;
		for(int i = 0;i <= 100;i++){
			for(int j = 0;j <= 100;j++){
				for(int k = 0;k < 4;k++){
					dp[i][j][k / 2][k % 2] = 0;
				}
			}
		}
		for(int i = 1;i <= w;i++){
			for(int j = 1;j <= h;j++){
				if(i == 1 && j == 1){
					dp[i + 1][j][0][0] += 1;
					dp[i][j + 1][1][0] += 1;
				}else{
					dp[i + 1][j][0][0] = (dp[i + 1][j][0][0] + dp[i][j][0][0] + dp[i][j][0][1]) % MOD;
					dp[i + 1][j][0][1] = (dp[i + 1][j][0][1] + dp[i][j][1][0]) % MOD;
					dp[i][j + 1][1][0] = (dp[i][j + 1][1][0] + dp[i][j][1][0] + dp[i][j][1][1]) % MOD;
					dp[i][j + 1][1][1] = (dp[i][j + 1][1][1] + dp[i][j][0][0]) % MOD;
				}
			}
		}
		cout << (dp[w][h][0][0] + dp[w][h][1][0] + dp[w][h][0][1] + dp[w][h][1][1]) % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

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

string s,t;
ostringstream oss;
stringstream ss;

oss << a << flush;
s = oss.str();

oss.str("");
oss << b << flush;
t = oss.str();

s += t;
int N;

ss << s;
ss >> N;

for(int i=1; i*i <= N;i++) {
    if(i*i == N) {
        cout << "Yes" << endl;
        return 0;
    }
}

cout << "No" << endl;

return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 struct Node{
  int key;
 struct Node *next,*prev;
};
 struct Node *nil;
struct Node * listSearch(int key){
struct  Node *cur=nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}
void init(){
  nil=(struct Node *)malloc(sizeof(struct Node));
  nil->next=nil;
  nil->prev=nil;
}
void print(){
struct  Node *cur=nil->next;
  int isf=0;
  while(1){
    if(cur==nil)break;
    if(isf++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}
void delete(struct Node *t){
  if(t==nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}
void deletefirst(){
  delete(nil->next);
}void deletelast(){
  delete(nil->prev);
}
void deletekey(int key){
  delete(listSearch(key));
}
void insert(int key){
struct  Node *x=(struct Node *)malloc(sizeof(struct Node));
 x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
int main(){
  int key,n,i;
  int size =0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
    if(com[6]=='F')deletefirst();
    else if (com[6]=='L')deletelast();
      }else{
    deletekey(key);
    nd++;
      }
      size--;
    }
  }
  print();
  return 0;
}

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

int main(){
    cin >> n;
    pair<string,int> p("a",1);
    vector<pair<string,int>>  a = {p};
    vector<string> A = {"a","b","c","d","e","f","g","h","i","j"};
    
    int s = 0;
    for (int i = 0; i < n; i++)
    {
        if(i == n-1){
            for (int j = 0; j < a.size(); j++)
            {
                cout << a[j].first << endl;
            }
        }
        else{
            int ss = a.size();
            for (int j = 0; j < ss; j++)
            {
                for (int k = 0; k < a[j].second+1; k++)
                {
                    string str = a[j].first + A[k];
                    if(k == a[j].second) a.push_back(make_pair(str,a[j].second+1));
                    else a.push_back(make_pair(str,a[j].second));
                }
                
            }
            a.erase(a.begin(),a.begin()+ss);
        }
    }
    
}

Measured memory_bytes: 13468
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 int a[n];
 int i;
 int sum=0;
 for(i=0;i<n;i++)
 {
 cin>>a[i];
 sum+=a[i];
 }
 float m=1.0;
 m*=sum;
 m/=n;
 float x=m-floor(m);
 if(x>=0.5)
 {
 	int p=m+1;
 	int ans1=0;
 	for(i=0;i<n;i++)
 	ans1+=pow(abs(a[i]-p),2);
 //	cout<<ans<<endl;
 	 p=m;
 	int ans2=0;
 	for(i=0;i<n;i++)
 	ans2+=pow(abs(a[i]-p),2);
 	cout<<min(ans1,ans2)<<endl;
 }
 else
 {
 	 		int p=m+1;
 	int ans1=0;
 	for(i=0;i<n;i++)
 	ans1+=pow(abs(a[i]-p),2);
 //	cout<<ans<<endl;
 	 p=m;
 	int ans2=0;
 	for(i=0;i<n;i++)
 	ans2+=pow(abs(a[i]-p),2);
 	cout<<min(ans1,ans2)<<endl;
 }
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
 
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
 
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹ここにすきなもじをいれてね！╹) */
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/* (๑╹最強╹) */


int main() {
   int ans = 0;
   int N;
   cin >> N;
   vector<int> vec(N);
   rep (i,N)
   {
      int a;
      cin >> a;
      if(i==0) vec.at(i) = a;
      else vec.at(i) = vec.at(i-1) + a;
   }
   int A = vec.at(N-1);
   vector<int> vec2(N);
   rep (i,N)
   {
      vec2.at(i) = abs(A - 2 * vec.at(i));
   }
   sort(vec2.begin(), vec2.end()); //配列変数vecを小さい順にソートする
   ans = vec2.at(0);
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int l,r; cin >> l >> r;
    int minnum = INF;
    int mod = 0;
    if((r-l)>=2019){
        cout << 0 << endl;
    }else{
        for(int i = l; i < r; i++){
            for(int j = i+1; j <= r; j++){
                int ll = i % 2019;
                int rr = j % 2019;
                mod = (ll*rr) % 2019;
                minnum = min(minnum,mod);
            }
        }
        cout << minnum << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)

items = []

def knapsack(n):
    for i in range(0, n + 1):
        res = 0
        for v, w in items:
            if i >= w:
                res = max(res, dp[i - w] + v)
        dp[i] = res
    return dp[n]

line = input()
E, W = list(map(int, line.split()))
for _ in range(0, E):
    line = input()
    v, w1 = list(map(int, line.split()))
    items += [[v, w1]]
dp = [0] * (W + 1)
used = [False] * E
knapsack(W)
print(dp[W])



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

int main() {
    int n,m,temp;
    cin>>n>>m;
    vector<bool> a(n+1,true);
    rep(i,m) {
        cin>>temp;
        a[temp]=false;
    }
    vector<ll> dp(n+1,0);
    dp[0]=1;
    if (a[1]) dp[1]=1;
    for (int i=2; i<=n; i++) {
        if (a[i-1]) dp[i]+=dp[i-1];
        if (a[i-2]) dp[i]+=dp[i-2];
        dp[i]%=MOD;
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
using namespace std;
vector<int> gra[100001];
int ans,k,a[100001];
int dfs(int p)
{
	int lev=1,i;
	for(i=0;i<gra[p].size();++i)
	{
		lev=max(lev,dfs(gra[p][i])+1);
	}
	if(lev==k && p!=1 && a[p]!=1)
	{
		++ans;
		lev=0;
	}
	return lev;
}
int main()
{
	int i,n;
	scanf("%d%d%d",&n,&k,&a[1]);
	ans=(a[1]==1?0:1);
	for(i=1;i<=n;++i)
	{
		gra[i].clear();
	}
	for(i=2;i<=n;++i)
	{
		scanf("%d",&a[i]);
		gra[a[i]].push_back(i);
	}
	dfs(1);
	printf("%d\n",ans);
	return 0;
}
/*
3 1
2 3 1
*/
/*
4 2
1 1 2 2
*/
/*
8 2
4 1 2 3 1 2 3 4
*/


Measured memory_bytes: 12288
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

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

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    PUTS(n * n * n);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int main(){
	int n, k;
	cin >> n >> k;
	ll a[n];
	ll dp[n+1][k+1];
	FOR0(i,n) cin >> a[i];
	mst0(dp);
	dp[0][0] = 1;
	int mod = 1e9 + 7;
	int lim = 0;
	FOR1(i,n){
		int sum = dp[i-1][0];
		lim += a[i-1];
		FOR0(j,k+1){
			if (lim < j) break;
			if(a[i-1]<j) sum -= dp[i-1][j-a[i-1]-1];
	      	if(sum<0) sum+=mod;
	      	dp[i][j] = sum;
	      	// cout << dp[i][j] << " ";
	      	if(j!=k) sum += dp[i-1][j+1];
	      	sum%=mod;
		}
		// cout << endl;
		// cout << dp[i][0] << endl;
	}
	cout << dp[n][k] << endl;

}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 2000
#define INF 1'000'000'000
int h, w;
int a[N][N];
bool vis[N][N];
bool flood(vector<pair<int, int>>& to_vis, int di, int dj, int d) {
    memset(vis, false, sizeof vis);
    queue<pair<int, int>> q;
    for(auto& p : to_vis) {
        vis[p.first][p.second] = true;
        q.push(p);
    }
    while(not q.empty()) {
        int i = q.front().first, j = q.front().second;
        q.pop();
        if(0 <= i + di and i + di < h and not vis[i + di][j]) {
            vis[i + di][j] = true;
            q.push({i + di, j});
        }
        if(0 <= j + dj and j + dj < w and not vis[i][j + dj]) {
            vis[i][j + dj] = true;
            q.push({i, j + dj});
        }
    }
    int min_i = INF, max_i = 0;
    int min_j = INF, max_j = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(vis[i][j]) {
                min_i = min(min_i, a[i][j]);
                max_i = max(max_i, a[i][j]);
            } else {
                min_j = min(min_j, a[i][j]);
                max_j = max(max_j, a[i][j]);
            }
        }
    }
    return max_i - min_i <= d and max_j - min_j <= d;
}
template <typename T, typename Function>
T bsearch(T L, T R, const Function& can, bool left_feasible = true) {
#ifdef DEBUG
    using actual_type = typename callable_traits<Function>::function_type;
    using expected_type = typename callable_traits<bool(T)>::function_type;
    static_assert(is_same<actual_type, expected_type>::value, "bsearch 'can' must be bool(T)");
#endif
    T& feasible = left_feasible ? L : R;
    T& infeasible = left_feasible ? R : L;
    while(R - L > 1) {
        T M = (L + R) / 2;
        (can(M) ? feasible : infeasible) = M;
    }
    return feasible;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w;
    int maxi = 0, mini = INF;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> a[i][j];
            maxi = max(maxi, a[i][j]);
            mini = min(mini, a[i][j]);
        }
    }
    cout << bsearch(-1, maxi - mini, [&](int d) {
        vector<pair<int, int>> to_vis;
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(maxi - a[i][j] > d) {
                    to_vis.push_back({i, j});
                }
            }
        }
        return flood(to_vis, 1, -1, d)
            or flood(to_vis, 1, 1, d)
            or flood(to_vis, -1, -1, d)
            or flood(to_vis, -1, 1, d);
    }, false) << endl;
    return 0;
}




Measured memory_bytes: 71236
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N,i,a[100000],l,cnt;
bool used[100000];
inline void solve(){
  IN(N);
  REP(i,N){
    IN(a[i]);
    a[i]--;
  }
  i=0;
  cnt=1;
  for(;;){
    l=a[i];
    if(l==1){
      OUT(cnt);
      return;
    }else if(used[l]){
      OUT(-1);
      return;
    }
    cnt++;
    used[l]=true;
    i=l;
  }
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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

int main()
{
    int n;
    cin>>n;
    string ans="No";
    for(int i=1;i<=9;i++)
    {
        if(n%i==0&&n/i<=9)
        {
            ans="Yes";
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256