akhauriyash/Code-Regression huggingface dataset:
'use strict';

const fs = require('fs');

const groups = [
  [1, 3, 5, 7, 8, 10, 12],
  [4, 6, 9, 11],
  [2],
];

const findGroupIndex = (n) => {
  for (let i = 0; i < 3; i++) {
    if (groups[i].indexOf(n) >= 0) {
      return i;
    }
  }
  return -1;
};

const input = fs.readFileSync('/dev/stdin', 'utf8')
  .split(' ')
  .map(n => parseInt(n, 10));

const x = input[0];
const y = input[1];

console.log(findGroupIndex(x) === findGroupIndex(y) ? 'Yes' : 'No');

Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int ans(int a, int b, int n)
{
    int r=0;
    int t;
    a -= b*(a/b);
    for(int i=0;i<n;++i)
    {
        a *= 10;
        t = a/b;
        r += t;
        a -= b*t;
    }
    return r;
}
int main()
{
    int a,b,n;
    while(cin >> a >> b >> n) cout << ans(a,b,n) << endl;
}

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

const int MAXN = 1e4 + 5;

int n, A[MAXN], B[MAXN];
long long a = 0, b = 0;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        static int x;
        scanf("%d", &x);
        a += x;
        A[i] = x;
    }
    for (int i = 1; i <= n; ++i) {
        static int x;
        scanf("%d", &x);
        b += x;
        B[i] = x;
    }
    
    if (a > b) puts("No");
    else if (a == b) {
        bool flag = 1;
        for (int i = 1; i <= n; ++i)
            if (A[i] != B[i]) {
                flag = 0; break;
            }
        puts(flag ? "Yes" : "No");
    } else {
        long long t1 = b - a, t2 = b - a;
        bool flag = 1;
        for (int i = 1; i <= n; ++i) {
            if (A[i] < B[i]) {
                if ((A[i] & 1) != (B[i] & 1)) {
                    if (!t2) {
                        flag = 0; break;
                    }
                    --t2; ++B[i];
                }
                if (t1 < (B[i] - A[i]) / 2) {
                    flag = 0; break;
                }
                t1 -= (B[i] - A[i]) / 2;
            } else {
                if (t2 < A[i] - B[i]) {
                    flag = 0; break;
                }
                t2 -= A[i] - B[i];
            }
        }
        puts(flag ? "Yes" : "No");
    }
    
    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n); REP(i, n) cin >> a[i];
  int lb = 0, ub = *max_element(ALL(a));
  while (ub - lb > 1) {
    int mid = (lb + ub) >> 1;
    ll cnt = 0;
    REP(i, n) cnt += (a[i] + mid - 1) / mid - 1;
    (cnt <= k ? ub : lb) = mid;
  }
  cout << ub << '\n';
  return 0;
}


Measured memory_bytes: 3952
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>
bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>
bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}



