akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, k;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	vector<pair<ll, ll> > v(n);
	FOR(i, n) cin >> v[i].first >> v[i].second;
	sort(ALL(v));
	ll ans = 5e18;
	FOR(i, n) FOR(j, i) {
		if (i-j+1 < k) continue;
		ll xsz = v[i].first-v[j].first;
		vector<ll> ys;
		for (int p = j; p <= i; p++) ys.push_back(v[p].second);
		sort(ALL(ys));
		ll ysz = 5e18;
		FOR(p, ys.size()-k+1) {
			ysz = min(ysz, ys[p+k-1]-ys[p]);
		}
		ans = min(ans, xsz*ysz);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	double d, n, cnt = 0;
	cin >> d >> n;
	if (d == 0) {
		for (double i = 1; i < 1000000; i++) {
			if (fmod(i, 100) != 0) {
				cnt++;
				if (cnt == n) {
					cout << i << endl;
					return 0;
				}
			}
		}
	} else if (d == 1) {
		for (double i = 1; i < 10000000; i++) {
			if (fmod(i, 100) == 0) {
				double j=i/100;
				if(fmod(j,100)!=0){
					cnt++;
					if (cnt == n) {
						cout << i <<endl;
						return 0;
					}
				}
			}
		}
	} else {
		for (double i = 10000; i < 10000000; i++) {
			if (fmod(i, 100) == 0) {
				double j=i/100;
				if (fmod(j, 100) == 0) {
					double k=j/100;
					if(fmod(k,100)!=0){
						cnt++;
						if (cnt == n) {
							cout << fixed<<setprecision(0)<<i  << endl;
							return 0;
						}
					}
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n, m; cin >> n >> m;
    vector<bool> toI(n, false), toN(n, false);
    for(int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        if(a == 0) toI[b] = true;
        if(b == n - 1) toN[a] = true;
    }

    for(int i = 0; i < n; i++) {
        if(toI[i] && toN[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n,k;
	char s[11],x;
	cin >> n ;
	for (int i = 0; i < n; ++i) cin >> s[i];
	cin >> k;
	x = s[k - 1];
	for (int i = 0; i < n; ++i)
		if (x != s[i]) s[i] = '*';
	for (int i = 0; i < n; ++i) cout<< s[i];
	cout << endl;
	return 0;
}

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

typedef long long ll;

ll a, b;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b;
    int ans = 1;
    while (1) {
        ll c = a << 1;
        if (c < a) break;
        if (c <= b) {
            ++ans;
            a = c;
        } else {
            break;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int N, M, C, B[20], A[20], count = 0;
	cin >> N >> M >> C;
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < M; j++) {
			cin >> A[j];
			sum += A[j] * B[j];
		}
		if (sum + C > 0) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();
        int[] a = sc.IntArray();

        Array.Sort(a);
        long ans = 0;
        for (int i = 0; i < k; i++)
        {
            ans += a[i];
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 28684
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, X;
  cin >> N >> X;
  vector <int> L(N);
  for (int i = 0; i<N ; i++){
    cin >> L.at(i);
  }
  int distance = 0;
  int number = 0;
  while (distance <= X && number <= N){
    if (number < N){
      distance += L.at(number);
    }
    number ++;
  }
  cout << number <<endl;
}

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

len = len(A)
i = 1
dai = 0

while(i < len):
    if(A[i-1] > A[i]):
        dai += (A[i-1] - A[i])
        A[i] = A[i-1]
    i += 1

print(dai)

Measured memory_bytes: 32380
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

int h, w, n;

bool done(char b[31][31]){
  REP(i,h) REP(j,w) if(b[i][j] != '.') return false;
  return true;
}

bool vanish(char b[31][31]){
  bool kesu[31][31] = {};
  REP(i,h) REP(j,w){
    char c=b[i][j];
    if(c == '.') continue;
    //たてに揃えることが可能
    if(i+n <= h){
      bool ok = true;
      REP(k, n) if(b[i+k][j] != c) {ok = false; break;}
      if(ok) REP(k, n) kesu[i+k][j] = true;
    }
    //横に揃えることが可能
    if(j+n <= w){
      bool ok = true;
      REP(k, n) if(b[i][j+k] != c) {ok = false; break;}
      if(ok) REP(k, n) kesu[i][j+k] = true;
    }          
  }
  bool ok=false;
  REP(i,h) REP(j,w) if(kesu[i][j]) b[i][j]='.', ok=true;
  return ok;
}

void fall(char b[31][31]){
  REP(j,w){
    int m=0;
    char s[31];
    ROF(i,h-1,0) if(b[i][j] != '.') s[m++] = b[i][j];
    REP(i,h) b[i][j] = '.';
    //h-1が下、下から埋める
    REP(i,m) b[h-i-1][j] = s[i];
  }
}

bool solve(char t[31][31]){
  char b[31][31];  
  REP(i, h) REP(j, w) b[i][j] = t[i][j];
      
  if(done(b)) return true;
  fall(b);
  if(!vanish(b)) return false;
  fall(b);

  return solve(b);
}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  char table[31][31];

  cin >> h >> w >> n;
  REP(i, h) {
    REP(j, w) {
      cin >> table[i][j];
    }
  }
  //REP(i, h) REP(j, w) cout << table[i][j] << " ";
  REP(i,h) REP(j,w-1){
    swap(table[i][j], table[i][j+1]);
    if(solve(table)){ cout << "YES" << endl; return 0;}
    swap(table[i][j], table[i][j+1]);
  }

  cout << "NO" << endl;
  
  return 0;
}



Measured memory_bytes: 3196
from collections import deque


H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
maze = [input() for _ in range(H)]

INF = 10 ** 12
path = [[INF] * W for _ in range(H)]  # path: 各マスへの移動コスト

# walk:移動A, warp:移動B
walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:  # 移動A
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))  # 移動Aの場合はコスト0. キューの先頭に追加する.
    for dx, dy in warp:  # 移動B
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1))  # 移動Bの場合はコスト1. キューの最後尾に追加する.
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)

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

using namespace std;

using Int  = int_fast64_t;
using UInt = uint_fast64_t;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

void sub()
{
    const auto N(cin2var<UInt>());
    const auto M(cin2var<UInt>());
    unordered_set<UInt> setAC;
    unordered_map<UInt, UInt> mapWA;
    UInt ac = 0u;
    UInt wa = 0u;
    for (auto i = 0u; i < M; ++i) {
        const auto p(cin2var<UInt>());
        const auto S(cin2var<string>());
        if (setAC.count(p)) continue;
        if (N < p) continue;
        if (S == "AC") {
            ++ac;
            wa += mapWA[p];
            setAC.insert(p);
        }
        else if (S == "WA") {
            ++mapWA[p];
        }
    }
    cout << ac << ' ' << wa << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    sub();
    return 0;
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

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

    string s; cin>>s;
    s='a'+s+'a';
    vector<int> vec;
    string t="";
    rep(i,s.size()){
        if(s.at(i)!='x'){
            t+=s.at(i);
            vec.push_back(i);
        }
    }

    string u=t;
    reverse(all(t));
    if(u!=t){
        cout<<-1<<endl;
        return 0;
    }

    int l=vec.size()/2-1,r=l+1;
    int ans=0;
    if(vec.size()%2==1)r++;
    while(l>=0){
        ans+=abs((vec.at(l+1)-vec.at(l))-(vec.at(r)-vec.at(r-1)));
        l--; r++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1640
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

typedef struct{
  char c[20];
  int time;
}process;

process *make_process(){
  process *p;
  p=malloc(sizeof(process));
  p->time=0;
  return p;
}

typedef process data;
#define success 1
#define failure 0


typedef struct{
  int size;
  int head;
  int tail;
  data **data;
}queue;

queue *make_queue(int queue_size){
  queue *p;
  p=malloc(sizeof(queue));
  p->data=malloc(queue_size*sizeof(data *));
  p->size=queue_size;
  p->head=0;
  p->tail=0;
  return p;
}

int enque(queue *Q,data *x){
  if((Q->tail+1)%(Q->size +1) ==Q->head) return failure;
  else{
    Q->data[Q->tail]=x;
    Q->tail=(Q->tail+1)%(Q->size +1);
    return success;
  }
}

int deque(queue *Q,data **x){
  if(Q->head==Q->tail) return failure;
  else{
    *x=Q->data[Q->head];
    Q->head=(Q->head+1)%(Q->size+1);
    return success;
  }
}




int main(){
  int i,n,q,time=0;
  process **P;
  queue *Q;
  scanf("%d %d",&n,&q);
  P=malloc(n*sizeof(process *));
  Q=make_queue(n);
  for(i=0;i<n;i++){
    P[i]=make_process();
    scanf(" %s%d",P[i]->c,&(P[i]->time));
    enque(Q,P[i]);
  }
  process **x;
  x=malloc(sizeof(process *));
  /**x=make_process();*/
  while(Q->head!=Q->tail){
    deque(Q,x);
    if((*x)->time <= q){
      time+=(*x)->time;
      printf("%s %d\n",(*x)->c,time);
    }
    else{
      (*x)->time-=q;
      enque(Q,*x);
      time+=q;
    }
  }
  return 0;
} 
  
  
  

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

using namespace std;
using ii = pair<int, int>;

int solve(int N, int L)
{
    vector<ii> xs(N);
    int ans = 0;

    for (int i = 0; i < N; ++i)
    {
        xs[i] = ii(abs(L + i), L + i);
        ans += L + i;
    }

    sort(xs.begin(),  xs.end());

    ans -= xs.begin()->second;
    
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, L;
    cin >> N >> L;

    auto ans = solve(N, L);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  double keta=0;
  int N,n=0,a,num,counter;
  cin>>N;
  num=N;
  while(num!=0){
    num/=10;
    keta++;
  }
  a=N;
  counter=keta;
  for(counter;counter>=0;counter--){
    int i=N/pow(10,keta);
    N=N-(i*pow(10,keta));
    n=n+i;
    keta--;
    //cout<<i<<" "<<n<<" "<<N<<" "<<keta<<" "<<endl;
  }
  if(a%n==0){
    cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 4116
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>


int main(){
  int N;
  scanf("%d",&N);
  std::vector<long long > A(N), B(N);
  bool sign = true;
  long long sum = 0;
  for (int i=0; i<N; i++){
    scanf("%lld",&A[i]);
    if (sign){
      sum += A[i];
    } else {
      sum -= A[i];
    }
    sign = !sign;
  }
  //std::cout << "sum=" << sum << std::endl;
  B[0] = sum;
  for (int i=1; i<N; i++){
    B[i] = A[i-1]*2-B[i-1];
  }
  for (int i=0; i<N; i++){
    printf("%lld ",B[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,a,b;
  cin >> n >> a >> b;
  if(abs(a-b)%2==0) cout << "Alice" << endl;
  else cout << "Borys" << endl;
  return 0;
    

}


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

int n, a, P[200010], ans = 0, len = 0;
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a);
        P[a] = i;
    }
    for(int i = 1; i <= n; i++) {
        if(P[i] > P[i-1]) len++;
        else ans = max(ans, len), len = 1;
    }
    printf("%d", n - max(ans, len));
}


Measured memory_bytes: 1024
n = int(input())
a = [input() for i in range(n)] 
m = int(input())
b = [input() for i in range(m)] 
c = a.count(a[0])
d = b.count(a[0])
ans = c-d
for i in range(n):
  if a.count(a[i]) - b.count(a[i]) > ans:
    ans = a.count(a[i]) - b.count(a[i])
if ans <= 0:
  print('0')
  exit()
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    if(a>0){
        printf("Positive");
        return 0;
    }else if(a<=0 && b>=0){
        printf("Zero");
        return 0;
    }else if((b-a)%2==1){
        printf("Positive");
        return 0;
    }else{
        printf("Negative");
        return 0;
    }
}



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

template <class Abel>
struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0; // to be set

    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) {
        for (int iter = 0; iter < 2; ++iter)
            dat[iter].assign(n + 1, UNITY_SUM);
    }

    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1));
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }

    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }

    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i)
            cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

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

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) { return rights[i] < rights[j]; });

    BIT<int> bit(N + 5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]] + 2, r + 2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i] + 1, lefts[i] + 2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i)
        cout << res[i] << endl;
}

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

