akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define endl "\n"
    #define sz(x) (int)(x).size()
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    ll mod =(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) return 1;
    	if (p == 2 || (p & 1)) return mult(x, binpow(x, p - 1));
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    // bool check(ll x){}
    ll binsearch(ll l,ll r)
    {
        while(l<r)
        {
            ll mid=(l+r)/2;
            // if(check(mid))r=mid;
            // else l=mid+1;
        }
        return l;
    }
    const ll man=(ll)1e3+5;
    vector<ll>adj[man];
    bool vis[man][man];
    ll d[man],depth[man],par[man];
    void addedge(ll u,ll v){adj[u].pb(v);adj[v].pb(u);}
    ll dx[4]={1,-1,0,0};ll dy[4]={0,0,1,-1};
/*........................................................................................................................*/


signed main()/*Check flow...question galat mat padhna */
{
    fast;
    ll x;
    cin>>x;
    cout<<(360)/(__gcd((ll)360,x))<<endl;
    
}



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

def f(S):
    if len(S)%2 != 0:
        return False

    for i in range(0, len(S), 2):
        if S[i:i+2] != 'hi':
            return False

    return True


S = input()
print('Yes' if f(S) else 'No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
    int MOD = 1000000007;
    
    int N; string S, T;
    cin >> N >> S >> T;
    
    long long ans;
    char before;
    
    int i;
    if(S.at(0)==T.at(0)) {
        ans = 3;
        before = '|';
        i = 1;
    }
    else {
        ans = 6;
        before = '=';
        i = 2;
    }
    
    while (i<N) {
        if(S.at(i)==T.at(i)) {
            if(before=='=') ans *= 1;
            else ans *= 2;
            ans %= MOD;
            
            before = '|';
            i++;
        }
        else {
            if(before=='=') ans *= 3;
            else ans *= 2;
            ans %= MOD;
            
            before = '=';
            i+=2;
        }
    }
    
    cout << ans << endl;
}


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

int main(void) {
	string s;
	cin >> s;
	int a = 0, z = 0;
	while(true){
		if(s[a] == 'A')break;
		a++;
	}
	for(int i = a; i < s.length(); i++){
		if(s[i] == 'Z') z = i;
	}
	cout << z-a+1 << endl;
  	return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> optimal(int cnt1, int cnt0) {
	if (cnt1 == 0) return vector<int>(cnt0, 0);
	vector<int> ans;
	for (int i = 0; i < cnt0 + cnt1; ++i) {
		if (i < cnt0 - 1 || (cnt0 % 2 == 0 && i == cnt0 - 1) || (cnt0 % 2 == 1 && i == cnt0)) ans.push_back(0);
		else ans.push_back(1);
	}
	return ans;
}
int main() {
	int N;
	cin >> N;
	vector<int> A;
	int cnt1 = 0, cnt0 = 0;
	for (int i = 0; i < N; ++i) {
		int aval;
		cin >> aval;
		if (aval >= 2) A.push_back(aval);
		if (aval == 1) ++cnt1;
		if (aval == 0) ++cnt0;
	}
	sort(A.begin(), A.end());
	if (cnt1 == 0 && cnt0 % 2 == 1) {
		int prefix = -1;
		if (!A.empty()) {
			prefix = A[0];
			A.erase(A.begin());
			if (A.size() >= 2 && A[A.size() - 2] == 2 && A[A.size() - 1] == 3) swap(A[A.size() - 2], A[A.size() - 1]);
			for (int i = 0; i < A.size(); ++i) cout << A[i] << endl;
		}
		for (int i = 0; i < cnt0; ++i) {
			if (i == cnt0 - 1 && prefix != -1) cout << prefix << endl;
			cout << 0 << endl;
		}
	}
	else {
		if (A.size() >= 2 && A[A.size() - 2] == 2 && A[A.size() - 1] == 3) swap(A[A.size() - 2], A[A.size() - 1]);
		for (int i = 0; i < A.size(); ++i) cout << A[i] << endl;
		vector<int> res = optimal(cnt1, cnt0);
		for (int i : res) cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>
int main(void)
{
	int n,a[200][3],b,i,k,t;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
	}
	for(k=0;k<3;k++){
		for(i=0;i<n-1;i++){
			b=a[i][k];
			for(t=i+1;t<n;t++){
				if(b==0) break;
				else if(b==a[t][k]){
					a[t][k]=0;
					a[i][k]=0;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		k=a[i][0]+a[i][1]+a[i][2];
//		printf("0=%d 1=%d 2=%d\n",a[i][0],a[i][1],a[i][2]);
		printf("%d\n",k);
	}
	return 0;
}

Measured memory_bytes: 2744
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
 
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 <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1005;
LL sum[maxn];
LL v[maxn * (maxn - 1) / 2];
bool vis[maxn * (maxn - 1) / 2];
bitset<45> p[maxn * (maxn - 1) / 2];
LL num[50];
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &sum[i]);
        sum[i] += sum[i - 1];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            v[++cnt] = sum[j] - sum[i];
            LL m = v[cnt], g = 0;
            while (m) {
                if (m & 1){
                    p[cnt].set(g);
                    num[g]++;
                }
                m >>= 1;
                g++;
            }
        }
    }
    for (int j = 44; j >= 0; j--) {
        if(num[j] < k)
            continue;
        for (int i = 1; i <= cnt; i++) {
            if (vis[i])
                continue;
            if (!p[i][j]) {
                vis[i] = true;
                for (int l = 0; l < 45; l++) 
                    if(p[i][l])
                        num[l]--;
            }
        }
    }
    LL ans = (LL(1) << 45) - 1;
    for (int i = 1; i <= cnt; i++) {
        if(vis[i])
            continue;
        ans &= v[i];
        k--;
        if (k == 0)
            break;
    }
    printf("%lld\n", ans);
    return 0;
}

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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; } 
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, pair<T*, int> a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

