akhauriyash/Code-Regression huggingface dataset:
/*
                _____________   ______________       __
               / _________  /\ /_____   _____/\     / /\
              / /\       / /  \\    /  /\    \ \   / /  \
             / /  \_____/ /   / \__/  /  \____\/  / /   /
            / /   /    / /   /    /  /   /       / /   /
           / /   /    / /   /    /  /   /       / /   /
          / /   /    / /   /    /  /   /       / /   /
         / /___/____/ /   /    /  /   /       / /___/________
        /____________/   /    /__/   /       /______________/\
        \            \  /     \  \  /        \              \ \
         \____________\/       \__\/          \______________\/
           ___       ___               ___    ___________
          /  /\     /  /\             /  /\  /_______   /\
         /  /__\___/  /  \           /  /  \ \      /  /  \
        /____    ____/   /          /  /   /  \____/  /   /
        \   /   /\   \  /          /  /   /       /  /   /
         \_/   /  \___\/ ___      /  /   /       /  /   /
          /   /   /     /  /\    /  /   /       /  /   /
         /   /   /     /  /__\__/  /   /       /  /___/____
        /___/   /     /___________/   /       /___________/\
        \   \  /      \           \  /        \           \ \
         \___\/        \___________\/          \___________\/

          A FAN OF FIZZYDAVID

*/

#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
//orz jzm
#define ll long long
#define ull unsigned ll
#define orz int
#define yjz main
#define fizzydavid return
#define ak 0
#define la ;
#define plusonesecond {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define minusonesecond exit(0)
const double EPS = 1e-8;
const ll PR = 19260817;
const ll inv2 = 500000004;
const ll inv3 = 333333336;
orz yjz() {
	string s;
	cin>>s;
	int l = s.length(), cnt=0;
	for(int i =0; i<l-1; i++) if(s[i]!=s[i+1]) cnt++;
	cout<<cnt<<endl;
	fizzydavid ak la
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

"""
AABBAABBAABB..が作れることと同値
"""

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

N,M = map(int,input().split())
S = input().rstrip()
# 0-indexedにしておく
AB = [[int(x)-1 for x in row.split()] for row in sys.stdin.readlines()]

# 頂点倍化しておく。同じ色から来る着地点、異なる色から来る着地点
edge = []
for a,b in AB:
    s = S[a]; t = S[b]
    if s == t:
        edge.append((a+N,b))
        if a != b:
            edge.append((b+N,a))
    else:
        edge.append((a,b+N))
        edge.append((b,a+N))

row,col = zip(*edge)

graph = csr_matrix(([1]*len(row),(row,col)),(2*N,2*N))

n_component,_ = connected_components(graph,connection='strong')

answer = 'Yes' if n_component < 2*N else 'No'
print(answer)

Measured memory_bytes: 123848
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int mod = 1e9 + 7;
const int MAXN = 100005;

int n, k;

lint ipow(int x, int p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

int main(){
	vector<int> yaksu;
	cin >> n >> k;
	for(int i=1; i*i<=n; i++){
		if(n % i == 0){
			yaksu.push_back(i);
			if(i * i != n) yaksu.push_back(n / i);
		}
	}
	sort(yaksu.begin(), yaksu.end());
	vector<lint> dp(yaksu.size());
	lint ret = 0;
	for(int i=0; i<dp.size(); i++){
		// dp[i] = (palindrome with exactly yaksu[i] period)
		dp[i] = ipow(k, (yaksu[i] + 1) / 2);
		for(int j=0; j<i; j++){
			if(yaksu[i] % yaksu[j] == 0){
				dp[i] += mod - dp[j];
			}
		}
		dp[i] %= mod;
		ret += dp[i] * (yaksu[i] % 2 ? yaksu[i] : (yaksu[i] / 2));
		ret %= mod;
	}
	cout << ret << endl;
}


Measured memory_bytes: 256
S = input()
if len(S) < 26:
    for i in range(26):
        c = chr(ord('a')+i)
        if c not in S:
            print(S + c)
            exit()
if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

cs = set()
for i in range(25):
    t,tt = S[-i-1],S[-i-2]
    cs.add(t)
    if tt < t:
        last = 'z'
        for c in cs:
            if c < tt: continue
            last = min(last, c)
        print(S[:-i-2] + last)
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

int main(){
    double a,b,x,s,rad;
    lli i,j,k;
    cin>>a>>b>>x;
    s=x/a;
    if(s>(a*b/2)){
        b=(b-s/a)*2;
        rad=atan(b/a);
    }
    else{
        a=2*s/b;
        rad=atan(b/a);
    }
    cout<<fixed<<setprecision(10)<<rad*360/(2*M_PI)<<endl;
}


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

using System.Collections;

class Program
{
    static void Main()
    {
        int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int R = nums[0];
        int G = nums[1];
        int B = nums[2];
        int N = nums[3];

        int ans = 0;

        for(int r = 0; r <= N / R; r++)
        {
            if (N - R * r < 0) break;

            for(int g = 0; g <= N / G; g++)
            {
                int remain = N - R * r - G * g;

                if (remain < 0) break;

                if (remain % B == 0)
                    ans++;
            }
        }

        Console.WriteLine(ans);
    }
}


static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}


Measured memory_bytes: 11348
r, g, b, n = [int(i) for i in input().split()]
t1 = n // r + 1
t2 = n // g + 1
ans = 0
for i in range(t1):
    for j in range(t2):
        t = r * i + g * j
        if (n - t) >= 0 and (n - t) % b == 0: ans += 1
print(ans)


Measured memory_bytes: 40940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }

            int[] X = new int[K + 1];

            for (int i = 0; i < A[0]; i++) {
                X[i] = -1;
            }

            for (int i = 0; i <= K - A[0]; i++) {
                for (int j = 0; j < N; j++) {
                    if (i + A[j] > K) {
                        break;
                    }

                    if (X[i + A[j]] < 1) {
                        X[i + A[j]] = X[i] * -1;
                    }
                }
            }

            String ans = (X[K] == 1) ? "First" : "Second";

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,k;
string s;

