akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W,i,j;
  cin >> H >> W;
  vector<char> vec(H*W);
  
  for (i=0;i<H*W;i++) cin >> vec.at(i);
  for(i=0;i<W+2;i++) cout << "#";
  cout << endl;
  
  for (j=0;j<H;j++){
    cout << "#";
    for (i=0;i<W;i++){
      cout << vec.at(j*W+i);
    }
    cout<< "#";
    cout << endl;
  }
  for(i=0;i<W+2;i++) cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	boolean[] prime;
	int[] sum;

	void run() {
		Scanner sc = new Scanner(System.in);

		era(1000000);

		while (sc.hasNext()) {
			int n = sc.nextInt();
			System.out.println(sum[n]);
		}

		sc.close();
	}

	public void era(int n) {
		prime = new boolean[n + 1];
		sum = new int[n + 1];

		Arrays.fill(prime, true);
		prime[0] = prime[1] = false;

		int count = 0;

		for (int i = 2; i <= n; i++) {
			if (prime[i]) {
				count++;
				for (int j = i + i; j <= n; j += i) {
					prime[j] = false;
				}
			}
			sum[i] += count;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 26400
#include <bits/stdc++.h>
using namespace std;
const int sz=105;
long long dp[sz][sz];
int n;
int have[sz];
vector<int> v;
int sieve[sz];
vector<int> d;

long long solve(int idx,int sofar){
    long long &ret=dp[idx][sofar];
    if(~ret) return ret;
    if(sofar==75) return ret=1;
    if(!idx) return ret=0;
    int curr=v[idx];
    ret=solve(idx-1,sofar);
    for(int i=2;i<=75;i++){
        if(have[curr]<i-1) break;
        if((sofar*i)>75||i==1) continue;
        ret+=solve(idx-1,sofar*i);
    }
    return ret;
}


int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
    for(int i=1;i*i<=75;i++){
        if(75%i) continue;
        d.push_back(i);
        if(75/i!=i) d.push_back(75/i);
    }
    sort(d.begin(),d.end());
    //for(auto u:d) cout<<u<< " ";
    //puts("");
    v.push_back(0);
    for(int i=2;i<=100;i++){
        if(sieve[i]) continue;
        for(int j=2*i;j<=100;j+=i) sieve[j]=i;
        v.push_back(i);
    }
    for(auto u:v){
        if(!u) continue;
        int prime=u;
        while(u<=n){
            have[prime]+=n/u;
            u*=prime;
        }
        //cout<<prime<< " "<<have[prime]<<'\n';
    }
    memset(dp,-1,sizeof(dp));
    printf("%lld",solve(v.size()-1,1));
    return 0;
}


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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int arr[] = {a,b,c}; 
    sort(arr, arr+3); 
        cout<<arr[0] <<" "<<arr[1] <<" "<<arr[2]<< endl;
}


Measured memory_bytes: 3164
#include<iostream>
#include<string>
#include<algorithm>
 
using namespace std;
 