const int N = (1e3) + 3;
const int H = (1e4) + 3;
const ll OO = 1e9;
bool done[N][H];
ll memo[N][H];
ll n, h, a[N], b[N];

ll dp(int n, int h) {
  if (h == 0) return 0;
  if (n == 0) return OO;
  ll &ret = memo[n][h];
  if (done[n][h]) return ret;
  done[n][h] = 1;
  return ret = min(b[n - 1] + dp(n, max(0LL, h - a[n - 1])), dp(n - 1, h));
}

int main() { // claudio van
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  cin >> h >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  memset(done, 0, sizeof done);
  cout << dp(n, h) << "\n";
  return 0;
}

Measured memory_bytes: 88960
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>
#define y1 y11
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define NAME ""

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

const ld PI = acos(-1.0);

const int MAXN = 300000;

const ll INF = 2ll * (ll)MAXN * (ll)MAXN;

int a[MAXN], b[MAXN];

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) a[i] = i, b[i] = 1000 * 1000 * 1000 - i;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		for (int j = x; j <= n; j++) b[j] -= n - i;
		for (int j = x + 1; j <= n; j++) a[j] += n - i;
	}
	for (int i = 1; i <= n; i++) cout << a[i] << " ";
	cout << endl;
	for (int i = 1; i <= n; i++) cout << b[i] << " ";
	cout << endl;
	return 0;
}






