akhauriyash/Code-Regression huggingface dataset:
s = input()
a = []
t = ""
for i in range(len(s)):
    if i == 0:
        a.append(s[i])
    else:
        t += s[i]
        if t != a[-1]:
            a.append(t)
            t = ""
        else:
            if i == len(s) - 1:
                a[-1] += t
print(len(a))


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

using namespace std;

 int main()
 {
   long int n,i,sum=0;
   cin>>n;
   i=n;

   while(i){
        sum+=(i%10);
        i/=10;

   }
   if(n%sum==0){cout<<"Yes"<<endl;}
   else {cout<<"No"<<endl;}

 }


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main() {
int n;
  int a;
  int b;
  int c;
  
  
  cin >> n;
  a = n/100;
  b = (n-100*a)/10;
  c = n-100*a-10*b;
  
  if (a==1) a=9;
  else if (a==9) a=1;
  
  if (b==1) b=9;
  else if (b==9) b=1;
  
  if (c==1) c=9;
  else if (c==9) c=1;
  
  
  
  cout << 100*a+10*b+c;
  cout << endl;
  
  
}


Measured memory_bytes: 256
require 'prime'
loop {
    n, m = gets.split
    n = n.to_i
    break if n == 0
    m = m.to_i(n)  
    a = []
    Prime.prime_division(n).each{|q, k|
        l = 0
        f = q
        while f <= m
            l += m / f
            f *= q 
        end
        a << l / k
    }
    p a.min
} 

Measured memory_bytes: 6252
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n, q;
	string s;
	int l, r;
	cin >> n >> q;
	cin >> s;
	int dp[100002];
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == 'A'&&s[i] == 'C') { dp[i] = dp[i - 1] + 1; }
		else dp[i] = dp[i - 1];
	}
	for (int i = 0; i < q; i++) {
		cin >> l >> r;
		int ans = 0;
		ans = dp[r-1] - dp[l-1];
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 1408
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String a = sc.nextLine();
    if(a.charAt(0)=='7'||a.charAt(1)=='7'||a.charAt(2)=='7'){
    	pl("Yes");
    }else{
    	pl("No");
    }
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 35760
'''tanon
たとえばRRRRRLLLLLという文字列があるとき、操作回数が十分大きければ、
子供たちは右端のRのマス、もしくは左端のLのマスにしか存在しないことが
分かります。
また右端のRのマスにいる子供は、2回後の操作でまた同じマスに戻ってきます。
以上のことと、操作回数は10^100より偶数であることから、
はじめに右端のRのマスから偶数マス離れたマスにいる子供は
右端のRのマスに移動し、
右端のRのマスから奇数マス離れたマスにいる子供は
左端のLのマスに移動することが分かります。
右端のRのマス、左端のLのマスに存在する人数は、
はじめにRのマスにいる子供について、
Rの個数rcが偶数であれば右端のRのマスにも左端のLのマスにもrc/2人、
奇数であれば右端のRのマスにrc/2+1人、左端のLのマスにrc/2人います。
また、はじめにLのマスにいる子供について、
Lの個数lcが偶数であれば右端のRのマスにも左端のLのマスにもrc/2人、
奇数であれば右端のRのマスにrc/2人、左端のLのマスにrc/2+1人います。
元の文字列を各部分がRR...RLL...Lとなるように区切って考えることにすると、
各部分について、上記の方法でそれぞれのマスにいる子供の数を求める
ことができます。
'''
s=input()+'R' 
#以下ではRが出てきたときに値を更新しているので最後にRを付け加える
l=len(s)
ans=[0]*(l-1) #すべてのマスの答えを0で初期化
rcnt=0
lcnt=0
rpos=0
lpos=0
flag=0
for i in range(l):
 if s[i]=='R':
   if flag==1: #文字列がLRとなっているとき、直前のRLについて答えを求める
     if rcnt%2==0: #Rの個数が偶数のとき
       ans[rpos]+=rcnt//2
       ans[lpos]+=rcnt//2
     else: #Rの個数が奇数のとき
       ans[rpos]+=rcnt//2+1
       ans[lpos]+=rcnt//2
     if lcnt%2==0: #Lの個数が偶数のとき
       ans[rpos]+=lcnt//2
       ans[lpos]+=lcnt//2
     else: #Lの個数が奇数のとき
       ans[rpos]+=lcnt//2
       ans[lpos]+=lcnt//2+1
     rcnt=0
     lcnt=0
   flag=0
   rcnt+=1 #Rの個数を求める
   rpos=i #右端のRの位置を求める
 elif s[i]=='L':
   if flag==0:
     lpos=i #左端のLの位置を求める
   lcnt+=1 #Lの個数を求める
   flag=1
print(*ans)

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <string>
#include <queue>

int N, M;
// std::vector<int> A, B;
int A, B;
std::vector<std::vector<int>> adj_list;
std::vector<int> sign;
std::queue<int> que;

int main() {
  std::cin >> N >> M;
  // A.assign(M, 0);
  // B.assign(M, 0);
  adj_list.assign(N, std::vector<int>());
  sign.assign(N, -1);
  // for (int j = 0; j < N; j++) {
  //   adj_list.at(j).reserve(N);
  // }

  for (int i = 0; i < M; i++) {
    std::cin >> A >> B;
    --A;
    --B;
    adj_list.at(A).push_back(B);
    adj_list.at(B).push_back(A);
  }
  que.push(0);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int nv : adj_list.at(v)) {
          if (sign.at(nv) == -1) {
            sign.at(nv) = v;
            que.push(nv);
          }
      }
  }

  std::cout << "Yes" << std::endl;
  for(int j = 1; j < N; j++) {
    std::cout << sign.at(j)+1 << std::endl;
  }
}


