akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define RFOR(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[ ";
    for (auto a : v) os << a << " ";
    os << "]";
    return os;
}

int main() {
    int N;
    cin >> N;
    vector<ll> cnt(N + 1, 0);
    for (int i = 2; i <= N; i++) {
        for (int j = i + i; j <= N; j += i) {
            cnt[j]++;
        }
    }

    ll ans = 1;
    FOR(i, 2, N + 1) ans += i * (cnt[i] + 2);

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

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

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

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

    string s;
    cin >> s;
    const ll n = s.size();

    ll ans = 0;
    REP(i, n) FOR(j, i, n) {
        bool flag = true;
        FOR(k, i, j+1) {
            if(s[k]!='A'&&s[k]!='T'&&s[k]!='G'&&s[k]!='C') {
                flag = false;
                break;
            }
        }
        if(flag) chmax(ans, j-i+1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static final int DONE_FLAG = '.';
    public static final int[] dx = { 0, 1, 0, -1 };
    public static final int[] dy = { -1, 0, 1, 0 };
    public static int h, w;
    public static char[][] map;
    public static void depthFirstSearch(int x, int y, char target) {
        if (map[y][x] != target) {
            return;
        }
        map[y][x] = DONE_FLAG;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || w <= nx || ny < 0 || h <= ny) {
                continue;
            }
            depthFirstSearch(nx, ny, target);
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            h = sc.nextInt();
            w = sc.nextInt();
            if (h == 0 && w == 0) {
                break;
            }
            map = new char[h][];
            for (int i = 0; i < h; i++) {
                map[i] = sc.next().toCharArray();
            }
            int count = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    char current = map[i][j];
                    if (current != DONE_FLAG) {
                        depthFirstSearch(j, i, current);
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 29600
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(int argc, char const *argv[]) {
  vector<int> abc(3);
  cin >> abc[0] >> abc[1] >> abc[2];
  sort(abc.begin(), abc.end());
  int shortage = 2 * abc[2] - abc[0] - abc[1];
  if ((abc[1] - abc[0]) % 2 == 0)
    cout << shortage / 2 << endl;
  else
    cout << shortage / 2 + 2 << endl;
  return 0;
}


Measured memory_bytes: 256
num = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())
print(num[a-1])

Measured memory_bytes: 3060
import qualified Data.Set as S
import Data.Array

main = do
  s <- getLine
  t <- getLine
  let ans = compute s t
  print ans

compute :: String -> String -> Int
compute s t
  | not (S.isSubsetOf ts ss) = -1
  | True = loop 0 t 0
  where
    ss = S.fromList s
    ts = S.fromList t
    m = length s
    arr = array (('a',0),('z',m-1)) arrlist
    arrlist = [ ((c,i),f c i d) | c <- ['a'..'z'], (i,d) <- zip [0..] s ]
    f c i d
      | c == d = 1
      | True   = succ $ arr ! (c, mod (succ i) m)
    loop acc [] _ = acc
    loop acc (t:ts) i = loop (acc + d) ts ((i + d) `mod` m)
      where
        d = arr ! (t,i)

{-
sのそれぞれの位置に対して、a-zが何文字後に出現するかというテーブルを高速に作って、
tはその表を辿る感じで数えるのかな。

全ての c in ts に対して、
s!!i == c のとき、arr ! c ! i = 0
s!!i /= c のとき、arr ! c ! i = succ (arr ! c ! (succ i `mod` length s))
-}


Measured memory_bytes: 290792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include<stdlib.h>
#include<cmath>
#include<list>
#define ll long long int
#define lll unsigned long long
using namespace std;
int main()
{char c[200];
scanf("%s",c);
int k=0;
while(k<strlen(c))
{
    if(k%2==0&&(c[k]!='R'&&c[k]!='U'&&c[k]!='D'))
    {
        printf("No\n");
        return 0;
    }
    if(k%2==1&&(c[k]!='L'&&c[k]!='U'&&c[k]!='D'))
    {
        printf("No\n");
        return 0;
    }
    k++;
}
printf("Yes\n");
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long double p[n+1];
  long double dp[n+1][n+1];
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
    cin>>p[i];
    dp[i][0]=0;
    for(int j=1;j<=i;j++){
      dp[i][j-1]=dp[i][j-1]+(1-p[i])*dp[i-1][j-1];
      dp[i][j]=p[i]*dp[i-1][j-1];
    }
  }
  long double ans=0;
  for(int i=n/2+1;i<=n;i++)
    ans+=dp[n][i];
  cout<<fixed<<setprecision(9)<<ans<<'\n';
}

Measured memory_bytes: 140928
#include<bits/stdc++.h>
#define int long long
#define scf(n) scanf("%lld",&n)
#define rep1(n) for(int i=1;i<=n;i++)
#define prf(n) printf("%lld",n)
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)

#define nl printf("\n")
#define spc printf(" ")
#define file freopen("in.txt","rt",stdin)
#define pii pair<int,int>
#define piii pair<pii,int>
#define MOD 10000007
using namespace std;

/*bool sortBySec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/******************************************/

/***********************************/
int n;
int arr[55];
bool isOK()
{
    bool ok = true;
    for(int i=0; i<n-1; i++)
    {
        if(arr[i]>arr[i+1])
            return false;
    }
    return ok;
}



int32_t main()
{


    /***********************************/
//#ifdef ONPC
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//#endif
//    //faster();

    /*********************************/
    sci(n);
    for(int i=0; i<n; i++)
    {
        sci(arr[i]);
    }
    if(isOK())
    {
        printf("YES\n");
        return 0;
    }
    for(int i=0; i<n-1; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            if(arr[i]>arr[j])
            {
                swap(arr[i],arr[j]);
                if(isOK())
                {
                    printf("YES\n");
                    return 0;
                }
                else
                {
                    swap(arr[j],arr[i]);
                }
            }
        }
    }
    printf("NO\n");




    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int A, B;
  cin >> A >> B;

  if (A < 10 && B < 10) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    if(c - a - b <= 0){
        cout << "No" << '\n';
    }else{
        cout << (4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No") << '\n';
    }
}
/*
a + 2√ab + b < c
2√ab < c - a - b
4ab < ()2
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,dp[250002],a[250002],ans,b[250002];
#define re register
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
inline int pos(re int x,re int y){
	return (x-1)*n+y;
}
inline void dfs(re int x,re int y,re int z=0){
	if(y>=dp[x]&&z)return;
	dp[x]=y;if(!b[x])++y;
	if(x>n)dfs(x-n,y,1);
	if(x<=n*n-n)dfs(x+n,y,1);
	if(x%n!=1)dfs(x-1,y,1);
	if(x%n)dfs(x+1,y,1);
}
int main(){
	n=read();
	for(re int i=1;i<=n*n;++i)a[i]=read();
	for(re int i=1;i<=n;++i)for(re int j=1;j<=n;++j)dp[(i-1)*n+j]=min(i-1,min(j-1,min(n-i,n-j)));
	for(re int i=1;i<=n*n;++i){
		ans+=dp[a[i]];b[a[i]]=1;
		dfs(a[i],dp[a[i]]);
	}
	printf("%d",ans);
}


Measured memory_bytes: 25604
from collections import deque

N = int(input())

stack = deque()
num_753 = 0


def dfs():
    global stack, num_753

    s = stack.pop()

    if int(s) > N:
        return

    is_contained = 1 if all(s.count(c) > 0 for c in '753') else 0
    num_753 += is_contained

    for next_s in '357':
        stack.append(s + next_s)


stack.append('0')
while stack:
    dfs()

# Output
print(num_753)


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  priority_queue<ll>que;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    que.push(a);
  }
  ll ans=0;
  while(que.top()+ans>=n){
    ll num=que.top()+ans;
    que.pop();
    ll cnt=num/n;
    //cout<<cnt<<endl;
    que.push((num-(num/n)*n)-ans-cnt);
    ans+=cnt;
  }
  cout<<ans<<endl;
  return 0;
}


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


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    FOR(i,0,n){
      ll in;
      cin>>in;
      if(in >= k)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
using ld = long double;
using ulli = unsigned long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(args...) do {cerr << #args << " : "; debug(args); } while(0)
#define all(v) ((v).begin()),((v).end())
#define size(x) (int) x.size() 
#define pb emplace_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
void debug () {cerr << endl;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template < typename T, typename ... hello>void debug( T arg, const hello &... rest) {cerr << arg << ' ';debug(rest...);}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    map<lli,lli> count;
    lli sum = 0;
    int n;
    cin >> n;
    for(int i = 1;i <= n; i++){
		lli in;
		cin >> in;
		sum += in;
		count[in] += 1;
	}
	int q;
	cin >> q;
	for(int i = 1;i <= q; i++){
		lli x,y;
		cin >> x >> y;
		if(count[x] > 0){
			sum -= count[x] * x;
			sum -= count[y] * y;
			count[y] += count[x];
			sum += count[y] * y;
			count[x] = 0;
		}
		cout << sum << "\n";
	}
}


//~ 1 2 3 4 = 10
//~ 2 2 3 4 = 11
//~ 2 2 4 4 = 12
//~ 4 4 4 4 = 16


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

int main(){
    int N,K;
    cin >> N >> K;
    int x;
    int length=0;
    for(int i=0; i<N; i++){
        cin >> x;
        if(K-x>x){
            length+=2*x;
        }
        else{
            length+=2*(K-x);
        }
    }
    cout << length << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
using namespace std;
int main()
{
    string a;
    cin>>a;
    if(a=="Sunny")
        printf("Cloudy\n");
    else if(a=="Rainy")
        printf("Sunny\n");
    else if(a=="Cloudy")
        printf("Rainy\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<cmath>
#include<iomanip>
using namespace std;

const double PI  =3.141592653589793238463;
#define pb push_back
#define pf push_front
#define sz(v)  ((int)(v).size());
#define all(v) ((v).begin()),((v).end())
typedef unsigned long long ull;
typedef long long ll;

typedef vector<int> vi;
typedef pair<int,int> pi;
//2 7 3 4 9

void printVec(vi v1)
{
    for(int i=0; i<v1.size(); i++)
        cout<<v1[i]<<" ";
    cout<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);


 ll n;cin>>n;
 map<ll,ll>MAP;
 ll new_n=sqrt(n);

for(ll x=1;x<=new_n;x++){
    for(ll y=1;y<=new_n;y++){
        for(ll z=1;z<=new_n;z++){
    ll v=(x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(x*z);
    if(v>n){
        break;
    }
    MAP[v]++;

}
}
}

for(int i=1;i<=n;i++){
    cout<<MAP[i]<<endl;
}
    return 0;

}


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

using namespace std;


int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> dev(0);
    
    for (int x = 1; x <= min(a,b); x++){
        if (a % x == 0 && b % x == 0)
            dev.push_back(x);
    }
    cout << dev.at(dev.size() - k) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N, M;
    cin >> N >> M;

    vvi G(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    vi res(N);
    vi dis(N, INF);
    dis[0] = 0;
    priority_queue<P, V(P), greater<P>> q;
    q.push(P(0, 0));
    while(!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.se;
        if(dis[v] > p.fi) continue;
        rep(i, G[v].size()) {
            if(p.fi+1 < dis[G[v][i]]) {
                res[G[v][i]] = v+1;
                dis[G[v][i]] = p.fi+1;
                q.push(P(dis[G[v][i]], G[v][i]));
            }
        }
    }

    cout << "Yes" << endl;
    rep(i, N-1) {
        cout << res[i+1] << endl;
    }



    return 0;
}

Measured memory_bytes: 14860
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	ll n, m;
	cin >> n >> m;
	map<ll, ll> mp;
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		mp[a] += b;
	}
	ll ans = 0;
	for (auto c : mp) {
		ll b = min(m, c.second);
		ans += b * c.first;
		m -= b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    double D, E;
    while (1)
    {
        cin >> D >> E;
        if (D == 0)
            break;
        double ans = INF;
        for (double i = 0; i <= D; i++)
        {
            double d = i * i + (D - i) * (D - i);
            double x = sqrt(d), y = abs(x - E);
            ans = min(ans, y);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+10;
int a[N];
int w[N];
char s[N];
char t[N];
int cmp1(int a,int b)
{
    return b<a;
}
multiset<int> ss;
map<int,int>mp;
int main()
{

    int n;
    //cin>>n;
    scanf("%s",s);
    scanf("%s",t);
    int ans=0;
    for(int i=0;i<strlen(s);i++){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
    //for(int i=1;i<=n;i++) cin>>a[i];
}


Measured memory_bytes: 4068
n, k = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7

C1 = [0]*n
C2 = [0]*n

for i in range(n):
    for j in range(n):
        if A[i] > A[j]:
            if j >= i:
                C1[i] += k*(k+1)//2
            else:
                C2[i] += (k-1)*k//2
ans = 0
#print(C1)
#print(C2)
for i in range(n):
    ans += C1[i]+C2[i]
print(ans%mod)


Measured memory_bytes: 42588
a, b, c, x, y = list(map(int, input().split(" ")))

ans = []
ans.append(x * a + y * b)
if(x < y):
    ans.append(x * 2 * c + (y - x) * b)
else:
    ans.append(y * 2 * c + (x - y) * a)
ans.append(max(x, y) * 2 * c)

print(min(ans))

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0513
AC
"""
import sys
from sys import stdin
from itertools import chain
input = stdin.readline


def flatten(listOfLists):
    "Flatten one level of nesting"
    return chain.from_iterable(listOfLists)


def main(args):
    global cards
    n = int(input())
    m = int(input())

    cards = [x for x in range(1, (2*n)+1)]
    for _ in range(m):
        op = int(input())
        if op == 0:
            # shuffle()
            temp = [[y, b] for y, b in zip(cards[:n], cards[n:])]
            cards = list(flatten(temp))
        else:
            # cut(k)
            cards = cards[op:] + cards[:op]

    print('\n'.join(map(str, cards)))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7776
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    string a, b, c;
    cin >> a >> b >> c;

/*
    cout << a[0] + 'A' - 'a';
    cout << b[0] + 'A' - 'a';
    cout << c[0] + 'A' - 'a' << endl;
*/

    printf("%c%c%c\n", a[0]+'A'-'a',b[0]+'A'-'a',c[0]+'A'-'a' );
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n, a, b;
    std::cin >> n >> a >> b;

    long long ans = n / (a + b) * a + std::min(n % (a + b), a);

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
#include <string.h>
#include <utility>
#include <cstdio>
#include <set>
#include <map>
#include <assert.h>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

#define ll long long
#define LL long long

int main() {
	int w;
	while (cin >> w) {
		int bun = 1;
		int flg = 0;
		while (bun != 1024) {
			if (w % (2 * bun)) {
				if (flg) cout << ' ';
				cout << bun;
				w -= bun;
				flg++;
			}
			bun *= 2;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.math.BigInteger;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = 1;
            while (T-- > 0)
            {
                solveOne(in, out);
            }
        }

        private void solveOne(Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            long[] nums = CPUtils.readLongArray(N, in);
            int MOD = 1_000_000_000 + 7;

            long[] ps = CPUtils.prefixSum(nums);

            BigInteger ans = new BigInteger("" + 0);

            for (int idx = 0; idx < N; idx++)
            {
                ans = ans.add(new BigInteger("" + nums[idx]).multiply(new BigInteger("" + (ps[ps.length - 1] - ps[idx]))));
            }
            out.println(ans.mod(new BigInteger("" + MOD)));
        }

    }

    static class CPUtils
    {
        public static long[] readLongArray(int size, Scanner in)
        {
            long[] array = new long[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextLong();
            }
            return array;
        }

        public static long[] prefixSum(long nums[])
        {
            long[] prefixSum = new long[nums.length];
            prefixSum[0] = nums[0];
            for (int i = 1; i < prefixSum.length; i++)
            {
                prefixSum[i] += prefixSum[i - 1] + nums[i];
            }
            return prefixSum;
        }

    }
}



Measured memory_bytes: 55444
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

long long int L,R;
long long int x=0x3f3f3f3f;
int main(){
    
    scanf("%lld%lld",&L,&R);
    
    
    for(int i=L;i<=min(L+2019,R);i++){
        for(int j=i+1;j<=min(L+2019,R);j++){
            x=min(x,1ll*i*j%2019);
        }
    }
    printf("%lld",x);
    
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

// vars
int a, b, c, d;

void input(){
    cin >> a >> b >> c >> d;
}

void solve(){
    REP(i, 101){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  sort(MY.begin(), MY.end());
  int count=0;
  for(int i=0;i<N-1;i++){
    count+=MY.at(i);
  }
  cout << count+MY.at(N-1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int x, n;
  cin >> x >> n;
//   初期化したものを　範囲0~101の
// 102個用意
  vector<int> d(102);
  rep(i,n) {
    int p;
    cin >> p;
    // フラグを立てる
    d[p] = 1;
  }
//   pair関数int型を持つ
  P ans(99999,-1);
  for (int i = 0; i <= 101; ++i) {
    if (d[i] == 1) continue;
    // 距離の絶対値を求める
    int dif = abs(x-i);
    ans = min(ans, P(dif,i));
  }
//   pairの2爪を出力
  cout << ans.second << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}


template <typename T>
void vecOutPadding(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}

template <typename T>
void matOut(vector<vector<T>>& mat) {
	for (const auto& row : mat) {
		for (const T& col : row)
			cout << col << " ";
		cout << endl;
	}
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	string s;
	cin >> s;
	s.insert(s.begin() + 4, ' ');
	cout << s << endl;

	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    string ans;
    rep(i, s.size()) {
        if(s[i] == '0') ans.push_back('0');
        if(s[i] == '1') ans.push_back('1');
        if(s[i] == 'B' && ans != "") ans.pop_back();
        if(s[i] == 'B' && ans == "") continue;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    ll k, a, b;
	cin >> k >> a >> b;
    string ans = "NG";
  	for(ll i = a; i <= b; i++){
      if(i % k == 0){
       ans = "OK"; 
      }
    }
  cout << ans << endl;
}

Measured memory_bytes: 3620
from collections import Counter
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

cnt = Counter(A)


def comb(n):
    return n * (n - 1) // 2


sumall = 0

for i in cnt.values():
    sumall += comb(i)

for a in A:
    ans = sumall - (cnt[a] - 1)
    print(ans)


Measured memory_bytes: 25912
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val s = readLine
  val subsList = ArrayBuffer.empty[ArrayBuffer[String]]
  var subs = ArrayBuffer.empty[String]
  val targetSet = Set("A", "T", "G", "C")
  
  for (l <- s) {
    if (targetSet contains l.toString) {
      subs += l.toString
    } else {
      subsList += subs
      subs = ArrayBuffer.empty[String]
    }
  }
  subsList += subs

  var maxSize = 0
  for (c <- subsList) {
    maxSize = if (c.size > maxSize) c.size else maxSize
  }
  println(maxSize)
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    string s, t; cin>>s>>t;
    int n=s.size();
    for(int i=0; i<=n; i++){
        rotate(s.begin(), s.begin()+1, s.end());
        if(s==t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

ll c2(ll a){
	return (a-1)*a/2;
}

const int mod = 2019;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint modPow(mint a, int n){
	//cout << a << endl;
	if(n == 1) return a;
	if(n % 2) return a * modPow(a, n-1);
	else return modPow(a*a, n/2);
}

int main(){
	string s; cin >> s;
	reverse(s.begin(), s.end());
	int n = s.size();

	vector<mint> a(n+1);
	vl d(2019);
	d[0] ++;
	mint deg = 10;
	for(int i=0; i<n; i++){
		mint now = (s[i]-'0');
		mint m;
		if(i!=0) m = modPow(deg, i).x;
		else m = 1;
		mint k = now * m;
		a[i+1] = a[i] + k;
		d[a[i+1].x] ++;
	}
	ll ans=0;
	rep(i,2019){
		// cout << d[i] << endl;
		ans += c2(d[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5156
N = int(input())
A = list(map(int, input().split()))
v = {}
c = {}
for i in range(N):
  if A[i] in v:
    v[A[i]] += 1
  else:
    v[A[i]] = 1
x = 0
for i in range(1, N+1):
  _l = v.get(i, 0)
  c[i] = _l * (_l - 1) // 2
  x += c[i]
for i in range(N):
  print(x - (v[A[i]] - 1))

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

int main(void) {
    static char s[4001];
    static char t[4001];
    while(~scanf("%s%s", s, t)) {
        int ans = 0;
        int i, j;
        int slen = strlen(s);
        int tlen = strlen(t);
        static unsigned short dp[4001][4001];
        memset(dp, 0, sizeof dp);
        for(i = 0; i < slen; i++) {
            for(j = 0; j < tlen; j++) {
                if( s[i] == t[j] )
                    dp[i + 1][j + 1] = dp[i][j] + 1;

                if( dp[i + 1][j + 1] > ans)
                    ans = dp[i + 1][j + 1];
            }
        }

        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 31820
#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 REP(i,k,n) for(int i = k; i < n; i++)

#define vi vector<int>
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
    int n,p;
    while(cin >> n >> p,n) {
        int ar[51] = {};
        int i = 0;
        int np = p;
        while(true) {
            if(np != 0) {
                np--;
                ar[i % n]++;
                if(ar[i % n] == p) {
                    cout << i % n << endl;
                    break;
                }
            }else{
                np = ar[i % n];
                ar[i % n] = 0;
            }
            i++;
        }
    }

    return 0;
}



Measured memory_bytes: 3052
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char c[N]; int head[N],vis[N],del[N],tot,d[N][2];
struct Edge{int v,next;Edge(int _v=0,int _n=0):v(_v),next(_n){}}edge[N];
inline void add(int x,int y){edge[++tot]=Edge(y,head[x]);head[x]=tot;}
void dfs(int x)
{	vis[x]=1;
	for(rint i=head[x];i;i=edge[i].next)
	if(!del[to])
	{	if(!vis[to]) dfs(to);
		else printf("Yes"),exit(0);
	}
}
int main()
{	int n,m,x,y; cin>>n>>m; scanf("%s",c+1);
	for(rint i=1;i<=m;i++)
	scanf("%d%d",&x,&y),d[x][c[y]-'A']++,d[y][c[x]-'A']++,add(x,y),add(y,x);
	queue<int> q;
	for(rint i=1;i<=n;i++) if(!d[i][0]||!d[i][1]) del[i]=1,q.push(i);
	while(!q.empty())
	{	int x=q.front(); q.pop();
		for(rint i=head[x];i;i=edge[i].next)
		if(!del[to])
		{	d[to][c[x]-'A']--;
			if(!d[to][0]||!d[to][1]) del[to]=1,q.push(to);
		}
	}
	for(rint i=1;i<=n;i++)// if(!del[i]) printf("Yes");
	if(!del[i]&&!vis[i]) dfs(i);
	printf("No");
	return 0;
}


Measured memory_bytes: 17280
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    while(b <= a) {
    	ans++;
    	b *= 2;
    }
    while(c <= b){
    	ans++;
    	c *= 2;
    }
    if(ans <= k){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
f=lambda:[*map(int,input().split())]
h,w=f()
r=range(10)
c=[f() for _ in r]
C=[0]*10
for _ in range(h):
  for i in f():
    if i>=0: C[i]+=1
m=[c[i][1] for i in r]
for _ in r:
  for i in r:
    for j in r:
      m[i]=min(m[i],c[i][j]+m[j])
print(sum(m[i]*C[i] for i in r))

Measured memory_bytes: 9072
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

LL par[100010];
LL rnk[100010];
LL sz[100010];

void init(LL n){
	for(LL i = 0;i < n;i++){
		par[i] = i;
		rnk[i] = 0;
		sz[i] = 1;
	}
}
LL find(LL x){
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}
void unite(LL x, LL y){
	x = find(x);
	y = find(y);
	if(x == y)  return;
	if(rnk[x] < rnk[y]){
		par[x] = y;
		sz[y] += sz[x];
	}else{
		par[y] = x;
		sz[x] += sz[y];
		if(rnk[x] == rnk[y])  rnk[x]++;
	}
}
bool same(LL x, LL y){
	return find(x) == find(y);
}
LL compsize(LL x){
	x = find(x);
	return sz[x];
}
int main(){
	LL N, M;
	cin >> N >> M;
	vLL a(M), b(M);
	for(int i = 0;i < M;i++)	cin >> a[i] >> b[i];
	init(N);
	vLL ans(M+1);
	ans[M] = N*(N-1)/2;
	for(int i = M-1;i >= 0;i--){
		ans[i] = ans[i+1];
		LL aa = find(a[i]);
		LL bb = find(b[i]);
		if(aa != bb){
			LL asz = compsize(aa);
			LL bsz = compsize(bb);
			unite(aa, bb);
			ans[i] -= asz*bsz;
		}
	}
	for(int i = 1;i <= M;i++)	cout << ans[i] << endl;	
}

Measured memory_bytes: 6016
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    static int k;
    static ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		k = sc.nextInt();
		for (int i = 0; i < n; i++) {
		    graph.add(new ArrayList<>());
		}
		for (int i = 0; i < n - 1; i++) {
		    int a = sc.nextInt() - 1;
		    int b = sc.nextInt() - 1;
		    graph.get(a).add(b);
		    graph.get(b).add(a);
		}
		long ans = kaijo(k, graph.get(0).size() + 1);
		for (int x : graph.get(0)) {
		    ans *= getCount(x, 0);
		    ans %= MOD;
		}
		System.out.println(ans);
   }
   
   static long kaijo(long num, int count) {
       long ans = 1;
       for (int i = 0; i < count; i++) {
           ans *= num - i;
           ans %= MOD;
       }
       return ans;
   }
   
   static long getCount(int idx, int parent) {
       long ans = kaijo(k - 2, graph.get(idx).size() - 1);
       for (int x : graph.get(idx)) {
           if (x == parent) {
               continue;
           }
           ans *= getCount(x, idx);
           ans %= MOD;
       }
       return ans;
   }

}


Measured memory_bytes: 89568
let array_of_string s = Array.init (String.length s) (fun i -> s.[i])

let () =
  read_line ()
  |> array_of_string
  |> Array.fold_left (fun (b, acc) c ->
      (not b, acc +
        match b, c with
        | true, 'p' -> 0
        | true, 'g' -> 1
        | false, 'p' -> -1
        | false, 'g' -> 0)) (false, 0)
  |> snd
  |> Printf.printf "%d\n"

Measured memory_bytes: 5376
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	a = ["pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"]
	n = readline() |> parseInt
	println(a[n%10+1])
end

main()

Measured memory_bytes: 159704
a = input().split()
q = int(a[0]) * 4
h = int(a[1]) * 2
s = int(a[2])
t = int(min([q,h,s]))
d = int(a[3])
b = int(input())

if min([t,d/2]) == t:
  print(int(b * t))
else:
  print(int((b // 2) * d + (b % 2) * t))

Measured memory_bytes: 9096
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<ll> VL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

  int N, M;
  cin >> N >> M;

  int k[M], p[M];
  VI v[M];
  rep(i, M)
  {
    cin >> k[i];
    VI vec;
    rep(j, k[i])
    {
      int s;
      cin >> s;
      vec.push_back(s - 1);
    }
    v[i] = vec;
  }
  rep(i, M)
  {
    cin >> p[i];
  }

  int ans = 0;
  rep(i, 1 << N)
  {
    // cout << "[case] " << bitset<10>(i) << endl;
    bool ok = true;
    rep(j, M)
    {
      int c = 0;
      for (int id : v[j])
      {
        // cout << "[" << j << "] " << id << endl;
        if ((i >> id) & 1)
        {
          // cout << "Hit!!" << endl;
          ++c;
        }
      }
      if ((c % 2) != p[j])
      {
        ok = false;
        break;
      }
    }
    if (ok)
    {
      ++ans;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256