Measured memory_bytes: 768
N=int(input())
Ls=list(map(int, input().split()))

Ls.sort()
ans=0
for i in range(N-2):
    Li=Ls[i]
    for j in range(i,N-1):
        Lj=Ls[j]
        if Li==Lj:
            continue
        for k in range(j,N):
            Lk=Ls[k]
            if Lj==Lk:
                continue
            if Li+Lj>Lk:
                ans+=1
print(ans)

Measured memory_bytes: 9196
from collections import deque
q=deque([1])
n=int(input())
l=[[] for i in range(n+1)]
for i in range(n-1):
  a,b,c=map(int,input().split())
  c=c%2
  l[a].append([b,c])
  l[b].append([a,c])
inf=10**10
d=[inf for i in range(n+1)]
d[1]=0
def dik(s):
  q=deque([s])
  while q:
    a=q.popleft()
    for i in l[a]:
      index=i[0]
      dis=i[1]
      if d[index]>dis+d[a]:
        d[index]=dis+d[a]
        q.append(index)
dik(1)
for i in range(1,n+1):
  if d[i]%2==0:
    print(0)
  else:
    print(1)

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

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  for (int i=0 ; i<3 ; i++){
    for (int j=0 ; j<3 ; j++)
      cin >> a.at(i).at(j);
  }
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i=0 ; i<n ; i++)
    cin >> b.at(i);
  
  for (int i=0 ; i<n ; i++){
    for (int j=0 ; j<3 ; j++){
      for (int k=0 ; k<3 ; k++){
        if (a.at(j).at(k) == b.at(i))
          a.at(j).at(k) = 0;
      }
    }
  }
  
  int ans = 0;
  for (int i=0 ; i<3 ; i++){
    if (a.at(i).at(0)==a.at(i).at(1) && a.at(i).at(1)==a.at(i).at(2)){
      ans = 1;
      break;
    }
    else if (a.at(0).at(i)==a.at(1).at(i) && a.at(1).at(i)==a.at(2).at(i)){
      ans = 1;
      break;
    }
  }
  if (ans == 0){
    if (a.at(0).at(0)==a.at(1).at(1) && a.at(1).at(1)==a.at(2).at(2))
      ans = 1;
    else if (a.at(0).at(2)==a.at(1).at(1) && a.at(1).at(1)==a.at(2).at(0))
      ans = 1;
  }
  
  if (ans == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3468
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

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

signed main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int ans = a[0];
	rep(i, n) {
		ans = gcd(a[i], ans);
	}
	print(ans);
}

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