int main(){
    string s; cin >> s;
    int n = s.length();
    VI ans(n, 0);
    //ev, od:各区間の偶数、奇数マスにいる子供の数、
    //eIxd, oIdx: 各区間の偶数、奇数の子供が集まる位置
    int ev = 0, od = 0, eIdx = -1, oIdx = -1;
    char prv = 'R';
    REP(i, n){
        if(prv == 'L' && s[i] == 'R'){
            prv = 'R';
            ans[eIdx] = ev; ans[oIdx] = od;
            ev = od = 0;
            eIdx = oIdx = -1;
        }
        if(i%2) ++od;
        else ++ev;
        if(prv == 'R' && s[i] == 'L'){
            prv = 'L';
            if(i%2){
                oIdx = i; eIdx = i-1;
            }else{
                eIdx = i; oIdx = i-1;
            }
        }
    }
    ans[eIdx] = ev; ans[oIdx] = od;
    REP(i, n){
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        cout<<'x';
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char buf[1000][1051];
int main(void)
{
	int i,j,k,n;
	int suu[1000];
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		for(i=0;i<n;i++)	{
			scanf(" %s",buf[i]);
			j=0;
			while(buf[i][j]=='.')	{
				buf[i][j]=' ';
				j++;
			}
			suu[i]=j;
		}
		for(i=0;i<n;i++)	{
			if(suu[i]!=0)	{
				buf[i][suu[i]-1]='+';
				if(suu[i]<suu[i-1])	{
					j=i-1;
					while(suu[j]!=suu[i])	{
						buf[j][suu[i]-1]='|';
						j--;
					}
				}
			}
		}
		for(i=0;i<n;i++)	{
			printf("%s\n",buf[i]);
		}
	}
	return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(x), end(x), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(x), rend(x), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T>
constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args>
constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args>
constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class T>
constexpr T ceiling(const T a, const T b) { return (a + b - 1) / b; }
ll plusMod(ll& a, const ll b) { return a = (a + b) % mod; }
template<typename A, size_t N, typename T>
constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
int b[105];
void solve() {
    cin >> n;

    rep(i, n - 1)
        cin >> b[i];

    int ans = b[0];
    rep(i, n - 2)
        ans += min(b[i], b[i + 1]);
    ans += b[n - 2];
    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n,k; cin>>n>>k;
	if((n+1)/2>=k) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    n,m = map(int, sys.stdin.readline().split())
    A = [sys.stdin.readline().rstrip() for _ in range(n)]
    B = [sys.stdin.readline().rstrip() for _ in range(m)]
    for r in range(n-m+1):
        for c in range(n-m+1):
            X = []
            for a in A[r:r+m]:
                X.append(a[c:c+m])
            if X == B:
                print('Yes')
                exit()
    print('No')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  double x=0;
  
  double A[n];
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  
  for(int i=0;i<n;i++){
    x += 1/A[i];
  }
  
  cout << std::setprecision(10) << 1/x << endl;
  
}


Measured memory_bytes: 256
/**
 * Created by abhishek on 7/31/2016.
 */
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int array[] = new int[n + 1];
        Arrays.fill(array,1);
        //ArrayList<Integer>list = new ArrayList<>();
        HashSet<Integer>set = new HashSet<>();
        set.add(1);
        for(int i = 1;i <= m;i++){
            st = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            if(set.contains(a)){
                set.add(b);
            }
            array[a]--;array[b]++;
            if(array[a] == 0)set.remove(a);
        }
        System.out.print(set.size());
    }
}


Measured memory_bytes: 25892
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    ll ans = 0;
    rep(i, 1, N) {
        ll diff = max(A[i - 1] - A[i], 0LL);
        A[i] += diff;
        ans += diff;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780
use std::cmp;

const MOD: usize = 998244353;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s = sc.chars();
    let n = s.len();
    let a = s
        .into_iter()
        .map(|c| c as usize - '0' as usize)
        .collect::<Vec<_>>();

    let mut dp = vec![0; 2 * n + 1];
    dp[a[0]] = 1;
    for turn in 1..(2 * n + 1) {
        let mut next = vec![0; 2 * n + 1];
        let add = if turn < n { a[turn] } else { 0 };
        let total = cmp::min(turn * 2, n * 2) - turn + 1;

        for red in 0..(total + 1) {
            let blue = total - red;
            if red > 0 {
                next[red + add - 1] += dp[red];
            }
            if blue > 0 {
                next[red + add] += dp[red];
            }
        }
        dp = next.into_iter().map(|next| next % MOD).collect();
    }
    println!("{}", dp[0]);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int kk = k;
	char s[100005];
	scanf("%s", s);
	int i;
	int ans = 0;
	char ss[100005];
	for (i = 0; i < n; i++)
		ss[i] = s[i];
	ss[n] = 'R';
	i = 0;
	while (ss[i] == 'L')
		i++;
	for (; i < n; i++)
	{
		if (ss[i] == 'L')
		{
			if (ss[i + 1] == 'R')
				k--;
			ss[i] = 'R';
			if (k == 0)
				break;
		}
	}
	if (k > 0 && ss[0] == 'L')
	{
		for (i = 0; i < n; i++)
		{
			ss[i] = 'R';
			if (ss[i + 1] == 'R')
				break;
		}
	}
	for (i = 0; i < n - 1; i++)
		if (ss[i] == 'R' && ss[i + 1] == 'R')
			ans++;
	for (i = n - 1; i > 0; i--)
		if (ss[i] == 'L' && ss[i - 1] == 'L')
			ans++;
	k = kk;
	for (i = 0; i < n; i++)
		ss[i] = s[i];
	ss[n] = 'L';
	for (i=0; i < n; i++)
	{
		if (ss[i] == 'R')
		{
			if (ss[i + 1] == 'L')
				k--;
			ss[i] = 'L';
			if (k == 0)
				break;
		}
	}
	int count = 0;
	for (i = 0; i < n - 1; i++)
		if (ss[i] == 'R' && ss[i + 1] == 'R')
			count++;
	for (i = n - 1; i > 0; i--)
		if (ss[i] == 'L' && ss[i - 1] == 'L')
			count++;
	if (ans < count)ans = count;
	printf("%d\n", ans);
	return 0;
}

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

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

	for(int n, m; cin >> n >> m, n;) {
		vector<int> cell(n);
		for(int i = 0; i < n; ++i)
			cin >> cell[i];

		vector<int> values(m);
		for(int i = 0; i < m; ++i)
			cin >> values[i];

		int pos = 0;
		for(int i = 0; i < m; ++i) {
			pos += values[i];
			if(pos < n)
				pos += cell[pos];

			if(pos >= n - 1) {
				cout << i + 1 << endl;
				break;
			}
		}
	}

	return EXIT_SUCCESS;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,t;
  cin >> n >> x >> t;
  if(n%x>0)
    cout << (n/x+1)*t;
  else
    cout << (n/x)*t;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> A(n-1);
  for(int i=0;i<n-1;i++){
    cin>>A.at(i);
  }
  vector<int> B(n,0);
  for(int i=0;i<n-1;i++){
    B.at(A.at(i)-1)++;
  }
  for(int i=0;i<n;i++){
    cout<<B.at(i)<<endl;
  }
}


