akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int a,b;
    cin >> a>>b;
    for(int i = 1; i < 1010 ; i++){
        int tmp = i*0.08;
        int tmp2 = i*0.1;
        if(tmp==a&&tmp2==b){
            cout << i << endl;
            return 0;
        } 
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

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


a=a%1000;
if (a==0)
{
    a=1000;
}

cout<<1000-a<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  string s;
  cin >> n >> s;
  ll r = 0, b = 0, g = 0;
  rep(i, n) {
    if (s.at(i) == 'R') {
      r++;
      continue;
    }
    if (s.at(i) == 'G') {
      g++;
      continue;
    }
    if (s.at(i) == 'B') {
      b++;
      continue;
    }
  }
  ll ans = r * b * g;
  if (!ans) {
    cout << 0 << endl;
    return 0;
  }
  rep(i, n) {
    reps(j, i+1, n) {
      if (s.at(i) == s.at(j)) continue;

      int k = 2*j - i;
      if (k >= n) continue;
      if ((s.at(i) != s.at(j)) && (s.at(i) != s.at(k)) && (s.at(k) != s.at(j))) {
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int kMaxN = 2048;

vi adj[kMaxN];
int n;
string str;

int sum_dist[kMaxN];
int min_sum[kMaxN];
int cnt_in[kMaxN];

void DfsDp(int v, int p) {
  cnt_in[v] = str[v - 1] - '0';
  vector<pii> children;
  int total_nd = 0;
  vi sums;

  for (int s : adj[v]) {
    if (s == p) { continue; }
    DfsDp(s, v);
    sum_dist[v] += sum_dist[s] + cnt_in[s];
    children.emplace_back(min_sum[s] + cnt_in[s], sum_dist[s] + cnt_in[s]);
    total_nd += children.back().nd;
    cnt_in[v] += cnt_in[s];
  }

  if (!children.empty()) {
    const int s = SZ(children);
    for (int i = 0; i < s; ++i) {
      if (children[i].st > total_nd - children[i].nd) {
        min_sum[v] = children[i].st - (total_nd - children[i].nd);
        break;
      }
    }
    if (min_sum[v] == 0) {
      min_sum[v] = total_nd % 2;
    }
    /*const int mx = *max_element(ALL(sums));
    const int sm = accumulate(ALL(sums), 0);
    if (sm >= 2 * mx) {
      min_sum[v] = sm % 2;
    } else {
      min_sum[v] = mx - (sm - mx);
    }*/
  }
}

ll Solve(int v) {
  fill_n(sum_dist, n + 1, 0);
  fill_n(min_sum, n + 1, 0);
  fill_n(cnt_in, n + 1, 0);
  DfsDp(v, -1);
  debug(v, adj[v], min_sum[v], sum_dist[v], cnt_in[v]);
  return (min_sum[v] == 0 ? sum_dist[v] / 2 : (ll)1e18);
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  cin >> n >> str;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].PB(v);
    adj[v].PB(u);
  }

  ll ans = 1e18;

  for (int v = 1; v <= n; ++v) {
    mini(ans, Solve(v));
  }

  if (ans > 1e17) { ans = -1; }
  cout << ans << "\n";
}



Measured memory_bytes: 640
from collections import Counter

n    = int(raw_input())
nums = list(map(int, raw_input().split()))

nums_odd  =   nums[0:n:2]
nums_even =   nums[1:n:2]

N_odd     =   sorted(Counter(nums_odd ).items(), key=lambda x: x[1], reverse=True) + [(-1,0)]
N_even    =   sorted(Counter(nums_even).items(), key=lambda x: x[1], reverse=True) + [(-1,0)]

if N_odd[0][0] == N_even[0][0]:
    if N_odd[0][1] + N_even[1][1] > N_odd[1][1] + N_even[0][1]:
        print n - N_odd[0][1] - N_even[1][1]
    else:
        print n - N_odd[1][1] - N_even[0][1]
else:
    print n - N_odd[0][1] - N_even[0][1]


Measured memory_bytes: 19856
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;

int main(){
    Fast;
    int n;
    cin>>n;
    unsigned long long int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    sort(a,a+n);
    reverse(a,a+n);
    bool ok=true;
    unsigned long long int ans=1LL,x=1e18;
    for(int i=0;i<n;i++){
        ans*=a[i];
        if(ans>x){
            cout<<-1<<endl;
            return 0;
            break;
        }
    }
    if(ok && ans>0){
        cout<<ans<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 4308
#include<iostream>
#include <algorithm>
#include <string>
#include<stack>
using namespace std;

int main() {
	int n, l;
	string s[100], r = "";
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		r += s[i];
	}

	cout << r << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
vint dp;
vector<pii> v;
int foo(int c){
	if(dp[c]>=0) return dp[c];
	int ret=1;
	rep(i,v.size()){
		if(v[c].F<v[i].F&&v[c].S<v[i].S){
			ret=max(ret,foo(i)+1);
		}
	}
	return dp[c]=ret;
}

void mainmain(){
	int n,m;
	while(cin>>n,n){
		v.clear();
		rep(i,n){
			int a,b;
			cin>>a>>b;
			v.PB(mkp(a,b));
		}
		cin>>m;
		rep(i,m){
			int a,b;
			cin>>a>>b;
			v.PB(mkp(a,b));
		}
		dp=vint(n+m,-1);
		rep(i,v.size()){
			foo(i);
		}
		int ans=0;
		rep(i,n+m){
			ans=max(ans,dp[i]);
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1208
//Five Variables

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    rep(i,1,6){
        int a;cin>>a;
        if(a==0){
            cout<<i<<nnn;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
N, M = map(int, input().split())
S = [0] * M
for i in range(M):
    _, *s, = map(int, input().split())
    for v in s:
        S[i] = S[i] | (1 << (v - 1))

*P, = map(int, input().split())

ans = 0
for p in range(2**N):
    ok = True
    for i in range(M):
        b = format(p & S[i], 'b')
        if b.count('1') % 2 != P[i]:
            ok = False
            break
    if ok:
        ans += 1

print(ans)

Measured memory_bytes: 3064
def main():
    A, B = input().split()
    a = int(A)
    b = int(B.replace('.', ''))
    str_ans = str(a*b)
    if a*b < 100:
        print('0')
    else:
        print(str_ans[:-2])


if __name__ == '__main__':
    main()


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 5005;
int mod;
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int temp[N][N];
void _add(int & x, int y){
	x += y; if(x >= mod) x -= mod;
}

int dp1[N][N], dp2[N][N];

void getDP(int s, int lft, int rgt){
	int n = lft;
	for(int i = 0; i <= s; i++) temp[0][i] = dp2[0][i] = 1;
	for(int i = 1; i <= n; i++){
		int mx = s;
		int old_mx = s; 
		mx = i == n ? s : s / (n - i);
		old_mx = s / (n - i + 1);
		for(int sum = s; sum >= 1; sum--){
			for(int v = 1; v <= mx; v++){
				temp[sum][v] = add(temp[sum][v - 1], 
					v <= sum ? temp[sum - v][min(v, old_mx)] : 0);
			}
		}
		if(i == lft){
			memcpy(dp1, temp, sizeof dp1);
		}
		if(i == rgt){
			memcpy(dp2, temp, sizeof dp2);
		}
	}
}

int main(){
	int n; sd(n); sd(mod);
	int k = n / 2, lft, rgt;
	if(n % 2 == 1){
		lft = k; rgt = k;
	}
	if(n % 2 == 0){
		lft = k, rgt = k - 1;
	}


	getDP(n, lft, rgt);
	for(int s = 1; s <= n; s++){
		for(int v = 0; v <= n; v++){
			dp2[s][v] = add(dp2[s][v], dp2[s - 1][v]);
		}
	}
	int ret = 0;
	for(int mid = 1; mid <= n; mid++){
		for(int a = 0; a < mid; a++){
			int num_ways = dp1[a][a];
			if(!num_ways) continue;
			ret = add(ret, mul(num_ways, dp2[mid - 1 - a][n - mid]));
		}
	}
	printf("%d\n", ret);
}

Measured memory_bytes: 293760
n = int(raw_input())
s = raw_input()
m = 0
c = 0
for si in s:
    if si == "(":
        c += 1
    else:
        c -= 1
    m = min(m, c)

ans = ""
if m < 0:
    ans += "(" * (-m)
    c += -m

if c < 0:
    ans = ans + "(" * (-c) + s
else:
    ans = ans + s + ")" * c

print ans

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

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

	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());

	int result = 1;
	int c = vec.at(0);
	for (int i = 1; i < N; i++) {
		if (c != vec.at(i)) {
			result += 1;
		}
		c = vec.at(i);
	}

	cout << result << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		while ((line = br.readLine()) != null) {
			int n = Integer.parseInt(line);
			if (n == 0) {
				break;
			} else {
				int a = 0, b = 0, suma = 0, sumb = 0;
				while (n > 0) {
					line = br.readLine();
					a = Integer.parseInt(line.split(" ")[0]);
					b = Integer.parseInt(line.split(" ")[1]);
					if (a > b) {
						suma += (a + b);
					} else if (a == b) {
						suma += a;
						sumb += b;
					} else {
						sumb += (a + b);
					}
					n--;
				}
				System.out.println(suma + " " + sumb);
			}
		}
	}
}

Measured memory_bytes: 51896
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
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...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N, M, K, Q, W, H, R, C;
string S;

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

    cin >> N >> R;
    if(N>=10){
        cout << R <<endl;
    } else {
        cout << R + (100 * (10 - N)) << endl;
    }
    return 0;
}


Measured memory_bytes: 764
S = input()
def palin_check(str):
    rstr = str[::-1]
    slen = len(str) if len(str) % 2 == 0 else len(str)-1
    if str[:int(slen/2)] != rstr[:int(slen/2)]:
        return "No"
    else:
        return "Yes"

if palin_check(S) == "No":
    print("No")
else:
    if palin_check(S[:int((len(S)-1)/2)]) ==  'No':
        print("No")
    else:
        print("Yes")

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

int main(){
  
  int A;
  int B;  
  int C;
  int D;
   
    cin >> A >> B >> C >> D;
  
  if ( (A+B) > (C+D) )
    
    cout << "Left" << endl;
  
  if ( (A+B) == (C+D) )
    
    cout << "Balanced" << endl;
  
  if ( (A+B) < (C+D) )
    
    cout << "Right" << endl;
  
} 


Measured memory_bytes: 3536
import java.util.Scanner;

class Main{
    public static void main(String[] a){
        Scanner s = new Scanner(System.in);

        String str = s.next();

        for(int i = str.length() - 1;i >= 0; i--){
            System.out.print(str.charAt(i));
        }
        System.out.println("");
    }
}

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

int main(){
  int N, a, x;
  cin >> N;
  cin >> a;
  x = N/500;
  x = N - x * 500;
  if(x <= a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import math

S=str(input())
N=len(S)
M=(N-1)//2

T=str()
U=str()

for i in range(M):
    T+=S[i]

for j in range(M+1,N):
    U+=S[j]

def check(letter):
    length=len(letter)
    number=math.floor(length)-1
    answer=1
    for x in range(number):
        if letter[x]!=letter[length-1-x]:
            answer=0
    return answer

Ans=min(check(S),check(T),check(U))

if Ans==1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
// AOJ DSL_5_A The Maximum Number of Customers
// 2018.5.5 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int s[100002];

// imos法で解く
int main()
{
	int N, T, i, ans;

	N = in(), T = in();
	for (i = 0; i < N; i++) {
		s[in()]++, s[in()]--;
	}
	ans = s[0];
	for (i = 1; i <= T; i++) {
		s[i] += s[i-1];
		if (s[i] > ans) ans = s[i];
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2160
import java.util.Scanner;

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


		String s = sc.next();
		String s2 = s+s;
		
		String p = sc.next();

		if (s2.contains(p)) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		sc.close();
	}
}


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

int main()
{
	int n;
  	cin >> n;
  	vector<string> gacha(n);
  	for(int i = 0; i < n; i++)
    {
    	cin >> gacha.at(i);
    }
  	sort(gacha.begin(),gacha.end());
  	int count = 1;
  	for(int i = 0; i < n-1; i++)
    {
    	if(gacha.at(i) != gacha.at(i+1))
        {
        	count++;
        }
    }
  	cout << count << endl;
}


Measured memory_bytes: 9600
def gcd(a,b):   #　ユーグリッドの互除法
    if b == 0:
        return a
    return gcd(b, a % b)

N, X = map(int,input().split())
city = list(map(int,input().split()))
X_diff = [0]*N
for i in range(N):
    X_diff[i] = abs(X-city[i])
    
ans = X_diff[0]
for i in range(1,N):
    ans = gcd(ans,X_diff[i])

print(ans)

Measured memory_bytes: 14252
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);

void solve() {
    string s;cin>>s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7'){
        cout<<"Yes"<<endl;
    } else{
        cout<<"No"<<endl;
    }
}
int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for (int i = 1; i <= test; i++) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

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

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
	int w,h,n;
	cin >> w >> h >> n;
	int miX = 0, maX = w, miY = 0, maY = h;
	while(n--){
		int x,y,a;
		cin >> x >> y >> a;
		if(a == 1) maxs(miX,x);
		else if(a == 2) mins(maX,x);
		else if(a == 3) maxs(miY,y);
		else mins(maY,y);
		//		cout << miX << " " << maX << " " << miY << " " << maY << endl;
	}
	cout << max(0,(maX - miX)) * max(0,(maY - miY)) << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
package main

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

func nextLine(r *bufio.Reader) string {
	var buf []byte
	for {
		line, isPrefix, err := r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func nextStr(s *bufio.Scanner) string {
	s.Scan()
	ref := s.Bytes()
	cp := make([]byte, len(ref))
	copy(cp, ref)
	return string(cp)
}

func nextInt(s *bufio.Scanner) int {
	n, err := strconv.Atoi(nextStr(s))
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	X := nextInt(s)
	Y := nextInt(s)

	for i := 0; i <= X; i++ {
		legs := i * 2 + (X - i) * 4
		if (legs == Y) {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

Measured memory_bytes: 1772
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N ;
    
    vector<ll> a(N);
    rep(i, N){
        cin >> a[i];
    }
    

    vector<bool> ans(N, false);
    
    for(ll i = N-1; i>=0; i--){
        ll idx = i+1;
        ll times = 2;
        ll cnt = 0;
        
        while(((idx * times) <= N)){
            if(ans[idx * times -1]) cnt++;
            times ++;
        }
        cnt += a[i];
        
        if(cnt%2 == 1) ans[i] = true;
    }
    
    ll cnt = 0;
    rep(i, N) if(ans[i]) cnt ++;
    cout << cnt << endl;
    
    rep(i, N){
        if(ans[i]) cout << (i+1) ;
        if(i == N-1 && cnt != 0) cout << endl;
        else if(cnt != 0) cout << " ";
    }


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

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

    string A = "ACL";
    string B;
    for(ll i = 0; i < K; i++){
        B = B + A;
    }

    cout << B << endl;
}

Measured memory_bytes: 3600
#include"bits/stdc++.h"
using namespace std;
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0);cout<<fixed<<setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}

#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'

using ll = long long int;

int main()
{
    double n;cin>>n;
    cout<<((n)*(acos(-1))*2)<<endll;
}



Measured memory_bytes: 3840
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>

#define MAX_N 1000000

using namespace std;

bool P[102];

int main()
{
    int X, N, i, p, best;

    scanf("%d%d", &X, &N);
    memset(P, 0, sizeof P);
    for(i = 0; i < N; ++i){
        scanf("%d", &p);
        P[p] = true;
    }

    best = 0;
    for(i = 1; i <= 101; ++i)
        if(!P[i] && abs(X - i) < abs(X - best))
            best = i;
    printf("%d", best);

    return 0;

}


Measured memory_bytes: 1732
n, m = map(int, input().split())
L = []
for i in range(m):
  L.append([i] + list(map(int, input().split() + ["000000000000"])))
L.sort(key=lambda x:(x[1], x[2]))
#print(L)

counter = 1
city = 0
for i in range(m):
  if city == L[i][1]:
    counter += 1
  else:
    counter = 1
  L[i][3] = str(L[i][1]).zfill(6) + str(counter).zfill(6)
  city = L[i][1]
#print(L)
L.sort(key=lambda x:x[0])
for i in range(m):
  print(L[i][3])

Measured memory_bytes: 102744
n = gets.to_i
A_n = gets.split.map(&:to_i)
ans = 0
amari = 10**9 + 7
sum = A_n.sum % amari
(0..n-1).each do |i|
  sum -= A_n[i]
  ans = (ans + A_n[i] * sum) % amari
end
p ans

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

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;

    // 累積和を求める
    vector<int> s(N + 1, 0);
    for (int i = 1; i < N; ++i) {
        int a = 0;
        if (S[i - 1] == 'A' && S[i] == 'C') a = 1;
        s[i + 1] = s[i] + a;
    }

    // 各クエリに答える
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        --l;
        int result = s[r] - s[l];
        if (l > 0 && S[l - 1] == 'A' && S[l] == 'C') --result;
        cout << result << endl;
    }
}

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


int n,m;
vector<vector<int> > g;

int dp[100010];

int rec(int v){
  if(dp[v]!=-1) return dp[v];

  int ans=0;
  for(auto nv : g[v]){
    ans=max(ans,rec(nv)+1);
  }
  return dp[v]=ans;
}

int main(){
  cin >> n >> m;
  g.assign(n,vector<int>());
  for(int i=0;i<m;++i){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
  }

  for(int i=0;i<n;++i){
    dp[i]=-1;
  }

  int ans=0;
  for(int i=0;i<n;++i){
    ans=max(ans,rec(i));
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 8192
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];


    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    Arrays.sort(a);
    int[] b = new int[a[n-1]+1];

    for (int j=0;j<b.length; j++){
      b[j] = 0;
    }

    long sum = 0;

    for (int i=0;i<n;i++){

      int current = a[i];
      for (int j=current;j<=a[n-1];j+=current){
        b[j] += 1;
      }
    }

    for (int i=0;i<n;i++){
      if (b[a[i]] < 2){
        sum += 1;
      }
    }

    System.out.println(sum);

  }

}


Measured memory_bytes: 60500
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

//question_a
using namespace std;
using ll = long long;
int main() {
	int n;
	cin >> n;
	ll* x = new ll[n];
	ll* y = new ll[n];
	ll* f1 = new ll[n];
	ll* f2 = new ll[n];
	for (int i = 0;i < n;i++) {
		cin >> x[i] >> y[i];
		f1[i] = x[i] + y[i];
		f2[i] = x[i] - y[i];
	}
	sort(f1, f1 + n);
	sort(f2, f2 + n);
	cout << max(f1[n - 1] - f1[0], f2[n - 1] - f2[0]) << endl;
}



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

int main(){
  int N,Y;
  cin>>N>>Y;
  bool flag=false;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        cout<<i<<" "<<j<<" "<<N-i-j<<endl;
        flag=true;
        break;
      }
    }
    if(flag){
      break;
    }
  }
  if(!flag){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
}


Measured memory_bytes: 764
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int t, i;

    for(;;out.println(t)){
      t = sc.nextInt(); if(t == 0)break;
      for(i = 0;i < 9;i++)t -= sc.nextInt();
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17200
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
bool vis[100005];
vector<int> adj[100005];
ll dp[100005][3];
ll dfs(int u,int b)
{
	//cout<<u<<" "<<b<<endl;
	if(dp[u][b]!=-1)
		return dp[u][b];
	vis[u]=true;
	vector<int>::iterator it;
	ll sum1=1,sum2=1,sum=0,g=0,d=0,f=0;
	for(it=adj[u].begin();it!=adj[u].end();it++)
	{
		if(!vis[*it])
		{
			g=1;
			d=(d+dfs(*it,0))%mod;
			if(b!=1)
				f=(f+dfs(*it,1))%mod;
			sum1=(sum1*d)%mod;
			sum2=(sum2*f)%mod;
			d=0;
			f=0;
		}
	}
	sum=(sum1+sum2)%mod;
	if(g!=1)
	{
		if(b==1)
			sum=1;
		else
			sum=2;
	}
	vis[u]=false;
	dp[u][b]=sum;
	return sum;
}
int main()
{
	ll n,i,x,y;
	cin>>n;
	for(i=1;i<=n-1;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for(i=1;i<=n;i++)
	{
		dp[i][0]=dp[i][1]=-1;
		vis[i]=false;
	}
	cout<<dfs(1,0)<<endl;
	//for(i=1;i<=n;i++)
		//cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
}


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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 1000000007
#define debug(x) cerr<<#x<<"="<<x<<'\n'

int read() {
  int x=0,w=1;
  char ch=0;
  while (ch<'0'||ch>'9') {
    if (ch=='-') w=-1;
    ch=getchar();
  }
  while (ch>='0'&&ch<='9') {
    x=(x<<3)+(x<<1)+(ch-'0');
    ch=getchar();
  }
  return x*w;
}

int p0w(ll base,int p) {
	ll res=1;
	while (p) {
		if (p%2==1) (res*=base)%=mod;
		(base*=base)%=mod;
		p/=2;
	}
	return res;
}

const int maxn=2e5+10;

int n,m;
int dif[maxn];

int main(){
	n=read(),m=read();
	int ans=0;
	for (int i=1;i<=m;i++) {
		int cur=p0w(m/i,n);
		int tmp=0;
		for (int j=1;j*j<=i;j++) {
			if (i%j) continue;
			tmp+=dif[j];
			if (j*j!=i) tmp+=dif[i/j];
		}
		tmp-=dif[i];
		dif[i]=i-tmp;
		ans+=(ll)dif[i]*(ll)cur%mod;
		ans%=mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    cout << pow(n, 2) * 3 << endl;
    return 0;
}

Measured memory_bytes: 256
"""
N towns
teleporter each town
teleporter at town i -> town A_i
k-times teleporter after starting at town 1
"""

from collections import deque

n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

visited = [0] * n
path = deque()
cur = 0

while not visited[cur]:
    visited[cur] = 1
    path.append(cur)
    cur = a[cur]

while path[0] != cur and k > 0:
    k -= 1
    path.popleft()

#print(path)
if k == 0:
    print(path[0] + 1)
else:
    print((path[k % len(path)]) + 1)


Measured memory_bytes: 91900
{-# LANGUAGE BangPatterns        #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE RankNTypes          #-}
{-# LANGUAGE ScopedTypeVariables #-}
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.List
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

main :: IO ()
main = do
  [n,m] <- readLnAsListWith unconsInt
  edges <- readLnAsUVecWith2Tuple unconsInt m
  let g = graph' edges n
      path = dfs [0..n-1] g
  print $ VU.maximum path

type Graph a = V.Vector [(Int, a)]
-- type Graph a = V.Vector (a, [Vertex])
type FlagVec s = VUM.MVector s Bool
type Vertex = Int

-- 解くべき問題により、シグネチャは変更する
dfs :: VU.Unbox a => [Vertex] -> Graph a -> VU.Vector Int
dfs vs g = VU.create $ do
  seen <- VUM.replicate (V.length g) False
  longestPath <- VUM.replicate (V.length g) 0
  mapM_ (go seen longestPath) vs
  return longestPath
  where go :: FlagVec s -> VUM.MVector s Int -> Vertex -> ST s ()
        go seen lp v = do
          VUM.write seen v True
          forM_ (g V.! v) $ \(nv, _) -> do
            s <- VUM.read seen nv
            if s
              then return ()
              else do go seen lp nv
            -- この時点で、lp[nv]に入ってる値は最大値。
            lv <- VUM.read lp v
            lnv <- VUM.read lp nv
            VUM.write lp v $ max lv (lnv + 1)

-- 重みなしグラフ
graph' :: VU.Vector (Vertex, Vertex) -> Int -> Graph ()
graph' = graph . VU.map (\(x,y) -> (x,y,()))

-- 有向グラフの場合は、to側の隣接リスト追加部分をコメントアウト
graph :: VU.Unbox a => VU.Vector (Vertex, Vertex, a) -> Int -> Graph a
graph vec n = V.create $ do
  g <- VM.replicate n []
  let l = VU.length vec
  forM_ [0..l-1] $ \i -> do
    let (from,to,w) = vec VU.! i
        f = from - 1
        t = to - 1
    VM.modify g ((t,w):) f
    -- VM.modify g ((f,w):) t
  return g


-- converter
unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

-- 1D Data
-- for list
readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith !st = unfoldr (runStateT st) <$> BS.getLine

-- for unboxed vector
readLnAsUVecWith :: VU.Unbox a => StateT BS.ByteString Maybe a -> Int -> IO (VU.Vector a)
readLnAsUVecWith !st !n = VU.unfoldrN n (runStateT st) <$> BS.getLine

-- example: 1D tuple vector
readLnAsUVecWith2Tuple :: VU.Unbox a => StateT BS.ByteString Maybe a -> Int -> IO (VU.Vector (a,a))
readLnAsUVecWith2Tuple !st !n = VU.replicateM n $ (\vec -> (vec VU.! 0, vec VU.! 1)) <$> readLnAsUVecWith st 2


Measured memory_bytes: 25536
from collections import deque

def main():
    stack = deque()

    for c in input().split(" "):

        if c.isdecimal():
            stack.append(int(c))
        
        elif c == "+" or c == "-" or c == "*":
            v1 = stack.pop()
            v2 = stack.pop()
            if c == "+":
                stack.append(v1 + v2)
            elif c == "-":
                stack.append(v2 - v1)
            elif c == "*":
                stack.append(v1 * v2)

    print(stack.pop())

main()


Measured memory_bytes: 6000
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	if (A > 12) {
		cout << B << endl;
	}
	else if (A >= 6) {
		cout << B / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class aoj
{
	static void Main()
	{
		string input;

		List<int> pnCount = new List<int>();
		pnCount.Add(0);

		while (true)
		{
			input = Console.ReadLine();
			if (input == null) { break; }

			int inputNumber = int.Parse(input);

			if (inputNumber > pnCount.Count)
			{
				for (int i = pnCount.Count; i < inputNumber + 1; i++)
				{
					if (isPrime(i+1))
					{
						pnCount.Add(pnCount[i - 1]+1);
					}
					else
					{
						pnCount.Add(pnCount[i - 1]);
					}
				}
				Console.WriteLine(pnCount[inputNumber -1]);
			}
			else
			{
				Console.WriteLine(pnCount[inputNumber -1]);
			}
		}
	}

	private static bool isPrime(int n)
	{
		if (n == 1)
		{
			return false;
		}
		else if (n < 9)
		{
			for (int i = 2; i < n; i++)
			{
				if (n % i == 0)
				{
					return false;
				}
				else
				{
					continue;
				}
			}
		}	
		else
		{
			for (int i = 2; i <= Math.Sqrt(n); i++)
			{
				if (n % i == 0)
				{
					return false;
				}
				else
				{
					continue;
				}
			}
		}
		return true;
	}
}

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


int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  ll sum = 0;
  ll mx = a[0];

  rep(i,n){
    if(a[i] > mx) mx = a[i];
    else sum += mx-a[i];
  }
  
  cout << sum << endl; 
  
}


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



int main() {
	int begin;
	int last;
	int middle;
	int number;

	string type_begin;

	string type_last;
	string type_middle;

	begin = 0;
	cin >> last;
	cout << 0 << endl;
	cin >> type_begin;
	if (type_begin == "Vacant") {

		cout << begin << endl;
		return 0;
	}

	type_last = type_begin;
	for (int i=0;i <= 20;i++) {

		middle = (begin+last)/2;
		cout << middle << endl;
		cin >> type_middle;
		number = middle - begin + 1;
		if (type_middle== "Vacant") {
		
			cout << begin << endl;
			return 0;
		}
		else if (((number % 2 == 0) && (type_begin == type_middle)) || ((number % 2 == 1) && (type_begin != type_middle))) {
			last = middle;
			type_last = type_middle;
		}

		else if (((number % 2 == 1) && (type_begin == type_middle)) || ((number % 2 == 0) && (type_begin != type_middle))) {
			begin = middle;
			type_begin = type_middle;
		}


		

	
	}


	return 0;

}




Measured memory_bytes: 852
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

map< int, int > mp1, mp2;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    for( int i = 0; i < n; ++i ) {
        int d;
        cin >> d;
        ++mp1[d];
    }
    int m;
    cin >> m;
    int a[m];
    for( int i = 0; i < m; ++i ) {
        cin >> a[i];
        ++mp2[a[i]];
    
    }

    bool flg = true;
    for( int i = 0; i < m; ++i ) {
        if( mp1[a[i]] < mp2[a[i]] ) flg = false;

    }

    if( flg ) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}



Measured memory_bytes: 19840
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) { // n が 0 になるまで
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	int ans = 10000000;
	for (int a = 1; a < n; a++) {
		int b = n - a;
		sum = findSumOfDigits(a) + findSumOfDigits(b);
		if (sum < ans) ans = sum;
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ll mod = 1000000007;

int main(){
    ll n;
    cin >> n;
    vecll a(n);
    for(auto& i : a) cin >> i;

    vecll ans(n);
    for(ll i = 0; i < n; i++){
        ans.at(a.at(i) - 1) = i + 1;
    }
    for(ll i = 0; i < n - 1; i++) cout << ans.at(i) << " ";
    cout << ans.at(n - 1) <<endl;
}

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


int main(){
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int rn, gn;
  rn = n / r + 1;
  gn = n / g + 1;

  ll ans = 0;
  rep(i, rn){
    rep(j, gn){
      ll rg = n - (i * r + j * g);
      if (rg >= 0 && rg % b == 0) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
 
struct dice {
    int face1;
    int face2;
    int face3;
    int face4;
    int face5;
    int face6;
};
 
struct dice move_W(struct dice d);
struct dice move_S(struct dice d);
struct dice move_E(struct dice d);
struct dice move_N(struct dice d);
 
int main() {
    struct dice d1;
    scanf("%d %d %d %d %d %d",
            &d1.face1, &d1.face2, &d1.face3, &d1.face4, &d1.face5, &d1.face6);

    struct dice d2;
    scanf("%d %d %d %d %d %d",
            &d2.face1, &d2.face2, &d2.face3, &d2.face4, &d2.face5, &d2.face6);
 
 
    struct dice d1_origin = {d1.face1, d1.face2, d1.face3, d1.face4, d1.face5, d1.face6};
 
    char command[24][7] = {"", "SEN", "SWN", "SSEE",
                           "N", "NSEN", "NSWN", "NSSEE",
                           "W", "WSEN", "WSWN", "WSSEE",
                           "E", "ESEN", "ESWN", "ESSEE",
                           "S", "SSEN", "SSWN", "SSSEE",
                           "SS", "SSSEN", "SSSWN", "SSSSEE"};
 
    int answer = 0; 

    for (int i = 0; i < 24; i++) {
        for (int j = 0; j < 7; j++) {
            switch (command[i][j]) {
                case 'W':
                    d1 = move_W(d1);
                    break;
                case 'S':
                    d1 = move_S(d1);
                    break;
                case 'E':
                    d1 = move_E(d1);
                    break;
                case 'N':
                    d1 = move_N(d1);
                    break;
                default:
                    break;
            }
        }
        if ((d1.face1 == d2.face1)&&(d1.face2 == d2.face2)&&(d1.face3 == d2.face3)
                 &&(d1.face4 == d2.face4)&&(d1.face5 == d2.face5)&&(d1.face6 == d2.face6)) {
            answer++;
            d1 = d1_origin;
            break;
        } else {
            d1 = d1_origin;
        }
    }
 
    if (answer == 1) {
        printf("Yes\n");
    } else {
	printf("No\n");
    }
 
    return 0;
}
 
struct dice move_W(struct dice d) {
    struct dice d_tmp = {d.face3, d.face2, d.face6, d.face1, d.face5, d.face4};
    return d_tmp;
}
 
struct dice move_S(struct dice d) {
    struct dice d_tmp = {d.face5, d.face1, d.face3, d.face4, d.face6, d.face2};
    return d_tmp;
}
 
struct dice move_E(struct dice d) {
    struct dice d_tmp = {d.face4, d.face2, d.face1, d.face6, d.face5, d.face3};
    return d_tmp;
}
 
struct dice move_N(struct dice d) {
    struct dice d_tmp = {d.face2, d.face6, d.face3, d.face4, d.face1, d.face5};
    return d_tmp;
}


Measured memory_bytes: 2148
import itertools

N = int(input())

A=[[] for _ in range(N)]
for i in range(N):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        A[i].append([x-1, y])

saidai = 0
for i in itertools.product(range(2), repeat=N):
    ans = list(i)
    Flag = True
    for j in range(N):
        if ans[j] == 1:
            for k in A[j]:
                if ans[k[0]] == k[1] or ans[k[0]] == -1:
                    ans[k[0]] = k[1]
                else:
                    Flag = False
                    break
    if Flag == True:
        saidai = max(ans.count(1), saidai)

print(saidai)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner scan= new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		for(int i=1; i<=n; i++)
		{
			if(i%3==0)
			{
				System.out.print(" "+i);
				continue;
			}
			int x =i;
			while(x>0)
			{
				if(x%10==3)
				{
					System.out.print(" "+i);
					break;
				}
				x/=10;
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 28736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main() {
    int S, S_up, S_under, num;
    string up, under;

    cin >> S;

    num = S / 100;
    S_up = num;
    num = num * 100;

    S_under = S - num;

    if (S_under <= 99 && 0 <= S_under) {
        under = "YEAR";
    }

    if (S_up <= 99 && 0 <= S_up) {
        up = "YEAR";
    }

    if (S_under <= 12 && 1 <= S_under) {
        under = "MONTH";
    }

    if (S_up <= 12 && 1 <= S_up) {
        up = "MONTH";
    }

    if(up=="YEAR"&&under=="YEAR"){
        cout<<"NA";
    }

    if(up=="YEAR"&&under=="MONTH"){
        cout<<"YYMM";
    }

    if(up=="MONTH"&&under=="YEAR"){
        cout<<"MMYY";
    }

    if(up=="MONTH"&&under=="MONTH"){
        cout<<"AMBIGUOUS";
    }


    return 0;
}

Measured memory_bytes: 256