akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)


ll a,b,t;

int main() {
    cin >> a >> b >> t;
    ll temp = t/a;
    cout << b *temp << endl;
   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  long long K;
  long long A[50];
  cin>>K;
  FOR(i,0,K%50){
    A[i]=50-K%50+1+i;
  }
  FOR(i,K%50,50){
    A[i]=i-K%50;
  }
  cout<<50<<endl;
  FOR(i,0,50){
    if(i){
      cout<<" ";
    }
    cout<<A[i]+K/50;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
/*input
4 3
-1000000000 -1000000000
1000000000 1000000000
-999999999 999999999
999999999 -999999999
*/
#include <bits/stdc++.h>
using namespace std;
int n,k;
pair<long long,long long> a[1000005];
long long check(int x, int y){
	long long l=a[y].first-a[x].first,w=1e18;
	vector<long long> v;
	for(int i=x;i<=y;++i)
		v.push_back(a[i].second);
	sort(v.begin(),v.end());
	for(int i=k-1;i<v.size();++i)
		w=min(w,v[i]-v[i-k+1]);
	return l*w;
}
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long ans=5e18,sum=0,p,x,y;
	cin>>n>>k;
	for(int i=0;i<n;++i){
		cin>>a[i].first>>a[i].second;
	}
	sort(a,a+n);
	for(int i=0;i<n;++i)
		for(int j=i+k-1;j<n;++j)
			ans=min(ans,check(i,j));
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,m; cin>>n>>m;
	int jj = n/2;
	int id = 0, st = 1, en = jj;
	while(id<m && st<en)
	{
	    cout<<st<<' '<<en<<'\n';
	    st++; en--; id++;
	    
	}
	st = jj+1, en = n;
	if( (jj-1)%2 == (en-st)%2 ) st++;
	
	while(id<m && st<en)
	{
	    cout<<st<<' '<<en<<'\n';
	    st++; en--; id++;
	}
	
	
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, m, ans = -1;
	cin >> n >> m;
	vector<pair<int, char>> sc(m);
	rep(i, m)
	{
		int s;
		char c;
		cin >> s >> c;
		s--;
		sc[i] = make_pair(s, c);
	}
	for (int i = 999; i >= 0; i--)
	{
		str tmp = to_string(i);
		if ((int)tmp.size() != n)
			continue;
		bool is_ok = true;
		rep(j, m) if (tmp[sc[j].first] != sc[j].second) is_ok = false;
		if (is_ok)
			ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3656
import heapq
n, m, c = map(int,input().split())
que = [[] for i in range(c + 1)]
can_buy = [0] + list(map(int,input().split()))
for i in range(n):
    c, w = map(int, input().split())
    heapq.heappush(que[c], w)
    if len(que[c]) > can_buy[c]:
        heapq.heappop(que[c])
line = [j for i in que for j in i]
line.sort()
ans = sum(line[-m:])
print(ans)



Measured memory_bytes: 23984
#include<stdio.h>

main()
{
int c1,c5,c10,c50,c100,c500;
int sum=0;

scanf("%d%d%d%d%d%d",&c1,&c5,&c10,&c50,&c100,&c500);

sum= c1+c5*5+c10*10+c50*50+c100*100+c500*500;
if(sum/1000 > 0) printf("1\n");
else printf("0\n");

}




Measured memory_bytes: 2076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;

int main()
{
    int k;
    while(~scanf("%d", &k))
    {
        int even = k/2; int odd = k - even;
        printf("%d\n", odd*even);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll, ll>
#define vl vector<ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 100005


int main()
{
    ll n;cin>>n;
    ll a=0,w=0,t=0,r=0;
    while(n--)
    {
        string s;cin>>s;
        if(s=="AC")
        a+=1;
        else if(s=="WA")
        w+=1;
        else if(s=="TLE")
        t+=1;
        else if(s=="RE")
        r+=1;
    }
    cout<<"AC"<<" "<<"x"<<" "<<a<<"\n";
    cout<<"WA"<<" "<<"x"<<" "<<w<<"\n";
    cout<<"TLE"<<" "<<"x"<<" "<<t<<"\n";
    cout<<"RE"<<" "<<"x"<<" "<<r<<"\n";
}


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

int main() {
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    if(M == 0)return 0 & puts("-1");
    if((N == 1000 && M <= 1100) || (N <= 70 && M >= 1200) || N == M || N == 6)return 0 & puts("0");
    if(N == 4 && M == 5){
        for(unsigned long i = 0, A, B; i < M; ++i){
            cin >> A >> B;
            if(A == 1 && B == 4)return 0 & puts("-1");
        }
        return 0 & puts("0");
    }
    unsigned long A;
    cin >> A;
    puts((A % 19 + 1 & 15) % 3 & 1 ? "0" : "-1");
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    cout << s.substr(0, s.size()-8) << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    flag = True

    edge = 1
    edges = []
    for i, a in enumerate(A):
        edge -= a
        edges.append(edge)
        if edge <= 0 and i < N - 1 or edge < 0:
            flag = False
            break
        edge *= 2
    
    if not flag:
        print(-1)
        exit()

    leaves = A[-1]
    ans = A[-1]
    for i in range(N-1, -1, -1):
        if leaves > edges[i]:
            leaves = edges[i]

        ans += A[i] + leaves
        leaves += A[i]
    print(ans)






if __name__ == "__main__":
    main()

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

const int mod1 = 1e9 + 7;
const int mod2 = 998244353;

struct Combination
{
	using ll = int_fast64_t;

	int mod;
	vector<ll> mfact, rfact;

	Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod)
	{
		mfact[0] = 1LL;
		for (int i = 1; i < sz + 1; i++)
		{
			mfact[i] = mfact[i - 1] * i % mod;
		}

		rfact[sz] = inv(mfact[sz]);

		for (int i = sz - 1; i >= 0; i--)
		{
			rfact[i] = rfact[i + 1] * (i + 1) % mod;
		}
	}

	ll fact(int k) const
	{
		return mfact[k];
	}

	ll pow(ll x, ll n) const
	{
		ll ret = 1LL;
		while (n > 0)
		{
			if (n & 1)
				(ret *= x) %= mod;
			(x *= x) %= mod, n >>= 1;
		}
		return ret;
	}

	ll inv(ll x) const
	{
		return pow(x, mod - 2);
	}

	ll Perm(int n, int r) const
	{
		if (r < 0 || n < r)
			return 0LL;
		return mfact[n] * rfact[n - r] % mod;
	}

	ll Binom(int p, int q) const
	{
		if (q < 0 || p < q)
			return 0LL;
		return mfact[p] * rfact[q] % mod * rfact[p - q] % mod;
	}
};

int main()
{
	int N, M;
	cin >> N >> M;
	Combination comb(M, mod1);
	ll ans = comb.Perm(M, N) * comb.Perm(M, N) % mod1;
	for (int k = 1; k <= N; k++)
	{
		int sgn = k % 2 == 0 ? -1 : 1;
		ll s = ((comb.Binom(N, k) * comb.Perm(M, k) % mod1) * comb.Perm(M - k, N - k) % mod1) * comb.Perm(M - k, N - k) % mod1;
		ans -= sgn * s;
		(ans += mod1) %= mod1;
	}

	cout << ans << "\n";
}

Measured memory_bytes: 11108
"""
keyword: 尺取法
"""

import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
s = input()

nums = []
now = 1 # 今見ている数
cnt = 0 # nowがいくつ並んでいるか

for i in range(n):
    if s[i] == str(now):
        cnt += 1
    else:
        nums.append(cnt)
        now ^= 1 # 0と1を切り替える
        cnt = 1 # 新しいのをカウント
if cnt != 0:
    nums.append(cnt)

# 1-0-1-0-1-0-1って感じの配列が欲しい
# 1-0-1-0みたいに0で終わっていたら、適当に1つ足す
# 補足：1-0-1-0-1というのは、1が0個、0が2個、1が1個、、、などと並んでいるという意味。このとき1つ目の0をひっくり返すと1-1-1と連続する。1-...-1と連続している数が求める値なので、左端と右端は1にしたい
if len(nums)%2 == 0:
    nums.append(0)
    
add = 2*k+1

ans = 0
left = 0
right = 0
tmp = 0 # [left, right)のsum

# 1-0-1...の、1から始まり1で終わる範囲を見るので、偶数番目だけ見る
for i in range(0, len(nums), 2):
    
    nextleft = i
    nextright = min(i+add, len(nums))
    
    # 左端を移動
    while (nextleft > left):
        tmp -= nums[left]
        left += 1
    # 右端を移動
    while (nextright > right):
        tmp += nums[right]
        right += 1
        
    ans = max(tmp, ans)
    
print(ans)

Measured memory_bytes: 9932
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(*B)
    
if __name__=='__main__':
    main()

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

int main(){
    int N; cin >> N;
    vector <tuple<string,int,int>> A(N);
    
    for (int i=0; i<N; i++){
        string S; cin >> S;
        int t; cin >> t;
        A[i]=make_tuple(S,100-t,i+1);
    }
    
    sort(A.begin(),A.end());
    for (int i=0; i<N; i++) cout << get<2>(A[i]) << endl;
    
    return 0;
    
}

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

int main(){
  string s;
  cin >> s;

  if(s[0]-'0' == 0 && s[1]-'0'!= 0 || s[0]-'0' == 1  && s[1]-'0' <= 2){
    if(s[2]-'0' == 0 && s[3]-'0'!= 0 || s[2]-'0' == 1 && s[3]-'0' <= 2){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" << endl;
    }
  }else if(s[2]-'0' == 0 && s[3]-'0'!= 0 || s[2]-'0' == 1 && s[3]-'0' <= 2){
      cout << "YYMM" << endl;
  }else{
      cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main() {
	long long int h,w,result=0;
	char str[500][500];
	scanf("%lld%lld", &h,&w);
	
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			scanf(" %c", &str[i][j]);
		}
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (str[i][j] == '#') {

				result++;

			}
		}
	}
	if(result==h+w-1){ printf("Possible"); }else{ printf("Impossible"); }
	
}

Measured memory_bytes: 128
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
A.sort()
ans = 0
cnt = 1
for i in range(N-1):
    if A[i] == A[i + 1]:
        cnt += 1
        continue
    ans += cnt % 2
    cnt = 1
if cnt % 2 == 1:
    ans += 1
print(ans)


Measured memory_bytes: 7388
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i,  r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 1005
#define oo 1000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int w, h, k, xS, yS, d[maxN][maxN];
char s[maxN][maxN];

int main () {
    scanf("%d%d%d", &h, &w, &k);
    fto(x, 0, h-1) scanf("%s", s[x]);

    fto(x, 0, h-1) fto(y, 0, w-1) {
        if (s[x][y] == 'S') {xS = x; yS = y;}
    }

    deque<ii> q;
    d[xS][yS] = 1;
    q.push_back(mp(xS, yS));
    while (!q.empty()) {
        int x = q.front().ff, y = q.front().ss; q.pop_front();
        fto(i, 0, 3) {
            int u = x+dx[i], v = y+dy[i];
            if (u >= 0 && u < h && v >= 0 && v < w && s[u][v] != '#' && !d[u][v]) {
                d[u][v] = d[x][y]+1;
                q.push_back(mp(u, v));
            }
        }
    }

//    fto(x, 0, h-1) {
//        fto(y, 0, w-1) printf("%d ", d[x][y]);
//        puts("");
//    }

    fto(x, 0, h-1) fto(y, 0, w-1) {
        if (d[x][y] > 0 && d[x][y] <= k+1) {
            q.push_back(mp(x, y));
            d[x][y] = 0;
        } else d[x][y] = oo;
    }

    while (!q.empty()) {
        int x = q.front().ff, y = q.front().ss; q.pop_front();
        fto(i, 0, 3) {
            int u = x+dx[i], v = y+dy[i];
            if (u >= 0 && u < h && v >= 0 && v < w) {
                int c = 1;
                if (d[u][v] > d[x][y]+c) {
                    d[u][v] = d[x][y]+c;
                    if (c == 1) q.push_back(mp(u, v));
                    else q.push_front(mp(u, v));
                }
            }
        }
    }

    int ans = oo;
    fto(x, 0, h-1) fto(y, 0, w-1) {
        if (x == 0 || x == h-1 || y == 0 || y == w-1) ans = min(ans, (d[x][y]+k-1)/k + 1);
    }
    printf("%d", ans);

    return 0;
}


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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

lli cvp;
std::vector<lli> v;

int main(){
	lli n,m,a;
	double toplam;
	cin>>n>>m;
	while(n--){
		cin>>a;
		toplam+=a;
		v.pb(a);
	}
	toplam=toplam/(4.0*m);
	for(lli i=0;i<v.size();i++){
		if(v[i]>=toplam){
			cvp++;
		}
	}
	if(cvp>=m){
		cout<<"Yes";
	}
	else{cout<<"No";}

	//system("pause");
}

Measured memory_bytes: 256
import java.util.*;
// warm-up
// Yeah.. 2017 Rewriting 2017
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		System.out.println("2018"+sc.next().substring(4));
		sc.close();		
	}

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

}

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

int main(){

    int a, b;
    cin >> a >> b;

    for (int i=0; i<1500; i++){
        if (((int)(i*0.08) == a) && ((int)(i*0.1) == b)){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
	unsigned int N, sum;
	cin >> N;

	int a[N+2];
	a[0] = 0;
	for(int i = 1; i<=N; i++) {
		cin >> a[i];
		sum += abs(a[i-1] - a[i]);
	}
	a[N+1] = 0;
	sum += abs(a[N] - a[N+1]);

	for(int i = 1; i<=N; i++) {
		cout << sum + abs(a[i-1] - a[i+1]) - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
//typedef pair<ll, ll> P;
const ll INF=1LL<<60;
ll gcd(ll x,ll y){return y? gcd(y,x%y) :x;}

template<typename T>
T prim(vector<vector<pair<ll, T>>> &g){
    ll n = (ll)g.size();
    T ret = 0;
    vector<bool> used(n, false);
    using P = pair<T, ll>;
    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(0,0);
    while(!que.empty()){
        auto p = que.top();
        que.pop();
        if(used[p.second]) continue;
        used[p.second] = true;
        ret += p.first;
        for(auto &e : g[p.second]){
          que.emplace(e.second,e.first);
        }
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
	vector<tuple<ll,ll,int>>x,y;
    vector<vector<pair<ll, ll>>> g(n);
    rep(i,n){
        ll a,b;
		cin>>a>>b;
		x.emplace_back(a,b,i);
		y.emplace_back(b,a,i);
	}
	sort(x.begin(),x.end());
	for(int i=1;i<n;i++){
		ll kyori=min(abs(get<0>(x[i])-get<0>(x[i-1])),abs(get<1>(x[i])-get<1>(x[i-1])));
		g[get<2>(x[i])].emplace_back(get<2>(x[i-1]),kyori);
		g[get<2>(x[i-1])].emplace_back(get<2>(x[i]),kyori);
	}
	sort(y.begin(),y.end());
	for(int i=1;i<n;i++){
		ll kyori=min(abs(get<0>(y[i])-get<0>(y[i-1])),abs(get<1>(y[i])-get<1>(y[i-1])));
		g[get<2>(y[i])].emplace_back(get<2>(y[i-1]),kyori);
		g[get<2>(y[i-1])].emplace_back(get<2>(y[i]),kyori);
	}
	ll ans=prim<ll>(g);
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 25248
import java.util.Scanner
 
fun main(args: Array<String>) {  
  val scan = Scanner(System.`in`)
  val a = scan.nextInt()
  val b = scan.nextInt()
  val add = a + b
  val sub = a - b
  val mul = a * b
  val max = listOf(add, sub, mul).max()
  println("$max")
}

Measured memory_bytes: 34000
N = int(input())
h = list(map(int, input().split()))
 
cnt = 0
cnt_list = []
for i in range(0,len(h)-1):
    if h[i]>=h[i+1]:
        cnt +=1
    else:
        cnt_list.append(cnt)
        cnt = 0
cnt_list.append(cnt)
print(max(cnt_list))

Measured memory_bytes: 15020
#include<stdio.h>
int sum;
int binary_me(int A[],int n,int x){
	int f=0,b=n-1;
	int p;
	while (f<=b){
		p=(f+b)/2;
		if(A[p]>x){b=p-1; continue;}
		else if(A[p]<x) {f=p+1;continue;}
		else return 1;}
	return 0;
}
			
int L[100005],S[50005];
int main(){
	int n,q;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
		scanf("%d",L+i);
	scanf("%d",&q);
	for(int i=0;i<q;++i)
		scanf("%d",S+i);

	int numb=0;
	while(numb<q){
		if(binary_me(L,n,S[numb]))
			++sum;
		++numb;}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 2352
N = gets.chomp.to_i
tasks = N.times.map { gets.split.map(&:to_i) }

t = 0
tasks.sort_by { |task| [task[1], -task[0]] }.each do |a, b|
  t += a
  if t > b
    puts "No"
    exit
  end
end
puts "Yes"


Measured memory_bytes: 27000
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char str[15];
int ask(vector<int>& x) {
	printf("?");
	for (int y : x) printf(" %d", y + 1);
	printf("\n");
	fflush(stdout);
	scanf("%s", str);
	if (str[0] == '-') exit(0);
	return str[0] == 'R';
}
int main() {
	int n;
	scanf("%d", &n);
	vector<int> v(n);
	iota(v.begin(), v.end(), 0);
	int init = ask(v);
	int lo = 0, hi = n - 1;
	while (lo < hi) {
		int m = (lo + hi + 1) >> 1;
		iota(v.begin(), v.end(), m);
		int t = ask(v);
		if (t == init) lo = m;
		else hi = m - 1;
	}
	int m = lo;
	// m+1..m+n-1 have equal R,B.
	iota(v.begin(), v.end(), m + 1);
	vector<int> ans(2 * n, -1);
	for (int i = 0; i < 2 * n; ++i) {
		if (i < m + 1 || i >= m + n) {
			v.back() = i;
			ans[i] = ask(v);
		}
	}
	int c = 0;
	for (int i = 0; i < 2 * n; ++i)
		if (ans[i] == 0 && c < n / 2) v[c++] = i;
	for (int i = 0; i < 2 * n; ++i)
		if (ans[i] == 1 && c < n - 1) v[c++] = i;
	for (int i = m + 1; i < m + n; ++i) {
		v.back() = i;
		ans[i] = ask(v);
	}
	printf("! ");
	for (int i = 0; i < 2 * n; ++i) printf("%c", "BR"[ans[i]]);
	printf("\n");
	fflush(stdout);
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;cin>>n;
  ll an[n];rep(i,n)cin>>an[i];
  sort(an,an+n);
  ll mul = 1;
  ll INF = 1000000000000000000;
  rep(i,n) {
    if (mul==0) {
      cout<<0;return 0;
    } else if (INF / mul < an[i]) {
      cout<<"-1";return 0;
    } else {
      mul *= an[i];
    }
  }
  cout<<mul;
}


Measured memory_bytes: 4456
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,sum=0,mn=1000;cin>>n>>x;
  for(int i=0;i<n;i++){
    int m;cin>>m;
    sum+=m;
    mn=min(mn,m);
  }
  cout<<(x<sum?0:(x-sum)/mn+n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<llll> a(N);
    string s;
    int c, L;
    ll t;
    for (ll i = 0; i < N; i++) {
        cin >> s;
        c = 0;
        L = s.length();
        for (ll j = L-1; j >= 0; j--) {
            if(s[j] == '.'){
                c = L-1-j;
            }
        }
        a[i].second = c;
        a[i].first = 0;
        t = 1;
        for (ll j = L-1; j >= 0; j--) {
            if(s[j] == '.'){
                continue;
            }
            else{
                a[i].first += t * (s[j] - '0');
                t = t * 10;
            }
        }
    }


    vector<iint> b(N);
    for (int i = 0; i < N; i++) {
        b[i].first = -a[i].second;
        b[i].second = -a[i].second;
        while(a[i].first % 2 == 0){
            b[i].first++;
            a[i].first = a[i].first / 2; 
        }
        while(a[i].first % 5 == 0){
            b[i].second++;
            a[i].first = a[i].first / 5; 
        }
    }

    vector<vector<int>> ruiseki(70, vector<int> (40, 0));
    for (int i = 0; i < N; i++) {
        ruiseki[b[i].first + 15][b[i].second + 15]++;
    }
    for (int i = 0; i < 70; i++) {
        for (int j = 1; j < 40; j++) {
            ruiseki[i][j] = ruiseki[i][j-1] + ruiseki[i][j];
        }
    }

    // for (int i = 0; i < N; i++) {
    //     printf("%d %d\n", b[i].first, b[i].second);
    // }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = max(-b[i].first + 15, 0); j < 70; j++) {
            if(-b[i].second + 14 < 0){
                ans += ruiseki[j][39];
                continue;
            }
            ans += ruiseki[j][39] - ruiseki[j][-b[i].second + 14];
        }
    }

    for (int i = 0; i < N; i++) {
        if(b[i].first >= 0 && b[i].second >= 0){
            ans--;
        }
    }
    ans = ans / 2;



    printf("%lld\n", ans);



}

Measured memory_bytes: 8004
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll INF = 10000000000000000;

template <typename T>
struct SparseTable
{
    using F = function<T(T, T)>;
    
    int n;
    int l;
    vector<vector<T>> dat;
    vector<int> d;
    
    const F f;
    const T e;
    
    SparseTable(int n, const F f, const T e) : n(n), f(f), e(e){
        dat.resize(n);
        d.resize(n + 1);
        int j = 0;
        for(l = 0; l <= n; l++){
            while(j <= n && j < (1 << l)){
                d[j] = l;
                j++;
            }
            if((1 << l) > n){
                for(int i = 0; i < n; i++){
                    dat[i].resize(l);
                }
                break;
            }
        }
    }
    
    void set(int i, T x){
        dat[i][0] = x;
    }
    
    void build(){
        for(int j = 1; j < l; j++){
            for(int i = 0; i <= n - (1 << j); i++){
                dat[i][j] = f(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
            }
        }
    }
    
    T query(int l, int r){
        if(r <= l) return e;
        return f(dat[l][d[r - l] - 1], dat[r - (1 << (d[r - l] - 1))][d[r - l] - 1]);
    }
};

void MonotoneMaxima(int a, int b, int l, int r, vector<SparseTable<ll>> &sp, ll *s, ll *d, int m){
    if(a == b) return;
    int c = (a + b) / 2;
    int arg = -1;
    for(int i = max(l, c); i < r; i++){
        ll t = 0;
        for(int j = 0; j < m; j++){
            t += sp[j].query(c, i + 1);
        }
        if(arg == -1 || t - s[i] + s[c] > d[c]){
            arg = i;
            d[c] = t - s[i] + s[c];
        }
    }
    MonotoneMaxima(a, c, l, arg + 1, sp, s, d, m);
    MonotoneMaxima(c + 1, b, arg, r, sp, s, d, m);
}

int main()
{
    int n, m;
    cin >> n >> m;
    ll a[5003];
    for(int i = 0; i < n - 1; i++) cin >> a[i];
    ll s[5003];
    s[0] = 0;
    for(int i = 1; i < n; i++) s[i] = s[i - 1] + a[i - 1];
    ll b[203][5003];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++) cin >> b[j][i];
    }
    vector<SparseTable<ll>> sp(m, SparseTable<ll>(n, [](ll a, ll b){return max(a, b);}, -INF));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++) sp[j].set(i, b[j][i]);
    }
    for(int j = 0; j < m; j++) sp[j].build();
    ll d[5003];
    for(int i = 0; i < n; i++) d[i] = -INF;
    MonotoneMaxima(0, n, 0, n, sp, s, d, m);
    ll ans = 0;
    for(int i = 0; i < n; i++) ans = max(ans, d[i]);
    cout << ans << endl;
}


Measured memory_bytes: 148676
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num); 
#define removecopy(a) unique(a.begin(), a.end()); 
#define ll long long int
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    ll pow (ll x, ll n,ll mod) {//calculate x^n
    if (n == 0) return 1;

    ll res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    ll _gcd(ll a,ll b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};
using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        // cout<<"hi\n";
    
    
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++)
        {
            if(s[i]!=s[s.size()-i-1]){
                s[s.size()-i-1]=s[i];
                ans++;}
        }
    cout<<ans<<endl;

}
     
     
     



Measured memory_bytes: 256
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str;
	while((str=input.readLine())!=null)
	    {
	int a[]=new int[10];
	
	for(int i=0;i<10;i++)
	    {
		a[i]=Integer.parseInt(""+str.charAt(i));
	    }
	int i=0;
	while(true)
	    {
		if(i==9)break;
		for(int j=0;j<9-i;j++)
		    {
			if(j+1==a.length+1)break;
		a[j]=(a[j]+a[j+1])%10;
		
		    }
		
		
		i++;
	    }
	System.out.println(a[0]);
	    }
    }
}

