akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int H[10000], W[10000];
	int ct = 0;
	while(true){
		cin >> H[ct] >> W[ct];
		if(H[ct] == 0 && W[ct] == 0) break;
		ct++;
	}
	for(int h = 0; h <= ct; h++){
		if(h != 0) cout << endl;
		for(int i = 0; i < H[h]; i++){
			if(i == 0 || i == H[h] - 1){
				for(int j = 0; j < W[h]; j++){
					cout << '#';
				}
			}
			else{
				cout << '#';
				for(int j = 1; j < W[h] - 1; j++){
					cout << '.';
				}
				cout << '#';
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    vector<int> as(5);
    for(int i=0; i<5; ++i){
        cin >> as[i];
    }
    int ans=200*5;
    for(int i=0; i<5; ++i){
        int sum=0;
        for(int j=0; j<5; ++j){
            if(i==j) sum+=as[j];
            else sum+=(as[j]+10-1)/10*10;
        }
        ans=min(sum, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int he, ta;
  for (int i=0;;i++){
    if(s[i]=='A'){
      he=i;
      break;
    }
  }
  for (int i=s.size()-1;;i--){
    if(s[i]=='Z'){
      ta=i;
      break;
    }
  }
  cout << ta-he+1 << endl;
}


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

int main(){
  for(int i = 0; i < 3; ++i){
    int h, m, s;
    cin >> h >> m >> s;
    int h_, m_, s_;
    cin >> h_ >> m_ >> s_;
    int ds = s_-s, dm = m_-m, dh = h_-h;
    if(ds < 0)
      ds += 60, --dm;
    if(dm < 0)
      dm += 60, --dh;
      
    printf("%d %d %d\n",dh,dm,ds);
  }
}



Measured memory_bytes: 3152
using System;
using System.Collections.Generic;

namespace practice_csharp
{
    class Program
    {
        const char CharA = 'A';
        const char CharZ = 'Z';
        static void Main(string[] args)
        {
            var sum = int.Parse(Console.ReadLine());
            var inData = Console.ReadLine();
            string result = "";
            foreach(var s in inData){
                var added = (int)s + sum;
                if(added > (int)CharZ){
                    added = CharA+(added-CharZ-1);
                }
                result += (char)added;
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 34772
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	set<int> st;
	for(int i=0;i<n;i++){
		cin>>x;
		st.insert(x);
		if(x == (*st.begin())){
			cnt[0]++;
		}
	}
	cout<<cnt[0];
	return 0;
}
//.........

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

int main() {
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  vector<int> a(N), b(N), c(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  }
  
  // 3次元DP表のマスを無限で初期化。
  // (選択出来る薬品数)*(Aの総量)*(Bの総量)
  const int inf = 100000000;
  vector<vector<vector<int>>> cost(41, vector<vector<int>>(10*40+1, vector<int>(10*40+1)));
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= 10*N; j++) {
      for (int k = 0; k <= 10*N; k++) {
        cost.at(i).at(j).at(k) = inf;
      }
    }
  }
  // 0*0*0の時のコストは0で確定(初期条件)
  cost.at(0).at(0).at(0) = 0;
  
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 10*N; j++) {
      for (int k = 0; k <= 10*N; k++) {
        if (cost.at(i).at(j).at(k) == inf) {
          continue;
        }
        else {
          cost.at(i+1).at(j).at(k) = min(cost.at(i+1).at(j).at(k), cost.at(i).at(j).at(k));
          cost.at(i+1).at(j+a.at(i)).at(k+b.at(i)) = min(cost.at(i+1).at(j+a.at(i)).at(k+b.at(i)), cost.at(i).at(j).at(k)+c.at(i));
        }
      }
    }
  }
  
  int ans = inf;
  for (int j = 1; j <= 10*N; j++) {
    for (int k = 1; k <= 10*N; k++) {
      if (j*Mb == k*Ma) {
        ans = min(ans, cost.at(N).at(j).at(k));
      }
    }
  }
  
  
  if (ans == inf) {
    cout << -1 << endl;
  }
  else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 27264
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> s(n),ans(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  bool can=true;
  for(int i=n-1;i>=0;i--){
    bool can2=false;
    for(int j=s.size()-1;j>=0;j--){
      if(s[j]==j+1){
        ans[i]=j+1;
        s.erase(s.begin()+j);
        can2=true;
        break;
      }
    }
    if(!can2){
      can=false;
      break;
    }
  }
  if(!can){
    cout << -1 << endl;
  }
  else{
    for(int i=0;i<n;i++){
      cout << ans[i] << endl;
    }
  }
}

Measured memory_bytes: 256
#ABC088

m = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
p = 0
q = 0
for i in range(len(a)//2):
    p += a[2 * i]
    q += a[2 * i + 1]

if len(a) % 2 != 0:
    p += a[-1]

print(p-q)




Measured memory_bytes: 3060
N, M = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(N)]
ans = 0
check = 0
AB.sort()

for a, b in AB:
    if b + check < M:
        check += b
        ans += a * b
    else:
        ans += (M - check) * a
        break
print(ans)


Measured memory_bytes: 21604
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    char x,y;cin>>x>>y;
    if(x<y){
        cout<<"<"<<endl;
    }else if(x>y){
        cout<<">"<<endl;
    }else{
        cout<<"="<<endl;
    }
}

Measured memory_bytes: 3624
program prob2
    implicit none
    integer::a, i, ans, t
    t = 10
    ans = 0
    do i = 1, 5
        read(*,*) a
        if(mod(a,10) > 0) t = min(t,mod(a,10))
        ans = ans + (a+9)/10*10
    end do
    ans = ans + t - 10
    write(*,*) ans
    stop
end program

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)
#define sz(x) int(x.size())
#define INF 1000000000000

vector<vector<ll>> to;
vector<ll> ans;
queue<ll> q;
int n, m;

int main()
{
  cin >> n >> m;
  to.resize(n);
  rep(i, n)
  {
    ans.push_back(-1);
  }
  rep(i, m)
  {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  q.push(0);
  ans[0] = 0;
  ll now = 0;
  while (q.size())
  {
    now = q.front();
    q.pop();
    vector<ll> tos = to[now];
    rep(i, tos.size())
    {
      ll t = tos[i];
      if (ans[t] == -1)
      {
        ans[t] = now;
        q.push(t);
      }
    }
  }
  vector<ll> output;
  rep(i, ans.size())
  {
    if (ans[i] == -1)
    {
      cout << "No" << endl;
      return 0;
    }
    output.push_back(ans[i]);
  }
  cout << "Yes" << endl;
  rep(i, n)
  {
    if (i == 0)
      continue;
    cout << output[i] + 1 << endl;
  }
  return 0;
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define go(i,s,t) for(int i = s; i >= t; -- i)
const int p = 1e9+7;

int n, c[1005];
long long ans = 1;

int main()
{
	cin >> n;
	fo(i,2,n)
	{
		int k = i;
		fo(j,2,sqrt(k))
		{
			while(k%j==0)
			{
				c[j]++;
				k /= j;
			}
		}
		if(k) c[k] ++;
	}
	fo(i,2,1000) ans = (ans * (c[i]+1)) % p;
	cout << ans;
	return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
using static System.Array;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var A = RLongs();

        var absmin = long.MaxValue;
        long absum = 0;
        int mc = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] < 0) mc++;
            absmin = Min(absmin, Abs(A[i]));
            absum += Abs(A[i]);
        }
        if (mc % 2 == 0) WriteLine(absum);
        else WriteLine(absum-absmin*2);
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 38964
#!/usr/bin/env python3
import copy
import numpy as np
from itertools import combinations


def main():
    H, W, K = map(int, input().split())
    c = np.array([list(input()) for _ in range(H)], dtype='str')
    cnt = 0

    h_pattern = []
    w_pattern = []

    for h_num in range(H + 1):
        h_pattern.extend(list(combinations(range(H), h_num)))

    for w_num in range(W + 1):
        w_pattern.extend(list(combinations(range(W), w_num)))

    cnt = 0
    for hp1 in h_pattern:
        for wp1 in w_pattern:
            d = copy.deepcopy(c)
            for hp2 in hp1:
                d[hp2, :] = 'x'
            for wp2 in wp1:
                d[:, wp2] = 'x'
            if np.count_nonzero(d == '#') == K:
                cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27116
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
using namespace std;

const int N=1e6+5;
const long long MOD=1e6+3;
long long m[N],r[N];
int q;
long long f,n,d,nd,l;

long long mult(long long x,int y){
	long long ret=1ll,mt=1ll*x;
	while(y){
		if(y&1) ret=(ret*mt)%MOD;
		y>>=1;
		mt=(mt*mt)%MOD;
	}
	return ret;
}

int main(){
	m[1]=1ll;
	for(int i=2;i<MOD;i++) m[i]=(m[i-1]*i)%MOD;
	for(int i=1;i<MOD;i++) r[i]=mult(m[i],MOD-2);
	r[0]=1ll;
	scanf("%d",&q);
	while(q--){
		scanf("%lld%lld%lld",&f,&d,&n);
		if(d==0){
			printf("%lld\n",mult(f,n));
			continue;
		}
		nd=mult(d,MOD-2);
		f=f*nd%MOD;
		l=f+n-1;
		if(l<MOD) printf("%lld\n",m[l]*r[f-1]%MOD*mult(d,n)%MOD);
		else puts("0");
	}
	return 0;
}

/*
数据不清空，爆零两行泪
读题不认真，爆零两行泪
分析不仔细，爆零两行泪
建树不构造，爆零两行泪
变量不统一，爆零两行泪
边界不算清，爆零两行泪
数组不开大，爆零两行泪
*/

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,k;
    cin >> n >> k;

    double s[n+k+10]={},x;
    REP(i,n){
        cin >> x;
        x=(x+1)/2;
        s[i]=s[i-1]+x; 
    }
    double ans;
    for(int i=0;i<n;i++){
        ans = max(ans,s[i+k]-s[i]);
    }



    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3328
n, m = map(int,input().split())
dig = [0 for i in range(n)]
ans = ''
flag = 0
for i in range(m):
    s,c = map(int,input().split())
    if s == 1 and c ==0 and n > 1:
        flag=1
    if dig[(s-1)] != 0 and c != dig[(s-1)]:
        flag=1
        break
    dig[(s-1)] = c
for i in range(n):
    if i == 0 and n > 1:
        if dig[i] != 0:

            ans += str(dig[i])
        else:
            ans += str(1)

    else:
        ans += str(dig[i])
if flag == 0:
    print(ans)
elif flag ==1:
    print('-1')


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10000)
# Longest path
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)
dp = [-1 for _ in range(N)]

