akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second > secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vector<vpll> path; vll A;
//***********//
ll binarySearch(vl V, ll key) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = V.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は V.size()
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;
		if (V[mid] >= key) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	cin >> N >> K;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	ll left = 0; 
	ll right = 1000000000;
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;
		ll key = 0;
		for (i = 0; i < N; i++) {
			key += (A[i]-1) / mid;
		}
		if (key<=K) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	co(right);
}

Measured memory_bytes: 4760
#include <iostream>
#include <vector>
#include <set>
#include <string>
using namespace std;

void finishWithNo() {
    cout << "No" << endl;
    exit(0);
}

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<string> W(N);
    set<string> setW;
    
    for (int i = 0; i< N; i++) {
        string st; cin >> st;
        W[i] = st;
        setW.insert(st);
    }
    
    if (N != (int)setW.size()) {
        finishWithNo();
    }
    
    for (int i = 1; i < N; i++) {
        int endLine = (int)W[i-1].size() - 1;
        if (W[i-1][endLine] != W[i][0]) {
            finishWithNo();
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 504
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

max_j = n - 1
max_diff = r[max_j] - r[max_j - 1]

for i in range(n-3, -1, -1):
    if r[i+1] > r[max_j]:
        max_j = i + 1
    tmp_diff = r[max_j] - r[i]
    if max_diff < tmp_diff:
        max_diff = tmp_diff

print(max_diff)


Measured memory_bytes: 13588
x = int(input())

if x>=400 and x<600:
    print(8)
elif x>=600 and x<800:
    print(7)
elif x>=800 and x<1000:
    print(6)
elif x>=1000 and x<1200:
    print(5)
elif x>=1200 and x<1400:
    print(4)
elif x>=1400 and x<1600:
    print(3)
elif x>=1600 and x<1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> d(D, vector<int>(26));
    rep(i, 26)
    {
        cin >> c[i];
    }
    rep(i, D)
    {
        rep(j, 26)
        {
            cin >> d[i][j];
        }
    }
    rep(i,D){
        cout << i % 26 + 1 << endl;
    }
    return 0;
}

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

int main() {
int k;
string s;
cin >> k >> s;
int m = s.size();
if(m <= k){
cout << s << endl;
return 0;
}
else{
cout << s.substr(0,k )+ "..." << endl;
return 0;
}
}

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

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

int main(){
	ll n ; cin >> n ;
	vvll g(n,vll(0)) ;
	for(int i=1;i<n;i++){
		ll a ; cin >> a ;
		a-- ;
		g.at(a).push_back(i) ;
		g.at(i).push_back(a) ;
	}
	for(int i=0;i<n;i++){
		ll r = g.at(i).size() ;
		cout << (i==0?r:r-1) << endl ;
	}
}


Measured memory_bytes: 16208
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    ll cnt=0,bef=0,h;
    REP(i,N){
        
        cin>>h;
        if(h<bef)cnt+=bef-h;
        if(i>=N-1)break;
        bef=h;
    }
    cnt+=h;
    cout<<cnt;
    //ll t=N*M;
    //cout<<fixed<<setprecision(20)<<N*M<<endl;
    //cout<<fixed<<setprecision(0)<<floor(t);
    //N-=F;
    //cout<<N/(M+F);
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<ll>>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n, d) for (int i = (s); i < (int)(n); i += (d))
#define allpt(v) (v).begin(), (v).end()
#define allpt_c(v) (v).cbegin(), (v).cend()
#define allpt_r(v) (v).rbegin(), (v).rend()

const int mod = 1e9 + 7;