Measured memory_bytes: 10148
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using real = double;
real EPS = 1e-10;
struct Point {
    real x, y;
    Point& operator+=(const Point a) { x += a.x; y += a.y;  return *this; }
    Point& operator-=(const Point a) { x -= a.x; y -= a.y;  return *this; }
    Point& operator*=(const real k) { x *= k; y *= k;  return *this; }
    Point& operator/=(const real k) { x /= k; y /= k;  return *this; }
    Point operator+(const Point a) const {return Point(*this) += a; }
    Point operator-(const Point a) const {return Point(*this) -= a; }
    Point operator*(const real k) const {return Point(*this) *= k; }
    Point operator/(const real k) const {return Point(*this) /= k; }
    bool operator<(const Point &a) const { return (x != a.x ? x < a.x : y < a.y); }
    explicit Point(real a = 0, real b = 0) : x(a), y(b) {};
};

istream& operator>> (istream& s, Point& P){
    s >> P.x >> P.y;
    return s;
}

inline real dot(Point a, Point b){ return a.x*b.x + a.y*b.y; }
inline real cross(Point a, Point b){ return a.x*b.y - a.y*b.x; }
inline real abs(Point a){ return sqrt(dot(a, a)); }

static constexpr int COUNTER_CLOCKWISE = 1;
static constexpr int CLOCKWISE = -1;
static constexpr int ONLINE_BACK = 2;
static constexpr int ONLINE_FRONT = -2;
static constexpr int ON_SEGMENT = 0;

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if(cross(b, c) > EPS) return COUNTER_CLOCKWISE;
    if(cross(b, c) < -EPS) return CLOCKWISE;
    if(dot(b, c) < 0) return ONLINE_BACK;
    if(abs(b) < abs(c)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
struct Segment {
    Point a, b;
    Segment(Point x, Point y) : a(x), b(y) {};
};

double distance(Segment l, Point c){
    if(dot(l.b-l.a, c-l.a) < EPS) return abs(c-l.a);
    if(dot(l.a-l.b, c-l.b) < EPS) return abs(c-l.b);
    return abs(cross(l.b-l.a, c-l.a)) / abs(l.a-l.b);
}

bool intersect(Segment l1, Segment l2){
    return (ccw(l1.a, l1.b, l2.a)*ccw(l1.a, l1.b, l2.b) <= 0 &&
            ccw(l2.a, l2.b, l1.a)*ccw(l2.a, l2.b, l1.b) <= 0);
}

Point crossPoint(Segment l1, Segment l2){
    real d1 = abs(cross(l1.b-l1.a, l2.b-l2.a));
    real d2 = abs(cross(l1.b-l1.a, l1.b-l2.a));
    if(d1 < EPS && d2 < EPS) return l2.a;
    return l2.a+(l2.b-l2.a)*d2/d1;
}

Point project(Segment s, Point p){
    Point Q = s.b-s.a;
    return s.a + Q*(dot(p-s.a, Q) / dot(Q, Q));
}

Point refrect(Segment s, Point p){
    Point Q = project(s, p);
    return Q*2-p;
}


int main(){
    double x1, y1, x2, y2, xq, yq;
    while(scanf("%lg,%lg,%lg,%lg,%lg,%lg", &x1, &y1, &x2, &y2, &xq, &yq) != EOF){
        Point a(x1, y1), b(x2, y2), P(xq, yq);
        Segment s(a, b);
        Point ans = refrect(s, P);
        printf("%.10lf %.10lf\n", ans.x, ans.y);
    }
    return 0;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
 int main()
{
    double x,y,a,b,w,h,l,m,p=0;
    int r=0;
     cin>>w>>h>>a>>b;
    l=(w*h)/2.0;
    if(w/2==a&&h/2==b){
        r=1;
    }
    printf("%.6lf %d\n",l,r);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
inline int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int gcd(int a , int b){
  if (b == 0) 
        return a; 
    return gcd(b, a % b);
}

int32_t main() 
{ 
  fast;
  string s;
  cin >> s;
  string ans ="";
  for(int i = 0 ; i < 3 ; i++) ans = ans + s[i];
    cout << ans << "\n";
  return 0;
} 
/*
  x dia y shovels
  2*y + y = y emarald
  x + 2*x = x emarld
  2*y + x <=a 
  y+2*x <=b 
  500 + 250 
  2*a + b ~ x
  a + 2*b ~ y
  max(a+b)
  2*x+y
  x+2*y
  1-2-3
  [ 1-2 2-3 ]

   
   
  1-2-3-4

*/
 

Measured memory_bytes: 3660
//
//  main.cpp
//  Atcoder176
//
//  Created by Keita on 2020/08/22.
//  Copyright © 2020 Keita. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;

void doProblemA(){
    int D, T, S;
    cin >> D >> T >> S;
    if(T * S < D){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}



int main(int argc, const char * argv[]){
    // insert code here...
    doProblemA();
    return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pii, int>
#define pb push_back
#define fs first
#define sc second
#define ppb pop_back
//#define LOCAL
//#define endl "\n"
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
#define fifo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9+7;



int n;int a[200001],b[200001];

void printyes()
{
	cout<<"Yes"<<endl;
	for(int i=0;i<n;i++)d0(b[i]);
		cout<<endl;
}
void solve()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];

	reverse(b,b+n);

	int l=n;int r=-1;int c;
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[i])
		{
			l=min(l,i);
			r=max(r,i);
		}
	}
	if(l>r)
	{
		printyes();return;
	}
	c=a[l];
	int i=0;int j=l;
	while(i<n && j<=r)
	{
		if(a[i]==c){i++;continue;}
		if(b[i]==c){i++;continue;}
		swap(b[i],b[j]);
		i++;j++;
	}
	if(j<=r)
	{
		cout<<"No"<<endl;return;
	}
	printyes();
}


int main()
{
	fifo
	ll t=1;
	//cin>>t;
	//cout<<t<<endl;
	for(ll test_case=1;test_case<=t;++test_case)
	{
		//cout<<"#"<<test_case<<endl;
		solve();
	}
}


Measured memory_bytes: 5224
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int h,w;
int m[2000][2000];
int t[2000][2000];
int yo[2000][2000];

int solve(int x, int y){
    if(m[x][y]==0)return 0;
    int tate = 1;
    int yoko = 1;

    //Up
    if(t[x][y]){
        tate = t[x][y];
    }else{
        for (int i = x-1; i >= 0; i--)
        {
            if(m[i][y])tate++;
            else break;
        }
        //Down
        for (int i = x+1; i < h; i++)
        {
            if(m[i][y])tate++;
            else break;
        }

        t[x][y] = tate;
        for (int i = x-1; i >= 0; i--)
        {
            if(m[i][y])t[i][y] = tate;
            else break;
        }
        //Down
        for (int i = x+1; i < h; i++)
        {
            if(m[i][y])t[i][y] = tate;
            else break;
        }
    }

    if(yo[x][y]){
        yoko = yo[x][y];
    }else{
        //Left
        for (int i = y-1; i >= 0; i--)
        {
            if(m[x][i])yoko++;
            else break;
        }
        //Right
        for (int i = y+1; i < w; i++)
        {
            if(m[x][i])yoko++;
            else break;
        }

        //Left
        yo[x][y] = yoko;
        for (int i = y-1; i >= 0; i--)
        {
            if(m[x][i])yo[x][i] = yoko;
            else break;
        }
        //Right
        for (int i = y+1; i < w; i++)
        {
            if(m[x][i])yo[x][i] = yoko;
            else break;
        }
    }
    return tate + yoko -1;
}

int main(void)
{
    cin >> h >> w;
    REP(i, h){
        REP(j, w){
            char a;
            cin >> a;
            if(a == '.')m[i][j] = 1;
        }
    }

    int ans = 0;
    REP(i, h){
        REP(j, w){
            ans = max(ans, solve(i,j));
        }
    }
    pr(ans);
}

Measured memory_bytes: 47104
'''
参考:1
https://tanuhack.com/num2alpha-alpha2num/
数値からアルファベットの変換…10進数→26進数
-----
例えば、『1000』という数値をアルファベットに変換させる場合、
1. 26のn乗で1000以下の最大のnを求める→『n+1』がアルファベットの桁数、n=2
2. (26^2)*xで1000以下の最大のxを求める→x=1、つまり3桁目のアルファベットはA
3. (26^1)*yで1000-(26^2)*1=324以下の最大のyを求める→y=12、つまり2桁目のアルファベットはL
4. (26^0)*z=12→つまり3桁目のアルファベットはL、ゆえに1000はALL
と、再帰を使って算出
-----

参考:2
https://note.nkmk.me/python-chr-ord-unicode-code-point/
整数（Unicodeコードポイント）→文字
'''
def num2alpha(num):
    if num <= 26:                                   # num == 1, num == 2, ...etc
        return chr(96+num)                          # chr(97) == 'a'
    elif num % 26 == 0:                             # num == 26, num == 52, ...etc
        return num2alpha(num//26-1)+chr(122)        # chr(122) == 'z', ∴num == 52 ⇒ 'az'
    else:                                           # num == 27, num == 53, ...etc
        return num2alpha(num//26)+chr(96+num%26)    # ∴num == 53 ⇒ 'ba'


N = int(input())
ans = num2alpha(N)

print(ans)


Measured memory_bytes: 9164
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W, K = MAP()

for x in range(H+1):
	y = (K-x*W)/(H-2*x) if H !=2*x else (H*W-K)/H
	if y.is_integer() and 0 <= y <= W:
		print("Yes")
		break
else:
	print("No")


Measured memory_bytes: 5148
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<int> l(2 * N);
    for (auto &&i : l) {
        cin >> i;
    }

    SORT(l);
    ll ans = 0;
    REP(i, l.size()) {
        if (i % 2 == 0)
            ans += l[i];
    }
    print(ans);

    return 0;
}

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

#define int long long 

using namespace std;

int a[400001];	

 main () {	
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1;i <= n;i ++) cin >> a[i];
	for (int i = 1;i <= n;i ++) {
		if (a[i] + 1 == a[i + 1]) continue;
		int st = i - a[i];
		if (st < 1 || a[i + 1] - a[i] > 1) {
			cout << -1;
			return 0;
		}
		ans += a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
#ifdef LOCAL
template <class T, class S>
ostream &operator<<(ostream &str, const pair<T, S> &p) {
  return (str << "{" << p.fi << ", " << p.se << "}");
}
template <template <class...> class Container, class... T>
ostream &operator<<(ostream &str, const Container<T...> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
struct dbg {
  dbg() { cout << "  "; }
  ~dbg() { cout << endl; }
  template <class T> dbg &operator<<(T oth) {
    cout << oth;
    return *this;
  }
};
#else
#define var(x) 0
struct dbg {
  template <class T> dbg &operator<<(T oth) { return *this; }
};
#endif
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    ll n;
    cin >> n;
    ll ans = n % 1000;
    if (ans != 0)
      ans = 1000 - ans;
    cout << ans << '\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int k;
   cin>>k;
   cout<<a[k-1];




}
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, m, k;
    std::cin >> n >> m >> k;
    if (n < m)
        std::swap(n, m);
    std::cout << (k + n - 1) / n << "\n";
    return 0;
}

Measured memory_bytes: 256
H, W = list(map(int, input().split()))

HW = []
for h in range(H):
    w = list(input())
    HW.append(w)

flg = True


def check(h, w):
    if h == 0:
        if w == 0:
            if HW[h + 1][w] == "#" or HW[h][w + 1] == "#":
                return True
        elif w == W - 1:
            if HW[h + 1][w] == "#" or HW[h][w - 1] == "#":
                return True
        else:
            if HW[h + 1][w] == "#" or HW[h][w + 1] == "#" or HW[h][w-1] == "#":
                return True
    elif h == H - 1:
        if w == 0:
            if HW[h - 1][w] == "#" or HW[h][w + 1] == "#":
                return True
        elif w == W - 1:
            if HW[h - 1][w] == "#" or HW[h][w - 1] == "#":
                return True
        else:
            if HW[h - 1][w] == "#" or HW[h][w + 1] == "#" or HW[h][w-1] == "#":
                return True
    else:
        if w == 0:
            if HW[h - 1][w] == "#" or HW[h + 1][w] == "#" or HW[h][w+1] == "#":
                return True
        elif w == W-1:
            if HW[h - 1][w] == "#" or HW[h + 1][w] == "#" or HW[h][w-1] == "#":
                return True
        else:
            if HW[h - 1][w] == "#" or HW[h + 1][w] == "#" or \
                    HW[h][w-1] == "#" or HW[h][w+1] == "#":
                return True
    return False


for i in range(0, H):

    if flg is False:
        break
    for j in range(0, W):
        if HW[i][j] == "#":
            flg = check(i, j)
            # print(i, j, check(i, j))
        if flg is False:
            break

if flg is True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3188
class Node:
    def __init__(self):
        self.is_parent = True
        self.parent = None

def root(node):
    depth = 0
    while node.parent != None:
        node = node.parent
        depth += 1
    return node, depth

N, M = map(int, input().split())

roots = [Node() for i in range(N)]
count = N

for i in range(M):
    x, y, z = map(int, input().split())
    x = roots[x-1]
    y = roots[y-1]
    if x.is_parent and y.is_parent:
            y.is_parent = False
            y.parent = x
            count -= 1
    else:
        root_x, depth_x = root(x)
        root_y, depth_y = root(y)
        if root_x != root_y:
            if depth_x >= depth_y:
                root_y.is_parent = False
                root_y.parent = root_x
                count -= 1
            else:
                root_x.is_parent = False
                root_x.parent = root_y
                count -= 1

print(count)


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

int w, h, x, y;

int main(){
  cin >> w >> h >> x >> y;
  cout << setprecision(10) <<  (double)h * (double)w / 2 << " ";
  if(x * 2 == w && y * 2 == h){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,bmi,bmi2,lzcnt")
#endif
#include <x86intrin.h>
#include <bits/extc++.h>
using namespace std;

template <class T> struct wavelet_matrix {
  using size_type = uint32_t;
  struct bit_vector {
    static constexpr size_type wsize = 64;
    static size_type rank64(uint64_t x, size_type i) {
      return _popcnt64(_bzhi_u64(x, i));
    }
#pragma pack(4)
    struct block_t {
      uint64_t bit;
      size_type sum;
    };
#pragma pack()
    size_type n, zeros;
    vector<block_t> block;
    bit_vector(size_type _n = 0) : n(_n), block(n / wsize + 1) {}
    int operator[](size_type i) const {
      return block[i / wsize].bit >> i % wsize & 1;
    }
    void set(size_type i) { block[i / wsize].bit |= (uint64_t)1 << i % wsize; }
    void build() {
      for (size_type j = 0; j < n / wsize; ++j)
        block[j + 1].sum = block[j].sum + _popcnt64(block[j].bit);
      zeros = rank0(n);
    }
    size_type rank0(size_type i) const { return i - rank1(i); }
    size_type rank1(size_type i) const {
      auto&& e = block[i / wsize];
      return e.sum + rank64(e.bit, i % wsize);
    }
  };
  size_type n, lg;
  vector<T> a;
  vector<bit_vector> bv;
  wavelet_matrix(size_type _n = 0) : n(_n), a(n) {}
  T& operator[](size_type i) { return a[i]; }
  void build() {
    lg = __lg(max<T>(*max_element(begin(a), end(a)), 1)) + 1;
    bv.assign(lg, n);
    vector<T> cur = a, nxt(n);
    for (auto h = lg; h--; ) {
      for (size_type i = 0; i < n; ++i) if (cur[i] >> h & 1) bv[h].set(i);
      bv[h].build();
      array it{begin(nxt), begin(nxt) + bv[h].zeros};
      for (size_type i = 0; i < n; ++i) *it[bv[h][i]]++ = cur[i];
      swap(cur, nxt);
    }
  }
  T kth(size_type l, size_type r, size_type k) const {
    T res = 0;
    for (auto h = lg; h--; ) {
      auto l0 = bv[h].rank0(l), r0 = bv[h].rank0(r);
      if (k < r0 - l0) l = l0, r = r0;
      else {
        k -= r0 - l0;
        res |= (T)1 << h;
        l += bv[h].zeros - l0;
        r += bv[h].zeros - r0;
      }
    }
    return res;
  }
  size_type count(size_type l, size_type r, T ub) const {
    if (ub >= (T)1 << lg) return r - l;
    size_type res = 0;
    for (auto h = lg; h--; ) {
      auto l0 = bv[h].rank0(l), r0 = bv[h].rank0(r);
      if (~ub >> h & 1) l = l0, r = r0;
      else {
        res += r0 - l0;
        l += bv[h].zeros - l0;
        r += bv[h].zeros - r0;
      }
    }
    return res;
  }
  size_type count(size_type l, size_type r, T lb, T ub) const {
    return count(l, r, ub) - count(l, r, lb);
  }
};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (auto&& e : a) cin >> e, --e;
  vector<int> last(n, n);
  wavelet_matrix<int> wm(n);
  for (int i = n; i--; ) {
    wm[i] = exchange(last[a[i]], i);
  }
  wm.build();
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    cout << r - l - wm.count(l, r, r) << '\n';
  }
}


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

int N, A, B, C;
int v = 100000;
int l[8];

void dfs(int cost, int n, int a, int b, int c) {
  if (n == N) {
    if (a == 0 || b == 0 || c == 0) return;
    cost += abs(A - a) + abs(B - b) + abs(C - c) - 30;
    v = min(v, cost);
    return;
  }
  dfs(cost + 10, n + 1, a + l[n], b, c);
  dfs(cost + 10, n + 1, a , b + l[n], c);
  dfs(cost + 10, n + 1, a, b, c + l[n]);
  dfs(cost + 0, n + 1, a, b, c);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) {
    int t;
    cin >> t;
    l[i] = t;
  }
  
  dfs(0, 0, 0, 0, 0);
  cout << v << "\n";
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define Pi pair<int,int>
#define IINF 1e9
#define LINF 1e18
#define vi vector<int>
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 0, 1,0,-1};
int dy[] = { 1, 0,-1,0};
int dx8[] = { -1,-1,-1,0,0,1,1,1};
int dy8[] = { -1,0,1,-1,1,-1,0,1};

unsigned long long sttoi(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ull gcd(ull a, ull b) {
	if (b > a)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

int comb(int n, int k) {
	int ans = 1;
	for (int i = 0; i < min(k, n - k); i++) {
		ans *= n - i;
		ans /= i + 1;
	}
	return ans;
}

ll mod_pow(ll n,ll p,ll mod){	
	if (p == 0) return 1 % mod;
	if (p < 2) {
		return n % mod;
	}else {
		ll d = 2, value = (n%mod)*(n%mod)%mod;
		while (d*2 < p) { d *= 2;	value *= value;	value %= mod;}
		value %= mod;
		return ((value%mod) * (mod_pow(n, p - d, mod)%mod)) % mod;
	}
}

bool isPrime(int n) {
	if (n <= 1)return false;
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i*i <= n; i += 2) {
		if (n%i == 0)return false;
	}
	return true;
}

void solve() {
	int n;
	vi l;
	cin >> n;
	rep(i, n*2) {
		int a;
		cin >> a;
		l.push_back(a);
	}
	int ans = 0;
	sort(l.begin(), l.end());
	for (int i = 0; i < n*2; i += 2) {
		ans += min(l[i], l[i + 1]);
	}
	P(ans);
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<pair<int,int> >adj[MAX];
int arr[MAX],dist[MAX];
void dfs(int src,int last,int d)
{
    dist[src]=d;
    for(int i=0; i<adj[src].size(); i++)
    {
        int child=adj[src][i].first;
        int cost=adj[src][i].second;
        if(child==last)
            continue;
        if(dist[child]==MAX)
            dfs(child,src,d+cost);
        else  if(dist[child]!= dist[src]+cost)
        {
            cout<<"No"<<endl;
            exit(0);
        }
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m;
    cin>>n>>m;
    for(int i=0; i<=n; i++)
        dist[i]=MAX;
    while(m--)
    {
        int u,v,x;
        cin>>u>>v>>x;
        adj[u].push_back({v,x});
        adj[v].push_back({u,-x});
    }
    int mx=INT_MAX,s;
    for(int i=1; i<=n; i++)
    {
        if(adj[i].size())
        {
            if(adj[i].size()<mx)
                mx=adj[i].size(),s=i;
        }
    }
    for(int i=1; i<=n; i++)
        if(dist[i]==MAX)
            dfs(i,0,0);

    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 38232
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
         ios::sync_with_stdio(false);    
        cin.tie(0);
        int n, m;
        
        cin>>n>>m;
        cout<<n*(n-1)/2+m*(m-1)/2;
        
        



       
                                
        


        return 0;

}

Measured memory_bytes: 256
class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.rank = [0]*n
  def find(self, x):
    if self.par[x]==x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  def unit(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x==y:
      return
    elif self.rank[x]<self.rank[y]:
      self.par[x] = y
      return
    elif self.rank[y]<self.rank[x]:
      self.par[y] = x
    else:
      self.par[y] = x
      self.rank[x] += 1
      
  def same(self, x, y):
    return self.find(x)==self.find(y)
  

N, M, *L = map(int, open(0).read().split())
p = L[:N]
ls = L[N:]
u = UnionFind(N+1)
for x,y in zip(*[iter(ls)]*2):
  u.unit(x,y)
inf = [0]*(N+1)
for i in range(N):
  inf[p[i]] = i
ans = sum(1 if u.same(i,inf[i]+1) else 0 for i in range(1,N+1))
print(ans)

Measured memory_bytes: 35324
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), 
        b = sc.nextInt(), 
        c = sc.nextInt(), 
        k = sc.nextInt();
        sc.close();

        for (;k > 0; k--) {
            if (a >= b) {
                b *= 2;
            } else if (b >= c) {
                c *= 2;
            } else {
                break;
            }
        }

        if (b > a && c > b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

using namespace std;

#define endl "\n"


int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == b && a != c && b != c)|| (b == c && a != b && a != c) || (a == c && b != c && b!= a))
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    string a;
    cin>>k;
    a=to_string(k);
    //cout<<a<<endl;
    reverse(a.begin(),a.end());
    if(a[0]=='2'||a[0]=='4'||a[0]=='5'||a[0]=='7'||a[0]=='9')
    {
        cout<<"hon"<<endl;
    }
   else if(a[0]=='0'||a[0]=='1'||a[0]=='6'||a[0]=='8')
        cout<<"pon"<<endl;
    else if(a[0]=='3')
        cout<<"bon"<<endl;
}


Measured memory_bytes: 3668
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff = -1
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff =  abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	if (s.size() > 9){
		cout << "NO" << endl;
		return 0;
	}
	for(int bit = 0; bit < (1 << s.size() + 1); bit++) {
		string t = "";
		for(int i= 0; i <= s.size(); i++) {
			if((bit >> i) & 1){
				t += 'A';
			}
			if(i < s.size()){
				t += s[i];
			}
		}	
		if (t == "AKIHABARA"){
			cout << "YES" << endl;
			return 0;
		}														
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8

n = int(input())

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

count = 0

flag = True
while(1):
    for i in range(n):
        if l[i]%2==0:
            l[i] /= 2
        else:
            flag = False
            break
    if flag==False:
        print(count)
        break
    count += 1

Measured memory_bytes: 3060
#!/usr/bin/env python3
import math
import numpy as np
 
n = int(input())
ans = np.inf
for i in range(1, int(math.sqrt(n))+1):
    if n%i==0:
        q = n/i 
        tmp = i+q 
        if tmp <= ans:
            ans = tmp 
print(int(ans-2))


Measured memory_bytes: 12496
#include<iostream>
#define lli long long int
using namespace std;

// Problem https://atcoder.jp/contests/abc048/tasks/abc048_b

lli devfunc(lli N,lli X){
    lli result;
    result = 0;
    if(N !=-1){
        result = N / X + 1;
    }
    return result;
}

lli solver(lli A,lli B,lli DEVNO){
    lli result;
    result = 0;
    result = devfunc(B,DEVNO)-devfunc(A-1,DEVNO);
    return result;
}

int main(void){
    lli answer;
    answer=0;
    lli a,b,x;
    cin >> a >> b >> x;
    answer = solver(a,b,x);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
def expected_value(x):
    x = int(x)
    return (x + 1) / 2


def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(expected_value, input().split(' ')))
    cumulative_list = [0]
    for p in p_list:
        cumulative_list.append(cumulative_list[-1] + p)
    max_len = 0
    for i in range(0, N - K + 1):
        if max_len < cumulative_list[i + K] - cumulative_list[i]: max_len = cumulative_list[i + K] - cumulative_list[i]
    print(max_len)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23588
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let _N: usize = read();
    let S: String = read();
    let whiteCount = S.chars().filter(|&c| c == '.').count();
    let (ans, _blackCount, _whiteCount) = S.chars().fold(
        (std::usize::MAX, 0, whiteCount),
        |(ans, leftBlackCount, rightWhiteCount), c| {
            let (leftBlackCount, rightWhiteCount) = if c == '.' {
                (leftBlackCount, rightWhiteCount - 1)
            } else {
                (leftBlackCount, rightWhiteCount)
            };
            let (leftBlackCount, rightWhiteCount) = if c == '#' {
                (leftBlackCount + 1, rightWhiteCount)
            } else {
                (leftBlackCount, rightWhiteCount)
            };
            let ans = std::cmp::min(ans, leftBlackCount + rightWhiteCount);
            (ans, leftBlackCount, rightWhiteCount)
        },
    );
    // 先頭の判定をしていないのでここでする
    let ans = std::cmp::min(ans, whiteCount);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
string s,t;
cin>>s>>t;
int a,b;
cin>>a>>b;
string u;
cin>>u;
if(s==u){
    cout<<a-1<<" "<<b<<endl;
    return 0;
}
else{
    cout<<a<<" "<<b-1<<endl;
    return 0;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int panjang,occ[30]={},total=0;
LL ans=1;
string input;
int ubah(char a){
	return a-'a';
}
void update(int a){
	occ[a]++;
	total++;
}
void update(char a){
	return update(ubah(a));
}
int main()
{
	cin>>input;
	panjang=input.length();
	for(int i=0;i<panjang;i++)
	{
		update(input[i]);
		ans+=total-occ[ubah(input[i])];
	}
	cout<<ans<<endl;
}

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

int main(){
  int N, K;
  long ans;
  
  cin >> N >> K;
  ans = pow(int(N / K), 3);
  if(K % 2 == 0){
    ans += pow(int((N + K / 2) / K), 3);
  }
  cout << ans;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        string S;
        cin >> S;

        if (S[0] == S[1] || S[1] == S[2] || S[2] == S[0])
        {
                cout << "No" << endl;
        }
        else
        {
                cout << "Yes" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

template<int row,int col>
struct BinaryMatrix{
    bitset<col> dat[row];
    int r,c;
    BinaryMatrix(size_t r,size_t c):r(r),c(c){}
    bitset<col> &operator[](int i){return dat[i];}
    const bitset<col> &operator[](int i) const{return dat[i];}
    void Gauss_Jordan(int extended=0){
        vector<int> used(r,0);
        for (int j=0;j<c;++j){
            if (extended&&j==c-1) break;
            int p=-1;
            for (int i=0;i<r;++i){
                if (!used[i]&&dat[i][j]){p=i; break;}
            }
            if (p==-1) continue;
            for (int i=0;i<r;++i){
                if (i!=p&&dat[i][j]) dat[i]^=dat[p];
            }
            used[p]=1;
        }
    }
};

const int MAX_N=1e5+10,MAX_B=61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<int> cnt(MAX_B,0),can(MAX_B,0);
    ll ans=0;
    BinaryMatrix<MAX_B,MAX_N+1> BM(MAX_B,N+1);
    for (int i=MAX_B-1;i>=0;--i){
        rep(j,N) if (A[j]&(1LL<<i)) ++cnt[i];
        if (cnt[i]&1) ans+=1LL<<i;
        else if (cnt[i]>0){
            can[i]=1;
            rep(j,N) if (A[j]&(1LL<<i)) BM[MAX_B-1-i][j]=1;
            BM[MAX_B-1-i][N]=1;
        }
    }
    BM.Gauss_Jordan(1);
    rep(i,MAX_B){
        if (!can[MAX_B-1-i]) continue;
        int ok=0;
        rep(j,N) if (BM[i][j]==1) ok=1;
        if (BM[i][N]==0) ok=1;;
        if (ok) ans+=(2LL<<(MAX_B-1-i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
h,w=gets.split.map(&:to_i)
diff_min = 100000000000
if h % 3 == 0 || w % 3 == 0
  puts 0
  exit
end
[h/3-2, 1].max.upto([h/3+2, h-1].min) do |i|
  [2*h/3-2, 1].max.upto([2*h/3+2, h-1].min) do |j|
    s1 = w * i
    s2 = w * (j - i)
    s3 = w * (h - j)
    diff = [s1, s2, s3].max - [s1, s2, s3].min
    diff_min = diff if diff_min > diff
  end
end

[w/3-2, 1].max.upto([w/3+2, w-1].min) do |i|
  [2*w/3-2, 1].max.upto([2*w/3+2, w-1].min) do |j|
    s1 = h * i
    s2 = h * (j - i)
    s3 = h * (w - j)
    diff = [s1, s2, s3].max - [s1, s2, s3].min
    diff_min = diff if diff_min > diff
  end
end

[h/3-2, 1].max.upto([h/3+2, h-1].min) do |i|
  [w/2-2, 1].max.upto([w/2+2, w-1].min) do |j|
    s1 = w * i
    s2 = j * (h - i)
    s3 = (w - j) * (h - i)
    diff = [s1, s2, s3].max - [s1, s2, s3].min
    diff_min = diff if diff_min > diff
  end
end

[w/3-2, 1].max.upto([w/3+2, w-1].min) do |i|
  [h/2-2, 1].max.upto([h/2+2, h-1].min) do |j|
    s1 = h * i
    s2 = j * (w - i)
    s3 = (h - j) * (w - i)
    diff = [s1, s2, s3].max - [s1, s2, s3].min
    diff_min = diff if diff_min > diff
  end
end
puts diff_min


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

const ll mod = 1e9+7;
bool chk(int a, int b, int c) { 
    if (a + b <= c || a + c <= b || b + c <= a) 
        return false; 
    else
        return true; 
}
int main() {
    int n;
    cin >> n;
    vector<int>arr(n),v(3);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int count = 0;
    set<int>s;
    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(arr[i] != arr[j] and (arr[j] != arr[k]) and(arr[i] != arr[k])){
                    if(chk(arr[i],arr[j],arr[k])){
                        count++;
                    }
                }
            }
        }
    }

    cout << count << endl;
}






Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

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

        int N = scan.nextInt();
        int[] Nnumber = new int[N];
        for (int n = 0; n < N; n++) {
        	Nnumber[n] = 1;
        }

        int M = scan.nextInt();

        int[] H = new int[N];
        for (int h = 0; h < N; h++) {
        	H[h] = scan.nextInt();
        }

        for (int i = 1; i <= M; i++) {
        	int tenboudai_num1 = scan.nextInt() - 1;
        	int tenboudai_num2 = scan.nextInt() - 1;
        	if (H[tenboudai_num1] > H[tenboudai_num2]) {
        		Nnumber[tenboudai_num2] = 0;
        	} else if (H[tenboudai_num1] < H[tenboudai_num2]) {
        		Nnumber[tenboudai_num1] = 0;
        	} else if (H[tenboudai_num1] == H[tenboudai_num2]) {
        		Nnumber[tenboudai_num1] = 0;
        		Nnumber[tenboudai_num2] = 0;
        	}
        }

        int count = 0;
        for (int k = 0; k < N; k++) {
        	if (Nnumber[k] != 0) {
        		count++;
        	}
        }

		System.out.println(count);

	}
}

Measured memory_bytes: 59940
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
using f32 = float;
using f64 = double;
using i8 = int_fast8_t;
using u8 = uint_fast8_t;
using i16 = int_fast16_t;
using u16 = uint_fast16_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
inline void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main(int argc, char *argv[]) {
    fast_io();

    i64 n;
    cin >> n;
    vector<i64> a(n);
    map<i64, i64> all;
    for (i64 i = 0; i < n; i++) {
        cin >> a[i];
        all[a[i]]++;
    }
    i64 sum = 0;
    for (auto i : all) {
        sum += i.second * (i.second - 1) / 2;
    }
    for (i64 i = 0; i < n; i++) {
        cout << sum - (all[a[i]] * (all[a[i]] - 1) / 2) +
                    ((all[a[i]] - 1) * (all[a[i]] - 2) / 2)
             << '\n';
    }

    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
  int n, t1 = 0, t2, x1 = 0, x2, y1 = 0, y2;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> t2 >> x2 >> y2;
    t1 = t2 - t1;
    x1 = abs(x2 - x1);
    y1 = abs(y2 - y1);
    if((x1 + y1) % 2 != t1 % 2 || (x1 + y1) > t1){
      cout << "No" << endl;
      return 0;
    }
    t1 = t2; x1 = x2; y1 = y2;
  }
  cout << "Yes" << endl;
}


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


int main(){
	int n,a,sum=0;
	cin >> n;
	a=n;
	while(1){
		if(a<=0)
			break;
		sum+=a%10;
		a/=10;
	}
	
	cout << (n%sum==0?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
P = [int(p) for p in input().split()]
Problem = [0, 0, 0]
for p in P:
    if p <= A: Problem[0] += 1
    elif A < p <= B: Problem[1] += 1
    else: Problem[2] += 1
print(min(Problem))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
int a,b,c,k;
cin>>a>>b>>c>>k;
for(int i=0;i<k;i++){
if(a>=b&&a>=c)a*=2;
if(b>a&&b>=c)b*=2;
if(c>a&&c>b)c*=2;
}
cout<<a+b+c;
return 0;
}

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

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

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

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

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

    ll x = (N[0] - '0') - 1, y = N[0] - '0';
    REP(i,1,SZ(N)) {
        x += 9;
        y += (N[i] - '0');
    }
    PR(MAX(x,y));

    return 0;
}

/*



*/

Measured memory_bytes: 3616
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n;
  cin>>n;
  for(int i=n;i<=999;i++){
    if(i%111==0){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256