int main() {
	int H, W, N;
	string S, T;
	int x, y;
	cin >> H >> W >> N >> y >> x >> S >> T;
	x--, y--;
 
	int l = 0, r = W;//[l, r)の区間で存在したらセーフ
	if (S[N - 1] == 'L') {
		l++;
	}
	if (S[N - 1] == 'R') {
		r--;
	}
	for (int i = N - 2; i >= 0; i--) {
		if (T[i] == 'R') {
			l = max(0, l - 1);
		}
		if (T[i] == 'L') {
			r = min(W, r + 1);
		}
		if (S[i] == 'L') {
			l++;
		}
		if (S[i] == 'R') {
			r--;
		}
		if (r <= l) {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (!(l <= x && x < r)) {
		cout << "NO" << endl;
		return 0;
	}
 
	int d = 0, u = H;//[d, u)の区間で存在したらセーフ
	if (S[N - 1] == 'D'){
		u--;
	}
	if (S[N - 1] == 'U') {
		d++;
	}
	for (int i = N - 2; i >= 0; i--) {
		if (T[i] == 'U') {
			u = min(H, u + 1);
		}
		if (T[i] == 'D') {
			d = max(0, d - 1);
		}
		if (S[i] == 'D') {
			u--;
		}
		if (S[i] == 'U') {
			d++;
		}
		if (u <= d) {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (!(d <= y && y < u)) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 776
from copy import deepcopy
from math import ceil
d,g=map(int,input().split())
lst=[]
for i in range(1,d+1):
    p,c=map(int,input().split())
    lst.append([i*100,p,c])
ans=1145141919
for p in range(d):
    tmp=deepcopy(lst)
    tmp=tmp[:p]+tmp[p+1:]
    for i in range(2**(d-1)):
        point=0
        problem=0
        for j in range(d-1):
            if (i>>j)&1:
                point+=tmp[j][0]*tmp[j][1]+tmp[j][2]
                problem+=tmp[j][1]
        if point<g:
            extra=g-point
            if extra>lst[p][0]*lst[p][1]+lst[p][2]:
                continue
            if extra>lst[p][0]*lst[p][1]:
                ans=min(ans,problem+lst[p][1])
                continue
            problem+=ceil(extra/lst[p][0])
        ans=min(ans,problem)

print(ans)

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

int main() {
    int n, m;
    cin >> n >> m;
    int ans = (m * (m - 1) / 2) + (n * (n - 1) / 2);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int mp[205][205],r[205],n,m,R,ans=100000000;
int main(){
	cin>>n>>m>>R;
	for( int i = 1; i <= R; i++ ) scanf("%d", &r[i]);
	memset(mp,63,sizeof(mp));
	for( int i = 1,u,v,w; i <= m; i++ ){
		scanf("%d%d%d", &u, &v, &w);
		mp[u][v] = mp[v][u] = w;
	}
	for( int i = 1; i <= n; i++ ) mp[i][i] = 0;
	for( int k = 1; k <= n; k++ )
		for( int i = 1; i <= n; i++ )
			for( int j = 1; j <= n; j++ )
				mp[i][j] = min( mp[i][j], mp[i][k]+mp[k][j] );
	sort( r+1, r+R+1 );
	do{
		int res = 0;
		for( int i = 2; i <= R; i++ ) res += mp[r[i-1]][r[i]];
		ans = min( ans, res );
	}while( next_permutation( r+1, r+R+1 ) );
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
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,
        mut v: [usize; n]
    }
    v[0] -= 1;
    for i in 1..n {
        if v[i] > v[i - 1] {
            v[i] -= 1;
        }
        if v[i - 1] > v[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

int main(){
    string op;
    int a,b;
    cin >> a >> op >> b;
    while(op != "?"){
        if(op == "+") cout << a+b << endl;
        if(op == "-") cout << a-b << endl;
        if(op == "*") cout << a*b << endl;
        if(op == "/") cout << a/b << endl;
        
        cin >> a >> op >> b;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    cout << A[N - 1] - A[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define tms(x) ___ = x; while(___--)
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int ___;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
int w[300000];
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k = next<int>(), n = next<int>(), Max = -1;
	rep(i, 0, n)
	{
		cin>>w[i];
		if (i) Max = max(Max, abs(w[i]-w[i-1]));
	}
	Max = max(Max, w[0]+k-w[n-1]);
	cout<<k-Max<<endl;
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


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

flag = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1==d2:
        flag += 1
    else:
        flag = 0
    if flag==3:
        break

if flag==3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9100
# -*- coding: utf-8 -*-
#参考
#https://atcoder.jp/contests/abc175/submissions/15939709

import sys
from collections import defaultdict 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**31
N = int(readline())
ss = []
cs = []
for i in range(N):
    s, c = readline().decode().rstrip().split()
    ss.append(s)
    cs.append(int(c))
    
dp = defaultdict(lambda:INF)
rdp = defaultdict(lambda:INF)
p = 0

ved = set()
for s in ss:
    dp[s] = min(dp[s], cs[p])
    p += 1
    ved.add(s)

ans = INF

while True:
    dpp = defaultdict(lambda:INF)
    rdpp = defaultdict(lambda:INF)
    
    for k, v in dp.items():
        if k == k[::-1]:
            ans = min(ans, v)
        else:
            p = 0
            for s in ss:
                if k.startswith(s[::-1]):
                    ns = k[len(s):]
                    if v + cs[p] < dp.get(ns,INF):
                        dpp[ns] = min(dpp[ns], v + cs[p])
                elif s[::-1].startswith(k):
                    ns = s[::-1][len(k):]
                    if v + cs[p] < rdp.get(ns,INF):
                        rdpp[ns] = min(rdpp[ns], v + cs[p])
                p += 1
     
    for k, v in rdp.items():
        if k == k[::-1]:
            ans = min(ans, v)
        else:
            p = 0
            for s in ss:
                if k.startswith(s):
                    ns = k[len(s):]
                    if v + cs[p] < rdp.get(ns,INF):
                        rdpp[ns] = min(rdpp[ns], v + cs[p])
                elif s.startswith(k):
                    ns = s[len(k):]
                    if v + cs[p] < dp.get(ns,INF):
                        dpp[ns] = min(dpp[ns], v + cs[p])
                p += 1
    if len(dpp) + len(rdpp) == 0:
        break
    for k, v in dpp.items(): 
        dp[k] = v
    for k, v in rdpp.items(): 
        rdp[k] = v

print(ans if ans < INF else -1)

Measured memory_bytes: 74612
N = int(input())
d = {i:-1 for i in range(1, N+1)}
*l, = map(int, input().split())

MOD = 10**9+7
n = N+1
fac = [1]*(n+1)
rev = [1]*(n+1)
 
for i in range(1,n+1):
  fac[i] = i*fac[i-1]%MOD
  rev[i] = pow(fac[i], MOD-2, MOD)
 
comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD if a>=b else 0

for i, j in enumerate(l):
    if d[j] != -1:
        break
    d[j] = i

a = d[j]
b = N-i
for i in range(1, N+2):
    print((comb(N+1, i)-comb(a+b, i-1))%MOD)



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  VL xs(N*3);
  REP(i,N*3) cin >> xs[i];
  SORT(xs);

  LL ans = 0;
  for(int i=0;i<N;++i)
	ans += xs[3*N-2-i*2];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    int n,x;
    cin >> n >> x;
    int l[n];
    REP(i, n) scanf("%d ", &l[i]);
    int zahyo = 0, count = 1;
    for(int i=0; i<n; i++) {
        zahyo += l[i];
        if (zahyo <= x) {
            count++;
            //printf("%d %d\n", zahyo, count);
        }
    }
    OUT(count);
    return 0;
}

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

int main(){
  int N;
  vector<int> a(N);
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++){
    ans += a.at(i);
  }
  cout << ans - N << endl;
}

Measured memory_bytes: 3728
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long ans = 0;
    long mod = x % 11;
    if (mod == 0) {
      ans = x / 11 * 2;
    } else if (1 <= mod && mod <= 6) {
      ans = x / 11 * 2 + 1;
    } else {
      ans = x / 11 * 2 + 2;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <iostream>

int main(){
  int h,w,i,q;

  std::cin >> h>> w;
  while(h != 0 && w != 0){
    for (i = 0; i < h; i++) {
      /* code */
      for (q = 0; q < w; q++) {
        std::cout << "#";
      }
      std::cout << '\n';
    }
    std::cout  << '\n';

    std::cin >> h>> w;

  }


  return 0;
}



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

int main(void){
    string s;
    cin >> s;
    for(int i=0; i<3; i++){
        if(s[i] == '1'){
            s[i] = '9';
        }else if(s[i] == '9'){
            s[i] = '1';
        }
    }
    cout << s << endl;
    return 0;
}

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

int main(){
	long long n,a,b;cin >> n >> a >> b;
	
	long long count=0;
	if(n==1&&a==b) cout << "1";
	else if(n==1&&a!=b) cout << "0";
	else if(a>b) cout << "0";
	else {
		count=(n-2)*b-(n-2)*a+1;
		cout << count;
	}
	
	return 0;
} 

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		while (true) {
			final long d = sc.nextLong();
			
			if(d == 0){
				break;
			}
			
			final int n = sc.nextInt();
			final int m = sc.nextInt();

			long[] stores = new long[n + 1];
			stores[0] = 0;
			for (int i = 1; i < n; i++) {
				stores[i] = sc.nextLong();
			}
			stores[n] = d;

			Arrays.sort(stores);

			long sum = 0;

			for (int i = 0; i < m; i++) {
				long der = sc.nextLong();

				int start = 0;
				int end = n;

				while (end - start > 1) {
					int med = (start + end) / 2;

					if (stores[med] > der) {
						end = med;
					} else if (stores[med] < der) {
						start = med;
					} else {
						start = med;
						end = med;
					}
				}

				int ans = 0;

				if (start == end) {
					ans = start;
				} else {
					if (Math.abs(stores[start] - der) < Math.abs(stores[end]
							- der)) {
						ans = start;
					} else {
						ans = end;
					}
				}
				// System.out.println(stores[start] + " " + stores[end] + " " +
				// der + "" + ans);
				sum += (Math.abs(stores[ans] - der));
			}

			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
    map<int,int> a;
    int n, m;
    cin >> n;
    int d, t;
    for(int i=0; i<n; i++){
        cin >> d;
        a[d]++;
    }
    cin >> m;
    if(n<m){
        puts("NO");
        return 0;
    }
    for(int i=0; i<m; i++){
        cin >> t;
        if(a[t]) a[t]--;
        else{
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 12936
/* Binary Search Tree <Find> */
#include <stdio.h>
#include <stdlib.h>

struct node
{
    struct node *right;
    int key;
    struct node *left;
};

typedef struct node * NodePointer;

void init(void);
NodePointer makenode(int);
void insert(int, NodePointer);
void preorder(NodePointer);
void inorder(NodePointer);
int find(int, NodePointer);

NodePointer head, tail;

int main()
{
    char str[7];
    int i, n, k;

    init();
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%s", str);
        if(str[0] == 'i'){
            scanf("%d", &k);
            insert(k, head);
        } else if(str[0] == 'p'){
            inorder(head -> right);
            printf("\n");
            preorder(head -> right);
            printf("\n");
        } else{
            scanf("%d", &k);
            if(find(k, head -> right)){
                printf("yes\n");
            } else{
                printf("no\n");
            }
        }
    }
    return 0;
}

void init(void)
{
    head = makenode(-1);
    tail = makenode(-1);
    head -> right = tail;
    head -> left = tail;
}

NodePointer makenode(int k)
{
    NodePointer x;

    x = malloc(sizeof(struct node));
    x -> key = k;
    x -> left = x -> right = tail;

    return x;
}

void insert(int k, NodePointer p)
{
    if(k < p -> key){
        if(p -> left == tail){
            p -> left = makenode(k);
        } else{
            insert(k, p -> left);
        }
    } else{
        if(p -> right == tail){
            p -> right = makenode(k);
        } else{
            insert(k, p -> right);
        }
    }
}

void preorder(NodePointer node)
{
    if(node != tail){
        printf(" %d", node -> key);
        preorder(node -> left);
        preorder(node -> right);
    }
}

void inorder(NodePointer node)
{
    if(node != tail){
        inorder(node -> left);
        printf(" %d", node -> key);
        inorder(node -> right);
    }
}

int find(int k, NodePointer node)
{
    if(node == tail){
        return 0;
    }

    if(node -> key == k){
        return 1;
    } else if(node -> key < k){
        return find(k, node -> right);
    } else{
        return find(k, node -> left);
    }
}


Measured memory_bytes: 14196
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, val;
    vector<int> parity = {0, 0};
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> val;
        parity[val%2] +=1 ;
    }
    if (parity[1] >= 1) {
        cout << "first" << endl;
    } else {
        cout << "second" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  set<ll> s;
  rep(i,n){
    cin>>a[i];
    s.insert(a[i]);
  }
  if(sz(s)>2){
    COUT("No");
    return 0;
  }
  else if(sz(s)==1){
    ll cu=a[0];
    if(cu*2<=n||n==cu+1){
      COUT("Yes");
      return 0;
    }
    else{
      COUT("No");
      return 0;
    }
  }
  else{
    ll cu=*rbegin(s);
    ll j=*begin(s);
    if(cu!=j+1){
      COUT("No");
      return 0;
    }
    ll m=0;
    rep(i,n){
      if(a[i]!=cu) m++;
    }
    if(m>=cu){
      COUT("No");
      return 0;
    }
    if(m+(cu-m)*2<=n){
      COUT("Yes");
      return 0;
    }
    else{
      COUT("No");
      return 0;
    }
  }
}


Measured memory_bytes: 5760
#include <stdio.h>

int main(){
  int max[3]={0,0,0};
  int temp;
  int in,i,j;
  while(1){
    if(scanf("%d",&in)!=1)break;
    for(i = 0;i<3;i++){
      if(max[i]<in){
	for(j=2;j>=i;j--){
	  max[j]=max[j-1];
	}
	max[i]=in;
	break;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",max[i]);
  }

  return 0;
}



Measured memory_bytes: 2112
n, m = gets.split(' ').map(&:to_i)

Switch = Struct.new(:state) do
  def turn_on
    self.state = 'on'
  end

  def turn_off
    self.state = 'off'
  end

  def on?
    state == 'on'
  end
end

switches = n.times.each_with_object({}) do |i, hash|
  hash[i+1] = Switch.new
end

Light = Struct.new(:sw_ids, :p, :switches) do
  def on?
    sw_ids.count { |sw_id| switches[sw_id].on? } % 2 == p
  end
end

lights = []
m.times do |i|
  inputs = gets.split(' ').map(&:to_i)
  sw_ids = inputs[1..inputs[0]]
  lights << Light.new(sw_ids, nil, switches)
end

gets.split(' ').map(&:to_i).each_with_index do |p, i|
  lights[i].p = p
end

patterns = 0
b = 2**n - 1
loop do
  bits = b.to_s(2)
  order = sprintf("%0#{n}d", bits)
  order.split('').each_with_index do |o, i|
    sw = switches[i+1]
    if o == "1"
      sw.turn_on
    else
      sw.turn_off
    end
  end

  if lights.all?(&:on?)
    patterns += 1
  end

  if b == 0
    break
  end
  b -= 1
end

print patterns


Measured memory_bytes: 2300
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var list = myconv(next(),7);
  var len = list.length;
  var output = 0;
  for(var i = len - 1; i >= 0; i--){
    if(list[i] >= 6 || list[i] >= 5 && list[i - 1] >= 5){
      output += 10 - list[i];
       list[i] = 0;
      if(i != 0){
         list[i - 1]++;
      }else{
        output++;
      }
    }else{
       output += list[i];
    }
  }
  myout(output);
}


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

bool exist(int X,string Y){
  int n=Y.size();
  for(int i=0;i<n;i++){
    if(Y.at(i) - 'a' == X){
      return true;
    }
  }
  return false;
}

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans=0;
  for(int i=1;i<N;i++){
    string A=S.substr(0,i);
    string B=S.substr(i,N-i);
    int count=0;
    for(int alph=0;alph<26;alph++){
      if(exist(alph,A)&&exist(alph,B)){
        count ++;
      }
    }
    ans = max(ans,count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// 
// Least common ancestor by doubling
//
// Description:
//   For a rooted tree T, LCA(u,v) is a vertex u
//   that is the deepest node that is a common ancestor of u and v.
//
// Algorithm:
//   It stores all 2^k-ancestors for all vertices.
//   Then LCA can be solved in O(log n) time.
//
// Complexity:
//   O(n) for preprocessing,
//   O(log n) for query
//
// Verified:
//   AOJ GRL_5C
//
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

#define fst first
#define snd second
#define all(c) ((c).begin()), ((c).end())
#define TEST(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }


struct tree {
  int n, logn;
  vector<vector<int>> adj;
  tree(int n) : n(n), adj(n) { 
    logn = 1;
    for (int k = 1; k < n; k *= 2) ++logn;
  }
  void add_edge(int s, int t) {
    adj[s].push_back(t);
    adj[t].push_back(s);
  }
  vector<vector<int>> parent;
  vector<int> rank, depth;
  void rootify(int r) {
    parent.assign(logn, vector<int>(n, r));
    rank.resize(n);
    depth.assign(n, 0);
    int id = 0;
    function<void (int,int)> dfs = [&](int u, int p) {
      rank[u] = id++;
      parent[0][u] = p;
      for (int i = 0; i+1 < logn; ++i) 
        parent[i+1][u] = parent[i][parent[i][u]];
      for (int v: adj[u]) 
        if (v != p) { depth[v] = depth[u]+1; dfs(v, u); }
    }; dfs(r, r);
  }

  int lca(int u, int v) {
    if (depth[u] > depth[v]) swap(u, v);
    for (int i = depth[v]-depth[u], k = 0; i; i /= 2) {
      if (i & 1) v = parent[k][v];
      ++k;
    }
    if (u == v) return u;
    for (int i = logn-1; i >= 0; --i) {
      if (parent[i][u] != parent[i][v]) {
        u = parent[i][u];
        v = parent[i][v];
      }
    }
    return parent[0][u];
  }
};

int main() {
  int n;
  scanf("%d", &n);
  tree T(n);
  for (int u = 0; u < n ; ++u) {
    int k; 
    scanf("%d", &k);
    for (int j = 0; j < k; ++j) {
      int v;
      scanf("%d", &v);
      T.add_edge(u, v);
    }
  }
  T.rootify(0);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    printf("%d\n", T.lca(u, v));
  }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    cin >> s;
    
    if (s[0] == s[s.size()-1]) {
    	cout << (s.size()&1 ? "Second" : "First") << '\n';
    }
    else {
    	cout << (s.size()&1 ? "First" : "Second") << '\n';
    }
   	
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(ll i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
 
ll dp[103][100003]; // n,v
vll value(103),wt(103);

ll solve(ll n , ll vmax)
{
	if(n==0) 
	{
		if(vmax==0)return 0; else return INT_MAX;
	}

	if(dp[n-1][vmax]!=-1)return dp[n-1][vmax];
	
	if(vmax>=value[n-1])
	{
		return dp[n-1][vmax]=min(solve(n-1,vmax),wt[n-1]+solve(n-1,vmax-value[n-1]));
	}
	else
		return dp[n-1][vmax]=solve(n-1,vmax);
}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll n,W; cin>>n>>W; forA(i,0,n,1)cin>>wt[i]>>value[i]; ll ans=0;
	memset(dp, -1, sizeof(dp));
	ll vmax =0; forA(i,0,n,1)vmax+=value[i];

	forA(i,0,vmax+1,1)
	{
		if(solve(n,i)<=W)ans=max(ans,i);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 84052
N = int(input())
A = list(map(int, input().split()))
B = [0] * N

for i in range(N):
#    print(A[i])
    B[A[i]-1] = i+1
#    index = A.index(i+1)
 #   B[i] = index+1
print(' '.join(map(str, B)))


Measured memory_bytes: 18376
import sys

l = input().split()
f = int(l[1])

t = {}

for l in sys.stdin:
    e = l.split()
    m = int(e.pop(0))
    s = sorted(e)
    for i in range(m):
        for j in range(i+1,m):
            k = (s[i],s[j])
            if k in t:
                t[k] += 1
            else:
                t[k] =  1

f = list(sorted(filter(lambda x: t[x] >= f, t)))
print(len(f))
for e in f:
    print("{0:s} {1:s}".format(e[0],e[1]))

Measured memory_bytes: 8428
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
const int INF=(1<<30)-1;
const int MAX=310;
const int MOD=1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int main(){
	int n,k;
	cin>>n>>k;
	int h[100000];
	REP(i,n){
		cin>>h[i];
	}
	sort(h,h+n);
	int ans=INF;
	REP(i,n-k+1){
		int t=h[i+k-1]-h[i];
		ans=min(ans,t);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

const int NMAX=100000;
int num[NMAX];
bool red[NMAX];

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    num[i]=1;
    red[i]=0;
  }
  red[0]=1;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    x--,y--;
    if(red[x]){
      if(num[x]<=1) red[x]=0;
      red[y]=1;
    }
    num[x]--;
    num[y]++;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(red[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define DEB 0
#define all(x) x.begin(), x.end()

int main(){
  const long long inf = INT_MAX;
  long long a,b,d,x,y;
  while(scanf("%lld%lld%lld",&a,&b,&d),a|b|d){
    long long ax = inf;
    long long ay = inf;
    for(y=0; y<=(ax+ay); y++){
      if( (d+b*y)%a==0 ){
#if DEB
	printf("y:%d\n",y);
#endif
	long long tx = (d+b*y)/a;
	if( tx+y <= ax+ay ){
	  if( tx+y == ax+ay ){
	    if( a*tx+b*y < a*ax+b*ay ){
	      ax = tx;
	      ay = y;
	    }
	  }else{
	    ax = tx;
	    ay = y;
	  }
	}
      }
      if( (d-b*y)>=0 && (d-b*y)%a==0 ){
	long long tx = (d-b*y)/a;
	if( tx+y <= ax+ay ){
	  if( tx+y == ax+ay ){
	    if( a*tx+b*y < a*ax+b*ay ){
	      ax = tx;
	      ay = y;
	    }
	  }else{
	    ax = tx;
	    ay = y;
	  }
	}
      }
    }

    for(x=0; x<=(ax+ay); x++){
      if( (d+a*x)%b==0 ){
#if DEB
	printf("x:%d\n",x);
#endif
	long long ty = (d+a*x)/b;
	if( x+ty <= ax+ay ){
	  if( x+ty==ax+ay ){
	    if( a*x+b*ty < a*ax+b*ay ){
	      ax = x;
	      ay = ty;
	    }
	  }else{
	    ax = x;
	    ay = ty;
	  }
	}
      }
      if( d-a*x>=0 && (d-a*x)%b==0 ){
	long long ty = (d-a*x)/b;
	if( x+ty <= ax+ay ){
	  if( x+ty == ax+ay ){
	    if( a*x+b*ty == a*ax+b*ay ){
	      ax = x;
	      ay = ty;
	    }
	  }else{
	    ax = x;
	    ay = ty;
	  }
	}
      }
    }
    printf("%lld %lld\n",ax,ay);
  }
  return 0;
}

Measured memory_bytes: 0
S = input()
T = input()
n = len(S)
m = len(T)

countmax = 0
for i in range(n-m+1):
    count = 0
    for j in range(m):
        if S[i+j] == T[j]:
            count += 1
    countmax = max(count,countmax)
print(m-countmax)

Measured memory_bytes: 9060
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    count = Counter(A)
    ans = 0
    for key, value in count.items():
        if key == value:
            continue
        else:
            if key<value:
                ans += value-key
            else:
                ans += value
    print(ans)

if __name__ == '__main__':
    main()

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a % b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    long long i, j, k, n, m, t, x, y, s=0, c=0, l;
  string p;
  cin >> p;
  for(i=0; i<p.size(); i++)
  {
	if(p[i]=='7')
    {
		s++;
      break;
    }
  }
  if(s>0)
    cout << "Yes";
  else
    cout << "No";
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int N=1e5+5;
    vector<pair<pair<ll,ll>,ll> >v;
    vector<pair<ll,ll> >g[N];
    bool vstd[N];
    ll ans;
    int main(){
    	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    	int n;cin>>n;
    	for(int i=1;i<=n;i++){
    		ll a,b;cin>>a>>b;
    		v.push_back({{a,b},i});
    	}
    	sort(v.begin(),v.end());
    	for(int i=0;i<n-1;i++){
    		g[v[i].second].push_back({v[i+1].second,v[i+1].first.first-v[i].first.first});
    		g[v[i+1].second].push_back({v[i].second,v[i+1].first.first-v[i].first.first});
    	}
    	for(int i=0;i<v.size();i++){
    		swap(v[i].first.first,v[i].first.second);
    	}
    	sort(v.begin(),v.end());
    	for(int i=0;i<n-1;i++){
    		g[v[i].second].push_back({v[i+1].second,v[i+1].first.first-v[i].first.first});
    		g[v[i+1].second].push_back({v[i].second,v[i+1].first.first-v[i].first.first});
    	}
    	priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
    	pq.push(make_pair(0,1));
    	while(pq.size()){
    		int node=pq.top().second;ll cost=pq.top().first;
    		pq.pop();
    		if(vstd[node])continue;
    		vstd[node]=true;
    		ans+=cost;
    		for(auto u:g[node]){
    			pq.push({u.second,u.first});
    		}
    	}
    	cout<<ans;
    	return 0;
    }

Measured memory_bytes: 22128
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int N = 26;

int getDigits(int n) {
    for (int i = 1;; i++) {
        if (n < pow(N, i)) {
            return i;
        } else {
            n -= pow(N, i);
        }
    }
}

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

    int n;
    cin >> n;
    n--;

    string ans;

    int d = getDigits(n);

    for (int i = 1; i < d; i++) {
        n -= pow(N, i);
    }

    for (int i = 0; i < d; i++) {
        ans.push_back(n % N + 'a');
        n /= N;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define tt this->
#define ll long long
using namespace std;
int main ()
{
string g;
cin>>g;
for (int i=0;i<g.size();i++)
{
    if (g[i]=='7')
    {
        cout<<"Yes";
        return 0;

    }
}
cout<<"No";

    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val count = hashMapOf<Int, Int>()
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    count[1] = 0
    count[2] = 0
    count[4] = 0

    for (i in 0 until n) {
        val ai = a[i]
        if (ai % 4 == 0) {
            count[4] = count[4]!! + 1
            continue
        }

        if (ai % 2 == 0) {
            count[2] = count[2]!! + 1
            continue
        }

        count[1] = count[1]!! + 1
    }

    var i = 0
    var pre = 4
    while (i < n) {
        if (pre == 4) {
            if (count[1]!! > 0) {
                count[1] = count[1]!! - 1
                pre = 1
            } else {
                if (count[4]!! > 0) {
                    count[4] = count[4]!! -1
                    pre = 4
                } else {
                    count[2] = count[2]!! -1
                    pre = 2
                }
            }
        } else if (pre == 1) {
            if (count[4]!! > 0) {
                count[4] = count[4]!! -1
                pre = 4
            } else {
                println("No")
                return
            }
        } else if (pre == 2) {
            if (count[2]!! > 0) {
                count[2] = count[2]!! -1
                pre = 2
            } else {
                if (count[4]!! > 0) {
                    count[4] = count[4]!! -1
                    pre = 4
                } else {
                    println("No")
                    return
                }
            }
        }
        i++
    }
    println("Yes")
}

Measured memory_bytes: 56208
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll a,b;cin>>a>>b;
    cout<<a*b<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





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

namespace _0645
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[,] tree = new int[x[0], x[1]];
			for (int i = 0; i < x[0]; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				for (int j = 0; j < x[1]; j++) tree[i, j] = a[j];
			}
			int[,,] dp = new int[x[0] * x[1], x[0] + 2, x[1] + 2];//distance updown leftright
			for (int i = 0; i < x[0] * x[1]; i++)
			{
				for (int j = 0; j <= x[0] + 1; j++)
				{
					for (int k = 0; k <= x[1] + 1; k++)
					{
						if (j == 1 && k == 1) continue;
						dp[i, j, k] = 1145141919;
					}
				}
			}
			int[,] move = new int[,] { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 }, };
			for (int i = 1; i < x[0] * x[1]; i++)
			{
				for (int j = 1; j <= x[0]; j++)
				{
					for (int k = 1; k <= x[1]; k++)
					{
						dp[i, j, k] = dp[i - 1, j, k];
						for (int l = 0; l < 4; l++)
						{
							dp[i, j, k] = Math.Min(dp[i, j, k], dp[i - 1, j + move[l, 0], k + move[l, 1]] + tree[j - 1, k - 1] * (i * 2 - 1));
						}
					}
				}
			}
			Console.WriteLine(dp[x[0] * x[1] - 1, x[0], x[1]]);
		}
	}
}


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

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

  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for(int i = 0; i < M; ++i) {
    cin >> s.at(i) >> c.at(i);
    s.at(i)--;
  }

  vector<int> number(N, -1);
  for(int i = 0; i < M; ++i) {
    if(number.at(s.at(i)) != -1 && number.at(s.at(i)) != c.at(i)) {
      cout << -1 << endl;
      return 0;
    }
    else {
      number.at(s.at(i)) = c.at(i);
    }
  }

  if(M == 0){
      if(N == 1)cout << 0 << endl;
      if(N == 2)cout << 10 << endl;
      if(N == 3)cout << 100 << endl;
      return 0;
  }
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    if(i == 0) {
      if(number.at(i) == -1) {
        ans = 1;
      }
      else if(number.at(0) == 0) {
        if(N == 1) {
          cout << 0 << endl;
        }
        else {
          cout << -1 << endl;
        }
        return 0;
      }
      else ans = number.at(i);
    }
    else{
      if(number.at(i) != -1) {
        ans += number.at(i);
      }
    }
    ans *= 10;
  }
  ans /= 10;
  cout << ans << endl;
  return 0;
}


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

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

  if( 105 <= N && N < 135 ) {
    cout << 1 << endl;
  } else if ( 135 <= N && N < 165 ) {
    cout << 2 << endl;
  } else if ( 165 <= N && N < 189 ) {
    cout << 3 << endl;
  } else if ( 189 <= N && N < 195  ) {
    cout << 4 << endl;
  } else if ( 195 <= N ){
    cout << 5 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,a,b,s[51],i;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)	s[i]=0;
	for(i=0;i<m;i++)	{
		scanf("%d %d",&a,&b);
		s[a]++;	s[b]++;
	}
	for(i=1;i<=n;i++)	printf("%d\n",s[i]);
	return 0;
}

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

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    printf("%d %d %d\n", x, y, z);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int ans = 0;
      int tmp = 0;
      int prev = sc.nextInt();
      int now = 0;
      for(int i = 1 ; i < n ; i++){
        now = sc.nextInt();
        if(prev >= now){
          tmp++;
        }else{
          ans = ans < tmp ? tmp : ans;
          tmp = 0;
        }
        prev = now;
      }
      ans = ans < tmp ? tmp : ans;
      
      System.out.println(ans);
      return;
    }
}

Measured memory_bytes: 47632
personCount, defaultPoint, questionCount = map(int, input().split(' '))

points = [0] * personCount

for questionNumber in range(questionCount):
    correctAnswer = int(input()) - 1
    points[correctAnswer] += 1

for point in points:
    if (defaultPoint - (questionCount - point)) > 0:
        print('Yes')
    else:
        print('No')

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

int main(){
    ll n, in;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    ll min = 1000000001;
    ll ki = 0;
    rep(i, n){
        cin >> a.at(i);
        sum += abs(a.at(i));
        if(min > abs(a.at(i))) min = abs(a.at(i));
        if(a.at(i) < 0) ki++;
    }
    if(ki%2 == 1){
        sum -= min*2;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    vector<int> v(5);
    for(int i = 0; i < 5; i++){
        cin >> v[i];
    }
    int k;
    cin >> k;
    if(v[4] - v[0] > k)
        cout << ":(";
    else
    {
        cout << "Yay!";
    }
    
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;


#define NIL (-1)

typedef struct {
	int parent;
	int left;
	int right;
} Node;

Node node[25];

void Preorder(int id)
{
	cout << ' ' << id;
	if (node[id].left != NIL) Preorder(node[id].left);
	if (node[id].right != NIL) Preorder(node[id].right);
}

void Inorder(int id)
{
	if (node[id].left != NIL) Inorder(node[id].left);
	cout << ' ' << id;
	if (node[id].right != NIL) Inorder(node[id].right);
}

void Postorder(int id)
{
	if (node[id].left != NIL) Postorder(node[id].left);
	if (node[id].right != NIL) Postorder(node[id].right);
	cout << ' ' << id;
}

int main()
{
	int n, id, left, right, root = 0;

	cin >> n;

	rep(i, n) {
		node[i].parent = NIL;
		node[i].left = NIL;
		node[i].right = NIL;
	}

	rep(i, n) {
		cin >> id >> left >> right;
		node[id].left = left;
		node[id].right = right;
		node[left].parent = id;
		node[right].parent = id;
	}

	rep(i, n) if (node[i].parent == NIL) root = i;

	cout << "Preorder" << endl;
	Preorder(root);
	cout << endl;
	cout << "Inorder" << endl;
	Inorder(root);
	cout << endl;
	cout << "Postorder" << endl;
	Postorder(root);
	cout << endl;

	return 0;
}


Measured memory_bytes: 3100
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());
        int c = Integer.parseInt(scanner.next());
        System.out.println(c+" "+a+" "+b);
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.PriorityQueue;

class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
	    InputStreamReader input = new InputStreamReader (System. in);
	    BufferedReader buffer = new BufferedReader(input);

	    PriorityQueue<Integer> quere = new PriorityQueue<Integer> (Collections.reverseOrder());
	    while(true){
		    String read = buffer.readLine();
		    String[] scan = read.split(" ");
	    	if(scan[0].equals("insert")){
	    		quere.add(Integer.parseInt(scan[1]));
	    	}
	    	if(scan[0].equals("extract")){
	    		System.out.println(quere.poll());
	    	}
	    	if(scan[0].equals("end")){
	    		break;
	    	}
	    }
	}
}

Measured memory_bytes: 231812