const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(const vector<T> &v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

template <typename T>
void show2dvec(const vector<vector<T>> &v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

template <typename T, typename S>
void show1dpair(const vector<pair<T, S>> &v)
{
    int n = v.size();
    rep(i, n) cout << v[i].first << wsp << v[i].second << rt;
    return;
}

template <typename T, typename S>
void pairzip(const vector<pair<T, S>> &v, vector<T> &t, vector<T> &s)
{
    int n = v.size();
    rep(i, n)
    {
        t.push_back(v[i].first);
        s.push_back(v[i].second);
    }
    return;
}

template <typename T>
void maxvec(vector<T> &v)
{
    T s = v[0];
    int n = v.size();
    rep(i, n - 1)
    {
        if (s > v[i + 1])
        {
            v[i + 1] = s;
        }
        s = v[i + 1];
    }
}

template <typename T, typename S>
bool myfind(T t, S s)
{
    return find(t.cbegin(), t.cend(), s) != t.cend();
}

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

VI cumsum(VI &v)
{
    int s = 0;
    VI ret = {0};

    rep(i, v.size())
    {
        s += v[i];
        ret.push_back(s);
    }
    return ret;
}

void shuffle(VI &v, int t)
{
    int temp = v[t - 1];
    rep(i, t - 1) v[t - 1 - i] = v[t - 2 - i];
    v[0] = temp;
}



int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    int d, d1, d2;
    VI dist(n, 0);
    rep(i, n - 1) rep2(j, i + 1, n)
    {
        //直行
        d1 = j - i;
        //X-Y経由
        d2 = abs(i - x) + abs(j - y) + 1;

        dist[min(d1, d2)]++;
        
    }

    rep2(i, 1, n) cout << dist[i] << rt;

    return 0;
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[200111];
bool f[200111],fix[200111];
bool check(int x)
{
//	cerr<<"solve:"<<x<<endl;
	for(int i=1;i<=n;i++)
	{
		f[i]=a[i]>=x;
	}
//	for(int i=1;i<=n;i++)cerr<<f[i];cerr<<endl;
	f[0]=f[1];f[n+1]=f[n];
	memset(fix,0,sizeof(fix));
	for(int i=1;i<=n+1;i++)
	{
		if(f[i]==f[i-1])
		{
			fix[i]=fix[i-1]=1;
		}
	}
//	for(int i=1;i<=n;i++)cerr<<fix[i];cerr<<endl;
	
	int mid=(n+1)/2;
//	cerr<<"mid="<<mid<<endl;
	if(fix[mid])return f[mid];
	else
	{
		int mn=mod;bool ans;
		for(int i=mid-1;i>=1;i--)if(fix[i]&&mid-i<=mn)mn=mid-i,ans=f[i];
		for(int i=mid+1;i<=n;i++)if(fix[i]&&i-mid<=mn)mn=i-mid,ans=f[i];
		return ans;
	}
}
int main()
{
	geti(n);n=2*n-1;
	for(int i=1;i<=n;i++)geti(a[i]);
	int l=1,r=n;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(check(mid))l=mid+1;
		else r=mid-1;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=15;
int cost[M],a[M][M],res[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		cin>>cost[i];
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	}
	int ans = 1e9;
	for(int mask = 0;mask<(1<<n);mask++)
	{
		for(int i=0;i<m;i++)
			res[i]=0;
		int cs = 0;
		for(int i=0;i<n;i++)
		{
			if((mask&(1<<i))==0)
				continue;
			cs += cost[i];
			for(int j=0;j<m;j++)
				res[j]+=a[i][j];
		}
		bool f=0;
		for(int j=0;j<m;j++)
			if(res[j]<x)
				f=1;
		if(f==0)
			ans=min(ans,cs);
	}
	if(ans==1e9)
		ans=-1;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3664
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int(), M = Reader.Int();
        var E = Enu.Range(0, N).Select(i => new List<int>()).ToArray();
        for (int i = 0; i < M; i++)
        {
            int a = Reader.Int(), b = Reader.Int();
            E[a].Add(b);
        }
        var sorted = TopologicalSort(E);
        foreach (int a in sorted) Console.WriteLine(a);
        Console.ReadLine();
    }


    int[] TopologicalSort(List<int>[] E)
    {
        var seen = new bool[E.Length];
        var sorted = new List<int>();
        Action<int> DFS = null;
        DFS = a =>
        {
            if (seen[a]) return;
            seen[a] = true;
            for (int i = E[a].Count - 1; i >= 0; i--)
                DFS(E[a][i]);
            sorted.Add(a);
        };
        for (int a = E.Length - 1; a >= 0; a--)
            DFS(a);

        sorted.Reverse();
        return sorted.ToArray();
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 11080
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

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...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

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

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int x;
  cin >> x;
  cout << 360 / __gcd(360ll, x) << "\n"; 
}


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

using ll = long long;

void solve(std::string S, std::string T){
    int cnt = 0;
    for(int i = 0;i < S.size();i++)
        if(S[i] != T[i])
            cnt++;
    cout<<cnt<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 4036
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int s[n];
    fill(s, s+n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        s[a-1]++;
        s[b-1]++;
    }

    for (int i = 0; i < n; i++) {
        if (s[i] % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long int LL;
int max(int a,int b){
	return a>b?a:b;
}
int min(int a,int b){
	return a<b?a:b;
}

int main(){
	LL n;
	while(scanf("%lld",&n)!=EOF){
		LL a=n,sum=0;
		while(n){
			sum+=n%10;
			n/=10;
		}
		if(a%sum==0)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
import math

while True:
    data = input().split()
    n, m ,p = int(data[0]),int(data[1]),int(data[2])
    if n == 0 and m == 0 and p == 0: break

    x = []
    pool = 0
    for i in range(n):
        bets = int(input())
        pool += bets * 100 
        x.append(bets)
    winner = m-1
    if x[winner] == 0:
        print(0)
    else:
        eps = 0.000000001
        ans = math.floor(pool*(1-p/100) + eps)
        ans = math.floor(ans / x[winner] + eps)
        print(ans)


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

main(){
  int n,i,ans;
  cin >> n;
  vector<int> a(n),b(n),c(n-1); 
  for(i=0;i<n;i++) cin >> a[i];
  for(i=0;i<n;i++) cin >> b[i];
  for(i=0;i<n-1;i++) cin >> c[i];

  ans=accumulate(b.begin(),b.end(),0);
  for(i=0;i<n-1;i++){
    if(a[i+1]-a[i]==1) ans += c[a[i]-1];
  }
  
  cout << ans << endl;
}
  
  

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932

//typedef long long ll;


int lcm(int a,int b) { return a*b/__gcd(a,b); }
//ll lcm(ll a,ll b) { return a*b/__gcd(a,b); }

/**
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/


int main(){
    int a,b,c,x,y,z,ans;
    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
    z=min(x,y);
    ans=min(a*z+b*z,c*z*2)+min(a*(x-z),c*(x-z)*2)+min(b*(y-z),c*(y-z)*2);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	string s,w="";
	cin>>k>>s;
	vector<string>v(200);
	int len=s.length();
	if(len>k){
		for(int i=0;i<k;i++){
				v[i]=s.substr(i,1);
				w.insert(w.length(),s.substr(i,1));
			}
			w.insert(w.length(),"...");
			cout<<w<<endl;
	}else{
		cout<<s<<endl;
	}



		return 0;
	}


Measured memory_bytes: 3648
K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
d = 0
for i in range(N):
    tmp = abs(A[i] - A[i-1])
    if tmp > K / 2:
        tmp = K - tmp
    if tmp > d:
        d = tmp
print(K - d)

Measured memory_bytes: 26444
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    H,A = LI()
    print(int(H/A) if H%A==0 else int(H/A+1))

main()



Measured memory_bytes: 27156
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll r;
    cin >> r;

    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 256
S = list(map(int, list(input())))

d = {0:{0:0, 1:0}, 1:{0:0, 1:0}}

for i, s in enumerate(S):
  d[i%2][S[i]] += 1


ans = min(d[0][0]+d[1][1], d[0][1]+d[1][0])
print(ans)

Measured memory_bytes: 4652
#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<char, char>;

int main()
{
  int n;
  string s;
  cin >> n >> s;
  // int ans = 0;
  vector<int> freq(3);
  rep(i, n)
  {
    int j = 0;
    if (s[i] == 'G')
      j = 1;
    else if (s[i] == 'B')
      j = 2;
    freq[j]++;
  }
  ll ans = 1;
  rep(i, 3) ans *= freq[i];

  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j < n - 1; j++)
    {
      int k = j + (j - i);
      if (k >= n)
        continue;

      if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k])
      {
        ans--;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
double check(double x1,double y1,double x2,double y2,double x3,double y3);
int main(void){
    double xa,xb,xc,xd,ya,yb,yc,yd;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
        double sq1S=check(xa,ya,xb,yb,xc,yc)+check(xa,ya,xd,yd,xc,yc);
        double sq2S=check(xb,yb,xc,yc,xd,yd)+check(xb,yb,xa,ya,xd,yd);

        double var=sq1S-sq2S;
        if(fabs(var)<=0.01)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

	}
	return 0;
}

double check(double x1,double y1,double x2,double y2,double x3,double y3){
    double ab,bc,ca;
    double S,s;
    ab=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    bc=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    ca=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    s=0.5*(ab+bc+ca);
    S=sqrt(s*(s-ab)*(s-bc)*(s-ca));
    return S;
}

Measured memory_bytes: 1224
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int64

readIntArray ()
|> fun [| x; b; c |] ->
    let a = x |> System.Math.Abs
    if b - a / c < 0L then a - b * c
    else if (b - a / c) % 2L = 1L then (a % c) - c |> System.Math.Abs
    else (a % c) |> System.Math.Abs
|> printfn "%d"


Measured memory_bytes: 30040
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
int main()
{
    string s;
    cin >> s;
    int len = s.length();
    for (int i = 0; i < len; i++)
    {
        cout << 'x' ;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int K = 0;
  
  scanf("%d",&K);
  
  for(int i=0;i<K*3;i++){
    switch(i%3){
        case 0:
          printf("A");
          break;
        
        case 1:
          printf("C");
          break;
        
        case 2:
          printf("L");
          break;
        
        default:
          break;
    }
  }
  
  printf("\n");

  return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    vector<vector<int>> v(n,vector<int>());
    deque<int> su;      // 種類別1個目
    deque<int> deq;     // 2個目以降
    REP(i,n) {
        int t, d; cin >> t >> d;
        t--;
        v[t].emplace_back(d);
    }
    REP(i,n) sort(RALL(v[i]));
    
    ll d1 = 0;
    REP(i,n) {
        if (!v[i].empty()) {
            d1 += v[i].front();
            su.emplace_back(v[i].front());
            FOR(j,1,v[i].size()) deq.emplace_back(v[i][j]);
        }
    }

    sort(ALL(deq));
    sort(RALL(su));

    ll d2 = 0;
    ll kind = su.size();
    if ( kind > k ) {
        while (kind > k) {
            d1 -= su.back();
            kind--;
            su.pop_back();
        }
    } else if (kind < k) {
        FOR(i,kind,k) {
            d2 += deq.back();
            deq.pop_back();
        }
    }

    ll ans = kind * kind + d1 + d2;
    while(!deq.empty()) {
        ll tmp = (kind-1) * (kind-1) + d1 + d2 - su.back() + deq.back();
        if (ans < tmp) {
            kind--;
            d1 -= su.back();
            su.pop_back();
            d2 += deq.back();
            deq.pop_back();
            ans = tmp;
        } else break;
    }
    //cerr << kind << " " << d1 << " " << d2 << endl;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6144
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    q = 1
    for a in A:
        q *= a

    print(sum((q-1) % a for a in A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3560
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = {{typeid(int), "%d"},
                                                      {typeid(ll), "%lld"},
                                                      {typeid(double), "%lf"},
                                                      {typeid(char), "%c"}};

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
	string sa, sb, sc;
	cin >> sa >> sb >> sc;

	char curPlayer = 'a';
	while (true) {
		switch(curPlayer) {
		case 'a':
			if (sa.empty()) {
				cout << "A" << endl;
				return 0;
			}
			curPlayer = sa[0];
			sa.erase(begin(sa));
			break;
		case 'b':
			if (sb.empty()) {
				cout << "B" << endl;
				return 0;
			}
			curPlayer = sb[0];
			sb.erase(begin(sb));
			break;
		case 'c':
			if (sc.empty()) {
				cout << "C" << endl;
				return 0;
			}
			curPlayer = sc[0];
			sc.erase(begin(sc));
			break;
		}
	}
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  auto tFormat = scanType[typeid(T)];
  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	string s;
	cin >> s;
	int g = 0;
	int p = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'g') {
			g++;
		}
		else {
			p++;
		}
	}
	cout << (g - p) / 2;
}

Measured memory_bytes: 512
N,K = list(map(int,input().split()))
data = [list(map(str, input().split())) for _ in range(N)]
base = 10**6

BW_data = [[0 for i in range(2*K)] for i in range(2*K)]

for x,y,c in data:
  x,y = int(x)%(2*K),int(y)%(2*K)
  if c == "B":
    BW_data[y][x] += 1
  else:
    BW_data[y][x] += base

def ACC2(l):
  H = len(l)
  W = len(l[0])
  ret = [[0]*(W+1) for i in range(H+1)]
  for i in range(H):
    for j in range(W):
      ret[i+1][j+1] = ret[i+1][j] + ret[i][j+1] - ret[i][j] + l[i][j]
  return ret

def RANGE_SUM_in_ACC(l,h1,h2,w1,w2):
  return l[h2][w2]-l[h2][w1]-l[h1][w2]+l[h1][w1]

BW_ACC = ACC2(BW_data)

BW_res = [[0 for i in range(2*K)] for i in range(K)]

for j in range(K):
  for i in range(2*K):
    if i<K:
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,j,j+K,i,i+K)
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,0,max(0,j),0,max(0,i))
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,0,max(0,j),min(2*K,i+K),2*K)
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,min(2*K,j+K),2*K,0,max(0,i))
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,min(2*K,j+K),2*K,min(2*K,i+K),2*K)
    else:
      BW_res[j][i] = BW_ACC[-1][-1]-BW_res[j][i-K]
      
ans = 0
for j in range(K):
  for i in range(2*K):
    ans = max(ans,BW_res[j][i]%base+BW_res[j][(i+K)%(2*K)]//base)
print(ans)

Measured memory_bytes: 181604
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp1.ABC._14X._143
{
    class A
    {
        public static void Main()
        {
            string[] inputStr = Console.ReadLine().Split();
            long a = long.Parse(inputStr[0]);
            long b = long.Parse(inputStr[1]);
            Console.WriteLine(Math.Max(a - 2 * b, 0) + "\n");
        }
    }
}


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

#define REP(i,k,n) for(int i=k; i<n; i++)
#define all int i=0; i<n; i++
#define pb push_back
typedef long long int ll;

int main(){
	int n;
	cin>>n;
	int a[n+1];
	int b[n];
	for(int i=0; i<n+1; i++)cin>>a[i];
	REP(i,0,n)cin>>b[i];
	ll ans = 0, k;
	REP(i,0,n){
		k = min(a[i],b[i]);
		ans+=k;
		a[i]-= k;
		b[i]-= k;
		k = min(a[i+1],b[i]);
		ans+= k;
		a[i+1]-=k;
		b[i]-=k;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

ll a[10010];
int main(){
	ll n;
	while(scanf("%lld",&n),n){
		ll s=0;
		rep(i,0,n){
			scanf("%lld",a+i);
			s+=a[i];
		}
		ll ans=0;
		rep(i,0,n)if(a[i]*n<=s)ans++;
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch StringsOfImpurity | diff StringsOfImpurity.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address StringsOfImpurity.cpp && ./a.out

/*
 
 8/18/2019
 
 21:13-
 
 */

const int MAX_N=1e6+1;
string S,T;

int suc[26][MAX_N];
void solve() {
  int N=SZ(S);
  string SS=S+S;
  int NN=SZ(SS);
  REP(c,26)suc[c][NN]=NN+100;
  for(int i=NN-1; i>=0; --i) {
    REP(c,26) suc[c][i]=suc[c][i+1];
    suc[SS[i]-'a'][i]=i+1;
  }
  LL res=0;
  int j=0;
  REP(i,SZ(T)) {
    int c=T[i]-'a';
    int jj=suc[c][j];
    assert(jj<NN);
    res+=jj-j;
    j=jj%N;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S>>T;
  
  map<char,int> cnt;
  FORR(c,S) cnt[c]++;
  FORR(c,T) if(cnt.count(c)==0) {
    cout<<-1<<endl;
    return 0;
  }
  solve();
  
  return 0;
}


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

using namespace std;

int main() {
    string S, T;
    int cnt = 0;
    vector<string> tenki;
    vector<string> yosou;

    cin >> S;
    cin >> T;

    for (int i = 0; i < 3; ++i) {
        char C1, C2;
        C1 = S[i];
        C2 = T[i];
        if (C1 == C2)cnt++;
    }

    cout << cnt << endl;
}

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

using namespace std;
typedef long long ll;
const int N = 100010;
int a[N];
int main()
{
	int n;
	cin>>n;
	int gcd;
	int x;
	cin>>x;
	gcd=x;
	for(int i=2;i<=n;i++) 
	{
		cin>>x;
		gcd=__gcd(gcd,x);
	}
	cout<<gcd<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

bool check(long long num, vector<long long> &h, long long a, long long b) {
    int n = h.size();
    long long cnt = 0;
    FOR(i, 0, n) {
        long long t = h[i];
        t -= num * b;
        if (t <= 0)
            continue;
        long long res = t / (a - b);
        if (t % (a - b))
            res++;
        cnt += res;
        if (cnt > num)
            return false;
    }
    return true;
}

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    vector<long long> h(n);
    FOR(i, 0, n) {
        cin >> h[i];
    }
    long long lb = 0, ub = 1e9;
    while (ub - lb > 1) {
        long long half = (lb + ub) / 2;
        if (check(half, h, a, b))
            ub = half;
        else
            lb = half;
    }
    cout << ub << endl;
    return 0;
}

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

#define Int long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl

int main(){
    int n;
    cin >> n;
    bool flg=true;
    vector<int> t(n+1),x(n+1),y(n+1);
    t[0]=x[0]=y[0]=0;
    for(int i=1;i<=n;i++){
        cin >> t[i] >> x[i] >> y[i];
        int ca = t[i]-t[i-1]-(x[i]-x[i-1])-(y[i]-y[i-1]);
        if(ca%2>0 || ca<0){
            flg=false;
        }
    }

    if(flg)YES;
    else NO;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=1e5+7;
int a[maxn],b[maxn];
vector<int> c;
int x,y,aa,bb,cc;
bool cmp(int d,int e){
    return d>e;
}
int main(){
    cin>>x>>y>>aa>>bb>>cc;
    for(int i=1;i<=aa;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=bb;i++){
        scanf("%d",&b[i]);
    }
    for(int i=1,t;i<=cc;i++){
       scanf("%d",&t);
       c.push_back(t);
    }
    sort(a+1,a+aa+1,cmp);
    sort(b+1,b+bb+1,cmp);
    for(int i=1;i<=x;i++){
        c.push_back(a[i]);
    }
    for(int j=1;j<=y;j++){
        c.push_back(b[j]);
    }
    sort(c.begin(),c.end(),cmp);
    long long ans=0;
    for(int i=0;i<x+y;i++){
        ans+=c[i];
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 6220
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

int sum(string s) {
    reverse(s.begin(), s.end());
    int res = 0, ten = 1;
    REP(i, s.size()) {
        int tmp = (int)s[s.size()-1-i]-48;
        if ( tmp > 0 ) {
            res += tmp * ten;
        }
        ten *= 10;
    }
    return res;
}
int dup(int ns[], int i) {
    REP(j, i) {
        if ( ns[i] == ns[j] ) return j;
    }
    return -1;
}

int main() {
    int a, l;
    stringstream ss;

    while (cin >> a >> l, a || l) {
        int ns[21];

        ns[0] = a;

        REP(i, 20) {
            ss.str("");
            ss << a;
            string tmp = ss.str();
            // cout << tmp << endl;

            // ゼロ埋め
            while(tmp.size() < l) {
                tmp = "0" + tmp;
            }

            // 最大値を出す
            sort(tmp.begin(), tmp.end());
            int big = sum(tmp);

            // 最小値を出す
            reverse(tmp.begin(), tmp.end());
            int sml = sum(tmp);

            ns[i+1] = a = big - sml;
            // cout << big << " " << sml << " " << a << endl;

            // 重複があれば
            int res = dup(ns, i+1);
            if ( res >= 0 ) {
                printf("%d %d %d\n", res, ns[i+1], i+1-res);
                // cout << res << " " << ns[i+1] << " " << i+1-res << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1264
package main

import (
	"fmt"
)

func main() {
	var R int

	fmt.Scan(&R)

	if R < 1200 {
		fmt.Println("ABC")
	}else if R < 2800 {
		fmt.Println("ARC")
	}else {
		fmt.Println("AGC")
	}

}

Measured memory_bytes: 512
from collections import deque
 
N = int(input())
Ass = tuple(deque(map(int, input().split())) for _ in range(N))
 
Q = set(range(N))
ans = -1
while Q:
    ans += 1
    Q2 = Q.copy()
    Q.clear()
    for i in Q2:
        if not Ass[i]:
            continue
        t = Ass[i][0] - 1
        if Ass[t][0] == i + 1:
            Q.add(i)
            Q.add(t)
    for i in Q:
        Ass[i].popleft()

if any(Ass):
    print(-1)
else:
    print(ans)

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

int main(){
    int l,r,n;
    cin >> l >> r;
    n =  r - l + 1;
    if(n >= 2019){
        cout << 0 << endl;
        return 0;
    }
    int A[2019];
    A[0] = l % 2019;
    for(int i = 1;i < n;i++){
        A[i] = A[i - 1] + 1;
    }
    int minv = 2020;
    for(int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            minv = min(minv,A[i] * A[j] % 2019);
        }
    }

    cout << minv << endl;

    return 0;
}

Measured memory_bytes: 256
def f(a, x)
  total = a.inject(0, :+)
  return total if x == 0

  (0..a.size-2).each{|i|
    sum = a[i] + a[i+1]
    if sum > x
      a[i+1] -= [a[i+1], sum - x].min
      if i == 0
        a[i] -= [a[i] + a[i+1] - x, 0].max
      end
    end
  }
  #p a
  total - a.inject(0, :+)
end

N, X = gets.split(" ").take(3).map(&:to_i)
Arr = gets.split(" ").take(N).map(&:to_i)
p f(Arr, X)


Measured memory_bytes: 11404
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2000000;
struct edge{int to,next;}e[maxn];
int n,m,np,first[maxn],deg[maxn][2];
bool color[maxn],del[maxn];
char str[maxn];
void addedge(int u,int v){
	e[++np]=(edge){v,first[u]};
	first[u]=np;
}
void DFS(int i){
	del[i]=1;
	for(int p=first[i];p;p=e[p].next){
		int j=e[p].to;if(del[j])continue;
		if(--deg[j][color[i]]==0)DFS(j);
	}
}
int main(){
	scanf("%d%d%s",&n,&m,str+1);
	for(int i=1;i<=n;i++)color[i]=str[i]-'A';
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		if(u==v)deg[u][color[u]]++;
		else{
			deg[u][color[v]]++;
			deg[v][color[u]]++;
			addedge(u,v);addedge(v,u);
		}
	}
	for(int i=1;i<=n;i++)
	if((!deg[i][0]||!deg[i][1])&&!del[i])DFS(i);
	bool can=0;
	for(int i=1;i<=n;i++)if(!del[i])can=1;
	printf("%s",can?"Yes":"No");
	return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair < int , int > Pi;
typedef pair < ll  , ll  > Pl;

const int INF = (1 << 30) - 1;
const ll LLINF = 1LL << 60;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int mod = 1000000007;
int N;
int A[105], B[105], C[105], D[105];
vector < int > G[205];
bool used[205];
int match[205];

inline void add_edge(int from,int to)
{
    G[from].push_back(to);
    G[to].push_back(from);
}

bool dfs(int v) {
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++) {
        int u = G[v][i],w = match[u];
        if(w < 0 || !used[w] && dfs(w)) { 
            match[u] = v;
            match[v] = u;
            return true;
        }
    }
    return false;
}

int bipartite_matching()
{
    int flow = 0;
    memset(match,-1,sizeof(match));
    for(int v = 0; v < 2 * N; v++) {
        memset(used,0,sizeof(used));
        if(match[v] < 0) {
            flow += dfs(v);
        }
    }
    return (flow);
}

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
    for(int i = 0; i < N; i++) cin >> C[i] >> D[i];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(A[i] < C[j] && B[i] < D[j]) {
                add_edge(i, N + j);
            }
        }
    }
    cout << bipartite_matching() << endl;
    return (0);
}

Measured memory_bytes: 256