def rec(c):
    if dp[c] != -1:
        return dp[c]
    res = 0
    for i in graph[c]:
        res = max(res, rec(i) + 1)
    dp[c] = res
    return res

for i in range(N):
    rec(i)
print(max(dp))

Measured memory_bytes: 115628
# ARC079C - Cat Snuke and a Voyage (ABC068C)
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    s, d = set(), set()
    for _ in range(m):
        a, b = map(int, input().split())
        if a == 1:
            s.add(b)
        elif b == n:
            d.add(a)
    print("POSSIBLE" if s & d else "IMPOSSIBLE")


if __name__ == "__main__":
    main()


Measured memory_bytes: 19012
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{


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

    int n; 
    cin >> n;




    int ans = pow(3,n);
    int prod = 1;

    for(int i = 0; i < n; i++)
    {
      int x;
      cin >> x;
      if(x%2 == 0)prod *= 2;
    } 





    cout << ans - prod;

    return 0; 
}


Measured memory_bytes: 4080
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int a,b,c,d,e,t;
    cin>>a>>b>>c>>d>>e;
    t=c*60+d-(a*60+b);
    cout<<max(0,t-e);
    
}

Measured memory_bytes: 3652
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int k = vs[0];
			int x = vs[1];
			if (500 * k >= x) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}



			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#define LL long long