#ifdef SU1
#define LOG
#endif

const int N = int(1e5) + 5;
int n;
int t[N], a[N];

bool read() {
	if (!(cin >> n))
		return false;
	forn(i, n)
		assert(scanf("%d", &t[i]) == 1);
	forn(i, n)
		assert(scanf("%d", &a[i]) == 1);
	return true;
}

int h[N];

void solve() {
	memset(h, -1, sizeof(h));
	forn(i, n) {
		if (i == 0 || t[i] != t[i - 1])
			h[i] = t[i];
	}
	nfor(i, n) {
		if (i == n - 1 || a[i] != a[i + 1]) {
			if (h[i] != -1 && h[i] != a[i]) {
				puts("0");
				return;
			}
			h[i] = a[i];
		}
	}
	
	forn(i, n) {
		if (h[i] > t[i] || h[i] > a[i]) {
			puts("0");
			return;
		}
	}
	
/*	forn(i, n)
		cerr << h[i] << " ";
	cerr << endl;*/
	
	int res = 1;
	int r = 0;
	forn(i, n) {
		if (h[i] == -1)
			continue;
			
		if (r <= i)
			r = i + 1;
		
		while (r < n && h[r] == -1) {
			++r;
		}
		
		if (r == n)
			break;
			
		int c = r - i - 1;
		forn(_, c)
			res = int((res * 1ll * min(h[i], h[r])) % (int(1e9) + 7));
	}
	
	cout << res << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif
    
    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		ld stime = gett();
		solve();
		cerr << "Time: " << gett() - stime << endl;
		//break;
	}
	
    return 0;
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = (int) s.size();
    int ans = 0;
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n - i - 1]) {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
lint A, B, C, D, E, F, G, H, I, J, K, L, M, N;
lint O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
lint ans = INT64_MAX;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N;
    
    for (lint i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            lint rst = i - 1;
            rst += N / i - 1;
            ans = min(ans, rst);
        }
    }

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

Measured memory_bytes: 256
class Dice:
    def __init__(self, label):
        self.d = label

    def roll(self, direction):
        if direction == "N":
            self.d[0], self.d[1], self.d[5], self.d[4] = self.d[1], self.d[5], self.d[4], self.d[0]
        elif direction == "S":
            self.d[0], self.d[1], self.d[5], self.d[4] = self.d[4], self.d[0], self.d[1], self.d[5]
        elif direction == "E":
            self.d[0], self.d[2], self.d[5], self.d[3] = self.d[3], self.d[0], self.d[2], self.d[5]
        elif direction == "W":
            self.d[0], self.d[2], self.d[5], self.d[3] = self.d[2], self.d[5], self.d[3], self.d[0]
        else:
            pass

label = [int(i) for i in input().split()]
label2 = [int(i) for i in input().split()]

dice1 = Dice(label)
dice2 = Dice(label2)

# ??¨????????¶???(4 * 6)???????????????????????¢??????
cmd = "N" * 4 + ("W" + "N" * 4) * 3 + "NE" + "N" * 4 + "EE" + "N" * 4 

for i in cmd:
    dice2.roll(i)

    if dice1.d == dice2.d:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 7812
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;
 
#define forl(i,a,b) for (int i = a; i <= b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ull a; long double b;
    cin>>a;
    cin>>b;
    long double p = (long double)a*(long double)b;
    ull q = trunc(p);
    cout<<q<<"\n";
    return 0;    
}


Measured memory_bytes: 3752
object Main extends App {
    def find(m: Int, ar: Array[Int]): Int = 
        if(ar(m) == m) m else {ar(m) = find(ar(m), ar); ar(m)}

    def unite(x: Int, y: Int, ar: Array[Int]) = {
        val _x = find(x, ar)
        val _y = find(y, ar)
        if(_x != _y) ar(_x) = _y
    }

    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (Array(n, m) <- in) {
        val a = (0 to n-1).toArray
        in.take(m).foreach(r => unite(r(0), r(1), a))
        val s = in.next.head
        in.take(s).foreach(q => println(if (find(q(0), a) == find(q(1), a)) "yes" else "no"))
    }
}

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

