akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
using namespace std;

#define N 1000
#define EPS 1e-9


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin >> n;
	if (n % N > 0)
		cout << (N - n % N) << '\n';
	else
		cout << 0 << '\n';

}

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

int main(){
  int N, K;
  cin >> N >> K;
  
  int a = N;
  int b;
  int answer = 0;
  while (a > 0){
    a = (a - (a % K)) / K;
    answer++;
  }
  
  cout << answer << endl;
    
  
  
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int a[N];
	for(int i=0;i<N;i++){
		scanf("%d",a+i);
	}
	int count = 0;
	
	for(int i=0 ; i<N-1 ; i++){
		if(a[i] == a[i+1]){
			if(a[i+2]==a[i+1]){
				a[i+1] = a[i+1]-1;
			}
			count++;
		}
	}
	if(a[N-1]==a[N]){
		count++;
	}
	printf("%d",count);
	return 0;
}

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

#define int long long

#define mod (int)1000000007
#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trrep(i, n) for(int i = (n); i >= 0; i--)
#define For(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)
#define trfor(i, s, t) for(int i = (t); i >= (s); i--)

bool d[10];

bool check(int n) {
  while(n > 0) {
    if(d[n % 10]) {
      return false;
    }
    n /= 10;
  }
  return true;
}

signed main() {
  int n, k;
  cin >> n >> k;
  rep(i, 10) {
    d[i] = false;
  }
  rep(i, k) {
    int w;
    cin >> w;
    d[w] = true;
  }
  while(1) {
    if(check(n)) {
      cout << n << endl;
      break;
    }
    n++;
  }
}


Measured memory_bytes: 256
// AOJ1127
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る

struct za{double x,y,z,r;};
struct edge{double x,y,cost;};
struct unionfind{
    vector<int> par;
    void init(int n){
        par.assign(n,-1);
    }
    int find(int x){
        if(par[x]<=-1) return x;
        par[x]=find(par[x]);
        return par[x];
    }
    int size(int x){
        return -1*par[find(x)];
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(size(x)<size(y)) swap(x,y);
        par[x]+=par[y];
        par[y]=x;
    }
    bool same_set(int x,int y){
        return find(x)==find(y);
    }
};
bool comp(edge a,edge b){
    return a.cost<b.cost;
}
double sq(double a){
    return a*a;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(3);

    while(true){
        int n;
        cin>>n;
        if(n==0) break;
        vector<za> ten(n);
        rep(i,n){
            za now;
            cin>>now.x>>now.y>>now.z>>now.r;
            ten[i]=now;
        }
        unionfind uf;
        uf.init(n);
        vector<edge> hen;
        for(int i=0;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                double center_dis=sqrt(sq(ten[i].x-ten[j].x)+sq(ten[i].y-ten[j].y)+sq(ten[i].z-ten[j].z));
                if(center_dis<=ten[i].r+ten[j].r){
                    uf.unite(i,j);
                }else{
                    edge aa;
                    aa.x=i,aa.y=j,aa.cost=center_dis-(ten[i].r+ten[j].r);
                    hen.e_b(aa);
                }
            }
        }
        sort(all(hen),comp);
        double total=0;
        rep(i,sz(hen)){
            edge cur=hen[i];
            if(!uf.same_set(cur.x,cur.y)){
                uf.unite(cur.x,cur.y);
                total+=cur.cost;
            }
        }
        cout<<total<<endl;
    }
    return 0;
}


Measured memory_bytes: 3364
import sys
input=sys.stdin.readline
N = int(input())

#(方針)同じ数でペアを作りまくる → 残りで隣の数とペアを作れるか
#→ この方針はダメ
#(ダメな例) 
#1 3
#2 4
#3 5
#上の方針) ans = 1+2+2 = 5
#正答) ans = 6 ((1,1)×1,(1,2)×1,(2,2)×1,(2,3)×1,(3,3)×2)

#(方針)枚数0が来たら (それまでのカードの枚数の和//2)ペア　作れる
ans = 0
sum_a = 0
for i in range(N):
  a = int(input())
  sum_a += a
  if(a == 0):
   ans += sum_a//2
   sum_a = 0
ans += sum_a//2
print(ans)

