akhauriyash/Code-Regression huggingface dataset:
import math

cos60=math.cos(math.radians(60))
sin60=math.sin(math.radians(60))

def knoc(n, l, r):
    if n == 0:
        return
    s = ((2*l[0]+r[0])/3, (2*l[1]+r[1])/3)
    t = ((l[0]+2*r[0])/3, (l[1]+2*r[1])/3)
    ux = (t[0]-s[0])*cos60-(t[1]-s[1])*sin60+s[0]
    uy = (t[0]-s[0])*sin60+(t[1]-s[1])*cos60+s[1]
    u = (ux, uy)
    
    knoc(n-1, l, s)
    print(s[0],s[1])
    knoc(n-1, s, u)
    print(u[0],u[1])
    knoc(n-1, u, t)
    print(t[0],t[1])
    knoc(n-1, t, r)
    
n = int(input())

start = (0,0)
end = (100,0)

print(start[0],start[1])
knoc(n, start, end)
print(end[0],end[1])
    


Measured memory_bytes: 5780
fun main(args: Array<String>) {
    abc125d()
}

fun abc125d() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toLong() }

    val negValCount = aList.count { it < 0 }
    val absList = aList.map { Math.abs(it) }.sorted()
    val minAbs = absList.first()

    val answer = if (negValCount % 2 == 0) absList.sum() else absList.drop(1).sum() - minAbs

    println(answer)
}