int main() {
	int K;
	cin >> K;
	cout << K / 2 * ((K + 1) / 2);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

偶数がK/2個、奇数が(K+1)/2個あるので、その積が答えになるよ
*/

Measured memory_bytes: 256
D, G = map(int, input().split())
p = [0 for _ in range(11)]
c = [0 for _ in range(11)]

for i in range(D):
    p[i], c[i] = map(int, input().split())

ans = 1e9
for mask in range(1 << D):
    s = 0
    num = 0
    rest_max = -1
    for i in range(D):
        if (mask >> i) & 1:
            s += 100 * (i+1) * p[i] + c[i]
            num += p[i]
        else:
            rest_max = i
    
    if s < G:
        s1 = 100 * (rest_max + 1)
        need = ( G - s + s1 - 1) // s1
        if need >= p[rest_max]:
            continue
        num += need
    ans = min(ans, num)

print(ans)

Measured memory_bytes: 41328
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
vector<int> x;
const int MAX = 16;

vector<vector<int>> calc(vector<int> a, int offset = 0) {
	vector<vector<int>> dp(n + 1, vector<int>(MAX, INF));
	rep(j, MAX) {
		dp[0][j] = 0;
		dp[1][j] = 2 * j + offset;
	}
	for(int i = 1; i < n; ++ i) {
		int s = a[n - 1 - i];
		rep(j, MAX) {
			int t = a[n - i];
			int need = 0;
			while(s > t) {
				++ need;
				t *= 4;
			}
			int add = 0;
			if(need >= MAX) {
				add = (2 * need - 2 * (MAX - 1)) * i;
				need = MAX - 1;
			}
			chmin(dp[i + 1][j], dp[i][need] + j * 2 + offset + add);
			s *= 4;
		}
	}
	return dp;
}

void solve() {
	cin >> n;
	x.resize(n);
	rep(i, n) {
		cin >> x[i];
	}
	auto right = calc(x);
	reverse(all(x));
	auto left = calc(x, 1);
    int ans = INF;
	for(int i = 0; i <= n; ++ i) {
		chmin(ans, left[i][0] + right[n - i][0]);
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 68964
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import fractions
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]

def gcd(nums):
    return reduce(fractions.gcd,nums)

ans = 1
A.sort()
gcd1 = gcd(A)
for i in range(N):
    A[i] //= gcd1

ans *= gcd1

gcd2 = A[0]
for i in range(1,N):
    gcd2 = fractions.gcd(gcd2,A[i])
    if gcd2 == 1:
        key = i
        break

a = copy.deepcopy(A)
a.remove(A[0])
b = copy.deepcopy(A)
b.remove(A[key])

ans *= max(gcd(a),gcd(b))
print(ans)


Measured memory_bytes: 16560
#include <iostream>
int main(){
int a,b,c=1,d=0;
while(c=1){
	std::cin>>a;
	
	int z=-100000;

	if(a==0){
		return 0;
	}
	int aa[a];
	for(int t=1;t<=a;t++){
		std::cin>>b;
	
		aa[t]=b;
	}
    
	for(int s=1;s<=a;s++){
		
			for(int l=s;l<=a;l++){
				d=d+aa[l];
				if(z<d){
					z=d;
				}
			}d=0;
		
		
	}
	std::cout<<z<<std::endl;
	
}
}

Measured memory_bytes: 3104
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        if(n%2 == 1) {
            System.out.println(0);
            return;
        }
        n/=2;
        long res = 0;
        while(n>=5) {
            res += n/5;
            n/=5;
        }
        System.out.println(res);
    }


}




Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main(int argc, char** argv){
  int N,K;
  cin >> N >> K;
  int A[N];
  for(int i = 0; i < N ; i++){
    cin >> A[i];
  }
  int ret;
  ret = 1 + ( N - 2) / ( K - 1 ) ;
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k,cnt;
char c[N];
int main()
{
	scanf("%s",c);
	n=strlen(c);
	if (c[0]==c[n-1])
	{
			for (i=0;i<n;++i) if (c[i]==c[0]) ++cnt;
			cnt+=cnt-1;
	}
	else 
	{
			int now=0;
			for (i=0;i<n;++i)
				if ((now==0&&c[i]==c[0])||(now==1&&c[i]==c[n-1]))
						now^=1,++cnt;
	}
			if ((n-cnt)&1) puts("First");
			else puts("Second");
}


Measured memory_bytes: 384
/*
	不互质的数两两连边
	先手的操作就是对边重定向
	后手到操作是找到最大的拓扑序
*/
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#define N 2005

using namespace std;

int n;
int a[N], deg[N];
bool gra[N][N], vis[N];

inline int gcd(int u, int v) { return v ? gcd(v, u % v) : u; }

void dfs(int u) {
	vis[u] = true;
	for(int v = 1; v <= n; ++v) {
		if(vis[v] || !gra[u][v]) continue;
		gra[v][u] = false, ++deg[v];
	}
	for(int v = 1; v <= n; ++v) {
		if(vis[v] || !gra[u][v]) continue;
		dfs(v);
	}
	return;
}
void topo() {
	priority_queue<int> hp;
	for(int i = 1; i <= n; ++i)
		if(!deg[i]) hp.push(i);
	while(!hp.empty()) {
		int u = hp.top(); hp.pop();
		printf("%d ", a[u]);
		for(int v = 1; v <= n; ++v)
			if(gra[u][v] && !--deg[v])
				hp.push(v);
	}
	putchar('\n');
	return;
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j)
			gra[i][j] = gra[j][i] = (gcd(a[i], a[j]) != 1);
	for(int i = 1; i <= n; ++i)
		if(!vis[i])	dfs(i);
	topo();
	return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	if (a%3==0||b%3==0||(a+b)%3==0){
		printf("Possible\n");
		return 0;
	}
	printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#define int long long
int inv[2000011],fac[2000011],finv[2000011],r1,r2,c1,c2;const int p=1e9+7;
int qpow(int bs,int ex){int ans=1;while(ex){if(ex&1)ans=ans*bs%p;bs=bs*bs%p;ex>>=1;}return ans;}
int c(int n,int m){if(n>m)return 0;return fac[m]*finv[n]%p*finv[m-n]%p;}
int sum(int n,int k){return (n-k+1)*qpow(k+1,p-2)%p*c(k,n+1)%p;}
signed main()
{
	scanf("%lld%lld%lld%lld",&r1,&c1,&r2,&c2);
	inv[1]=1;for(int i=2;i<=2000010;++i)inv[i]=(p*inv[p%i]-p/i*inv[p%i])%p;fac[0]=1;
	for(int i=1;i<=2000010;++i)fac[i]=fac[i-1]*i%p;finv[0]=1;for(int i=1;i<=2000010;++i)finv[i]=finv[i-1]*inv[i]%p;int ans=0;
	for(int i=r1;i<=r2;++i)ans+=((sum(i+c2,i)-sum(i+c1-1,i))%p+p)%p,ans%=p;printf("%lld\n",ans);return 0;
}

Measured memory_bytes: 46976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1];
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	hlist := make([]int, n+1)
	alist := make([]int, m+1)
	blist := make([]int, m+1)
	goodlist := make([]int, n+1)
	var i, omen int

	for i = 1; i <= n; i++ {
		hlist[i] = nextInt()
	}
	for i = 1; i <= m; i++ {
		alist[i] = nextInt()
		blist[i] = nextInt()
		//fmt.Println("hlist[alist[i]], hlist[blist[i]]", hlist[alist[i]], hlist[blist[i]])
		if hlist[alist[i]] <= hlist[blist[i]] {
			goodlist[alist[i]] = -1
		}
		if hlist[alist[i]] >= hlist[blist[i]] {
			goodlist[blist[i]] = -1
		}
	}

	//fmt.Println(goodlist)
	for i = 0; i <= n; i++ {
		if goodlist[i] == -1 {
			omen++
		}
	}
	fmt.Println(n - omen)
}