#define rint register int
#define pii pair<int,int>
#define mid ((l+r)>>1)
#define MAXN 1005
#define INF 0x3f3f3f3f
using namespace std;

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

int h, w, dis[MAXN][MAXN], ans;
char mp[MAXN][MAXN];

struct Node
{
    int x, y, dis;
    Node(int _x=0, int _y=0, int _dis=0) {x=_x, y=_y, dis=_dis;}
};

queue<Node> q;

int main()
{
	scanf("%d%d", &h, &w);
	memset(dis, -1, sizeof(dis));
	for(rint i=1; i<=h; ++i)
	{
		scanf("%s", mp[i]+1);
		for(rint j=1; j<=w; ++j)
			if(mp[i][j]=='#') q.push(Node(i, j, 0)), dis[i][j]=0;
	}
	while(!q.empty())
	{
		int x=q.front().x, y=q.front().y;
		ans=max(ans, q.front().dis); q.pop();
		for(rint i=0; i<4; ++i)
		{
			int nx=x+dx[i], ny=y+dy[i];
			if(nx>0 && nx<=h && ny>0 && ny<=w && dis[nx][ny]==-1)
			{
				dis[nx][ny]=dis[x][y]+1;
				q.push(Node(nx, ny, dis[nx][ny]));
			} 
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 17296
#include<bits/stdc++.h>
const int MX=123456;
using namespace std;
int n,m,cnt=0;
vector<int>v[MX];
int val[MX];
int T=0;
int low[MX];
void dfs(int x,int p=-1)
{
	val[x]=low[x]=T++;
	for(auto &u:v[x])
	{
		if(u==p) continue;
		if(val[u]==-1)
		{
			dfs(u,x);
			if(low[u]>val[x]) cnt++;
			low[x]=min(low[x],low[u]);
		}
		else
		low[x]=min(low[x],val[u]);
	}
}
int main() {
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	fill(val,val+MX,-1);
	dfs(1,-1);
	cout<<cnt;
	return 0;
}

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

using namespace std;
using vi = vector<int>;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int64_t> Ai(n);
    rep(i,n){
        cin >> Ai.at(i);
    }
    vector<int64_t> vec(n-k+1);
    int64_t sum = 0;
    for (int i=0; i<k; i++){
        sum += Ai.at(i);
    }
    vec.at(0) = sum;
    for (int i=1; i<n-k+1; i++){
        sum = vec.at(i-1);
        sum = sum - Ai.at(i-1) + Ai.at(i-1+k);
        vec.at(i) = sum;
    }

    for (int i=1; i<n-k+1; i++){
        if (vec.at(i) > vec.at(i-1))cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 6336
//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright ?? 2017??´ Nag. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>

//A-Z = 65 - 90
//a-z = 97 - 122

using namespace std;

int main(void) {
    string x;
    int sum;
    
    cin >> x;
    while( !(x=="0") ) {
        sum = 0;
        for( auto i:x ) {
            sum += i - '0';
        }
        cout << sum << endl;
        
        cin >> x;
    }
    
    return 0;
    
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int N;
  vector<ull> a;
  vector<ull> add;
  ull count = 0;

  cin >> N;
  a.resize(N);
  add.resize(N);

  FOR(i, N) { cin >> a[i]; }

  int last = N - 1;
  for (int i = 0;; i = (i + 1) % N) {
    a[i] += add[(i + N - 1) % N] - add[i];
    if (a[i] >= N) {
      add[i] = add[(i + N - 1) % N] + a[i] / N;
      count += a[i] / N;
      a[i] %= N;
      last = i;
    } else if (last != i) {
      add[i] = add[(i + N - 1) % N];
    } else {
      break;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0] * 5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())


mn = min(A)
minidx = A.index(mn)
ans = 0
ans = minidx

ans += ( N + A[minidx] -1)//A[minidx]
ans += 5 - 1 - minidx
print(ans)


# ans = 0
# tmp = N
# for i in range(5):
#     if tmp > A[i]:
#         ans += (tmp + A[i]-1) // A[i]
#         tmp = A[i]
#     else:
#         ans += 1
# print(ans)
    


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

int main(){
  int a,b,c,x,y;
  int ans=0;
  cin>>a>>b>>c>>x>>y;
  c*=2;
  ans=min(a+b,c)*min(x,y);
  if(x<y)ans+=min(b,c)*abs(x-y);
  else ans+=min(a,c)*abs(x-y);
  cout<<ans<<endl;
  return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}

int n;
ll a[100005];
ll dp[100005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n;
    for (int i = 0; i < n; ++i)
        std::cin >> a[i];

    std::fill(dp, dp + n + 1, inf);
    std::reverse(a, a + n);
    for (int i = 0; i < n; ++i) {
        *std::upper_bound(dp, dp + n, a[i]) = a[i];
    }

    std::cout << std::lower_bound(dp, dp + n, inf) - dp << std::endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Arrays
import java.util.ArrayList
import java.util.ArrayDeque

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun <T : Comparable<T>> Iterable<T>.argmax(): Int? = withIndex().maxBy{it.value}?.index
fun <T : Comparable<T>> Iterable<T>.argmin(): Int? = withIndex().minBy{it.value}?.index

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (a, op, b) = reader.readLine()!!.split(" ")

    if (op == "+") {
        println(a.toInt() + b.toInt())
    } else {
        println(a.toInt() - b.toInt())

    }
}


Measured memory_bytes: 35784
N,M = list(map(int, input().split()))
AB_array = []
for _ in range(N):
    AB_array.append(list(map(int, input().split())))

AB_array_s = sorted(AB_array, key=lambda x: x[0])

count = 0
for i in range(len(AB_array_s)):
    A,B = AB_array_s[i]
    if M <= B:
        count += A * M
        break
    else:
        M -= B
        count += A * B

print(count)


Measured memory_bytes: 29792
#include <stdio.h>

int main()
{
	bool *sosu;
	int *ans,now,n;

	sosu = new bool[1000000];
	ans = new int[1000000];

	for(int i = 0; i < 1000000; i++){
		sosu[i] = true;
	}
	sosu[0] = sosu[1] = false;
	for(int i = 0; i < 1000000; i++){
		if(sosu[i] == true){
			for(int j = 2; j*i < 1000000; j++){
				sosu[j*i] = false;
			}
		}
	}
	now = 0;
	for(int i = 0; i < 1000000; i++){
		if(sosu[i] == true)
			now++;
		ans[i] = now;
	}

	while(scanf("%d",&n) != EOF){
		printf("%d\n",ans[n]);
	}

	return 0;
}

Measured memory_bytes: 5912
#include <bits/stdc++.h>
using namespace std;
typedef long long int i64;
#define SZ(v) (int((v).size()))
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(__attribute__((unused)) istream_iterator<string> it) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;
  string A, B;
  A += s[0];
  A += s[1];
  B += s[2];
  B += s[3];
  int a = stoi(A), b = stoi(B);
  bool x = false, y = false;
  x |= (a <= 12 && a >= 1);
  y |= (b <= 12 && b >= 1);
  if (x && y) {
    cout << "AMBIGUOUS";
  } else if (x) {
    cout << "MMYY";
  } else if (y) {
    cout << "YYMM";
  } else {
    cout << "NA";
  }
  
  return 0;
}


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

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 26596
N = int(input())
A = list(map(int, input().split()))

student_dic = {}
for i in range(N):
    student_dic[A[i]] = i+1


tmp = sorted(student_dic.items())
for i in range(N):
    if i == N-1:
        print(tmp[i][1])
    else:
        print(tmp[i][1], end=" ")


Measured memory_bytes: 66088
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> P;
#define INF (INT_MAX/4)

struct edge{ int cost,to; };

int N,K,c[5000],r[5000],a[10000],b[10000];
vector<int> G0[5000];
int d[5000][5000];//i->j???????????????

vector<edge> G1[5000];
int m[5000];

int main(){
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++) scanf("%d%d",&c[i],&r[i]);
	for(int i=0;i<K;i++){
		scanf("%d%d",&a[i],&b[i]);
		a[i]--; b[i]--;
		G0[a[i]].push_back(b[i]);
		G0[b[i]].push_back(a[i]);
	}
	for(int i=0;i<N;i++){
		queue<P> q;
		q.push(P(i,r[i]));
		while(!q.empty()){
			P x=q.front(); q.pop();
			if(d[i][x.first]==1) continue;
			d[i][x.first]=1;
			if(x.second==0) continue;
			for(int j=0;j<G0[x.first].size();j++) if(d[i][G0[x.first][j]]==0) q.push(P(G0[x.first][j],x.second-1));
		}
	}
	for(int i=0;i<N;i++) for(int j=0;j<N;j++) if(i!=j&&d[i][j]){
		edge x; x.cost=c[i]; x.to=j; G1[i].push_back(x);
	}
	priority_queue<P, vector<P>, greater<P> > que; //(?????¢,??????)
	fill(m,m+N,INF);
	m[0]=0;
	que.push(P(0,0));
	
	while(!que.empty()){
		P p=que.top(); que.pop();
		int v=p.second;
		if(m[v]<p.first) continue;
		for(int i=0;i<G1[v].size();i++){
			edge e=G1[v][i];
			if(m[e.to]>m[v]+e.cost){
				m[e.to]=m[v]+e.cost;
				que.push(P(m[e.to],e.to));
			}
		}
	}
	printf("%d\n",m[N-1]);
}

Measured memory_bytes: 223656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, i, j, count;
  int MAX = 0;
  
  cin >> N;
  vector<string> s(N);
  for(i=0;i<N;i++) cin >> s.at(i);
  
  cin >> M;
  vector<string> t(M);
  for(i=0;i<M;i++) cin >> t.at(i);
  
  for(j = 0; j < N; j++){
    count = 0;
    for(i = 0; i < N; i++){
      if(s.at(j)==s.at(i)) count++;
    }
    for(i = 0; i < M; i++){
      if(s.at(j)==t.at(i)) count--;
    }
    MAX = max(MAX, count);
  }
  cout << MAX << endl;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 200

typedef long long ll;
typedef pair<int, int> P;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

P point[MAXN+1];

int main(void) {
    int N;
    while (1) {
        cin >> N;
        if (N == 0) break;
        int x_plus_max = 0, x_minus_max = 0, y_plus_max = 0, y_minus_max = 0;
        point[0].first = 0, point[0].second = 0;
        for (int i = 1; i < N; i++) {
            int n, d;
            cin >> n >> d;
            point[i].first = point[n].first + dx[d];
            point[i].second = point[n].second + dy[d];
            x_plus_max = max(x_plus_max, point[i].first);
            x_minus_max = max(x_minus_max, -point[i].first);
            y_plus_max = max(y_plus_max, point[i].second);
            y_minus_max = max(y_minus_max, -point[i].second);
        }
        int x = x_plus_max + 1 + x_minus_max;
        int y = y_plus_max + 1 + y_minus_max;
        cout << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

const int M = 1000000007;

int main()
{
    int n;
    scanf("%d", &n);

    int t[100000], a[100000];
    for (int i = 0; i < n; ++i)
        scanf("%d", &t[i]);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);

    long long ans;
    if (t[n - 1] == a[0]) {
        ans = 1;
        for (int i = 1; i < n - 1; ++i) {
            if ((t[i - 1] != t[i] && a[i] < t[i]) || (a[i] != a[i + 1] && t[i] < a[i]))
                ans = 0;
            if (t[i - 1] == t[i] && a[i] == a[i + 1])
                ans = (ans * min(t[i], a[i])) % M;
        }
    } else {
        ans = 0;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[]args) {
    Scanner s = new Scanner(System.in);
    int a = s.nextInt(), b = s.nextInt(), c = s.nextInt();
    List<Integer> list = new ArrayList<>();
    for (int i = 1; i <= Math.min(a, b) ; ++i) {
      if (a % i == 0 && b % i == 0) {
	 list.add(i);
      }
    }
    System.out.println(list.get(list.size() - c));
  }  
}


Measured memory_bytes: 25172
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<iostream>
using namespace std;

typedef long long ll;

int n;
string s;

int main(){
    cin >> s;
    n=s.length();
    int t=0,cnt=n/2;
    for(int i=0;i<n;i++)
        if(s[i]=='p') t++;
    cnt-=t;
    printf("%d",cnt);
}


Measured memory_bytes: 512
a = []
c = []
n = int(input())
max_i = 0
max_s = 0
b = False
for i in range(n):
    aa = int(input())
    a.append(aa) 
    c.append(aa)   
    if max_i < aa : max_i = aa

c.remove(max_i)
max_s = max(c)

for i in range(n):
    if a[i] != max_i : print(max_i)
    else:print(max_s)
        

    



Measured memory_bytes: 14120
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll N;
	double A[nmax_def];
	double Ainv[nmax_def];
	double AinvS = 0.0;
	cin >> N;
	for (i = 0; i < N; i++)
	{
		cin >> A[i];
		Ainv[i] = 1.0 / A[i];
		AinvS += Ainv[i];
	}
	double ans = 1.0 / AinvS;
	printf("%.12f", ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
char exchange(char c) {
	if('A' <= c && c <= 'Z') {
		return c + ('a' - 'A');
	}
	if('a' <= c && c <= 'z'){
		return c+('A'-'a');
	}
	else return c;
}
int main(void){
	char  w;
	while(1){
		scanf("%c",&w);
		if(w=='\n') break;
		w=exchange(w);
		printf("%c",w);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }
    else{
        cout<<r+100*(10-n)<<endl;
    }
}

Measured memory_bytes: 256
#include <cassert>
#include <vector>
#include <iostream>
#include <set>
#include <utility>
using namespace std;

int main(){
  const int INF = 1e9;
  int N, M;
  string S;
  cin >> N >> M >> S;
  vector<pair<int,int>> dp(N+1,{INF,INF});
  dp[N] = {0,0};
  set<pair<int,int>> E;
  E.insert({0,N});
  for(int i = N-1; i >= 0; --i){
    if(i+M+1 <= N){
      E.erase({dp[i+M+1].first,i+M+1});
    }
    if(S[i] == '1') continue;
    if(E.empty()) continue;
    pair<int,int> p = *E.begin();
    // cerr << p.second-i << endl;
    assert(p.second-i <= M);
    dp[i] = {p.first+1,p.second-i};
    E.insert({dp[i].first,i});
  }
  if(dp[0].first >= INF){
    cout << -1 << endl;
    return 0;
  }
  int idx = 0;
  cout << dp[idx].second;
  while(idx < N){
    idx += dp[idx].second;
    if(idx == N){
      cout << endl;
      return 0;
    }
    cout << " " << dp[idx].second;
  }
}


Measured memory_bytes: 3712
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] a=new int[4];int[] b=new int[4];
		while(sc.hasNext()){
			int hit=0,blow=0;
			//入力
			for(int i=0;i<4;i++){
			a[i]=sc.nextInt();
			}
			for(int i=0;i<4;i++){
				b[i]=sc.nextInt();
			}
			
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					if(a[i]==b[j]){
						if(i==j) hit++;
						else blow++;
					}
				}
			}
			System.out.println(hit+" "+blow);
		}
		sc.close();
	}
}