int mod = 1000000007;

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

  string s;
  cin >> s;

  map<char,int> m;
  for (int i = 0; i < n; i++) {
    m[s[i]]++;
  }

  ll res = 1;
  for(auto x:m) {
    res = res * (x.second+1) % mod;
  }
  cout << res-1 << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt() % 10;

        String str = new String();
        if(n == 3){
            str = "bon";
        } else if(n == 0 || n == 1 || n == 6 || n == 8){
            str = "pon";
        } else{
            str = "hon";
        }

        System.out.println(str);
        sc.close();
    }
}

Measured memory_bytes: 35756
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(void){
  int n,r;
  cin >> n >> r;
  if(n >= 10){
    cout << r << endl;
  }
  else{
    cout << r + 100*(10-n) << endl;
  }
  return 0;
}


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

int binarysearch(vector<long long> &acc, int x){
    int ok = (int)acc.size();
    int ng = -1;
    int mid;
    while (abs(ok-ng)>1){
        mid = (ok + ng)/2;
        if (acc[mid] >= x) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<long long> a(n);
    for (int i = 0; i<n; i++) cin >> a[i];
    vector<long long> acc(n+1);
    for (int i = 0; i<n+1; i++) acc[i] = 0;
    for (int i = 0; i<n; i++) acc[i+1] = (acc[i] + a[i]) % m;
    sort(acc.begin(), acc.end());
    long long ans = 0;
    for (int i = 0; i<n+1; i++){
        ans += binarysearch(acc, acc[i]+1) - binarysearch(acc, acc[i]);
        ans--;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
long long int a, b, g, l, t, x, y;
while((scanf("%lld %lld", &a, &b))!=EOF){
x=a;
y=b;
if(a==0) g=b;
else if(b==0) g=b;
else{
while(b!=0){
t=b;
b=a%b;
a=t;
}
g=a;
}
l=(x*y)/g;
printf("%lld %lld\n",g,l);
}
return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <math.h>

using namespace std;

long long int gcd(long long int x, long long int y) {
	if (x < y){
      return gcd(y, x);
    }
	long long int r;
	while (r = x % y) {
		x = y;
		y = r;
	}
	return y;
}

int main(void){
  long long int n,i,j;
  cin >> n;
  long long int a[n];
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  long long int maxGcd = 1;
  long long int dtmp, d[n], di[n];
  
  d[0]= a[0];
  di[0] = a[n-1];
  for(i=1;i<n;i++){
    d[i] = gcd(d[i-1], a[i]);
    di[i] = gcd(di[i-1], a[n-i-1]);
  }

  maxGcd = max(d[n-2] , di[n-2]);
  for(i=1;i<n-1;i++){
    dtmp = gcd(d[i-1],di[n-2-i]);
    if(dtmp>maxGcd) maxGcd=dtmp;
  }  
  cout << maxGcd << endl;
  return 0;
}


Measured memory_bytes: 2560
# coding: utf-8

N = int(input())
A = list(map(int, input().split()))

count = 0
imp = 0

while True:
    for i in range(0, N):
        if int(A[i]) % 2 == 1:
            imp = 1
            break

    if imp == 1:
        break

    for i in range(0, N):
        A[i] = int(A[i] / 2)
    count += 1

print(count)

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

int main(){
    int N;cin >> N;
    int ans = 1;
    rep(i,3){
        ans *= N;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

  int answer = numeric_limits<int>::max();
  for (int P = 0; P <= 100; P++) {
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += (X[i] - P) * (X[i] - P);
    }
    answer = min(answer, sum);
  }
  cout << answer << endl;

  return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(6 <= a && a <= 12){
        cout << b / 2 << endl;
    }else if(a <= 5){
        cout << 0 << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	long long int N;
	cin >> N;
	vector<vector<long long int>>D( 2, vector<long long int>( N ) );
	for( size_t i = 0; i < N; i++ ) {
		cin >> D[0][i] >> D[1][i];
	}
	long long int ans = 0;
	for( int i = N - 1; i >= 0; i-- ) {
		long long int j = (D[0][i]+ans-1)/D[1][i];
		while( D[0][i] + ans > D[1][i] * j ) {
			j++;
		}
		D[1][i] *= j;
		ans = D[1][i] - D[0][i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
s = input()
q = int(input())
que = [list(map(str, list(input().split()))) for i in range(q)]

hanten = 0
left = ""
right = ""
for i in range(q):
    if que[i][0] == "1":
        if hanten == 0:
            hanten = 1
        else:
            hanten = 0
    elif que[i][0] == "2":
        if hanten == 0:
            if que[i][1] == "2":
                sub = [right, que[i][2]]
                right = ''.join(sub)
            elif que[i][1] == "1":
                sub = [que[i][2], left]
                left = ''.join(sub)
        else:
            if que[i][1] == "2":
                sub = [que[i][2],left]
                left = ''.join(sub)
            elif que[i][1] == "1":
                sub = [right,que[i][2]]
                right = ''.join(sub)

sub = [left, s, right]
s = ''.join(sub)
if hanten == 1:
    s = s[::-1]
print(s)

Measured memory_bytes: 41452
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i,n=5;
		for(i=1;i<=n; i++)
		{
		    int x = sc.nextInt();
		    if(x == 0)
		    {
		        System.out.println(i);
		        break;
		    }
		}
	}
}


Measured memory_bytes: 35752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, d, f, x = 0, y = 0;
    double e = 0, w = 0;
    cin >> a >> b >> c >> d >> e >> f;
    for (int i = 0; i <= 30; i++) for (int j = 0; j <= 30; j++) if (i * a * 100 + j * b * 100 <= f) {
        int g = i * a * 100 + j * b * 100;
        if (!i && !j) continue;
        for (int k = 0; k <= 3000; k++) for (int l = 0; l <= 3000; l++) if (g + k * c + l * d <= f) {
            int h = k * c + l * d;
            //cout << g << ' ' << h << '\n';
            if (100 * h <= e * g) {
                //cout << g << ' ' << h << '\n';
                if (1.0 * h / g > w) {
                    w = 1.0 * h / g;
                    x = g + h;
                    y = h;
                }
            }
        }
    }
    if (!x) x = a * 100;
    cout << x << ' ' << y << '\n';
}


Measured memory_bytes: 384
import sys
import math
from collections import Counter
import itertools
import fractions
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

A,B,H,M=MI()



kakuM = M*6
kakuH = (H+M/60)*30 - kakuM


ans = A**2 + B**2 - 2 * A * B * math.cos(math.radians(kakuH))

print(Decimal(ans).sqrt())


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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  ll a[n], xors = 0;
  REP(i, n) {
      cin >> a[i];
      xors ^= a[i];
  }

  vector<ll> v;
  for (ll i = 0; i < n; i += 2) {
    xors ^= a[i] ^a[i + 1];
    v.push_back(a[i + 1] ^ xors);
    v.push_back(a[i] ^ xors);
    xors ^= a[i] ^ a[i + 1];
  }
 
  REP(i, v.size()) {
      if (i) cout << " ";
      cout << v[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 6856
while True:
    a, op, b = [i for i in input().split()]
    if op == "?":
        break
    elif op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "/":
        print(int(a) // int(b))


Measured memory_bytes: 5604
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,a[N];

int main() {
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+n+1); int cnt=0;
	for (int i=2;i<=n;++i) if (a[i]==a[i-1]) ++cnt;
	if (cnt&1) ++cnt;
	printf("%d\n",n-cnt);
	return 0;
}

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

using namespace std;

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

    int sum = 700;

    for(int i=0;i<3;i++)
    {
        if(str[i]=='o')
            sum = sum + 100;


    }

    printf("%d",sum);

   return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map { it.toLong() }
    var result = 0L
    if (A % 2 == 0L) {
        for (i in 0 until ((B - A + 1) % 4)) {
            if (i == 0L) result = B else result = result xor (B - i)
        }
        println(result)
        return
    } else {
        for (i in 0 until ((B - A) % 4)){
            if (i == 0L) result = B else result = result xor (B - i)
        }
        println(result xor A)
        return
    }
}

Measured memory_bytes: 37864
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {


	int N;
	scanf("%d", &N);

	if (N % 10 == 9 || N / 10 == 9) {
		printf("Yes");
	}
	else {
		printf("No");
	}

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    bool flag=false;
    cin >> n;
    rep(i,n) {
        char c;
        cin >> c;
        if(c=='Y') flag=true;
    }
    if(flag) cout << "Four" << endl;
    else cout << "Three" <<endl;
    return 0;

}


Measured memory_bytes: 256
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        String S = in.next();
        int ans = 0;
        for(int i = 0; i+3 <= N; i++){
            if(S.substring(i, i+3).equals("ABC")){
                ans++;
            }
        }
        println(ans);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 23252
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
using namespace std;
static inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int pow(long x, int n, long m){
    long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x, ret %= m;
        x *= x, x %= m;
        n >>= 1; 
    }
    return ret % m;
}

int euler_phi(int n) {
   int ret = n;
   for(int i = 2; i * i <= n; ++i){
       if(n % i == 0) {
           ret -= ret / i;
           while(n % i == 0) n /= i;
       }
   }
   if(n > 1) ret -= ret / n;
   return ret;
}

int main()
{
    int K = 0, c = getchar();
    while(c > 47 && c < 58){
        K = K * 10 + c - 48;
        c = getchar();
    }

    K /= gcd(K, 7);
    K *= 9;

    if(gcd(K, 10) != 1) {
        printf("%d\n", -1);
        return 0;
    }

    int res = euler_phi(K);

    int ans = 1000000;
    for(int i = 1; i * i <= res; ++i){
        if(res % i == 0) {
            if(pow(10, i, K) == 1){
                printf("%d\n", i);
                return 0;
            }
            int tmp = res / i;
            if(pow(10, tmp, K) == 1) if(tmp < ans) ans = tmp;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}

int main(){
  map<char, int> mp;
  string s;
  while(cin>>s){
    REP(i,s.size()){
      char c = s[i];
      if(c>='A' && c<='Z'){ c += ('a'-'A'); ++mp[c];}
      else if(c>='a' && c<='z'){++mp[c];}
    }
  }
  for(char c='a';c<='z';++c){
    printf("%c : %d\n",c,mp[c]);
  }
}


Measured memory_bytes: 3260
#[allow(unused_imports)]
use std::cmp;
use std::collections::BTreeSet;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let ab = sc.read_pairs::<usize>(n);

    let mut a = ab.iter().map(|x| x.0).collect::<Vec<usize>>();
    let mut b = ab.iter().map(|x| x.1).collect::<Vec<usize>>();

    a.sort();
    b.sort();

    if n % 2 == 0 {
        let min = a[n / 2 - 1] + a[n / 2];
        let max = b[n / 2 - 1] + b[n / 2];
        let ans = max - min + 1;
        println!("{}", ans);
    } else {
        let min = a[n / 2];
        let max = b[n / 2];
        let ans = max - min + 1;
        println!("{}", ans);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 7916
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const ll mod = 100000000009909;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
string s; 
vpll v1, v2, tmp;
map<pll, ll> m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s;
  v1.pb(pll(0, 0));
  FOR(i, 0, n){
    int a = (s[i] - 'a') + 1;
    tmp.clear();
    each(itr, v1){
      tmp.pb(pll((itr->fi * 27 + a) % mod, itr->se));
      tmp.pb(pll(itr->fi, (itr->se * 27 + a) % mod));
    }
    swap(v1, tmp);
  }
  v2.pb(pll(0, 0));
  FORR(i, n*2-1, n){
    int a = (s[i] - 'a') + 1;
    tmp.clear();
    each(itr, v2){
      tmp.pb(pll((itr->fi * 27 + a) % mod, itr->se));
      tmp.pb(pll(itr->fi, (itr->se * 27 + a) % mod));
    }
    swap(v2, tmp);
  }
  ll ans = 0;
  each(itr, v1) m[*itr] += 1;
  each(itr, v2) ans += m[*itr];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 43296
#include<stdio.h>
int f[3], i;
char S[3][101];
int main(){
  scanf("%s%s%s", S[0], S[1], S[2]);
  i=0;
  while(S[i][f[i]]!=0){
    i=S[i][f[i]++]-'a';
  }
  putchar(i+'A');
  putchar(10);
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ll longlongint
using namespace std;
int main(){
     SPEED;
     int a,b;
     cin>>a>>b;
     string s="Odd";
     if(a*b%2==0)s="Even";
     cout<<s;
     ed;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int sum = 1;
    int i = 0;
    while(sum < b){
      sum--;
      sum+=a;
      i++;
    }
    System.out.println(i);
  }
}

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

int main() {
  int N,i,j;
  cin>>N;
  vector<int> A(N), C(1e6+1,0);
  vector<bool> B(1e6+1, true);
  for (i=0;i<N;i++) cin>>A[i];
  sort(A.begin(), A.end());
  for (i=0;i<N;i++) {
    C[A[i]]++;
    if (B[A[i]] && C[A[i]]<=1) {
      for (j=2;A[i]*j<1e6+1;j++) {
        B[A[i]*j]=false;
      }
    }
  }
  int ans=0;
  for (i=0;i<N;i++) {
    if (C[A[i]]==1 && B[A[i]]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7556