akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

void printvec(vecl A) {
    REP(i,A.size()) cout << A[i] << " ";
    cout << endl;
}

void solve(vecl A, vecl B, int N) {
    ll sumA = 0, sumB = 0;
    REP(i,N) sumA += A[i];
    REP(i,N) sumB += B[i];
    if(sumA > sumB) {
        cout << "No" << endl;
        return;
    }
    
    ll cntA = 0,cntB = 0;

    REP(i,N) {
        if(A[i] > B[i]) cntB += A[i]-B[i];
        else if(A[i] < B[i]) cntA += (B[i]-A[i])/2; 
    }
    if(cntA >= cntB) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {

    // 入力
    int N; cin >> N;
    vecl A(N),B(N);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];

    //solve
    solve(A,B,N);

}

Measured memory_bytes: 3924
ac=0
wa=0
tle=0
re=0
for _ in range(int(input())):
    s=input()
    if s=='AC':
        ac+=1
    elif s=='WA':
        wa+=1
    elif s=='TLE':
        tle+=1
    else:
        re+=1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Measured memory_bytes: 9108
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    cout<<n*n*n<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    int h, w, k;
    cin >> h >> w >> k;

    int si, sj, ti, tj;
    cin >> si >> sj >> ti >> tj;
    --si, --sj, --ti, --tj;

    const int inf = 1e9;
    int d[h][w];
    rep (i, h)
    {
        string s;
        cin >> s;
        rep (j, w)
        {
            d[i][j] = (s[j] == '@' ? -1 : inf);
        }
    }


    queue<P> q;
    q.emplace(si, sj);
    d[si][sj] = 0;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    while (!q.empty())
    {
        auto from = q.front(); q.pop();
        int fi = from.first;
        int fj = from.second;
        rep (i, 4)
        {
            int ni = fi;
            int nj = fj;
            int dyy = dy[i];
            int dxx = dx[i];
            rep (j, k)
            {
                ni += dyy;
                nj += dxx;
                if (!(IN(0, h, ni) && IN(0, w, nj))) break;
                if (d[ni][nj] < d[fi][fj] + 1) break;
                if (d[ni][nj] != inf) continue;
                d[ni][nj] = d[fi][fj] + 1;
                q.emplace(ni, nj);
            }
        }
    }

    int ans = d[ti][tj];
    if (ans == inf) cout << "-1\n";
    else cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 8236
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
// " ", ' '

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));
const int MAXN = 1005;
const int MAXV = 1005*(1005-1)/2;
vvec  to(MAXV, vec()); //list of vertex next to v.
vvec ID(MAXN, vec(MAXN));

vector<bool> calculated(MAXV, false);
vector<bool> visited(MAXV, false);
vec dp(MAXV); //max length of path from v.

// 関数：
int toID(int i, int j) {
	if(i > j) swap(i, j);
	return ID.at(i).at(j);
}

int dfs(int v) {
	if(visited.at(v)) {
		if(!calculated.at(v)) return -1;
		return dp.at(v);
	}
	visited.at(v) = true;
	dp.at(v) = 1;
	for(int u: to.at(v)) {
		int res = dfs(u);
		if(res==-1) return -1;
		dp.at(v) = max(dp.at(v), res+1);
	}
	calculated.at(v) = true;
	return dp.at(v);
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N; cin >> N;
	vvec A(N, vec(N-1));
	rep(i, N) {
		rep(j, N-1) {
			cin >> A.at(i).at(j);
A.at(i).at(j) -= 1;
		}
	}
	
	int V = 0;
	rep(i, N)rep(j, N) {
		if(i < j) {
			ID.at(i).at(j) = V++;
		}
	}
	rep(i, N) {
		rep(j, N-1) {
			A.at(i).at(j) = toID(i, A.at(i).at(j));
		}
		rep(j, N-2) {
			to.at(A.at(i).at(j+1)).push_back(A.at(i).at(j));
		}
	}
	
	int ans = 0;
	rep(i, V) {
		int res = dfs(i);
		if(res == -1) {
			cout << "-1" << endl;
			return 0;
		}
		ans = max(ans, res);
	}

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


Measured memory_bytes: 47616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}

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


	int N = getint(), M = getint();
	bool X[200010] = {};
	rep(i, M) X[getint() + 100000] = true;

	int mae = -1;
	int sa[200010] = {};
	rep(i, 200001) {
		if (X[i]) {
			if (mae != -1) {
				sa[i - mae]++;
			}
			mae = i;
		}
	}

	int kotae = 0;
	rep(i, 200001) {
		while (M > N && sa[i]) {
			sa[i]--;
			kotae += i;
			M--;
		}
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
N,M = map(int,input().split())
i = 0
l = [-1]*N
t = 0
while i<M:
    s,c = map(int,input().split())
    if N>1 and s == 1 and c == 0:
        t = -1
    elif l[s-1] == -1 or l[s-1] == c:
        l[s-1] = c  
    else:
        t = -1 
    i+=1

if N>1 and l[0] == -1:
    l[0] = 1
elif l[0] == -1:
    l[0] = 0

for i in range(0,N):
    if l[i]==-1:
        l[i]=0
    i+=1

if t == 0:
    for i in range(0,N):
        t += l[i]*(10**(N-i-1))
        i+=1

print(t)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int a,b;
  cin>>a>>b;
  if((a+b)%2==0){
    cout<<(a+b)/2<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }

}