Measured memory_bytes: 18120
import java.util.*;

class Main {
    public static void main(String[] args) {
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         int b = scan.nextInt();
         int c = scan.nextInt();

         int count = 0;
         
         for (int i=a; i<=b; i++) {
             if (c%i == 0) count++;
         }

         System.out.println(count);
    }
}

Measured memory_bytes: 26156
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<int> c(N, 0);
  for (int i = N - 1; i >= 0; i--){
    c[i] = a[i];
    for (int j = 2 * i + 1; j < N; j += i + 1){
      c[i] ^= c[j];
    }
  }
  vector<int> b;
  for (int i = 0; i < N; i++){
    if (c[i] == 1){
      b.push_back(i + 1);
    }
  }
  int M = b.size();
  cout << M << endl;
  for (int i = 0; i < M; i++){
    cout << b[i];
    if (i < M - 1){
      cout << ' ';
    }
  }
  cout << endl;
}

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

int main(void)
{
    int N;
    string S;
    cin >> N >> S;
    vector<ll> eastCost(N,0);
    vector<ll> westCost(N,0);

    eastCost[0] = 0;
    westCost[N-1] = 0;
    for (int i = 0; i < N-1; i++)
    {
        if(S[i] == 'W'){
            eastCost[i+1] = eastCost[i] + 1;            
        } else {
            eastCost[i+1] = eastCost[i];
        }

        if(S[N-i-1] == 'E'){            
            westCost[N-i-2] = westCost[N-i-1] + 1;
        } else{
            westCost[N-i-2] = westCost[N-i-1];
        }
    }

    vector<ll> cost(N, 0);
    for(int i = 0; i < N; i++){
        cost[i] = eastCost[i] + westCost[i];
    }

    cout << *min_element(cost.begin(), cost.end()) << endl;

    return 0;
}