int main() {
  cin >> s; 
  int ans=0;
  rep(i,s.size()-1)if(s[i]!=s[i+1]) ans++;
  cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

ll N, K;
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> K;
    
    // bを固定
    ll ans = 0;
    FOR(b, K+1, N+1) {
        ll n = N / b;
        if (N % b >= K) {
            ans += (N % b) - K + 1;
            ans += n * (b-1-K+1);
        } else {
            ans += n * (b-1-K+1);
        }
    }
    if (K == 0) ans -= N;
    cout << ans << endl;
    return 0;
}


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

int main()
{
        ll X, Y; cin >> X >> Y;
        ll a = 0;
        ll b = 0;

        for (int i = 0; i <= X; ++i) {

                a = i;
                b = X-i;
                ll leg = a * 2 + b * 4;
                if (leg == Y) {
                        cout << "Yes" << endl;
                        exit(0);
                }
        }
        cout << "No" << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,k; cin >> n >> k;
    int ans = 0;
    if(k%2 == 1) ans = pow(n/k,3);
    else {
      int x = 2*n/k;
      int a = x/2;
      int b = x-a;
      ans = pow(a,3) + pow(b,3);
    }
    ANS;

    return 0;
}




Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  
  double volume = a*a*b;
  double theta;
  if (volume / 2.0 < x) {
    theta = atan(2.0 * (volume - x) / (a*a*a)) * 180.0 / M_PI;
  }
  else {
    theta = (M_PI * 0.5 - atan(2.0 * x / (b*b*a))) * 180.0/ M_PI;
  }
  cout << fixed << setprecision(16) << theta << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        System.out.print(n*(n-1)/2);
    }
    
}


Measured memory_bytes: 21844
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		String s = "No";
		if(y % 2 == 0){
			y /= 2;
			for(int i=0; i<=x; i++){
				if(2 * i + (x - i) == y){
					s = "Yes";
					break;
				}
			}
		}
		System.out.println(s);
	}
}


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

int main() {
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    int c = max(a, b);
    int d = min(a, b);
    if (abs(c-d) >=2)
        cout << c + (c -1) << endl; 
    else 
        cout << c + d << endl;
    


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N =sc.nextInt();
    int A[] =new int [N];
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();}
    int z=0;
      for(int k=0;k<N;k++){
        z=z+(A[k])*(A[k]);}
    int x=0;
    for(int j=1;j<=100;j++){
      int y=0;
      for(int m=0;m<N;m++){
        y=y+(A[m]-j)*(A[m]-j);}
      z=Math.min(z,y);
      if(z==y){x=y;}}
    System.out.println(x);
  }
}

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

using namespace std;

