akhauriyash/Code-Regression huggingface dataset:
import sys
import copy
import math
import itertools

a = [int(c) for c in input().split()]
N=a[0]
A=a[1]
B=a[2]

if N % (A+B) >= A:
    cnt=A
else:
    cnt=N % (A+B)

cnt += int(N/(A+B))*A
print(cnt)

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

int main(){
  int n,m; cin>>n>>m;
  vector<ll> num(n),sum(n+1,0);
  for(int i=0;i<n;i++){
    cin>>num[i];
    num[i]%=m;
    sum[i+1]=(sum[i]+num[i])%m;
  }
  ll ans=0;
  sort(sum.begin(),sum.end());
  for(int i=1;i<=n;i++){
    ll count=1;
    if(sum[i]==0) count++;
    while(sum[i]==sum[i+1] && i!=n){
      count++; i++;
    }
    ans+=((count)*(count-1))/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define P pair<int,int>
using namespace std;

P a[200];
signed main() {
	int ans = 1;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		ans = ans * 2 % mod;
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	ans -= n + 1;
	ans %= mod;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			vector<int>V;
			if (a[i].first == a[j].first) {
				for (int k = 0; k < n; k++) {
					if (a[k].first == a[i].first) {
						V.push_back(k);
					}
				}
			}
			else if (a[i].second == a[j].second) {
				for (int k = 0; k < n; k++) {
					if (a[k].second == a[i].second) {
						V.push_back(k);
					}
				}
			}
			else {
				double x = double(a[j].second - a[i].second) / (a[j].first - a[i].first);
				double y = double(a[i].second) - a[i].first*x;
				for (int i = 0; i < n; i++) {
					if (abs(a[i].first*x + y - a[i].second) <= 1e-5) {
						V.push_back(i);
					}
				}
			}
			sort(V.begin(), V.end());
			if (V.size()>=2&&V[0] == i&&V[1]==j) {
				int k = 1;
				for (int j : V) {
					k = k * 2 % mod;
				}
				k -= V.size(); k--;
				ans -= k;
				ans %= mod;
			}
		}
	}
	ans += mod * 5;
	ans %= mod;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset> //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip> //do setprecision
#include <ctime>
#include <complex>
using namespace std;

int main(void){
	int i,n,temp;
	
	cin >> n;
	map<int,int> numberof;
	for(i=0;i<n;i++){
		cin >> temp;
		numberof[temp]++;
	}
	auto itrf=numberof.begin();
	auto nextitr=next(itrf,1);
	if(nextitr->first<n){
		if(numberof.size()==1){
			if((itrf->first==1) || (itrf->first+1==n) || (2*itrf->first<=n)){
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}else if(numberof.size()==2){
			if((itrf->first+1)==nextitr->first){
				if((n-itrf->second)/2+itrf->second>=(itrf->first+1) && (itrf->second+1<=itrf->first+1)){
					cout << "Yes" << endl;
				}else{
					cout << "No" << endl;
				}
			}else{
				cout << "No" << endl;
			}
		}else{
			cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 4992
#include <cctype>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

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

int main(){
	LL n;
	cin >> n;
	
	deque<LL> b;
	REP(i, n){
		LL x;
		cin >> x;

		if(i % 2 == 0) b.push_back(x);
		else b.push_front(x);
	}

	if(n % 2 == 1){
		reverse(b.begin(), b.end());
	}

	REP(i, n){
		cout << b[i];
		if(i != n - 1){
			cout << " ";
		}
	}
	cout << endl;

}


Measured memory_bytes: 3840
//JOI-honsen-Ganbarimasu!!

#include<iostream>
#include<algorithm>
using namespace std;

long long JOI_honsen_Gannbarimasu(long long a, long long b, long long &x, long long &y) {
	long long d;
	if (b == 0) {
		d = a;
		x = 1; y = 0;
	}
	else {
		d = JOI_honsen_Gannbarimasu(b, a%b, y, x);
		y -= a / b*x;
	}
	return d;
}

int main() {
	long long a, b, x, y;
	cin >> a >> b;
	JOI_honsen_Gannbarimasu(a, b, x, y);
	cout << x << ' ' << y << endl;
	return 0;
}

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

int main()
{
	int n,k=0;
	cin>>n;
	if(n%2==0||n%5==0)
	{
		cout<<"-1";
		return 0;
	}
	
	for(int i=1;i;i++)
	{
		k=(k*10+7)%n;
		if(k==0)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	vector<pii>V(5);
	int A = (a % 10);
	int B = (b % 10);
	int C = (c % 10);
	int D = (d % 10);
	int E = (e % 10);
	V[0].first = A, V[0].second = a;
	V[1].first = B, V[1].second = b;
	V[2].first = C, V[2].second = c;
	V[3].first = D, V[3].second = d;
	V[4].first = E, V[4].second = e;
	sort(V.begin(), V.end());
	int ans = 0;
	int key = 6;
	for (int i = 0; i < 5; ++i) {
		if (V[i].first == 0) {
			ans += V[i].second;
		}
		else {
			key = i;
			break;
		}
	}
	if (key == 6) {
		cout << ans << endl;
		return 0;
	}
	else {
		ans += V[key].second;
		for (int i = key + 1; i < 5; ++i) {
			V[i].second += (10 - (V[i].second % 10));
			ans += V[i].second;
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#define de puts("#")
#define bug(x) cout<<#x<<" : "<<x<<endl
#define cha1 printf("L : %d,R : %d,x : %d,l : %d,r : %d,rt : %d\n",L,R,x,l,r,rt)
#define cha2 printf("L : %d,R : %d,l : %d,r : %d,rt : %d\n",L,R,l,r,rt)
#define cha3 printf("pos : %d,x : %d,l : %d,r : %d,rt : %d\n",pos,x,l,r,rt)
#define lcha1 printf("L : %lld,R : %lld,x : %lld,l : %lld,r : %lld,rt : %lld\n",L,R,x,l,r,rt)
#define lcha2 printf("L : %lld,R : %lld,l : %lld,r : %lld,rt : %lld\n",L,R,l,r,rt)
#define lcha3 printf("pos : %lld,x : %lld,l : %lld,r : %lld,rt : %lld\n",pos,x,l,r,rt)
#define huge(n,m,a) for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++)printf("%d ",a[i][j]);puts("");}puts("")
#define lhuge(n,m,a) for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++)printf("%lld ",a[i][j]);puts("");}puts("")
#define lowbit(x) (x&(-x))
#define IN freopen("in.txt","r",stdin)
#define OUT1 freopen("out1.txt","w",stdout)
#define OUT2 freopen("out2.txt","w",stdout)
#include<iostream>
#include<stdio.h>
#include<set>
using namespace std;
const int maxn=1e5+5;
int a[maxn];
multiset<int>q;

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		multiset<int>::iterator it=q.lower_bound(a[i]);
		if(it==q.begin())q.insert(a[i]);
		else{
			it--;
			q.erase(it);
			q.insert(a[i]);
		}
	}
	printf("%d\n",q.size());
	return 0;
}

Measured memory_bytes: 5376
// Problem: F - Range Set Query
// Contest: AtCoder - AtCoder Beginner Contest 174
// URL: https://atcoder.jp/contests/abc174/tasks/abc174_f
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
//#define int long long
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t) for (int i = s; i <= (int)t; i++)
#define RESET(x) memset((x), 0, sizeof(x))
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int N = 500050;
int cnt[N], ans, a[N];
void move(int pos, int sign) {
  if (sign) {
    if (++cnt[a[pos]] == 1) ++ans;
  } else {
    if (--cnt[a[pos]] == 0) --ans;
  }
}
int n, Q;
struct Query {
  int l, r, id;
} q[N];
int answer[N];
void solve() {
  scanf("%d%d", &n, &Q);
  rep(i, n) cin >> a[i];
  int BL = 1000;
  rep(i, Q) {
    int l, r;
    scanf("%d%d", &l, &r);
    --l;
    q[i] = {l, r, i};
  }
  sort(q, q + Q, [BL](const Query& a, const Query& b) {
    int al = a.l / BL, bl = b.l / BL;
    return (al != bl) ? al < bl : a.r < b.r;
  });
  int l = 0, r = 0;
  rep(i, Q) {
    while (l > q[i].l) move(--l, true);
    while (r < q[i].r) move(r++, true);
    while (l < q[i].l) move(l++, false);
    while (r > q[i].r) move(--r, false);
    answer[q[i].id] = ans;
  }
  rep(i, Q) printf("%d\n", answer[i]);
}
signed main() {
  int T = 1;
  // cin >> T;
  while (T--) solve();
  return 0;
}


Measured memory_bytes: 15460
n,m,k=map(int,input().split(" "))
a=[-9]
b=list(a)
a.extend(map(int,input().split(" ")))
b.extend(map(int,input().split(" ")))

t=0
i=1
while i<=n :
    # print("a[{}]={}".format(i,a[i]))
    if t+a[i]>k :
        break
    t+=a[i]
    # print("t=",t)
    i+=1
i-=1
# print("i=",i)
j=1
while j<=m :
    if t+b[j]>k :
        break
    t+=b[j]
    j+=1
j-=1
# print("j=",j)
ans=i+j
for i in range(i,0,-1):
    t-=a[i]
    # print("i-1=",i-1,end='  ')
    while j+1<=m and t+b[j+1]<=k :
        j+=1
        t+=b[j]
    # print("j=",j)
    ans=max(ans,i-1+j)

print(ans)


Measured memory_bytes: 39940
s = input()
if s=='SUN':
    print(7)
if s=='MON':
    print(6)
if s=='TUE':
    print(5)
if s=='WED':
    print(4)
if s=='THU':
    print(3)
if s=='FRI':
    print(2)
if s=='SAT':
    print(1)



Measured memory_bytes: 3060
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, m, q = input_to_int_map()
    kumis = [input_to_int_tuple() for i in range(q)]

    import itertools

    rets = [0]
    for comb in itertools.combinations_with_replacement(range(1, m + 1), n):
        val = 0
        for kumi in kumis:
            if (comb[kumi[1] - 1] - comb[kumi[0] - 1]) == kumi[2]:
                val += kumi[3]

        rets.append(val)

    print(max(rets))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12520
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<lli>/*------------------*/vlli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()
#define makepair/*---------------------*/make_pair

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}
lli getsum(lli x)
{
    lli res = 0;
    while(x > 0)
    {
        res += x%10;
        x /= 10;
    }
    return res;
}
int main()
{
	opt;
	lli n,a,b,i,ans = 0;
	cin >> n >> a >> b;
	REP(i,1,n)
	{
        if(getsum(i) >= a and getsum(i) <= b) ans += i;
	}
	cout << ans << endl;
	return 0;
}










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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
vector<pair<ll,ll> > prime_fac(ll n){
	vector<pair<ll,ll> >ret;
	for(ll p = 2; p * p <= n; ++p){
		if (n % p != 0) continue;
		int divc = 0;
		while(n % p == 0){
			++divc;
			n /= p;
		}
		ret.push_back(MP(p,divc));
	}
	if (n != 1) ret.push_back(MP(n,1));
	return ret;
}

int main() {
    ll N; cin >> N;
    ll ans = 0;
    vector<pair<ll,ll> > PN = prime_fac(N);
    int sz = PN.size();
    REP(i,sz){
        ll e = PN[i].second;
        //DB2(PN[i].first,e);
        for (ll d = 1; d < 1000; d++) {
            if (e - d < 0) break;
            e -= d;
            ans++;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
  string s; cin >> s;
  int g = 1, win = 0, lose = 0;
  for(int i = 1; i < s.size(); i++) {
    if(s[i] == 'g') {
      if(g > 0) g--, win++;
      else g++;
    } else if(s[i] == 'p'){
      if(g > 0) g--;
      else g++, lose++;
    }
  }
  cout << win - lose << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
ll dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
typedef pair<ll, ll> P;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    // 1の個数と0の個数を交互に記録していく
    // 先頭と最後尾が0のときにも記録する
    vector<ll> num;
    if (s[0] == '0') {
        num.push_back(0);
    }
    for (ll i = 0; i < (ll)s.size();) {
        ll j = i;
        while (j < (ll)s.size() && s[j] == s[i]) {
            ++j;
        }
        num.push_back(j - i);
        i = j;
    }
    if (s.back() == '0') {
        num.push_back(0);
    }

    // 累積和を記録する
    vector<ll> sums((ll)num.size() + 1, 0);
    for (ll i = 0; i < (ll)num.size(); ++i) {
        sums[i + 1] = sums[i] + num[i];
    }

    ll ans = 0;
    // 偶数番目の添字から始まる,長さ2k+1以下の区間の総和のうち,最大値を求める
    for (ll left = 0; left < (ll)sums.size(); left += 2) {
        ll right = left + k * 2 + 1;
        if (right >= (ll)sums.size()) {
            right = (ll)sums.size() - 1;
        }
        ans = max(ans, sums[right] - sums[left]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2116
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s ; cin >> s ;
	ll ans = 0 ;
	for(int i=1;i<s.size();i++) if(s.at(i-1)!=s.at(i)) ans++ ;
	cout << ans << endl ;
}


Measured memory_bytes: 512
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Thu Dec 27 21:10:07 2018
//
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)

	ans := 700
	for i := range S {
		if S[i] == 'o' {
			ans += 100
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>

typedef long long int ll;

using namespace std;

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

    int nac = 0, nwa = 0, ntle = 0, nre = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "AC") nac++;
        if (s == "WA") nwa++;
        if (s == "TLE") ntle++;
        if (s == "RE") nre++;
    }

    cout << "AC x "<< nac << endl;
    cout << "WA x " << nwa << endl;
    cout << "TLE x " << ntle << endl;
    cout << "RE x " << nre << endl;
}

Measured memory_bytes: 3628
def main():
    N, M = map(int,input().split(' '))
    H = list(map(int,input().split(' ')))
    H.insert(0, 0)
    ma = [0]*(N+1)

    for _ in range(M):
        A, B = map(int,input().split(' '))
        ma[A]=max(ma[A],H[B])
        ma[B]=max(ma[B],H[A])

    ans = 0
    for i in range(1,N+1):
        if H[i] > ma[i]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 19928
/*
Owner: dxxrk
Problem: Can't Wait for Holiday
Date: 24/11/2019
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s; cin >> s;
	if(s == "SAT"){
		cout << 1;
	}
	else if(s == "SUN"){
		cout << 7;
	}
	else if(s == "MON"){
		cout << 6;
	}
	else if(s == "TUE"){
		cout << 5;
	}
	else if(s == "WED"){
		cout << 4;
	}
	else if(s == "THU"){
		cout << 3;
	}
	else if(s == "FRI"){
		cout << 2;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  ll A,B,N;
  ll x;
  cin >> A >> B >> N;
  ll min;
  if(B-1 < N) min = B - 1;
  else min = N;
  cout << A * min / B;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=2e5+11;
const int M=3e6+11;
const int W=1e3+11;
const int inf=1e9;
const ll INF=1e18;
const ll mod=1e9+7;
const ld EPS=1e-9;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=(c+b-1)/b;
  int y=(a+d-1)/d;
  if(x<=y)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 3668
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
from collections import deque

MOD = 10**9 + 7
N = int(input())
tree = dict(zip(range(N), [[] for i in range(N)]))
edge_id = {}
c = 0
for i in range(N-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  tree[a].append(b)
  tree[b].append(a)
  edge_id[(a, b)] = c
  edge_id[(b, a)] = c + 1
  c += 2

# 部分木のサイズ
# 頂点v1 -> v2の向きを考えたときに、頂点v2を根とする部分木のサイズを計算する
size = [0] * 2*(N-1)
def calc_size(v1, v2):
  global size
  idx = edge_id[(v1, v2)]
  if size[idx]:
    return size[idx]
  children = tree[v2]
  s = 1
  for child in children:
    if child == v1:
      continue
    s += calc_size(v2, child)
  size[idx] = s
  idx_inv = edge_id[(v2, v1)]
  size[idx_inv] = N - s
  return s

# 階乗、組合せの計算
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
MOD = 10**9+7
for i in range(2, 2*10**5+1):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)

def comb(n, r, mod=MOD):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

# 頂点iに1を書くときの場合の数
ans = [0] * N
dp = [0] * 2*(N-1)
def calc_dp(v1, v2):
  global dp
  idx = edge_id[(v1, v2)]
  if dp[idx]:
    return dp[idx]
  children = tree[v2]
  s = calc_size(v1, v2)
  res = g1[s-1]
  for child in children:
    if child == v1:
      continue
    res *= calc_dp(v2, child)
    res %= MOD
    _s = calc_size(v2, child)
    res *= g2[_s]
    res %= MOD
  dp[idx] = res
  return res

def calc_ans(i):
  global ans
  global dp
  if ans[i]:
    return ans[i]
  children = tree[i]
  res = g1[N-1]
  for child in children:
    res *= calc_dp(i, child)
    res %= MOD
    _s = calc_size(i, child)
    res *= g2[_s]
    res %= MOD
  ans[i] = res
  return res

calc_ans(0)
d = deque([[0, -1]])
c = 0
while d:
  node, par = d.popleft()
  c += 1
  children = tree[node]
  for child in children:
    if child == par:
      continue
    s = calc_size(node, child)
    r = s * pow(N-s, MOD-2, MOD) % MOD
    ans[child] = ans[node] * r % MOD
    d.append([child, node])

print(*ans, sep='\n')

Measured memory_bytes: 186912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int N=1e5+5;
const int MAXN=1e5+5;
const ll inf=0x3f3f3f3f;
char s[5],t[5];
int main(){
    std::ios::sync_with_stdio(false);
    int n,l,r;
    cin>>l>>r;
    int ans=0;
    int tt=0;
    if(r==1) cout<<0<<endl;
    else{
    while(tt<r){
        if(tt!=0) tt--;
        tt+=l;
        //cout<<tt<<endl;
        ans++;
    }
    cout<<ans<<endl;
    }
    return 0;
}





Measured memory_bytes: 256
O=list(input())
E=list(input())
F=[]
if len(O)==len(E):
    for i in range(len(O)):
        F=F+[O[i]]+[E[i]]
else:
    for i in range(len(O)-1):
        F=F+[O[i]]+[E[i]]
    F+=O[len(O)-1]
print(''.join(F))

Measured memory_bytes: 61924
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=2e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
ll arr[MAXN];
vector<ll>edges[MAXN];
set<ll>s;
int main()
{
    ll n;cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>arr[i];
        s.insert(arr[i]);
        edges[arr[i]].push_back(i);
    }
    ll sum=0;
    for(auto v:s)
    {
        ll k=edges[v].size();
        sum+=(k*(k-1))/2;
    }
    for(ll i=1;i<=n;i++)
    {
        ll k=edges[arr[i]].size();
        ll res=sum-(k*(k-1))/2;
        k--;
        res+=(k*(k-1))/2;
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 19072
n = int(input())

ALL = (10 ** n) % (10**9 +7)
wo_0 = (9 ** n) % (10**9 +7)
wo_9 = (9 ** n) % (10**9 +7)
wo_0_9 = (8 ** n) % (10**9 +7)

ans = (ALL - (wo_0 + wo_9 - wo_0_9)) % (10**9 +7)
print(ans)

Measured memory_bytes: 10720
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;

    int cnt = 0;
    for (int n = a; n <= b; n++) {
        if (n / 10000 == n % 10 && (n / 1000) % 10 == (n / 10) % 10) {
            cnt ++;
        }
    }
    put(cnt);
    return 0;
}

Measured memory_bytes: 3560
n, a, b = map(int, input().split()) 

result = 0

def check(n):
    sum = 0
    while n>0 :
        sum += n%10
        n//=10
    return sum

for i in range(n):
    x = check(i+1)
    if a <= x and x <= b:
        result += i+1

print(result)

Measured memory_bytes: 72944
#include <stdio.h>
int main(void) {
  int a, b;

  scanf("%d%d", &a, &b);
  if (a % 2 == 1 && b % 2 == 1) {
    printf("Odd\n");
  } else {
    printf("Even\n");
  }
  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;

  cin >> n;

  set<string> st;

  rep(i, n){
    string s;
    cin >> s;
    st.insert(s);
  }

  cout << st.size() << endl;





  return 0;
}


Measured memory_bytes: 19272
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(void)
{
    string str;
    int alphabet[26];
    for(int i=0; i<26; i++) alphabet[i] = 0;
    while(getline(cin, str))
    {
    for(int i=0; str[i]!='\0'; i++) 
    {
        if((str[i]>='A') && (str[i]<='Z'))
            alphabet[(str[i]-'A')%26]++;
        else if((str[i]>='a') && (str[i]<='z'))
            alphabet[(str[i]-'a')%26]++;
    }
    }
    for(int i=0; i<26; i++)
        printf("%c : %d\n", i+'a', alphabet[i]);
    
    return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>

using namespace std;

#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
constexpr int MOD = 1000000007;

void solve() {
  int N;
  cin >> N;
  vector<int> A(4);
  for(int i = 0; i < N; i++){
    int X;
    cin >> X;
    A[X]++;
  }
  vector<vector<vector<double>>> dp(N + 1, vector<vector<double>>(N + 1, vector<double>(N + 1)));
  //dp[w][x][y] = w 3s, x 2s, y 1s, and N - (x + y + z) 0s
  dp[0][0][0] = 0;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N; j++){
      for(int k = 0; k <= N; k++){
        int Z = N - (i + j + k);
        if(Z == N) continue;
        if(i + j + k > N) continue;
        double val = 1;
        if(i > 0) val += (1.0 * i / N) * dp[i - 1][j + 1][k];
        if(j > 0) val += (1.0 * j / N) * dp[i][j - 1][k + 1];
        if(k > 0) val += (1.0 * k / N) * dp[i][j][k - 1];
        val = val / (1 - (1.0 * Z / N));
        dp[i][j][k] = val;
      }
    }
  }
  cout << setprecision(10) << fixed << dp[A[3]][A[2]][A[1]];
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

Measured memory_bytes: 219920
#include<iostream>
 using namespace std;
 int main(){
 int a=0,b=0,c=0,S;
	cin>>S;
		a=S/3600;
		b=(S-a*3600)/60;
		c=S-a*3600-b*60;
			cout<<a<<":"<<b<<":"<<c<<endl;
return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e17;
const char ENDL = '\n';

ll comb(ll a,ll b){
    ll res = 1;
    rep(i,b){
        res *= a - i;
        res /= (i + 1);
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, a, b;
    cin >> n >> a >> b;
    vll v(n);
    rep(i, n) cin >> v[i];
    sort(all(v),greater<ll>());
    if (v[0]==v[a-1]){
        ll cnt = 0;
        rep(i,n){
            if (v[i]==v[a-1])
                cnt++;
        }
        ll ans = 0;
        repf(i,a,1+min(b,cnt)){
            ans += comb(cnt, i);
        }
        cout << v[a - 1] << ENDL;
        cout << ans << ENDL;
        return 0;
    }
    int cnt1 = 0, cnt2 = 0;
    rep(i,n){
        if (v[a-1]==v[i]){
            if (i<=a-1)
                cnt1++;
            else
                cnt2++;
        }
    }
    ld s = 0;
    rep(i, a) s += v[i];
    cout << fixed << setprecision(17) << s/(ld)(a) << endl;
    cout << comb(cnt1 + cnt2, cnt1) << ENDL;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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 ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class FPathPassI {
public:

    vector<int> graph[200005];
    vector<ll> ans;
    vector<ll> child;
    vector<ll> color;
    vector<ll> par;
    vector<ll> cnt;
    ll all = 0;

    ll dfs(int v, int pa) {
      child[v] = 1;
      ll before = cnt[color[v]];
      for(auto e: graph[v]) {
        if (e == pa) continue;
        ll pre = all-cnt[color[v]];
        child[v] += dfs(e, v);
        ll nxt = all-cnt[color[v]];
        ans[color[v]] -= (nxt-pre+1)*(nxt-pre)/2;
      }
      cnt[color[v]] = before + child[v];
      all++;
      return child[v];
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      color.resize(n);
      ans.resize(n, n*(n+1)/2);
      child.resize(n);
      par.resize(n, -1);
      cnt.resize(n);
      rep(i, n) {
        cin >> color[i];
        color[i]--;
      }
      rep(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
      }

      dfs(0, -1);

      rep(i, n) {
        ll pre = 0;
        ll nxt = n - cnt[i];
        ans[i] -= (nxt-pre+1)*(nxt-pre)/2;
      }

      rep(i, n) {
        cout << ans[i] << '\n';
      }
    }
};

signed main() {
  FPathPassI solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 37560
#include <iostream>
#include <string>

using namespace std;

main(){
    string str1,str2,str3;
    cin >> str1 >> str2 >> str3;
    if(str1[str1.size()-1]==str2[0] and
       str2[str2.size()-1]==str3[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int main() {
    int64_t h, w, n;
    cin >> h >> w >> n;

    vector<vector<int64_t>> t(h);
    for (auto i : irange(0L, n)) {
        int64_t x, y;
        cin >> x >> y;
        --x;
        --y;
        t[x].push_back(y);
    }

    int64_t s = -1;
    for (auto i : irange(0L, h)) {
        if (find(t[i].begin(), t[i].end(), s + 1) == t[i].end()) {
            ++s;
        }

        if (i == h - 1) {
            cout << h << endl;
            return 0;
        }

        if (t[i + 1].empty()) {
            continue;
        }

        if (any_of(t[i + 1].begin(), t[i + 1].end(),
                   [&](int64_t j) { return j <= s; })) {
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	double n, d, c = 0;
	cin >> n >> d;
	while(n--) {
		double x, y;
		cin >> x >> y;
		x = abs(x);
		y = abs(y);
		double dis = pow(x, 2) + pow(y, 2);
		dis = pow(dis, 0.5);
		// cout << dis << endl;
		// cout << c << endl;
		if(dis <= d)
			c++;
	}	
	cout << c << "\n";
}

Measured memory_bytes: 4292
s = gets.chomp
q = gets.to_i
isReverse = false
l, r = "", ""
q.times do
  t = gets.split
  if t[0].to_i == 1
    isReverse = isReverse ? false: true
  else
    f = t[1].to_i
    c = t[2]
    isBack = (f == 1 && isReverse) || (f == 2 && !isReverse)
    if isBack
      r << c
    else
      l << c
    end
  end
end
s = l.reverse + s + r
s.reverse! if isReverse
puts s

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int solve(string s, int idx, bool stuck) {
  if(idx == s.size()) return 0;
  if(!stuck) return 9 * (s.size() - idx);
  int ret = 0;
  for(char ch = '0'; ch <= s[idx]; ch++) {
    ret = max(ret, ch - '0' + solve(s, idx+1, ch == s[idx]));
  }
  return ret;
}

void solve() {
  string s;
  cin >> s;
  cout << solve(s, 0, true) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


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

using namespace std;

#define MOD 1000000007

vector<unordered_map<string, int>> memo(200);
int N;

bool ok(string s) {
  if (s.find("AGC") != string::npos) {
    return false;
  }
  for (int i = 0; i < 3; i++) {
    string copied = s;
    char tmp = copied[i];
    copied[i] = copied[i+1];
    copied[i+1] = tmp;
    if (copied.find("AGC") != string::npos) {
      return false;
    }
  }
  return true;
}

int dfs(int cur, string last) {
  auto it = memo[cur].find(last);
  if (it != memo[cur].end()) {
    return memo[cur][last];
  }
  if (cur == N) return 1;
  int cnt = 0;
  for (auto c : "AGCT") {
    if (c == 0) continue;
    string newstr = last + c;
    if (ok(newstr)) {
      cnt = (cnt + dfs(cur+1, newstr.substr(1))) % MOD;
    }
  }
  memo[cur][last] = cnt;
  return cnt;
}

int main() {
  cin >> N;
  cout << dfs(0, "XXX") << endl;
  return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

#define POS(i,j) ((i)*(n/2)+(j))

void run(void){
  srand((unsigned)time(NULL));
  int n,k;
  scanf("%d%d",&n,&k);
  int *card=(int *)calloc(k*(n/2),sizeof(int));
  int i,j;
  for(i=0;i<k*(n/2);i++) scanf("%d",card+i);
  int *ans=(int *)calloc(n,sizeof(int));
  while(1){
    const int m=100000;
    for(i=0;i<n;i++) ans[i]=rand()%m<m/2?0:1;
    for(i=0;i<k;i++){
      int sum=0;
      for(j=0;j<n/2;j++) sum+=ans[card[POS(i,j)]-1];
      if(!(n/8<=sum && sum<=n*3/8)) break;
    }
    if(i>=k) break;
  }
  for(i=0;i<n;i++) printf("%d",ans[i]);
  printf("\n");
}

int main(void){
  run();
  return 0;
}



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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    string s, t ;
    cin >> s >> t ;
    int ans = 0 ;
    int n = SZ(s) ;
    REP(i,n){
        if(s[i]!=t[i]){
            ans++ ;
        }
    }
    cout << ans <<endl;


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



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

def F(A,B):
    N=len(str(A))
    M=len(str(B))
    if N>=M:
        return N
    else:
        return M

N=int(input())
divisors=make_divisors(N)
ans=float("inf")
for A in divisors:
    B=N//A
    ans=min(ans,F(A,B))
print(ans)

Measured memory_bytes: 9296
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int N, M;
int main(int argc, char const* argv[]) {
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  map<int,int> ans;
  for (size_t i = 0; i < a.size(); i++) {
    cin >> a[i]>>b[i];
    ans[a[i]]++;
    ans[b[i]]++;
  }
for(int i=1;i<=N;i++){
  cout<<ans[i]<<endl;
}
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def insertSort(A, n, g):
    count = 0
    for i in range(g, n):
        v = A[i]
        x = i - g
        while x >= 0 and A[x] > v:
            A[x+g] = A[x]
            x = x - g
            count += 1
        A[x+g] = v
    return count

def shellSort(A, n):
    # 3h+1(... 121, 40, 13, 4, 1) is a good value for G[]
    G = list()
    h = 1
    count = 0
    while h <= n:
        G.append(h)
        h = h*3 + 1
    G = G[::-1] # Reverse
    m = len(G)
    for g in G:
        count += insertSort(A, n, g)

    print(m)
    print(' '.join(map(str, G)))
    print(count)
    for a in A:
        print(a)

n = int(sys.stdin.readline())
A = list()
for i in range(n):
    A.append(int(sys.stdin.readline()))

shellSort(A, n)



Measured memory_bytes: 45524
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k,dp[100101]={};
    string f="First",s="Second";
    cin>>n>>k;
    vector<int>a(n);
    rep(i,0,n){
        cin>>a[i];
    }
    rep(i,0,k+1){
        if(dp[i]){continue;}
        rep(j,0,n){
            if(i+a[j]<=k){dp[i+a[j]]=1;}
        }
    }
    if(dp[k]){cout<<f<<"\n";}
    else{cout<<s<<"\n";}
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 1013
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define IINF 1000000000
#define mp make_pair
#define pb push_back
#define remove pop
#define all(x) x.begin(), x.end()

int n, m;
int costs[MAXN];
vector<int> unlock[MAXN];
int unlockMask[MAXN];

ll dp[MAXN][1<<12]; //min cost


int main() {
	if (fopen("FILENAME.in", "r")) {
		freopen("FILENAME.in", "r", stdin);
		freopen("FILENAME.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		costs[i] = a;

		for (int j = 0; j < b; j++) {
			int v;
			cin >> v;

			unlockMask[i] |= (1 << (v - 1));
		}
	}

	//cout << "wat " << endl;

	for (int i = 0; i <= m; i++) {
		for (int j = 0; j < (1 << n); j++) {
			dp[i][j] = INF;
		}
	}

	dp[0][0] = 0;
	//want dp n 1 << n - 1

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < (1 << n); j++) {
			//Don't select i
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);

			//Select i
			int newmask = j | unlockMask[i];
			dp[i + 1][newmask] = min(dp[i + 1][newmask], dp[i][j] + costs[i]);
		}
	}

	ll ans = dp[m][(1 << n) - 1];

	if (ans == INF) {
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
}

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

int main(){
    int a, b;
    string s;
    cin >> a >> b >> s;

    bool judge = true;
    for(int i = 0; i < a+b+1; i++){
        if(i == a && s[i] != '-')                   judge = false;
        if(i != a && (s[i] < '0' || '9' < s[i]))    judge = false;
    }

    if(judge)   cout << "Yes" << endl;
    else        cout << "No" << endl;
    
    return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    int xtmp, ytmp;
    vector<int> a(n);
    vector<vector<int>> x(n, vector<int>(n-1, 0));
    vector<vector<int>> y(n, vector<int>(n-1, 0));
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
        for(int ia=0;ia<a.at(in);ia++) {
            cin >> xtmp >> ytmp; xtmp--;
            x.at(in).at(ia) = xtmp;
            y.at(in).at(ia) = ytmp;
        }
    }

    int ans = 0;
    bool flg;
    for(int bn=0;bn<(1<<n);bn++) {
        flg = true;
        for(int in=0;in<n;in++) {
            if(!((bn>>in)&1)) continue;
            for(int ia=0;ia<a.at(in);ia++) {
                xtmp = x.at(in).at(ia);
                ytmp = y.at(in).at(ia);
                if(((bn>>xtmp)&1)^ytmp) { 
                    flg = false;
                    // cout << "false" << endl;
                }
            }
        }
        if(flg) {
            int anstmp = 0;
            for(int in=0;in<n;in++) {
                if((bn>>in)&1) anstmp++;
            }
            // cout << anstmp << endl;
            ans = max(ans, anstmp);
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>           // printf(), scanf()
#include <vector>
#include <queue>            // priority_queue
#include <algorithm>        // fill()
#include <utility>          // pair

using namespace std;
static const int MAX_V = 100000;
static const long INF = 1L << 62;

typedef pair<long, int> P;
struct edge
{
	int to;
	int cost;
};

vector<edge> G[MAX_V];
int V;

void
dijkstra(int s)
{
	priority_queue<P, vector<P>, greater<P> > que;
	long d[MAX_V];

	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int u = p.second;
		if (d[u] < p.first)
			continue;

		for (unsigned int v = 0; v < G[u].size(); ++v)
		{
			edge e = G[u][v];
			if (d[u] + e.cost < d[e.to])
			{
				d[e.to] = d[u] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}

	for (int u = 0; u < V; ++u)
	{
		if (d[u] == INF)
			printf("INF\n");
		else
			printf("%ld\n", d[u]);
	}
}

int
main(int argc, char** argv)
{
	edge e;
	int E;
	int r;
	int s, t, d;
	int i;

	scanf("%d %d %d", &V, &E, &r);
	for (i = 0; i < E; ++i)
	{
		scanf("%d %d %d", &s, &t, &d);
		e.to = t;
		e.cost = d;
		G[s].push_back(e);
	}

	dijkstra(r);
	return 0;
}

Measured memory_bytes: 12616