akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  string S; cin >> S;
  string E = "AKIHABARA";

  for (int i = 0; i < E.size(); ++i) {
    if (i > S.size()) {
      break;
    } else if ((i < S.size() and S[i] != E[i]) or (i == S.size())) {
      if (E[i] == 'A') S.insert(i, "A");
    } else if (i < S.size() and S[i] == E[i]) {
      continue;
    }
  }

  if (S != E) cout << "NO" << endl;
  else cout << "YES" << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N,0);
  vector<pair<int,int>> P;
  for(int i=0;i<N;i++){
    cin>>X[i];
  }
  sort(X.begin(),X.end());
  
  for(int i=1;i<N-1;i++){
    if(X[i]>0){
      P.emplace_back(X[0],X[i]);
      X[0]-=X[i];
    }
    else{
      P.emplace_back(X[N-1],X[i]);
      X[N-1]-=X[i];
    }
  }
  
  /*cout<<X[0]-X[N-1]<<endl;
  
  for(int i=0;i<N-2;i++){
    cout<<setprecision(20)<<P[i].first<<" "<<P[i].second<<endl;
  }*/
  
    P.emplace_back(X[N-1],X[0]);
    cout << X[N-1] - X[0] << endl;
    for(auto &e : P){
        cout << e.first << " " << e.second << endl;
    }
  
  return 0;
}

Measured memory_bytes: 4712
import java.util.*;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = Integer.parseInt(sc.next());
    	Integer a[] = new Integer[N];

    	for (int i=0; i<N; i++){
    		a[i] = Integer.parseInt(sc.next());
    	}

    	Arrays.sort(a, Collections.reverseOrder());

    	int ans = 0;

    	for(int i=0; i<N; i++){
    		if (i%2==0){
    			ans += a[i];
    		}else{
    			ans -= a[i];
    		}
    	}

    	System.out.println(ans);
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>

using namespace std;

void sort(vector<int>& count, vector<int>& order)
{
	int size = count.size() - 1;
	for(int i = 0; i < size; ++i)
	{
		for(int j = size; j > i; --j)
		{
			if(count[j] == count[j - 1] && order[j] < order[j - 1])
			{
				int temp = order[j];
				order[j] = order[j - 1];
				order[j - 1] = temp;
			}
			if(count[j] > count[j - 1])
			{
				int temp = count[j];
				count[j] = count[j - 1];
				count[j - 1] = temp;
				temp = order[j];
				order[j] = order[j - 1];
				order[j - 1] = temp;
			}
		}
	}
}

void solve()
{
	int n, m;
	while(cin >> n >> m)
	{
		if(!n && !m)
		{
			break;
		}
		vector<int> order(m);
		for(int i = 0; i < m; ++i)
		{
			order[i] = i + 1;
		}
		vector<int> count(m);
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < m; ++j)
			{
				int temp;
				cin >> temp;
				if(temp)
				{
					count[j]++;
				}
			}
		}
		sort(count, order);
		for(int i = 0; i < m - 1; ++i)
		{
			cout << order[i] << " ";
		}
		cout << order[m - 1] << endl;
	}
}

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

Measured memory_bytes: 904
#include<iostream>
using namespace std;
int main(){
  int N,K;
  int answer=0;
  cin>>N>>K;
  int D[K],R[5]={0};
  for(int i=0;i<K;i++)cin>>D[i];
  for(int ans=N;ans<=10*N;ans++){
    bool flag=true;
    int ans_=ans;
    while(true){
      int part=ans_%10;ans_/=10;
      for(int j=0;j<K;j++){if(part==D[j])flag=false;}
      if(ans_==0)break;
    }
    if(flag){answer=ans;break;}
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
  int n;
  char s[100001][5];
  int i;
  int a[4];
  for(i=0;i<4;i++){
    a[i]=0;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s[i]);
    if(strcmp(s[i],"AC")==0) a[0]++;
    else if(strcmp(s[i],"WA")==0) a[1]++;
    else if(strcmp(s[i],"TLE")==0) a[2]++;
    else if(strcmp(s[i],"RE")==0) a[3]++;
  }
  printf("AC x %d\n",a[0]);
  printf("WA x %d\n",a[1]);
  printf("TLE x %d\n",a[2]);
  printf("RE x %d\n",a[3]);
  return 0;
}


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

int main(){
  int H, W, K, ans = 0;
  cin >> H >> W >> K;
  
  vector<char> board(H * W);
  
  for (int i = 0; i < H; i++){
    string C;
    cin >> C;
    
    for (int j = 0; j < W; j++){
      
      board.at(i * W + j) = C.at(j);
        
    }
  }
  
  for (int bit = 0; bit < (1 << H); bit++){
    for (int bit2 = 0; bit2 < (1 << W); bit2++){
      int num = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++){
          //cout << bit2 << endl;
          if (!(bit & (1 << i)) && !(bit2 & (1 << j)) && board.at(i * W + j) == '#'){
            num++;
          }
        }
      }
      
      if (num == K){
        ans++;
      }
      
    }
  }
  
  cout << ans << endl;
}

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

