akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        s: chars
    }
    let mut count = vec![0;4];
    for i in 0..s.len() {
        if s[i]=='N' {
            count[0]+=1;
        }
        if s[i]=='S' {
            count[1]+=1;
        }
        if s[i]=='W' {
            count[2]+=1;
        }
        if s[i]=='E' {
            count[3]+=1;
        }
    }
    let mut ans = true;
    if count[0]==0 {
        if count[1]!=0 {
            ans = false;
        }
    }
    if count[1]==0 {
        if count[0]!=0 {
            ans = false;
        }
    }
    if count[2]==0 {
        if count[3]!=0 {
            ans = false;
        }
    }
    if count[3]==0 {
        if count[2]!=0 {
            ans = false;
        }
    }
    if ans {
        println!("Yes");
    }else{
        println!("No");
    }
}

Measured memory_bytes: 4352
n = int(input())
h_list = list(map(int,input().split()))
tmp_list = []
count = 0
for i in range(len(h_list)-1):
    if h_list[i] >= h_list[i+1]:
        count += 1
    else:
        tmp_list.append(count)
        count = 0
tmp_list.append(count)
print(max(tmp_list))

Measured memory_bytes: 14228
from collections import deque

N, Q = map(int, input().split())  # N個の頂点, Q回の操作

# 辺を受け取る
graph = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)

count = [0] * N
# その頂点に対して与えられるカウントは伝播する
for i in range(Q):  # Q個の操作について
    p, x = map(int, input().split())
    # ある頂点を根とする部分木には、今現在のcountが全て伝播していく
    count[p-1] += x

q = deque([0])  # 開始のノード
flag = [False] * N

while len(q):
    v = q.pop()
    flag[v] = True  # 部分木の根を到達済みにする

    for e in graph[v]:  # vを根にもつノード全てに操作をする
        # graphは子のみを格納するのではなく、そのノードから出ている辺を
        # 親とか子供とか関係なく全て格納してしまうため、親の方向に
        # 対して伝播をしないようにflagで管理する
        if flag[e]:  # 頂点eがvの親であればスルー
            continue
        # eはvの子供であることが確定する
        count[e] += count[v]  # 親の値を伝播させていく
        q.append(e)

print(*count)


Measured memory_bytes: 56172
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int n,m;
	while(cin >> n >> m){
		if(n==0 && m==0 || cin.eof()) break;
		vector< int> cr(n);
		rep(i,n) cr[i]=i+1;
		int sta =0;
		while(1){
			int zn = cr.size();
//			rep(z,zn) cout << cr[z] << " "; cout << endl;
			if(zn==1) break;
			int ar = (sta + m -1 ) % zn ;
			cr.erase(cr.begin()+ar);
			sta = ar;
		}
		cout << cr[0] << endl;
	
	}
	return 0;
	
}

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