Measured memory_bytes: 7140
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

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

    return gcd(b,a%b);
}

int main()
{
    faster

    ll a,b;
    cin>>a>>b;

    cout<<(a*b)/gcd(a,b)<<endl;




    return 0;
}


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

int main()
{
  int n;
  string s;

  cin >> n >> s;

  int ans = 0;

  for(int i = 1; i < n; i++){
    int cnt = 0;

    for(char c = 'a'; c <= 'z'; c++){
      bool left = false;
      bool right = false;

      for(int j = 0; j < i; j++){
        if(s[j] == c) left = true;
      }

      for(int j = i; j < n; j++){
        if(s[j] == c) right = true;
      }

      if(left && right) cnt++;

    }

    ans = max(ans, cnt);

  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,sum=0;
  cin>>n;
  long long int arr[n],tot[n+1];
  memset(tot,0,sizeof tot);
  for(int i=0;i<n;i++) {cin>>arr[i];tot[arr[i]]++;}
  for(int i=1;i<=n;i++){
    sum+=tot[i]*(tot[i]-1)/2;
  }
  for(int i=0;i<n;i++){
    cout<<sum-tot[arr[i]]+1<<endl;
  }
}

Measured memory_bytes: 5760
n = int(input())
datA = []
datB = []
buf = []
for i in range(n):
    a,b = map(int, input().split())
    datA.append(a)
    datB.append(b)
    buf.append([a+b,i])
buf.sort(reverse=True)
resA, resB = 0, 0
for i in range(n):
    if i%2 == 0:
        resA += datA[buf[i][1]]
    else:
        resB += datB[buf[i][1]]

print(resA - resB)


Measured memory_bytes: 99168
#include<bits/stdc++.h>
#define rep(i,k,n)     for (ll i = k; i < n; ++i)
#define repr(i,k,n)    for (ll i = k; i >= n; --i)
#define repp(p,a)      for (p=a.begin();p!=a.end();++p)
#define all(a)         a.begin(),a.end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define reppn(p,a,n)    for (p=a.begin();(p+n)!=a.end();++p)
#define F              first
#define S              second
#define ll             long long
#define hell           1000000007
#define god            LLONG_MAX
#define lb             lower_bound
#define ub             upper_bound
#define pb             push_back
#define ct             continue
#define endl           '\n'
#define sp(n)          setprecision(n)
#define srt(a)         sort(all(a))
#define srtd(a)        sort(a.rbegin(),a.rend())
#define sz(a)          ll((a).size())
#define sum(a)         accumulate(all(a),(ll) 0)
#define pdt(a)         accumulate(all(a),double(1),multiplies<double> ())
#define dotpdt(a,b)    inner_product(all(a),b.begin(),0)
#define mkp(a,b)       make_pair(a,b)
#define REP(x,s)       for (auto x : s)
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll t=1;
  //cin>>t;
  while(t--)
  {
     ll n,k;
     cin>>n>>k;
     vector<long double>v;
     rep(i,0,n)
     {
         long double a;
         cin>>a;
         v.pb(a);
     }
     rep(i,0,n)
     {
         v[i]=((v[i]+1)/2.0);
     }
     vector<long double>vans;
     long double ans=0;
     rep(i,0,k)
     {
         ans+=v[i];
     }
     vans.pb(ans);
     rep(i,k,n)
     {
         ans+=v[i];
         ans-=v[i-k];
         vans.pb(ans);
     }
     srt(vans);
     cout<<fixed<<sp(10)<<vans[vans.size()-1];
     
     
  }      
 
 
 return 0;
}

