akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
A=[]
par=[-1]*n
def find(x):
  if par[x]<0:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return False
  else:
    if par[x]>par[y]:
      x,y=y,x
    par[x]+=par[y]
    par[y]=x
    return True
def same(x,y):
  return find(x)==find(y)
def size(x):
  return -par[find(x)]
for i in range(m):
  a,b=map(int,input().split())
  A.append([a,b])
A=A[::-1]
ans=n*(n-1)//2
Ans=[ans]
for i in range(m):
  a,b=A[i]
  if not same(a-1,b-1):
    ans-=(size(a-1)*size(b-1))
  Ans.append(ans)
  unite(a-1,b-1)
Ans=Ans[::-1][1:]
print(*Ans,sep="\n")

Measured memory_bytes: 28624
# https://atcoder.jp/contests/abc104/tasks/abc104_b


def main():
    S = input()
    if S[0] == "A" and S[2:-1].count("C") == 1:
        S = S.replace('A', '', 1).replace('C', '', 1)
        if all(c.islower() for c in S):
            print("AC")
            exit()

    print("WA")


if __name__ == '__main__':
    main()




Measured memory_bytes: 2940
n = int(input())
x = range(n)
P =[]
s = 0
for _ in x:P.append([int(i) for i in input().split()])
P+=[P[0]]
for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Measured memory_bytes: 7720
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int A[200000 + 10];
int dp[200000 + 10][5];

signed main(void) {
    int L;
    cin >> L;
    rep(i, L) cin >> A[i];
     
    dp[0][0] = A[0];
    dp[0][1] = (A[0] == 0) ? 2 : ((A[0] % 2 == 0) ? 0 : 1);
    dp[0][2] = (A[0] == 0) ? 1 : ((A[0] % 2 == 0) ? 1 : 0);
    dp[0][3] = (A[0] == 0) ? 2 : ((A[0] % 2 == 0) ? 0 : 1);
    dp[0][4] = A[0];
    
    Rep(i, 1, L) {
        dp[i][0] = dp[i-1][0] + A[i];
        dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + ((A[i] == 0) ? 2 : ((A[i] % 2 == 0) ? 0 : 1));
        dp[i][2] = min(dp[i-1][2], min(dp[i-1][0], dp[i-1][1])) + ((A[i] == 0) ? 1 : ((A[i] % 2 == 0) ? 1 : 0));
        dp[i][3] = min(dp[i-1][3], min(dp[i-1][2], min(dp[i-1][0], dp[i-1][1]))) + ((A[i] == 0) ? 2 : ((A[i] % 2 == 0) ? 0 : 1));
        dp[i][4] = min(dp[i-1][4], min(dp[i-1][3], min(dp[i-1][2], min(dp[i-1][0], dp[i-1][1])))) + A[i];
    }
    
    // rep(i, L) {
    //     rep(j, 5) cout << "dp["<<i<<"]["<<j<<"]="<<dp[i][j] <<endl;
    // }

    cout << *min_element(dp[L-1], dp[L-1]+5) << endl;

    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace std;
using namespace __gnu_pbds; 
#define     mod            (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif






 
int main()
 
{  
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    IOS;
    
   int a;

   cin>>a;
   

   int ans = a + pow(a,2) + pow(a,3);

   cout<<ans<<endl; 
   
   
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  char a, b;
  cin >> a >> b;
  if (a > b) {
    swap(a, b);
  }
  for (ll i = 0; i < (b - '0'); ++i) {
    cout << a;
  }
  cout << "\n";
}


Measured memory_bytes: 3536
#include <stdio.h>
#define MAX 20000001
int A[MAX],B[MAX],C[MAX];

int main(){

  int i,n;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
      scanf("%d",&A[i+1]);
      C[i]=0;  
    }
 
  for(i=1;i<=n;i++)
      C[A[i]]=C[A[i]]+1;

  for(i=1;i<MAX;i++)
      C[i]=C[i]+C[i-1];

  for(i=n;i>0;i--){
      B[C[A[i]]]=A[i];
      C[A[i]]=C[A[i]]-1;
    }
 
  for(i=1;i<=n-1;i++)
      printf("%d ",B[i]);

  printf("%d\n",B[i]);

  return 0;
}

Measured memory_bytes: 96848
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(int argc, char const *argv[])
{
    int n = 0;
    int s = 0;
    int buf;
    int bmax = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> buf;
        s += buf;
        bmax = max(buf, bmax);
    }

    cout << s - bmax / 2;

    /* code */
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll x = N / (A+B);
    ll y = N % (A+B);

    if (y <= A) {
        cout << x * A + y << endl;
    } else {
        cout << x * A + A << endl;
    }

    return 0;
}


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