int main() {
  int n, m, s, c;
  cin >> n >> m;
  vector<int> num(n, -1);
  while (m--) {
    cin >> s >> c;
    if (num[--s] != -1 && num[s] != c || n > 1 && !s && !c) {
      cout << -1 << '\n';
      return 0;
    }
    num[s] = c;
  }
  for (int i = 0; i < n; ++i)
    cout << (num[i] == -1 ? (n > 1 && !i) : num[i]);
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
N =int(input()) 
L = list(map(int, input().split()))
cnt = 0

for i1, l1 in enumerate(L):
    for i2, l2 in enumerate(L[i1+1:]):
        for i3, l3 in enumerate(L[i2+i1+2:]):
            if l1 + l2 > l3 and l2 + l3 > l1 and l3 + l1 > l2 and l1 != l2 and l2 != l3 and l3 != l1:
                cnt += 1
print(cnt)


Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int X = sc.nextInt();
        boolean ans = solve(A, B, X);

        System.out.println(ans ? "YES" : "NO");
    }

    private static boolean solve(int A, int B, int X) {
        if (A <= X && X <= A+B) return true;

        return false;
    }
}


Measured memory_bytes: 23764
n = int(input())
a = sorted(list(map(int, input().split())))
i = n - 1
p = 0
q = 0
while i > 0:
  if a[i] == a[i-1]:
    if p == 0:
      p = a[i]
      i -= 1
    else:
      q = a[i]
      break
  i -= 1
print(p*q)

Measured memory_bytes: 20064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
 int a,b;
 cin>>a>>b;
 if(a*b%2==1) {cout<<"Yes";
 }
 else{cout<<"No";}
}

Measured memory_bytes: 384
A, B, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for i in range(m)]

ans = min(a) + min(b)

for x, y, c in xyc:
    ans = min(ans, a[x - 1] + b[y - 1] - c)

print(ans)

Measured memory_bytes: 38560
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int K = scan.nextInt();
        int C = scan.nextInt();
        String S = scan.next();

        int l[] = new int[N];
        int r[] = new int[N];

        int day = 1;
        for(int i = 0; i < N; i++) {
            if(S.charAt(i) == 'o') {
                l[i] = day++;
                i += C;
            }
        }

        day = K;
        for(int i = N-1; i >=0 ; i--) {
            if(S.charAt(i) == 'o') {
                r[i] = day--;
                i -= C;
            }
        }

        for(int i = 0; i < N; i++) {
            if(l[i] !=0 && l[i] == r[i])
                os.println(i+1);
        }
    }
}

Measured memory_bytes: 55440
n=int(input())
x=0
y=0
t=0
fl=True
for i in range(n):
  nt,nx,ny=map(int,input().split())
  dist=abs(x-nx)+abs(y-ny)
  if (nt-t)%2!=dist%2 or (nt-t)<dist:
    print("No")
    break
  x,y=nx,ny
  t=nt
else:
  print("Yes")

Measured memory_bytes: 69568
//#include "SaveFuncs.cpp"

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
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; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

int Main()
{
	string S, T;
	cin >> S >> T;

	int ret = 0;
	rep(i, 3)
	{
		if (S.at(i) == T.at(i))
		{
			ret++;
		}
	}

	cout << ret;

	return 0;
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	Main();

	return 0;
}


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

#define PB push_back
#define MP make_pair
#define fi first
#define se second

typedef long long LL;

const double EPS=1e-9;
const double PI=acos(-1.0);
const int MAXN=100005;
const LL MOD=1000000007;
const int dx[8]={-1, 0, 1, -1, 1, -1, 0, 1}, dy[8]={-1, -1, -1, 0, 0, 1, 1, 1};

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int stat;

int main(){
	base();
	int n;
	bool rev=0;
	string stat;
	string s1="", s2="";
	cin>>n;
	while(1){
		if(!rev){
			cout<<s1<<'.'<<endl;
			cout<<s2<<'.'<<endl;
			cin>>stat;
			if(stat=="end") return 0;
			if(stat=="T"){
				s1=s1+'.';
				s2=s2+'.';
				continue;
			}
			cout<<s1<<'#'<<endl;
			cout<<s2<<'.'<<endl;
			cin>>stat;
			if(stat=="end") return 0;
			if(stat=="T"){
				s1=s1+'#';
				s2=s2+'.';
				continue;
			}
			cout<<s1<<'.'<<endl;
			cout<<s2<<'#'<<endl;
			cin>>stat;
			if(stat=="end") return 0;
			if(stat=="T"){
				s1=s1+'.';
				s2=s2+'#';
				continue;
			}
			cout<<s1<<'#'<<endl;
			cout<<s2<<'#'<<endl;
			cin>>stat;
			if(stat=="end") return 0;
			if(stat=="T"){
				s1=s1+'#';
				s2=s2+'#';
				continue;
			}
			rev=1;
		}
		else{
			cout<<'.'<<s1<<endl;
			cout<<'.'<<s2<<endl;
			cin>>stat;
			if(stat=="end") return 0;
			if(stat=="T"){
				s1='.'+s1;
				s2='.'+s2;
				continue;
			}
			cout<<'#'<<s1<<endl;
			cout<<'.'<<s2<<endl;
			cin>>stat;
			if(stat=="end") return 0;
			if(stat=="T"){
				s1='#'+s1;
				s2='.'+s2;
				continue;
			}
			cout<<'.'<<s1<<endl;
			cout<<'#'<<s2<<endl;
			cin>>stat;
			if(stat=="end") return 0;
			if(stat=="T"){
				s1='.'+s1;
				s2='#'+s2;
				continue;
			}
			cout<<'#'<<s1<<endl;
			cout<<'#'<<s2<<endl;
			cin>>stat;
			if(stat=="end") return 0;
			if(stat=="T"){
				s1='#'+s1;
				s2='#'+s2;
				continue;
			}
			rev=0;
		}
	}

	return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int)x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9 + 7;