Measured memory_bytes: 256
inputs = list(map(int, list('125')))


def prepare():
    global inputs
    inputs = list(map(int, list(input())))


def solve():
    total = 0
    slot = len(inputs) - 1
    cases = range(1 << slot)
    for case in cases:
        sum = inputs[slot]
        power = 0
        for i in range(slot):
            if case & (1 << i):
                power = 0
            else:
                power += 1
            sum += inputs[slot - (i + 1)] * 10**power
        total += sum
    return total


prepare()
output = solve()
print(output)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n+2, 0);
  rep(i,1,n+1) cin >> a[i];
  int k = 0;
  rep(i,0,n+1) {
    k += abs(a[i] - a[i+1]);
  }
  rep(i,1,n+1) {
    int ans = k - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]);
    ans += abs(a[i-1] - a[i+1]);
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 3776
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace aizu1
{
    public class Solution
    {
        static double cos = Math.Cos(60 * Math.PI / 180 );
        static double sin = Math.Sin(60 * Math.PI / 180);
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            curve kochCurve = new curve();
            Console.Write(kochCurve.kochCurving(n));

        }

        public class curve
        {
            List<Point> list=new List<Point>();

            public curve()
            {
                list.Add(new Point { x=0,y=0});
                list.Add(new Point { x = 100,y=0 });
            }

            public string kochCurving(int n)
            {
                string res = "";

                for(int i=0;i<n;i++)
                {
                    for(int j=0;j<list.Count()-1;j++)
                    {
                        Point p1 = list[j], p2 = list[j + 1];
                        divide(p1, p2, j);
                        getTraiangle(list[j+1],list[j+2],j+1);
                        j += 3;
                    }
                }

                foreach(var p in list)
                {
                    res += p.ToString() + "\n";
                }
                return res;
            }

            public void divide(Point p1, Point p2,int index)
            {
                list.Insert(index + 1, p1.getTriplePoint(p2));
                list.Insert(index+2, p2.getTriplePoint(p1));
            }

            public void getTraiangle(Point p1, Point p2, int index)
            {
                list.Insert(index + 1,p1.getTrianglePoint(p2));
            }

            public class Point
            {
                public double x { get; set; }
                public double y { get; set; }

                public Point getTriplePoint (Point other)
                {
                    double tmpX = x * 2 / 3 + other.x * 1 / 3;
                    double tmpY = y * 2 / 3 + other.y * 1 / 3;

                    return new Point { x = tmpX, y = tmpY };
                }

                public Point getTrianglePoint(Point other)
                {

                    return new Point
                    {
                        x=x+cos*(other.x-x)-sin*(other.y-y), 
                        y=y+sin*(other.x-x)+cos*(other.y-y)
                    };
                }
                public override string ToString()
                {
                    return string.Format("{0:F8} {1:F8}",x, y);
                }
            }
        }
    }
}