int main() {
    int h,n;

    
cin >> h >> n;
int atk=0;
    vector <int> a(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
        atk+=a[i];
    }

    if(atk >= h)
    cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    



}











//初AC時（リアルタイム参加）のときのコード

/*#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long int h,n;
 
    
cin >> h >> n;
    for (long int i = 0; i < n; i++)
    {long int x;
        cin >> x;
        h-=x;
    }
 
    if(h <=0 )
    cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
 
 
 
}

*/

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if(N % 2 == 0){
      vector<char> S(N/2),T(N/2);
      for(int i=0;i<N;i++){
          if(i<N/2){
              cin >> S[i];
          }else{
              cin >> T[i-N/2];
          }
      }
      if(S==T){
          cout << "Yes" << endl;
      }else{
          cout << "No" << endl;
      }
  }else{
      cout << "No" << endl;
  }
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int A, B, C, X, Y, Z;
	scanf("%d %d %d", &A, &B, &C);
	X = abs(A - B);
	Y = abs(B - C);
	Z = abs(C - A);
	if (X >= Y && X >= Z) printf("%d\n", Y + Z);
	else if (Y >= X && Y >= Z) printf("%d\n", Z + X);
	else printf("%d\n", X + Y);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	forn(i,s.size())
		cout<<'x';
	return 0;
}


Measured memory_bytes: 256
l=[0]+[int(i) for i in input()]
l.reverse()
su=0
for i in range(len(l)):
    if l[i]>5:
        l[i]=10-l[i]
        l[i+1]+=1
    elif l[i]==5 and l[i+1]>4:
        l[i+1]+=1
    su+=l[i]
print(su)

Measured memory_bytes: 116388
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>

using ll = long long;
using std::cout;
using std::cin;