const ll INF = 2e15;
template <class T>
void print(const T& t) {
    cout << t << endl;
}
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

ll evaluate(int contest, int date, vector<ll>& last, vector<ll>& c, vll& s) {
    ll point_today = 0;
    point_today += s[date][contest];
    for (ll j = 1; j <= 26; j++) {
        if (j == contest) {
            continue;
        }
        point_today -= c[j] * (date - last[j]);
    }
    return point_today;
}

int main() {
    ll d;
    cin >> d;  //全日数
    vl c(27);
    for (ll i = 1; i <= 26; i++) {  // c_i==c[i]
        cin >> c[i];
    }
    vll s(d + 1, vl(27));  // s_d,i==s[d][i]
    for (ll i = 1; i <= d; i++) {
        for (ll j = 1; j <= 26; j++) {
            cin >> s[i][j];
        }
    }
    vl t;
    vl last(27, 0);  // last(d,i)==last[i]
    // ll satisfy = 0;
    for (ll date = 1; date <= d; date++) {
        priority_queue<pair<ll, int>> q;
        for (ll contest = 1; contest <= 26; contest++) {
            q.push(mp(evaluate(contest, date, last, c, s), contest));
           // cout<<evaluate(contest, date, last, c, s)<<" ";
        }
        //cout<<endl;
        t.pb(q.top().S);
        // satisfy += q.top().F;
        last[q.top().S] = date;
        
    }
    rep(i, d) { print(t[i]); }
}


Measured memory_bytes: 3720
#include<iostream>

using namespace std;

int main(){
  int liver[4][3][10]={0};

  int n;
  int b,f,r,v;

  int i,j,k;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    liver[b-1][f-1][r-1] += v;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++)
	cout << " " << liver[i][j][k];
      cout << endl;
    }
    if(i==3)
      break;
    cout << "####################" << endl;
  }
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }



int main() {
//    int n,m,q; cin >> n >> m >> q;
//    vector<int> a(q);
//    vector<int> b(q);
//    vector<int> c(q);
//    vector<int> d(q);
//    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
//
//    vector<vector<ll>> dp(q, vector<ll>(q, 0));
//    rep(i, )

    ll a,b,n; cin >> a >> b >> n;
    double ans = floor(a*min(n,b-1)/b);

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
vector<vector<int>> vec(100005);
void f(int i)
{
    int l;
    int max=0;
    for(int j=0;j<vec[i].size();j++)
    {
        if(dp[vec[i][j]]==-1)
            f(vec[i][j]);
        l = dp[vec[i][j]]+1;
        if(l>max)
            max=l;
    }
    dp[i]=max;
}
int main()
{
    int n,m,x,y;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        vec[x].push_back(y);
    }
    for(int i=0;i<100005;i++)
        dp[i]=-1;
    int max=0;
    for(int j=1;j<=n;j++)
    {
        if(dp[j]==-1)
            f(j);
        if(dp[j]>max)
            max=dp[j];
    }
    cout<<max<<endl;
    return 0;
}



        


Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int main(){
    i64 L, R;
    cin >> L >> R;
    if(R - L > 2019)cout << 0 << endl;
    else{
      i64 minmod = 2020;
      for(i64 i = L;i<R;i++){
        for(i64 j=i+1;j<=R;j++){
          minmod = min(minmod, i*j%2019);
        }
      }
      cout << minmod << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
Ds = Counter(list(map(int,input().split())))
m = int(input())
Ts = Counter(list(map(int,input().split())))
check = True
for key,value in Ts.items():
    if key not in Ds:
        check = False
        break
    elif Ds[key]<value:
        check = False
        break
if check:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 57304
def rs(): return input().strip()
def ri(): return int(input())
def ria(): return list(map(int, input().split()))
def ia_to_s(a): return ' '.join([str(s) for s in a])


import math


def solve(a, b, h, m):
    h_a = 90 - 360 / 12 * (m / 60 + h)
    m_a = 90 - 360 / 60 * m
    angle = m_a - h_a

    return (a*a + b*b - 2*a*b*math.cos(angle*math.pi/180))**0.5



def main():
    a, b, h, m= ria()
    print(solve(a, b, h, m))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62560
// AOJ Volume 0 0094

#include <stdio.h>

int main(void)
{
    int a, b;
    double s;
    
    scanf("%d%d", &a, &b);
    
    s = a * b * 10000 / 33057.85;
    
    printf("%lf\n", s);
    
    return (0);
}

Measured memory_bytes: 632
n,q = map(int,input().split())
A = []
B = []
C = []
t = 0

for i in range(n):
    x,y = input().split()
    A.append([x,int(y)])

while len(A)>0:
    f = A[0][1]
    if f<=q:
        t += f
        B.append(A[0][0])
        C.append(t)
    else:
        t += q
        A[0][1] -= q
        A.append(A[0])
    A.pop(0)

for j in range(len(B)):
    print(B[j],C[j])


Measured memory_bytes: 14804
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n;
    if(n==1)
        cout<<"Hello World"<<endl;
    else if(n==2)
    {
        cin>>a>>b;
        int ans=a+b;
        cout<<ans<<endl;
    }


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int INF = 1e9;

lint solve() {
    string S, T;
    cin >> S >> T;
    int N = S.size();
    vector<vector<int>> num(26);
    rep(i, 0, N) num[S[i] - 'a'].push_back(i);
    rep(i, 0, 26) num[i].push_back(INF);
    int l = -1;
    lint ans = 0;
    for(auto c : T) {
        int cn = c - 'a';
        if(num[cn].size() == 1) return -1;
        int n = *upper_bound(num[cn].begin(), num[cn].end(), l);
        if(n == INF) {
            n = num[cn][0];
            ans += N;
        }
        l = n;
    }
    return ans + l + 1;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 1216
V,E,r = map(int,input().split())
edges = [[] for _ in range(V)]
for _ in range(E):
    s,t,d = map(int,input().split())
    edges[s].append([d,t])

def dijkstra(s):
    import heapq
    dist = [float('inf')] * V
    fixed = [False]*V
    dist[s] = 0
    fixed[s] = True
    priority_que = []
    for e in edges[s]:
        heapq.heappush(priority_que,e)

    while len(priority_que):
        edge = heapq.heappop(priority_que)
        if fixed[edge[1]]:
            continue
        v = edge[1]
        dist[v] = edge[0]
        fixed[v] = True
        for ne in edges[v]:
            heapq.heappush(priority_que,[ne[0]+dist[v], ne[1]])
    return dist
dist = dijkstra(r)
for dd in dist:
    if dd == float('inf'):
        print('INF')
    else:
        print(dd)



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

int main() {
  int n;
  cin >> n;
  ll a[n][3];
  rep(i,n)rep(j,3) cin >> a[i][j];

  ll dp[100010][3];
  rep(i,100010)rep(j,3) dp[i][j] = 0;

  rep(i,n)rep(j,3)rep(k,3) {
    if(j == k) continue;
    dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
  }

  ll ans = 0;
  rep(i,3) ans = max(ans, dp[n][i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int n, A[20];

int solve(int i,int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main(){
  int q, m, i;

  scanf("%d", &n);
  for(i = 0;i < n;i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for(i = 0;i < q;i++){
    scanf("%d", &m);
    if(solve(0, m)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

Measured memory_bytes: 1788
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		for(int i=1; i<=3; i++){
			if(i!=a && i!=b){
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 21844
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n, k; cin >> n >> k;
	vector<ll> l(k), r(k);
	rep(i, k) {
		cin >> l[i] >> r[i];
	}
	ll mod = 998244353;
	vector<ll> dp(n + 1);
	vector<ll> sum(n + 1);
	dp[1] = 1;
	sum[1] = 1;
	repi(i,2, n + 1) {
		rep(j, k) {
			//i(現在の数値) - li(集合和の左)　～ i(現在の数値) - ri(集合和の右)の組み合わせの合計を取得したい
			//高速化するために累積和を使用する
			//8 2
			//2 5
			//i = 8の場合
			//3:(8 - 5)～6:(8 - 2)の組み合わせを累積和から計算する
			//sum[6:(8-2)] -  sum[2:(8 - 5 - 1)]
			//右辺最後にマイナス1しているのは1 2 3 4の累積和 1 3 6 10 の2～4の値をとる場合はsum[3] - sum[0]となるため
			ll li = i - r[j];
			ll ri = i - l[j];
			if (ri < 0) continue;
			li = max(li, (ll)1);
			dp[i] += sum[ri] - sum[li - 1] + mod;
			dp[i] %= mod;
		}
		//組み合わせの合計を累積和として更新
		sum[i] = sum[i - 1] + dp[i];
		sum[i] %= mod;
	}
	cout << dp[n] << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


Measured memory_bytes: 6372
// Problem : B - Trick or Treat
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int a[110];

int main()
{
	fastIO;
	int n,k;
	cin >> n >> k;
	rep(i,0,k){
		int d; cin >> d;
		rep(j,0,d) {
			int t; cin >> t;
			a[t]++;
		}
	}		
	int sum = 0;
	rep(i,1,n + 1) {
		if(!a[i]) sum++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3652
n,k=map(int,input().split())
seq=input()

if seq[n-1]=="0":
    seq=seq+"1"
else:
    seq=seq+"0"

l=[]

if seq[0]=="0":
    l.append(0)

st=0
for i in range(n):
    if seq[i:i+2] in ("01","10"):
        l.append(i+1-st)
        st=i+1

if len(l)%2==0:
    l.append(0)

if 2*k+1>=len(l):
    print(sum(l))
else:
    lis=[sum(l[0:2*k+1])]
    for i in range((len(l)-2*k-1)//2):
        lis.append(lis[i]-l[2*i]-l[2*i+1]+l[2*i+2*k+1]+l[2*i+2*k+2])
    print(max(lis))

Measured memory_bytes: 5436
#include <iostream>

using namespace std;

int main (void)
{
    int h, w;
    cin >> h >> w;

    char s[h+2][w+2];
    for (int i = 1; i < h + 1; i++) {
        cin >> &s[i][1];
    }

    // 周囲に壁を作る
    for (int i = 0; i < w + 2; i++) {
        s[0][i] = '-';
        s[h+1][i] = '-';
    }
    for (int i = 0; i < h + 2; i++) {
        s[i][0] = '-';
        s[i][w+1] = '-';
    }
    // ここまで

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

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            int bomb = 0;
            if (s[i][j] == '.') {
                for (int k = 0; k < 8; k++) {
                    int nx = i + dx[k];
                    int ny = j + dy[k];
                    if (s[nx][ny] == '#') {
                        bomb++;
                    }
                }
                s[i][j] = (char)(bomb + '0');
            }
        }
    }

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cout << s[i][j];
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  char ch; cin>>ch;
  if(isupper(ch))
    cout<<"A\n";
  else
    cout<<"a\n";
  return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;
struct eat{
    ll time; ll cost; ll amount;
};

int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> A(N,0);  
    vector<ll> F(N,0);
    for(ll i=0;i<N;i++){
        cin>>A[i]
    ;}
    for(ll i=0;i<N;i++){
        cin>>F[i]
    ;}
    //Aは大きい順Fは小さい順
    sort(A.begin(), A.end());
    sort(F.begin(), F.end());
    reverse(A.begin(), A.end());
    vector<eat> eats(N);
    for(ll i=0;i<N;i++){
        eats[i]=eat{A[i]*F[i],A[i],F[i]}
    ;}

    ll L=-1,R=INF;
    while(L+1<R){
        ll m=(L+R)/2;
        //K2は全員時間m以下にするために必要な修行
        ll K2=0;
        for(ll i=0;i<N;i++){
            if(m<eats[i].time){
                K2+=(eats[i].time-m)/eats[i].amount;
                if((eats[i].time-m)%eats[i].amount!=0)K2++;
            }
        ;}
        if(K2<=K){R=m;}
        else{L=m;}
    }
    cout<<R<<endl;


    return 0;
}


Measured memory_bytes: 8064
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>

using namespace std;

int w,h;
int fie[60][60];
int painted[60][60][2];
int res[2];
int sx[4]={1,0,-1,0};
int sy[4]={0,1,0,-1};

void paint(int x,int y,int c){
	for(int i=0;i<4;i++){
		int nx=x+sx[i],ny=y+sy[i];
		if(nx>=0 && nx<w && ny>=0 && ny<h){
			if(fie[nx][ny]==0 && painted[nx][ny][c]==0){
				painted[nx][ny][c]=1;
				paint(nx,ny,c);
			}
		}
	}
}

int main(void){
	while(1){
		scanf("%d %d",&w,&h);
		if(w+h==0)break;
		for(int i=0;i<h;i++){
			string str;
			cin >> str;
			for(int j=0;j<w;j++){
				if(str[j]=='B')fie[j][i]=1;
				if(str[j]=='W')fie[j][i]=2;
				if(str[j]=='.')fie[j][i]=0;
			}
		}
		memset(painted,0,sizeof(painted));
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(fie[j][i]==1)paint(j,i,0);
				if(fie[j][i]==2)paint(j,i,1);
			}
		}
		res[0]=res[1]=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(painted[j][i][0]==1 && painted[j][i][1]==0)res[0]++;
				if(painted[j][i][0]==0 && painted[j][i][1]==1)res[1]++;
			}
		}
		printf("%d %d\n",res[0],res[1]);
	}
	return 0;
}

Measured memory_bytes: 1332
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	for (int i = 0; i < m; i++) {
		cin >> b.at(i);
	}
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a.at(i).at(j);
		}
	}
	int cnt = 0, sum;
	for (int i = 0; i < n; i++) {
		sum = 0;
		for (int j = 0; j < m; j++) {
			sum += b.at(j) * a.at(i).at(j);
		}
		sum += c;
		if (sum > 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
const int inv2=500000004;
int a[3030];
int dp[3030][3030];
int main()
{
	int n,q,x,y,ans=0;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dp[i][j]=(a[i]>a[j]);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&x,&y);
		for(int j=1;j<=n;j++)
			if(j!=x&&j!=y)
			{
				dp[x][j]=dp[y][j]=(long long)(dp[x][j]+dp[y][j])*inv2%mod;
				dp[j][x]=dp[j][y]=(long long)(dp[j][x]+dp[j][y])*inv2%mod;
			}
		dp[x][y]=dp[y][x]=(long long)(dp[x][y]+dp[y][x])*inv2%mod;
	}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			(ans+=dp[i][j])%=mod;
	for(int i=1;i<=q;i++)
		ans=ans*2%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 35712
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(){
  int a,b,c,d;
  int flag = 0;

  scanf("%d %d %d %d", &a, &b, &c, &d);

  do{
    if(c <= b){
      flag = 1;
      break;
    }

    else c -= b;

    if(a <= d){
      flag = -1;
      break;
    }

    else a -= d;
  }while(a > 0 && c > 0);

  if(flag == 1) printf("Yes\n");

  else if(flag == -1) printf("No\n");
  return 0;
}


Measured memory_bytes: 1648
n, m = map(int, input().split())
List = list(map(int, input().split()))

tokuhyo_sum = sum(List)

count = 0
for i in List:
    if i * 4 * m >= tokuhyo_sum:
        count += 1

if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
A_sum = sum(A)

for i in range(N):
    if A[i] >= B[i]:
        A[i] -= B[i]
    elif A[i] <= B[i]:
        tmp = B[i] - A[i] 
        A[i] = 0
        if A[i+1] >= tmp:
            A[i+1] -= tmp
        else:
            A[i+1] = 0
print(A_sum - sum(A))

Measured memory_bytes: 81892
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
char s[100005];
int a[100005],b[100005];
int t;
int s1,s2,s3;
int main()
{
	int len;
	cin>>s;
	len=strlen(s);
	for(int i=0;i<len;i++)
	{
		if(s[i]=='a')
			s1++;
		if(s[i]=='b')
			s2++;
		if(s[i]=='c')
			s3++;
	}
	t=min(s1,min(s2,s3));
//	cout<<s1<<' '<<s2<<' '<<s3;
	
	if(s1==s2&&s2==s3&&s1==s3)
		cout<<"YES"<<endl;
	else if(((s1==t+1)&&(s2==t)&&(s3==t))||((s2==t+1)&&(s1==t)&&(s3==t))||((s3==t+1)&&(s2==t)&&(s1==t)))
		cout<<"YES"<<endl;
	else if(((s1==t+1)&&(s2==t+1)&&(s3==t))||((s3==t+1)&&(s2==t+1)&&(s1==t))||((s1==t+1)&&(s3==t+1)&&(s2==t)))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

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

int main()
{
  int a, b, c; cin >> a >> b >> c;
  if (a == b && b == c && c == a)
    cout << "No" << endl;
  else if (a != b && b != c && c != a)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

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

int main()
{
  int n;
  string s;
  double x,y,a,b,ans=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    x=(s[0]-'0')*10+(s[1]-'0');
    y=(s[3]-'0')*10+(s[4]-'0');
    a=(x+y/(60))*5;
    b=y;
    ans=min(6*abs(a-b),360-6*abs(a-b));

    if(ans<30)cout<<"alert"<<endl;
    else if(90<=ans && ans<=180)cout<<"safe"<<endl;
    else cout<<"warning"<<endl;
  }

  return 0;
}

Measured memory_bytes: 1188
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ns := make([]int, n)
	for i := range ns {
		fmt.Scan(&ns[i])
	}

	max := 0
	ans := 0
	for _, n := range ns {
		if n >= max {
			max = n
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
sa = input()
sb = input()
sc = input()

marker = 'a'

na = 0
nb = 0
nc = 0

while True:
    if marker == 'a':
        if na == len(sa):
            print('A')
            exit()
        marker = sa[na]
        na += 1
    elif marker == 'b':
        if nb == len(sb):
            print('B')
            exit()
        marker = sb[nb]
        nb += 1
    else:
        if nc == len(sc):
            print('C')
            exit()
        marker = sc[nc]
        nc += 1


Measured memory_bytes: 38256
# https://atcoder.jp/contests/abc093/tasks/abc093_b

import itertools
import collections
import bisect

def main():
    A, B, K = map(int, input().split())
    ans = []
    for i in range(K):
        if A <= A + i <= B:
            ans.append(A + i)
        else:
            break
    for i in range(K):
        if A <= B - i <= B :
            ans.append(B - i)
        else:
            break

    # print(ans)
    ans = list(set(ans))
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#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>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  int r;
  cin >> r;
  double ans = 6.28 * r;
  cout << setprecision(20) << fixed << ans << endl;
}

Measured memory_bytes: 3768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int R = Integer.parseInt(reader.readLine());
    System.out.println(2*R*Math.acos(-1));
  }
}

Measured memory_bytes: 32984
n = int(input())
prime = [0]
for i in range(3, 100001, 2):
    count = 0
    count2 = 0
    for j in range(1, int(i ** 0.5) + 1):
        if i % j == 0:
            count += 1
    for j in range(1, int(((i+1)//2) ** 0.5) + 1):
        if ((i+1)//2) % j == 0:
            count2 += 1
    if count == count2 == 1:
        prime.append(1)
    else:
        prime.append(0)

def cum_sum(lst):
    cums = [0] * (len(lst)+1)
    cums[1] = lst[0]
    for i in range(2,len(lst)+1):
        cums[i] = cums[i-1] + lst[i-1]
    return cums

prime = cum_sum(prime)
for i in range(n):
    l,r = map(int,input().split())
    print(prime[r//2+1]- prime[l//2])



Measured memory_bytes: 55004
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
s = input()
n = len(s)
ans = 0

for i in range(2 ** (n - 1)):
    k = 0
    num_list = []
    for j in range(n):
        if (i >> j) & 1:
            num = s[k : j + 1]
#             print(num)
            k = j + 1
            num_list.append(int(num))
#             print(num_list)
    num = s[k : n +1]
    num_list.append(int(num))
    ans += sum(num_list)
print(ans)

Measured memory_bytes: 9044
n = int(input())
a = list(map(int, input().split()))
 
d = {}
for i in range(1, n+1):
    k = i - a[i-1]
    if k in d:
        d[k] += 1
    else:
        d[k] = 1
ans = 0
for i in range(1, n+1):
    k = a[i-1]+i
    if k in d:
       ans += d[k]
print(ans)

Measured memory_bytes: 40408
using System;
using System.Linq;

namespace ABC114_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var min = int.MaxValue;
            foreach (var i in Enumerable.Range(0, s.Length - 2))
            {
                var temp = Math.Abs(753 - int.Parse(s.Substring(i, 3)));
                if (temp < min)
                {
                    min = temp;
                }
            }

            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 11220
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N = int(input())
temp = N
ans= ""
t = 26
count = 1

while True:
  if(N<=t):
    break
  else:
    N -= t
    t=t*26
    count+=1

#N = temp

#for i in range(count):
  

for i in reversed(range(1,count)):
  ans += chr(96+(N-1)//(26**i)+1)
  #print(N,i,(N-1)//(26**i))
  N = N-(26**i)*((N-1)//(26**i))
  #print(i)

#print(N)
if(N==0):
  ans += chr(96+26)
else:
  ans += chr(96+N)

#ans += chr(96+N)
#ans += chr(96+temp%26)

print(ans)


Measured memory_bytes: 75036