Measured memory_bytes: 61876
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  console.log(buildMaxHeap(arr).reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  let left, right, largest;
  const maxHeapify = (i) => {
    right = (left = 2 * i + 1) + 1;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



Measured memory_bytes: 140208
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

c = [[0]*3 for _ in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                c[i][j] = 1


for i in range(3):
  if c[i][0] and c[i][1] and c[i][2]:
    print('Yes')
    exit()
  if c[0][i] and c[1][i] and c[2][i]:
    print('Yes')
    exit()
if c[0][0] and c[1][1] and c[2][2]:
  print('Yes')
  exit()
if c[0][2] and c[1][1] and c[2][0]:
  print('Yes')
  exit()

print('No')

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

using namespace std;

#define REP(i, a, b) for(ll i=a;i<b;i++)
#define REPR(i, a, b) for(ll i=b-1;i>=a;i--)
#define forr(i, n) for(ll i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define w(t) int t;cin>>t;while(t--)
#define W(t) ll t;cin>>t;while(t--)
#define endl '\n'
#define space ' '
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl

typedef long long ll;

// const int N = 2e5 + 5;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int X;
	cin >> X;
	if (X >= 30)
		yes;
	else
		no;
	return 0;
}


Measured memory_bytes: 3624
n, m = map(int, input().split())
mod = 10**9 + 7
ans = 1
if n == m:
    for i in range(n):
        ans = ans * (i + 1) % mod
    print(ans * ans % mod * 2 % mod)
elif abs(n - m) == 1:
    for i in range(min(n, m)):
        ans = ans * (i + 1) % mod
    print(ans * max(n, m) % mod * ans % mod)
else:
    print(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG


int main() {
  ll N, K;
  cin >> N >> K;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));
  
  double ans_f = log(N)/log(K);

  cout << (int)ans_f + 1 << endl;

  return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < n; i++) 
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

void load() {
	ll a, b; 
	scanf("%lld%lld", &a, &b);
	int br = 0;
	while (a <= b && a > 0) {
		a *= 2;
		br++;
	}
	printf("%d\n", br);
}

void solve() {

}

int main() {
	load();
	solve();
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int sum = sc.nextInt();
			
			if(sum == 0){
				break;
			}
			
			for(int i = 0; i < 9; i++){
				sum -= sc.nextInt();
			}
			
			System.out.println(sum);
		}
		
	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
typedef long long ll;
using namespace std;

const int N = 4005;

int R[N], G[N], B[N];

int main(){
    IOS
    int n;
    cin >> n;
    string s;
    cin >> s;
    FOR(i,1,n){
        R[i] = R[i-1] + (s[i-1] == 'R');
        G[i] = G[i-1] + (s[i-1] == 'G');
        B[i] = B[i-1] + (s[i-1] == 'B');
    }
    ll ans = 0;
    int c = 'R' + 'G' + 'B';
    FOR(i,1,n){
        FOR(j,i+2,n){
            if(s[i-1] != s[j-1]){
                char x = (char)(c - (s[i-1] + s[j-1]));
                if(x == 'R'){
                    ans += R[j] - R[i-1];
                }
                else if(x == 'G'){
                    ans += G[j] - G[i-1];
                }
                else{
                    ans += B[j] - B[i-1];
                }
                if((i + j) % 2 == 0){
                    if(s[(i + j)/2-1] == x){
                        ans--;
                    }
                }
            }
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
 
int main() {
    int n, min = 1001, min2 = 1001, a, b;
    double x;
    cin >> n;
    vector<int> as(n);
    for (int i = 0; i < n; i++){
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    x = as[0];
    for (int i = 0; i < n - 1; i++){
        x = (x + as[i + 1]) / 2.0;
    }
    cout << x << endl;
}

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

bool check(int x,int y,int z)
{
    return (x + y > z) && (x + z > y) && ( y + z > x ) && x != y && x!=z && y !=z;
}
int main(){
    int n;
    while(scanf("%d",&n) == 1 && n)
    {
        int buffer[n];
        for(int i = 0; i < n; ++i) scanf("%d",&buffer[i]);
        int cont = 0;
        for(int i = 0; i < n -2 ; ++i) 
        {
            for(int j = i + 1; j < n - 1; ++j)
            {
                for(int k = j + 1; k < n; ++k)
                {
                    if(check(buffer[i],buffer[j],buffer[k])) 
                    {
                        ++cont;
                    }
                }
            }
        }
        printf("%d\n",cont);
    } 
    return 0;
}


Measured memory_bytes: 3764
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		String p[]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110"
		,"01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111"
		,"1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
		String c=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		String q[]={"11010","11110","11100","11101","11011","11111","00000","00001","00010","00011","00100"
		,"00101","00110","00111","01000","01001","01010","01011","01100","01101","01110","01111","10000","10001"
		,"10010","10011","10100","10101","10110","10111","11000","11001"};
		while(s.hasNext()){
			String k=s.nextLine();
			String a="";
			for(int i=0;i<k.length();i++)
				for(int j=0;j<32;j++)if(k.charAt(i)==c.charAt(j))a+=p[j];
			while(a.length()%5!=0)a+="0";
			String e="";
			for(int i=0;i<a.length()/5;i++){
				for(int j=0;j<32;j++){
					if(a.substring(i*5,(i+1)*5).equals(q[j]))e+=c.charAt(j);
				}
			}
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<cstring>
#include<iomanip>
#define _USE_MATH_DEFINES
#include<cmath>
using namespace std;
int main()
{
	int a,b,hour,min;
	cin>>a>>b>>hour>>min;
	double hd=30*hour+min*0.5;
	double md=6*min;
	double du=fabs(hd-md);
	if(du>180)
	du=360-du;
	double ans=sqrt(a*a+b*b-2*a*b*cos(M_PI*du/180));
	cout<<fixed<<setprecision(20)<<ans;
} 

Measured memory_bytes: 4164
#include <iostream>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	int n;
	int a[1001];
	while(cin >> n && n)
	{
		double sum = 0;
		rep(i,n) 
		{
			cin >> a[i];
			sum += a[i];
		}

		sum /= n;
		double ans = 0;
		rep(i,n)
		{
			ans += ((a[i] - sum)*(a[i] - sum))/n;
		}
		cout << fixed;
		cout.precision(8);
		cout << sqrt(ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
lis = input().split()
st = []
for i in lis:
  if i == "+":
    x = st.pop()
    y = st.pop()
    st.append(x+y)
  elif i == "-":
    x = st.pop()
    y = st.pop()
    st.append(y-x)
  elif i == "*":
    x = st.pop()
    y = st.pop()
    st.append(x*y)
  else:
    st.append(int(i))
print(st[0])  


Measured memory_bytes: 5600
import java.util.Scanner;

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

    int N = scanner.nextInt();
    long[] A = new long[N];
    long[] B = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = scanner.nextInt();
      B[i] = scanner.nextInt();
    }
    long res = 0;
    for (int i = N - 1; i >= 0; i--) {
      A[i] += res;
      long r = A[i] % B[i];
      if (r > 0) res += B[i] - r;
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 87612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N; cin >> N;
    cout << (int)sqrt(N) * (int)sqrt(N) << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            for(int k = 0; k < 30; k ++){
                if(((i >> k) & 1) ^ ((j >> k) & 1)){
                    cout << k + 1 << " ";
                    break;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
    int t[5];
    for (int i = 0; i < 5; i++)
        cin >> t[i];

    sort(t, t+5);
    int ans = INT_MAX;
    do {
        int time = 0;
        for (int i = 0; i < 5; i++){
            if (t[i]%10 == 0 || i == 4)
                time += t[i];
            else
                time += t[i] + 10-t[i]%10;
        }
        ans = min(ans, time);
    }
    while (next_permutation(t, t+5));

    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <stdio.h>
int main(void){
    char n[3];
    scanf("%s", n);
    for (int i = 0; i < 3; i++) {
        if (n[i] == '1') n[i] = '9';
        else if (n[i] == '9') n[i] = '1';
    }
    printf("%s\n", n);
    return 0;
}


Measured memory_bytes: 128
use std::io::*;
 
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    if s[0] == s[2] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2096
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

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


    ll A, B, C;
    cin >> A >> B >> C;

    auto solve = [&]() {
        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1)return 0LL;
        if (A == B && B == C)return -1LL;
        ll cnt = 0;
        while ((A % 2 == 0 && B % 2 == 0 && C % 2 == 0)) {
            ll a = (B + C) / 2;
            ll b = (C + A) / 2;
            ll c = (A + B) / 2;
            A = a;
            b = b;
            C = c;
            cnt++;
        }
        return cnt;
    };

    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
T = [int(input()) for _ in range(n)]

import fractions
#import math
from functools import reduce
def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)
  #return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

print(lcm_list(T))


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


template<int mod>
struct ModInt{
	int x;

	ModInt() : x(0){}
	ModInt(long long y) : x(y>=0 ? y%mod : (mod-(-y)%mod)){}

	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}

	ModInt operator-() const{return ModInt(-x);}
	ModInt operator+(const ModInt &p) const{return ModInt (*this)+=p;}
	ModInt operator-(const ModInt &p) const{return ModInt (*this)-=p;}
	ModInt operator*(const ModInt &p) const{return ModInt (*this)*=p;}
	ModInt operator/(const ModInt &p) const{return ModInt (*this)/=p;}
	bool operator==(const ModInt &p) const{return x==p.x;}
	bool operator!=(const ModInt &p) const{return x!=p.x;}
	friend ostream &operator<<(ostream &os, const ModInt &p){return os<<p.x;}
	friend istream &operator>>(istream &is,ModInt &a){
		int t;
		is>>t;
		a=ModInt<mod>(t);
		return (is);
	}

	ModInt inverse() const{
		int a=x, b=mod, u=1, v=0, t;
		while(b>0){
			t=a/b;
			a-=t*b;
			swap(a,b);
			u-=t*v;
			swap(u,v);
		}
		return ModInt(u);
	}
	
	ModInt pow(int e) const{
		long long a=1,p=x;
		while(e>0){
			if(e%2==0){p=(p*p)%mod; e/=2;}
			else {a=(a*p)%mod; e--;}
		}
		return ModInt(a);
	}
};

const int p=1000000007;
using modint = ModInt<p>;

int mod_pow(int a,int n){
	if(n==0)return 1;
	if(n%2==1) return (a*mod_pow(a,n-1))%p;
	int tmp=mod_pow(a,n/2);
	return (tmp*tmp)%p;
}

int ncr(int n,int a){
	int ans=1;
	for(int i=0;i<a;i++){
		ans*=(n-i);
		ans%=p;
	}
	int Y=1;
	for(int i=1;i<=a;i++){Y*=i; Y%=p;}
	Y=mod_pow(Y,p-2);
	return (ans*Y)%p;
}

signed main(){
	int n,a,b; cin>>n>>a>>b;
	int tmp=mod_pow(2,n)-1;
	int ans=tmp-ncr(n,a)-ncr(n,b);
	modint A=ans;
	cout<<A<<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{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        	String list = br.readLine();
        	String an = null;
        	for (int i = 1; i <= Integer.parseInt(list); i++)
        	{
        		if (i % 3 == 0)
        			System.out.print(" " + i);
        		else
        		{
        			Integer oi = new Integer(i);
        			String suji = oi.toString();
        			char[] charsuji = suji.toCharArray();
        			for (int j = 0; j < suji.length(); j ++)
        			{
        				String newsuji = String.valueOf(charsuji[j]);
        				if (newsuji.equals("3"))
        				{
        					System.out.print(" " + i);
        				    break;
        				}
        			}
        		}
        	}
        	System.out.println();
	}

}

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

int main()
{
	int n;
	cin >> n;
	vector<int> vec;

	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		vec.push_back(tmp);
	}
	
	vector<int> tmp = vec;
	sort(tmp.begin(), tmp.end());
	int smallAns = tmp[n / 2 - 1];
	int bigAns = tmp[n / 2];

	for (int i = 0; i < n; i++)
	{
		if (vec[i] <= smallAns)
		{
			cout << bigAns << endl;
		}
		else
		{
			cout << smallAns << endl;
		}

	}

	return 0;
}


Measured memory_bytes: 3828
//ABC089B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	set<char> s;
	char a;
	for(int i=0;i<n;i++){
		cin >> a;
		s.insert(a);
	}
	if(s.size() == 3){
		cout << "Three" << endl;
	}else{
		cout << "Four" << endl;
	}
	return 0;
}

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

string S;

int main(void) {
  cin >> S;

  REP(i, 0, 2) REP(j, 0, 2) REP(k, 0, 2) REP(l, 0, 2) {
    string t = "";
    t += (i == 0 ? "A" : "");
    t += "KIH";
    t += (j == 0 ? "A" : "");
    t += "B";
    t += (k == 0 ? "A" : "");
    t += "R";
    t += (l == 0 ? "A" : "");
    if(t == S) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}


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

using namespace::std;

int main()
{
	int N, A, B;
  	cin >> N >> A >> B;
	int max_num, min_num;
  	max_num = min(A, B);
  
    min_num = N-(A+B);
  	if(min_num >= 0)
      min_num = 0;
  	else
      min_num = -min_num;
  	cout << max_num << ' ' << min_num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  rep(i, K) {
    vector<int> B(N, 0);
    vector<int> lim(N, 0);
    
    int m = N;
    
    int k = 1;
    rep(i, N) {
      B[i] += k;
      k -= lim[i];
      if(i+A[i] < N) lim[i+A[i]]++;
      if(A[i] > 0) k++;
    }
    k = 0;
    rep(i, N) lim[i] = 0;
    rep(i, N) {
      B[N-1-i] += k;
      m = min(m, B[N-1-i]);
      k -= lim[N-1-i];
      if(N-1-i-A[N-1-i] >= 0) lim[N-1-i-A[N-1-i]]++;
      if(A[N-1-i] > 0) k++;
    }
    
    if(m == N) {
      rep(i, N) cout << B[i] << " ";
      cout << endl;
      return 0;
    }
    
    A = B;
  }
  
  rep(i, N) cout << A[i] << " ";
  cout << endl;
    
    
  

}

Measured memory_bytes: 8008
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
int a[310];
vector<int> v;
signed main(){
    int n,l;
    cin>>n>>l;

    int temp=-1,tans=INF;
    rep(i,n){
        a[i]=l+i;
        //cout<<a[i]<<endl;
        if(tans>=abs(a[i])){
            temp=i;
            tans=abs(a[i]);
        }
    }
    int ans=0;
    rep(i,n){
        if(temp==i)continue;
        ans+=a[i];
    }
    cout<<ans<<endl;


 
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll a, b;

	cin >> a >> b;

	ll res = 0;
	for (ll i = a; i > 0; i /= b)
	{
		res++;
	}

	println(res);
}

Measured memory_bytes: 256
#include<stdio.h>
int dp[3001][3001];
int main(void)
{
	int i,j,n,t,s,a[3001],b[3001],max;
	scanf("%d%d%d",&n,&t,&s);
	for(i=0;i<n;i++) scanf("%d%d",&a[i],&b[i]);
	for(i=0;i<=n;i++){
		for(j=0;j<=t;j++) dp[i][j]=-1;
	}
	dp[0][0]=0;
	for(i=0;i<n;i++){
		for(j=0;j<=t;j++){	
			if(dp[i][j]!=-1){
				if(dp[i][j]>dp[i+1][j]) dp[i+1][j]=dp[i][j];
				if(s>=j+b[i]||s<=j){
					if(j+b[i]<=t&&dp[i][j]+a[i]>dp[i+1][j+b[i]]) dp[i+1][j+b[i]]=dp[i][j]+a[i];
				}
				else if(s+b[i]<=t&&dp[i][j]+a[i]>dp[i+1][s+b[i]]) dp[i+1][s+b[i]]=dp[i][j]+a[i];
			}
		}
	}
/*	for(i=0;i<=n;i++){
		for(j=0;j<=t;j++) printf("%d ",dp[i][j]);
			printf("\n");
	}*/
	max=0;
	for(i=0;i<=t;i++){
		if(max<dp[n][i]) max=dp[n][i];
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 37868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll dp[61][2][2][2][2];
ll L, R;

ll dfs(int pos, bool ismax, bool ismin, bool ismaxy, bool zero) {
	if (pos == -1) return 1;
	ll &res = dp[pos][ismax][ismin][ismaxy][zero];
	if (~res) return res;
	
	res = 0;
	if ((!ismax || ismax && R >> pos & 1) && (!ismaxy || ismaxy && R >> pos & 1)) res += dfs(pos - 1, ismax, ismin & (L >> pos & 1), ismaxy, false);
	if (!ismin || ismin && L >> pos & 1 ^ 1) {
		
		if (!zero && (!ismaxy || ismaxy && R >> pos & 1)) res += dfs(pos - 1, ismax & (R >> pos & 1 ^ 1), ismin, ismaxy, zero);
		res += dfs(pos - 1, ismax & (R >> pos & 1 ^ 1), ismin, ismaxy & (R >> pos & 1 ^ 1), zero);
	}
	res %= MOD;
	return res;
}

int main() {
	cin >> L >> R;
	memset(dp, -1, sizeof(dp));
	cout << dfs(60, true, true, true, true) << endl;
	return 0;
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int H, W, N;

int main(){
  cin >> H >> W >> N;
  int sy, sx;
  cin >> sy >> sx;
  string S, T;
  cin >> S >> T;

  int ans = true;
  // ←
  {
    int x = sx;
    rep(i, N){
      if(S[i] == 'L') x--;
      if(x == 0) {
        ans = false;
        goto F;
      }
      if(x != W && T[i] == 'R') x++;
    }
  }
  // →
  {
    int x = sx;
    rep(i, N){
      if(S[i] == 'R') x++;
      if(x == W + 1) {
        ans = false;
        goto F;
      }
      if(x != 1 && T[i] == 'L') x--;
    }
  }
  // ↑
  {
    int y = sy;
    rep(i, N){
      if(S[i] == 'U') y--;
      if(y == 0) {
        ans = false;
        goto F;
      }
      if(y != H && T[i] == 'D') y++;
    }
  }
  // ↓
  {
    int y = sy;
    rep(i, N){
      if(S[i] == 'D') y++;
      if(y == H + 1) {
        ans = false;
        goto F;
      }
      if(y != 1 && T[i] == 'U') y--;
    }
  }

F:
  puts(ans ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	int n;
	string test;
	cin >> test;
	n = test.size();
	int ans = 0;

	for (int i = 0; i < n / 2; i++) {
		if (test[i] != test[n - 1 - i])ans++;
	}

	printf("%d", ans);

	return 0;
}



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


using namespace std;
typedef long long ll;
typedef pair<ll,ll> LL;

vector<ll> plist;

bool checksosu(ll num){
    for(ll prime:plist){
        if(num%prime==0){
            return false;
        }
    }
    return true;
}

int main(void){
    ll X;
    cin>>X;
    if(X==2){
      cout<<2<<endl;
      return 0;
    }
    if(X==3){
      cout<<3<<endl;
      return 0;
    }
    if(X==4){
      cout<<5<<endl;
      return 0;
    }

    plist.push_back(2);
    plist.push_back(3);
    ll num = 5;
    while(true){
        if(checksosu(num)){
            if(num>=X){
                cout<<num<<endl;
                break;
            }
            plist.push_back(num);
        }
      num++;
      num++;
    }

    return 0;
}

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

int main(){

  string s;
  cin>>s;

  char a[4];
  for(int i=0;i<4;i++){
      a[i]=s[i];
  }
  sort(a,a+4);

  if(a[0]==a[1] && a[2]==a[3] && a[0]!=a[3]){
      cout<<"Yes"<<endl;
  }else{
      cout<<"No"<<endl;
  }

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

char a[51][51];
char b[51][51];


signed main(){
  int n,m;
  cin>>n>>m;
  rep(i,n)rep(j,n)cin>>a[i][j];
  rep(i,m)rep(j,m)cin>>b[i][j];
  bool flag=false;

  rep(i,n){
    rep(j,n){
      if(i+m-1>=n||j+m-1>=n)continue;
      bool key=true;
      rep(k,m){
        rep(l,m){
          if(a[i+k][j+l]!=b[k][l])key=false;
        }
      }
      if(key)flag=true;
    }
  }

  cout<<(flag?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class395
    {
        static void Main()
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NK[0], K = NK[1];
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(l);
            int leng = 0;
            for (int i = N - 1; i >= N-K; i--)
            {
                leng += l[i];
            }

            Console.WriteLine(leng);
        }
    }
}


Measured memory_bytes: 28064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    
   int n;
   cin>>n;
   vector<ll> A(n);
   rep(i,n){
       cin>>A[i];
   }
   //累積和
   vector<ll> B(n+1);
   B[0]=0;
   for(int i=1;i<=n;i++){
       B[i]=A[i-1];
       B[i]+=B[i-1];
   }
   sort(B.begin(), B.end());
//    for(auto b:B){
//        cout<<b<<" ";
//    }
//    cout<<endl;
   vector<ll> ans;
   ll count=1;
   int i=1;
   while(i<=n){
       while(B[i]==B[i-1] && i<=n){
           count++;
           i++;
       } 
       ans.push_back(count);
       count=1;
       i++;
   }
//    for(auto an:ans){
//        cout<<an<<" ";
//    }
//    cout<<endl;
   ll res=0;
   rep(i, ans.size()){
       if(ans[i]%2==0){
           res+=(ans[i]/2)*(ans[i]-1);
       }else{
           res+=((ans[i]-1)/2)*ans[i];
       }
        // res+=ans[i]*(ans[i]-1)/2;
   }

    cout<<res<<endl;

    return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 999999999
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

//================================================
int func(int n, int s, int c) {
	if (n == 0 && s == 0) return 1;
	
	if ((s > 0 && n == 0) || (n >= 2 && s <= 0) || c < 0){
		return 0;
	}

	if (c > s) {
		return func(n, s, c - 1);
	} else {
		return func(n - 1, s - c, c - 1) + func(n, s, c - 1);
	}
}


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

	int n, s;
	while (cin >> n >> s) {
		if (n == 0 && s == 0 ) break;
		cout << func(n, s, 9) << "\n";
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    LL a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }

    LL ans = 0;
    loop(i,0,n)
    {
        loop(j,i+1,n)
        {
            loop(k,j+1,n)
            {
                if(a[i] != a[j] && a[i] != a[k] && a[j] != a[k])
                {
                    if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i]) ++ans;
                }
            }
        }
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3640
import java.util.*;
 
public class Main {
    public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            long a = sc.nextLong();
            long b = sc.nextLong();
            long x = sc.nextLong();
            long n = 0;
            if (x==0) {
              System.out.println(n);
              return;
            }
            n = b/x - a/x;
 
            if (a % x == 0) { n++; }
             // output
            System.out.println(n);
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

int vege[1000];

bool comp(int a, int b){
	return a > b;
}

int main(){
	int n, m;
	while(cin >> n >> m && (n || m)){
		for(int i = 0; i < n; i++){
			cin >> vege[i];
		}
		sort(vege, vege + n, comp);
		int cost = 0;
		for(int i = 0; i < n; i++){
			if((i + 1) % m == 0) continue;
			cost += vege[i];
		}
		cout << cost << endl;
	}
	return 0;
}

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

int Sum(long long n) 
{
	int res = 0;
	while (n > 0) 
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}
int main() 
{
	long long n, temp;
	cin >> n;
	int ans = Sum(n);
	temp = n;
	long long cnt = 1;
	while (temp >= 10) 
	{
		temp /= 10;
		cnt *= 10;
	}
	ans = max(ans, Sum(n / cnt * cnt - 1));
	cout << ans << endl;
	return 0;
}

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



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

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}



ll x,k;

int main()
{
    cin>>x>>k;

    ll div=x/k;
    

    ll a,b;
    a=abs(k*div-x);
    b=abs(k*div+k-x);

    if(a<b){
        cout<<a<<endl;
    }else{
        cout<<b<<endl;
    }

    return 0;

}




Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    int N,T,A;
    cin>>N>>T>>A;
    int ans=0;
    float min=10000000;
    for(int i=0;i<N;i++){
        int h;cin>>h;
        float a=A-(T-h*0.006);
        if(a<0)a*=-1;
        if(min>a){
            min=a;
            ans=i+1;
        }
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}
const int MAX = 2000000;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, 0, N) { cin >> a[i]; }
    int t = 1;
    int res = 0;
    rep(i, 0, N) {
        if(t == a[i]) {
            res++;
            t++;
        }
    }
    if(res == 0) {
        cout << -1 << endl;
    } else {
        cout << N - res << endl;
    }
}


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

using namespace std;

int main(){
	string s;

	cin >> s;

	int num1 = (s[0] - '0') * 10 + s[1] - '0';
	int num2 = (s[2] - '0') * 10 + s[3] - '0';
	bool can1 = false, can2 = false;

	if(num1 >= 1 && num1 <= 12){
		can1 = true;
	}

	if(num2 >= 1 && num2 <= 12){
		can2 = true;
	}

	if(can1 && can2){
		cout << "AMBIGUOUS" << endl;
	}else if(can1){
		cout << "MMYY" << endl;
	}else if(can2){
		cout << "YYMM" << endl;
	}else{
		cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int i;
	int num4=0;
	int num2=0;
	int num1=0;
	LL A;
	for (i=0;i<N;i++){
		cin>>A;
		if (A%4==0){
			num4++;
		}else if (A%2==0){
			num2++;
		}else{
			num1++;
		}
	}
	if (num1==0){
		cout<<"Yes"<<endl;
		return 0;
	}
	if (num1<num4){
		cout<<"Yes"<<endl;
		return 0;
	}
	int N4=N-(2*num4+1);
	if (N4==0){
		cout<<"Yes"<<endl;
		return 0;
	}
	
	if (num2>N4 && num2>1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,P = map(int,input().split(" "))
A = list(map(int,input().split(" ")))

odd = 0
even = 0
for i in range(N):
    if A[i] % 2 == 1:
        odd += 1
    else:
        even += 1

def nCr(n:int ,r: int) -> int:
    r,v = min(n-r,r),1
    for i in range(r):
        v = (v * (n-i) // (i+1))
    return v

ans = 0
for j in range(1,N+1,2):
    if j > odd:
        break
    ans += nCr(odd,j) * (2**even)

if P == 1:
    print(ans)
else:
    print(2**N - ans)

Measured memory_bytes: 38384
#include<stdio.h>
#include<math.h>
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if((a==b)&&(a!=c))
    printf("Yes");
  else
    if((a==c)&&(a!=b))
      printf("Yes");
      else
        if((c==b)&&(c!=a))
        printf("Yes");
        else
          printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,h[maxn],tot,ans[maxn];
set<int>comp[maxn];
struct node
{
    int to,nxt,com;
}e[maxn<<2];
void add(int x,int y,int z)
{
    tot++;
    e[tot].to=y;
    e[tot].com=z;
    e[tot].nxt=h[x];
    h[x]=tot;
}
priority_queue<pair<int,int> >p;
int main()
{
    int i,j;
    memset(ans,inf,sizeof ans);
    scanf("%d%d",&n,&m);
    while(m--)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        add(a,b,c);
        add(b,a,c);
    }
    p.push({0,1});ans[1]=0;
    while(!p.empty())
    {
        int now=p.top().se,ca=-p.top().fi;
        p.pop();
        if(ans[now]<ca)continue;
        for(i=h[now];i;i=e[i].nxt)
        {
            int to=e[i].to,to_com=e[i].com;
            int to_ca=ca+(!comp[now].count(to_com));
            if(ans[to]>to_ca)
            {
                ans[to]=to_ca;
                p.push({-to_ca,to});
                comp[to].clear();
                comp[to].insert(to_com);
            }
            else if(ans[to]==to_ca)
            {
                comp[to].insert(to_com);
            }
        }
    }
    printf("%d\n",ans[n]==inf?-1:ans[n]);
    //system("Pause");
    return 0;
}

Measured memory_bytes: 20216
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aeroui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int L = in.nextInt();

            String[] arr = new String[N];
            for (int i = 0; i < N; ++i) arr[i] = in.next();
            Arrays.sort(arr);

            for (String s : arr)
                out.print(s);
        }

    }
}



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

int main() {
  int N,cnt=0;
  string S;
  cin >> S;
  N =S.size();
  vector<int> s(N);

  //s[i]は整数の列

  for(int i=0;i<N;i++){
  s[i] = S[i] - '0';
  }

  for(int i=1;i<N;i++){
     if(s[i] == s[i-1]){
     cnt++;
       if(s[i] ==1){
       s[i]=0;
       }
       else if(s[i]==0){
       s[i]=1;
       }
     }
  }


  cout << cnt << endl;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] s = new int[n];
		int sum = 0;
		for(int i=0;i<n;i++){
			s[i] = scanner.nextInt();
			sum += s[i];
		}
		if(sum % 10 != 0){
			System.out.println(sum);
			return ;
		}
		Arrays.sort(s);
		for(int i=0;i<n;i++){
			int result = sum - s[i];
			if(result % 10 != 0){
				System.out.println(result);
				return;
			}
		}
		System.out.println(0);
	}

}


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

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

using namespace std;
using lint=long long;

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

	lint ans=0;
	ans+=min(n,m/2);
	m-=2*min(n,m/2);
	ans+=m/4;
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
sb = n.times.map{gets.chomp}
m = gets.to_i
sr = m.times.map{gets.chomp}

ws = Hash.new(0)
sb.each{|wb| ws[wb] += 1}
sr.each{|wr| ws[wr] -= 1}

ans = 0
ws.each{|k,v| ans = [ans,v].max}
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const double pi=acos(-1);

int main(){
  string s;
  cin >> s;
  
  ll ans=0;
  rep(i,MOD){
    string t;
    cin >> t;
    if(t=="END_OF_TEXT"){
      cout << ans<< endl;
      return 0;
    }
    if(t.size()==s.size()){
      bool ok = true;
      rep(j,s.size()){
        if(t[j]==s[j]  || t[j]-'A'==s[j]-'a') continue;
        else{
          ok=false;
          break;
        }
      }
      if(ok){
        ans++;
      }
    }
          
  }
  
}



Measured memory_bytes: 3160