Measured memory_bytes: 12140
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
	#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	#endif
	int t;
	cin >> t;
	while (t--) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		if (a < b) {
			cout << "No\n";
			continue;
		}
		if (d < b) {
			cout << "No\n";
			continue;
		}
		if (b < c + 2) {
			cout << "Yes\n";
			continue;
		}
		a %= b;
		if (a > c) {
			cout << "No\n";
			continue;
		}
		ll r = d % b;
		if (r == 0) {
			r = b;
		}
		ll g = __gcd(r, b);
		ll y = a % g;
		ll w = b - g + y;
		if (w <= c) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
		
	}
	
}


Measured memory_bytes: 256
n, x = map(int, input().split())

l = [0]*(n+1)
l[0] = 1
for i in range(1,n+1):
  l[i] = l[i-1]*2+3

p = [0]*(n+1)
p[0] = 1
for i in range(1,n+1):
  p[i] = p[i-1]*2+1
  
ans = 0  
def bts(a,b):
  global ans
  if b == 1:
    ans += 0
  elif 1 < b < l[a-1]+1:
    bts(a-1,b-1)
  elif b == l[a-1]+1:
    ans += p[a-1]
  elif b == l[a-1]+2:
    ans += p[a-1]+1
  elif l[a-1]+2 < b < l[a-1]*2+2:
    ans += p[a-1]+1
    bts(a-1,b-2-l[a-1])
  else:
    ans += p[a]

bts(n,x)
  
print(ans)


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