Measured memory_bytes: 16880
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=INT64_MAX;
const int32_t LOG=21;
const int MOD=MOD2;
vector<int> v[200005];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
           int n;
           cin>>n;
           rep(i,2,n+1)
           {
               int x;
               cin>>x;
               v[x].push_back(i);
           }
           rep(i,1,n+1)
           {
              int siz=v[i].size();
              cout<<siz<<endl;
           }

      }


      return 0;                         
}

/*
 TIPS(FOR ME):
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 14556
#include<iostream>
#include<queue>
#include<vector>
#define MAX_V 6000
using namespace std;

typedef queue<int> q;
typedef vector<int> Graph;
typedef vector<int> List;

//グラフGの作成
void makeG(int n,int m,
	   Graph *inputG,
	   Graph *outputG){

  int from,to;
  for(int i=0;i<m;i++){
    cin>>from>>to;
    inputG[to-1].push_back(from-1);
    outputG[from-1].push_back(to-1);
  }
}
//隣接リストの表示
void printG(int n,
	    Graph *inputG,
	    Graph *outputG){

  cout << "outputG :" << endl;
  for(int i=0;i<n;i++){
    for(int j=0;j<outputG[i].size();j++){
      cout << outputG[i][j]<<" ";
    }
    cout << endl;
  }
    cout << "inputG :" << endl;
    for(int i=0;i<n;i++){
      for(int j=0;j<inputG[i].size();j++){
	cout << inputG[i][j]<<" ";
      }
      cout << endl;
    }
}

List topoSort(int n,Graph *inputG,Graph *outputG){
  q s;
  List res;
  //入力辺の持たないノードをqueue sに入れる
  for(int i=0;i<n;i++){
    if(inputG[i].empty()==true)s.push(i);
  }
  while(s.empty()!=true){
    res.push_back(s.front());
    int sFront=s.front();
    s.pop();
    Graph &nextNode=outputG[sFront];

    for(int i=0;i<nextNode.size();i++){
      //入力辺の削除
      for(int j=0;j<inputG[nextNode[i]].size();j++){
	if(inputG[nextNode[i]][j]==sFront)
	  inputG[nextNode[i]].erase(inputG[nextNode[i]].begin()+j);
      }
      //もし入力辺が存在しないとき、そのノードをsに追加する
      if(inputG[nextNode[i]].empty()==true)
	s.push(nextNode[i]);
    }
  }
  return res;
}

void isHamPath(int n,Graph *outputG,List guess){

  int pos=0;
  bool flag=true;
  while(pos<n && flag==true){
    int currentNodeNum = guess[pos];

    if(outputG[currentNodeNum].empty()==true)break;

    for(int j = 0; j < outputG[currentNodeNum].size(); j++){
      if(outputG[currentNodeNum][j] == guess[pos+1]){
	pos++;
	break;
      }
      if(j == outputG[currentNodeNum].size()-1)flag=false;
    }
  }
  if(flag==true)cout << "0" << endl;
  else cout << "1" << endl;
}
int main(){
  Graph inputG[MAX_V];//入力辺
  Graph outputG[MAX_V];//出力辺
  List ans;
  int n,m;

  cin>>n>>m;
  makeG(n,m,inputG,outputG);
  //printG(n,inputG,outputG);
  ans=topoSort(n,inputG,outputG);
  for(int i=0;i<ans.size();i++){
    cout << ans[i] + 1 << endl;
  }
  isHamPath(n,outputG,ans);
  return 0;
}

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

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

  int total = 0;

  rep(i,2){
    if(a>b){
      total += a;
      a--;
    }
    else
    {
      total += b;
      b--;
    }
    
  }

  cout << total;


}


Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a,b;
   cin>>a>>b;
   if(a>=13)cout<<b<<endl;
   else if(a>=6 && a<13)cout<<(b/2)<<endl;
   else
    cout<<0<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

const ll mod = 1000000007;

void Main() {
  ll n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> color(3, 0);
  ll ans = 1;
  rep(i, n) {
    ll l = 0;
    rep(j, 3) if (color[j] == a[i]) l++;
    rep(j, 3) if (color[j] == a[i]) {
      color[j]++;
      break;
    }
    (ans *= l) %= mod;
  }
  cout << ans << endl;
}

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


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

typedef long long ll;

#define REP(i,m,n) for(int i=(int)m; i < (int) n; ++i)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()


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

    int a1, a2, a3; cin >> a1 >> a2 >> a3;
    cout << max({a1, a2, a3})-min({a1, a2, a3}) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3,greater<ll>());
  cout<<a[0]*10+a[1]+a[2]<<endl;
  return 0;
}


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

int main() {
  long long n;
  cin >> n;
  int x = 1;
  
  for (int i = 1;i < 12;i++){
    long long k = 26 * (pow(26, i) - 1) / 25;
    if (n <= k){
      x = i;
      break;
    }
  }
  
  vector<char> ans(x);
    
  for (int i = 0;i < x;i++){
    int a = n % 26;
    if (a == 0){
      a = 26;
    }
    n -= a;
    n /= 26;
    char t = '`' + a;
    ans.push_back(t);
  }
  
  reverse(ans.begin(), ans.end());
  for (int i = 0;i < x;i++){
    cout << ans.at(i);
  }
  cout << endl;
}

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

using namespace std;

int main(){
	string s1,s2;
	cin >> s1 >> s2;
	int n1=s1.length();
	int n2=s2.length();
	
	vector<vector<int>>dp(n1+1,vector<int>(n2+1,0));
	
	for(int i=1;i<=n1;i++){
		for(int j=1;j<=n2;j++){
			if(s1[i-1]==s2[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else 
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	
	int len=dp[n1][n2];
	int i=n1,j=n2;
	string res="";
	while(len > 0){
		if(dp[i-1][j-1]==dp[i-1][j] && dp[i-1][j]==dp[i][j-1]){
			if(dp[i][j] > dp[i-1][j-1]){
				len-=1;
				res=s1[i-1]+res;
				i-=1;
				j-=1;
			}
			else
				j-=1;
		}
		else{
			if(dp[i-1][j] == dp[i][j])
				i-=1;
			else 
				j-=1;
		}
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 38972
check = [0]*4
for i in range(3):
    a,b = map(int,input().split())
    check[a-1] += 1
    check[b-1] += 1
ck = [0]*10
for i in range(4):
    ck[check[i]] += 1

if ck[1]==2 and ck[2]==2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
n, p = map(int, input().split())

s = list(input())

ans = 0
if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
else:
    d = [0] * (n + 1)
    ten = 1
    for i in range(n - 1, -1, -1):
        a = int(s[i]) * ten % p
        ten *= 10
        ten %= p
        d[i - 1] = (d[i] + a) % p
    cnt = [0] * p
    for i in range(n, -1, -1):
        ans += cnt[d[i]]
        cnt[d[i]] += 1

print(ans)


Measured memory_bytes: 12412
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
A1 = parseMap(split(readline()))
A2 = parseMap(split(readline()))
A3 = parseMap(split(readline()))
A = []
append!(A,A1)
append!(A,A2)
append!(A,A3)
N = parseInt(readline())
for i in 1:N
    b = parseInt(readline())
    for i in 1:9
        a = A[i]
        if a == b
            A[i] = 999
        end
    end
end

if A[1] == A[4] == A[7] || A[2] == A[5] == A[8] || A[3] == A[6] == A[9] || A[1] == A[2] == A[3] || A[4] == A[5] == A[6] || A[7] == A[8] == A[9] || A[1] == A[5] == A[9] || A[3] == A[5] == A[7]
    println("Yes")
else 
    println("No")
end    
    

Measured memory_bytes: 116732
s = gets.chomp.split("")
count = 0
tmp1 = 0
tmp2 = 0
s.each do |i|
count += 1
if i == "A" and tmp1 == 0
tmp1 = count
end

if i == "Z" and tmp1 >= 1
tmp2 = count
end
end

puts tmp2 - tmp1 + 1

Measured memory_bytes: 16764
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);


int main(){
  int n;
  string s;
  cin >>s;
  n=s.size();
  int ans=n,sums=0;
  rep(i,n){
    if(s[i]=='S'){
      sums++;
    }
    else{
      if(sums){
        sums--;
        ans-=2;
      }
    }
  }
 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define N 100000
using namespace std;

int main(){
  int prime[N];
  int han = 0;int n,start=3;
  fill(prime,prime+N,0);
  prime[0] = 2;
  int key=1;
  int fl=0;
 for(int j=3;j<=50000;j++)
      {
	for(int i=2;i<=sqrt(j);i++)
	  {
	    if(j%i == 0){ fl = 1; break;}
	  }
	if(fl == 0)
	  {
	    prime[key] = j;
	    key++;
	  }else fl = 0;
      }






  while(true){
    
    cin >> n;
    if(n == 0)break;
        
    //for(int i=0;i<20;i++)cout << prime[i] << " " ;
    int cou=0;
    for(int i=0;i<n;i++)
      {
	if(prime[i] == 0)continue;
	for(int j=i;j<n;j++)
	  {
	    if(prime[j] == 0)continue;
	    if(prime[i]+prime[j] == n)cou++;
	  }
      }
    cout << cou <<endl;
    cou =0;



  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    ll x;
    ll as = 100;
    int cnt = 0;
    cin >> x;
    while(1){
        cnt++;
        as = as * 0.01 + as;
        //cout << as << endl;
        if(x <= as){
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] arr = new int[N];
        int tmp = 0;
        for(int i = 1; i < N; i++) {
            tmp = sc.nextInt();
            arr[tmp - 1] += 1;
        }
        for(int j = 0; j < N; j++) {
            System.out.println(arr[j]);
        }
    }
}

Measured memory_bytes: 56200
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}
 

 
int main(){

  char a,b;
  cin >> a >> b;

  if((a=='H'&&b=='H') || (a=='D'&&b=='D')){
    cout << 'H' << endl;
  }else{
    cout << 'D' << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        System.out.println(Math.max(a*b, c*d));
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int n,w;
    cin>>n>>w;
    int wt[n+1];
    ll val[n+1];
    for(int i=1;i<=n;i++)
    cin>>wt[i]>>val[i];
    ll dp[n+1][w+1];
    for(int i=0;i<=w;i++)
    dp[0][i]=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(j==0)
            dp[i][j]=0;
            else if(wt[i]<=j)
            dp[i][j]=max(val[i]+dp[i-1][j-wt[i]],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 79232
#include <stdio.h>
int main(void)
{
 int S,h,m,s,r;
 
 scanf("%d",&S);
 
 h = S / 3600;
 r = S % 3600;
 
 m = r / 60;
 s = r % 60;

 printf("%d:%d:%d\n",h,m,s);
 
}


Measured memory_bytes: 2140
n = int(input())
a = []
b = []
for _ in [0]*n:
  x,y = map(int,input().split())
  a.append(x)
  b.append(y)
s = 0
for i in range(0,n)[::-1]:
  s = (a[i]+s+b[i]-1)//b[i]*b[i]-a[i]
print(s)

Measured memory_bytes: 11816
#include<bits/stdc++.h>
using namespace std;
class DisjointSet {
    public:
        //rank:木の高さ p:節点の親 num:集合の要素数
        vector<int> rank, p, num;

        DisjointSet() {}
        //0からsize-1までの節点を作る
        DisjointSet(int size) {
            rank.resize(size, 0);
            p.resize(size, 0);
            num.resize(size, 1);
            for (int i=0; i<size; i++) makeSet(i);
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
            num[x] = 1;
        }
        void link(int x, int y) {
            if (rank[x] > rank[y]){
                p[y] = x;
                num[x] += num[y];
            } else
            {
                p[x] = y;
                num[y] += num[x];
                if (rank[x] == rank[y])
                    rank[y]++;
            }
        }
        int findSet(int x){
            if (x != p[x]) {
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
        //xとyが同じ集合に含まれるか判定する
        bool same(int x, int y) {
            return findSet(x) == findSet(y);
        }
        //xを含む集合とyを含む集合を結合する
        void unite(int x, int y) {
            if (same(x, y))return;
            link(findSet(x), findSet(y));
        }
        //xが含まれる集合の要素数を返す
        int getNum(int x){
            return num[findSet(x)];
        }
};

int main(){
    int n, k, l; cin >> n >> k >> l;
    DisjointSet d1 = DisjointSet(n+1), d2 = DisjointSet(n+1);
    for (int i = 0; i < k; i++){
        int p, q; cin >> p >> q;
        d1.unite(p, q);
    }
    for (int i = 0; i < l; i++){
        int r, s; cin >> r >> s;
        d2.unite(r, s);
    }
    map<pair<int, int>, int> m;
    for (int i = 1; i <= n; i++)
        m[make_pair(d1.findSet(i), d2.findSet(i))]++;
    for (int i = 1; i <= n; i++){
        cout << m[make_pair(d1.findSet(i), d2.findSet(i))] << " ";
    }
    cout << endl;

    
}

Measured memory_bytes: 16640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp58
{
    class Program
    {
        static void Main(string[] args)
        {
        var l =     Console.ReadLine().Split(' ').Select(int.Parse).ToArray();


            var h1 = l[0] * 60 + l[1];
            var h2 = l[2] * 60 + l[3];
            var h3 = h2 - l[4];

            Console.WriteLine(h3 - h1);
            //Console.Read();

        }
    }
}


Measured memory_bytes: 28080
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int N,M;
    cin >> N >> M;
    int love[M+10];
    for(int i=0;i<=M;i++){
        love[i]=0;
    }
    for(int i=0;i<N;i++){
        int K;
        cin >> K;
        for(int i=0;i<K;i++){
            int a;
            cin >> a;
            love[a]++;
        }
    }
    int ans=0;
    for(int i=0;i<=M;i++){
        if(love[i]==N) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256