Measured memory_bytes: 10752
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[200010];
    rep(i, N) cin >> A[i];
    ll ans = 0;
    if (A[0] != 0) {cout << "-1" << endl; return 0;}
    rep(i, N - 1) {
        if (A[i] + 1 < A[i + 1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    int state = 0;
    RREP(i, N - 1, 0) {
        state = max(0, state - 1);
        if (i == N - 1) {
            ans += A[i];
            state = A[i];
        } else if (state < A[i]) {
            ans += A[i];
            state = A[i];
        }
    }
    cout << ans << endl;
    return 0;
}
// 0 1 2 3 4 4
//  0 0 1 2 3 4
//  0 1 2 3 4 4

// 0 1 1 0 1 2 2 1 2
//  0 0 0 0 0 0 0 1 2 (2)
//  0 0 0 0 0 1 2 1 2 (4)
//  0 0 0 0 1 2 2 1 2 (6)
//  0 0 1 0 1 2 2 1 2 (7)
//  0 1 1 0 1 2 2 1 2

// 0 1 2 3 4 2 3 4
//          1 2 3 4  

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;


int main(){
    while(1){
    
    int n,m;
    cin>>n>>m;
    if(n==0 && m==0){break;}
    pair<int,int>a[10000];
    unsigned long long int count=0;
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
        swap(a[i].first,a[i].second);
        count+=a[i].first*a[i].second;
    }
    sort(a,a+n);
    reverse(a,a+n);
    for(int i=0;i<n;i++){
        m-=a[i].second;
        count-=a[i].first*a[i].second;
        if(m<=0){count-=m*a[i].first; break;}
        }
        
    cout<<count<<endl;
        
    }
    
    return 0;
}


Measured memory_bytes: 3156
def main(argv)
  v = gets.chomp.split(' ').map(&:to_i)

  if v.map{|x| x % 2}.include?(0) then
    puts 0.to_s
    return
  end

  v.sort!
  puts (v[0] * v[1]).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		Map<String,Integer> tV = new TreeMap<>();//total vote paper
		
		int nV = scn.nextInt();//taking number of votes
		int[] VList= new int[nV];
		
		for(int i = 0;i<nV;i++) {
			String v = scn.next();
			
			if(!tV.isEmpty()) {
				if(tV.containsKey(v)) {
					tV.put(v,tV.get(v)+1);
				}else {
					tV.put(v,1);
				}
			}else {
				tV.put(v,1);
			}
			
			VList[i] = tV.get(v);//store the number of cointing vote paper 
		}
		Arrays.sort(VList);
		//Chaking, all number of vote same
		if(VList[nV-1] == VList[0]) {
			for(Map.Entry<String,Integer> vote : tV.entrySet()) {
				System.out.println(vote.getKey().toString());//print all equales votes
			}
		}else {
			if(VList[0] != VList[nV-1]) {
				for(Map.Entry<String,Integer> vote : tV.entrySet()) {
					if(vote.getValue() == VList[nV-1]) {
						System.out.println(vote.getKey().toString());//print selected votes
					}
				}
			}
		}
		scn.close();
	}
}

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

int main() {
    vector<int> A(3);
    rep(i, 3) cin >> A[i];
    sort(A.begin(), A.end());
    // 2 4 5
    int ans = 0;
    while(A[1] != A[2]) {
        A[0]++;
        A[1]++;
        ans++;
    }
    // 3 5 5
    while(A[0] < A[1]) {
        A[0] += 2;
        ans++;
    }
    ans += A[0] - A[1];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int N,a,b,c;
   cin >> N;
   a = N/100;
   c = N%10;
   b = (N/10)%10;
   if(a == 7 || b == 7 || c == 7 ) cout << "Yes";
   else cout << "No";
   
   return 0;
}

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


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

    vector<ll> H(N+1);
    for(int i = 1; i <= N; i++){
        cin >> H[i];
    }

    vector<ll> A(M+1), B(M+1);
    for(int i = 1; i <= M; i++){
        cin >> A[i] >> B[i];
    }

    vector<vector<ll>> bridge(N+1, vector<ll>());
    for(int i = 1; i <= M; i++){
        bridge[A[i]].push_back(B[i]);
        bridge[B[i]].push_back(A[i]);
    }

    ll ans = 0;
    for(int i = 1; i <= N; i++){
        ll h = H[i];
        bool good = true;
        for(int j = 0; j < bridge[i].size(); j++){
            if(h <= H[bridge[i][j]]){
                good = false;
                break;
            }
        }
        if(good) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 11440
#include <stdio.h>

int main(void) {
        int input_s = 0;
        int output_s = 0;
        int output_m = 0;
        int output_h = 0;

        scanf("%d", &input_s);

        output_h = input_s / 3600;
        output_m = (input_s % 3600) / 60;
        output_s = (input_s % 3600) % 60;

        printf("%d:%d:%d\n",output_h, output_m, output_s);

        return 0;
}



Measured memory_bytes: 2128
#include<iostream>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	if (A == 1 && B == 2 || A == 2 && B == 1) {
		cout << 3 << endl;
	}
	else if (A == 3 && B == 1 || A == 1 && B == 3) {
		cout << 2 << endl;
	}
	else cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }else if(a < b){
        cout << "a < b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll C[25], dp[25][50005];

int main() {
    init();
    ll N,M;
    cin >> N >> M;
    rep(i, M) cin >> C[i];
    sort(C, C + M);

    rep(i, M) fill(dp[i + 1], dp[i + 1] + N + 1, INF);
    iota(dp[0], dp[0] + N + 1, 0ll);

    rep(i,M){
        rep(j,N+1){
            dp[i + 1][j] = dp[i][j];
            if (j >= C[i]) chmin(dp[i + 1][j], dp[i + 1][j - C[i]] + 1);
        }
    }

    cout << dp[M][N] << endl;
}


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

using namespace std;
int N,Res;

void dfs(int cn, int x, int y, vector< vector<int> >& A) {
	if (x == N-1 && y == 1) {
		if (cn > Res) {
			Res = cn;
		}
		return;
	}
	if (x < N-1) {
		dfs(cn+A[y][x+1],x+1,y,A);
	}
	if (y < 1) {
		dfs(cn+A[y+1][x],x,y+1,A);
	}
}

int main(void) {
	cin >> N;
	vector< vector<int> > A(2,vector<int>(N));
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> A[i][j];
		}
	}
	Res = 0;
	dfs(A[0][0],0,0,A);

	cout << Res << endl;

	return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int a, b; std::cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0)
        std::cout << "Possible" << "\n";
    else
        std::cout << "Impossible" << "\n";
}


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