Measured memory_bytes: 3064
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(L);
	READV(R);
	ll ch=(R/2019)-((L-1)/2019);
	if (ch>0)
	{
		cout<<0<<endl;
	}
	else
	{
		ll ans=inf;
		FORI(i,L,R)
		{
			FORI(j,i+1,R+1)
			{
				ans=min(ans,(ll)((i%2019)*(j%2019))%2019);
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<ll>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
const ll INF = (ll)1e9;

int main(){

    ll q=0;
    cin >> q;
    auto l = v<ll>(q,0);
    auto r = v<ll>(q,0);
    rep(i,q) cin >> l[i] >> r[i];

    auto so = v<ll>();
    auto so2 = v<ll>();
    so.push_back(2);
    for(ll i=3;i<=1e5;i+=2){
        bool flag = true;
        for(auto j:so){
            if(i%j==0) {
                flag = false;
                break;
            }
        }
        if(flag) so.push_back(i);
    }

    for(auto i:so) {
        so2.push_back(i);
        so2.push_back(i*2);
    }
    so.clear();
    sort(so2.begin(),so2.end());
    auto kai = v<p<>>();
    rep(i,so2.size()-1){
         if(so2[i]%2==0||so2[i]+1!=so2[i+1]||so2[i+1]%2==1) continue;
         kai.push_back(make_pair(so2[i],so2[i+1]));
    }
    
    rep(i,q){
        ll ans = 0;
        ll be = lower_bound(kai.begin(),kai.end(),make_pair(l[i],(ll)0))-kai.begin();
        ll en = upper_bound(kai.begin(),kai.end(),make_pair(r[i],(ll)INF))-kai.begin();
        cout<<en-be<< endl;
    }

    return 0;
}

Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin>>N>>D;
  if(N%(2*D+1)==0){
    cout<<N/(2*D+1)<<endl;
  }
  else{
    cout<<1+N/(2*D+1)<<endl;
  }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Cand[200];

int main(){
  ll X; cin >> X;
  for (ll i = 0; i < 200; i++) Cand[i] = pow(i, 5);
  
  for (int i = 0; i < 200; i++){
    for (int j = 0; j <= i; j++){
      if (Cand[i] - Cand[j] == X){
        printf("%d %d\n", i, j); return 0;
      }
      if (Cand[i] + Cand[j] == X){
        printf("%d %d\n", i, -1 * j); return 0;
      }
    }
  }
  
  return 0;
}


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

#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

/* Hola */

int main(){
  FIN;
  string pal;
  cin >> pal;
  long long ans=0, cont=0;
  for(long i=0; i<pal.size(); i++)
  {
    if(pal[i]=='B') cont++;
    if(pal[i]=='W') ans+=cont;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	char a, b, c, d;
	cin >> a >> b >> c >> d;
	a -= '0';
	b -= '0';
	c -= '0';
	d -= '0';
	string op = "+++";
	auto rec = [&a, &b, &c, &d, &op](auto rec, int l, int p) -> string {
		string ret;
		if(l == 3){
			if(p == 7){
				ret += (char)(a + '0');
				ret += op[0];
				ret += (char)(b + '0');
				ret += op[1];
				ret += (char)(c + '0');
				ret += op[2];
				ret += (char)(d + '0');
				ret += "=7";
			}
			return ret;
		}
		int q = (l == 0 ? b : l == 1 ? c : d);
		op[l] = '+';
		ret = rec(rec, l + 1, p + q);
		if(!ret.empty()) return ret;
		op[l] = '-';
		return rec(rec, l + 1, p - q);
	};
	cout << rec(rec, 0, a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
int s1[100010],s2[100010];
cin>>s;
int len1=0,len2=0;
s1[0]=1;
for(int i=1;i<s.size();i++)
   s1[i]=1-s1[i-1];
for(int i=1;i<s.size();i++)
   s2[i]=1-s2[i-1];   
for(int i=0;i<s.size();i++)
   {if((s[i]-'0')!=s1[i])len1++;
  if((s[i]-'0')!=s2[i])len2++;
   }
  cout<<min(len1,len2);
	return 0;
}


Measured memory_bytes: 1280
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

int main()
{
    int N;
    cin >> N;
    REP(i, 1, 10)REP(j, 1, 10)if (i*j == N) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
s = list(map(int, input()))

def zo(a):
  if a==1:
    b=0
  else:
    b=1
  return b

vol = len(s)
klist = s
glist = s
nk = 1
ng = 0
k=0
g=0

for i in range(vol):
  if klist[i]!=nk:
    k=k+1
  if glist[i]!=ng:
    g=g+1
  nk = zo(nk)
  ng = zo(ng)

if k>=g:
  print(g)
else:
  print(k)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int sum(int x,int y,int z){ return x+y+z;}
int main(){
   int n,i,res=0;
   int a[21];
   cin>>n;
   for(i=0;i<n;i++) cin>>a[i];
   for(i=0;i<n-2;i++) if(a[i+1]==(sum(a[i],a[i+1],a[i+2])-min(a[i],min(a[i+1],a[i+2]))-max(a[i],max(a[i+1],a[i+2])))) res++;
   cout<<res;
   return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    int min_diff = 1410065407;
    for (size_t t = 0; t < n; t++)
    {
        int sum_a = 0;
        for (size_t i = 0; i < t; i++)
        {
            sum_a+=a[i];
        }
        int sum_b = 0;
        for (size_t i = t; i < n; i++)
        {
            sum_b+=a[i];
        }
        if(min_diff > abs(sum_b-sum_a)) min_diff = abs(sum_b-sum_a);
    }

    cout << min_diff << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x = 1;
    int y = 1;
    while(1){
        scanf("%d %d",&x,&y);
        if(x == 0 && y == 0) break;
        if(x<y){
            printf("%d %d\n",x,y);
        }else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
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; }

int main(void){
  int N;
  cin >> N;
  
  vector<string> S(N);
  set<string> sort;
  for(int i = 0; i < N; i++){
    cin >> S.at(i);
    sort.insert(S.at(i));
  }
  cout << sort.size() << endl;
}

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

using namespace std ; 


const int N = 1e5 + 7 ; 

int n; 

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ; 
        //freopen("in.in" , "r" , stdin) ; 
        int x = 1 ; 
        for(int i =1 ;i <=5;i++){
                int t ; cin >> t; 
                if(t == 0 ){
                        x = i ; 
                }
        }
        cout<< x ; 
        return 0 ; 
}

Measured memory_bytes: 3640
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int dfs(int x, int y, int z) {
    if (x == a && y == b && z == c) return 1;
    
    int ans = 0;
    if (x != a) ans += dfs(x + 1, y, z);
    if (x >= y + 1/* && y != b*/) ans += dfs(x, y + 1, z);
    if (y >= z + 1/* && z != c*/) ans += dfs(x, y, z + 1); 

    return ans;
}

uint64_t gcd_impl( uint64_t n, uint64_t m ) {
        for( int i = 0; i < 10; ++i ) {
                uint64_t t = n - m;
                bool q = m > t;
                n = q ? m : t;
                m = q ? t : m;
                if( m == 0 ) { return n; }
        }
        return gcd_impl( m, n % m );
}

uint64_t gcd( uint64_t n, uint64_t m ) {
        return n > m ? gcd_impl( n, m ) : gcd_impl( m, n );
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;

    vector<int> aa(200000, 0);

    rep (i, 0, n - 1) {
        cin >> b;
        aa[b - 1]++;
    }

    rep (i, 0, n) {
        cout << aa[i] << endl;
    }


    return 0;
}



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

int h[100010];

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

    int n;
    cin>>n;

    for(int i=n-1;i>=0;i--)cin>>h[i];

    bool ans=true;

    for(int i=1;i<n;i++)
    {
        if(h[i]-h[i-1]==1)h[i]--;
        else if(h[i]-h[i-1]>1)
        {
            ans=false;
            break;
        }
    }

    puts(ans?"Yes":"No");

    return 0;
}


Measured memory_bytes: 3976
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

template<typename T>
vector <T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N, K;
    cin >> N >> K;
    cout << N - (K - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::vector<int> a(3);
	for(int i = 0; i < 3; i++) scanf("%d", &a[i]);
	sort(begin(a), end(a)); a.erase(unique(begin(a), end(a)), end(a));
	
	printf("%d\n", a.size());
	return 0;
}


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

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

  replace(S.begin(), S.end(), '?', 'D');
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(void){
  ll k;
  cin >> k;

  ll m=0;
  ll a=1;
  int i=1;

  while (i<=k){
    m+=(7*a);
    m%=k;
    if (m==0) {
      cout << i << endl;
	  return 0;
    }
    a*=10;
    a%=k;
    i++;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(){
    int i;
    
    int n;
    scanf("%d\n",&n);
    
    int a[n];
    for(i=0;i<n;i++)scanf("%d ",&a[i]);
    
    int q;
    scanf("%d\n",&q);
    
    int c;
    int b,e,k;
    while(q--){
        scanf("%d %d %d\n",&b,&e,&k);
        c=0;
        for(i=b;i<e;i++)if(a[i]==k)c++;
        printf("%d\n",c);
    }
    
    
    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, m;
string s[111];
int c[26];
void solve(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> s[i];
		for(int j = 0; j < m; j++){
			c[s[i][j]-'a']++;
		}
	}
	
	bool ok = 1;
	int cnt = 0;
	for(int i = 0; i < 26; i++){
		if(c[i] & 1) cnt++;
	}
	if(cnt > 1 || (cnt == 1 && n*m%2==0)) ok = 0;
	cnt = 0;
	for(int i = 0; i < 26; i++){
		if(c[i] % 4 == 2) cnt++;
	}
	if(n&1) cnt -= m/2;
	if(m&1) cnt -= n/2;
	if(cnt > 0) ok = 0;
	
	cout << (ok ? "Yes" : "No") << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int32_t main() {
	FIO;

	int n , k ;
	cin >> n >> k;

	if (n % k == 0) {
		cout << 0;
	}
	else {
		cout << 1;
	}


	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
 
public class Main {
 
	
    public static void main(String[] args){
    	double PI = 3.141592653589;
    	Scanner sc = new Scanner(System.in);
    	double r = sc.nextDouble();
    	double f = (double)r*(double)r*(double)PI;
    	double l = 2*(double)PI*(double)r;
    	System.out.println(String.format("%.6f", f)+" "+String.format("%.6f", l));

    }
}

Measured memory_bytes: 28460
#include<stdio.h>
int main(void)
{	
	char s[4];
	int x;
	scanf("%s",s);
	x=700;
	if(s[0]=='o'){
		x=x+100;
	}
	if(s[1]=='o'){
		x=x+100;
	}
	if(s[2]=='o'){
		x=x+100;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    ll x,k,d,point;
    in(x,k,d);
    //0付近に近づく前にkが尽きてしまうパターン
    if((double)abs(x)/k>=d){
        out(abs(x)-k*d);
    }else{
        if(d>=2)point=x%d;
        else if(d==1)point=0;
        //pointが負の場合もある
        if(point<0)point+=d;
        k-=abs(x-point)/d;
        cout<<(k%2==0?point:abs(point-d))<<endl;
    }
}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

bool sorted[200010];

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

    int res = 0;
    
    int cnt = 0;
    for (int i=0; i<N; ++i) {
        if (i == 0 || P[i-1] < P[i]) cnt ++;
        else cnt = 1;
        if (K <= cnt) {
            sorted[i-K+1] = true;
            res = 1;
        };
    }

    set<int> st;
    for (int i=0; i<K; ++i) {
        st.insert(P[i]);
    }

    if ( ! sorted[0]) res ++;
    for (int i=1; i+K-1<N; ++i) {
        if (i > 1) st.erase(P[i-2]);
        st.insert(P[i+K-1]);

        if (sorted[i]) continue;
        if (P[i-1] == *st.begin() && P[i+K-1] == *st.rbegin()) continue;
        res ++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>

int main(void) {
	// in
	int n;
	std::cin >> n;
	std::vector<int> x(n), xx(n);
	for(int i = 0; i < n; ++i) {
		std::cin >> x[i];
		xx[i] = x[i];
	}

	// sort
	std::sort(xx.begin(), xx.end());

	int med_x = xx[(n+1)/2];

	if(n % 2 == 0) {
		for(int i = 0; i < n; ++i) {
			if(x[i] < med_x) std::cout << med_x << std::endl;
			else std::cout << xx[(n+1)/2-1] << std::endl;
		}
	}
	else {
		for(int i = 0; i < n; ++i) {
			if(x[i] <= med_x) std::cout << xx[(n+1)/2+1] << std::endl;
			else std::cout << med_x << std::endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int j = 0; j < M; j++) {
    cin >> B[j];
  }
  // cout<<"ok20"<<endl;
  for (int i = 0; i <= N - M; i++) {
    // cout<<"ok"<<endl;
    for (int j = 0; j <= N - M; j++) {
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (A[i + k][j + l] != B[k][l]) goto label;
          if (k == M - 1 && l == M - 1) {
            cout << "Yes" << endl;
            return 0;
          }
        }
      }
    label:
      if (0) {
      };
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  string s1,s2;
  int t=0,h=0;
  
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    if(s1.compare(s2)==0) {
      t++;h++;
    }else if(s1.compare(s2)>0) t+=3;
    else h+=3;
  }
  cout << t << " " << h << endl;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n; cin >> n;
  double res = 0;
  for(int i=0;i<n;i++) {
    double x; cin >> x;
    res += 1/x;
  }
  cout << setprecision(10) << 1/res;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a,b,c,d,e,f,n;
  while(cin>>n&&n){
    a=b=c=d=e=f=0;
    for(i=0;i<n;i++){
      int t,u,v;
      scanf("%d:%d%d",&t,&u,&v);
      if(0){
      }else if(11*60<=t*60+u&&t*60+u<=14*60+59){
	a++;
	if(u>v){
	  if(u-v>=52)
	    b++;
	}else if(v-u<=8){
	  b++;
	}
      }else if(18*60<=t*60+u&&t*60+u<=20*60+59){
	c++;
	if(u>v){
	  if(u-v>=52)
	    d++;
	}else if(v-u<=8){
	  d++;
	}
      }else if(21*60<=t*60+u&&t*60+u<=24*60){
	e++;
	if(u>v){
	  if(u-v>=52)
	    f++;
	}else if(v-u<=8){
	  f++;
	}
      }else if(0<=t*60+u&&t*60+u<=1*60+59){
	e++;
	if(u>v){
	  if(u-v>=52)
	    f++;
	}else if(v-u<=8){
	  f++;
	}
      }
    }
    if(a)
      cout<<"lunch "<<100*b/a<<endl;
    else
      cout<<"lunch no guest"<<endl;
    if(c)
      cout<<"dinner "<<100*d/c<<endl;
    else
      cout<<"dinner no guest"<<endl;
    if(e)
      cout<<"midnight "<<100*f/e<<endl;
    else
      cout<<"midnight no guest"<<endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    m1 += h1 * 60;
    m2 += h2 * 60;
    cout << (m2 - m1 - k) << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

const int N = 1e5 + 101;

int n, m, a, b;
bool odw[N];
int h[N];
vector <int> g[N];
vector <pair<int, int>> res;

bool dfs(int v, int p) {
	h[v] = h[p] + 1;
	odw[v] = true;
	int deg = 0;
	for (auto it : g[v]) {
		if (odw[it]) {
			if (it != p && h[it] < h[v]) {
				deg++;
				res.pb({v, it});
			}
			continue;
		}
		if (it != p) {
			if (dfs(it, v)) {
				res.pb({v, it});
				deg++;
			}
		}
	}
	if (deg % 2) {
		res.pb({v, p});
		deg++;
		return false;
	}
	return true;
}
			

int main() {
	scanf ("%d%d", &n, &m);
	rep(i, 1, m) {
		scanf ("%d%d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	if (m % 2) {
		printf ("-1\n");
		return 0;
	}
	dfs(1, 0);
	assert(ss(res) == m);
	for (auto it : res)
		printf ("%d %d\n", it.fi, it.se);
	
	return 0;
}	


Measured memory_bytes: 19532
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  while(cin>>n>>m,n+m){
    vector<pair<ll,pair<ll,ll>>>pll(m);
    for(int i=0;i<m;i++){
      ll t,f,to;
      cin>>t>>f>>to;
      pll[i]=(mp(t,mp(f-1,to-1)));
    }
    sort(ALL(pll));
    vector<bool> virus(n,false);
    virus[0] = true;
    for(int i=0;i<m;i++){
      ll f = pll[i].S.F;
      ll t = pll[i].S.S;
      if(virus[f])virus[t] = true;
    }
    ll ans=0;
    for(auto a:virus)ans+=a;
    cout<<ans<<endl;
  }
  return 0;
}



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

int main(void){
	int a,b,d,r;
	double f;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	f=a/(double)b;
	cout<<d<<" "<<r;
	printf(" %lf\n",f);
	return 0;
}
	


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if (fabs(a - b) <= d && fabs(b - c) <= d || fabs(a - c) <= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

void solv()
{
	int r; scanf("%d", &r);
	printf("%d", r*r);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#define ll long long
using namespace std;

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


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	int a=0;
	for(int i=1;i<n;i++)a+=s[i]!=s[i-1];
	cout<<a<<endl;
}

Measured memory_bytes: 512
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    N = I()
    A = LI()
    Q = I()
    B = [0] * Q
    C = [0] * Q
    cnt = defaultdict(int)

    for i in range(Q):
        B[i], C[i] = MI()


    for a in A:
        cnt[a] += 1

    ans = sum(A)

    for i in range(Q):
        b_cnt = cnt[B[i]]
        c_cnt = cnt[C[i]]

        # print(ans, b_cnt * B[i])

        ans -= b_cnt * B[i]
        ans += b_cnt * C[i]

        print(ans)

        cnt[B[i]] = 0
        cnt[C[i]] += b_cnt




if __name__ == '__main__':
    main()


Measured memory_bytes: 91392
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int a[N],b[N],n,k,c[N];
int check(int anv)
{
	for(int i=1;i<=n;i++)c[i]=a[i]%anv;
	sort(c+1,c+n+1);
	int ans=0,sum=0,l=0,r=n+1;
	while(l<r-1)
	{
		if(sum<=0)l++,ans+=c[l],sum+=c[l];else
			r--,sum-=(anv-c[r]);
	}
	return ans;
}
int main()
{
	scanf("%d%d",&n,&k);
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int num=0;
	for(int i=1;i<=sqrt(sum);i++)
		if(sum%i==0)
		{
			b[++num]=i;
			b[++num]=sum/i;
		}
	sort(b+1,b+num+1);
	for(int i=num;i>=1;i--)
		if(check(b[i])<=k)
		{
			printf("%d\n",b[i]);
			break;
		}
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 21;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,t;
    cin >> x >> t;
    if (x <= t) PRINT(0);
    else PRINT(x-t);
}


Measured memory_bytes: 256
/* ex4_1
   kento_titech*/
#include<stdio.h>
int main(void){
    int n,d,num_people;
    scanf("%d %d",&n,&d);
    if(n%(2*d+1)==0){//1人の監視できる最大本数は2d+1本
        num_people=n/(2*d+1);//nが2d+1で割り切れるとき
    }else{
        num_people=n/(2*d+1)+1;//割り切れないときは余りをさらにひとりが監視
    }
    printf("%d\n",num_people);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;
int x,y;
signed main(){
    cin >> x >> y;
    if(abs(x-y) >= 2)cout << "Alice" <<endl;
    else cout << "Brown" <<endl;
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

typedef long long ll;

using namespace std;

int main ()
{
  int N,cnt,cur,p,res;
  char pin[3];
  string S;

  cin >> N;
  cin >> S;

  REPI(3)
    pin[i] = '0';

  cnt = 0;
  res = 0;
  while (cnt < 1000){
    cur = 0;
    p = 0;

    while (p<S.size ())
    {
      if (S[p] == pin[cur])
      {
        if (cur == 2)
        {
          res++;
          break;
        }
        cur++;
      }

      p++;
    }
    
    cur = 0;
    pin[cur]++;
    while (pin[cur] > '9' && cur < 2)
    {
      pin[cur] = '0';
      cur++;
      pin[cur]++;      
    }
    cnt++;
  }
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3676
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
        int t=0,h=0;
        for(int i=0;i<n;i++){
            String[] a=br.readLine().split(" ");
            int s=0;
            int l0=a[0].length();
            int l1=a[1].length();
            if(l0<l1){
            	s=l0;
            }else{
            	s=l1;
            }
            boolean even=false;
    		for(int j=0;j<s;j++){
    			if((int)a[0].charAt(j)>(int)a[1].charAt(j)){
    				t+=3;
    				even=false;
    				break;
    			}else if((int)a[0].charAt(j)<(int)a[1].charAt(j)){
    				h+=3;
    				even=false;
    				break;
    			}else{
    				even=true;
    			}
    		}
    		if(even){
                if(l0>l1){
                	t+=3;
                }else if(l0<l1){
                	h+=3;
                }else{
        			t+=1;
        			h+=1;
                }
    		}
        }
		System.out.println(t+" "+h);
	}
}

Measured memory_bytes: 18360
#include <bits/stdc++.h>
using namespace std;
int h,w,a,b;
int main()
{
	scanf("%d%d%d%d",&h,&w,&a,&b);
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)printf("%d",((i<b)^(j<a)));
		puts("");
	}
	return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  int c = b;
  while(c> 0){
    c = c/10;
    a = a*10;
  }
  int d = a+b;
  if((int)sqrt(d)*(int)sqrt(d)==d){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

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

            var ans = B[0];
            for (int i = 0; i < B.Length - 1; i++)
            {
                ans += Math.Min(B[i], B[i + 1]);
            }
            ans += B.Last();

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
def main():
    N,M,X=map(int, input().split())
    A=[list(map(int, input().split())) for _ in range(N)]
    ans=10**10
    for i in range(2**N):
        b=i+2**N
        c=0
        l=[0]*M
        ok=True
        for j in range(N):
            if b>>j&1 == 1:
                c+=A[j][0]
                for k in range(M):
                    l[k]+=A[j][k+1]
        for x in l:
            if x < X: ok = False 
        if ok:
            ans = min(ans, c)
    if ans==10**10: print('-1')
    else: print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 9236
# Union Find 木
from sys import setrecursionlimit


def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j


setrecursionlimit(10 ** 6)

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

parent = [-1] * N
for _ in range(M):
    X, Y, Z = map(int, input().split())
    unite(parent, X - 1, Y - 1)
print(len([x for x in parent if x < 0]))


Measured memory_bytes: 11724
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N,K;
    cin>>N>>K;
    vll A(N);
    for (size_t i = 0; i < N; i++)
    {
        cin>>A[i];
    }
/*    if(K==0)
    {
        cout<<*max_element(all(A))<<endl;
        return 0;
    }*/
    auto judge = [&](ll x){
        ll cnt = 0;
        if(x==0)
        {
            return false;
        }
        for (size_t i = 0; i < N; i++)
        {
            cnt += max(0LL,(A[i]-1)/x);
        }
        return (cnt <= K);
    };
    ll ok = INF/2,ng = 0;
    while(abs(ok-ng)>1)
    {
        ll mid = (ok+ng)/2;
        if(judge(mid))
        {
            ok=mid;
        }else
        {
            ng=mid;
        }
        
    }
    cout<<ng+1<<endl;
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll INF = 1e18+1;
int MOD = 1000000007;
main(){
    ll N,tmin = 1,amin = 1;
    cin >> N;
    for(int i = 0;i < N;i++){
        ll t,a,n;
        cin >> t >> a;
        n = max((tmin+t-1)/t,(amin+a-1)/a);
        tmin = n*t;
        amin = n*a;
    }
    cout << tmin+amin << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	string S1,S2,S3;

	cin >> S1 >> S2 >>S3;

	string ans = "A";

	ans += S2[0];
	ans += 'C';

	cout << ans <<endl;

	return 0;
}

Measured memory_bytes: 256
import Data.List

answer lst k = foldl (+) 0 . map length .
  drop k . reverse $
  Data.List.sortOn length (Data.List.group $ Data.List.sort lst)

main = interact $ (++ "\n") . show . readAndAnswer . lines
  where readAndAnswer (x:y:_) = let
          [n, k] = map read $ words x
          in
          answer (map (\x -> read x :: Int) (take n $ words y)) k


Measured memory_bytes: 53500
n = int(input())
d = dict()
for i in range(n):
    s = list(input())
    s.sort()
    s = "".join(s)
    if s not in d.keys():
        d[s] = 1
    else:
        d[s] += 1
count = 0
for i in d.values():
    count += i * (i-1) // 2
print(count)

Measured memory_bytes: 22224
n = int(input())
*A, = map(int, input().split())
ans = 0
for i in range(n):
    j = A[i:].index(min(A[i:])) + i
    A[i], A[j] = A[j], A[i]
    if i != j:
        ans += 1
print(*A)
print(ans)

Measured memory_bytes: 7628