akhauriyash/Code-Regression huggingface dataset:
# AtCoder Grand Contest 033
# https://atcoder.jp/contests/agc033
import sys
import datetime
today = datetime.datetime.today

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main_ok():
    H, W = i2nn()
    HW = H * W
    A = ii2ss(H)
    A = [[0 if s == '#' else HW for s in line] for line in A]
    for i in range(H):
        for j in range(1, W):
            if A[i][j-1]+1 < A[i][j]:
                A[i][j] = A[i][j-1]+1
        for j in range(W-2, -1, -1):
            if A[i][j+1]+1 < A[i][j]:
                A[i][j] = A[i][j+1]+1
    for j in range(W):
        for i in range(1, H):
            if A[i-1][j]+1 < A[i][j]:
                A[i][j] = A[i-1][j]+1
        for i in range(H-2, -1, -1):
            if A[i+1][j]+1 < A[i][j]:
                A[i][j] = A[i+1][j]+1
    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] > ans:
                ans = A[i][j]
    print(ans)

def main():
    H, W = i2nn()
    A = ii2ss(H)
    A = [[True] * (W + 2)] + [[True] + [s == '#' for s in line] + [True] for line in A] + [[True] * (W + 2)]
    q = []
    for i in range(1, H+1):
        for j in range(1, W+1):
            if A[i][j] == True:
                q.append((i, j))
    rec = 0
    while len(q) > 0:
        q2 = []
        for i0, j0 in q:
            i, j = i0 - 1, j0
            if A[i][j] != True:
                A[i][j] = True
                q2.append((i, j))
            i, j = i0 + 1, j0
            if A[i][j] != True:
                A[i][j] = True
                q2.append((i, j))
            i, j = i0, j0 - 1
            if A[i][j] != True:
                A[i][j] = True
                q2.append((i, j))
            i, j = i0, j0 + 1
            if A[i][j] != True:
                A[i][j] = True
                q2.append((i, j))
        rec += 1
        q = q2
    print(rec - 1)

main()


Measured memory_bytes: 107244
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int t;
cin>>t;
ol(t/2-(t+1)%2);