class osa_k{
private:
    vector<int> prime_sieve;
    vector<int> set_prime;
    int N;
    void eratosthenes(){
        for(int i=2;i*i<N;i++) {
            if(prime_sieve[i]<i) continue;
            for(int j=i*i;j<N;j+=i){
                if(prime_sieve[j]==j) prime_sieve[j] = i;
            }
        }                
    }

    void setPrimeSet(){
        for(int i=2;i<N;i++){
            if(prime_sieve[i]==i){
                set_prime.emplace_back(i);
            }
        }        
    }
public:    
    osa_k(const int n):N(n){
        prime_sieve.resize(n);
        iota(prime_sieve.begin(),prime_sieve.end(),0);
        eratosthenes();
        setPrimeSet();
    }

    //例えばi=8の時、{2,2,2}
    vector<int> getFactor(int i) {
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        return res;
    }
    //例えばi=12の時、{{2,2},{3,1}};
    vector<pair<int,int>> getFactorPow(int i) {
        vector<pair<int,int>> res;
        int old=prime_sieve[i];
        int count=0;
        while(i>1){
            if(old==prime_sieve[i]){
                count++;
            }
            else{
                res.emplace_back(make_pair(old,count));
                old=prime_sieve[i];
                count=1;
            }
            i/=prime_sieve[i];
        }
        res.emplace_back(make_pair(old,count));
        return res;
    }    
    //例えばi=8の時、{2}
    vector<int> getFactorSet(int i){
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        //重複を省く
        sort(res.begin(),res.end());
        decltype(res)::iterator result = unique(res.begin(), res.end());
        res.erase(result, res.end());
        return res;
    }
    //素数の集合を得る {2,3,5,7,11,...}
    vector<int> getPrimeSet(){
        return set_prime;
    }
    //iが素数:true
    bool isPrime(const int i){
        if((i==0)||(i==1)){
            return false;
        }
        if(prime_sieve[i]==i){
            return true;
        }
        return false;
    }
};

long long PowMod(long long n,long long k,long long mod) {
    long long r = 1;
 
    for (; k > 0; k >>= 1) {
        if (k & 1) {
            r = (r * n) % mod;
        }
        n = (n * n) % mod;
    }
    return r;
}

int main(){
    int n;cin>>n;
    const int MAX=1000005;
    constexpr int MOD=1000000007;
    osa_k o(MAX);
    vector<int> a(n);
    vector<int> field(MAX);
    for(int i=0;i<n;i++){
        cin>>a[i];
        auto f=o.getFactorPow(a[i]);
        for(auto x:f){
            field[x.first]=max(field[x.first],x.second);
        }
    }
    long long tmp=1;
    for(int i=1;i<MAX;i++){
        tmp*=PowMod(i,field[i],MOD);
        tmp%=MOD;
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=tmp*PowMod(a[i],MOD-2,MOD);
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11624
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] march = new int[5];
		for(int i = 0; i < n; i++){
		    String s = sc.next();
		    if(s.charAt(0) == 'M') march[0]++;
		    if(s.charAt(0) == 'A') march[1]++;
		    if(s.charAt(0) == 'R') march[2]++;
		    if(s.charAt(0) == 'C') march[3]++;
		    if(s.charAt(0) == 'H') march[4]++;
		}
		
		// 計算
		long result = 0;
		for(int i = 0; i < 1<<5; i++){
		    if(Integer.bitCount(i) != 3) continue;
		    long cnt = 1;
		    for(int j = 0; j < 5; j++){
		        if(((i>>j)&1) == 1){
		            cnt *= (long)march[j];
		        }
		    }
		    result += cnt;
		}
		
		// 出力
		System.out.println(result);
	}
}




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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;

    int ans=h2-h1;
    ans*=60;
    ans+=m2-m1-k;

    cout<<max(0,ans)<<"\n";

    return 0;

}