int main(){
    long long N,M,A,B,ans=0;
    cin >> N >> M;
    vector<long long> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    vector<long long> flag(N);
    for(int j=0;j<M;j++){
        cin >> A >> B;
        if(H[A-1]>=H[B-1]){
            flag[B-1]++;
        }
        if(H[A-1]<=H[B-1]){
            flag[A-1]++;
        }
    }
    for(int k=0;k<N;k++){
        if(flag[k]==0)
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int main()
{
    int n,h;
    cin >> n >> h;
    vector<int> a(n),b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a.rbegin(),a.rend()),sort(b.rbegin(),b.rend());
    int res;
    for(res = 0; res < n && b[res] > a[0] && 0 < h; res++) h -= b[res];
    if(h > 0) res += (h+a[0]-1)/a[0];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
import collections

N = int(input())
#print(N)
W = [input() for i in range(N)]
#print(W)

c = collections.Counter(W)

cnt = 0
for i in range(N-1):
    #print(i)
    if (W[i][-1] == W[i+1][0]):
        #print("yes")
        cnt += 1
    else:
        break

if (len(c.keys())) == N and (cnt == N-1):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3316
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

int main()
{
	string S, T;
	cin >> S >> T;

	int res = 0;
	rep(i, 3)if (S[i] == T[i])res++;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main{ 
        public static void main(String[] args){
            int i=0,j,k,l,m,o=0,p=0;
            int a[][];
            int q[][][];
            a = new int[1000][1000];
            q = new int[1000][10][10];
                Scanner n = new Scanner(System.in);
                int c = n.nextInt();
                while(i<c){
                     a[i][0] = n.nextInt();
                     for(j=1;j<4;j++){
                         a[i][j]=n.nextInt();
                     }
                     i++;
                }
                i=0;
                while(i<4){
                    for(m=0;m<c;m++){
                        if(((a[m][0])-1)==i){
                            q[i][(a[m][1]-1)][(a[m][2]-1)]+=a[m][3];
                        }
                    }
                        for(k=0;k<3;k++){
                            for(l=0;l<10;l++){
                                 System.out.print(" " + q[i][k][l]);
                            }
                            System.out.printf("\n");
                        }
                        if(i==3){
                            System.exit(0);
                        }else{
                        System.out.println("####################");
                        }
                     i++;
                }
        }
    }


Measured memory_bytes: 34484
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int t, int n) {
    int cnt = 0;
    vector<vector<bool>> used(1000, vector<bool>(1000, false));
    int dx[] = {0, 0, -1, -1, 1, 1};
    int dy[] = {-1, 1, -1, 0, 0, 1};
    set<PII> block;
    PII start;
    REP(_, n) {
        int x, y;
        scanf("%d%d", &x, &y);
        used[x + 500][y + 500] = true;
    }
    int x, y; scanf("%d%d", &x, &y);
    start = MP(x + 500, y + 500);
    queue<pair<PII, int>> q;
    q.push(MP(start, 0));
    while (!q.empty()) {
        auto buf = q.front(); q.pop();
        PII now = buf.first;
        if (buf.second > t) continue;
        if (used[now.first][now.second]) continue;
        used[now.first][now.second] = true;
        cnt++;
        REP(i, 6) {
            int nx = now.first + dx[i];
            int ny = now.second + dy[i];
            //if (!inside(MP(nx, ny))) continue;
            q.push(MP(MP(nx, ny), buf.second + 1));
        }
    }
    cout << cnt << endl;
    return;
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n >> m, n) {
        solve(n, m);
        //return 0;
    }
}

Measured memory_bytes: 3324
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if not (a % 3 and b % 3 and (a + b) % 3):
        print("Possible")
    else:
        print("Impossible")
    return

#B
def B():
    _, n = LI()
    l = LI()
    l.sort(reverse = True)
    print(sum(l[:n]))
    return

#C
def C():
    n = II()
    a = LI()
    for i in range(n-1):
        a[i + 1] += a[i]
    maxa = a[-1]
    ans = inf
    for i in range(n-1):
        ans = min(ans, abs(2 * a[i] - maxa))
    print(ans)
    return

#D
def D():
    n = II()
    edg = [[] for i in range(n)]
    for _ in range(n - 1):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
    rank = [0] * n
    q = deque()
    q.append(0)
    rank[0] = 1
    while q:
        p = q.pop()
        for i in edg[p]:
            if rank[i]:
                continue
            rank[i] = rank[p] + 1
            q.appendleft(i)
    k = 2
    q = deque()
    q.append(n - 1)
    while q:
        p = q.pop()
        for i in edg[p]:
            if rank[i] < rank[p]:
                if rank[i] <= k:
                    a = p
                    break
                q.appendleft(i)
                k += 1
    ans1 = 1
    ans2 = 1
    check = [True] * n
    q = deque()
    q.append(a)
    check[a] = False
    while q:
        p = q.pop()
        for i in edg[p]:
            if rank[i] > rank[p]:
                q.append(i)
                ans1 += 1
                check[i] = False
    q = deque()
    q.append(0)
    check[0] = False
    while q:
        p = q.pop()
        for i in edg[p]:
            if check[i]:
                q.append(i)
                ans2 += 1
                check[i] = False
    print(["Fennec", "Snuke"][ans1 >= ans2])
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 60852
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="ARC"){
    	cout<<"ABC";
	}
	else{
		cout<<"ARC";
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

string s;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    if(s.lg>=4 && s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I') cout << "Yes";
    else cout << "No";
}


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

min_count = len(str(n))
for i in range(1, int(n**0.5) + 1):
  if n % i == 0:
    a = i
    b = int(n / i)
    if len(str(a)) < len(str(b)):
      count = len(str(b))
    else:
      count = len(str(a))
    if count < min_count:
      min_count = count
print(min_count)

Measured memory_bytes: 9328
main = do
  [n, a, b, c, d] <- fmap (fmap read . words) getLine
  print $ f n a b c d

f n a b c d = min (g n a b) (g n c d)
g n amount price 
  | n `mod` amount == 0 = n `div` amount * price
  | otherwise = (n `div` amount + 1) * price


Measured memory_bytes: 3648
#include<cstdio>
int n,m,h,w;
int main()
{
	scanf("%d%d%d%d",&n,&m,&h,&w);
	if(n%h)
	{
		printf("Yes\n");
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
				printf("%d ",i%h?99999:(-100000*(h-1)));
			printf("\n");
		}
	}
	else if(m%w)
	{
		printf("Yes\n");
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
				printf("%d ",j%w?99999:(-100000*(w-1)));
			printf("\n");
		}
	}
	else printf("No\n");
}