Measured memory_bytes: 4820
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:56:05 2019

@author: Yamazaki Kenichi
"""
import heapq

N,K = map(int,input().split())
V = list(map(int,input().split()))

def a(K):
    if K > N:
        return N
    else:
        return K

ans = 0
for i in range(K):
    for j in range(a(K-i)+1):
        tmp = 0
        minus = [0]
        for k in range(a(K-i)):
            tmp += V[k-j]
            heapq.heappush(minus,V[k-j])
#            print(tmp,minus)
        for k2 in range(i):
            if minus[0] < 0:
                tmp += (-heapq.heappop(minus))
            else:
                break
#        print(ans,tmp,i,j,k)
        ans = max(ans,tmp)
    
print(ans)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N, M;
    cin >> N >> M;
    vec L(M), R(M);
    REP(i,0,M) cin >> L[i] >> R[i];

    sort(ALL(L));
    sort(ALL(R));
    PR(MAX(R[0]-L[M-1]+1,0));

    return 0;
}

/*



*/

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define frr(j,i,n) for(int i=j;i<=n;++i)
using namespace std;
vector<int> g[100005];
int dis[100005],vis[100005];
void dfs(int node)
{
    vis[node]=1;
    for(int child : g[node])
    {
        if(!vis[child])
            dfs(child);
        dis[node]=max(dis[node],dis[child]+1);
    }
}
void solve()
{
	int n,m;
    cin>>n>>m;
    int u,v;
    frr(1,i,m)
    {
        cin>>u>>v;
        g[u].pb(v);
    }
    frr(1,i,n)
    {
        if(!vis[i])
            dfs(i);
    }
    
    int maxi=0;
    frr(1,i,n)  maxi=max(maxi,dis[i]);

    cout<<maxi<<"\n";

}
int main() 
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}



Measured memory_bytes: 12608
#include<stdio.h>
int main()
{
	int x,y,z;
	scanf("%d%d%d",&x,&y,&z);
	if(x-y==0)
		printf("%d\n",z);
	else
		if(x-z==0)
			printf("%d\n",y);
		else
			printf("%d\n",x);
	
	
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
      try (Scanner sc = new Scanner(System.in)){
          while(sc.hasNextInt()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int ans = a + b;
            int ansLen = String.valueOf(ans).length();
            System.out.println(ansLen);
          }
      }
    }
}

Measured memory_bytes: 26172
#include <iostream>
#include <vector>
#include <queue>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;
int main() {
    // input
    int n, m; cin >> n >> m;
    vector<vector<int> > g(n);
    repeat (i,m) {
        int u, v; cin >> u >> v; -- u; -- v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    // decompose
    int a_components = 0, a_nodes = 0; // connected graph: |V|  = 1
    int b_components = 0, b_nodes = 0; // connected graph: |V| >= 2 and no odd cyles
    int c_components = 0, c_nodes = 0; // connected graph: |V| >= 2 and odd cycles exist
    vector<char> used(n);
    repeat (root,n) if (not used[root]) {
        bool is_bipartite = true;
        int size = 0;
        queue<int> que;
        que.push(root);
        used[root] = 'A';
        while (not que.empty()) {
            int i = que.front(); que.pop();
            ++ size;
            for (int j : g[i]) {
                if (used[j]) {
                    if (used[i] == used[j]) is_bipartite = false;
                } else {
                    used[j] = (used[i] == 'A' ? 'B' : 'A');
                    que.push(j);
                }
            }
        }
        if (size == 1) {
            ++ a_components; a_nodes += size;
        } else if (is_bipartite) {
            ++ b_components; b_nodes += size;
        } else {
            ++ c_components; c_nodes += size;
        }
    }
    // output
    ll ans = 0;
    ans += a_nodes *(ll) a_nodes; // A A
    ans += 2 * a_nodes *(ll) b_nodes; // A B ; B A
    ans += 2 * a_nodes *(ll) c_nodes; // A C ; C A
    ans += b_components *(ll) b_components * 2; // B B
    ans += 2 * b_components *(ll) c_components; // B C ; C B
    ans += c_components *(ll) c_components; // C C
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7040
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	public void run() throws Exception {
		FastScanner sc = new FastScanner();
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		
		long diff = a-k;
		if (diff>0) {
			a = diff;
			k = 0;
		}
		else {
			a = 0;
			k = Math.abs(diff);
		}
		if (k>0){
			long diff2 = b-k;
			if (diff2>0) {
				b = diff2;
				k = 0;
			}
			else {
				b = 0;
				k = Math.abs(diff2);
			}
		}
		System.out.println(a + " " + b);
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}

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

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

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

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

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

	}
//	public void run() throws Exception
//	{
//		System.out.println("Hi");
//	}
	public static void main (String[] args) throws Exception {
		new Main().run();
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    string s,t;
    cin>>s>>t;
    int n=sz(s);
    vector<char> vecs(26,'-'),vect(26,'-');
    rep(i,n){
        char p=s[i],q=t[i];
        if(vecs[p-'a']=='-') vecs[p-'a']=q;
        else if(q!=vecs[p-'a']){
            cout<<"No"<<endl;
            return 0;
        }
        
        if(vect[q-'a']=='-') vect[q-'a']=p;
        else if(p!=vect[q-'a']){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}



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

using namespace std;


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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


int main() {
  string A,B;
  cin >> A >> B;

  int dp[A.length()+1][B.length()+1]={};

  //find the path
  rep(i,A.length())
    rep(j,B.length()){
    if(A[i]==B[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
    chmax(dp[i+1][j+1],dp[i+1][j]);
    chmax(dp[i+1][j+1],dp[i][j+1]);
  }
  /* display the recursion
  rep(i,A.length()+1){
    rep(j,B.length()+1){
      cout << dp[i][j] << "\t";
    }
    cout << endl;
  }
  */

  //make the string
  string result ="";
  int a=A.length();
  int b=B.length();
  while(a>0 && b>0){
    if(dp[a][b]==dp[a-1][b]){
      a--;
      continue;
    }
    if(dp[a][b]==dp[a][b-1]){
      b--;
      continue;
    }
    result= A[a-1]+result;
    a--;
    b--;
  }

  cout << result << endl;

}

Measured memory_bytes: 35456
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-11 10:55:56
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=1000010,M=510;
int n,v[N],p[N],c;
i64 ans[M][M];
i64 gcd(i64 a,i64 b){ return b?gcd(b,a%b):a; }
i64 lcm(i64 a,i64 b){ return a/gcd(a,b)*b; }
int main()
{
	n=1000000;
	fr(i,2,n)
	{
		if(!v[i]) p[++c]=i;
		fr(j,1,c)
			if(i*p[j]<=n)
			{
				v[i*p[j]]=1;
				if(i%p[j]==0) break;
			}
			else break;
	}
	n=read()+2;
	fr(i,0,n+1) fr(j,0,n+1) ans[i][j]=1; 
	fr(i,1,n) fr(j,1,n) if((i+j)%2==0) ans[i][j]=p[(i+j)/2]*p[(i-j)/2+2*n];
	fr(i,1,n) fr(j,1,n) if((i+j)%2==1) ans[i][j]=lcm(ans[i-1][j],lcm(ans[i+1][j],lcm(ans[i][j-1],ans[i][j+1])))+1;
	fr(i,2,n-1) fr(j,2,n-1) printf("%lld%c",ans[i][j],j==n-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 12928
///
// File:  a.cpp
// Author: ymiyamoto
//
// Created on Sat Sep 30 12:02:40 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint32_t a, b, h;
  cin >> a;
  cin >> b;
  cin >> h;

  cout << (a + b) * h / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long double W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << fixed << SP(20) << (W * H / 2) << " ";
  if (W / 2 == x && H / 2 == y)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define f first
#define s second

using namespace std;

typedef long long ll;

ostream& operator << (ostream &os, vector <int> &v) {
    for (int i : v)
        os << i << " ";
    os << "\n";
    return os;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector <int> arr[3];
    for (int i = 0; i < 3; ++i)
        arr[i].resize(n);
    for (int i = 0; i < n; ++i)
        cin >> arr[0][i] >> arr[1][i] >> arr[2][i];
    vector <int> dp[3];
    for (int i = 0; i < 3; ++i) {
        dp[i].resize(n);
        dp[i][0] = arr[i][0];
    }
    for (int i = 1; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            dp[j][i] = max(dp[(j + 1) % 3][i - 1], dp[(j + 2) % 3][i - 1]) + arr[j][i];
    cout << max({dp[0][n - 1], dp[1][n - 1], dp[2][n - 1]}) << "\n";
    return 0;
}


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

bool compare(pair<string,lnt>& p1,pair<string,lnt>& p2)
{

    if(p1.first<p2.first)
    {
        return true;
    }
    else if(p2.first<p1.first)
    {

        return false;
    }
    else if(p1.second>p2.second)
    {
        return true;
    }
    else
    {
        return false;
    }
}
int main()
{
    lnt n;
    cin>>n;
    vector<pair<string,lnt> > v,v1;
    for(int i=0;i<n;i++)
    {

        string s;lnt p;
        cin>>s>>p;
        v.push_back(make_pair(s,p));
        v1.push_back(make_pair(s,p));


    }
    sort(v.begin(),v.end(),compare);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {

            if(v[i]==v1[j])
            {   //cout<<v[i].first<<" "<<v1[i].first<<endl;
                cout<<j+1<<endl;
            }
        }

    }

}


Measured memory_bytes: 256
#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];
		--A[i];
	}
	
	vector<int> B(N);
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
	}
	
	vector<int> C(N-1);
		for (int i = 0; i < N; ++i) {
		cin >> C[i];
	}
	
	// 计算答案
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += B[A[i]];
		if (i > 0 && A[i] == A[i-1]+1) {
			// 连续吃了编号为 A[i-1] 和 A[i-1]+1 的菜
			ans += C[A[i-1]];
		}
	}
	// 输出结果
	cout << ans << endl;
}

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

int top,new_num[MAX];
int isEmpty(void){
return top==0;
}
int isFUll(){
	return top >=MAX -1;
}


void push(int x){
	if(isFUll()){
		printf("overflow\n");
		exit(1);
	}
	top++;
	new_num[top]=x;
}
int pop(){
	if(isEmpty()){
		printf("underflow");
		exit(1);
	}
	top--;
	return new_num[top+1];
}
int main(void){
	int x,y,X;
	char num[MAX];

	top=0;
	while(scanf("%s",num) != EOF){
		if(num[0] == '+'){
			x=pop();
			y=pop();
			push(x+y);
		}
		else if(num[0] == '-'){
			x=pop();
			y=pop();
			push(y-x);
		}
		else if(num[0] == '*'){
			x=pop();
			y=pop();
			push(x*y);
		}
		else{
			X=atoi(num);
			push(X);
		}
	}
	printf("%d\n",pop());
	return 0;
}

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

int main() {
    long long int n, a, b;
    cin >> n >> a >> b;
    long long int ans = 0;
    ans += (n / (a + b)) * a;
    if(n % (a + b) > a) {
        ans += a;
    }
    else {
        ans += n % (a + b);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3576
#include <stdio.h>
 
int main(){
  int n,i,j,b=0,m=0,a;
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    if(i%10==0)m+=1;
    a=i;
    for(j=0; j<m; j++){
      if(a%10==3){
    b=1;
    break;
      } 
      a/=10;
    }
    if(i%3==0||b)printf(" %d",i);
    b=0;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2104
n,k=map(int,input().split())
l=[]
for i in range(n):
  v=int(input())
  l.append(v)
l.sort()
tmp=l[n-1]
for j in range(n-k+1):
  tmp=min(tmp,l[j+k-1]-l[j])
print(tmp)

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

typedef long long ll;

ll n;

ll is_Prime(ll x){
    if(x == 1) return 1;
    ll Max = -1;
    for(ll i = 2; i * i <= x; i++){
        if(x % i == 0){
            Max = max(Max, i);
        }
    }
    ll Changdu = 0;
    if(Max == -1){
        while(x > 0){
            Changdu++;
            x /= 10;
        }
        return Changdu;
    }
    else{
        Max = x / Max;
        while(Max > 0){
            Changdu++;
            Max /= 10;
        }
        return Changdu;
    }
}

int main(){
    cin >> n;
    cout << is_Prime(n) << endl;
    return 0;
}


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

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23552
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iostream>
#define N 100005
#define int long long
using std::max;
using std::min;
using std::swap;

int n,m;
int val[N],sum[N];

int getint(){
    int x=0,f=0;char ch=getchar();
    while(!isdigit(ch)) f|=ch=='-',ch=getchar();
    while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}

signed main(){
    n=getint(),m=getint();
    for(int i=1;i<=n;i++)
        val[i]=getint(),sum[i]=sum[i-1]+val[i];
    int p=std::lower_bound(val+1,val+1+n,0)-val;
    if(p==1){
        printf("%lld\n",val[m]);
        return 0;
    } int ans=2e18;
    for(int i=0;i<=min(p-1,m);i++){
        if(!i){
            if(p+m-1>n) continue;
            ans=min(ans,val[p+m-1]);
            continue;
        }
        int a=-val[p-i];
        int want=m-i;
        if(m-i+p-1>n) continue;
        int b=val[p+want-1];
        if(!want) b=0;
        ans=min(ans,min(2*a+b,2*b+a));
    } printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
//chicken
//top1
 
#define DEBUG
#define endl "\n" 
#define forn(i,k,n) for(ll i=(k); i<(n); i++)
 
const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }
 
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;
 
using namespace std;
 int A[210000];
  int main(){
  	
int N;scanf("%d",&N);
        for(int i =0;i<N;i++)scanf("%d",A+i);
    std::sort(A,A+N);
                   for(int i=0;i<N-1;i++){
        if(A[i]==A[i+1]){
                                printf("NO\n");return 0;
 
  }
 }
                                printf("YES\n");
 }          

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a, b, c;

	cin >> a >> b >> c;

	if (c >= a && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;

	}

}

Measured memory_bytes: 256
import itertools
n = input()
length = len(n)
n = int(n)

num_list = []
for i in range(length,2,-1):
    l = list(itertools.product(['3','5','7'],repeat = i))
    l = [int(''.join(i)) for i in l if len(set(i)) == 3 ]
    num_list.extend(l)
    
num_list = [i for i in num_list if i <= n]

print(len(num_list))

Measured memory_bytes: 6388
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>
#include<iomanip>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define INF 1e20
#define min_3(a, b, c) min(a, min(b, c));
typedef long long ll;

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

  int lower = s % 100;
  int upper = s / 100;
  
  if(upper <= 12 && lower <= 12 && upper > 0 && lower > 0) cout << "AMBIGUOUS" << endl;
  else if(lower <= 12 && lower > 0) cout << "YYMM" << endl;
  else if(upper <= 12 && upper > 0) cout << "MMYY" << endl;
  else cout << "NA" << endl;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val S = sc.next()
  val isExists = S.startsWith("keyence") || S.endsWith("keyence") ||
    1.until("keyence".length).map("keyence".splitAt).exists {
      case (l, r) =>
        S.startsWith(l) && S.endsWith(r)
    }
  println(if (isExists) "YES" else "NO")
}


Measured memory_bytes: 55316
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include<set>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int H, W, K;

int main()
{
  ll ans = 0;
  int N, M;
  cin >> N >> M;

  DisjointSet ds(N);
  REP(i,0,M){
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    ds.unite(x, y);
  }
  set<int> st;
  REP(i, 0, N)
  {
    st.insert(ds.findSet(i));
   
  }
  ans = st.size();
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
#define M 1005
int A[M];
inline void rd(int &l){
	l=0;int f=0;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){l=l*10+ch-'0';ch=getchar();}
	if(f)l=-l;
}
int main(){
	int n,m,al=0,f,t=0;
	rd(n);rd(m);
	for(int i=1;i<=n;++i)rd(A[i]),al+=A[i];
	f=ceil(al*1.0/(4*m));
	for(int i=1;i<=n;++i)if(A[i]>=f)++t;
	if(t>=m)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

type Item struct {
	a, b int
}

func main() {
	var i Item
	fmt.Scanf("%d %d", &i.a, &i.b)
	x := i.a * i.b
	if x%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a >= b && a >= c){
    cout << a*10 + b + c << endl;
  }
  else if(b > a && b >= c){
    cout << a + b*10 + c << endl;
  }
  else{
    cout << a + b + c*10 << endl;
  }
}

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

int main()
{
	int n; cin >> n;
	string s; cin >> s;
	vector<bool>ans(n);
	for(int i = 0; i < n; i++)ans[i] = s[i] == 'x';

	for (int i = 0; i < 4; i++) {
		bool is_wolf = i / 2;
		bool is_next_wolf = i % 2;
		vector<bool>order(n);
		order[0] = is_wolf;
		order[1] = is_next_wolf;
		order[n - 1] = is_wolf^ans[0] ? is_next_wolf ^ 1 : is_next_wolf;
		for (int j = 1; j < n-2; j++) {
			order[j + 1] = order[j]^ans[j] ? order[j - 1] ^ 1 : order[j - 1];
		}
		if ((order[n - 1] == order[n - 2]^ans[n-2] ? order[n - 3] ^ 1 : order[n - 3]) && (order[0] == order[n - 1] ^ ans[n - 1] ? order[n - 2] ^ 1 : order[n - 2])) {
			for (int j = 0; j < n; j++) {
				cout << "SW"[order[j]];
			}
			cout << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 512
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = ns()

if s[0] == 'A' and s[2:-1].count('C') == 1:
    indx = 2 + s[2:-1].index('C')
    for i in range(len(s)):
        if i != 0 and i != indx and s[i] != s[i].lower():
            break
    else:
        print('AC')
        exit()

print('WA')

Measured memory_bytes: 3696
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

template<class T>
using V = vector<T>;

signed main() {
  int n;cin>>n;

  V<V<pii>> s(n);
  rep(i, n){
    int a;cin>>a;
    rep(j, a){
      int x,y;cin>>x>>y;
      x--;
      s[i].pb(mp(x, y));
    }
  }

  int ans = 0;
  rep(mask, 1<<n){
    vi x(n);
    int sum = 0;
    rep(i, n){
      if(mask&(1<<i)) x[i]=1, sum++;
    }

    bool check=true;
    rep(i, n){
      each(el, s[i]){
        int j = el.first;
        int t = el.second;
        if (t==1) {
          if (x[i]==1 && x[j]==0) check=false;
        }
        if (t==0) {
          if (x[i]==1 && x[j]==1) check=false;
        }
      }
    }
    if (check) chmax(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define max  2000001
#define vmax  10000

int main(){
    
    int c[vmax+1];
    int n,i,j;
    cin >> n;
    unsigned short *A, *B;
    A = new unsigned short[n + 1];
    B = new unsigned short[n + 1];
    for (i = 0; i<vmax;i++){
        c[i]=0;
    }
    for (i = 1;i<=n; i++){
        cin >> A[i];
        c[A[i]]++;
    }
    for (i = 1;i<=vmax;i++){
        c[i] = c[i -1] + c[i];
    }
    for (j = 0; j<=n;j++){
        B[c[A[j]]] = A[j];
        c[A[j]]--;
    }
    for (i = 1; i<=n ;i++){
        if (i>1) cout << " ";
        cout << B[i];
    }
    cout<< endl;
    return 0;
}

Measured memory_bytes: 10928