int main(){
    std::string s;
    cin >> s;
    ll ans = 0;
    ll n = s.size();
    std::vector<ll> val(2019,0);
    ll mod = 0;
    ll factor = 1;
    val[0]++;
    for(int i=0; i<n; i++){
        ll num = s[n-1-i] - '0';
        mod = (mod+factor*num) % 2019;
        factor = factor*10%2019;
        val[mod]++;
    }
    for(int i=0; i<2019; i++){
        ll v = val[i];
        ans += v * (v-1) / 2;
    }
    
    cout << ans << std::endl;

    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class a, int N, class T>
void fillArray(a(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, m, q;
vector<int> g[100005];
int v[100005], d[100005], c[100005];
bool used[100005][15];
int color[100005];
void dfs(int pos, int dist, int co) {
    if (used[pos][dist]) return;
    used[pos][dist] = true;
    if (color[pos] == 0) color[pos] = co;
    if (dist == 0) return;
    rep(i, sz(g[pos])) dfs(g[pos][i], dist - 1, co);
}

void solve() {
    cin >> n >> m;
    rep(i, m) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].emplace_back(b); g[b].emplace_back(a);
    }

    cin >> q;
    rep(i, q) {
        cin >> v[i] >> d[i] >> c[i];
        --v[i];
    }

    repd(i, q) dfs(v[i], d[i], c[i]);
    rep(i, n) cout << color[i] << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll M=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % M; }
ll SUB(ll x, ll y) { return (x-y+M) % M; }
ll MUL(ll x, ll y) { return x*y % M; }
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%M!=0); return MUL(x, POW(y, M-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }


int N;


ll _fact[1000001];

void _prepare_fact(){
    _fact[0] = _fact[1] = 1LL;
    for(int i=2; i<=N; ++i) {
        _fact[i] = MUL(_fact[i-1], i);
    }
}

inline ll fact(int x){
    assert(IN(x,0,N));
    return _fact[x];
}


ll sub(int k) {
    // k回以内で
    // a +  b = k - 1
    // a + 2b = N - 2
    int a = k*2 - N;
    if (a < 0) return 0;
    int b = N - k - 1;
    // fprintf(stderr, " // N=%d, k=%d; a=%d, b=%d;; %d %d %d %d %d\n", N,k,a,b, a+b, a,b,k,N-1-k);
    assert(a+b == k-1);
    assert(a+b*2 == N-2);

    return MUL(
            DIV(fact(a+b),
                MUL(fact(a), fact(b))),
            MUL(fact(k), fact(N-1-k))
        );
}

ll solve() {
    ll total = 0;
    ll last = 0;
    for (int k=1; k<=N-1; ++k) {
        ll a = sub(k), x = SUB(a, last);
        total = ADD(total, MUL(x, k));
        // fprintf(stderr, "<=k=%d: %lld ; x=%lld\n", k,a, x);
        last = a;
    }
    return total;
}

int main() {
    cin >> N;
    assert(IN(N,2,1000000));

    _prepare_fact();

    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 8064
#!/usr/bin/env python3
import sys


YES = "yes"  # type: str
NO = "no"  # type: str


def solve(S: str):
    print(YES if len(S) == len(set(S)) else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
#define check(x) if(x >= mod) x -= mod
const int inf=0x3f3f3f3f,mod=998244353;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n,k,pre[305],dp[305][305][305],sum1[305][305][305],sum2[305][305][305],one,zero,cnt[305],pre1[305];
char s[305];
int main()
{
    scanf("%s%d",s+1,&k);
    n = strlen(s+1);
    rep(i,1,n) {pre[i] = pre[i-1] + (s[i] == '1');if(s[i] == '1') cnt[i - pre[i]]++;}
    pre1[0] = cnt[0];
    rep(i,1,n) pre1[i] = pre1[i-1] + cnt[i];
    dp[0][0][0] = 1;
    one = pre[n]; zero = n - pre[n];
    k = min(k, one);
    rep(i,0,zero+1) {
        if(i) rep(j,0,one) rep(k,j,one){
            if(k < pre1[i - 1]) continue;
            int num = cnt[i - 1];
            if(num <= j){
                //rep(l,0,k) {dp[i][j][k] += dp[i-1][j - min(l,num)][k - l];check(dp[i][j][k]);}
                int j1 = j - num, k1 = k - num;
                dp[i][j][k] = sum1[i-1][k1 - j1][j] - (j1 == 0 ? 0 : sum1[i-1][k1 - j1][j1 - 1]);
                dp[i][j][k] = ((ll)dp[i][j][k] % mod + mod) % mod;
                if(k - num > 0) {dp[i][j][k] += sum2[i-1][j1][k - num - 1];check(dp[i][j][k]);}
            }
            else
            {
                //rep(l,0,j) {dp[i][j][k] += dp[i-1][j - l][k - l];check(dp[i][j][k]);}
                dp[i][j][k] = sum1[i-1][k - j][j];
            }
        }
        rep(j,0,one) rep(k,j,one){
            if(i && k < pre1[i - 1]) continue;
            sum1[i][k - j][j] = (j?sum1[i][k - j][j - 1]:0) + dp[i][j][k];
            sum2[i][j][k] = (k?sum2[i][j][k-1]:0) + dp[i][j][k];
            check(sum1[i][k - j][j]);
            check(sum2[i][j][k]);
        }
    }
    int ans = 0;
    rep(i,0,k) {ans += dp[zero+1][one - i][one];check(ans);}
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 86884
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n, = [int(i) for i in readline().split()]
s = input()


r = s.count("R")
w = 0

ans = 1<<30
for i in range(n+1):
    """
    W..WR..R (Wがi個)
    不純なWがw個
    不純なRがr個
    """
    v = max(w,r)
    ans = min(ans,v)
    
    if i!=n:
        if s[i] == "W":
            w += 1
        else:
            r -= 1
    
    #print(r,w)

print(ans)
    
    
    
    

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

public class ABC153_B {
    private static void Main(string[] args) {
        var h = Read1LineAsIntArray()[0];
        var a = Read1LineAsIntArray();

        var answer = (a.Sum() >= h) ? "Yes" : "No";
        Console.WriteLine(answer);
    }
  
    private static int[] Read1LineAsIntArray() => Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray();
}

Measured memory_bytes: 19680
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

LL n;
int ans1[2010],ans2[2010];
int s1,t1,s2,t2,p;

void solve(LL n){
	if (n==1)return;
	if (n&1){
		solve(n/2);
		ans1[++t1]=ans2[++t2]=++p;
	}
	else{
		solve(n-1);
		ans1[--s1]=ans2[++t2]=++p;
	}
}

int main(){
	scanf("%lld",&n);
	s1=t1=s2=t2=1000;
	p=ans1[1000]=ans2[1000]=1;
	solve(n);
	printf("%d\n",p*2);
	fo(i,s1,t1)printf("%d ",ans1[i]);
	fo(i,s2,t2)printf("%d ",ans2[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
  
int main(){
    int a, b;
      
    cin>> a >> b;
      
    if ( a < b ) cout << "a < b" << endl;
    else if ( a > b ) cout << "a > b" << endl;
    else cout << "a == b" << endl;
  
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)
#define all(x) x.begin(), x.end()
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;


int32_t main() {
    int n;
    cin >> n;
    double p[n + 1];
    FOR(i, 1, n + 1) {
        cin >> p[i];
    }
    double d[n + 1][n + 1];
    FOR(i, 0, n + 1) {
        FOR(j, 0, n + 1) {
            d[i][j] = 0;
        }
    }
    d[0][0] = 1;
    FOR(i, 1, n + 1) {
        d[i][0] = d[i - 1][0] * p[i];
        // cout << d[i][0] << " ";
        FOR(j, 1, n + 1) {
            d[i][j] = d[i - 1][j] * p[i] + d[i - 1][j - 1] * (1 - p[i]);
            // cout << d[i][j] << " ";
        }
        // cout << endl;
    }
    double ans = 0;
    FOR(i, 0, (n + 1) / 2) {
        ans += d[n][i];
    }
    cout << fixed << setprecision(10) << ans;
    return 0;
}

Measured memory_bytes: 144420
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    cout << ((n%k==0) ? 0 : 1);;
    cout << endl;
    return 0;
}




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

using namespace std;

int main()
{
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;

  int ans = 1e9;

  // AB買わない
  ans = min(ans, A*X+B*Y);

  // ABだけ買う
  ans = min(ans, max(X, Y)*2*C);

  // ABとA,B買う
  ans = min(ans, X*2*C + max(0, (Y-X))*B);
  ans = min(ans, Y*2*C + max(0, (X-Y))*A);

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
  int N; scanf("%d", &N);
  int K; scanf("%d", &K);
  char S[50] = {};
  int i;
  for(i = 0; i <= N; i++){
    scanf("%c", &S[i]);
    if(i == K){
      if(S[i] == 'A') S[i] = 'a';
      if(S[i] == 'B') S[i] = 'b';
      if(S[i] == 'C') S[i] = 'c';
    }
  }

  printf("%s", S);

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
 
namespace ALDS1_3
{
    class Program
    {
        public struct Process
        {
            public readonly string n;
            public readonly int t;
            public Process(string n, int t)
            {
                this.n = n;
                this.t = t;
            }
        }
 
        static void Main()
        {
            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var b = new Queue<Process>();
               
            for (var i = 0; i < a[0]; i++)
            {
                var c = Console.ReadLine().Split();
                var d = c[0]; var e = int.Parse(c[1]);
                b.Enqueue(new Process(d, e));
            }
 
            var f = 0;
 
            while (b.Count > 0)
            {
               var g = b.Dequeue();
               var k = g.n;
               var v = g.t;
               f += v < a[1] ? v : a[1];
               v -= a[1];
               if (v <= 0)
                   Console.WriteLine("{0} {1}", k, f);
               else
                   b.Enqueue(new Process(k, v));
            }
        }
    }
}

Measured memory_bytes: 15672
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();

    String[] data1 = new String[s.length()];
    String[] data2 = new String[t.length()];

    for (int i = 0; i < s.length(); i++) {
      data1[i] = s.substring(i,i+1);
    }

    for (int i = 0; i < t.length(); i++) {
      data2[i] = t.substring(i,i+1);
    }

    Arrays.sort(data1);
    Arrays.sort(data2);

    String n = data1[0];
    String m = data2[data2.length-1];

    for (int i = 1; i < data1.length; i++) {
      n += data1[i];
    }

    for (int i = data2.length-2; i >= 0; i--) {
      m += data2[i];
    }

    if (n.compareTo(m) < 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 8e5 + 5 ; 
const int P = 200003 ; 
int n, m, R[N], g[N], ord[N], fc[N], f[N], c[N], tt[N], limit, L, num, cnt, ans[N] ; 
void Init( int x ) {
	limit = 1, L = 0 ; 
	while( limit <= x ) limit <<= 1, ++ L ;
	rep( i, 0, limit ) R[i] = ( R[i >> 1] >> 1 ) | ( ( i & 1 ) << ( L - 1 ) ) ;
}
const double Pi = acos( -1.0 ) ;
struct Complex {
	double x, y ; 
	Complex( double xx = 0, double yy = 0 ) { x = xx, y = yy ; }
} F[N], Q[N], C[N], A1[N], A2[N], B1[N], B2[N] ; 
Complex operator * ( Complex x, Complex y ) { return Complex( x.x * y.x - x.y * y.y, x.x * y.y + x.y * y.x ) ; }
Complex operator + ( Complex x, Complex y ) { return Complex( x.x + y.x, x.y + y.y ) ; }
Complex operator - ( Complex x, Complex y ) { return Complex( x.x - y.x, x.y - y.y ) ; }
Complex operator / ( Complex x, double y ) { return Complex(x.x / y, x.y / y ) ; }
void FFT( Complex *a, int type ) {
	for( int i = 0; i < limit; ++ i ) if( R[i] > i ) swap( a[R[i]], a[i] ) ;
	for( int k = 1; k < limit; k <<= 1 ) {
		Complex Dw = Complex( cos( Pi / k ), type * sin( Pi / k ) );	
		for( int i = 0; i < limit; i += ( k << 1 ) ) {
			Complex w = Complex( 1, 0 ) ;
			for( int j = i; j < i + k; ++ j, w = w * Dw ) {
				Complex Ny = w * a[j + k], Nx = a[j] ;
				a[j + k] = Nx - Ny,	a[j] = Nx + Ny ; 
			} 
		}
	}	
	if( type != 1 ) rep( i, 0, limit ) a[i] = a[i] / (double)limit ;
}
signed main()
{
	n = gi() ; 
	rep( i, 1, n ) c[i] = gi() ; 
	int gg = 2, ff = 1 ; cnt = 400 ; 
	for( re int i = 0; i < P - 1; ++ i ) {
		ord[ff] = i, fc[i] = ff, ff = ff * 2 % P ; 
	}
	int Ans = 0 ; 
	rep( i, 1, n ) if(c[i]) tt[ord[c[i]]] ++, Ans -= c[i] * c[i] % P ; 
	rep( i, 0, P ) A1[i].x = tt[i] / cnt, A2[i].x = tt[i] % cnt ; 
	rep( i, 0, P ) B1[i].x = tt[i] / cnt, B2[i].x = tt[i] % cnt ; 
	Init( 2 * P + 5 ), FFT( A1, 1 ), FFT( A2, 1 ), FFT( B1, 1 ), FFT( B2, 1 ) ; 
	num = cnt * cnt % P ; 
	rep( i, 0, limit ) F[i] = A1[i] * B1[i], Q[i] = ( A1[i] * B2[i] + A2[i] * B1[i] ), C[i] = A2[i] * B2[i] ; 
	FFT( F, -1 ), FFT( Q, -1 ), FFT( C, -1 ) ;
	rep( i, 0, limit ) {
		ans[i] = ( (int)(F[i].x + 0.5) * num + ( (int)(Q[i].x + 0.5) * cnt ) + (int)(C[i].x + 0.5) ) ; 
		Ans += ans[i] * fc[i % (P - 1)] ;
	}
	cout << Ans / 2 << endl ; 
	return 0;
}

Measured memory_bytes: 105904
/*
      author  : nishi5451
      created : 14.08.2020 16:07:08
*/

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

int INF = 1001001001;

int main(){
    int n;
    cin >> n;
    int ans = INF;
    for(int i=0; i<n; i++){
        ll a;
        cin >> a;
        int now = 0;
        while(a%2==0){
            a/=2;
            now++;
        }   
        ans = min(ans,now); 
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int MOD = 1e9 + 7;
const int MX = 2e5 + 5;
const ll INF = 1e18;
const ld PI = acos((ld) - 1);

int main() {
	int k;
	cin >> k;
	int res = 1;
	int seq = 7 % k;
	while(res <= k) {
		if(seq % k == 0) {
			cout << res << '\n';
			return 0;
		}

		seq = (((seq % k) * (10 % k)) % k) + (7 % k);
		res++;
	}
	cout << -1 << '\n';
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;







int main() {
	int n, l;
	string s, t = "Hoshino";
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++) {
		getline(cin, s);
		l = 0;
		while (1) {
			l = s.find(t, l);
			if (l == string::npos)break;
			//cout << l << endl;
			s[l + 6] = 'a';
			l += 6;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define ll long long
#define N ((int)2e5+5)
using namespace std;
bool vis[N];
int dis[N];
vector<int>vec[N];
int bfs(int src)
{
    int cnt=1;
    queue<int>que;
    que.push(src);
    vis[src]=1;
    dis[src]=0;
    while(!que.empty())
    {
        int a=que.front();
        que.pop();
        for(int b:vec[a])
            if(vis[b]==0)
        {
            cnt++;
            que.push(b);
            vis[b]=1;
            dis[b]=dis[a]+1;
        }
    }
    return cnt;
}
int main()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        vec[a].push_back(b);
        vec[b].push_back(a);

    }
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
            {
                mx=max(mx,bfs(i));
            }
    }
    cout<<mx<<endl;
}




Measured memory_bytes: 16080
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
a = readints()
ans = []
for i in range(n):
    if 1 <= a[i] and a[i] <= 399:
        ans.append('hai')
    if 400 <= a[i] and a[i] <= 799:
        ans.append('tya')
    if 800 <= a[i] and a[i] <= 1199:
        ans.append('midori')
    if 1200 <= a[i] and a[i] <= 1599:
        ans.append('mizu')
    if 1600 <= a[i] and a[i] <= 1999:
        ans.append('ao')
    if 2000 <= a[i] and a[i] <= 2399:
        ans.append('ki')
    if 2400 <= a[i] and a[i] <= 2799:
        ans.append('daidai')
    if 2800 <= a[i] and a[i] <= 3199:
        ans.append('aka')
    if a[i] >= 3200:
        ans.append('nanndemoii')
tmp = 0
for i in range(n):
    if ans[i] == 'nanndemoii':
        tmp += 1
if tmp == n:
    print(1, n)
    exit()
# print(ans)
set_ans = list(set(ans))
# print(set_ans)
min_cnt = 0
for i in range(len(set_ans)):
    if set_ans[i] != 'nanndemoii':
        min_cnt += 1
# print(min_cnt)
max_cnt = 0
for i in range(n):
    if ans[i] == 'nanndemoii':
        max_cnt += 1
max_cnt += min_cnt
print(min_cnt, max_cnt)


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

int main() {
  int n, m, t, p;

  while (cin >> n >> m >> t >> p, n) {
    vector<vector<int>> a(m, vector<int>(n, 1));
    while (t--) {
      int d, c;
      cin >> d >> c;

      if (d == 1) {
        vector<vector<int>> b(m, vector<int>(max(c, n - c), 0));
        for (int i = 0; i < m; ++i) {
          for (int j = 0; j < max(c, n - c); ++j) {
            if (c + j < n) b[i][j] += a[i][c + j];
            if (c - j - 1 >= 0) b[i][j] += a[i][c - j - 1];
          }
        }

        a = b;
        n = max(c, n - c);
      } else {
        vector<vector<int>> b(max(c, m - c), vector<int>(n, 0));
        for (int j = 0; j < n; ++j) {
          for (int i = 0; i < max(c, m - c); ++i) {
            if (c + i < m) b[i][j] += a[c + i][j];
            if (c - i - 1 >= 0) b[i][j] += a[c - i - 1][j];
          }
        }

        a = b;
        m = max(c, m - c);
      }
    }

    while (p--) {
      int x, y;
      cin >> x >> y;

      cout << a[y][x] << endl;
    }
  }
}



Measured memory_bytes: 3148
#!python3.4.3

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
  
def main():
  a, b, c = map(int, input().split(' '))
  
  divisors = make_divisors(c)
  count = 0
  
  for i in range(a, b+1):
    if i in divisors:
      count+=1

  print(count)


if __name__ == "__main__":
  main()



Measured memory_bytes: 5640
N,M=map(int,input().split())
ks=[[] for _ in range(M)]
for i in range(M):
    ks[i]=list(map(int,input().split()))
p=list(map(int,input().split()))

button=[0]*N
lit=[0]*M
x=pow(2,N)
total=0
for i in range(x):
    for j in range(N):
        if (i>>j)&1:
            button[j]=1
        else:
            button[j]=0
    for j in range(M):
        for k in range(1,ks[j][0]+1):
            if button[ks[j][k]-1]:
                lit[j]+=1
    count=0
    for j in range(M):
        if lit[j]&1==p[j]:
            count+=1
    if count==M:
        total+=1
    for j in range(M):
        lit[j]=0
print(total) 

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
#include<map>
#include <cassert>
#include<sstream>
using namespace std;
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long mod = 1e9 + 7;
signed main()
{
	int n;
	cin >> n;
	long long x[100004];
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	long long sa[100004];
	long long ruiseki = 0;
	for (int i = 0; i < n -1; i++) {
		sa[i] = x[i + 1] - x[i];
		ruiseki += sa[i];
		ruiseki %= mod;
	}
	long long ans = 0;
	long long ruijou[100004];
	ruijou[0] = 1;
	for (int i = 1; i <= 100003; i++) {
		ruijou[i] = ruijou[i - 1] * i;
		ruijou[i] %= mod;
	}
	ans += (ruiseki*ruijou[n - 1]) % mod;
	long long now = ruijou[n - 1];
	for (int i = 0; i < n - 2; i++) {
		ruiseki -= sa[i];
		ruiseki += mod;
		ruiseki %= mod;
		now -= ((ruijou[i] * modinv(ruijou[i + 2],mod)%mod)*ruijou[n-1])%mod;
		now += mod;
		now %= mod;
		ans += (now*ruiseki)%mod;
		ans %= mod;
	}
	cout << ans;
}


Measured memory_bytes: 2560
N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)


Measured memory_bytes: 32676
while True:
    M,F,R = map(int,input().split())
    if M == -1 and F == -1 and R == -1:
        break
    if M == -1 or F == -1:
        print("F")
    elif M+F >= 80:
        print("A")
    elif M+F >= 65:
        print("B")
    elif M+F >= 50:
        print("C")
    elif M+F >= 30:
        if R >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")




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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, M, K;

int main() {
	cin >> N >> M >> K;

	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= M; ++j) {
			int num = i * M + j * N - 2 * i * j;
			if (num == K) {
				puts("Yes");
				return 0;
			}
		}
	}

	puts("No");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

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 RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define INF (1 << 30)
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout << #x << ": " << x << endl
#define _DDEBUG(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x, y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    if (!v.empty())
    {
        out << '[';
        copy(v.begin(), v.end(), ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

/* template end */

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

    int n, m, x;
    cin >> n >> m >> x;
    set<int> s;
    REP(i, m)
    {
        int t;
        cin >> t;
        s.insert(t);
    }

    int cost0 = 0, costn = 0;
    for (int i = x - 1; 0 < i; i--)
    {
        cost0 += s.find(i) != s.end() ? 1 : 0;
    }
    for (int i = x + 1; i < n; i++)
    {
        costn += s.find(i) != s.end() ? 1 : 0;
    }

#if DEBUG
    cout << "** RESULT **" << endl; // debug
#endif
    cout << min(cost0, costn) << endl;
    return 0;
}


Measured memory_bytes: 256
/**Bismillahir Rahmanir Raheem
    Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 2e5 + 5;
const int M = 1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
map<string,int>mp;
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1,mx=0;
    string s[N];
    ///scanf("%d",&test);
    for(int cs=1; cs<=test; cs++) {
        int n;
        scanf("%d",&n);
        for(int i=1; i<=n; i++) {
            cin>>s[i];
            mp[s[i]]++;
            mx=max(mx,mp[s[i]]);
        }
        sort(s+1,s+n+1);
        for(int i=1; i<=n; i++) {
        if(mp[s[i]]==mx) {
                cout<<s[i];
                mp[s[i]]=0;
                if(i!=n)cout<<endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 26752
import itertools as ite
import math

INF = 10 ** 18

N, M, p = map(int, raw_input().split())
ls = []
for i in range(M):
    ls.append((input() - p) % N)
ls = sorted(ls)
ans = min(ls[-1], N - ls[0])
for i in range(M - 1):
    len1 = ls[i]
    len2 = N - ls[i + 1]
    ans = min(ans, len1 * 2 + len2, len2 * 2 + len1)
print ans * 100



Measured memory_bytes: 5488
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,m;
char s[111];
int cnt[256];
int a[10011],an;
bool vis[111][111];
int vcnt;
bool used[10011];
void dfs(int x,int y)
{
	if(vis[x][y])return;
	vis[x][y]=1;
	vcnt++;
	dfs(n-x+1,y);
	dfs(x,m-y+1);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)cnt[s[j]]++;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(!vis[i][j])
			{
				vcnt=0;
				dfs(i,j);
				a[an++]=vcnt;
			}
		}
	}
	sort(a,a+an);
	for(int i=1;i<256;i++)
	{
		for(int j=an-1;cnt[i]>0&&j>=0;j--)
		{
			if(used[j])continue;
			if(cnt[i]>=a[j])
			{
				cnt[i]-=a[j];
				used[j]=1;
			}
		}
		if(cnt[i]>0)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
class SegTree
    def update(k); @d[k] = @op.call(@d[2 * k], @d[2 * k + 1]); end

    def initialize(v, e, &op)
        @n = v.size
        @log = (@n - 1).bit_length
        @size = 1 << @log
        @op = op

        @d = Array.new(2 * @size, e) # vector

        @n.times{|i| @d[@size + i] = v[i]}
        (@size - 1).downto(1) {|i| update(i)}
    end

    def set(pos, x)
        pos += @size
        @d[pos] = x
        1.upto(@log) {|i| update(pos >> i)}
    end

    def get(pos); @d[pos + @size]; end

    def prod(l, r)
        sml = smr = @d[0]
        l += @size
        r += @size

        while l < r
            (sml = @op.call(sml, @d[l]); l += 1) if l[0] == 1
            smr = @op.call(@d[r -= 1], smr) if r[0] == 1
            l >>= 1
            r >>= 1
        end
        @op.call(sml, smr)
    end

    def all_prod; @d[1]; end

    def max_right(l, &f)
        return @n if l == @n
        l += @size
        sm = @d[0]

        loop do
            l >>= 1 while l[0] == 0
            x = @op.call(sm, @d[l])
            if !f.call(x)
                while l < @size
                    l <<= 1
                    x = @op.call(sm, @d[l])
                    if f.call(x)
                        sm = x
                        l += 1
                    end
                end
                return l - @size
            end
            
            sm = x
            l += 1
            break if (l & -l) == l
        end

        @n
    end
    
    def min_left(r, &f)
        return 0 if r == 0
        r += @size
        sm = @d[0]

        loop do
            r -= 1
            r >>= 1 while r > 1 && r[0] == 1
            x = @op.call(@d[r], sm)
            if !f.call(x)
                while r < @size
                    r = 2 * r + 1
                    x = @op.call(@d[r], sm)
                    if f.call(x)
                        sm = x
                        r -= 1
                    end
                end
                return r + 1 - @size
            end
            sm = x
            break if (r & -r) == r
        end

        0
    end
end

n, q = gets.split.map(&:to_i)
st = SegTree.new(gets.split.map(&:to_i), -1) {|ch1, ch2| ch1 > ch2 ? ch1 : ch2}

q.times do
    t, x, y = gets.split.map(&:to_i)
    
    if t == 1
        st.set(x-1, y)
    elsif t == 2
        puts st.prod(x-1, y)
    else
        puts st.max_right(x-1){|v| v < y} + 1
    end
end

Measured memory_bytes: 36740
require 'set'

def main
    n,k = gets.chomp.split(" ").map(&:to_i)
    ss = Array.new(n+1, 0)
    k.times do
        d = gets.chomp.to_i
        as = gets.split(" ").map(&:to_i)
        as.each do |i|
            ss[i] += 1
        end
    end
    puts ss.count{ |x| x == 0 } - 1
end

main

## イディオムなど
# until s.empty? do
#
## 配列のインデックス
# s[0,6] # 0番目から6文字
# s[0..6] # 0番目から6番目まで
# s[5..-1] # 5番目から最後まで
#
## 全探索
# [0, 1].repeated_permutation(n) do |combination| # bit全探索
# array.combination(i) do |selected| # array から要素が i 個である部分列を全部抽出
#
## 無向グラフの幅優先探索(BFS)
# to = Array.new(n).map{Array.new()} # ある頂点と繋がる頂点のリスト
# m.times do
#     a,b = gets.chomp.split(" ").map(&:to_i)
#     to[a].push b
#     to[b].push a
# end
# q = Queue.new # BFS は queue
# ds = Array.new(n, -1)
# pre = Array.new(n, -1)
#
## その他
# a1 = Marshal.load(Marshal.dump(a2)) # 深いコピー
# matrix = Array.new(n).map{Array.new()} # 二次元配列の初期化
# 

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;

    rep(i,s.length()){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const long long int ARRAY = 200005;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  vector<int> bucket(ARRAY);
 
  for(int i=0; i<N; i++){
    cin >> a[i];
    bucket[a[i]]++;
  } //for
 
  int num_type = 0;
  for(int i=0; i<N+1; i++){
    if(bucket[i] > 0) num_type++;
  }//for
  
  sort(bucket.rbegin(), bucket.rend());
  int i = 1;
  int ans = 0;
  while(num_type > K){
    if( bucket[N-i] > 0){
       num_type--;
       ans += bucket[N-i];
    }//if   
    i++;
  } //while

  cout << ans << "\n";
}//main


Measured memory_bytes: 4740
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int dp[18][5][5][5][5][5][5][5];
int f[10][10];
int a[7];
int b[7];
int pts[5]={0,0,60,70,80};
int test;

int main(void){
	scanf("%d",&test);
	for(int tester=0;tester<test;tester++){
		memset(dp,-1,sizeof(dp));
		memset(f,0,sizeof(f));
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++)scanf("%d",&f[j][i]);
		}
		dp[0][f[0][0]][f[1][0]][f[2][0]][f[3][0]][f[4][0]][f[0][1]][f[1][1]]=0;
		for(int i=0;i<16;i++){
			for(a[0]=0;a[0]<=4;a[0]++){
				for(a[1]=0;a[1]<=4;a[1]++){
					for(a[2]=0;a[2]<=4;a[2]++){
						for(a[3]=0;a[3]<=4;a[3]++){
							for(a[4]=0;a[4]<=4;a[4]++){
								for(a[5]=0;a[5]<=4;a[5]++){
									for(a[6]=0;a[6]<=4;a[6]++){
										if(dp[i][a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]]>=0){
											for(int j=0;j<7;j++)b[j]=a[j];
											for(int j=0;j<5;j++){
												for(int k=0;k<=1;k++){
													if(b[k]!=0){
														b[k]++;
														if(b[k]==5)b[k]=1;
													}
												}
												for(int k=5;k<=6;k++){
													if(b[k]!=0){
														b[k]++;
														if(b[k]==5)b[k]=1;
													}
												}
												if(i%4==3){
													dp[i+1][b[2]][b[3]][b[4]][b[5]][b[6]][f[0][(i+1)/4+1]][f[1][(i+1)/4+1]]=max(dp[i+1][b[2]][b[3]][b[4]][b[5]][b[6]][f[0][(i+1)/4+1]][f[1][(i+1)/4+1]],dp[i][a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]]+pts[b[0]]+pts[b[1]]);
												}else{
													int nx=(i+2)%4;
													if(nx==0)nx=4;
													dp[i+1][b[1]][b[2]][b[3]][b[4]][b[5]][b[6]][f[nx][i/4+1]]=max(dp[i+1][b[1]][b[2]][b[3]][b[4]][b[5]][b[6]][f[nx][i/4+1]],dp[i][a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]]+pts[b[0]]);
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		int res=0;
		for(a[0]=0;a[0]<=4;a[0]++){
			for(a[1]=0;a[1]<=4;a[1]++){
				for(a[2]=0;a[2]<=4;a[2]++){
					for(a[3]=0;a[3]<=4;a[3]++){
						for(a[4]=0;a[4]<=4;a[4]++){
							for(a[5]=0;a[5]<=4;a[5]++){
								for(a[6]=0;a[6]<=4;a[6]++){
									if(dp[16][a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]]>=0)res=max(res,dp[16][a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]]+pts[a[0]]+pts[a[1]]+pts[a[2]]+pts[a[3]]+pts[a[4]]);
								}
							}
						}
					}
				}
			}
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 6688
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint x;

void solve(){
  cin >> x;
  llint ans=x/11*2;
  if(x%11==0)ans+=0;
  else if(x%11>6)ans+=2;
  else ans++;
  cout << ans <<  endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256