Measured memory_bytes: 1920
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N,M;
vector<vector<int>> adj;
int a[50],b[50];

LL ans = 0;

void solve(){
	for(int i=0;i<M;i++){
		//a[i],b[i]間を切断して考える
		queue<int> q;
		q.push(1);
		vector<int> used(N+1,0);
		used[1] = 1;
		while(!q.empty()){
			int now = q.front();q.pop();
			for(int next : adj[now]){
				if(used[next]==0){
					if((a[i]==now && b[i]==next)
					|| (a[i]==next && b[i]==now)){
						continue;
					}
					used[next] = 1;
					q.push(next);
				}
			}
		}
		// printf("%d,%d:\n",a[i],b[i]);
		// for(int j=1;j<=N;j++){
		// 	printf("used[%d]=%d,",j,used[j]);
		// }
		// cout << endl;
		for(int j=1;j<=N;j++){
			if(used[j]==0){
				ans++;
				break;
			}
		}
	}
}
 
int main(){
    cin >> N >> M;
    adj = vector<vector<int>>(N+1);
	for(int i=0;i<M;i++){
		int a_input,b_input;
		cin >> a_input >> b_input;
		adj[a_input].push_back(b_input);
		adj[b_input].push_back(a_input);
		a[i] = a_input;
		b[i] = b_input;
	}
 
    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;


int main() {

	ll n, k;
	cin >> n >> k;

	n = n % k;

	ll m = min(n, k-n);

	cout << m<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int x,y;
		int counter = 1;
		while(sc.hasNext()) {
			x= sc.nextInt();
			y= sc.nextInt();
			while(x < 0 || 10000 < x);
			while(y < 0 || 10000 < y);
			if(x == 0 && y == 0)
				break;
			if(counter < 3000) {
				if(x <= y)
					System.out.println(x + " " + y);
				if(x > y)
					System.out.println(y + " " + x);
				counter++;
			}
		}
	}


}