Measured memory_bytes: 3636
N = int(input())
a = input().split()
 
#a_list = [int(i) for i in a]
#a_list_index = [a_list.index(i+1) + 1 for i in range(N)]
#print(' '.join(map(str, a_list_index)))

new_list =[0] * N
for i , b in enumerate(a):
  new_list[int(b)-1] = i + 1
print(' '.join(map(str, new_list)))

Measured memory_bytes: 63788
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  ll ans = 0;
  for (int i=1; i<=N; i++){
    if(i>=10 && i<100) continue;
    if(i>=1000 && i<10000) continue;
    if(i == 100000) continue;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val a = readLine().split(" ").map(_.toInt)

  def solve() = {
    val set = a.toSet
    // All 0
    val allZero = a.forall(_ == 0)

    // 0 and other num.(The number of 0 is n/3, and the number of x is 2n/3)
    val zeroAnd2Types = set(0) && set.size == 2 &&
      a.count(_ == 0) == n/3 && n % 3 == 0

    // 3 nums (x,y,z). (x ^ y ^ z == 0). The number of each num is n/3
    val threeType = set.size == 3 &&
      a.groupBy(identity).toSeq.map(_._2.length).distinct.length == 1 &&
      set.drop(1).foldLeft(set.head) { (acc, num) => acc ^ num } == 0 && n % 3 == 0

    if(allZero || zeroAnd2Types || threeType) "Yes" else "No"
  }

  println(solve())

}



Measured memory_bytes: 64216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        long r = sc.nextLong();
        long min = 2018;
        r = Math.min(r, Math.min(r, l + 2019));
        for (long i = l; i < r; i++) {
            for (long j = i + 1; j <= r; j++) {
                if (i % 2019 == 0) {
                    System.out.println(0);
                    return;
                }
                min = Math.min(min, (i * j) % 2019);
            }
        }
        System.out.println(min);
    }

}


Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
const int maxn = 1e5 + 10;
int vis[maxn] = {0}, n, m, f[maxn];

int father(int x){
    if(x == f[x]){return x;}
    return f[x] = father(f[x]);
}

void unite(int x, int y){
    int fx = father(x), fy = father(y);
    if(fx != fy){
        f[fy] = fx;
    }
}

int main(){
    scanf("%d%d", &n, &m);
    int total = 0;
    for(int i = 1; i <= n; i++){
        f[i] = i;
    }
    for(int i = 0; i < m; i++){
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        unite(x, y);
    }
    for(int i = 1; i <= n; i++){
        if(!vis[father(i)]){
            vis[father(i)] = 1;
            total++;
        }
    }
    printf("%d", total);
    return 0;
}


Measured memory_bytes: 1024
from itertools import product, permutations

while True:
    a = list(map(int, input().split()))
    if a == [0, 0, 0, 0]:
        break
    flag = False
    for op1, op2, op3 in product("+-*", repeat=3):
        for n1, n2, n3, n4 in permutations(a):
            expr_base = "{}{}{}{}{}{}{}".format(n1, op1, n2, op2, n3, op3, n4)
            for expr in (
                expr_base,
                "("+expr_base[:3]+")"+expr_base[3:],
                expr_base[:2]+"("+expr_base[2:5]+")"+expr_base[5:],
                expr_base[:4]+"("+expr_base[4:]+")",
                "("+expr_base[:3]+")"+expr_base[3]+"("+expr_base[4:]+")",
            ):
                if eval(expr) == 10:
                    print(expr)
                    flag = True
                    break
            if flag: break
        if flag: break
    if not flag:
        print(0)



Measured memory_bytes: 5648
#include<cstdio>

