akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    char s[10];
    cin >>s;
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
        cout  << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n, W;
  cin >> n >> W;
  ll val[n], wt[n];
  for(int i = 0 ; i < n ; i++)
    cin >> wt[i] >> val[i];
  ll dp[n + 1][W + 1];
  memset(dp, 0, sizeof(dp));
  for(int i = 1 ; i <= n ; i++){
    for(int j = 1 ; j <= W ; j++){
      if(wt[i-1] <= j)
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-wt[i-1]] + val[i-1]);
      else
        dp[i][j] = dp[i-1][j];
    }
  }
  cout << dp[n][W];
}

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


// Modint
struct Mint {
	static const long long mod = (long long)(1e9 + 7);
	long long val;

	Mint() { val = 0; }
	Mint(long long a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(long long p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0)
			std::cerr << "WARNING: inv() is called with 0." << std::endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	long long ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	long long ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

Mint pow(Mint a, long long b) {
	return a.pow(b);
}


// Combinatorics
constexpr int MAX_N = 200003;
std::vector<Mint> fact(MAX_N), inv(MAX_N);

void init_fact() {
	fact[0] = inv[0] = 1;
	for (long long i = 1; i < MAX_N; i++) {
		fact[i] = fact[i - 1] * Mint(i);
		inv[i] = fact[i].inv();
	}
}

// aCb
Mint C(int a, int b) {
	if (a < b) return 0;
	Mint res = fact[a];
	res *= inv[b];
	res *= inv[a - b];
	return res;
}

// aPb
Mint P(int a, int b) {
	if (a < b) return 0;
	return fact[a] * inv[a - b];
}

// aHb
Mint H(int a, int b) {
	if (b == 0) return 1;
	return C(a + b - 1, b);
}


int main() {
	int n, k; std::cin >> n >> k;
	Mint ans = 0;
	for (int i = k; i <= n + 1; i++) {
		Mint hi = Mint(n)*Mint(n + 1)/Mint(2) - Mint(n - i)*Mint(n - i + 1)/Mint(2);
		Mint lo = Mint(i)*Mint(i - 1)/Mint(2);
		ans += hi - lo + Mint(1);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 6288
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define got(container,num) get<num-1>(container)
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m

using namespace std;
const int INF=LLONG_MAX-1e10;
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;

main()
{
    IOS
    string k;
    cin>>k;
    fa(i,k)b[i-'A']++;
    out(b[1]&& b[0]?"Yes":"No")
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    A,B = inputMap()
    if A == 1:
        A = 55
    if B == 1:
        B = 55
        
    if A < B:
        print("Bob")
    elif B<A:
        print("Alice")
    else:
        print("Draw")
            
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38512
#include<stdio.h>
#define N 101

void print(int *a, int n){
  int i;
  for(i=0;i<n;i++){
    if(i) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
}

void insertionsort(int *a, int n){
  int i,j,key;

  for(i=1;i<n;i++){    //０の時は前に数字がないので、１からスタート
    key=a[i];
    j=i-1;
    while(j>=0&&key<a[j]){  //前の数字より大きい時点で、最大なので移動はしない
      a[j+1]=a[j];
      j--;           //大きい方を前に、小さい方を後ろに移動させる
      a[j+1]=key;
    }
    print(a,n);  //表示
  }
}

int main(){
  int i,n,a[N];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);

  print(a,n);
  insertionsort(a,n);

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a, b, c;
    a=n%10;
    b=(n/10)%10;
    c=(n/100)%10;
    if(a==7 || b==7 || c==7){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 3104
n, m = map(int, input().split())
s = input()[::-1]
ans = []
now = 0
while now<n:
    for i in range(min(m, n-now), 0, -1):
        if s[now+i]=='0':
            now += i
            ans.append(i)
            break
    else:
        print(-1)
        exit(0)
print(*ans[::-1])

Measured memory_bytes: 11396
// D - Flipping Signs

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int min_abs = INF;
	int cnt_neg = 0;
	ll tot = 0;
	for (int i=0; i<N; i++) {
		int A;
		cin >> A;
		min_abs = min(min_abs, abs(A));
		if (A < 0) cnt_neg++;
		tot += abs(A);
	}

	ll ans;
	if (cnt_neg % 2 == 0) {
		ans = tot;
	} else {
		ans = tot - 2 * min_abs;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	double res = a[0];
	FOR(i,1, n) {
		res = (double)(res+a[i])/2;
	}

	cout << setprecision(20) << res << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

public class p1041{
	p1041(){
		string str;
		int n, sm;
		
		while((str = Console.ReadLine()) != null){
			n = (int.Parse(str))/4;
			if(n == 0) break;
			sm = 0;
			while(0 < n--)
				sm += int.Parse(Console.ReadLine());
			Console.WriteLine("{0}", sm);
		}
	}
	
	public static int Main(string[] args){
		new p1041();
		return 0;
	}
}

Measured memory_bytes: 5560
import std.stdio;
import std.algorithm;

const int INF = 99999999;
int[10][10] cost;
int[10] sum;
int n, m, a, b, c, ans;

void main(){
	while (scanf("%d", &n), n) {
		m = -1;
		foreach (i; 0..10) {
			cost[i][] = INF;
			cost[i][i] = 0;
		}
		foreach (i; 0..n) {
			scanf("%d%d%d", &a, &b, &c);
			cost[a][b] = cost[b][a] = c;
			m = max(m, max(a, b)+1);
		}

		warshall_floyd();
		
		sum[] = 0;
		ans = INF;
		foreach (i; 0..m) {
			foreach (j; 0..m) {
				sum[i] += cost[i][j]; 
			}
			if (ans > sum[i]) {
				ans = sum[i];
				a = i;
			}
		}
		writeln(a, " ", ans);
	}
}

void warshall_floyd(){
	for (int k = 0; k < m; k++)
		for (int i = 0; i < m; i++)
			for (int j = 0; j < m; j++)
				if (cost[i][j] > cost[i][k] + cost[k][j])
					cost[i][j] = cost[i][k] + cost[k][j];
}

Measured memory_bytes: 1036
// AGC013_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    ll N;
    cin >> N;
    vector<ll> vec(N), vec_diff(N-1);
    REP(i, N) cin >> vec[i];
    for (ll i = 1; i < N; ++i) {
        vec_diff[i-1] = vec[i] - vec[i-1];
    }
    
    // calculation
    if (N <= 2) {
        cout << 1 << "\n";
    } else {
        ll res = 1;
        ll diff_now;
        bool flag_before = (vec[1]-vec[0]) > 0, flag_now;
        bool flag_flat = (vec[1]-vec[0] == 0);
        
        for (ll i = 2; i < N; ++i) {
            diff_now = vec[i] - vec[i-1];
            flag_now = diff_now > 0;  // 増加なら true
            if (diff_now == 0) {
                continue;
            }
            
            if (flag_flat) {
                flag_flat = false;
            } else {
                // flag の変化があった時に それを数える
                if (flag_before != flag_now) {
                    res += 1;
                    flag_flat = true;
                }
            }
            
            flag_before = flag_now;
        }
        cout << res << "\n";
    }
    return 0;
}


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

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

	vector<int> div(n + 1, 0);
	for (int i = 2; i <= n; i++) {
		int num = i;
		for (int j = 2; j <= i; j++) {
			while (num % j == 0) {
				div[j]++;
				num /= j;
			}
		}
	}

	// 24, 14, 4, 2
	vector<int> cnt(4, 0);
	rep(i, n + 1) {
		if (div[i] > 23) cnt[0]++;
		if (div[i] > 13) cnt[1]++;
		if (div[i] > 3) cnt[2]++;
		if (div[i] > 1) cnt[3]++;
	}

	int ans = 0;
	if (cnt[0] > 0) {
		ans += cnt[0] * (cnt[3] - 1);
	}
	if (cnt[1] > 0) {
		ans += cnt[1] * (cnt[2] - 1);
	}
	ans += cnt[2] * (cnt[2] - 1) / 2 * (cnt[3] - 2);
	if (div[2] > 73) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N, K;
  cin >> N >> K;
  vector <int> h(N);
  rep(i,N) cin >> h[i];
  sort(all(h));
  int ans = inf;
  rep(i,N - K + 1){
    ans = min(ans, h[i + K - 1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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; }

int main(){
	int n,x,t; cin>>n>>x>>t;
	int ans = ceil(n/(x+0.0))*t;
	printf("%d\n", ans);
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n;
vector<int> a;

bool solve(int i, int m){
    if(m == 0) return true;
    if(i >= n) return false;
    bool res = solve(i + 1, m) || solve(i + 1, m - a[i]);
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    rep(i, 0, n) cin >> a[i];
    int q;
    cin >> q;
    rep(i, 0, q){
        int m;
        cin >> m;
        if(solve(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T>
CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using 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 << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex) exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex) exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int K = read(), A = read(), B = read(), ans = 1;
  if (B - A <= 2) {
    ans += K;
  } else {
    ans = A;
    K -= A - 1;
    ans += (B - A) * (K / 2);
    ans += K % 2;
  }
  print(ans);

  return 0;
}


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

int main()
{
  char digit[1001];
  while (1) {
    cin >> digit;
    if(strcmp(digit, "0")==0) break;
    int sum = 0;
    for (int i=0; digit[i]!='\0'; i++) sum += digit[i] - '0';
    cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 220
// 44

using namespace std;

const int MAXN = (int) 2e5;

int arr[MAXN + 1];
ll sp[MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> arr[i];
        sp[i] = sp[i - 1] + arr[i];
    }
    ll ans = 1e18;
    for(i = 2; i <= n - 2; i++) {
        int res1 = 1, res2 = n - 1;
        for(int step = 1 << 17; step; step >>= 1) {
            if(res1 + step < i && 2 * sp[res1 + step] <= sp[i]) {
                res1 += step;
            }
            if(res2 - step > i && sp[n] - sp[res2 - step] <= sp[res2 - step] - sp[i]) {
                res2 -= step;
            }
        }
        //printf("%d %d\n" ,res1,res2);
        for(int a = 0; a <= 1; a++) {
            for(int b = -1; b <= 0; b++) {
                res1 += a;
                res2 += b;
                if(res1 < i && res2 < n) {
                    ll mx = max(max(sp[res1], sp[i] - sp[res1]), max(sp[res2] - sp[i], sp[n] - sp[res2]));
                    ll mn = min(min(sp[res1], sp[i] - sp[res1]), min(sp[res2] - sp[i], sp[n] - sp[res2]));
                    ans = min(ans, mx - mn);
                }
                res1 -= a;
                res2 -= b;
            }
        }
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 2560
def main():
    n, m = map(int, input().split())
    s, c = []*m, []*m
    for i in range(m):
        a, b = map(int, input().split())
        s.append(a), c.append(b)
    for i in range(0, 10 ** n):
        loop = True
        string = str(i)
        if len(string) != n:
            continue
        for j in range(m):
            if string[s[j] - 1] != str(c[j]):
                loop = False
        if loop:
            print(string)
            quit()
    print(-1)
if __name__ == "__main__":
    main()

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

int mcbottomup(int a[],int n)
{
    int pp;
   int p=0;
   int pnt=abs(a[2]-a[1]);


    for(int i=3;i<=n;i++)
    {
        pp=p;
        p=pnt;
        pnt=min(abs(a[i]-a[i-1])+p,abs(a[i]-a[i-2])+pp);
    }
    return pnt;
}
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){cin>>a[i];}
    cout<<mcbottomup(a,n);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a[3] = {}, val[3] = {1, 0, -1};
	for (int &i : a) cin >> i;
	int k; cin >> k;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		int mi = min(k, a[i]);
		ans += val[i] * mi;
		k -= mi;
	}
	cout << ans;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q), score(n, 0);
  for (int i = 0; i < q; i++) {
    int a;
    cin >> a;
    score[a - 1]++;
  }
  for (int i = 0; i < n; i++) {
    if (k - q + score[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

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

int main(){
  int cnt=0,port=0,tobe=0,asis=1,result=0;
  cin >> cnt;
  vector<int> f(cnt),s(cnt),p(cnt-1);
  rep(i,cnt) cin >> f[i];
  rep(i,cnt) cin >> s[i];
  rep(i,cnt-1) cin >> p[i];
  result += s[f[0]-1];
  for(int i=1;i<cnt;i++){
    result += s[f[i]-1];
    if(f[i]==f[i-1]+1){
      result += p[f[i-1]-1];
    }
  }
  cout << result << endl;
  return 0;
}

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

#define mp make_pair
#define fi first
#define se second
#define forn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) forn(i, 0, (n))
#define all(x) x.begin(), x.end()
#define len(x) (int)x.size()
#define endl '\n'

#define ld long double
#define vc vector
#define pq priority_queue
#define uset unordered_set
#define umap unordered_map
#define vi vc<int>
#define pii pair<int, int>
#define vii vc<pii>

inline void FASTIO(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void solve(){
    return;
}

signed main(){
    FASTIO();
    int n, k; cin >> n >> k;
    if(k >= n) cout << "unsafe";
    else cout << "safe";
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
  ll ans = 0;
  for (int i = N-1; i >= 0; i--) {
    A[i] += ans;
    ll tmp = B[i] - (A[i] % B[i]);
    if (tmp != B[i]) ans += tmp;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const K=input[0].split(' ')[1]-0;
  console.log(Math.floor(Math.log(N)/Math.log(K))+1);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


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

int main(){
	int d;
	cin >> d;
	
	if(d == 25) cout << "Christmas" << endl;
	else if(d == 24) cout << "Christmas Eve" << endl;
	else if(d == 23) cout << "Christmas Eve Eve" << endl;
	else if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
	
	return 0;
}

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

#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define Int const int &
const int mod=23333;

long long dis[233][233];
int r[66], rk[66];;

int main(void) {
	memset(dis, 0x3f, sizeof(dis));
	int n, m, rr;
	cin>>n>>m>>rr;
	for (int i=1; i<=rr; i++) {
		cin>>r[i];
		rk[i]=i;
	}
	for (int i=1; i<=n; i++) {
		dis[i][i]=0;
	}
	for (int i=1; i<=m; i++) {
		long long a, b, c;
		cin>>a>>b>>c;
		dis[a][b]=dis[b][a]=min(c, dis[a][b]);
	}
	for (int k=1; k<=n; k++) {
		for (int i=1; i<=n; i++) {
			for (int j=1; j<=n; j++) {
				dis[i][j]=min(dis[i][j], dis[i][k]+dis[k][j]);
			}
		}
	}
//	for (int i=1; i<=n; i++) {
//		for (int j=1; j<=n; j++) {
//			cout<<dis[i][j]<<' ';
//		}
//		cout<<'\n';
//	}
	long long ret=0x7f7f7f7f7f;
	do {
		long long ans=0;
		for (int i=2; i<=rr; i++) {
			ans+=dis[r[rk[i-1]]][r[rk[i]]];
		}
		ret=min(ans, ret);
	} while (next_permutation(rk+1, rk+1+rr));
	cout<<ret;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int x,p;cin>>x>>p;
  int ma=x*4;
  int mi=x*2;
  if(p>=mi&&p<=ma&&p%2==0)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int h,w,n;
char route[1050][1050];
int dirx[4]={0,-1,0,1};
int diry[4]={-1,0,1,0};
int vis[1005][1005];
struct maze
{
    int x,y;
    int time;
};
maze BFS(int dx,int dy,char ch)
{
    int xx,yy;
    queue<maze>q;
    memset(vis,0,sizeof(vis));
    maze a,b;
    a.x=dx;
    a.y=dy;
    a.time=0;
    q.push(a);
    vis[dx][dy]=1;
    while(!q.empty())
    {
        a=q.front();
        q.pop();
        if(route[a.x][a.y]==ch)
            return a;
        for(int i=0;i<4;i++)
        {
            xx=a.x+dirx[i];
            yy=a.y+diry[i];
            if(xx>=0&&xx<h&&yy>=0&&yy<w&&route[xx][yy]!='X')
            {
                b.x=xx;
                b.y=yy;
                b.time=a.time+1;
                if(!vis[xx][yy])
                {
                    q.push(b);
                    vis[xx][yy]=1;
                }
            }
        }
    }
}
int main()
{
    int dex=0,dey=0,tim;
    while(scanf("%d%d%d",&h,&w,&n)!=EOF)
    {
        getchar();
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
                scanf("%c",&route[i][j]);
                if(route[i][j]=='S')
                {
                    dex=i;
                    dey=j;
                    route[i][j]='0';//0起点开始
                }
            }
            getchar();
        }
        maze st;
        tim=0;
        for(int i=0;i<n;i++)//分段搜索最优路径，每段最优路径相加即为最终的最优路径
        {
            st=BFS(dex,dey,route[dex][dey]+1);
            tim+=st.time;
            dex=st.x;
            dey=st.y;
        }
        printf("%d\n",tim);
    }
    return 0;
}


Measured memory_bytes: 8168
a,b=io.read("n","n","l")
ok=true
for i,cc in ipairs{(io.read()):byte(1,a+1+b)} do
  if i==a+1 then
    ok=ok and cc == 45
  else
    ok=ok and cc ~= 45
  end
end
print(ok and "Yes" or "No")

Measured memory_bytes: 760
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	a = max(x - a, a - x);
	b = max(x - b, b - x);
	if (a > b)
		cout << "B";
	else
		cout << "A";
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 9000000000000000000 //9e18:極めて大きい値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define LOGMAXR 18 // floor(log2(10^5)) + 1: 配列の最大のrangeのlog
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素

int main(){
  char c;
  REP(i, 3){
    cin >> c;
    if(c == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 2988
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}

int main(void)
{
	int n,k;
	ll res,s,t; 
	scanf("%lld%lld",&n,&k);
	s=n/k;
	res=s*s*s;
	if(k%2==0){
		t=n/(k/2)-s;
		res+=t*t*t;
	}
	printf("%lld\n",res);
	return 0;
}
    
    
    

Measured memory_bytes: 128
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003

int dp[353][353]={0};
int bow[353][353]={0};

set<string> a;

int main(){
	
	int n,S;
	
	while(cin>>n>>S,n!=0||S!=0){
		int r[120]={0};
		int a;
		rep(i,n){
			cin>>a;
			r[a]++;
		}
		long long ans=0;
		REP(i,1,101){
			REP(j,i,101){
				if(i+j>S&&r[i]>0&&r[j]>0){
					if(i==j)
					ans+=r[i]*(r[i]-1)/2;
					else
					ans+=r[i]*r[j];
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1156
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main(void){
  int n, m, ans;
  int a[1000010];
  string s;
  while(cin >> n, n){
    cin >> m >> s;
    memset(a, 0, sizeof(a));
    ans = 0;
    for(int i = 0;i < m; i++){
      if(i >= 2 && a[i - 2] && s[i - 1] == 'O' && s[i] == 'I') a[i] = a[i - 2] + 1;
      else if(i < m - 2 && s[i] == 'I' && !a[i] && s[i + 1] == 'O' && s[i + 2] == 'I') a[i + 2]++;
    }
    for(int i = 0;i < m; i++){
      if(a[i] >= n) ans++;
    }
    cout << ans << endl;
  }
}


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

const int N = 2e5 + 10;

char a[N];
int n;

int main() {
	scanf("%d%s", &n, a);
	int l = 0, r = n - 1, num = 0;
	while (l < r) {
		if (a[l] == 'W') {
			while (r > l && a[r] != 'R') r--;
			if (a[r] == 'R') {
				num++;
				l++;
				r--;
			}
		} else {
			l++;
		}
	}
	printf("%d\n", num);
	return 0;
}

Measured memory_bytes: 3984
N, K = list(map(int, input().split()))

h = []
for i in range(N):
	h.append(int(input()))

ans = float("inf")
h = sorted(h)

for i in range(N - K + 1):
	if ans > h[i + K - 1] - h[i]:
		ans = h[i + K - 1] - h[i]

print(ans)

Measured memory_bytes: 8280
N, Q = map(int, input().split())
S = input()

t = [0] * (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

int main() {
    int a, b;
    cin >> a >> b;
    if(a + b == 15) {
        cout << "+" << endl;
        return 0;
    }
    if(a * b == 15) {
        cout << "*" << endl;
        return 0;
    }
    cout << "x" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


ll n;
  cin>>n;
  ll s=0,s1=0;
  if(n>=500)
  {s=n/500;
   n=n-s*500;
   s1=1000*s;
  // cout<<s;
  }
s=n/5;
  s1+=5*s;
  cout<<s1<<"\n";




return 0;}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }



int main() { 
    int n; cin >> n;
    vector<int> A(n+1); rep(i, n) cin >> A[i+1];
    vector<int> res(n+1);

    int one = 0;
    for(int num=n; num>0; num--){
        int cnt = 0;
        for(int i=num*2; i<=n; i += num){
            if(res[i]) cnt++;
        }
        if(cnt%2==1 && A[num]==0 || cnt%2==0 && A[num]==1) res[num] = 1, one++;
        else res[num] = 0;
    }
    
    cout << one << ln;
    for(int i=1; i<=n; i++){
        if(res[i]) cout << i << ln;
    }
}

Measured memory_bytes: 2432
import math

ABC = list(map(int,input().split()))

score = 0

if (max(ABC) + ABC[0] + ABC[1] + ABC[2]) % 2 == 0:
    score = (max(ABC) * 3 - ABC[0] - ABC[1] - ABC[2])
else:
    score = ((max(ABC) + 1) * 3 - ABC[0] - ABC[1] - ABC[2])

print(math.floor(score/2))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;

int main()
{
  char ch;
  while(true){
    scanf("%c",&ch); //scanfは' 'も読み取る
    if(ch=='\n') break;
    if(islower(ch)!=0){ //小文字ならばtrue
      ch=toupper(ch); //小文字→ 大文字
      cout << ch;
    }else if(isupper(ch)!=0){ //大文字ならばtrue
      ch=tolower(ch); //大文字→ 小文字
      cout << ch;
    }else{
      cout << ch;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1148
import heapq
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
ph = []
qh = []
for i in range(x):
    ph.append(p[i])
for i in range(y):
    qh.append(q[i])
heapq.heapify(ph)
heapq.heapify(qh)
for i in range(c):
    p0 = heapq.heappop(ph)
    q0 = heapq.heappop(qh)
    if min(p0,q0) >= r[i]:
        heapq.heappush(ph,p0)
        heapq.heappush(qh,q0)
        break
    else:
        if p0 > q0:
            heapq.heappush(ph,p0)
            heapq.heappush(qh,r[i])
        else:
            heapq.heappush(qh,q0)
            heapq.heappush(ph,r[i])
print(sum(ph)+sum(qh))

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(),(x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int,int> P;
typedef vector<int> vi;

int H,W;
const int MAX=500;
int mp[MAX][MAX];

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

    cin>>H>>W;
    rep(i,0,H) {
        rep(j,0,W) {
            cin>>mp[i][j];
        }
    }

    vector<P> bef;
    vector<P> aft;
    int ans=0;
    rep(i,0,H) {
        rep(j,0,W-1) {
            if(mp[i][j]%2==1) {
                mp[i][j+1]++;
                bef.pb(P(i,j));
                aft.pb(P(i,j+1));
                ans++;
            }
        }
    }
    rep(i,0,H-1) {
        if(mp[i][W-1]%2==1) {
            mp[i+1][W-1]++;
            bef.pb(P(i,W-1));
            aft.pb(P(i+1,W-1));
            ans++;
        }
    }
    cout<<ans<<endl;
    rep(i,0,bef.size()) {
        cout<<bef[i].fi+1<<' '<<bef[i].se+1<<' '<<aft[i].fi+1<<' '<<aft[i].se+1<<endl;
    }
    return 0;
}






Measured memory_bytes: 8164
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	vector<int> tapu;
	while (L > 0) {
		tapu.emplace_back(L % 2);
		L /= 2;
	}

	vector<tuple<int, int, int>> ans;
	vector<int> x(tapu.size(), 1);
	int sz = tapu.size();
	for (int i = 0; i + 1 < sz; ++i) {
		ans.emplace_back( i, i + 1, 0 );
		ans.emplace_back( i, i + 1, x[i] );
		x[i + 1] = x[i] * 2;
	}
	int X = 0;
	for (int i = sz - 1; i >= 0; --i) {
		if (tapu[i] == 0) { continue; }
		if (i < sz - 1) {
			ans.emplace_back( i, sz - 1, X );
		}
		X += x[i];
	}

	cout << tapu.size() << " " << ans.size() << endl;
	for (auto t : ans) {
		cout << get<0>(t) + 1 << " " << get<1>(t) + 1 << " " << get<2>(t) << endl;
	}

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
  set<char> list;
  for (int i=0; i<3; i++) {
    char c;
    cin >> c;
    list.insert(c);
  }
  if (list.size() == 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

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

int n, m;
int a[105], b[105];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		a[i] = 2 * i;
	for (int i = 1; i <= m; i++)
		b[i] = 2 * i - 1;
		
	int sum = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if ((a[i] + a[j]) % 2 == 0) sum++;
	for (int i = 1; i <= m; i++)
		for (int j = i + 1; j <= m; j++)
			if ((b[i] + b[j]) % 2 == 0) sum++;
	cout << sum << endl; 
	return 0;
}


Measured memory_bytes: 256
<?php

// define('DEBUG', true);
define('DEBUG', false);


fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));
// var_dump($a);
$arr = array();
$sq = array();
$target = 0;

rsort($a);

for ($i = 0; $i < $N; $i++) {
    $arr[$a[$i]]++;
    if ($arr[$a[$i]] == 2) {
        $sq[$target] = $a[$i];
        $arr[$a[$i]] -= 2;
        $target++;
        if ($target >= 2) {
            echo ($sq[0] * $sq[1]) . PHP_EOL;
            exit;
        }
    }
}

echo "0\n";


Measured memory_bytes: 19188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  bool p[3000+1];
  rep(i,0,3000+1) p[i]=false;
  int i=0;
  while(i<=3000){
    int j=i;
    while(j<=3000){
      p[j]=true;
      j+=d;
    }
    i+=c;
  }
  vector<int> q;
  rep(i,0,3000+1){
    if(p[i]) q.push_back(i);
  }
  int water=0;
  int sugar=0;
  int cur=-1;
  rep(i,0,30){
    rep(j,0,30){
      if(100*(a*i+b*j)<=f && i+j!=0){
        auto it=upper_bound(q.begin(),q.end(),min(f-100*(a*i+b*j),(a*i+b*j)*e));
        it--;
        if(*it/(a*i+b*j)>cur){
          sugar=*it;
          water=a*i+b*j;
          cur=*it/(a*i+b*j);
        }
      }
    }
  }
  cout<<100*water+sugar<<' '<<sugar<<endl;
}

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

int main()
{
    char s[105];
    cin.get(s, 105);
    int c, f, apc, apf;
    c = f = -1;
    apc = apf = 0;
    for(int i = 0; s[i]; i++)
        {
            if((s[i] == 'c' || s[i] == 'C') && !apc) apc = 1;
            if((s[i] == 'f' || s[i] == 'F') && apc) apf = 1;
        }
    if(apf == 1) cout << "Yes";
    else cout << "No";
    return 0;
}


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

vector <int> g[5];
vector <int> gr[5];

int memo[5];

int main () {
	
	int x=0, y=0, i=0;

	for (i=0; i<3; i++) {
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	bool flag=0;
	for (i=1; i<=4; i++) {
		if (g[i].size()>=3) {
			flag=1;
			break;
		}
	}

	if (flag==0) printf("YES\n");
	else printf("NO\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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; }
int main(void){
    string s; cin>>s;
    vector <vector<ll>> dp(2 ,vector <ll> (20, -114514));// 0ぴた1未満
    dp[0][0]= 0;
    for(int i=0;i<s.size();i++){
        int dd = s[i]-'0';
        // 未満 to 未満
        dp[1][i+1] = dp[1][i] + 9;
        // ぴた to 未満
        chmax(dp[1][i+1], dp[0][i]+ dd-1);
        //chmax(dp[1][i+1], dp[0][i]+9-1);
        // ぴたぴた
        chmax(dp[0][i+1], dp[0][i] + dd);
    }
    cout<<max(dp[0][s.size()], dp[1][s.size()]) <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
using namespace std;


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

    map<int, int> even, odd;

    rep(i, n) {
        if (i % 2 == 0) even[v[i]]++;
        else odd[v[i]]++;
    }

    int num_e = -1;
    int cnt_e1 = 0;
    int cnt_e2 = 0;
    for (auto e: even) {
        if (e.second > cnt_e1) {
            num_e = e.first;
            cnt_e2 = cnt_e1;
            cnt_e1 = e.second;
        } else if (e.second > cnt_e2) {
            cnt_e2 = e.second;
        }
    }

    int num_o = -1;
    int cnt_o1 = 0;
    int cnt_o2 = 0;
    for (auto e: odd) {
        if (e.second > cnt_o1) {
            num_o = e.first;
            cnt_o2 = cnt_o1;
            cnt_o1 = e.second;
        } else if (e.second > cnt_o2) {
            cnt_o2 = e.second;
        }
    }

    if (num_e != num_o) cout << n - cnt_e1 - cnt_o1 << endl;
    else cout << min(n- cnt_e1 - cnt_o2, n- cnt_e2 - cnt_o1) << endl;
}

Measured memory_bytes: 5376
using System;
using System.Collections.Generic;
using System.Linq;

class Pg
{
    static void Main()
    {
        var lst=Read0095().ToList();
        var ans =lst.Where(x => x == lst.Max()).First();
        Console.WriteLine("{0} {1}", lst.IndexOf(ans) + 1, ans);
    }
    private static IEnumerable<int> Read0095()
    {
        var n = int.Parse(Console.ReadLine());
        var tmplst = new List<IEnumerable<int>>();
        while (n-- > 0)
             tmplst.Add(Console.ReadLine().Split().Select(int.Parse));
        return tmplst.OrderBy(x => x.First()).Select(x => x.Last());
    }
}


Measured memory_bytes: 18608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e15)+1;
const ll mod = ll(1e9)+7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    pf(n / (a + b) * a + min(a,n % (a + b)));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
int count=0;

void merge(int* a,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;
  int l[n1],r[n2];

  for(i=0;i<n1;i++)l[i]=a[left+i];
  for(i=0;i<n2;i++)r[i]=a[mid+i];
  l[n1]=INT_MAX;
  r[n2]=INT_MAX;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(l[i]<=r[j]){
      a[k]=l[i];
      i++;
      count++;
    }else {
      a[k]=r[j];
      j++;
      count++;
    }
  }
}
  
void mergeSort(int* a,int left,int right){
  int mid;
  mid=(left+right)/2;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(a,left,mid);
    mergeSort(a,mid,right);
    merge(a,left,mid,right);
  }
}

int main(){
  int i,j,n;
  int a[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  mergeSort(a,0,n);
  for(i=0;i<n-1;i++)printf("%d ",a[i]);
  printf("%d\n%d\n",a[i],count);
  return 0;
}

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

using namespace std;

int n;
int x,y,h,code;
int lst[105][3];

bool check(int i){
	if(lst[i][2]==max(0,h-abs(x-lst[i][0])-abs(y-lst[i][1]))) return true;
	else return false;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>lst[i][0]>>lst[i][1]>>lst[i][2];
		if(h==0&&lst[i][2]!=0) code=i,h=-1;
	}
	for(x=0;x<=100;x++)
		for(y=0;y<=100;y++){
			bool flag=1;
			h=abs(x-lst[code][0])+abs(y-lst[code][1])+lst[code][2];
			
			for(int i=0;i<n;i++)
				if(!check(i)){flag=0;break;}
			if(flag){
				cout<<x<<' '<<y<<' '<<h<<endl;
				return 0;
			}
		}
	return -1;
}
				

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = LONG_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

int a[N], b[N];
int n;
void solve() {
	int i;
	for (i = 0; i <= n; i++) b[i] = 0;

	for (i = 0; i < n; i++) {
		int l = max(i - a[i], 0);
		int r = min(i + a[i] + 1, n);

		b[l]++;
		b[r]--;
	}

	for (i = 1; i <= n; i++)
		b[i] += b[i - 1];

	for (i = 0; i < n; i++) {
		a[i] = b[i];
	}

}

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;

	while (tc--) {

		int  m, k, i, j;
		int x, y;

		cin >> n >> k;

		for (i = 0; i < n; i++)
			cin >> a[i];

		int ok = 0;

		// for (i = 0; i < n; i++) {
		// 	// printf("%d ", a[i]);
		// 	cout << a[i] << " ";
		// }
		// cout << endl;

			
		while (k--) {
			ok = 1;
			for (i = 0; i < n; i++) {
				ok &= (a[i] == n);
			}

			if (ok)	break;


			solve();

		}

		for (i = 0; i < n; i++) {
			printf("%d ", a[i]);
		}

	}

}

Measured memory_bytes: 5308
#include <stdio.h>
#include <math.h>

typedef long long ll;

int F(ll A, ll B);

int main() {

	ll N;

	scanf("%lld",&N);

	ll i;

	int ans = 100;

	for (i = 1ll; i <= (int)sqrt((double)N) + 1; i += 1ll) {
		if (N%i == 0ll) {
			int a = F(i, N / i);
			if (ans > a) {
				ans = a;
			}
		}
	}
	printf("%d\n",ans);

	return 0;
}
int F(ll A, ll B) {
	int cnt = 0;

	while (1) {
		if (A == 0ll) { break; }
		A /= 10ll;
		cnt++;
	}
	int cnt2 = 0;

	while (1) {
		if (B == 0ll) { break; }
		B /= 10ll;
		cnt2++;
	}
	if (cnt > cnt2) {
		return cnt;
	}
	else {
		return cnt2;
	}
}

Measured memory_bytes: 128