akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void assignColor();
void dfs(int r, int c);

int main() {
    int s, t, m, q;

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if ( color[s] == color[t]) {
            cout << "yes" << '\n';
        }
        else {
            cout << "no" << '\n';
        }
    }

}


void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] =  c;
    while (!S.empty()) {
        int u = S.top(); S.pop();
        for ( int i = 0; i < G[u].size(); i++ ){
            int v = G[u][i];
            if (color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL) dfs(u, id++);
    }
}



Measured memory_bytes: 8896
package main

import(
	"os"
	"io"
	"bufio"
	"bytes"
	"fmt"

	"strings"
	"strconv"
	"sort"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

func max(lhs, rhs int) int {
	if lhs < rhs {
		return rhs
	} else {
		return lhs
	}
}

func solve(items *[]Item, capacity int) float64 {
	// sort by value
	sort.Slice((*items), func(lhs, rhs int) bool {
		return float64((*items)[lhs].value) / float64((*items)[lhs].weight) > float64((*items)[rhs].value) / float64((*items)[rhs].weight)
	})
	// for _, v := range *items {
	// 	fmt.Printf("%v => %f\n", v, float64(v.value) / float64(v.weight))
	// }
	total := 0.0
	for _, v := range (*items) {
		if v.weight <= capacity {
			capacity -= v.weight
			total += float64(v.value)
		} else {
			total += float64(v.value) / float64(v.weight) * float64(capacity)
			capacity = 0
		}
	}
	return total
}

type Item struct {
	value int
	weight int
}

func main() {
	var n int
	var capacity int
	fmt.Scanf("%d %d", &n, &capacity)
	inputs, err := ReadLongLines(n)
	if err != nil {
		fmt.Println(err)
		return
	}

	items := make([]Item, n)
	for i := range items {
		s := strings.Split(inputs[i], " ")
		v, _ := strconv.Atoi(s[0])
		w, _ := strconv.Atoi(s[1])
		items[i] = Item{v, w}
	}
	total := solve(&items, capacity)
	fmt.Printf("%f", total)
}


Measured memory_bytes: 10232
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int main(){
	ll x, y;
	cin >> x >> y;
	ll res=1, tmp=x;
	while(tmp*2<=y){
		tmp*=2;
		res++;
	}
	cout << res << endl;
	return 0;
}


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



int main()
{
     int n,v[101]={0},x,nr=0,i;

     cin>>n;

     for(i=1;i<=n; i++)
     {
         cin>>x;
         v[x]=1;

     }

     for(i=1; i<=100; i++)
       if(v[i])nr++;

     cout<<nr;






    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

class Point
{
public:
  double x, y;

  Point(double x = 0, double y = 0) : x(x), y(y) {}

  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(a * x, a * y); }
  Point operator/(double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }

  bool operator<(const Point &p) const
  {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator==(const Point &p) const
  {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

typedef Point Vector;

double dot(Vector a, Vector b)
{
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b)
{
  return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b)
{
  return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2)
{
  return isOrthogonal(a1 - a2, b1 - b2);
}

bool isParallel(Vector a, Vector b)
{
  return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2)
{
  return isParallel(a1 - a2, b1 - b2);
}

int main()
{
  int q;
  int x0, y0, x1, y1, x2, y2, x3, y3;
  cin >> q;

  for (int i = 0; i < q; i++)
  {
    scanf("%d %d %d %d %d %d %d %d", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
    if (isOrthogonal(Point(x0, y0), Point(x1, y1),
                     Point(x2, y2), Point(x3, y3)))
    {
      cout << 1 << endl;
    }
    else if (isParallel(Point(x0, y0), Point(x1, y1),
                        Point(x2, y2), Point(x3, y3)))
    {
      cout << 2 << endl;
    }
    else
    {
      cout << 0 << endl;
    }
  }

  return 0;
}


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

int main (void)
{
    int N, T, A, H[1000];
    int i, ans = 0;
    double temp;

    scanf("%d", &N);
    scanf("%d %d", &T, &A);

    for (i = 0; i < N; i++) {
         scanf("%d", &H[i]);
        if (fabs(A - (T - H[ans] * 0.006)) > fabs(A - (T - H[i] * 0.006))) ans = i;
    }

    printf("%d\n", ans + 1);
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

        static class TaskA {
                public void solve(int testNumber, InputReader in, PrintWriter out) {
                        long a = in.l();
                        long b = in.l();
                        if (a * b % 2 == 0) {
                                out.println("Even");
                        } else {
                                out.println("Odd");
                        }
                }

        }

        static class InputReader {
                InputStream is;
                private byte[] inbuf = new byte[1024];
                public int lenbuf = 0;
                public int ptrbuf = 0;

                public InputReader(InputStream is) {
                        this.is = is;
                }

                private int readByte() {
                        if (lenbuf == -1) throw new InputMismatchException();
                        if (ptrbuf >= lenbuf) {
                                ptrbuf = 0;
                                try {
                                        lenbuf = is.read(inbuf);
                                } catch (IOException e) {
                                        throw new InputMismatchException();
                                }
                                if (lenbuf <= 0) return -1;
                        }
                        return inbuf[ptrbuf++];
                }

                public long l() {
                        long num = 0;
                        int b;
                        boolean minus = false;
                        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
                        if (b == '-') {
                                minus = true;
                                b = readByte();
                        }

                        while (true) {
                                if (b >= '0' && b <= '9') {
                                        num = num * 10 + (b - '0');
                                } else {
                                        return minus ? -num : num;
                                }
                                b = readByte();
                        }
                }

        }
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll n,m;
VV to;

Vec bfs(ll s){
    Vec dist(n,INF);
    Vec pre(n,-1);
    dist[s]=0;
    queue<ll> q;
    q.push(s);

    P best(INF,s);
    while(!q.empty()){
        ll &now = q.front();
        q.pop();
        Each(y,to[now]){
            if(y==s){
                if(best.fi>dist[now]){
                    best = mp(dist[now],now);
                }
            }
            if(dist[y]>dist[now]+1){
                dist[y]=dist[now]+1;
                pre[y]=now;
                q.push(y);
            }
        }
    }
    Vec res;
    if(best.fi==INF){
        return  res;
    }
    res.pb(s);
    res.pb(best.se);
    ll p = best.se;
    while(1){
        if(pre[p]==s){
            break;
        }
        res.pb(pre[p]);
        p = pre[p];
    }
    reverse(ALL(res));
    return res;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    to.resize(n);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        to[a].pb(b);
    }
    Vec ans;
    rep(i,n){
        Vec res = bfs(i);
        if(res.size()>0){
            if(ans.size()==0){
                ans = res;
            }else{
                if(res.size()<ans.size()){
                    ans = res;
                }
            }
        }
    }
    if(ans.size()==0){
        cout<<-1<<endl;
        return 0;
    }else{
        cout<<ans.size()<<endl;
        rep(i,ans.size()){
            cout<<ans[i]+1<<endl;
        }
    }
    return  0;
}


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

int main() {
  int N;
  cin >>N;
  //cout <<N <<endl;
  
  vector<int> A(N);
  vector<vector<int>> x(N), y(N);
  for (int i=0; i<N; i++){
    cin >>A.at(i);
    //cout <<A.at(i) <<endl;
    for (int j=0; j<A.at(i); j++){
      int tmpx=0, tmpy=0;
      cin >>tmpx >>tmpy;
      x.at(i).push_back(tmpx-1);
      y.at(i).push_back(tmpy);
      //cout <<x.at(i).at(j) +1 <<" " <<y.at(i).at(j) <<endl;
    }
  }
  
  int ans = 0;
  for (int i=0; i<(1<<N); i++){
    bitset<16> bit(i);
    int tmp=0;
    bool flag=true;
    for (int j=0; j<N; j++){
      if(bit.test(j)){
        for (int k=0; k<x.at(j).size(); k++){
          
          //cout <<endl << "bit:" <<bit <<" j:" <<j <<" x:" <<x.at(j).at(k) <<" y:" <<y.at(j).at(k);
          
          if (bit.test(x.at(j).at(k)) && (y.at(j).at(k))==1 ){
            //tmp++;
            //cout <<" OK1 " ;
          }else if( !(bit.test(x.at(j).at(k))) && (y.at(j).at(k))==0 ){
            //tmp++;
            //cout <<" OK1 " ;
          }else{
            flag=false;
            //cout <<" NG1 " ;
          }
          //if(!flag) break;
          if(flag){
          //tmp++;
            //cout <<endl << "bit:" <<bit <<" j:" <<j <<" x:" <<x.at(j).at(k) <<" y:" <<y.at(j).at(k);
          //cout <<" OK " ;
          }else{
            //cout <<" NG ";
          }
        } //k
        if(flag) tmp++;
      } //if(bit.test(j))
      //if(!flag) break;
    } //j
    if (!flag) tmp=0;
    ans = max(ans, tmp);
    //cout <<endl <<"ans: " <<ans <<" tmp: "<<tmp <<endl;
  } //i
  cout <<ans <<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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 dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;

    int max_len=1;
    int last = n-1,num_zero=(s.back()=='0');
    for(int first = n-2; 0 <= first; first--)
    {
        if(s[first]=='1' || (s[first]=='0' && s[first+1]=='0')){
            max_len = max(max_len, last - first + 1);
        }
        else{
            ++num_zero;
            while(k<num_zero){
                while(s[last]=='1')--last;
                while(s[last]=='0')--last;
                --num_zero;
            }
            max_len=max(max_len,last-first+1);
        }
    }
    cout<<max_len<<endl;
}

Measured memory_bytes: 512
import math
import itertools

N , D  = map(int,input().split())
X_list = list() 
count = 0

for i in range(N):
	Inp = list(map(int,input().split()))
	X_list.append(Inp)

for i in itertools.combinations(X_list,2):
	distance = 0
	for j in range(len(i[0])):
		distance += abs(i[0][j]-i[1][j])**2
	if math.sqrt(distance) % 1 == 0:
		count += 1 
print(count)

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  std::sort(v.begin(), v.end());
  long double num = v[0];
  for (int i = 1; i < v.size(); i++)
  {
    num = (num + v[i]) / 2;
  }

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>
#include <string.h>
 
char map[22][22], mk[22][22];
int que[500][2], top, end;
int m[4][2] = {{1,0},{-1,0},{0,-1},{0,1}};
 
int main()
{
    int w, h, i, r, c, r2, c2, ans;
     
    while (scanf("%d%d", &w, &h) && w) {
        memset(mk, 0, sizeof(mk));
        for (i = 0, r = 0; r < h; r++) {
            scanf("%s", map[r]);
            for (c = 0; c < w; c++) if (map[r][c] == '@') {
                que[0][0] = r, que[0][1] = c; mk[r][c] = 1, top = 0, end = 1, i = 1;
            }
        }
        while (top < end) {
            r = que[top][0], c = que[top++][1];
            for (i = 0; i < 4; i++) {
                r2 = r + m[i][0], c2 = c + m[i][1];
                if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || map[r2][c2] == '#') continue;
                if (mk[r2][c2]) continue;
                mk[r2][c2] = 1;
                que[end][0] = r2, que[end++][1] = c2;
            }
        }
        for (ans = 0, r = 0; r < h; r++) for (c = 0; c < w; c++) ans += mk[r][c];
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2104
var s,n;
var count;

function Merge(left,mid,right){
    var n1 = mid - left;
    var n2 = right - mid;
    var L = new Array(n1 + 1),R = new Array(n2 + 1);
    for(var i = 0;i < n1;i++)
        L[i] = s[left + i];
    for(var i = 0;i < n2;i++)
        R[i] = s[mid + i];
    L[n1] = 2000000000;
    R[n2] = 2000000000;
    var i = 0;
    var j = 0;
    for(var k = left;k < right;k++){
        if(L[i] <= R[j])
            s[k] = L[i++];
        else{
            s[k] = R[j++];
            count += n1 - i;
        }

    }
}

function MergeSort(left,right){
    if(left + 1< right){
        var mid = Math.floor((left + right)/2);
        MergeSort(left,mid);
        MergeSort(mid,right);
        Merge(left,mid,right);
    }
}

function Main(input){
    input = input.split("\n");
    n = parseInt(input[0],10);
    s = new Array(n);
    input[1] = input[1].split(" ");
    for(var i = 0;i < n;i++){
        s[i] = parseInt(input[1][i],10);
    }
    count = 0;
    MergeSort(0,n);
    console.log(count);
}
 
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 48648
def Csum(a):
    b,c=[0],0
    for i in range(len(a)):
        c+=a[i]
        b.append(c)
    return b
n,k=map(int,input().split())
p=Csum(list(map(int,input().split())))
ans=0
for i in range(n-k+1):
    ans=max(ans,p[i+k]-p[i])
print((ans+k)/2)

Measured memory_bytes: 32064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
using namespace std;
typedef unsigned long long ll;
ll n;
ll a[5];
int main()
{
	cin>>n;
	ll mn;
	for(int i=0;i<5;i++){
		cin>>a[i];
		if(i==0) mn=a[i];
		else mn=min(mn,a[i]);
	}
	cout<<(n+mn-1)/mn+4<<endl;
}

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

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

  map<string, int> mp;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }

  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main() {
    int n , a = 0;
    string s;
    cin >> n;
    cin >> s;
    cin >> a;
    char ex = s[a -1];
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] != ex){
            s[i] = '*';
        }
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
l[11],v1,v2;main(i){for(;~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2);printf("%d\n",i+1)){for(i=1;i<10;i++)l[i]+=l[i-1];for(i=0;i<10;i++){if(l[i]>=l[9]*(v1/((double)v1+v2)))break;}}exit(0);}

Measured memory_bytes: 596
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//string alp = "abcdefghijklmnopqrstuvwxyz";
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  cout << ((a%3==0||b%3==0||(a+b)%3==0)?"Possible":"Impossible") << endl;
  return 0;
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())
n = ip()                                     #入力整数1つ
#n,x= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
b = set(a)
coin = len(a) - len(b)
if coin%2:coin+=1
print(len(a)-coin)

Measured memory_bytes: 24684
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main()
{
	int* nums;
	int numsCount;

	std::cin >> numsCount;
	nums = new int[numsCount];
	for (int i = 0; i < numsCount; i++)
	{
		std::cin >> nums[i];
	}

	std::vector<int> appearedNums = {};
	std::vector<int> appearedCounts = {};
	int eliminateCount = 0;

	for (int i = 0; i < numsCount; i++)
	{
		bool newbie = true;
		for (int j = 0; j < appearedNums.size(); j++)
		{
			if (nums[i] == appearedNums[j])
			{
				newbie = false;
				appearedCounts[j]++;
				break;
			}
		}
		if (newbie)
		{
			if (nums[i] > numsCount - i)
			{
				eliminateCount += 1;
			}
			else
			{
				appearedNums.push_back(nums[i]);
				appearedCounts.push_back(1);
			}
		}
	}

	for (int i = 0; i < appearedNums.size(); i++)
	{
		if (appearedCounts[i] >= appearedNums[i])eliminateCount += appearedCounts[i] - appearedNums[i];
		else eliminateCount += appearedCounts[i];
	}

	std::cout << eliminateCount;

    return 0;
}



Measured memory_bytes: 640
ans = []
while True:
    data = raw_input().split()
    n = int(data[0])
    m = int(data[1])
    if n == 0 and m == 0:
        break
    
    member = range(1,n+1)
    p = 0
    c = n
    while c != 1:
        p += m-1
        if p >= c:
            while p >= c:
                #print 'out:',p,'->',p-c
                p = p-c
                
        #print 'c:',c,' p:',p
        temp = member.pop(p)
        #print temp
        c -= 1
    ans.append(member[0])
for i in ans:
    print i

Measured memory_bytes: 4260
def divide_num(n):
  ans = 0
  for i in range(1,n+1):
    if n%i == 0:
      ans+=1
  return ans
n = int(input())
res = 0
for i in range(1,n+1):
  d = divide_num(i)
  if d == 8 and i%2 ==1:
    res +=1
print(res)

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

ll power(ll n,ll p,ll mod)
{
  if(p==0) return 1;
  ll temp=power(n,p/2,mod)%mod;
  temp=(temp*temp)%mod;
  if(p%2 !=0) temp*=n;
  return temp%mod;
}

int main()
{
    ll n;cin>>n;
    if(n>=400 && n<600) cout<<8;
    else if(n>=600 && n<800) cout<<7;
    else if(n>=800 && n<1000) cout<<6;
    else if(n>=1000 && n<1200) cout<<5;
    else if(n>=1200 && n<1400) cout<<4;
    else if(n>=1400 && n<1600) cout<<3;
    else if(n>=1600 && n<1800) cout<<2;
    else if(n>=1800 && n<2000) cout<<1;
    
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    if(x >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

int main(void){
    ll N,K;
    cin>>N>>K;
    vector<pair<ll,ll>> P(N);
    for (ll i=0;i<N;i++) cin>>P[i].first>>P[i].second;
    sort(P.begin(),P.end());
    for (ll i=0;i<N;i++){
        ll a=P[i].first,b=P[i].second;
        K -= b;
        if (K<=0) {
            cout<<a<<endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  int ra = r *100;
  int ga = g *10;
  int k = ra + ga + b;
  if(k%4 == 0) cout << "YES" <<endl;
  else cout << "NO" <<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;
using ll = long long;

int main()
{
    int n;
    scanf("%d", &n);

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

    sort(a, a + n * 3);

    ll ans = 0;
    for (int i = 0; i < n; ++i)
        ans += a[n + i * 2];

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1408
n, m = gets.chomp.split.map(&:to_i)
ab = Array.new(n) { gets.chomp.split.map(&:to_i) }.sort_by! {|a, _| a }
res = 0
ab.each do |a, b|
  num = [b, m].min
  res += a * num
  m -= num
  break if m <= 0
end
puts res

Measured memory_bytes: 12664
c=[]
for i in range(3):
    a,b=map(int,input().split())
    c.append(a)
    c.append(b)
if c.count(1)<3 and c.count(2)<3 and c.count(3)<3 and c.count(4)<3:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int N;
long long h[100010];

long long dp[100100];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100100; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i< (int)(n); i++)
typedef long long ll;


int main(){
    int S, W;
    cin >> S >> W;
    if (W >= S){
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3532
#include <iostream>
using namespace std;
int main()
{
    int n,m,x,a[101]={0},j,sum1=0,sum2=0;
    cin>>n>>m>>x;
    for(int i=0;i<m;i++)
    {
        cin>>j;
        a[j]=1;
    }
    for(int i=0;i<x;i++)
        sum1+=a[i];
    for(int i=x;i<n;i++)
        sum2+=a[i];
    if(sum1<sum2)
        cout<<sum1<<endl;
    else
        cout<<sum2<<endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
int main(){
    LL N;cin>>N;
    vector<LL> spf(N+1,0);
    for( LL i = 0; i <= N; i++)spf[i]=i;
    for( LL i = 2; i*i <= N; i++ ){
        //if(i==2)cout<<spf[i]<<" "<<i<<endl;
        if( spf[i]==i){
            for( LL j = i * i; j <= N; j += i ){//primeの2倍,3倍,4倍,...,
                if(spf[j]==j)spf[j]=i;   
            }
        }
    }
    //REP(i,100)cout<<spf[i]<<endl;
    LL res=1;
    for(LL i=2;i<=N;i++){
        map<LL,int>mp;
        LL n=i;
        while(n!=1){
            mp[spf[n]]++;
            n/=spf[n];
            //cout<<n<<" "<<spf[n]<<endl;
        }
        LL resn=1;
        for(auto it:mp){
            resn*=(it.second+1LL);
        }
        res+=(i*resn);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 81384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define inf 1e17
#define MAX_SIZE 1000005 

void pr(int arr[], int size) 
{ for (ll i=0; i < size; i++) {printf("%d ", arr[i]); }cout << endl;}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
   ll t=1;
    // cin>>t;
    while(t--){
        ll n;
        cin >> n;
        ll x = n%10;
        if(x==3){cout << "bon" << endl;}
        else{
            if(x == 2 || x == 4 || x == 5 || x==7 || x==9){cout << "hon" << endl;}
            else{cout << "pon" << endl;}
        }
    }
  return 0;
}


Measured memory_bytes: 3660
def insertionSort(A, n, g):
  cnt = 0
  for i in range(g, n):
    v = A[i]
    j = i - g
    while j >= 0 and A[j] > v:
      A[j + g] = A[j]
      j = j - g
      cnt += 1
    A[j + g] = v

  return cnt

def shellSort(A, n):
  tot_cnt = 0
  G = [1]
  span = 4

  while span < n:
    G.append(span)
    span = span * 3 + 1

  G.reverse()
  m = len(G)
  
  for g in G:
    tot_cnt += insertionSort(A, n, g)

  return m, G, tot_cnt

n = int(input())
A = []

for i in range(n):
  A.append(int(input()))

m, G, tot_cnt = shellSort(A, n)
print(m)
print(*G)
print(tot_cnt)
print(*A, sep = "\n")


Measured memory_bytes: 53304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdin = new Scanner(System.in);
		String s = stdin.next();
		System.out.println(Character.getNumericValue(s.charAt(0))+Character.getNumericValue(s.charAt(1))+Character.getNumericValue(s.charAt(2)));
		

	}

}


Measured memory_bytes: 23636
/* 
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    int n;
    cin >> n;
    vector<vector<int>> val(n, vector<int>(3));
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < 3; ++j)
        {
            cin >> val[i][j];
        }
    }
    vector<int> dp = {val[0][0], val[0][1], val[0][2]};
    for(int i = 1; i < n; ++i)
    {
        vector<int> prev = dp;
        for(int j = 0; j < 3; ++j)
        {
            for(int k = 0; k < 3; ++k)
            {
                if(j == k) continue;
                dp[j] = max(dp[j], val[i][j] + prev[k]);
            }
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << "\n";
    return 0; 
}


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

int parent[200005], ranks[200005];

void initset(int n) {
  for (int i = 0; i < n; i++) {
    parent[i] = i;
    ranks[i] = 0;
  }
}

int findset(int x) {
  if (parent[x] == x) return x;
  parent[x] = findset(parent[x]);
  return parent[x];
}

bool sameset(int x, int y) {
  return findset(x) == findset(y);
}

void mergeset(int x, int y) {
  x = findset(x);
  y = findset(y);
  if (ranks[x] > ranks[y]) {
    parent[y] = x;
  }
  else {
    parent[x] = y;
    if (ranks[x] == ranks[y]) {
      ranks[y]++;
    }
  }
}

int N, M, K, L;

int main() {

  cin >> N >> M;
  initset(N+M+5);
  for (int i = 0; i < N; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> L;
      mergeset(i+1, N+L);
    }
  }
  
  for (int i = 1; i <= N; i++) {
    if (!sameset(i,1)) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  
}


Measured memory_bytes: 1792
N = int(input())
t = [list(map(int,input().split())) for _ in range(N)]
for i in range(N):
    if (
           (t[i][0] % 2 == 0 and ((t[i][1]+t[i][2]) % 2 != 0 or (abs(t[i][1])+abs(t[i][2])) > t[i][0]))
        or (t[i][0] % 2 == 1 and ((t[i][1]+t[i][2]) % 2 != 1 or (abs(t[i][1])+abs(t[i][2])) > t[i][0]))
        ):
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 27300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public struct Pos
	{
		public int X {get;set;}
		public int Y {get;set;}

	}
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var h = p[0];
		var w = p[1];
		
		var map = new int[w, h];
		var score = new int[w, h];
		for(int y = 0; y < h; y++)
		{
			var l = Console.ReadLine();
			for(int x = 0; x < w; x++)
			{
				map[x, y] = (l[x] == '.') ? 0 : 1;
			}
		}
		int max = 0;
		for(int y = 0; y < h; y++)
		{
			for(int x = 0; x < w; x++)
			{
				var np = new int[w,h];
				for(int i = 0; i < w; i++)
					for(int j = 0; j < h; j++)
						np[i,j] = 9999999;
				Route(new Pos(){X=x,Y=y}, 0, w, h, map, np);
				int t=0;
					for(int j = 0; j < h; j++){
				for(int i = 0; i < w; i++)
					
						//Console.Write(np[i,j]);
						if(np[i,j]!=9999999)
						t=Math.Max(t, np[i,j]);
						//Console.WriteLine();
						}
				max = Math.Max(max, t);
			}
		}
		Console.WriteLine(max);
	}
	
	private static int Route(Pos pos, int score, int w, int h, int[,] map, int[,] scores)
	{
		if(!(pos.X >= 0 && pos.Y >= 0 && pos.X < w && pos.Y < h))
		{
			return score - 1;
		}
		//Console.WriteLine(pos.X + "," + pos.Y);
		if(map[pos.X, pos.Y] == 1)	return score - 1;
		
		if(scores[pos.X, pos.Y] <= score)	return score - 1;
		
		int maxScore = score;
		scores[pos.X, pos.Y] = score;
		
		maxScore = Math.Max(maxScore, Route(new Pos(){X=pos.X + 1, Y=pos.Y + 0}, score + 1, w, h, map, scores));
		maxScore = Math.Max(maxScore, Route(new Pos(){X=pos.X + 0, Y=pos.Y + 1}, score + 1, w, h, map, scores));
		maxScore = Math.Max(maxScore, Route(new Pos(){X=pos.X + 0, Y=pos.Y - 1}, score + 1, w, h, map, scores));
		maxScore = Math.Max(maxScore, Route(new Pos(){X=pos.X - 1, Y=pos.Y + 0}, score + 1, w, h, map, scores));
		return maxScore;
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11348
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    println!("{}", (n-2) * 180);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
    long long a,b,x;
    while(~scanf("%lld%lld%lld",&a,&b,&x))
    {
        long long ax=a/x;
        long long bx=b/x;
        if(a%x==0) bx++;
        printf("%lld\n",bx-ax);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <numeric>

int main()
{
    int n;
    std::cin >> n;
    std::vector<int64_t> arr(3 * n);
    for (int i = 0; i < 3 * n; ++i)
    {
        std::cin >> arr[i];
    }

    std::priority_queue<int64_t, std::vector<int64_t>, std::greater<int>> q1;
    std::priority_queue<int64_t> q2;
    std::vector<int64_t> max1(n + 1), max2(n + 1);

    int64_t sum1 = std::accumulate(arr.begin(), arr.begin() + n, 0ll);
    int64_t sum2 = std::accumulate(arr.rbegin(), arr.rbegin() + n, 0ll);
    for (int i = 0; i < n; ++i)
    {
        q1.emplace(arr[i]);
        q2.emplace(arr[3 * n - i - 1]);
    }
    max1[0] = sum1;
    max2[n] = sum2;

    for (int i = 0; i < n; ++i)
    {
        const auto top1 = q1.top();
        if (top1 < arr[n + i])
        {
            // 交換したほうがいい
            sum1 += arr[n + i] - top1;
            q1.pop();
            q1.emplace(arr[n + i]);
        }
        max1[i + 1] = sum1;

        const auto top2 = q2.top();
        if (top2 > arr[2 * n - i - 1])
        {
            // 交換したほうがいい
            sum2 += arr[2 * n - i - 1] - top2;
            q2.pop();
            q2.emplace(arr[2 * n - i - 1]);
        }
        max2[n - i - 1] = sum2;
    }

    int64_t d = max1[n] - max2[n];
    for (int i = 0; i < n; ++i)
    {
        d = std::max(d, max1[i] - max2[i]);
    }

    std::cout << d << std::endl;
    return 0;
}


Measured memory_bytes: 9000
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] H = new int[N];

        for (int i = 0; i < N; i++) {
            H[i] = sc.nextInt();
        }

        int max = 0;
        int cnt = 0;
        int cur = H[0];
        for (int i = 1; i < N; i++) {
            if (cur >= H[i]) {
                cnt++;
            } else {
                cnt = 0;
            }
            max = Math.max(cnt, max);
            cur = H[i];
        }

        System.out.println(max);
        return;
    }

}

Measured memory_bytes: 50992
(eval-when (:compile-toplevel)
  #-swank (proclaim '(optimize (speed 3) (debug 0) (safety 0))))

(defparameter inf 2000000000)

(defun read-integer (&optional (in *standard-input*))
  (declare (inline read-byte))
  (labels ((number-char-p (b)
             (<= #.(char-code #\0) b #.(char-code #\9)))
           (minus-char-p (b)
             (= b #.(char-code #\-)))
           (to-number (b)
             (- b #.(char-code #\0))))
    (declare (inline number-char-p minus-char-p to-number))
    (macrolet ((%read-byte ()
                 '(the (unsigned-byte 8)
                       #+swank (char-code (read-char in nil #\Nul))
                       #-swank (read-byte in nil 0))))
      (let* ((minus-p nil)
             (x (loop for b = (%read-byte)
                      if (number-char-p b)
                        return (to-number b)
                        end
                      if (minus-char-p b)
                        do (setf minus-p t))))
        (declare (boolean minus-p) (fixnum x))
        (the fixnum (loop for b = (%read-byte)
                          and y = x then (+ (* y 10) (to-number b))
                          unless (number-char-p b)
                            return y))))))

(defun split (x str &optional (acc nil))
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (split x (subseq str (+ pos size)) (cons (subseq str 0 pos) acc))
        (nreverse (cons str acc)))))

(defmacro minf (field &rest x)
  `(setf ,field (min ,field ,@x)))

(defmacro maxf (field &rest x)
  `(setf ,field (max ,field ,@x)))

(defun solve (stairs n)
  (let ((dp (make-array n :element-type 'integer :initial-element inf)))
    (setf (aref dp 0) 0)
    (dotimes (i (1- n))
      (minf (aref dp (1+ i)) (+ (aref dp i) (abs (- (aref stairs i) (aref stairs (1+ i))))))
      (if (< (+ i 2) n)
          (minf (aref dp (+ i 2)) (+ (aref dp i) (abs (- (aref stairs i) (aref stairs (+ i 2))))))))
    (aref dp (1- n))))

(let* ((n (parse-integer (read-line)))
       (stairs (make-array n :adjustable t :fill-pointer 0)))
  (dotimes (i n)
    (vector-push (read-integer *standard-input*) stairs))
  (format t "~A~%" (solve stairs n)))



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

int main() {
  int n,i,j,l;
  double s[10020];
  double a2,m,a;
  
  while(1) {
    m=0;
    a2 = 0;
    scanf("%d" , &n);
    if(n == 0) {
      break;
    }

    for(i=0;i<n;i++) {
      scanf("%lf", &s[i]);
	m=m+s[i];
	//printf("m[%d] = %lf\n",i ,m);
    }
    m=m/n;

    for(i=0; i<n; i++) {
      a2 =a2+(s[i]-m)*(s[i]-m);
    }
    a2 = a2/n;

    printf("%.11lf\n",sqrt(a2));

  }

  return 0;

}


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

int main() {
  char X,Y,ans;
  cin >> X >> Y;
  map<char,int>a;
  a['A']=10;
  a['B']=11;
  a['C']=12;
  a['D']=13;
  a['E']=14;
  a['F']=15;
  if(a[X]>a[Y]){
    ans='>';
  }else if(a[X]<a[Y]){
    ans='<';
  }else{
    ans='=';
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;

ll cnt1(ll num,int dig) {
	ll cnt = (num) / (1LL << (dig+1)) *(1LL << dig);
	
	if (num % (1LL << (dig + 1)) > (1LL << dig)) {
		cnt += num % (1LL << (dig + 1LL)) - (1LL << dig);
	}
	return cnt;
}


int main() {

	ll a, b;
	cin >> a >> b;
	//cout << a << b << endl;
	vector<bool> f;
	int b_dig = 0;
	while (b  >= (1LL <<  b_dig) ){
		//cout << b_dig << endl;
		f.emplace_back(((cnt1(b+1,b_dig)-cnt1(a,b_dig))%2) == 1);
		b_dig++;
	}

	ll ans = 0;
	for (int i = f.size() - 1;i >= 0; i--) {
		ans = ans * 2 + (f[i] ? 1 : 0);
		//cout << f[i] << endl;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
mod = int(input())
a = {}
b = int(0)
flag = int(0)
ans = int(0)
for i in range(mod):
  b = b * 10 + 7
  b = b % mod
  if b == 0:
    flag = 1
    ans = int(i) + 1
    break
  else:
    pass

if flag == 1:
  print(ans)
else:
  print("-1")

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main()
{
  FASTIO;
  long long int T,count1=0,count2=0,count3=0,count4=0;
  cin>>T;
  string a[T];
  while(T--)
  {
   cin>>a[T];
   if(a[T]=="AC")
   {
    count1++;
   }
   else if(a[T]=="WA")
   {
    count2++;
   }
   else if(a[T]=="TLE")
   {
    count3++;
   }
   else if(a[T]=="RE")
   {
    count4++;
   }
  }
 cout<<"AC "<<"x "<<count1<<"\n";
 cout<<"WA "<<"x "<<count2<<"\n";
 cout<<"TLE "<<"x "<<count3<<"\n";
 cout<<"RE "<<"x "<<count4;
}

Measured memory_bytes: 6772
#include<stdio.h>
int main(void){
    long long int w,h;
    scanf("%lld %lld",&w,&h);
    if(w==1 && h==1){
        printf("1\n");
        return 0;
    }
    if(w==1){
        printf("%lld\n",h-2);
        return 0;
    }
    if(h==1){
        printf("%lld\n",w-2);
        return 0;
    }
    printf("%lld\n",(w-2)*(h-2));
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{int n;
cin>>n;
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{if(s[i]+n<=90)
s[i]=s[i]+n;
else if(s[i]+n>90)
{int rem=abs(90-(s[i]+n));
s[i]=64+rem;
}
}
cout<<s;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

//?????§??¬?´???°????±???????????????°??????(m >= n)
int calcGcd(int m, int n);
//????°???¬?????°????±???????????????°??????
inline int calcLcm(int m, int n, int gcd);

int main(){
	int gcd, lcm, a, b;
	
	while(std::cin >> a >> b){
		if(a > b) gcd = calcGcd(a, b);
		else gcd = calcGcd(b, a);
		lcm = calcLcm(a, b, gcd);
		
		std::cout << gcd << " " << lcm << std::endl;
	}
	
	return 0;
}

int calcGcd(int m, int n){
	return n == 0 ? m : calcGcd(n, m%n);
}

inline int calcLcm(int m, int n, int gcd){
	return m / gcd * n;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n;
  cin>>n;
  vector<int> d(13,0);
  d[0]=1;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    d[x]++;
  }
  int ans=0;
  for(int i=0;i<13;i++)
    if(d[i]>2){
      cout<<0<<endl;
      return 0;
    }
  for(int b=0;b<(1<<13);b++){
    vector<int> v;
    for(int i=0;i<13;i++){
      if(!d[i]) continue;
      if(d[i]==1){ 
	if((b>>i)&1) v.push_back(24-i);
	else v.push_back(i);
      }else{
	v.push_back(24-i);
	v.push_back(i);
      }
    }
    int k=v.size();
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    if(k!=(int)v.size()) continue;
    
    //cout<<b<<":"<<endl;
    //for(int i:v) cout<<i<<" ";cout<<endl;
    
    int tmp=24;
    for(int i=0;i<(int)v.size();i++)
      for(int j=i+1;j<(int)v.size();j++){
	int x=v[j]-v[i];
	//cout<<x<<endl;
	tmp=min(tmp,min(x,24-x));
      }
    
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
	int i,j;
	int a[200010],b[200010];
	for(i=0;i<=n-1;i++)
	   {
	    scanf("%d",&a[i]);
	    b[i]=a[i];
	   }
	sort(b,b+n);
	if(b[n-1]==b[n-2])
	  for(i=1;i<=n;i++)
	      printf("%d\n",b[n-1]);
	else
	  for(i=0;i<=n-1;i++)
	    {
	      if(a[i]!=b[n-1])
	      printf("%d\n",b[n-1]);
	      else
	      printf("%d\n",b[n-2]);
	    }
    }
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  rep(i, 0, h) cin >> v[i];

  queue<P> q;
  vector<vector<int>> mp(h, vector<int>(w, 1e9));
  rep(i, 0, h) {
    rep(j, 0, w) {
      if (v[i][j] == '#') {
        q.push(make_pair(i, j));
        mp[i][j] = 0;
      }
    }
  }

  while (!q.empty()) {
    P p = q.front();
    q.pop();
    int y = p.first, x = p.second;
    rep(i, 0, 4) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || nx < 0 || ny >= h || nx >= w)
        continue;
      if (v[ny][nx] == '#' || mp[ny][nx] != 1e9)
        continue;
      chmin(mp[ny][nx], mp[y][x] + 1);
      q.push(make_pair(ny, nx));
    }
  }

  int ans = 0;
  rep(i, 0, h) {
    rep(j, 0, w) { chmax(ans, mp[i][j]); }
  }

  cout << ans << endl;
}


Measured memory_bytes: 13456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test1
{
    class Program
    {
        static void Main(string[] args)
        {
            var item = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            string msg = string.Empty;
            switch (item[0].CompareTo(item[1]))
            {
                case -1:
                    msg = "a < b";
                    break;
                case 0:
                    msg = "a == b";
                    break;
                case 1:
                    msg = "a > b";
                    break;
            }

            Console.WriteLine(msg);
        }
    }
}

Measured memory_bytes: 5648