Measured memory_bytes: 10616
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

int main() {

	int N;

	cin >> N;

	map<long, long> V;

	//vector<long> V;

	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}

	long long c;
	long long sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> c;
		if (c < V[i]) {
			sum += V[i] - c;
		}
	}

	

	cout << sum;


}

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

int main(){
  int a, b, c;
  std::cin >> a >> b >> c;
  int d = a - b;

  if(d > c){
    std::cout << "0" << '\n';
  }
  else{
    std::cout << c - d << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 10000000
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

bool bfs(vector<vector<int>> &E,int start,int goal){
	vector<bool> B(51,false);
	B[start] = true;
	queue<int> Q;
	Q.push(start);
	while(Q.size()!=0){
		int from = Q.front();
		Q.pop();
		for(int i=0;i<E[from].size();i++){
			int to = E[from][i];
			if(B[to])continue;
			B[to]=true;
			Q.push(to);
		}
	}
	return B[goal];
}

int main(){
    
	int N;
	cin>>N;
	
	vector<int> a(N),b(N);
	
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	for(int i=0;i<N;i++){
		cin>>b[i];
	}
	
	vector<bool> f(50,true);
	
	
	
	for(int i=50;i>=0;i--){
		if(i!=50)f[i]=false;
		vector<vector<int>> E(51,vector<int>());
		for(int j=0;j<50;j++){
			if(f[j]){
				for(int k=0;k<=50;k++){
					E[k].push_back(k % (j+1));
				}
			}
		}
		bool ff = true;
		for(int j=0;j<N;j++){
			if(bfs(E,a[j],b[j])==false){
				ff=false;
				break;
			}
		}
		if(i==50){
			if(ff)continue;
			else{
				cout<<-1<<endl;
				return 0;
			}
		}
		
		if(!ff)f[i]=true;
	}
	long long ans = 0;
	for(int i=0;i<50;i++){
		if(f[i]){
			ans += (long long)1<<(i+1);
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}



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

using namespace std;

vector<vector<int> > G;
int *color;
vector<int> L;

void visit(int u);

void toporogical_sort(int s) {
    color[s] = 1;
    for (int i = 0; i < G[s].size(); i++) {
        int u = G[s][i];
        if (color[u] == 0) {
            visit(u);
        }
    }
    L.push_back(s);
}

void visit(int u) {
    color[u] = 1;
    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (color[v] == 0) {
            visit(v);
        }
    }
    L.push_back(u);
}

int main() {
    int n, m; cin >> n >> m;
    G.resize(n);
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        G[a].push_back(b);
    }

    color = new int[n];
    for (int i = 0; i < n; i++)
        color[i] = 0;
    for (int i = 0; i < n; i++) {
        if (color[i] == 0) 
            toporogical_sort(i);
    }

    for (int i = n-1; i >= 0; i--)
        cout << L[i] << endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int g = Integer.parseInt(sc.next());
    for(int i = 0; i < N-1; i++){
      int a = Integer.parseInt(sc.next());
      g = gcd(g, a);
    }
    System.out.println(g);
  }
  public static int gcd(int a, int b){
    if(b < a){
      return gcd(b, a);
    }
    
    if(a == 0){
      return b;
    }
    
    return gcd(b%a, a);
  }
}

Measured memory_bytes: 46372
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string s;
  cin>>s;
  string ans = "";
  for(int i=0;i<4;i++){
    ans += s[i];
  }
  ans += ' ';
  for(int i=4;i<12;i++){
    ans += s[i];
  }
  
  cout<<ans<<endl;
  return 0;
}


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