int main(){
    int N;
    scanf("%d",&N);
    for(int n = 1; n <= N; n++){
        if(n % 3 == 0){
            printf(" %d",n);
        }
        else{
            int Q = n;
            int r;
            for(int j = 1;; j++){
                r = Q % 10;
                Q = Q / 10;
                if(r == 3){
                    printf(" %d",n);
                    break;
                }
                if(Q == 0){
                    break;
                }
            }
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2724
//arc080_c.cpp
//Sun Jul 14 17:46:52 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n];
	int non = 0;
	int two = 0;
	int four = 0;
	for (int i=0;i<n;i++){
		cin >> a[i];
		if (a[i]%4==0){
			four++;
		}else if (a[i]%2==0){
			two++;
		}else {
			non++;
		}
	}

	if (four>=non && max(0,four-non-two)%2==0){
		cout << "Yes" << endl;
	}else if (four>=non-1 && two == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int dx[8]={1,-1,0,0,1,1,-1,-1},dy[8]={0,0,1,-1,1,-1,1,-1};
void renew(string &x,string y){
	if(x.size()>y.size()) return;
	if(x.size()<y.size()){
		x=y;
		return;
	}
	if(x>y) x=y;
}
int main(){
	while(true){
		int H,W;
		cin>>H>>W;
		if(H==0) break;
		string s[10];
		rep(i,H) cin>>s[i];
		string ans;
		rep(ai,H) rep(aj,W) rep(ad,8){
			//show(ai);
			//show(aj);
			//show(ad);
			string sa;
			int ax=ai,ay=aj;
			do{
				sa+=s[ax][ay];
				ax+=dx[ad],ay+=dy[ad];
				if(ax==H) ax=0;
				if(ay==W) ay=0;
				if(ax==-1) ax=H-1;
				if(ay==-1) ay=W-1;
				//show(ax);
				//show(ay);
			}while(!(ax==ai&&ay==aj));
			//show(sa);
			rep(bi,H) rep(bj,W) rep(bd,8){
				if(s[ai][aj]!=s[bi][bj]) break;
				if(ai==bi&&aj==bj&&ad==bd) continue;
				//show(bi);
				//show(bj);
				//show(bd);
				int bx=bi,by=bj,cnt=0;
				do{
					if(cnt>=sa.size()||sa[cnt]!=s[bx][by]) break;
					cnt++;
					bx+=dx[bd],by+=dy[bd];
					if(bx==H) bx=0;
					if(by==W) by=0;
					if(bx==-1) bx=H-1;
					if(by==-1) by=W-1;
				}while(!(bx==bi&&by==bj));
				renew(ans,sa.substr(0,cnt));
			}
		}
		if(ans.size()<=1) puts("0");
		else cout<<ans<<endl;
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int k=max(A,B)-min(A,B);
  int what=k%2;
  if(what)cout<<"IMPOSSIBLE";
  else cout<<(A+B)/2;
  cout<<endl;
}
    
    
    


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	char S;
	string x[3];
	x[0] = "Sunny";
	x[1] = "Cloudy";
	x[2] = "Rainy";
	cin >> S;
	if (S == 's' || S == 'S')
		cout << x[1];
	else if (S == 'c' || S == 'C')
		cout << x[2];
	else
		cout << x[0];

}

Measured memory_bytes: 3564
#include <bits/stdc++.h> 
using namespace std;
#define endl "\n"

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

	int n, q;
	cin >> n >> q;
	char t[q];
	int dir[q];
	string s;
	cin >> s;
	for (int i = 0; i < q; i++) {
		char a, b;
		cin >> a >> b;
		t[i] = a, dir[i] = (b == 'R') ? 1 : -1;
	}
	int l = -1, r = n;
	while (r - l > 1) {
		int m = (l + r) / 2;
		int cur = m;
		bool flag = false;
		for (int i = 0; i < q; i++) {
			if (s[cur] == t[i]) cur += dir[i];
			if (cur == n) break;
			if (cur == -1) {
				flag = true;
				break;
			}
		}
		(flag) ? l = m : r = m;
	}
	int L = l;
	l = -1, r = n;
	while (r - l > 1) {
		int m = (l + r) / 2;
		int cur = m;
		bool flag = false;
		for (int i = 0; i < q; i++) {
			if (s[cur] == t[i]) cur += dir[i];
			if (cur == -1) break;
			if (cur == n) {
				flag = true;
				break;
			}
		}
		(flag) ? r = m : l = m;
	}
	if (L >= r) cout << 0 << endl;
	else cout << r - L - 1 << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int NUM_BITS = 18;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

// Returns a tuple of (l, u) s.t.
// - l is the minimum value s.t. is_upper_fn(l) is false.
// - r is the minimum value s.t. is_upper_fn(r) is true.
//
// Required:
// - is_upper_fn is a function s.t.
//   - There exists a constant c s.t. is_upper_fn(x) is true for x >= c and
//     is_upper_fn(x) is false for x < c.
// - is_upper_fn(min_value) is false.
// - is_upper_fn(max_value) is true.
//
// Verified: ABC144E
tuple<int64, int64> BinarySearch(function<bool(int64)> is_upper_fn, int64 l, int64 u) {
  while (u - l >= 2) {
    int64 m = (l + u) / 2;
    if (is_upper_fn(m)) u = m; else l = m;
  }
  return make_tuple(l, u);
}

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }
  int64 c;
  cin >> c;

  auto next_table = Make2DVector(NUM_BITS, n, -1);
  for (int i = 0; i < n; i++) {
    next_table[0][i] = i;
    if (i > 0) next_table[0][i] = next_table[0][i - 1];
    while (next_table[0][i] + 1 < n && xs[next_table[0][i] + 1] - xs[i] <= c) {
      next_table[0][i]++;
    }
  }

  for (int b = 1; b < NUM_BITS; b++) {
    for (int i = 0; i < n; i++) {
      next_table[b][i] = next_table[b - 1][next_table[b - 1][i]];
    }
  }

  int q_count;
  cin >> q_count;
  for (int q = 0; q < q_count; q++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);

    auto is_upper_fn = [&](int k) -> bool {
      int v = a;
      for (int b = 0; b < NUM_BITS; b++) {
        if (k & (1 << b)) {
          v = next_table[b][v];
        }
      }
      return v >= b;
    };

    int l = 0;
    int u = n - 1;
    tie(l, u) = BinarySearch(is_upper_fn, l, u);
    cout << u << "\n";
  }
}

Measured memory_bytes: 8696
#include <iostream>

using namespace std;

int main()
{
	int r, c, element;
	int sum_line = 0, sum_all = 0, sum_colum[100] = { 0 };
	cin >> r >> c;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> element;
			cout << element << " ";
			sum_line += element;
			sum_colum[j] += element;
		}
		cout << sum_line << endl;
		sum_all += sum_line;
		sum_line = 0;
	}
	for (int i = 0; i < c; i++) {
		cout << sum_colum[i] << " ";
	}
	cout << sum_all << endl;
	return 0;
}