return 0;
}



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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int A[N] = {0};
    for(int i = 0, tmp; i < N; i++){
        cin >> tmp;
        A[--tmp]++;
    }
    int ans = 0;
    sort(A, A+N, greater<int>());
    for(int i = 0, cnt = 0; i < N; i++){
        if(cnt < K){
            cnt++;
            continue;
        }
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>

using ll = long long;
using itn = int;
using namespace std;


int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;

	char c = s[k - 1] + 0x20;
	s[k - 1] = c;
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
hash = Hash.new(0)
n.times do
  a, b = gets.split.map(&:to_i)
  hash[a] += b
end
hash.sort.each do |key, value|
  k -= value
  if k <= 0
    puts key
    exit
  end
end


Measured memory_bytes: 9992
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
typedef long long ll;
typedef std::vector<int> VI;
typedef std::pair<int, int> PII;

using namespace std;

int main()
{
  int K, X;
  cin >> K >> X;
  int l = max(-1000000, X-K+1);
  int r = min(1000000, X+K-1);
  for (int i = l; i <= r; i++)
  {
    printf("%d%c", i, (i==r) ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;





int main(void) {
    ll N, M, C;
    cin >> N >> M >> C;
    ll i, j;
    ll b[22];
    ll a[22];
    
    for(i=0; i<M; i++) {
        cin >> b[i];
    }
    
    ll ans=0;
    for(i=0; i<N; i++) {
        ll t=C;
        for(j=0; j<M; j++) {
            cin >> a[j];
            t+=a[j]*b[j];
        }
        
        if(t>0) ans++;
        
    }
    
    pt(ans);
    
    
}





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

int main(){
	
	long long n,m,l;
	cin >> n >> m >> l ;
	
	long long i,j,k;
	long long mat1[n][m];
	for (i=0; i<n; i++){
		for (j=0; j<m; j++){
			cin >> mat1[i][j];
		}
	}
	
	long long mat2[m][l];
	for (j=0; j<m; j++){
		for (k=0; k<l; k++){
			cin >> mat2[j][k];
		}
	}
	 
	long long mat3[n][l];
	for (i=0; i<n; i++){
		for (k=0; k<l; k++){
			mat3[i][k]=0;
		}	
	}	

	for (i=0; i<n; i++){	
		for (k=0; k<l; k++){
			for (j=0; j<m; j++){
				mat3[i][k]+= mat1[i][j]*mat2[j][k];
			}
		}	
	}	
	
	for (i=0; i<n; i++){
		for (k=0; k<l; k++){
			cout << mat3[i][k] ;
			if (k!=l-1) cout << " ";
		}	
		cout << "\n";
	}		
	
	return 0;
}

Measured memory_bytes: 1388
#include <stdio.h>
#define SIZE 200000

int main(void) {
  int p[SIZE];
  int n;
  int min, count = 0;

  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  min = p[0];

  for(int i = 0; i < n; i++) {
    if(p[i] <= min) {
      count++;
      min = p[i];
    }
  }

  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 896
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    a := make([]int64,n+1)
    a[0] = 2
    a[1] = 1
    for i:=2;i<=n;i++{
        a[i] = a[i-1] + a[i-2]
    }
    fmt.Println(a[n])
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

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


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

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> h(n);
    rep (i, n)
        cin >> h[i];

    vector<bool> ok(n, true);
    rep (i, m)
    {
        int a, b;
        cin >> a >> b;
        if (h[a - 1] >= h[b - 1])
            ok[b - 1] = false;
        if (h[a - 1] <= h[b - 1])
            ok[a - 1] = false;
    }

    int ans = 0;
    rep (i, n)
        if (ok[i])
            ans++;

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

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

  int main() {
    double A, B, C, D, E, F, maxs = -1.0;
    int W, S;

    cin >> A >> B >> C >> D >> E >> F;

    for (int a = 0; a < 30; a++) {
      for (int b = 0; b < 30; b++) {
        for (int c = 0; c < 300; c++) {
          for (int d = 0; d < 300; d++) {
            if (a != 0 || b != 0) {
              if (100*A*a + 100*B*b + C*c + D*d <= F && maxs < (C*c + D*d)/(100*A*a + 100*B*b + C*c + D*d) ) {
                if (E * (A*a + B*b) >= C*c + D*d) {
                  maxs = (C*c + D*d)/(100*A*a + 100*B*b + C*c + D*d);
                  W = 100*A*a + 100*B*b;
                  S = C*c + D*d;
                }
              }
            }
          }
        }
      }
    }

    cout << W + S << " " << S << endl;
    return 0;
  }


Measured memory_bytes: 256
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

ans = 0
def dfs(cur, rem):
    global ans
    if len(rem) == 0:
        ans += 1
        return
    for cand in G[cur]:
        if cand in rem:
            i = rem.index(cand)
            dfs(cand, rem[:i] + rem[i+1:])

dfs(0, list(range(1, N)))

print(ans)



Measured memory_bytes: 3064
import sys

# S = input()
# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    N = int(input())

    print((N+1)//2)


if __name__ == '__main__':
    main()


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

struct solver{
	int xl, xr, yl, yr;

	int fromsafe(int x, int y){
		int dx, dy;
		if(x < xl){ dx = xl - x; }
		else if(x > xr){ dx = x - xr; }
		else{ dx = 0; }
		if(y < yl){ dy = yl - y; }
		else if(y > yr){ dy = y - yr; }
		else{ dy = 0; }
		return dx + dy;
	}

	int solve(int n){
		int x, y;
		cin >> xl >> yl >> xr >> yr >> x >> y;
		int ans = 0;
		for(int i = 0; i < n; ++i){
			int nx, ny;
			cin >> nx >> ny;
			
			int d = abs(x - nx) + abs(y - ny);
			int t = max(fromsafe(x, y) - 1, 0);
			int u = fromsafe(nx, ny);
			ans += min(d, t + u);

			x = nx;
			y = ny;
		}
		return ans;
	}
};

int main(){
	int n;
	while(cin >> n && n){
		cout << solver().solve(n) << endl;
	}
}


Measured memory_bytes: 3080
// atcoder - dp - B
#include <bits/stdc++.h>

using namespace std;

const int N = 100005;

int n, k, h[N], dp[N];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	for (int i = 0; i < n-1; i++) {
		for (int j = 1; j <= k; j++){
			if (i+j >= n) break;
			dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	int n;
	cin >> n;

	long long ans = 0;
	
	for(int i = 1; i <= n; i++) {
		if(i % 3 == 0 || i % 5 == 0) continue;
		ans += i;
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 3476
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N; cout << 180 * (N-2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int cnt[3] = {};
    rep(i,0,N){
        int x;
        cin >> x;
        if(x % 4 == 0)cnt[0]++;
        else if(x % 2 == 0)cnt[1]++;
        else cnt[2]++;
    }
    if(cnt[1])cnt[2]++;
    if(cnt[2] <= cnt[0] + 1)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
    int key;
    struct node *next,*prev;
};
struct node *nil;

void set(void){
    nil=(struct node *)malloc(sizeof(struct node));
    nil->next =nil;
    nil->prev =nil;
}

void insert(int key){
    struct node *x;
    x=(struct node *)malloc(sizeof(struct node));
    x->key=key;
    x->next=nil->next;
    nil->next->prev=x;
    x->prev=nil;
    nil->next=x;
}

struct node*  finditem(int key){
    struct node *n=nil->next;

    while(n!=nil && n->key!=key){
        n=n->next;
    }
    return n;
}
void deletenode(struct node *t){
    if(t==nil) {
        return;
    }
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void printList(){
    struct node *n;
    int i=0;
    for(n=nil->next; n!=nil; n=n->next){
        if(i++!=0) {
            printf(" ");
        }
        printf("%d",n->key);
    }
    printf("\n");
}

int main(){
    int n,key,i;
    char c[20];

    scanf("%d",&n);
    set();
    for(i=0;i<n;i++){
        scanf("%s",c);
        if(c[0]=='i'){
            scanf("%d",&key);
            insert(key);
        }else if(c[0]=='d'&&strlen(c)>6){
            if(c[6]=='F') {
                deletenode(nil->next);
            }else if(c[6]=='L'){
                deletenode(nil->prev);
            }
        }else{
            scanf("%d",&key);
            deletenode(finditem(key));
        }
    }
    printList();

    return 0;
}


Measured memory_bytes: 32948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int K,S;
    cin >> K >> S;
    int count = 0;
    rep(i,K + 1){
        rep(j,K + 1){
            if (0 <= S - i - j && S - i - j <= K){
                count++;
            }
        }
    }
    cout << count << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  double m = 0;
  for (auto &e : a) {
    cin >> e;
    m += e;
  }
  m /= n;
  int r = 0;
  for (int i = 0; i < n; i++) {
    if (abs(a[i] - m) < abs(a[r] - m)) {
      r = i;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 764
n = int(input())
a = list(map(int, input().split()))
m = max(a)
l = m/2
x, v = abs(a[0]-l), 0
for i in range(n):
    s = abs(a[i]-l)
    if x > s:
        x, v = s, i
if a[v] == m:
    print(m, 0)
else:
    print(m, a[v])
        

Measured memory_bytes: 14428
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
int main(){
    string n;
    cin >> n;
    int N = 0;
    for(int i = 0; i < n.size(); i++)
        N += (n[i] - '0');
    int M = ((int)n[0] - (int)'0' - 1) + ((n.size() - 1) * 9);
    cout << max(N, M) << endl;
    return 0;
}

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

using ll = long long;
const long long kLimit = 1000000000000000000ll;

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

	int n;
	cin >> n;
	ll ans = 1;

	vector<ll> arr;

	for (int i = 0; i < n; ++i) {
		ll x;
		cin >> x;
		arr.push_back(x);
	}
	sort(arr.begin(), arr.end());

	for (ll x : arr) {
		if (ans == 0) break;
		if (x > kLimit / ans) {
			ans = -1;
			break;
		}
		ans *= x;
	}

	if (ans > kLimit) ans = -1;
	cout << (long long) ans << endl;
	return 0;
}

Measured memory_bytes: 4260
from collections import Counter as C
n = int(input())
v = list(map(int,input().split()))
v1,v2 = v[0::2], v[1::2]
a1 = C(v1).most_common()
a2 = C(v2).most_common()

if a1[0][0]!=a2[0][0]:
    print(n-a1[0][1]-a2[0][1])
    exit()

res = n//2
if len(a2)!=1:
    res = a1[0][1] + a2[1][1]
if len(a1)!=1:
    res = max(res, a1[1][1] + a2[0][1])
print(n-res)


Measured memory_bytes: 21084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    string s;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    
	int a,b,c,d;
	a=0;
	b=-1;
	
	while(a+b!=0){
		while(a+b>0){
			for(c=0;c<b;c++){
				printf("#");
			}
			printf("\n");
			for(c=2;c<a;c++){
				printf("#");
				for(d=2;d<b;d++){
					printf(".");
				}
				printf("#\n");
			}
			for(c=0;c<b;c++){
				printf("#");
			}
			a=-1;
			b=-1;
			printf("\n\n");
		}
		scanf("%d%d",&a,&b);
	}
	
	return 0;
}



Measured memory_bytes: 2040
// D - Lunlun Number
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int K; cin>>K; //候補の個数
	vector<ll> candidate; //候補
	queue<ll> q;
	rp(i, 1, 10) q.push(i); //最上位桁かつ候補の初期値
	while(q.size()){
		ll n = q.front(); q.pop(); //候補を取り出す
		candidate.push_back(n); //候補を登録
		if(candidate.size() >= K) break; //候補が充足したら終了
		//m = n%10 + {-1,0,+1}: 登録した候補の第一位に差分を加算して次の第一位へ
		rp(m, n%10-1, n%10+2) if(0<=m && m<=9) q.push(n*10+m); //第一位が [0,9] の範囲内なら末尾に追加
	}
	cout<< candidate[K-1] <<endl; //昇順で登録してあるので最終候補が解
}

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


int N, M, X, Y;
vector<int> x, y;


void input() {
    cin >> N >> M >> X >> Y;
    x = vector<int>(N);
    y = vector<int>(M);
    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];
}


int main() {
    input();
    int a = max(X, *max_element(x.begin(), x.end())) + 1;
    int b = min(Y, *min_element(y.begin(), y.end()));
    if (b < a) cout << "War" << endl;
    else cout << "No War" << endl;
}


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


    int main(){
        
        vector <int> count_odd(100000);
        vector <int> count_even(100000);
        int n;
        cin >> n;

        int v;
        for(int i = 0; i < n; i++){
            cin >> v;
            if(i % 2 == 0) count_even[v] ++;
            else count_odd[v] ++;
        }
     
        int maxOdd = *max_element(count_odd.begin(), count_odd.end());
        int maxEven = *max_element(count_even.begin(), count_even.end());
        size_t maxIndexOdd = distance(count_odd.begin(), max_element(count_odd.begin(), count_odd.end()) );
        size_t maxIndexEven = distance(count_even.begin(), max_element(count_even.begin(), count_even.end()) );

        count_odd[maxIndexOdd] = 0;
        count_even[maxIndexEven] = 0;
        int secOdd = *max_element(count_odd.begin(), count_odd.end());
        int secEven = *max_element(count_even.begin(), count_even.end());


        if(maxIndexOdd != maxIndexEven) cout << n - (maxOdd + maxEven) << endl;
        else cout << n - max(maxOdd + secEven, maxEven + secOdd ) << endl;
        

    }



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

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

ll power(ll x, ll y)
{
    ll res = 1;

    while (y > 0) {

        if (y & 1)
            res = res * x;


        y = y >> 1;
        x = x * x;
    }
    return res;
}

vector<int> w[200010];

int a1[100000000];
int b1[100000000];
int c1[100000000];
int d1[100000000];
int e1[100000000];


int vis[200010];

void dfs(int nxt , int prev , int val)
{
    vis[nxt] += val;
    for(int i=0;i<(int)w[nxt].size();i++)
        if(w[nxt][i]!=prev)
            dfs(w[nxt][i],nxt,vis[nxt]);
}

int main()
{
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        w[a].push_back(b);
        w[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int p,x;
        cin>>p>>x;
        vis[p]+=x;
    }
    dfs(1,0,0);
    for(int i=1;i<=n;i++) cout<<vis[i]<<" ";
    cout<<'\n';
    return 0;
}


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

using namespace std;

#define PI 3.1415926535897932

int main(){
    char a[10],b[10],c[10];
    scanf("%s %s %s",&a,&b,&c);
    printf("%c%c%c\n",a[0]-32,b[0]-32,c[0]-32);

    return 0;
}


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

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;

using namespace std;

int main(void) {
	int N; cin >> N;
	vector<int> a(N);
	set<int> log;
	log.insert(0);
	int now = 0;
	int ans = 0;
	rep(i, N) {
		cin >> a[i];
		a[i]--;
	}

	while (true) {
		now = a[now];
		if (log.count(now) != 0) {
			ans = -1;
			break;
		}
		log.insert(now);
		ans++;
		if (now == 1) break;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5376
import sys
input = sys.stdin.buffer.readline

def main():
    H,W,D = map(int,input().split())
    a = [list(map(int,input().split())) for _ in range(H)]
    pos = [[-1,-1] for _ in range(H*W)]
    for i in range(H):
        for j in range(W):
            pos[a[i][j]-1][0] = i
            pos[a[i][j]-1][1] = j
    
    def manhattan_dist(x1,y1,x2,y2):
        return abs(x2-x1)+abs(y2-y1)

    ans_list = [[0] for _ in range(D)]
    for i in range(D):
        do = -(-(H*W-i)//D)
        for j in range(do-1):
            x1,y1 = pos[D*j+i]
            x2,y2 = pos[D*(j+1)+i]
            md = manhattan_dist(x1,y1,x2,y2)
            ans_list[i].append(ans_list[i][-1]+md)
    
    Q = int(input())
    for _ in range(Q):
        a,b = map(int,input().split())
        mod = a%D-1
        u = -(-a//D)-1
        w = -(-b//D)-1
        print(ans_list[mod][w]-ans_list[mod][u])

if __name__ == "__main__":
    main()


Measured memory_bytes: 66940
#include<iostream>
#include<algorithm>
 
using namespace std;
 
 
int main(){
    int a[10];
    for(int i=0;i<10;i++){
        cin>>a[i];
    }
    sort(a,a+10);
 
    cout<<a[9]<<endl<<a[8]<<endl<<a[7]<<endl;
 
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

# define fr(a,b) for(int i = a; i < b; i++)
# define rep(i,a,b) for(int i = a; i < b; i++)

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 1 , 0 } ;
const int dy[] = { 0 , 1 , 0 , -1 } ;

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;


void solve(){

    vector<string> cards(3);
    fr(0,3) cin >> cards[i];

    int turn = 0;

    while(true){

        if(cards[turn].empty()){
                cout << char(('A'+turn)) ;
                    break;

        }int next = cards[turn][0] - 'a';
         cards[turn].erase(0,1);
         turn =next;
        }
    line
  	return;

}

int main(){
	fast
	int t=1;
	//cin >> t;
	while(t--){
             solve();
    }

	R 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  //Patern 1
  /*
  if (a <= c && c <= b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  */
  
  //Patern 2
  /*
  if (a <= c && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
  */
  
  //Patern 3
  cout << ((a <= c && c <= b) ? "Yes" : "No") << endl;
  
  return 0;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N;
        cin >>N;
        vector<int> A(N, 0);
        Rep0(i, N)
                cin >>A.at(i);
        Sort(A);
        int S=0;
        for (int i=0; i<N-2; i++) {
                int a0=A.at(i);
                for (int j=i+1; j<N-1; j++) {
                        int a1=A.at(j);
                        if (a0==a1)
                                continue;
                        for (int k=j+1; k<N; k++) {
                                int a2=A.at(k);
                                if (a1==a2)
                                        continue;
                                if (a2-a1<a0)
                                        S++;
                        }
                }
        }
        cout <<S <<endl;
        return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+5;
LL a[maxn]; LL b[maxn];
int main(void)
{
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i],&b[i]);
	sort(a+1,a+1+n); sort(b+1,b+1+n);
	LL res;
	if(n&1)
	{
		res=(b[(n+1)/2]-a[(n+1)/2])+1;
	}
	else
	{
		res=(long long)((2.0*((long double)1.0*(b[n/2]+b[n/2+1])/2-(long double)1.0*(a[n/2]+a[n/2+1])/2)));
		res=res+1; 
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int l = 0;
  int r = N - 1;
  int ans = 0;
  while (l < r) {
    while (l < N && S[l] != 'W') l ++;
    while (r >= 0 && S[r] != 'R') r --;
    if (l < r) ans ++;
    l ++;
    r --;
  }
  cout << ans << endl;
}

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

int main() {
    

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    //Write code below
    
    string s;
    
    cin >> s;
    
    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0) {
            if(s.at(i) == 'L') {
                cout << "No" << endl;
                exit(0);
            }
        } else {
            if (s.at(i) == 'R') {
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    
    cout << "Yes" << endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<double, P> PDP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 100

struct Point {
  double x, y, z, r;
};

Point p[MAX_N];
int parent[MAX_N];
double ans;

double dis(int i, int j) {
  return sqrt((p[i].x - p[j].x) * (p[i].x - p[j].x) + (p[i].y - p[j].y) * (p[i].y - p[j].y)
           + (p[i].z - p[j].z) * (p[i].z - p[j].z));
}

double  corridor(int i, int j) {
  double d = dis(i, j);
  if (d > p[i].r + p[j].r) return d - (p[i].r + p[j].r);
  else return 0;
}

int find(int i) {
  if (i == parent[i]) return i;
  return parent[i] = find(parent[i]);
}

void unite(PDP v) {
  int x = find(v.se.fi), y = find(v.se.se);
  if (x == y) return;

  parent[y] = x;
  ans += v.fi;
}

int main(){
  cin.sync_with_stdio(false);
  int n;

  while(cin >> n, n) {
    rep(i, n) cin >> p[i].x >> p[i].y >> p[i].z >> p[i].r;
    vector<PDP> v;
    rep(i, n - 1)repl(j, i + 1, n)  v.pb(PDP(corridor(i, j), P(i, j)));
    rep(i, n) parent[i] = i;

    sort(all(v));
    ans = 0;

    rep(i, v.size()) unite(v[i]);

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

  return 0;
}

Measured memory_bytes: 3312
#include<bits/stdc++.h>
using namespace std;
int n,w;
vector<pair<int,long long int> >v;
long long int a[100001][101];
long long int knap(int x,int y)
{
	if(y==n)
	{
		return 0;
	}
	if(a[x][y]!=0)
	return a[x][y];

		
		if(v[y].first<=x)
		{
			a[x][y]=max(v[y].second+knap(x-v[y].first,y+1),knap(x,y+1));
			return a[x][y];
		}
	
	else
	{
		knap(x,y+1);
	}
	
}
int main()
{
	cin>>n>>w;
	int x,y;
	long long int res;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		v.push_back(make_pair(x,y));
	}
	res=knap(w,0);
	cout<<res<<endl;
}

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

using namespace std;

bool v[5000][5000];


int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  map< int, int > mp;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(begin(A), end(A));
  for(int i = 0; i < N; i++) {
    mp[A[i]] = i;
  }

  int ret = 1;
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      if(v[i][j]) continue;
      v[i][j] = true;
      int sa = A[j] - A[i];
      ret = max(ret, 2);
      int pre = j;
      for(int k = A[j] + sa, l = 3;; k += sa, l++) {
        if(!mp.count(k)) {
          ret = max(ret, l - 1);
          break;
        }
        v[pre][mp[k]] = true;
        pre = mp[k];
      }
    }
  }

  cout << ret << endl;

}


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

using namespace std;

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    int h[100005];
    for(int i = 0; i < n; ++i)
        scanf("%d", &h[i]);
    sort(h, h + n);
    int ans = 1e9;
    for(int i = 0; i <= n - k; ++i)
        ans = min(ans, h[i+k-1] - h[i]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
from cmath import pi, exp

def convolve(a, b):
    """配列a, bの畳み込みをFFT(fast Fourier transform)によって計算する
    res[k] = sum{i=0...n}a[i]*b[k-i]
    """
    def fft(a, inverse=False):
        # バタフライ演算用の配置入れ替え
        for i in range(n):
            j = 0
            for k in range(h):
                j |= (i >> k & 1) << (h - 1 - k)
            if i < j:
                a[i], a[j] = a[j], a[i]
 
        # バタフライ演算
        sign = 1.0 if inverse else -1.0
        b = 1
        while b < n:
            for j in range(b):
                w = exp(sign * 2.0j * pi / (2.0 * b) * j)
                for k in range(0, n, b*2):
                    s = a[j + k]
                    t = a[j + k + b] * w
                    a[j + k] = s + t
                    a[j + k + b] = s - t
            b *= 2
 
        # 逆変換時には配列のサイズで割る
        if inverse:
            for i in range(n):
                a[i] /= n
        return a
 
    def ifft(a):
        return fft(a, inverse=True)
 
    n = 1 << (len(a) + len(b) - 1).bit_length()
    h = n.bit_length() - 1
    a += [0] * (n - len(a))
    b += [0] * (n - len(b))
    
    # in-placeで計算を進めることに注意
    fft(a), fft(b)
    for i in range(n):
        a[i] *= b[i]
    ifft(a)
 
    res = [int(abs(v) + 0.5) for i, v in enumerate(a)]
    return res[1:]

import sys
input = sys.stdin.readline
n,m = map(int, input().split())
a = list(map(int, input().split()))
 
cnt = [0] * (100001)
for i in a:
    cnt[i] += 1 

c = convolve(cnt[0:], cnt[0:])
ans = 0
for i in range(len(c))[::-1]:
    if c[i] > 0:
      p = min(m,c[i])
      m -= p
      ans += i*p+p
      if m == 0:
        break
print(ans)

Measured memory_bytes: 242580
/*  ex5_3 Grid Compression
    pandacodeb  */

#include <stdio.h>

int main(void){
    int height, width;
    int i, j;
    scanf("%d %d", &height, &width);
    char a[height][width];
    
    //各行・列には最終的に消すかを表す配列；最初の値は 0 (false)
    int rowDel[height], colDel[width];
    for (i = 0; i < height; i++){
        rowDel[i] = 0;
    }
    for (j = 0; j < width; j++){
        colDel[j] = 0;
    }

    //入力（行ごと）
    for (i = 0; i < height; i++){
        for (j = 0; j < width; j++){
            scanf(" %c", &a[i][j]);
        }
    }

    //どの行が # を持たないのかをチェックする
    for (i = 0; i < height; i++){
        for (j = 0; j < width; j++){
            //最初の # 見つければ、残りを無視して次の行にチェックする
            if (a[i][j] == '#'){
                break;
            }
            //最後まで # を持たない場合 -> その行を消すか=true
            else if (a[i][j] == '.' && j == width - 1){
                rowDel[i] = 1;
            }
        }
    }
    //どの列が # を持たないのかをチェックする
    for (j = 0; j < width; j++){
        for (i = 0; i < height; i++){
            //最初の # 見つければ、残りを無視して次の列にチェックする
            if (a[i][j] == '#'){
                break;
            }
            //最後まで # を持たない場合 -> その列を消すか=true
            else if (a[i][j] == '.' && i == height - 1){
                colDel[j] = 1;
            }
        }
    }

    //出力(行ごと)
    for (i = 0; i < height; i++){
        //消さない行だけは出力される
        if (rowDel[i] == 0){
            for (j = 0; j < width; j++){
                //消さない列だけは出力される
                if (colDel[j] == 0){
                    printf("%c", a[i][j]);;
                }
            }
            printf("\n");
        }
    }
    return 0;
}


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

int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;

    if(A+B<=C*2){
        cout << A*X+B*Y;
    }else{
        if(X==Y){
            cout << C*2*X;
        }else if(X<Y){
            if(B>=C*2){
                cout << C*2*Y;
            }else{
                cout << C*2*X+B*(Y-X);
            }
        }else{
            if(A>=C*2){
                cout << C*2*X;
            }else{
                cout << C*2*Y+A*(X-Y);
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

bool p[1000001];

void primes() {
    for (int i = 0; i < 1000001; i++) {
        p[i] = true;
    }
    
    p[0] = p[1] = false;
    
    for (int i = 2; i < sqrt(1000001); i++) {
        if (p[i]) {
            for (int j = i * 2; j < 1000001; j += i) {
                p[j] = false;
            }
        }
    }
}

int main() {
    int n, x;
    primes();

    while (true) {
        cin >> n >> x;
        if (!n && !x) break;
        
        bool dp[1000001] = {false};
        int dishes[30];

        for (int i = 0; i < n; i++) {
            cin >> dishes[i];
            dp[dishes[i]] = true;
        }

        for (int i = 0; i < 1000001; i++) {
            for (int j = 0; j < n; j++) {
                if (i - dishes[j] >= 0 && dp[i - dishes[j]]) {
                    dp[i] = true;
                    break;
                }
            } 
        }

        int max = 0;
        for (int i = 0; i <= x; i++) {
            if (p[i] && dp[i]) max = i;
        }

        if (max) {
            cout << max << endl;
        } else {
            cout << "NA" << endl;
        }
        
    }

    return 0;
}

Measured memory_bytes: 3116
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
need = []
iranaiko = []
for a in A:
	if a >= K:
		need.append(a)
	elif a in need:
		need.append(a) 
	elif a in iranaiko:
		pass
	else:
		z = 0
		B = A[:]
		B.remove(a)
		fusoku = [K - i - 1 for i in range(a)]
		for bi,b in enumerate(B):
			if b >= K:
				bi = bi - 1
				break
		B = B[:bi + 1]
		B.reverse()
		C = [0]
		for b in B:
			D = []
			for c in C:
				if b + c < K:
					if b + c in fusoku:
						z = 1
						need.append(a)
						break
					D.append(b + c)
				
			D.append(0)
			C = D[:]
			if z == 1:
				break
			
		if z == 0:
			iranaiko.append(a)

print(N - len(need))


Measured memory_bytes: 58332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();

        var n = sc.nextInt();
        var d = sc.nextInt();
        var x = new int[n, d];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < d; j++)
            {
                x[i, j] = sc.nextInt();
            }
        }
        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                double tmp = 0;
                for (int t = 0; t < d; t++)
                {
                    tmp += Math.Pow(x[j, t] - x[i, t], 2);
                }
                tmp = Math.Sqrt(tmp);
                if (tmp == (int)tmp) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

/* 参加者10人のうち得点の高い方から3人の合計を求める */
int scr(void)
{
	int a, w, s;
	int i;
	int max[3];

	for (i = 0; i < 3; i++) 
		max[i] = 0;
	for (i = 0; i < 10; i++) {
		scanf("%d", &a);
		if (max[0] < a) {
			max [2] = max[1]; max[1] = max[0]; max[0] = a;
		} else if (max[1] < a) {
			max[2] = max[1]; max[1] = a;
		} else if (max[2] < a)
			max[2] = a;
	}
	s = 0;
	for (i = 0; i < 3; i++)
		s += max[i];
	return(s);
}

int main(void)
{
	printf("%d ", scr());
	printf("%d\n", scr());

	return 0;
}

Measured memory_bytes: 596
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        h:usize,w:usize,m:usize,
        mut hw:[(Usize1,Usize1);m],
    }
    let mut st = BTreeSet::new();
    for &(h, w) in hw.iter() {
        st.insert((h, w));
    }
    //
    let mut xs = vec![0; MX];
    let mut ys = vec![0; MX];
    for &(h, w) in hw.iter() {
        xs[h] += 1;
        ys[w] += 1;
    }

    let mut st2 = st.clone();
    let mut ans = 0;
    // for hw in st {
    //     let (x,w) = hw;
    //     // x
    //     ans += xs[x];

    // }
    let mut xmax = 0;
    let mut ymax = 0;
    let mut sf = true;
    let mut xmaxs = vec![];
    let mut ymaxs = vec![];
    for i in 0..MX {
        if xs[i] > xs[xmax] {
            xmax = i;
            xmaxs = vec![i];
        }
        if ys[i] > ys[ymax] {
            ymax = i;
            ymaxs = vec![i];
        }
        if xs[i] == xs[xmax] {
            xmaxs.push(i);
        }
        if ys[i] == ys[ymax] {
            ymaxs.push(i);
        }
    }
    // dbg!(&xmaxs);
    // dbg!(&ymaxs);
    let mut ans = 0;
    for &x in xmaxs.iter() {
        for &y in ymaxs.iter() {
            if st.contains(&(x, y)) {
                ans = max(ans, xs[xmax] + ys[ymax] - 1);
            } else {
                ans = max(ans, xs[xmax] + ys[ymax]);
                println!("{}", ans);
                return;
            }
        }
    }
    println!("{}", ans);
}
const MX: usize = 1010101;


Measured memory_bytes: 35424
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1;
	cin>>s2;
	int m=s1.length();
	int n=s2.length();
	int T[m+1][n+1];
	for (int i=0;i<=n;i++)
	{
		T[0][i]=0;	
	}
	for (int i=0;i<=m;i++)
	{
		T[i][0]=0;	
	}
	for (int i=1;i<=m;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if(s1[i-1]==s2[j-1])
			{
				T[i][j]=T[i-1][j-1]+1;
			}
			else
			{
				T[i][j]=max(T[i-1][j],T[i][j-1]);
			}
		}
	}
//	cout<<T[m][n]<<"\n";
	int l=0;
	char c[T[m][n]];
	int i=m,j=n;
	while(T[i][j]!=0)
	{
		if(T[i][j]==T[i-1][j])
		{
			i=i-1;
		}
		else if(T[i][j]==T[i][j-1])
		{
			j=j-1;
		}
		else
		{
			c[l++]=s1[i-1];
			i=i-1;
			j=j-1;
		}
	}
	for(int k=l-1;k>=0;k--)
	{
		cout<<c[k];
	}
}

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

int main()
{
  vector<int> s(28);
  for (int i = 0; i < 28; ++i)
    cin >> s[i];
  sort(s.begin(), s.end());

  for (int i = 1; i <= 30; ++i) {
    if (!binary_search(s.begin(), s.end(), i))
      cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
  int N,A[100],kisuu[100],i,all=1,yozisyo=1;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    all=all*3;
  }

  for(i=0;i<N;i++){
    if(A[i]%2==0){
      kisuu[i]=2;
    } else {
      kisuu[i]=1;
    }
  }

  for(i=0;i<N;i++){
    yozisyo=kisuu[i]*yozisyo;
  }

  printf("%d\n",all-yozisyo);
  

  return 0;
}
  


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[2000];

int main() {
    init();
    ll N, Z, W;
    cin >> N >> Z >> W;
    rep(i, N) cin >> A[i];

    ll a, b;
    a = b = A[N - 1];
    if (N > 1) b = A[N - 2];

    cout << max(abs(a - W), abs(a - b)) << endl;
}

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

int main(){
  
  int A, B;
  cin >> A >> B;
  
  if((A * B) % 2 == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3616