akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ALL(c) c.begin(),c.end()
using namespace std;
using lli = long long;
static const int MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> V(N);
    for(int i=0; i<N; i++){cin >> V[i];}

    vector<int> odd(100001,0),even(100001,0),ordx(100001),ordy(100001);
    for(int i=0; i<N; i++){
        if(i%2 == 0){even[V[i]]++;}else{odd[V[i]]++;}
    }
    iota(ALL(ordx),0);
    sort(ALL(ordx),[&](int x,int y){return even[x] > even[y];});
    iota(ALL(ordy),0);
    sort(ALL(ordy),[&](int x,int y){return odd[x] > odd[y];});

    if(ordx[0] != ordy[0]){
        cout << (N - even[ordx[0]] - odd[ordy[0]]) << endl;
    }else{
        cout << min((N-even[ordx[0]]-odd[ordy[1]]),(N-even[ordx[1]]-odd[ordy[0]])) << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
import sys
import math
def resolve():
    S=input().rstrip()
    c=0
    for i in range((len(S)//2)):
        if(S[i]!=S[-i-1]):
            c+=1
    print(c)

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """redcoder"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """vvvvvv"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """abcdabc"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 5920
using System;
using System.Linq;

namespace _20200419_C
{
    class Program
    {
        static void Main(string[] args) { 


            long n= long.Parse(Console.ReadLine());

            long[] inputLongArray1 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long[] outputarray = new long[n];
            for (int i=0; i<n-1; i++)
            {
                outputarray[ inputLongArray1[i]-1 ]++;
                
            }

            for(int i=0; i < n; i++)
            {
                Console.WriteLine(outputarray[i]);
            }
        }
    }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int64 dist(pll a, pll b){
  return abs(a.first - b.first) + abs(a.second - b.second);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m;
  cin >> n >> m;
  vector<pll> ab(n),cd(m);
  REP(i,n)cin >> ab[i].first >> ab[i].second;
  REP(i,m)cin >> cd[i].first >> cd[i].second;
  REP(i,n){
    int32 mn = LLINF;
    int32 ans = -1;
    REP(j,m){
      if(dist(ab[i],cd[j]) < mn){
        mn = dist(ab[i],cd[j]);
        ans = j+1;
      }
    }
    ANS(ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
int main(){
  	std::string s1,s2;
  	std::cin>>s1>>s2;
  	if(s1.size()+1==s2.size()){
      for(int i=0;i<s1.size();++i){
        if(s1[i]!=s2[i]){
         	std::cout<<"No"<<std::endl; 
          	return 0;
        }
      }
      std::cout<<"Yes"<<std::endl;
    }else{
      std::cout<<"No"<<std::endl;
    }
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <cstdio>
#include <math.h>
#include <utility>
#include <list>
#include <functional>
using namespace std;

#define ll long long
#define vecint vector<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007
#define NIL -1

string A,B;


void solve(){
  if(A.size()>B.size()){
    print("GREATER");
    return;
  }else if(A.size()<B.size()){
    print("LESS");
    return;
  }else{
    rep(i,A.size()){
      char a=A[i];
      char b=B[i];
      if(a>b){
        print("GREATER");
        return;
      }else if(a<b){
        print("LESS");
        return;
      }else{
        continue;
      }
    }
  }
  print("EQUAL");
  return;
}

int main(){
  cin>>A>>B;
  solve();
  return 0;
}


Measured memory_bytes: 256
while True:
  a, operator, b = input().split()
  a, b = int(a), int(b)
  if operator == '?':
    break
  if operator == '+':
    print(a + b)
  if operator == '-':
    print(a - b)
  if operator == '*':
    print(a * b)
  if operator == '/':
    print(a // b)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#pragma optimize("TKACHENKO-GORYACHENKO")
#define psl pair <string, ll>
#define pls pair <ll, string>
#define x first
#define y second
#pragma GCC optimize("O3")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 4e5;
const ll inf = 1e9;

ll n, m, k, t, s;

int main()
{
	pyshnapyshnakaa;
	ll q, w, e, a, b, c;
	cin >> n >> k >> s;
	for (q = 0; q < k; q++) {
		cout << s << " ";
	}
	if (s == inf) {
		for (; q < n; q++) {
			cout << 1 << " ";
		}
	}
	else {
		for (; q < n; q++) {
			cout << s + 1 << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long n,ans=0;
    cin>>n;
    vector<long>a(3*n);
    for(int i=0;i<3*n;i++)cin>>a[i];
    sort(a.begin(),a.end(),std::greater<long>());
    for(int i=0;i<2*n;i+=2)ans+=a[i+1];
    cout<<ans<<endl;
    return 0;
}

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

ll n , x;
ll a[55], p[55]; ///バーガーの厚さと含まれるパティの数を入れる配列


ll dfs(ll N, ll X){
  if (N == 0) return 1;
  else if (X <= N) return 0;
  else if (X <= 1 + a[N-1]) return dfs(N-1, X-1);
  else if (X == 2 + a[N-1])  return p[N-1] + 1;
  else return p[N-1] + 1 + dfs(N-1, X-a[N-1]-2);
}

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

  a[0] = 1;
  p[0] = 1;
  rep(i, n) a[i + 1] = 2 * a[i] + 3;
  rep(i, n) p[i + 1] = 2 * p[i] + 1;
  ll ans = dfs(n, x);

  cout << ans << endl;


}


Measured memory_bytes: 3632
input = raw_input

exists = [False] * 203

x, n = map(int, input().split(" "))

inputs = input()
try:
    mid = 101
    ps = map(int, inputs.split(" "))
    for p in ps: 
        if abs(x-p) <= 100:
            diff = p - x
        #print(p, diff)
        exists[mid+diff] = True


    #print("exists", [i for i in range(203) if exists[i]])
    for i in range(0, 102):
        if not exists[mid-i]:
            out = x -i 
            break
        if not exists[mid+i]:
            out = x +i 
            break
except:
    out = x


print(out)

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

const int N = 2e5+10;
int memo[2][2][N];

string s;

int solve(int pos, bool one, bool two) {
    if(pos >= (int)s.size()) {
        return 0;
    }
    if(pos+1 >= (int)s.size()) {
        if(one) return 1;
        return -1e9;
    }
    if(pos+2 >= (int)s.size()) {
        if(one && s[pos] != s[pos+1]) {
            return 2;
        }
        if(two) {
            return 1;
        }
        return -1e9;
    }
    if(memo[one][two][pos] != -1) {
        return memo[one][two][pos];
    }

    int res = -1e9;
    if(one) {
        res = max(res, 1 + solve(pos+1, (s[pos] != s[pos+1]), true));
    }
    if(two) {
        bool canTwo = false;
        if(pos+3 >= (int)s.size()) canTwo = true;
        if(s.substr(pos, 2) != s.substr(pos+2, 2)) canTwo = true;
        res = max(res, 1 + solve(pos+2, true, canTwo));
    }

    return memo[one][two][pos] = res;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; ++i) {
        memo[0][0][i] = -1;
        memo[0][1][i] = -1;
        memo[1][0][i] = -1;
        memo[1][1][i] = -1;
    }
    cout << solve(0, true, true) << '\n';
}


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

const ll MOD = 1e9 + 7;
ll fact[211111];

ll inv(ll x) {
    ll res = 1, p = MOD - 2;
    while(p) {
        if(p & 1) res = (res * x) % MOD;
        x = (x * x) % MOD;
        p /= 2;
    }
    return res;
}

ll c(ll n, ll k) {
    if(k > n) return 0;
    return ((fact[n] * inv(fact[k]) % MOD) * inv(fact[n - k])) % MOD;
}

ll ways(ll n, ll m) {
    return c(n + m - 2, m - 1);
}

int main() {
    fact[0] = 1;
    for(ll i = 1; i < 211111; i++) 
        fact[i] = (i * fact[i - 1]) % MOD; 
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    ll ans = ways(H, W);
    for(int i = 0; i < A; i++) {
        ans = (ans - ways(H - A + 1 + i, B) * ways(A - i, W - B) % MOD+ MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
using System;
namespace test03
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] inputs = input.Split(' ');
            string answer = (int.Parse(inputs[0]) * int.Parse(inputs[1])).ToString();
            answer = answer + ' ' + (int.Parse(inputs[0]) * 2 + int.Parse(inputs[1]) * 2).ToString();
            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 5592
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = next();
  if(s[2] == s[3] && s[4] == s[5]){
    myout("Yes");
  }else{
    myout("No");
  }
}

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

typedef long long ll;
const int INF = 1e9;

const int S = 1e6 + 5;
int seen[S] = {0};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int k;
	cin>>k;
	int ans = 1;
	int cur = 7;
	while (1){
		cur %= k;
		// cout<<cur<<'\n';
		if (seen[cur]){
			cout<<"-1\n";
			return 0;
		}
		seen[cur] = 1;
		if (cur == 0){
			cout<<ans<<'\n';
			return 0;
		}
		cur *= 10;
		cur += 7;
		ans++;
	}
	return 0;
}

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

int main(){

    string s ;
    cin >> s ;
    ll ans = 0 ;
    ll n = 0 ;
    for (ll i = 0 ; i<s.size() ; i++) {
        if (s[i] =='R') n++ ;
        else {
            //n =0  ;
            ans = max(ans , n) ; n = 0 ;
        }
    }

    cout << max(ans, n) ;


    return 0 ;
}


Measured memory_bytes: 3616
n = int(input())
stones = input()
left = 0
right = n-1

ans = 0
while True:
  while left < n and stones[left] == 'R':
    left += 1
  while right > 0 and stones[right] == 'W':
    right -= 1
  if left < n and right > 0 and left < right:
    left += 1
    right -= 1
    ans += 1
  else:
    break
print(ans)

Measured memory_bytes: 67756
n=int(input())
sp=[]
for i in range(n):
  sp.append(list(map(str,input().split())))
  sp[i][1] = int(sp[i][1])
for i in range(n):
  sp[i].append(i)
sp = sorted(sp,key=lambda x:x[1])
sp.reverse()
sp = sorted(sp,key=lambda x:x[0])
for i in range(n):
  print(sp[i][2]+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int n, q, sum[101010];
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> q;
  string s; cin >> s;
  rep(i, 1, n) {
    if (s[i-1] == 'A' && s[i] == 'C') {
      sum[i]++;
    }
  }
  rep(i, 0, n) sum[i+1] += sum[i];
  rep(i, 0, q) {
    int l, r;
    cin >> l >> r;
    cout << sum[r-1] - sum[l-1] << endl;
  }
  return 0;
}



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

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

    string s;
    cin >> s;

    std::size_t a_pos = s.find_first_of('A');
    std::size_t z_pos = s.find_last_of('Z');

    cout << z_pos - a_pos + 1 << endl;

    return 0;
}


Measured memory_bytes: 832
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	m := make(map[rune]bool)
	for _, r := range s {
		m[r] = true
	}
	if len(m) == len(s) {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	string S;
	cin >> S;

	map<char, int> A;

	rep(i, 4) {
		A[S[i]]++;
	}

	for (auto a : A) {
		if (a.second != 2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;


	return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INFLL (1ll<<60)
static const int MAX=200000;
int N;
ll a[MAX],sum;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>N;
    cin>>a[0];
    for(int i=1;i<N;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    ll min_d=INFLL;
    
    for(int i=0;i<N-1;i++){
        if(min_d>abs(a[i]-(a[N-1]-a[i]))) min_d=abs(a[i]-(a[N-1]-a[i]));
    }
    
    cout<<min_d<<"\n";
    
    return 0;
}


Measured memory_bytes: 1792
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define F first
#define S second
#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()


void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

const int N = 2e5;


signed main() {
    accell();
    int n;
    cin >> n;
    vector<int>a(n);
    bool g = true;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a % 2 == 0) {
            if (a % 5 == 0 || a % 3 == 0) {
                g = true;
            } else {
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    return 0;
}


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





int main() {
  string S;
  cin>>S;
  int size=int(S.size());
  
  string answer="None";
  
  for (int i=0;i<26;i++){
    char check=(char)(int('a')+i);
    
    bool flag=false;
    for (int j=0;j<size;j++){
      if (S.at(j)==check){
        flag=true;
        break;
      }
    }
    if (flag==false){
      answer=check;
      break;
    }
  }
    
      
  cout<<answer<<endl;
  
}
  













Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, H, W);
  VEC(string, C, H);
  rep(i, 0, H) {
    print(C[i]);
    print(C[i]);
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int tate, yoko;
    char buf[16];

    fgets(buf, 16, stdin);
    sscanf(buf, "%d %d", &tate, &yoko);

    printf("%d %d\n", tate*yoko, tate*2 + yoko*2);

    return(0);
}

Measured memory_bytes: 604
#include<cmath>
#include<cstdio>
#define int long long
#define x1 xxx1
#define x2 xxx2
#define y1 xxx3
#define y2 xxx4
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
template<typename T>inline void rd(T&x){int fl=0,ch;while(ch=getchar(),ch<48||57<ch)fl^=!(ch^45);x=(ch&15);while(ch=getchar(),47<ch&&ch<58)x=x*10+(ch&15);if(fl)x=-x;}
template<typename T>inline void pt(T x){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);}
template<typename T>inline void pt(T x,int ch){pt(x),putchar(ch);}
template<typename T>inline T max(const T&x,const T&y){return x<y?y:x;}
template<typename T>inline T min(const T&x,const T&y){return x<y?x:y;}
const int N=200005;
int n,k,a[N],tim[N],nod[N],nxt[N],pos[N];
void out(int u){
	if(u>n)return;
	if(nxt[u]<=u)pt(a[u],' '),out(u+1);else out(nxt[u]+1);
}
signed main(){
	rd(n),rd(k);
	rep(i,1,n)rd(a[i]);
	for(int i=1;i<=n;++i){
		if(!pos[a[i]])pos[a[i]]=i;
	}
	for(int i=n;i>=1;--i){
		nxt[i]=pos[a[i]];
		pos[a[i]]=i;
	}
	nxt[n+1]=0;
	int u=1;
	nod[1]=u,tim[u]=1;
	if(k==1){out(1);return 0;}
	for(int i=2;i<=k;++i){
		u=nxt[u]+1;
		while(nxt[u]>u)u=nxt[u]+1;
		nod[i]=u;
		if(tim[u]){
			k=(k-1)%(i-tim[u])+tim[u];
			if(k)out(nod[k]);
			return 0;
		}
		tim[u]=i;
		if(i==k){
			out(u);
			return 0;
		}
	}
	return 0;
}
//6
//100
//1 3 2 2 3 2

Measured memory_bytes: 9088
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------


int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<int> b;

    if(n % 2 == 0){
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                b.push_back(a[i]);
            } else {
                b.insert(b.begin(), a[i]);
            }
        }
    } else {
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                b.insert(b.begin(), a[i]);
            } else {
                b.push_back(a[i]);
            }
        }
    }
    for(int i = 0; i < b.size(); i++){
        if(i != b.size() - 1){
            cout << b[i] << " ";
        } else {
            cout << b[i] << endl;
        }
    }

}

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

int main()
{
	int n;
	string s;
	cin>>n>>s;
	
	int cnt =0;
	for(int i=0;i<n-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
s = input()
t = input()

ans = 10000
for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if s[i+j:i+j+1] != t[j:j+1]:
            count += 1
    ans = min(ans,count)
print(ans)

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

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

	cout << fixed << setprecision(11) << (L / 3) * (L / 3) * (L / 3) << endl;

}

Measured memory_bytes: 256
//Compile: g++ -g -Wshadow -Wall main.cpp -o a.exe -Ofast -Wno-unused-result
//Build: g++ -g -Wshadow -Wall -o "%e" "%f" -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG
//Compile and run: g++ -g -Wshadow -Wall main.cpp -o a.exe -Ofast -Wno-unused-result && a.exe

#pragma GCC optimize("Ofast")

#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<long, long> pl;
typedef std::vector<int> vi;
typedef std::vector<ll> vl;
typedef std::vector<pii> vpii;
typedef std::vector<pl> vpl;
typedef std::vector<vi> vvi;
typedef std::vector<vl> vll;
typedef std::map<int, int> mii;
typedef std::priority_queue<int> pqd;
typedef std::priority_queue<int, vi, std::greater<int>> pqi;

#define gc getchar_unlocked
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264
#define MOD 1e9 + 7
#define INF INT64_MAX;

#define fo(i, n) for (ll i = 0; i < n; ++i)
#define Fo(i, k, n) for (ll i = k; k < n ? i < n : i > n; k < n ? ++i : --i)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define deb(x) cout << #x << "=" << x << endl
#define sortall(x) sort(x.begin(), x.end())
#define tr(it, a) for (auto it = a.begin(); it != a.end(); ++it)
#define ps(x, y) std::fixed << setprecision(y) << x
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mk(arr, n, type) type* arr = new type[n]

std::mt19937_64 rng(std::chrono::high_resolution_clock::now().time_since_epoch().count());

inline void setup() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

#ifdef LOCAL_PROJECT  //run with -DLOCAL_PROJECT drung compilation
    freopen("input.txt", "r", stdin);
#else
#ifndef ONLINE_JUDGE  //runs automatically for supported online judges
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
#endif
}

inline void solve();

int main() {
    setup();

    ll t = 1;

    // std::cin >> t;

    while (t--) {
        solve();
    }
    return 0;
}

using namespace std;

inline void solve() {
    ll n;
    cin >> n;
    if (!(n % 1000)) {
        cout << n % 1000;
    } else
        cout << abs(1000 - n % 1000);
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc045/tasks/arc061_a

"""
import sys
from sys import stdin
from itertools import combinations
input = stdin.readline


def prepare_eq(S, c):
    # c番目の数字の後に+を入れた数式を生成する (0起算)
    if len(c) == 0:
        return S

    eq = ''
    for i, s in enumerate(S):
        eq += s
        if i == c[0]:
            eq += '+'
            c = c[1:]
            if len(c) == 0:
                eq += S[i+1:]
                break
    return eq


def solve(S):
    total = 0
    for i in range(len(S)):
        for c in combinations(range(len(S)-1), i): # 0個〜文字列の長さ-1個までの+記号を追加して、数式を生成する
            eq = prepare_eq(S, c)
            total += eval(eq)   #  その数式の値を加算
    return total


def main(args):
    S = input().strip()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


void rm(vi&v, int x)
{
	auto it=find(v.begin(), v.end(), x);
	v.erase(it);
}


int con(vvi&v, vvi&c, int l, int a, int b)
{
	if(v[a][b]>0 || v[b][a]>0) return 0;

	v[a][b]=v[b][a]=l;
	rm(c[a], b);
	rm(c[b], a);
	return 2;
}


void min_u(int&m, int v)
{
	if(m>v) m=v;
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vvi v(n+1), c(n+1);
		vi ct(n+1);

		for(auto&mv:v) mv.resize(n+1, -1);
		for(int i=1;i<=n;i++) ct[i]=i;
		for(int i=1;i<=n;i++)
		{
			c[i]=ct;
			rm(c[i], i);
		}

		int rest=n*(n-1)/2;
		for(int l=1;rest;l++)
		{
			vi t(n+1, -1);

			for(int skip=1;skip<n;skip++)
			{
				for(int a=1;a+skip<=n;a++)
				{
					int b=a+skip;
					if(v[a][b]>0) continue;

					int f=0;
					if(t[a]<0) f|=1;
					if(t[b]<0) f|=2;
					if(f==0)
					{
						if(!((t[a]^t[b])&1)) continue;
					}
					switch(f)
					{
						case 3:
							t[a]=0;
							t[b]=1;
							break;
						case 2:
							t[b]=t[a]+1;
							break;
						case 1:
							t[a]=t[b]+1;
							break;
					}
					v[a][b]=v[b][a]=l;
					rest--;
				}
			}
		}

		for(int i=1;i+1<=n;i++)
		{
			for(int j=i+1;j+1<=n;j++)
			{
				printf("%d ", v[i][j]);
			}
			printf("%d\n", v[i][n]);
		}
	}
	return 0;
}


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

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    double ave = std::accumulate(a.begin(),a.end(),0.0) / (double)n;
    double min = 10000000;
    int itr;
    for(int i = n - 1; i >= 0; i--){
        if(std::abs(a[i] - ave) <= min){
            min = std::abs(a[i] - ave);
            itr = i;
        }
    }
    std::cout << itr << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << a* b << endl;
}


Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ
 
 
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  if (x >= 30){
    cout << "Yes\n";
  }else
  {
    cout << "No\n";
  }
  
  
  return 0;
}

Measured memory_bytes: 3648
import math

a,h,x=map(int,input().split())

hanbun=x>(a*a*h/2)

if(hanbun):
    takasa=(x/a/a)*2-h
    katamuki=(h-takasa)/a
    print(math.degrees(math.atan(katamuki)))
else:
    haba=2*x/a/h
    print(math.degrees(math.atan(h/haba)))

Measured memory_bytes: 3060
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        t: u32,
        a: [u32; n],
    }
    let mut ans = t;
    for i in 1..n {
        ans += std::cmp::min(a[i] - a[i - 1], t);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

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

using namespace std;

int main(){
	string s; cin>>s;
	int n=s.length();

	int cnt1=0,cnt2=0;
	rep(i,n){
		if(i%2==0){
			if(s[i]=='0') cnt1++; else cnt2++;
		}
		else{
			if(s[i]=='1') cnt1++; else cnt2++;
		}
	}
	cout<<min(cnt1,cnt2)<<endl;

	return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

class Prime {
public:
    Prime(ll n) {
        mPrimeTbl.clear();
        vector<bool> u(n, false);
        for (ll i = 2; i <= n; ++i) {
            if (u[i])
                continue;
            mPrimeTbl.push_back(i);
            for (ll p = i; p <= n; p += i)
                u[p] = true;
        }
    }

    ~Prime() {}

    ll num() {
        return static_cast<ll>(mPrimeTbl.size());
    }

    ll get(ll index) {
        return mPrimeTbl[index];
    }

private:
    vector<ll> mPrimeTbl;
};

int main() {
    ll X;
    cin >> X;

    Prime p(500000);
    REP(i, p.num()) {
        ll t = p.get(i);
        if (t >= X) {
            cout << t << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 896
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int A = sc.nextInt();
        System.out.println((int) Math.ceil(((float) H) / A));
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<b)
using namespace std;


int main(){
	string s;
	cin>>s;
	char now;
	bool flag=true;
	if(s.size()<=3){
		if(s!="mew") flag=false;
	}else{
		REP(i,1,(int)s.size()-1){
			if(now=='m'&&s[i]=='e'){
				now='e';
			}else if(now=='e'&&s[i]=='w'){
				s.erase(s.begin()+i);
				i--;
				s.erase(s.begin()+i);
				i--;
				s.erase(s.begin()+i);
				i=max(0,i-3);
				now=' ';
			}else if(s[i]=='m') now='m';
			else now=' ';
		}
		if(s!="mew") flag=false;
	}
	p(flag?"Cat":"Rabbit");
	return 0;
}

Measured memory_bytes: 3224
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long c = parseLong(sc.next());
		long k = parseLong(sc.next());
		long[] t = new long[n];
		for (i = 0; i < t.length; i++) {
			t[i] = parseLong(sc.next());
		}
		sc.close();
		Arrays.parallelSort(t);
		long bus=0;
		long person=0;
		long limit=t[0]+k;
		for (i = 0; i < t.length; i++) {
			person++;
			if(t[i]>limit || person>c) {
				bus++;
				person=1;
				limit=t[i]+k;
			}
		}
		if(person>0)bus++;
		out.println(bus);
	}
}


Measured memory_bytes: 46852
n, m = map(int, input().split())
W, V = [], []
for i in range(n):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
sumV = sum(V)
A = [1 << 30 for j in range(sumV+1)]
A[0] = 0
for i in range(n):
    B = []
    for j in range(V[i]):
        B.append(A[j])
    for j in range(V[i], sumV+1):
        B.append(min(A[j], A[j-V[i]]+W[i]))
    A = B
for j in range(sumV, 0, -1):
    if A[j] <= m:
        print(j)
        exit()


Measured memory_bytes: 111828
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n,c,k; cin>>n>>c>>k;
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin>>t[i];
  }ll ans=0;
  sort(t.begin(),t.end());
  int i=n-1;
  while(i>=0){
    int cnt=1,log=i-1;
    while(cnt!=c && log>=0){
      if(t[i]-k<=t[log]){
        cnt++; log--;
      }else{
        break;
      }
    }
    ans++;
    i=log;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 30
#define MAX_D 400

    /*
    いろいろ
    int x = rand()%100;
    double x = (double)rand()/RAND_MAX;
    mt19937 get_rand_mt;
    shuffle(vec.begin(), vec.end(), get_rand_mt);
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    char cc[4] = {'U','L','D','R'};
    */

int D;
int c[MAX_N];
int s[MAX_D][MAX_N];
int ma;
int ans[MAX_D];

int calc(){
    int las[26] = {};
    int res = 0;
    rep(i,D){
        res += s[i][ans[i]];
        las[ans[i]] = i+1;
        rep(j,26){
            res -= (i + 1 - las[j]) * c[j];
        }
    }
    return res;
}


int main() {
    srand((unsigned) time(NULL));
    clock_t start,end;
	start = clock();


    string fileNameIfs = "input.txt";
    const char* cstrIfs = fileNameIfs.c_str();
    ifstream ifs(cstrIfs);
    if(!ifs.is_open()){ // 標準入力する
        cin >> D;
        rep(i,26)cin >> c[i];
        rep(i,D)rep(j,26)cin >> s[i][j];
    }else{ // ファイル入力する
        ifs >> D;
        rep(i,26)ifs >> c[i];
        rep(i,D)rep(j,26)ifs >> s[i][j];
    }    
    
    int las[26] = {};
    rep(i,D){
        int max_s = -1;
        int arg = -1;
        rep(j,26){
            int tmp_score = s[i][j] + (i+1-las[j]) * c[j];
            if(tmp_score > max_s){
                max_s = tmp_score;
                arg = j;
            }
        }
        ans[i] = arg;
        las[arg] = i+1;
    }

    ma = calc();

    start = clock();
    int loop = 0;
    while(true){
        loop++;
        int x = rand()%D;
        int y = rand()%26;

        int keep = ans[x];
        ans[x] = y;

        int tmp = calc();

        if(tmp >= ma){
            if(tmp > ma){
                // cout << loop << ' ' << tmp << endl;
            }
            ma = tmp;
        }else{
            ans[x] = keep;
        }

        end = clock();
        if((double)(end-start)/CLOCKS_PER_SEC > 1.7)break;
    }


    rep(i,D){
        cout << ans[i] + 1 << endl;
    }

    string fileName = "out.txt";
    const char* cstr = fileName.c_str();
    ofstream ofs(cstr);
    rep(i,D){
        ofs << ans[i] + 1 << endl;
    }
    ofs.close();
    // cout << ma << endl;
    return 0;
}
 
 


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a = 100;
    intl cnt = 1;
    while(true){
        a *= 1.01;
        if(a >= n)break;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<stack>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

bool in[100010];

int main()
{
	int r,c,n;
	cin >> r >> c >> n;
	
	vector<pair<int,int> > v;
	
	REP(i,n)
	{
		int x[2],y[2];
		cin >> x[0] >> y[0] >> x[1] >> y[1];
		if((x[0] == 0 || x[0] == r || y[0] == 0 || y[0] == c)
		&&(x[1] == 0 || x[1] == r || y[1] == 0 || y[1] == c))
		{
			REP(j,2)
			{
				if(y[j] == 0)v.PB(MP(x[j],i));
				else if(x[j] == r)v.PB(MP(r+y[j],i));
				else if(y[j] == c)v.PB(MP(2*r+c-x[j],i));
				else v.PB(MP(2*(r+c)-y[j],i));
			}
		}
	}
	
	sort(ALL(v));
	
	/*
	REP(i,v.size())
	{
		cout << v[i].SE << ' ';
	}
	cout << endl;
	*/
	
	stack<int> s;
	
	REP(i,v.size())
	{
		if(!in[v[i].SE])
		{
			s.push(v[i].SE);
			in[v[i].SE] = true;
		}
		else
		{
			if(s.top() != v[i].SE)
			{
				cout << "NO" << endl;
				return 0;
			}
			else
			{
				s.pop();
			}
		}
	}
	
	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double s = x / a;
    double alpha;
    double PI = acos(-1);

    if(s >= a * b / 2){
        double h = 2 * (b - s / a);
        alpha = atan2(h, a);
    }
    else{
        double w = 2 * s / b;
        alpha = atan2(b, w);
    }
    alpha *= 180.0 / PI;
    printf("%.10f\n", alpha);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  string s ; cin >> s;
  char haiku[19];

  for(int i=0; i<19; i++){//sの要素s[i]は文字として扱う
    if(s[i] == ',')
      haiku[i] = ' ';
    else
      haiku[i] = s[i];
  }

  for(int i=0; i<19; i++){
    cout << haiku[i];
  }
    cout << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var XY = new List<Tuple<long, long>>();
            var isBall = new HashSet<Tuple<long, long>>();
            for(var i=0;i<N;++i)
            {
                var xy = Sarray();
                var x = xy[0];
                var y = xy[1];
                var tpl = Tuple.Create(x, y);
                XY.Add(tpl);
                isBall.Add(tpl);
            }
            var cost0 = 0L;
            var sortedXY = XY.OrderBy(xy => xy.Item1).ThenBy(xy => xy.Item2).ToArray();
            for (var fb = 0; fb < N; ++fb)//最初に拾うボール
            {
                //p,qを決める
                for (var dc = fb + 1; dc < N; ++dc)
                {
                    var kBall = sortedXY[fb];
                    var nBall = sortedXY[dc];
                    var p = nBall.Item1 - kBall.Item1;
                    var q = nBall.Item2 - kBall.Item2;
                    //いい感じになるか確認
                    var good = 0L;
                    for (var gd = 0; gd < N; ++gd)
                    {
                        var sx = sortedXY[gd].Item1 + p;
                        var sy = sortedXY[gd].Item2 + q;
                        var tpl = Tuple.Create(sx, sy);
                        if (isBall.Contains(tpl)) ++good;
                    }
                    cost0 = Max(cost0, good);
                }
            }
            WriteLine(N - cost0);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 17872
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    cout << max({a,b,c})-min({a,b,c});
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
 
int main() {
  string S;
  int N, cnt, c1, c0;
  cnt = c1 = c0 = 0; 
  cin >> S;
  N = S.size();
  for(int i = 0;i < N; ++i){
    if(S[i] == '1')
      c1++;
    else
      c0++;
  }
      
  if(c1 >= c0)
    cnt = 2 * c0;
  else
    cnt = 2 * c1;
      
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;

ll sum(ll x){return x*(x+1)/2;}

int main() {
    ll x;cin >> x;
    ll left=0,right=x;
    ll mid;
    while(left<right){
        mid = (left+right)/2;
        if(sum(mid)<x) left = mid+1;
        else right = mid;
    }
    cout << left << endl;
    return 0;
}


Measured memory_bytes: 256
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

N = int(input())
L = list(map(int, input().split()))
# L.sort()
# print(L)

cnt = 0
a = 0
c = combinations(range(N), 3)
for ci in c:
    i, j, k = ci
    if (
        L[i] + L[j] > L[k]
        and L[j] + L[k] > L[i]
        and L[k] + L[i] > L[j]
        and L[i] != L[j]
        and L[j] != L[k]
        and L[k] != L[i]
    ):
        flg = True
    else:
        flg = False
    if flg:
        cnt += 1
print(cnt)
# for i, li in enu(L):
#     for j, lj in enu(L[i + 1 :]):
#         for k, lk in enu(L[i + 1 + j + 1 :]):
#             a += 1
#             if li + lj > lk:
#                 cnt += 1
# print(a, cnt)


Measured memory_bytes: 74324