int main(){
string s;
int count = 0;
cin >> s;
bool x = false;
if(s.at(0)=='A')
{
    for(int i=2;i<s.size()-1;i++)
    {
        if(s.at(i)=='C')
        count++;
    }
    if(count==1)
    {
        if(s.at(1)!='C'&&s.at(s.size()-1)!='C'&&s.at(1)!='A'&&s.at(s.size()-1)!='A')
        {
            for(int i = 1;i<s.size();i++)
        {
            if(s.at(i)!='C'&&(s.at(i)<'a'||s.at(i)>'z'))
            {x=false; break;}
            else x=true;
        }
        }
    }
}
if(x)
cout << "AC" << endl;
else 
cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint n, s = 0;
  cin >> n;
  rep(i, n) if((i+1)%3 != 0 &&  (i+1)%5 != 0) s += i+1;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3636
input()
nbs = map(int, input().split())

answer = 0
count = {}

for nb in nbs:
    count[nb] = count.get(nb, 0) + 1

for nb in sorted(count.keys(), reverse=True):
    searching = (1 << nb.bit_length()) - nb
    nb_count = count[nb]
    sr_count = count.get(searching, 0)
    if sr_count:
        if nb == searching:
            increment = nb_count // 2
        else:
            increment = nb_count if nb_count < sr_count else sr_count
            count[searching] -= increment
        answer += increment

print(answer)

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

int N, M, D[1000][1000];
char S[1000][1000];
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 }; 
queue<pair<int, int>> Q;

int main()
{
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (S[i][j] == '#') {
				Q.push({ i,j });
			}
		}
	}

	int ans = 0;
	while (!Q.empty()) {
		int x, y;
		tie(x, y) = Q.front();
		Q.pop();
		int d = D[x][y];
		ans = d;
		for (int k = 0; k < 4; k++) {
			int px = x + dx[k];
			int py = y + dy[k];
			if (px < 0 || px >= N || py < 0 || py >= M) continue;
			if (S[px][py] == '.') {
				Q.push({ px,py });
				S[px][py] = '#';
				D[px][py] = d + 1;
			}
		}
	}

	cout << ans << endl;
}

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

#define FOR(i, n) for (int i = 0; i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)

int main() {
	int X, A, B;

	cin >> X >> A >> B;
	
	X = X - A; // X -= A;

	X = X % B;

	cout << X << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define LINF 1LL << 60

vector<P> robots;

bool cmp(const P &x, const P &y){
  return x.first + x.second < y.first + y.second;
}

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i){
    ll x, l;
    cin >> x >> l;
    robots.push_back(P(x, l));
  }

  sort(robots.begin(), robots.end(), cmp);

  ll f = -LINF;
  int count = 0;
  for(auto rb : robots){
    ll x = rb.first;
    ll l = rb.second;

    if(f <= x - l){
      ++count;
      f = x + l;
    }
  }

  cout << count << endl;
}


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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
#define mp make_pair
#define pb push_back
# define PI acos(-1)
# define double long double
const int MxN = 200005 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
 
int v ; 
vector<PII> a(9) ; 
VI tmp(10) ; 

bool fun(const PII &a, const PII &b) {
	if(a.first == b.first) {
		return a.second > b.second ; 
	}

	return a.first < b.first ; 
}

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

	string s ; 
	cin >> s ;
	int cur = 0 ,c1=0,c2=0,d=0;
	VI a(n)  ; 
	FOR(i,0,n) {
		if(s[i] == '('){
			bool ok = false ;
			FOR(j,0,-cur) {
				cout << '(' ;
				c1++; 
				ok = true ; 
			}
			if(ok)
				cur = 0 ; 
			c1++;
			cur++;
			
		}
		if(s[i]==')') {
			c2++; 
			cur--;
			if(cur > 0)
				++d ; 
		}
	}  
	FOR(i,0,-cur)
	cout << '(' ; 
	cout << s ; 
	FOR(i,0,c1-c2)
	cout << ')' ; 
	
	
	
 

}

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