int main()
{
    int A, B, C, D, E;
    std::cin  >> A >> B >> C >> D >> E;
    std::vector<int> dishes = {A, B, C, D, E};
    int min_time = (A + B + C + D + E) * 100;
    for(int i = 0; i < 5; ++i){
        int i_time = dishes[i];
        if(i_time % 10 != 0){
            i_time = (i_time/10 + 1) * 10;
        }
        
        for(int j = 0; j < 5; ++j){
            if(j == i)continue;
            int j_time = i_time + dishes[j];
            
            if(j_time % 10 != 0){
              j_time = (j_time/10 + 1) * 10;
             } 
             
            for(int k = 0; k < 5; ++k){
                if(k == i || k == j) continue;
                int k_time = j_time + dishes[k];
               
                if(k_time % 10 != 0){
                    k_time = (k_time/10 + 1) * 10;
                }
                
                for(int l = 0; l < 5; ++l){
                    if(l == i || l == j || l == k) continue;
                    int l_time = k_time + dishes[l];
                    
                    if(l_time % 10 != 0){
                        l_time = (l_time/10 + 1) * 10;
                    }
                    
                    for(int m = 0; m < 5; ++m){
                        if(m == i || m == j || m == k || m == l) continue;
                        int m_time = l_time + dishes[m];
                        
                        if(m_time < min_time) min_time = m_time;
                    }
                }
            }
        }
    }

    std::cout << min_time << std::endl;
    return 0;
}


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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll n,k;cin>>n>>k;
  vector<ll> a(n);
  int i,j;
  rep(i,n)cin>>a[i];
  sort(all(a));
  ll pos=0;
  ll zero=0;
  ll neg=0;
  ll pn=0;
  ll zn=0;
  ll nn=0;
  rep(i,n)
  {
    if(a[i]==0)zn++;
    else if(a[i]>0)pn++;
    else nn++;
  }
  zero=zn*(n*2-(zn+1))/2;
  neg=pn*nn;
  pos=n*(n-1)/2-zero-neg;
  ll ans=0;
  if(k<=neg)
  {
    ll left=-1234567890123456789;
    ll right=-1;
    ll lasok=-1;
    while(left<=right)
    {
      ll mid=(left+right)/2;
      if((right-left)%2!=0)mid--;
      int nowi=0;
      int nowj=nn+zn;
      ll count=0;
      while(nowi<nn&&nowj<n)
      {
        if(a[nowi]*a[nowj]<=mid)
        {
          count+=(n-nowj);
          nowi++;
        }
        else
        {
          nowj++;
        }
      }
      nowi=nn+zn;
      nowj=0;
      while(nowi<n&&nowj<nn)
      {
        if(a[nowi]*a[nowj]<=mid)
        {
          count+=(n-nowi);
          nowj++;
        }
        else
        {
          nowi++;
        }
      }
      count/=2;
      if(count<k)
      {
        left=mid+1;
      }
      else
      {
        lasok=mid;
        right=mid-1;
      }
    }
    ans=lasok;
  }
  else if(k<=neg+zero)
  {
    ans=0;
  }
  else
  {
    ll left=1;
    ll right=1234567890123456789;
    ll lasok=1234567890123456789;
    while(left<=right)
    {
      ll mid=(left+right)/2;
      int nowi=nn-1;
      int nowj=0;
      ll count=0;
      while(nowi>=0&&nowj<nn)
      {
        if(a[nowi]*a[nowj]<=mid)
        {
          count+=(nn-nowj);
          if(nowi>=nowj)count--;
          nowi--;
        }
        else
        {
          nowj++;
        }
      }
      nowi=nn+zn;
      nowj=n-1;
      while(nowi<n&&nowj>=nn+zn)
      {
        if(a[nowi]*a[nowj]<=mid)
        {
          count+=(nowj-nn-zn+1);
          if(nowj>=nowi)count--;
          nowi++;
        }
        else
        {
          nowj--;
        }
      }
      count/=2;
      count+=(zero+neg);
      if(count<k)
      {
        left=mid+1;
      }
      else
      {
        lasok=mid;
        right=mid-1;
      }
    }
    ans=lasok;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int A,B,C;
	int flg = 0;
	scanf("%d %d %d",&A,&B,&C);
	if(A > C){
		if(B < C){
			flg=1;
		}
	}
	if(A < C){
		if(B > C){
			flg=1;
		}
	}
	if(flg==1){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    Main(){
        Scanner sc = new Scanner(System.in);
        int x;
        int y;

        while(true){
            x = sc.nextInt();
            y = sc.nextInt();
            if (x == 0 && y == 0)break;
            System.out.printf("%d %d\n", Math.min(x, y),Math.max(x, y));
        }
    }

    public static void main(String[] args){
        new Main();
    }
}



Measured memory_bytes: 40688
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

// C - Welcome to AtCoder

int main(void) {
    io;
    int total_prob, attemp;
    cin >> total_prob >> attemp;
    int ca = 0; // correct ans
    int at = 0; // total penalty
    int pcnt[total_prob] = {0}; // penalty count
    bool found[total_prob] = { false }; // correct found ?

    rep(i, attemp) {
        int val;
        string s;
        cin >> val >> s;
        val--;
        if (s == "AC" && (found[val] == false)) {
            ca++;
            found[val] = true;
            at += pcnt[val];
        } else {
            pcnt[val]++;
        }

    }
    cout << ca << " " << at;
    return 0;
}


Measured memory_bytes: 4104
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


class Node:
    def __init__(self,value,index):
        self.value = value
        self.index = index

    def __str__(self):
        return 'val : ' + str(self.value) + ' index : ' + str(self.index)

# 0-indexed SegmentTree
class SegmentTree:
    def __init__(self,N,default_list,default_value=INF):
        self.N0 = pow(2,(N-1).bit_length())
        self.nodes = [Node(default_value,i+1-self.N0) for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].value = default_value
            elif N > ind >= 0:
                self.nodes[i].value = default_list[ind]
            else:
                self.nodes[i] = self.process(self.nodes[i*2+1],self.nodes[i*2+2])

    def __getitem__(self,key): # getiten : ST[i]
        return self.nodes[key+self.N0-1].value

    def __setitem__(self,i,x): # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].value = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.process(self.nodes[i*2+1],self.nodes[i*2+2])

    def __str__(self):
        return '['+', '.join(map(str,[self.nodes[i+self.N0-1].value for i in range(self.N0)]))+']'

    def query(self,L,R): #[L,R)の値
        retnode = Node(INF,INF)
        L += self.N0
        R += self.N0
        while L < R:
            if R&1 :
                R -= 1
                retnode = self.process(retnode,self.nodes[R-1])
            if L&1 :
                retnode = self.process(retnode,self.nodes[L-1])
                L += 1
            L >>= 1; R >>= 1
        return retnode

    def process(self,node_x,node_y): #x,yが子の時，親に返る値
        if node_x.value < node_y.value:
            return node_x
        else:
            return node_y


N,M = inpl()

ST = SegmentTree(N,[INF]*N)
ST[0] = 0

LRc = []
for _ in range(M):
    L,R,c = inpl()
    LRc.append((L-1,R-1,c))

LRc.sort()

for L,R,c in LRc:
    MIN = ST.query(L,R+1).value
    if ST[R] > MIN + c:
        ST[R] = MIN + c

if ST[N-1] == INF:
    print(-1)
else:
    print(ST[N-1])


Measured memory_bytes: 132020
void main(){int i,j,n=1<<18;char p[1<<18];for(i=0;i<n;i++)p[i]=(i<2)?0:1;for(i=2;i*i<n;i++)for(j=i*2;j<n;j+=i)p[i]?p[j]=0:0;for(;j=0,scanf("%d",&n),n;printf("%d\n",j))for(i=n+1;i<=2*n;i++)p[i]?j++:0;}

Measured memory_bytes: 0
n,m=map(int,input().split())
xy=[]

for i in range(n):
    a,b=map(int,input().split())
    xy.append((a,b))

xy=sorted(xy)

ans=0
for p,c in xy:
    if m>=c:
        ans+=p*c
        m-=c
    else:
        ans+=p*m
        m=0
        break
print(ans)


Measured memory_bytes: 17788
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 5050;
LL k,q,d[N],a[N];
inline void solve(){
	LL i,n,x,m; LL nn,cnt2 = 0;
	cin >> n >> x >> m; x %= m; nn = n; --nn,--n;
	for (i = 1; i <= k; ++i) a[i] = d[i] % m;
	LL sum = 0,cnt = 0;
	for (i = 1; i <= k; ++i) sum += a[i],cnt2 += (a[i]==0)?(1):(0);
	cnt += sum / m,sum %= m;
	LL t = n / k; n %= k;
	sum *= t,cnt *= t,cnt += sum / m,sum %= m; cnt2 *= t;
	for (i = 1; i <= n; ++i) sum += a[i],cnt2 += (a[i]==0)?(1):(0); sum += x;
	cnt += sum / m,sum %= m;
	cout << nn - cnt - cnt2 << endl;
}
int main(){
	cin >> k >> q;
	int i;
	for (i = 1; i <= k; ++i) cin >> d[i];
	while (q--) solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N;
    if(N%10==9 || N/10==9)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll x,y;
int main(){
	cin >> x >> y;

	ll g[] = {-1,0,2,0,1,0,1,0,0,1,0,1,0};
	if(g[x] == g[y]) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int N;
    scanf("%d",&N);
    char str[10002];
    scanf("%s",str);
    int i=0;
    while(*(str+i)!='\0')
    {
        *(str+i)=(*(str+i)+N>'Z')?(*(str+i)+N-26):(*(str+i)+N);
        i++;
    }
    printf("%s",str);
    return 0;
}


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

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

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

int main(){
    go();

    // code here
    string s,t;cin>>s>>t;
    int cnt = 0;
    forn(0,s.length(),1) if(s[i]!=t[i]) cnt++;
    cout<<cnt;
}






Measured memory_bytes: 3840
#include <iostream>
// #include <vector>
using namespace std;

const int MAX = 100;
const int INFTY = (1 << 21);
int n;
int M[MAX][MAX];

void dijkstra(int s){
  int color[MAX], d[MAX], p[MAX];
  // vector<int> S;
  for(int i=0;i<n;i++){
    color[i] = 0;
    d[i] = INFTY;
    p[i] = -1;
  }
  d[s] = 0;
  p[s] = -1;
  color[0] = 1;

  while(true){
    int mincost = INFTY;
    int u = -1;
    for(int i=0;i<n;i++){
      if(color[i] != 2 && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }

    // if(mincost == INFTY) break;
    if(u == -1) break;
    color[u] = 2;

    // S.push_back(u);
    for(int i=0;i<n;i++){
      if(M[u][i] != -1 && (d[i] > M[u][i] + d[u])){
        d[i] = M[u][i] + d[u];
        color[i] = 1;
        p[i] = u;
      }
    }
  }

  for(int i=0;i<n;i++){
    cout << i << " " << d[i] << endl;
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      M[i][j] = INFTY;

  for(int i=0;i<n;i++){
    int id, k, v, c;
    cin >> id >> k;
    for(int j=0;j<k;j++){
      cin >> v >> c;
      M[id][v] = c;
    }
  }

  dijkstra(0);
  return 0;
}



Measured memory_bytes: 3092
import sys
import math
import fractions
from functools import reduce
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)


S = IS()
K = II()
for i in range(K):
    if S[i] != '1':
        print(S[i])
        exit()
print('1')


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

typedef long long LL;
const int mod = 1000000007, N = 10000005;

int n, inv[N], pow3[N], h[N];
void reduce(int &x) { x += x >> 31 & mod; }

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n, pow3[0] = 1;
	for (int i = 1; i <= n; ++i) {
		inv[i] = i == 1 ? 1 : (LL) (mod - mod / i) * inv[mod % i] % mod;
		pow3[i] = (LL) pow3[i - 1] * (mod + 1) / 3 % mod;
		reduce(h[i] = h[i - 1] + inv[i] - mod);
	}
	int ans = 0;
	for (int i = 1; i < n; ++i) {
		ans = (ans + (LL) pow3[i] * (h[n] - h[n - i] + mod)) % mod;
	}
	ans = (ans * 2LL + (LL) pow3[n - 1] * h[n]) % mod;
	ans = (LL) ans * inv[n] % mod * (mod + 1) / 3 % mod;
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c)
    cout << 1 << endl;
  else if (a == b || b == c || a == c)
    cout << 2 << endl;
  else
    cout << 3 << endl;
}


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

int main(){
        ll i,j,n,m,v,b,c,tmp,cnt,i_pre=0,idx=0,nn=0,ans=0;
        cin >> n >> m;
        vector<ll> a(n);
        vector<pair<ll,ll>> li(m);
        vector<ll> d(n);
        for(i=0;i<n;++i){
                cin >> tmp;
                ans += tmp;
                a.at(i) = tmp;
        }
        sort(a.begin(), a.end());
        for(i=0;i<m;++i){
                cin >> b >> c;
                li.at(i) = make_pair(c, b);
        }
        sort(li.rbegin(),li.rend());
        while(1){
                v = li.at(idx).first;
                cnt = li.at(idx).second;
                for(i=i_pre;i<min(n,i_pre+cnt);++i) d.at(i) = v;
                i_pre = i;
                if(i_pre==n||idx==m-1) break;
                ++idx;
        }
        for(i=0;i<n;++i){
                if(a.at(i)<d.at(i)) ans -= a.at(i)-d.at(i);
                else break;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;
struct node{
	pii v;
	int lc,rc;
}tre[N*19];int tot;
inline pii aww(pii a,int b){
	return (b&1)?mp(max(a.fi,a.se+b),max(a.se,a.fi+b)):mp(a.fi+b,a.se+b);
}
inline bool get(pii a,int b){return b>=0&&((b&1)?(b<=a.se):(b<=a.fi));}
inline pii pmax(pii a,const pii &b){cmax(a.fi,b.fi);cmax(a.se,b.se);return a;}
#define mid ((l+r)>>1)
#define ls tre[o].lc,l,mid
#define rs tre[o].rc,mid+1,r
void add(int O,int &o,int l,int r,int x,pii y){
	tre[o=++tot].v=pmax(tre[O].v,y);
	if(l==r)return;
	if(x<=mid){
		tre[o].rc=tre[O].rc;
		add(tre[O].lc,ls,x,y);
	}else{
		tre[o].lc=tre[O].lc;
		add(tre[O].rc,rs,x,y);
	}
}
pii que(int o,int l,int r,int x){
	if(l==r)return tre[o].v;
	if(x<=mid)return pmax(que(ls,x),tre[tre[o].rc].v);
	return que(rs,x);
}
int rt[N],a[N],h[N],s[N];
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
	tre[0].v.se=-(N<<1|1);
    int n,i,cx=0,mx=0,cy=0,my=0,C,M,b;
    scanf("%d",&n);
    rep(i,1,n){
		scanf("%d",&a[i]);
		if(a[i]>mx){mx=a[i];h[i]=1;}
	}
	mx=0;
	per(i,n,1)add(rt[i+1],rt[i],1,n,a[i],aww(que(rt[i+1],1,n,a[i]),1+h[i]));
	per(i,n,1)s[i]=h[i]+s[i+1];
	if(!get(tre[rt[1]].v,s[1])){puts("-1");return 0;}
	rep(i,1,n){
		C=cx+(a[i]>mx);M=max(mx,a[i]);
		//printf("Y (%d,%d) %d\n",que(rt[i+1],1,n,my).fi,que(rt[i+1],1,n,my).se,C-cy+s[i+1]);
		//printf("X (%d,%d) %d\n",que(rt[i+1],1,n,M ).fi,que(rt[i+1],1,n,M ).se,cy-C+s[i+1]);
		if(get(que(rt[i+1],1,n,my),C-cy+s[i+1])||get(que(rt[i+1],1,n,M),cy-C+s[i+1]))
		{cx=C;mx=M;putchar('0');}else{cy+=(a[i]>my);cmax(my,a[i]);putchar('1');}
	}
    return 0;
}

Measured memory_bytes: 63872
#include <stdio.h>
int n,m,i,j;
int A[100][100],B[100],C[100];
int main(){
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf(" %d",&A[i][j]);
    }
  }
  for(i=0;i<m;i++){
    scanf(" %d",&B[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      C[i]+=A[i][j]*B[j];
    }
    printf("%d\n",C[i]);
  }
  return 0;
}

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

using namespace std;

int main(){
    int sum;
    string n;
    while(true){
        sum =0;
        cin >> n;
        if(n=="0"){break;}
        for(int i=0;i<n.length();i++){
            string t = "";
            t+= n[i];
            sum += atoi(t.c_str());
        }
        cout << sum << endl;
    }

    return 0;
}



Measured memory_bytes: 3156
n = gets.to_i
w = n.times.map{ gets.chomp.to_s }
ans = 'Yes'
(1...n).each do |i|
    if w[i][0] != w[i-1][-1]
        ans = 'No'
        break
    end
end
if ans == 'Yes'
    if w.uniq.count == n
        puts ans
    else
        ans = 'No'
        puts ans
    end
else
    puts ans
end

Measured memory_bytes: 1916