Measured memory_bytes: 35120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){

  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC";
  else cout << "ABC";

  cout << endl;

  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, t, a, x, y;
signed main() {
	cin >> n >> t >> a;
	for (int i = 0; i < n - 1; i++) {
		cin >> x >> y;
		if (t <= x) {
			if (a <= y) {
				t = x;
				a = y;
			}
			else {
				a = (a + y - 1) / y * y;
				t = a / y * x;
			}
		}
		else {
			if (a <= y) {
				t = (t + x - 1) / x * x;
				a = t / x * y;
			}
			else {
				t = max((t + x - 1) / x, (a + y - 1) / y)*x;
				a = max((t + x - 1) / x, (a + y - 1) / y)*y;
			}
		}
	}
	cout << t + a << endl;
	endre;
}


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

using namespace std;
typedef long long ll;
int N;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int ans = 0;
    cin >> N;
    for(int i = 1; i <= N; i++){
        int a; cin >> a;
        if((i%2 == 1) &&(a%2 == 1)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
line = list(input())
n = len(line)
if n%2==1:
    a = int(n/2)
    a_count = 0
    for i in range(0,n-a-1):
        if line[i] != line[n-i-1]:
            a_count += 1

    print(a_count)
else:
    b = int(n/2)
    b_count = 0
    for t in range(0,n-b):
        if line[t] != line[n-1-t]:
            b_count+=1
    print(b_count)

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

int main()
{
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3672
#096_C
h,w=map(int,input().split())
s=['.'+input()+'.' for _ in range(h)]
s=['.'*(w+2)]+s+['.'*(w+2)]
flg=True
for i in range(1,h+1):
    for  j in range(1,w+1):
        if s[i][j]=='#':
            if all(s[i+_i][j+_j]=='.' for _i,_j in [(1,0),(0,1),(-1,0),(0,-1)]):
                flg=False
                break

print('Yes' if flg else 'No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>
#include <math.h>
#include<assert.h>

typedef long long ll;
#define rep(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
ll POW(ll a, ll b){ll c=1,i;rep(i,0,b,1)c*=a;return c;}


int main(void){
    ll d,n;
    scanf("%lld %lld",&d,&n);
    if(n==100)n++;
    ll ans=pow(100,d)*n;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2244
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;

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

  int ans = N * N;

  cout << ans << endl;
  return 0;
}

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

int main(void) {
  int n, cou = 0;
  cin >> n;
  int arr[n] = {0}, brr[n] = {0};
  for (int i = 0; i < n; i++) {
    cin >> arr[i] >> brr[i];
  }
  for (int i = 0; i < n; i++) {
    cou += brr[i] - arr[i] + 1;
  }
  cout << cou << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
int n,k,q,ans=0;
  cin>>n>>k>>q;
  vector<int> p(n,0);
  REP(i,q){
    int a;
    cin>>a;
    p[a-1]++;
  }
  REP(i,n){
  if(p[i]>-k+q)cout<<"Yes\n";
    else cout<<"No\n";
  }

  return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
struct unifnd{
  VI ht,pr;
  in fnd(in a){
    in ta=a;
    while(a!=pr[a])a=pr[a];
    in tt=ta;
    while(ta!=a){
      tt=pr[ta];
      pr[ta]=a;
      ta=tt;
    }
    return a;
  }
  void uni(in a, in b){
    a=fnd(a);
    b=fnd(b);
    if(a==b)return;
    if(ht[b]<ht[a])swap(a,b);
    pr[a]=b;
    ht[b]+=(ht[a]==ht[b]);
  }
  void ini(in n){
    ht.resize(n);
    pr.resize(n);
    forn(i,n){
      ht[i]=0;
      pr[i]=i;
    }
  }
};
unifnd tfd;
in n;
vector<pair<in,in> > bx,by;
vector<pair<in,pair<in,in> > > egs;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n;
  tfd.ini(n);
  in tx,ty;
  forn(z,n){
    cin>>tx>>ty;
    bx.PB(MP(tx,z));
    by.PB(MP(ty,z));
  }
  sort(all(bx));
  sort(all(by));
  forn(z,n-1){
    egs.PB(MP(bx[z+1].first-bx[z].first,MP(bx[z].second,bx[z+1].second)));
    egs.PB(MP(by[z+1].first-by[z].first,MP(by[z].second,by[z+1].second)));
  }
  sort(all(egs));
  in sm=0;
  in hv=0;
  in nxt=0;
  while(hv<n-1){
    if(tfd.fnd(egs[nxt].second.first)==tfd.fnd(egs[nxt].second.second)){
      ++nxt;
      continue;
    }
    tfd.uni(egs[nxt].second.first,egs[nxt].second.second);
    sm+=egs[nxt].first;
    ++hv;
    ++nxt;
  }
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 14560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll INF = 1LL << 58;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};
//x以下の要素への最小index
template <class T> int former(const vector<T> &v, T x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> int latter(const vector<T> &v, T x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T1>
void cout_vec(const int n, vector<T1> &vec1){
  rep(i, n){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
ll comb(ll n,ll k){
    ll ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
ll gcd(ll a,ll b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    rep(i,3){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int x,y;
    x=a[2]-a[0];
    y=a[2]-a[1];
    if(x%2==0 && y%2==0){
        cout<<x/2+y/2<<endl;
    }else if(x%2==1 && y%2==0){
        cout<<1+(x+1)/2+y/2<<endl;
    }else if (x%2==0 && y%2==1){
        cout<<1+x/2+(y+1)/2<<endl;
    }else{
        cout<<(x-1)/2+(y-1)/2+1<<endl;
    }
}

Measured memory_bytes: 256
N = int(input())
# (先頭A,末尾B)を表すリストを作る
L = [[0 for i in range(10)]for i in range(10)]

for i in range(1,N+1):
  #str変換で先頭と末尾を取る
  A = int(str(i)[0])
  B = int(str(i)[-1])
  #該当するリストに足す
  L[A][B] += 1
  
ans = 0

#リストの反転した形とかける
for i in range(10):
  for j in range(10):
    ans += L[i][j] * L[j][i]

print(ans)

Measured memory_bytes: 3064
#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 rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    int N,K;
    SCD2(N,K);
    VI hi;
    VSCD(hi,N);
    sort(hi.begin(),hi.end());

    int ans = 2100000000;
    int ind = 0;
    while(true){
        if (ind + K - 1 >= N) break;
        ans = min(ans,hi[ind + K - 1] - hi[ind]);
        ind++;
    }

    PRINTD(ans);
}

Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int len[10] = {0,2,5,5,4,5,6,3,7,6};
    int len_max[10] = {0};
    int prev[10001] = {0};
    int dp[100001];
    for(int i = 0; i < M; i++){
        int A;
        cin >> A;
        len_max[len[A]] = max(len_max[len[A]], A);
    }
    for(int i = 0; i <= N; i++){
        dp[i] = -1;
    }
    dp[0] = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 1; j < 10; j++){
            if(i-j >= 0 && dp[i-j] >= 0 && len_max[j] != 0){
                if(dp[i] <= dp[i-j]+1){
                    if(dp[i] == dp[i-j]+1) prev[i] = max(prev[i], len_max[j]);
                    else prev[i] = len_max[j];
                    dp[i] = dp[i-j]+1;
                }
            }
        }
    }
    
    int idx = N;
    
    while(true){
        cout << prev[idx];
        idx -= len[prev[idx]];
        if(idx == 0) break;
    }
    
    cout << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int A[401];
ll B[401];
ll dp[401][401];

ll sagasu(int a, int b) {
	if (dp[a][b]) return dp[a][b];
	if (a == b) return 0;
	ll ret = 1e18;
	rep(i, b - a) {
		ret = min(ret, sagasu(a, a + i) + sagasu(a + i + 1, b));
	}
	ret += B[b] - B[a - 1];
	dp[a][b] = ret;
	return dp[a][b];
}

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


	int N;
	cin >> N;
	rep1(i, N) cin >> A[i];

	rep1(i, N) B[i] = B[i - 1] + A[i];

	co(sagasu(1, N));

	Would you please return 0;
}

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

const ll md = 1000000007;

int main(){
  ll n;
  cin >> n;
  
  map<ll,int> mp;
  
  for(int i=0; i<n; i++){
    ll x;
    cin >> x;
    
    mp[x]++;
    if(mp[x]>2 || mp[0] > 1 || x%2 == n%2){
      cout << 0 << endl;
      return 0;
    }
  }
  
  ll ans = 1;
  for(int i=0; i<n/2; i++){
    ans *= 2;
    ans %= md;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>

typedef struct{
int v[100];
int k;
} Roll;

void stack(int);
int push();
void dfs();
void visit(int);

char color[101];
int top=0;
int n;
Roll A[101];
int f[101];
int d[101];
int time;
int main(){
  int i,j;
  int T;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&T);
    scanf("%d",&A[i].k);
    for(j=0;j<A[i].k;j++){
      scanf("%d",&A[i].v[j]);
    }
  }
  dfs();
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }

  
  return 0;
}

void dfs(){
  int i;
  for(i=1;i<=n;i++){
    color[i]='w';
    d[i]=0;
    f[i]=0;
  }
  time=0;
  
  for(i=1;i<=n;i++){
    if(color[i]=='w')
      visit(i);
  }
}
void visit(int u){
  int i;
  color[u]='g';
  d[u]=++time;
  for(i=0;i<A[u].k;i++){
    if(color[A[u].v[i]]=='w')
      visit(A[u].v[i]);
  }
  color[u]='b';
  f[u]=++time;
}



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

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

    int cnt;
    cnt = b / a;
    if(c < cnt) cout << c << endl;
    else cout << cnt << endl;
    return 0;
}

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

int64_t luc(int N){
  int64_t a=2,b=1,c;
  if(N==0) return 2;
  if(N==1) return 1;
  for(int i=1;i<N;i++){
    c=a+b;
    if(i%2==1) a=c;
    else b=c;
  }
  return c;
}

int main(){
  int N;
  cin>>N;
  cout<<luc(N)<<endl;
}

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

int main()
{
string s,c;
cin>>s;
cin>>c;
int flag=0;
if(c.length()!=s.length()+1){
    flag=1;
}
else{
    for(int i=0;i<s.length();i++){
        if(s[i]!=c[i]){
            flag=1;
        }
    }
}
if(flag==0){
    cout<<"Yes\n";
}
else{
    cout<<"No\n";
}
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << b * (t/a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, M, D;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> D;

    double ans;
    if (D == 0) ans = 1.0 * (M - 1) / N;
    else ans = 2.0 * (N - D) / N / N * (M - 1);

    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
main :: IO ()
main = do
    a <- readLn
    b <- readLn
    c <- readLn
    x <- readLn
    print $ length
        [ ()
        | s <- [0 .. a]
        , t <- [0 .. b]
        , u <- [0 .. c]
        , 500 * s + 100 * t + 50 * u == x
        ]



Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int maxn = 100005;
string s;
int d;
ll dp[10005][2][100];
ll dfs(int now, int lim, int m) {
	if (now == -1) {
		return m == 0;
	}
	if (~dp[now][lim][m]) {
		return dp[now][lim][m];
	}
	int up = lim ?  s[now] - '0' : 9;
	ll ans = 0;
	for (int i = 0 ; i <= up ; i++) {
		ans += dfs(now - 1, lim && (i == up), (m + i) % d);
		ans %= mod;
	}
	return dp[now][lim][m] = ans;
}
void go() {
	cin >> s >> d;
	reverse(all(s));
	memset(dp, -1, sizeof(dp));
	cout << (dfs(s.size() - 1, 1, 0) + mod - 1) % mod << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        e: usize,
        t: usize,
        v: [usize; n]
    }
    let mut ps = vec![0; n];
    let mut p = 0;
    for i in 0..n {
        while 2 * v[i] > t + 2 * v[p] {
            p += 1;
        }
        ps[i] = p;
    }
    let mut dp = vec![usize::max_value(); n + 1];
    dp[0] = 0;
    dp[1] = t;
    let mut m = i64::max_value() >> 2;
    for i in 1..n {
        for j in ps[i - 1]..ps[i] {
            m = min(m, dp[j] as i64 - 2 * v[j] as i64);
        }
        dp[i + 1] = min(dp[ps[i]] + t, (m + 2 * v[i] as i64) as usize);
    }
    println!("{}", dp[n] + e);
}


Measured memory_bytes: 6396
X = input()
N = len(X)

ans = 0
nsta = 0
for i in range(N):
    if X[i] == "T":
        if nsta > 0:
            nsta -= 1
            ans +=  1
    if X[i] == "S":
        nsta += 1

print( N - 2 * ans)



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

using namespace std;

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

    long long mod = 1000000000 + 7;

    long long p1 = 1;
    for (long long i = 0; i < N; i++) {
        p1 = (p1 * 9) % mod;
    }
    long long p2 = 1;
    for (long long i = 0; i < N; i++ ) {
        p2 = (p2 * 10) % mod;
    }
    long long p3 = 1;
    for (long long i = 0; i < N; i++) {
        p3 = (p3 * 8) % mod;
    }
    long long ans = ((p2 + p3) % mod - 2 * p1 % mod) % mod;
    if (ans < 0) ans += mod;
    cout << ans << endl;
}


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

ll nCr(int n, int r, int dup){
    int nn;
    ll* a = (ll*)calloc(n,sizeof(ll));
    ll retv;
    nn = (dup) ? (n+r-1) : n;
    if ( nn-r < r ) r = nn-r;
    if ( r == 0 ) return 1;
    if ( r == 1 ) return nn;
    for ( int i=1; i<r; i++ ) a[i] = i+2;
    for ( int i=3; i<=nn-r+1; i++ ) {
        a[0] = i;
        for ( int j=1; j<r; j++ ) a[j] += a[j-1];
    }
    retv = a[r-1];
    free(a);
    return retv;
}

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    
    
    if(R == 1 && G == 1 && B == 1){
        cout << nCr(N+1,2,1) << endl;
        return 0;
    }
	  
    ll ans = 0;
    for(int i=0;R*i<=3000;i++){
        for(int j=0;R*i+G*j<=3000;j++){
            for(int k=0;R*i+G*j+B*k<=3000;k++){
                if(R*i+G*j+B*k == N)
                    ans++;
            }
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  lli N,K;
  cin >> N >> K;
  vector<lli> H(N);
  rep(i, N)
    cin >> H[i];
  lli ans =0;
  
sort(H.begin(), H.end());
  
  if(N<K){
  cout << 0 << endl;
    return 0;
  }
  else
  {
  rep(i, K){
  H[N-i-1]=0;
  }
    
  rep(i, N)
    ans+=H[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
using namespace std;
int fact(int n) {
	if (n == 0)return 1;
	return n * fact(n - 1);
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int a[114514];
signed main() {
	int n;
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int ansa = 0, ansb = 0, cnt;
	for (int i = 0; i < n; i++) {
		if (a[i] == a[i + 1]) {
			ansa = a[i];
			cnt = i;
			break;
		}
	}
	if (ansa == 0||cnt+2>=n-1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = cnt+2; i < n; i++) {
		if (a[i] == a[i + 1]) {
			ansb = a[i];
			break;
		}
	}
	cout << ansa * ansb << endl;
	getchar(); getchar(); return 0;
}


Measured memory_bytes: 1024
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n;
    cin>>n;
    ll s[100];
    rep(i,100) s[i]=0;
    rep(i,9){
        rep(j,9){
            if(s[(1+i)*(1+j)]==0) s[(1+i)*(1+j)]=1;
        }
    }
    if(s[n]==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main() {
  string s;
  cin >> s;
  for( int i=1;i<s.size()-1;i++){
    string anos = s.substr(0,s.size() - 1 - i);
    if( anos.size()%2 != 0 ){
      continue;
    }
    //cout << anos << endl;
    //cout << anos.substr(0,anos.size()/2) << " " << anos.substr(anos.size()/2) << endl;
    if( anos.substr(0,anos.size()/2) == anos.substr(anos.size()/2) ){
      cout << anos.size() << endl;
      return 0;
    }
  } 
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    map<ll,ll> m;
    REP(i, N){
        ll a;
        cin >> a;
        m[a]++;
    }
    vector<ll> l;
    for(auto&& i:m){
        while(i.se!=0){
            if(i.se>=2)l.pb(i.fi);
            i.se/=2;
        }
    }
    RSORT(l);
    if(l.size()<2) pr(0);
    else pr(l[0]*l[1]);
}

Measured memory_bytes: 6528
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

type SortSlice []int

func (s SortSlice) Len() int {
        return len(s)
}

func (s SortSlice) Swap(i, j int) {
        s[i], s[j] = s[j], s[i]
}

func (s SortSlice) Less(i, j int) bool {
        return s[i] < s[j]
}

func reverseString(str string) string {
        buf := []rune(str)
        for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 {
                buf[i], buf[j] = buf[j], buf[i]
        }
        return string(buf)
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func intabs(a, b int) int {
        return int(math.Abs(float64(a - b)))
}

func main() {
        line := readBigLine()
        N := parseInt(line)

        a := make([]int, 110000)

        line = readBigLine()
        spl := strSprit(line)
        for i := 1; i <= N; i++ {
                a[i] = parseInt(spl[i-1])
        }

        summer := make([]int, 110000)

        allsum := 0

        for i := 0; i < N; i++ {
                summer[i] = intabs(a[i], a[i+1])
                allsum += summer[i]
        }
        summer[N] = intabs(a[N], a[0])
        allsum += summer[N]

        for i := 1; i <= N; i++ {
                printsum := allsum - summer[i-1] - summer[i]

                if i == N {
                        printsum += intabs(a[i-1], a[0])
                } else {
                        printsum += intabs(a[i-1], a[i+1])
                }

                fmt.Println(printsum)

        }

}


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

int main() {
vector<int>v(3);
cin>>v[0]>>v[1]>>v[2];
sort(v.begin(),v.end());
if(v[2]==v[0]+v[1])
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

class Binary_Indexed_Tree:

    def __init__(self,n):
        self.size=n
        self.graph=[0]*(n+1)

    def partially_sum(self,i):
        res=0
        while i>0:
            res+=self.graph[i]
            i-=i&-i
        return res

    def add_element(self,i,x):
        while self.size>=i:
            self.graph[i]+=x
            i+=i&-i
    
    def ret_sum(self,l,r):
        return self.partially_sum(r)-self.partially_sum(l)

n,q=map(int,input().split())
t=Binary_Indexed_Tree(n)

for i,x in enumerate(input().split(),1):
    t.add_element(i,int(x))

for _ in range(q):
    a,b,c=map(int,input().split())
    if a:
        print(t.ret_sum(b,c))
    else:
        t.add_element(b+1,c)

Measured memory_bytes: 67036
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int r;
	cin >> r;
	cout << r * r << endl;
}

Measured memory_bytes: 256