Measured memory_bytes: 3680
#include <cstdio>
#include <list>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    char s[15];
    list<int>l;
    while(n--){
        int m;
        scanf("%s", s);
        if(s[0] == 'i'){
            scanf("%d", &m);
            l.push_front(m);
        }
        else if(s[6] == 'L'){
            l.pop_back();
        }
        else if(s[6] == 'F'){
            l.pop_front();
        }
        else{
            scanf("%d", &m);
            for(list<int>::iterator it=l.begin(); it!=l.end(); it++){
                if(*it == m){
                    l.erase(it);
                    break;
                }
            }
        }
    }

    bool flag = true;
    for(list<int>::iterator it=l.begin(); it!=l.end(); it++){
        if(flag){
            flag = !flag;
            printf("%d", *it);
        }
        else{
            printf(" %d", *it);
        }
    }
    printf("\n");
    return 0;
}


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

struct pair{
  long a;
  int b;
};

int compare(const void *x, const void *y) {
  return ((struct pair *)x)->a - ((struct pair *)y)->a;
}

int main() {
  int N,M;
  scanf("%d %d",&N,&M);
  struct pair AB[N];
  for (int i = 0; i < N; i++) {
    scanf("%ld %d",&AB[i].a,&AB[i].b);
  }
  qsort(AB,N,sizeof(struct pair),compare);

  struct pair ab = {0,M};
  for (int i = 0; i < N; i++) {
    if (ab.b >= AB[i].b) {
      ab.a += AB[i].a*AB[i].b;
      ab.b -= AB[i].b;
    }
    else {
      ab.a += AB[i].a*ab.b;
      break;
    }
  }
  printf("%ld\n",ab.a);
  return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, x, ans = 0;
  cin >> a >> b >> x;
  if (x == 1) ans = b - a + 1;
  else {
    long long q = (a - 1) / x;
    if (a == 0) ans++;
    if (a != x * q + 1) a = x * q + 1;
    ans += (b - a + 1) / x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);


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

  map<string, int> mp;
  int n;
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int m;
  cin >> m;
  rep(i, m) {
    string s;
    cin >> s;
    mp[s]--;
  }

  int ans = 0;
  for (auto& p : mp) {
    chmax(ans, p.second);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define T 2
#define K 4

int main(void) {
	int x, y;
	int i, j;

	scanf("%d", &x);
	scanf("%d", &y);

	for (i = 0; i <= x; i++) {
		if ((x-i)*T + i*K == y || i*T + (x-i)*K == y) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");



	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	cout << n * n * n << endl;
	return 0;
}

Measured memory_bytes: 256
import copy

# a = get_int()
def get_int():
    return int(input())

# a = get_string()
def get_string():
    return input()

# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]

# a_list = get_string_list():
def get_string_list():
    return input().split()

# a, b = get_int_multi()
def get_int_multi():  # a, b = get_int_multi()
    return map(int, input().split())

# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    m = get_int()
    ret = 0
    if m < 600:
        ret = 8
    elif m < 800:
        ret = 7
    elif m < 1000:
        ret = 6
    elif m < 1200:
        ret = 5
    elif m < 1400:
        ret = 4
    elif m < 1600:
        ret = 3
    elif m < 1800:
        ret = 2
    elif m < 2000:
        ret = 1

    print(ret)




if __name__ == '__main__':
    main()




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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double r,w,c,g;
  while( cin >> r >> w >> c >> g&&(w + r + c + g)){
    int ans = 0;
    while(c > r / w){
       r += g;
       ++ans;
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    int a[3][3];
    rep(i, 3) {
        rep(j, 3) cin >> a[i][j];
    }
    bool be[110];
    fill(be, be + 110, false);;
    int n;
    cin >> n;
    int b[15];
    rep(i, n) {
        cin >> b[i];
        be[b[i]] = true;
    }
    if(be[a[0][0]] && be[a[0][1]] && be[a[0][2]]) cout << "Yes" << endl;
    else if(be[a[1][0]] && be[a[1][1]] && be[a[1][2]]) cout << "Yes" << endl;
    else if(be[a[2][0]] && be[a[2][1]] && be[a[2][2]]) cout << "Yes" << endl;
    else if(be[a[0][0]] && be[a[1][0]] && be[a[2][0]]) cout << "Yes" << endl;
    else if(be[a[0][1]] && be[a[1][1]] && be[a[2][1]]) cout << "Yes" << endl;
    else if(be[a[0][2]] && be[a[1][2]] && be[a[2][2]]) cout << "Yes" << endl;
    else if(be[a[0][0]] && be[a[1][1]] && be[a[2][2]]) cout << "Yes" << endl;
    else if(be[a[0][2]] && be[a[1][1]] && be[a[2][0]]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
arr = []
initial = int(input())
temp = initial
for i in range(2, int(-(-temp**0.5//1))+1):
  if temp%i==0:
    cnt=0
    while temp%i==0:
      cnt+=1
      temp //= i
    arr.append(cnt)
if temp!=1:
  arr.append(1)
if arr==[]:
  arr.append(1)

def judge(n):
  l = 1
  while n > 0:
    n -= l
    l += 1
  if n == 0:
    return l-1
  else:
    return l-2

count = 0
for i in arr:
  count += judge(i)

if initial == 1:
  print(0)
else:
  print(count)

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

int main(){
	int n;
	while(cin >> n){
		int count = 0;
	for(int a=0 ; a<10 ;a++){
		for(int b =0 ; b<10 ; b++) {
			for(int c=0 ; c<10 ; c++) {
				for(int d =0; d<10 ; d++) {
					if(a+b+c+d==n) count++;
					
				}
			}
		}
	}
	cout << count << "\n";
}
	return 0;
	
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(void)
{
    int h, m, s;

    cin >> s;
    h = s / 3600; s %= 3600;
    m = s / 60;   s %= 60;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}

Measured memory_bytes: 1164
if __name__ == '__main__':
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    friend = [[-1] for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        friend[a - 1].append(h[b - 1])
        friend[b - 1].append(h[a - 1])
    ans = 0
    for i in range(n):
        if h[i] > max(friend[i]):
            ans += 1
    print(ans)


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

int main(void){
	int a, s, d, f;
	cin >> a >> s >> d >> f;
	int ans;
	if (a <= s) {
		ans += a;
	}
	else {
		ans += s;
	}
	if (d <= f) {
		ans += d;
	}
	else {
		ans += f;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char s[3],t[3];
  scanf("%s",&s);
    scanf("%s",&t);
  int c=0;
  for(int i=0;i<3;i++){
	if(s[i]==t[i])c++;
  }
  printf("%d",c);
  return 0;
}
               

Measured memory_bytes: 128
_n, m = gets.split.map(&:to_i)
a, b = Array.new(m) { gets.split.map(&:to_i) }.transpose
cut = count = 0

a.zip(b).sort_by { |_x, y| y }.each do |x, y|
  if cut < x
    cut = y - 1
    count += 1
  end
end

puts count


Measured memory_bytes: 28912
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

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

	return 0;
}


Measured memory_bytes: 3140
s = set(list(input()))
if 'N' in s:
  if 'S' not in s:
    print('No')
    exit()
if 'S' in s:
  if 'N' not in s:
    print('No')
    exit()
if 'W' in s:
  if 'E' not in s:
    print('No')
    exit()
if 'E' in s:
  if 'W' not in s:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

const int N = 131073;

#define pll pair<ll, ll>

int n;
vector<pll> f[N];
int ch[N][2], v[N][2];

boolean cmp(const pll& a, const pll& b) {
	return (a.first ^ b.first) ? (a.first < b.first) : (a.second > b.second);
}

void merge_sort(vector<pll>& A, vector<pll>& B, vector<pll>& C) {
	vector<pll> :: iterator pa = A.begin(), pb = B.begin();
	while (pa != A.end() && pb != B.end()) {
		(cmp(*pa, *pb)) ? (C.push_back(*(pa++))) : (C.push_back(*(pb++)));
	}
	while (pa != A.end()) C.push_back(*(pa++));
	while (pb != B.end()) C.push_back(*(pb++));
}

void dfs(int p, ll mid) {
	static vector<pll> T, G, H;
	f[p].clear();
	if (ch[p][0] == -1) {
		f[p].push_back(pll(0, 0));
		return;
	}
	dfs(ch[p][0], mid);
	dfs(ch[p][1], mid);
	T.clear(), G.clear(), H.clear();
	vector<pll> &L = f[ch[p][0]], &R = f[ch[p][1]];
	for (auto& par : L) par.first += v[p][0], par.second += v[p][0];
	for (auto& par : R) par.first += v[p][1], par.second += v[p][1];
	int sl = L.size(), sr = R.size();
	for (int i = 0, j = 0; i < sl; i++) {
		while (j < sr && L[i].second + R[j].first <= mid) j++;
		if (j && (T.empty() || T.back().second > R[j - 1].second)) {
			T.push_back(pll(L[i].first, R[j - 1].second));
		}
	}
	for (auto& par : T) {
		G.push_back(pll(par.second, par.first));
	}
	reverse(G.begin(), G.end());
	merge_sort(T, G, H);
	for (int i = (signed) H.size() - 1; ~i; i--) {
		pll& par = H[i];
		while (!f[p].empty() && (f[p].back().second >= par.second))
			f[p].pop_back();
		f[p].push_back(par);
	}
	reverse(f[p].begin(), f[p].end());
//	for (int i = 0; i < (signed) f[p].size() - 1; i++) {
//		assert(cmp(f[p][i], f[p][i + 1]));
//	}
#ifdef local
	cerr << p << ": ";
	for (auto& par : f[p]) {
		cerr << "(" << par.first << ", " << par.second << ")" << " ";
	}
	cerr << '\n';
#endif
}

int main() {
#ifdef local
	freopen("a.in", "r", stdin);
#endif	
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		ch[i][0] = ch[i][1] = -1;
	}
	ll sum = 0;
	for (int i = 2, x, w; i <= n; i++) {
		scanf("%d%d", &x, &w);
		if (ch[x][0] == -1) {
			ch[x][0] = i;
			v[x][0] = w;
		} else {
			ch[x][1] = i;
			v[x][1] = w;
		}
		sum += w;
	}
#ifdef local
	dfs(1, 26);
	return 0;
#endif

	ll l = 0, r = sum, mid;
	while (l <= r) {
		mid = (l + r) >> 1;
		dfs(1, mid);
		if (f[1].size()) {
			r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
	printf("%lld\n", r + 1);
	return 0;
}


Measured memory_bytes: 30160
#include <stdio.h>
int main(){
    int n,m,count=0;
    scanf("%d%d",&n,&m);
    int ka[n][m+1];
    int sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&ka[i][0]);
        for(int j=1;j<ka[i][0]+1;j++){
            scanf("%d",&ka[i][j]);
        }
    }
    for(int k=0;k<m;k++){
        for(int i=0;i<n;i++){
            for(int j=1;j<ka[i][0]+1;j++){
                if(ka[i][j]==k+1){
                    sum++;
                    break;
                }
            }
        }
        if(sum==n){
            count++;
        }
        sum=0;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  ABC169E

#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    vector<int>ls(n),rs(n);
    rep(i,n){
        cin>>ls.at(i)>>rs.at(i);
    }
    sort(ls.begin(),ls.end());
    sort(rs.begin(),rs.end());
    int ans=0;
    if (n%2==1) {
        int L=ls.at(n/2);
        int R=rs.at(n/2);
        ans=R-L+1;
    }else{
        
        int L2=ls.at(n/2-1)+ls.at(n/2);
        int R2=rs.at(n/2-1)+rs.at(n/2);
        ans=R2-L2+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4460
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0u32; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let ans = av.iter().map(|a| a.trailing_zeros()).min().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}

int main() {
	int N;
	cin >> N;
	
	vector<int> H(N, 0);
	repeat(i, N) {
		cin >> H[i];
	}

	int result = 1;
	int start = H[0];
	repeat(i, 1, N) {
		if (start <= H[i]) {
			result++;
			start = H[i];
		}
	}

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = ReadLine();
        WriteLine(N.Length == 1 ? int.Parse(N) : (N.Skip(1).Count(x => x == '9') == N.Length - 1 ? N : $"{int.Parse(N.First() + "") - 1}{"9999999999999999".Substring(0, N.Length - 1)}").Select(x => int.Parse(x + "")).Sum());
    }
}

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

int main() {
  int X;
  int Y = 360;
  cin >> X;
  if (X % 5 ==0){
    Y =72;
  }
  if (X % 3 ==0){
    Y = Y/3;
   	 if (X % 9 ==0){
    	Y =Y/3;
	  }
  }
  if (X % 2 ==0){
    Y = Y/2;
   	 if (X % 4 ==0){
    	Y =Y/2;
       if (X % 8 ==0){
    	Y =Y/2;
	  }
	  }
  }
  cout << Y << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

const ll MOD = 1000 * 1000 *1000 + 7 ;
inline void chadd(ll &a, const ll b) { a = (a + b) % MOD;}
inline ll add(const ll a, const ll b){ return (a + b) %  MOD;}
inline void chsub(ll &a, const ll b) { a = (a - b + MOD) % MOD;}
inline ll sub(const ll a, const ll b){ return (a - b + MOD) % MOD; }
inline void chmul(ll &a, const ll b) { a = (a * b) %  MOD;}
inline ll mul(const ll a, const ll b){ return (a * b) %  MOD;}

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<int> cnt(60,0);
  REP(i,N) {
    ll v; cin>>v;
    REP(i,60) {
      cnt[i] += (int)((v>>i)& 1LL);
    }
  }
  //  pp(cnt, 60);
  ll ans = 0;
  REP(i, 60) {
    ll tmp = (1LL << i) % MOD;
    chmul(tmp, (N - cnt[i]));
    chmul(tmp, cnt[i]);
    chadd(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	ll ret=0;
	vector<ll>divs(n+1);
	for(ll i=1;i<=n;i++){
		for(ll j=i;j<=n;j+=i){
			divs[j]++;
		}
	}
	for(ll i=1;i<=n;i++){
		ret += i * divs[i];
	}
	cout<<ret<<endl;
	return 0;
}

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

int main(){
	
	ll a,b;
	cin >> a >> b;
	ll ans = INT_MIN;
	ans = max(ans,a+(a-1));
	ans = max(ans,a+b);
	ans = max(ans,b+(b-1));
	cout << ans << endl;

	return 0;
}

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

#define ll long long
#define ld long double

#define pii pair<int, int>
#define pci pair<char, int>
#define pcc pair<char, char>

#define vi vector <int>
#define vll vector<long long>
#define vld vector<long double>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

#define vvi vector<vi>
#define vvll vector<vll>
#define vvld vector<vld>
#define vvb vector<vb>
#define vvc vector<vc>
#define vvs vector<vs>

#define vpii vector<pii>
#define vpci vector<pci>
#define vpcc vector<pcc>

#define all(v) (v).begin(), (v).end()
#define allrev(v) (v).rbegin(), (v).rend()
#define allcomp(v) (v).begin(), (v).end(), comp
#define allrevcomp(v) (v).rbegin(), (v).rend(), comp

const int MOD = 1e9 + 7;
const ld pi = 3.1415926535897932384626433832;

#define line cout<<"\n";
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

void solve(int test_case){
   int n , k;

   cin >> k >> n;
   vi v(n);

   for(int i = 0; i < n; i++)
        cin >> v[i];

    sort(all(v));

    int a = v[0] - v[n - 1] + k;
    int b = v[n -1] - v[0];
    int max;
    if(a < b) max = a;
    else max = b;
    for(int i = 0; i < n - 1; i++)
        if(v[i+1] - v[i] > max)
            max = v[i+1] - v[i];

    cout << (k - max) % k;
}

int main(){
    fast
    int test = 1;
   // cin>>test;
    for(int i = 1; i <= test; i++){
        solve(i);
    }
    return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//int N[100005];
int main(){
    string s;cin>>s;
    int N[s.size()];
    for(int i=0;i<s.size();i++){
        N[i]=0;
    }
    for(int i=0;i<s.size();i++){
        
        if(s.at(i)=='R'&&s.at(i+1)=='L'){
            for(int j=i;j>=0&&s.at(j)=='R';j--){
                if((i-j)%2){
                    N[i+1]++;
                }
                else N[i]++;
            }
           // cout << N[3] <<endl;
            for(int j=i+1;j<s.size()&&s.at(j)=='L';j++){
                if((j-i)%2){
                    N[i+1]++;
                }
                else N[i]++;
            }
        }
        
    }
    
    for(int i=0;i<s.size();i++){
        cout << N[i] << " ";
    }
    
    cout << endl;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
n=int(input())
Edges=[]
for i in range(n-1):
  a,b,c=map(int,input().split())
  Edges.append([a,b,c])
q,k=map(int,input().split())
def BFS(K,edges,N):
  roots=[[] for i in range(n)]
  for a,b,c in edges:
    roots[a-1]+=[(b-1,c)]
    roots[b-1]+=[(a-1,c)]
  dist=[-1]*n
  stack=[]
  stack.append(K)
  dist[K]=0
  while stack:
    label=stack.pop(-1)
    for i,c in roots[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        stack+=[i]
  return dist
D=BFS(k-1,Edges,n)
for i in range(q):
  x,y=map(int,input().split())
  print(D[x-1]+D[y-1])

Measured memory_bytes: 58428
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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 <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N;
	ll result=0;
	cin>>N;
	VI vec(N);
	REP(i, N) {
		ll l,r;
		cin >> l>>r;
		vec[i]=r-l+1;
	}
	result=SUM(vec);
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
s=input()

s = list(s)

memo1=10000000000000000000000

ans = 0

for i in range(len(s)):
    if s[i] == 'A':
        memo1=min(memo1, i)
    if s[i] == 'Z':
        memo2=i
print(memo2-memo1+1)

Measured memory_bytes: 61680
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define eb emplace_back
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }
  
  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=2e5+15;
  const int M=1e3+13;
 
 vi adj[N];
 int par[N];
 bool vt[N];

 void doit()
 { 
   int n,m; cin>>n>>m;
   rep(i,0,m){
     int x,y; cin>>x>>y; adj[x].pb(y); adj[y].pb(x);
   }

   queue<int> q; q.push(1); vt[1]=true;

  int ct=0;
   while(!q.empty()){
     int tp=q.front(); q.pop();
     ct++;
     tr(i,adj[tp]){
       if(vt[i]) continue;
       q.push(i);
       par[i]=tp;
       vt[i]=true;
     }
   }

   if(ct!=n) cout<<"No";
   else{
     cout<<"Yes"<<nl;
     rep(i,2,n+1) cout<<par[i]<<nl;
   }

   
 }  

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	
   int tc=1;                         
//  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
  
   doit();
   if(i<tc)
   cout<<nl;
  }

 return 0; 
}

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

int main()
{
    long long n,i,mi=105,ma=-105,j,p,sum=0,result=10000000000;
    cin>>n;
    long long a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        mi=min(mi,a[i]);
        ma=max(ma,a[i]);
    }
    for(j=ma;j>=mi;j--){
        sum=0;
        for(i=0;i<n;i++){
            p=(a[i]-j)*(a[i]-j);
            sum+=p;
        }
        result=min(result,sum);
    }
    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 3604
N=int(input())
K=int(input())
#for i in range(100):
 # for j in range(100):
  #  for k in range(100):
   #   if(i!=j and i!=k and j!=k):
    #    if(i*(10**))
ans=0
if(K==3):
  for a in range(1,10):
    for b in range(1,10):
      for c in range(1,10):
        ap=0
        bp=0
        cp=0
        while(a*(10**ap)<=N):#aについてみる
          ap+=1
        ap-=1
        while(a*(10**ap)+b*(10**bp)<=N and bp<ap):#bについてみる
          bp+=1
        bp-=1
        while(a*(10**ap)+b*(10**bp)+c*(10**cp)<=N and cp<bp):#cについてみる
          cp+=1
        cp-=1
        ans+=1+cp+(bp*(bp-1))//2+(ap*(ap-1)*(ap-2))//6
  print(ans)
elif(K==2):
  ans=0
  for i in range(100):
    for j in range(100):
      if(i>j):
        for a in range(1,10):
          for b in range(1,10):
            if(a*(10**i)+b*(10**j)<=N):
              ans+=1
  print(ans)
else:
  ans=0
  for i in range(100):
    for a in range(1,10):
      if(a*(10**i)<=N):
        ans+=1
  print(ans)

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

int main() {
  int h, w;
  cin >> h >> w;
  char array[h+2][w+2];
  for(int i = 0; i < h+2; i++) {
    for(int j = 0; j < w+2; j++) {
      array[i][j] = '.';
    }
  }
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      cin >> array[i][j];
    }
  }
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      if(array[i][j] == '#' && array[i-1][j] == '.' && array[i+1][j] == '.' && array[i][j-1] == '.' && array[i][j+1] == '.') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  // for(int i = 0; i < h+2; i++) {
  //   for(int j = 0; j < w+2; j++) {
  //     printf("%c", array[i][j]);
  //   }
  //   printf("\n");
  // }
  return 0;
}


Measured memory_bytes: 256
open Printf
open Scanf

let id x = x

let n, k = scanf "%d %d" (fun n k -> n, k)

let cond v = v mod k = 0

let rec gcd m n =
  if m < n then gcd n m
  else if n = 0 then m
  else gcd n (m mod n)

let lcm m n = m * n / gcd m n

let rec step_loop st ed step f =
  if st <= ed then begin
    f st; step_loop (st + step) ed step f
  end else ()

let () =
  let count = ref 0 in
  for a = 1 to n do
    let m1 = a mod k in
    let m2 = (k - m1) mod k in
    if m1 = m2 then
      if m1 = 0 then begin
        count := !count + (n / k) * (n / k);
      end else begin
        let v = (n - m1) / k + 1 in
        count := !count + v * v
      end;
  done;
  printf "%d\n" !count


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    int n=s.size();
    int res=0,part=0;
    bool all=true;
    rep(i,n){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            part++;
        }else{
            part=0;
        }
        chmax(res,part);
    }
    
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,x,ans=1e9;
    cin>>a>>b>>x;
    for(int i=0;i<=20000;i++){
        int c=x-(i*1000);
        if(c<=0)ans=min(a*i,ans);
        else{
            if(c%500==0)ans=min(a*i+c/(500)*b,ans);
            else ans=min(a*i+(c/(500)+1)*b,ans);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3136
h,w=map(int,input().split())

A=[]
for i in range(h):
  s=input()
  A.append([s[i] for i in range(w)])
g=[[[]for i in range(w)] for _ in range(h)]

for i in range(h):
  for j in range(w):
    if A[i][j]=='.':
      if i-1>=0:
          if A[i-1][j]=='.':
            g[i][j].append((i-1,j))
      if i+1<h:
          if A[i+1][j]=='.':
            g[i][j].append((i+1,j))          
      if j+1<w:
          if A[i][j+1]=='.':
            g[i][j].append((i,j+1))          
      if j-1>=0:
          if A[i][j-1]=='.':
            g[i][j].append((i,j-1))  
        
from collections import deque
def bfs(a,b):
  time=[[-1]*w for _ in range(h)]
  time[a][b]=0
  stack=deque([])
  stack.append((a,b))
  n=1
  while stack:
    d=stack.popleft()
    for v in g[d[0]][d[1]]:
      if time[v[0]][v[1]]==-1:
        time[v[0]][v[1]]=time[d[0]][d[1]]+1
        stack.append(v)
        
      else:
        continue
     
  timem=0
  for i in range(h):
    for j in range(w):
      timem=max(timem,time[i][j])
  return timem
ans=0
for i in range(h):
  for j in range(w):
    bfsm=bfs(i,j)
    ans=max(ans,bfsm)
print(ans)

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

int main(){
    int K,N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i,N){
        cin >> A.at(i);
    }
    
    int mx = -1;
    rep(i,N){
        int tmp;
        if(i == N-1) tmp = A.at(0) + K -A.at(i);
        else tmp = A.at(i+1) - A.at(i);
        mx = max(mx,tmp);
    }

    cout << K-mx << endl;
}   

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int A, B;
    cin >> A >> B;
    cout << "100 100" << endl;
    int base = 0;
    --A;
    --B;
    for (int i = 0; i < 100; i++) {
        if (i < 50) {
            for (int j = 0; j < 100; j++) {
                if ((base + j) % 4 == 0 && A > 0) {
                    cout << '.';
                    --A;
                }
                else cout << '#';
            }
            cout << endl;
        } else {
            for (int j = 0; j < 100; j++) {
                if ((base + j) % 4 == 0 && B > 0 && i != 50) {
                    cout << '#';
                    --B;
                }
                else cout << '.';
            }
            cout << endl;
        }
        base += 2;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        if (a == 0) {
            System.out.println(0);
            return;
        } else if (b == 0) {
            System.out.println(n);
            return;
        }
        long ans = n / (a + b);
        long mod = n % (a + b);
        ans *= a;
        ans += mod <= a ? mod : a;
        System.out.println(ans);
    }
}

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



 int main(){
    int n;
    cin>>n;
    vector<string> k;
    for(int i=0;i<n;i++){
        string x;
        cin>>x;
        sort(x.begin(),x.end());
        k.push_back(x);
    }
    sort(k.begin(),k.end());
   map<string,long long>freq;
   for(string const &i: k){
       freq[i]++;
   }
  vector<long long>d;

   for(auto y : freq){
       d.push_back(y.second);
   }
  long long sum=0;
  for(int s=0;s<d.size();s++){
      sum=sum+((d[s])*(d[s]-1))/2;
  }
   
  cout<<sum;
}
    

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

using namespace std;

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;

  double pi = 3.141592653589793238462643383279502884L;
  double at = (H + M / 60) / 12 * 2 * pi;
  double ax = cos(at) * A;
  double ay = sin(at) * A;
  double bt = (M / 60) * 2 * pi;
  double bx = cos(bt) * B;
  double by = sin(bt) * B;
  cout << setprecision(20) << hypot(ax - bx, ay - by) << endl;
}


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

using Line = vector<int>;

string solve(auto C) {
  set<Line> S;
  for(auto v: C) S.emplace(v);
  if(S.size() != 2) return "no";

  auto f = *begin(S);
  auto s = *rbegin(S);
  for(auto& i: f) i = !i;
  if(f != s) return "no";

  auto sum = 0;
  for(auto i: f) sum += i ? 1 : -1;
  if(1 < abs(sum)) return "no";

  return "yes";
}

int main() {
  int W, H;
  cin >> W >> H;

  vector<Line> C(H, Line(W));
  for(auto& i: C) for(auto& j: i) cin >> j;

  cout << solve(C) << endl;
}

Measured memory_bytes: 14636