#define MAX 10000
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,k,ans = 1000000000;
vector<int> v;

main() {
    cin >> n >> k;
    rep(i,n) {
        int hoge;
        cin >> hoge;
        v.pb(hoge);
    }
    sort(all(v));
    repo(i,k-1,n) ans = min(ans,v[i]-v[i-k+1]);
    cout << ans << endl;
}

Measured memory_bytes: 1400
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;

		sc = new Scanner(in);

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a - b >= 0){
			System.out.println("delicious");
		}else{
			if(a - b < -x){
				System.out.println("dangerous");
			}else{
				System.out.println("safe");
			}
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	string s; cin>>s;
	if(s=="ARC") cout<<"ABC\n";
	else cout<<"ARC\n";
	
	return 0;
}


Measured memory_bytes: 3636
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int h, n;
    cin >> h >> n;

    int sum = 0;
    rep(i, n){
        int a;
        cin >> a;
        sum += a;
    }

    if(sum < h){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i;
	int n;
	int a[6];
	double b;
	int j;
	for(i = 0; i < 6; i++){
		a[i] = 0;
	}
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%lf", &b);
		if(b < 165.0){
			a[0]++;
		}else if(b < 170.0){
			a[1]++;
		}else if(b < 175.0){
			a[2]++;
		}else if(b < 180.0){
			a[3]++;
		}else if(b < 185.0){
			a[4]++;
		}else{
			a[5]++;
		}
	}
	for(i = 0; i < 6; i++){
		printf("%d", i + 1);
		printf(":");
		for(j = 0; j < a[i]; j++){
			printf("*");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 640