Measured memory_bytes: 1160
using System;

class Program
{
    public static void Main(){
        var s=Console.ReadLine().Split(' ');
        var a=int.Parse(s[0]);
        var b=int.Parse(s[1]);
        while(a%b!=0){
            var tmp=b;
            b=a%b;
            a=tmp;
        }
        Console.WriteLine(b);
    }
}

Measured memory_bytes: 9068
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

vector<ll> t;
ll T,N;

/* add your algorithm here */

int main() {
  cin >> N >> T;
  ll tt;
  rep(i,N) {
    cin >> tt;
    t.pb(tt);
  }

  ll ans = 0;
  ll tmp = t[0];

  if (N == 1) {
    ans += T;
    cout << ans << endl;
    return 0;
  }

  for (int i = 1; i < N; ++i) {
    bool flag = false;
    if (t[i-1] + T < t[i]) {
      ans += t[i-1] + T - tmp;
      tmp = t[i];
      flag = true;
    }

    if (i == N-1 && flag) {
      ans += T;
    } else if (i == N-1 && !flag) {
      ans += t[i] + T - tmp;
    }
  }

  cout << ans << endl;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		





int main() {

	int mi = 9;
	int ans = 0;
	bool b = false;

	REP(i, 5) {
		int a;
		cin >> a;
		if (a % 10 == 0) {
			ans += a;
			continue;
		}
		b = true;
		ans += (a + 9) / 10 * 10;
		mi = min(mi, a % 10);
	}
	if(b)cout << ans - 10 + mi << endl;
	else cout << ans << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        UL N; cin >> N;
        LL m, M, S;
        m = 1000000000;
        M = -1000000000;
        S = 0;
        rep(i, N) {
            LL a; cin >> a;
            m = min(m, a);
            M = max(M, a);
            S += a;
        }
        cout << m << " " << M << " " << S << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



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

int main()
{
  int H, W, K;
  cin >> H >> W >> K;
  
  int cake[305][305] = {};
  int cnt = 1;
  
  for (int h = 1; h <= H; h++)
  {
    string S; cin >> S;
    for (int w = 1; w <= W; w++)
    {
      if (S[w - 1] - 'a' == '#' -'a')
      {
        cake[h][w] = cnt;
        cnt++;
      }
    }
  }
  
  int num = 1;
  for (int h = 1; h <= H; h++)
  {
    int right = 1, cnt_zero = 0;
    
    for (int w = 1; w <= W; w++)
    {
      if (cake[h][w] == 0) cnt_zero++;
      else if (cake[h][w] == num)
      {
        int left = w - 1;
        for (int v = right; v <= left; v++)
        {
          cake[h][v] = num;
        }
        num++;
        right = w + 1;
      }
      
      if (w == W)
      {
        for (int v = right; v <= W; v++)
        {
          cake[h][v] = num - 1;
        }
      }
      
      if (cnt_zero == W)
      {
        for (int w = 1; w <= W; w++)
        {
          cake[h][w] = 0;
        }
      }
      
    }
  }
  
  // イチゴが乗ってない行を考える
  int top = 1;
  for (int h = 1; h <= H; h++)
  {
    if (cake[h][1] != 0)
    {
      int bottom = h - 1;
      for (int hh = top; hh <= bottom; hh++)
      {
        for (int w = 1; w <= W; w++)
        {
          cake[hh][w] = cake[h][w];
        }
      }
      top = h + 1;
    }
    
    if (h == H)
    {
      for (int hh = top; hh <= H; hh++)
      {
        for (int w = 1; w <= W; w++)
        {
          cake[hh][w] = cake[top - 1][w];
        }
      }
    }
  }
  
  for (int h = 1; h <= H; h++)
  {
    for (int w = 1; w <= W; w++)
    {
      cout << cake[h][w] << " ";
    }
    cout << endl;
  }
  return 0;
  
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
   int A,B,Q; cin >> A >> B >> Q;
   vector<ll> s(A),t(B);
   rep(i,A) cin >> s[i];
   rep(i,B) cin >> t[i];
   rep(i,Q){
       ll x;
       cin >> x;
       ll dist = LINF;
       rep(l,2){
           auto a1 = s.begin(),a2 = s.end(),b1 = t.begin(),b2 = t.end();
           if(l == 1){a1 = s.begin();  a2 = s.end(); b1 = t.begin(); b2 = t.end();}
           else {a1 = t.begin(); a2 = t.end(); b1 = s.begin(); b2 = s.end();}
            rep(j,2){
                int index_1 = (int)(lower_bound(a1,a2,x) - a1) - j;
                if(index_1 >= 0 && index_1 < (int)(a2 - a1+1)){
                    rep(k,2){
                        int index_2 = (int)(lower_bound(b1,b2,(ll)*(a1+index_1)) - b1) - k;
                        if(index_2 >= 0 && index_2 < (int)(b2-b1+1)) dist = min(dist,abs((ll)*(a1+index_1) - x) + abs((ll)*(b1+index_2) - (ll)*(a1+index_1)));
                    }
                }
            }
       }
       cout << dist << endl;
   }
   
}

Measured memory_bytes: 2944
import java.util.Scanner;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	// private static final char GU = 'g';
	private static final char PA = 'p';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.nextLine().toCharArray();
			int p = 0;
			for (char c : s) {
				if (PA == c) {
					p++;
				}
			}
			System.out.println(s.length / 2 - p);
		}
	}
}


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

int main(){
    int n,t;
    vector<pair<int, int> >time(n);
    cin>>n>>t;
    for(int i = 0; i < n; i++) {
        int c,t;
        cin>>c>>t;
        time[i] = make_pair(c,t);
    }
    int ans = 20021003;
    for(int i = 0; i < n; i++) {
        if(time[i].second <= t){
            ans = min(ans, time[i].first);
        }
    }
    if(ans == 20021003){
        cout << "TLE" << endl;
    } else {
    cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 33024
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import queue
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
a = LI()
b = [None for i in range(n-1)]
for i in range(n-1):
    a[i+1] += a[i]
for i in range(n-1):
    b[i] = abs(2*a[i]-a[n-1])
print(min(b))
"""

#D
n = I()
v = [[] for i in range(n)]
for i in range(n-1):
    a,b = LI()
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
d_f = [-1 for i in range(n)]
q = queue.Queue()
q.put(0)
d_f[0] = 0
while not q.empty():
    x = q.get()
    for y in v[x]:
        if d_f[y] == -1:
            d_f[y] = d_f[x] + 1
            q.put(y)
d_s = [-1 for i in range(n)]
q.put(n-1)
d_s[n-1] = 0
while not q.empty():
    x = q.get()
    for y in v[x]:
        if d_s[y] == -1:
            d_s[y] = d_s[x] + 1
            q.put(y)
f = 0
s = 0
for i in range(n):
    if d_f[i] <= d_s[i]:
        f += 1
    else:
        s += 1
if f > s:
    print("Fennec")
else:
    print("Snuke")
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 71980
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    lli n;
    cin >> n;
    string s;
    cin >> s;
    lli w = 0, r = 0;
    for (lli i = 0; i < n;i++)
    {
        if(s[i]=='W')
            w++;
        else
            r++;
    }
    lli x = 0, y = 0;
    for (lli i = 0; i < r;i++)
    {
        if(s[i]=='W')
            x++;
    }
    for (lli i = r; i < n;i++)
    {
        if(s[i]=='R')
            y++;
    }
        cout << min(x, y);
    cout << endl;
    // cout<< fixed << 1.0 * clock() / CLOCKS_PER_SEC << setprecision(10);
    return 0;
}

Measured memory_bytes: 3772
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, a, b = readmi()
print(min(n * a, b))

Measured memory_bytes: 6864