akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(300*300*300+10)

def rec(v):
    if dp[v] != -1:
        return dp[v]
    
    res = 0
    for nv in Graph[v]:
        res = max(res, rec(nv) + 1)
    
    dp[v] = res
    return dp[v]


N, M = map(int, input().split())
G = [[int(_) for _ in input().split()] for _ in range(M)]
dp = [-1]*(N)
Graph = [[] for _ in range(N)]
ans = 0

for i in G:
    Graph[i[0]-1].append(i[1]-1)

for v in range(N):
    ans = max(ans, rec(v))

print(ans)

Measured memory_bytes: 166148
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {


	string s1,s2,s3;

	cin>>s1>>s2>>s3;

	s1=toupper(s1[0]);
	s2=toupper(s2[0]);
	s3=toupper(s3[0]);

	cout<<s1[0]<<s2[0]<<s3[0]<<endl;




	return 0;
}



Measured memory_bytes: 256
//
//  main.swift
//  Atcoder
//
//  Created by Louis Joe Shen on 2020/9/26.
//  Copyright © 2020 Louise Joe Shen. All rights reserved.
//

import Foundation

var input = readLine()!

var ans = ""

for i in input{
    if i == "B"{
        if ans.isEmpty{
            //doing nothing
        }else{
            ans.removeLast()
        }
    }else{
        ans += String(i)
    }
}

print(ans)


Measured memory_bytes: 12928
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> a(n+2);
	vector<int> save(n+1); 
	a[0] = 0;
	a[n+1] = 0;
	for (int i = 1; i <= n; i++) cin >> a[i];

	ll sum = 0;
	for (int i = 0; i <= n; i++){
		sum += abs(a[i] - a[i+1]); 
	}

	for (int i = 0; i < n; i++){
		save[i+1] = abs(a[i] - a[i+1]) + abs(a[i+1] - a[i+2]) - abs(a[i] - a[i+2]);
	}

	for (int i = 1; i <= n; i++){
		cout << sum - save[i] << endl;
	}
}



Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int M = 1e9+7;
const int N = 1e4;
const int D = 1e2;
int dp[N][D][2];
string s;
int n, d;

int f(int id, int mod, int flag) {
    if (id == n) return mod == 0;
    int &r = dp[id][mod][flag];
    if (r != -1) return r;
    r = 0;
    int lim = flag ? 9 : (s[id]-'0');
    forn(dig, 0, lim+1) {
        int next = (mod + dig) % d;
        bool nw_flag = flag || dig < (s[id]-'0');
        r = (r + f(id+1, next, nw_flag)) % M;
    }
    return r;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> s >> d;
    n = s.size();
    
    memset(dp, -1, sizeof dp);
    int ans = (f(0, 0, 0) - 1 + M) % M;
    
    cout << ans << endl;
}


Measured memory_bytes: 12260
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, a, b = MAP()

if n == 2:
	print(0)
	exit()

def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, int(y/2)) ** 2 % mod
    else:
        return power(x, int((y-1)/2)) ** 2 * x % mod

ans = power(2, n)-1

fact = [1]*(2*10**5+2)
for i in range(1, 2*10**5+1):
	fact[i] = (fact[i-1]*i)%mod

def C(n, a):
	tmp = 1
	for i in range(n, n-a, -1):
		tmp = (tmp*i)%mod
	return tmp*power(fact[a], mod-2)

print((ans-C(n, a)-C(n, b))%mod)


Measured memory_bytes: 13524
#include<stdio.h>
int main(){
char str[5];
  for(int i= 0; i<5;i++){
    scanf("%s", &str[i]);
  }
  
  for(int j = 0; j<5; j++){
    if(str[j] == 'A' && str[j+1] == 'C'){
      printf("Yes\n");
      return 0;
    }
  }    
        printf("No\n");
         return 0;
      
  }

Measured memory_bytes: 128
#include <stdio.h>

int add(int a[100], int b) {
	int all = 0;
	for (int c = 0; c < b; c++) {
		all = a[c] + all;
	}
	return all;
}

int main() {
	int N;
	int T[100];
	int M;
	int TM[100];
	int P[100];
	int X[100];
	scanf("%d", &N);
	for (int a=0; a < N; a++) {
		scanf("%d", &T[a]);
	}
	int all = add(T, N);
	scanf("%d", &M);
	for (int a=0; a < M; a++) {
		scanf("%d %d", &P[a], &X[a]);
	}
	for (int a = 0; a < M; a++) {
		int key = P[a] - 1;
		int sum = X[a]-T[key];
		int num = all + sum;
		printf("%d\n", num);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k;
void solve(){
    scanf("%lld%lld%lld",&n,&m,&k);
    if((m+k)%2==0){
        printf("%lld\n",k-(m+k)/2);
    }
    else{
        printf("%lld\n",min(n-k,m-1)+1+(k-m-1)/2);
    }
}
int main(){
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    ll a[n];
    ll b[n];
    REP(i,n)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    REP(i,n)
    {
        if(b[i]==a[n-1])cout<<a[n-2]<<"\n";
        else cout<<a[n-1]<<"\n";
    }
  }
  return 0;
}

Measured memory_bytes: 4736
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#include <complex>
typedef complex<double> P;
double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}
int main() {
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	P line = P(c - a, d - b);
	int query;
	cin >> query;
	REP(i, query) {
		double e, f;
		cin >> e >> f;
		P hypo = P(e - a, f - b);
		P hoge = P(a, b) + line * dot(line, hypo) / pow(abs(line), 2);
		P final_digit = hoge - P(e, f);
		P ans = P(e, f) + final_digit * 2.0;
		cout << fixed << setprecision(10) << ans.real() << " " << ans.imag() << endl;
	}
	return 0;
}


Measured memory_bytes: 3332
import sys

n, m = [int(_) for _ in input().split()]
ans = 0
if n == 1 and m == 1:
    ans = 1
    print(ans)
    sys.exit()
if n == 1:
    ans = m-2
elif m == 1:
    ans = n-2
else:
    ans = (n-2) * (m-2)
print(ans)

Measured memory_bytes: 3060
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main()
        {
            char[] c = new char[] { ' ' };
            string[] ab = Console.ReadLine().Split(c);
            short a = Int16.Parse(ab[0]);
            short b = Int16.Parse(ab[1]);

            if (a > b)
            {
               Console.WriteLine("a > b");
            }
            else if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else
            {
                Console.WriteLine("a == b");
            }
        }
    }
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    string s;
    cin >> s;
    int n=s.size();
    bool flag=true;
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n/2-1-i]) flag=false;
    }
    for(int i=0;i<n;i++){
        if(s[i]!=s[n-1-i]) flag=false;
    }
    if(flag) puts("Yes");
    else puts("No");

    return 0;
}





Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;cin>>n;vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    int q;cin>>q;
    rep(i,0,q){
        int x;cin>>x;
        auto it=lower_bound(all(v),x);
        cout<<(it-v.begin())<<endl;
    }
    
    
}



/*

*/



Measured memory_bytes: 3104
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  string s;
  cin >> s;
  int sum = 0;
  for (auto& c : s) sum += c - '0';
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ch[22];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	ll ans=0;
	for(ll i=2;i<n;i++){
		if(ch[i-2]<ch[i-1]&&ch[i-1]<ch[i]){
			ans++;
		}
		if(ch[i-2]>ch[i-1]&&ch[i-1]>ch[i]){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3604
fun main() {
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
    val takahashi = (c+b-1)/b
    val aoki = (a+d-1)/d
    when {
        takahashi <= aoki -> println("Yes")
        takahashi > aoki -> println("No")
    }
}

Measured memory_bytes: 36372
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int n, t;
	cin >> n;
	
	vector<int> Ai(n+1, 0);
	rep(i, n-1)
	{
		cin >> t;
		Ai.at(t) += 1;
	}

	for (int i = 1; i <= n; ++i)
	{
		cout << Ai.at(i) << endl;
	}

	return 0;
}

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

class Cube {
public:
	int f[6];
	Cube() {}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
};

bool eq(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++)
		if (c1.f[i] != c2.f[i])return false;
	return true;
}

bool equal(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			if (eq(c1, c2))return true;
			c1.roll_z();
		}
		if (i % 2 == 0)c1.roll_y();
		else c1.roll_x();
	}
	return false;
}

Cube C[100]; int n;

bool check() {
	for (int i = 0; i < n - 1; i++)
		for (int j = i + 1; j < n; j++)if (equal(C[i], C[j]))return false;
	return true;
}

int main()
{
	cin >> n;
	for (int j = 0; j < n; j++)
		for (int i = 0; i < 6; i++)cin >> C[j].f[i];

	if (check())cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3112
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;


class P
{
    static void Main()
    {
        int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int min = a.Where(x => x < 3200).Select(x => x / 400).Distinct().Count();
        Console.WriteLine($"{Max(1, min)} {min + a.Count(x => x >= 3200)}");
    }
}


Measured memory_bytes: 13408
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int A,P;

int main() {

	scanf("%d%d", &A,&P);



	printf("%d\n", (A*3+P)/2);

	return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
num = dict()
ans = 0

for i in range(n):
    num[i+a[i]] = 0
    
for i in range(n):
    num[i+a[i]] += 1
    
for i in range(n):
    if i-a[i] in num:
        ans += num[i-a[i]]
        
print(ans)
    


Measured memory_bytes: 40304
N = int(input())
B = list(map(int, input().split()))
A = [0]*N


for i in range(N):
    if i == 0:
        A[i] = B[0]
    elif i == N - 1:
        A[i] = B[N - 2]
    else:
        A[i] = min(B[i], B[i-1])

print(sum(A))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll t = a;
    chmin(t,tmin(b,c,d));
    chmin(t,e);
    cout << (n+t-1)/t+4 << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean[][] cards = new boolean[4][13];
        for (int i=0; i<n; i++) {
            String s = sc.next();
            switch (s.charAt(0)) {
                case 'S':
                    cards[0][sc.nextInt()-1] = true;
                    break;
                case 'H':
                    cards[1][sc.nextInt()-1] = true;
                    break;
                case 'C':
                    cards[2][sc.nextInt()-1] = true;
                    break;
                case 'D':
                    cards[3][sc.nextInt()-1] = true;
                    break;
            }
        }
        char[] c = {'S','H','C','D'};
        for (int i=0; i<4; i++) {
            for (int j=0; j<13; j++) {
                if (!cards[i][j]) {
                    System.out.println(c[i]+" "+(j+1));
                }
            }
        }
    }
}



Measured memory_bytes: 26236
from collections import defaultdict
import sys
sys.setrecursionlimit(100000)

def counter():
    cnt = 0
    while True:
        yield cnt
        cnt += 1

def dfs(here, visited, track, count, connect):
    visited |= {here}
    for c in connect[here]:
        if c not in visited:
            dfs(c, visited, track, count, connect)
    track.append(here)

def kosaraju(here, visited, track, count, connect):
    visited |= {here}
    for c in connect[here]:
        if c not in visited:
            kosaraju(c, visited, track, count, connect)
    track[here] = count

vertices, edges = (int(n) for n in input().split(" "))
connect = defaultdict(list)
reversed_connect = defaultdict(list)
for _ in range(edges):
    v1, v2 = (int(n) for n in input().split(" "))
    connect[v1].append(v2)
    reversed_connect[v2].append(v1)

visited = set()
track_gen = counter()
track = []
for v in range(vertices):
    if v not in visited:
        dfs(v, visited, track, track_gen, connect)

visited = set()
track_gen = counter()
strongly_con = [-1 for n in range(vertices)]
for here in track[::-1]:
    if here not in visited:
        num = next(track_gen)
        kosaraju(here, visited, strongly_con, num, reversed_connect)

q_num = int(input())
for _ in range(q_num):
    v1, v2 = (int(n) for n in input().split(" "))
    if strongly_con[v1] == strongly_con[v2]:
        print(1)
    else:
        print(0)

Measured memory_bytes: 21992
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int box[1024]={0}, num, i;
	double bw, bl;

	i = 0;
	while(scanf("%d,%lf,%lf", &num, &bw, &bl) != EOF){
		if(bw / (bl * bl) >= 25){
			box[i] = num;
			i++;
		}
	}
	i = 0;
	while(box[i] != 0){
		printf("%d\n", box[i]);
		i++;
	}

	return 0;
}

Measured memory_bytes: 632
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B] = input[0].map(Number);

  return (A + B) % 24;
};

console.log(main(read()));


Measured memory_bytes: 29480
#include<stdio.h>
int main(){
    int n,a,b,c,d,count;
    while(scanf("%d",&n)!=EOF){
        count=0;
        for(a=0;a<=9;a++){
            for(b=0;b<=9;b++){
                for(c=0;c<=9;c++){
                    for(d=0;d<=9;d++){
                        if(a+b+c+d==n)count++;
                    }
                }
            }
        }
    printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N, K; cin >> N >> K;
    vector<int> V(N);
    for(int i=0; i<N; i++){
        cin >> V[i];
    }
    
    int R = min(N, K);
    int ans = 0;
    for(int i=0; i<=R; i++){
        for(int j=0; j<=R-i; j++){
            vector<int> C;
            int cur = 0;
            for(int k=0; k<i; k++){
                C.push_back(V[k]);
                cur += V[k];
            }
            for(int k=0; k<j; k++){
                C.push_back(V[N-1-k]);
                cur += V[N-1-k];
            }
            sort(C.begin(), C.end());
            for(int k=0; k<min(i+j, K-i-j); k++){
                if(C[k] > 0) break;
                cur -= C[k];
            }
            ans = max(cur, ans);
        }
    }
    cout << ans << endl;
    return 0;
}



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

const int MOD = 1e9+7;
const int MAX_N = 3006;
int n;
string s;
ll dp[MAX_N][MAX_N], pfx[MAX_N][MAX_N];

void solve()
{
	dp[1][1] = 1;
	for(int i=2;i<=n;i++){
	    for(int x=1;x<=i;x++) pfx[i-1][x]=(pfx[i-1][x-1]+dp[i-1][x])%MOD;
		if(s[i-2]=='<'){
			for(int j=1;j<=i;j++){
			    // 1..j-1
				dp[i][j] = pfx[i-1][j-1];
			}
		}
		else{
			for(int j=1;j<=i;j++){
			    // > prev value j..i-1
				dp[i][j] = (pfx[i-1][i-1]-pfx[i-1][j-1]+MOD)%MOD;
			}
		}
	}
	ll ans = 0;
	for(int x=1;x<=n;++x) (ans+=dp[n][x])%=MOD;
	cout << ans << '\n';
}

int main()
{
	cin >> n >> s;
	solve();
	return 0;
}

Measured memory_bytes: 95916
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		if(y % 2 != 0) {
			System.out.println("No");
			return;
		}

		int sum = 0;
		for(int i = 0; i<= x; i++) {
			sum = i * 2 + (x - i) * 4;
			if(sum == y) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");

	}

}

Measured memory_bytes: 35772
#include<stdio.h>
int main(void){
    int i,j,cnt=0,tmp,N,A[100],min=100,mins=0;
    scanf("%d", &N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    for(i=0;i<N-1;i++){
        min=A[i];
        mins=i;
        for(j=i+1;j<N;j++){
            if(A[j]<min){
                mins=j;
                min=A[j];
            }
        }
        if(mins!=i){
            tmp=A[i];
            A[i]=A[mins];
            A[mins]=tmp;
            cnt++;
        }
    }
    printf("%d",A[0]);
    for(i=1;i<N;i++) printf(" %d",A[i]);
    printf("\n");
    printf("%d\n",cnt);
    return 0;
}

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

using i64 = int64_t;

int main(){
    i64 n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<i64> problems;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        problems.push_back(a);
    }

    sort(problems.rbegin(), problems.rend());

    i64 valid = 0, invalid = n;
    while(abs(valid-invalid) > 1){
        i64 mid = (valid + invalid) / 2;
        if(mid < p){
            valid = mid;
        }else if(problems[mid]+m < problems[p-1]){
            invalid = mid;
        }else{
            i64 sum = (p-1)*m + (n-mid-1)*m;
            for(int i=p-1;i<mid;++i){
                sum += problems[mid]+m-problems[i];
            }
            if(sum >= m*(v-1))valid = mid;
            else invalid = mid;
        }
    }

    cout << valid + 1 << endl;

    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    int n;
    cin>>n;
    int a[n][2];
    for(int i = 0; i < n; i++){
        cin>>a[i][0]>>a[i][1];
    }
    int ans = 0; 
    int flag = 0;
    for(int i = 0; i < n; i++){
          if(a[i][0] == a[i][1]){
              ans++;
          }
          else{
              ans = 0;
          }
          if(ans == 3){
              flag = 1;
          }
          
    }
    if(flag){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll jiyu = 0;
    map<ll, ll> rates;
    cin >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        if(temp >= 3200) jiyu++;
        else rates[temp / 400]++;
    }
    cout << max((ll)rates.size(), (ll)(jiyu > 0LL)) << ' ' << rates.size() + jiyu << endl;
    return 0;
}


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

vector<int> adj[10];

int main(){
  int cnt = 0;
  int n,m;
  cin >> n >> m;

  int i;
  int perm[10];
  rep(i,0,n) perm[i] = i + 1;

  int a,b;
  rep(i,0,m){
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  do{
    for(i = 0;i < n - 1;i++){
      int t = perm[i + 1];
      int k = adj[perm[i]].size();

      int j;
      int flag = 0;
      for(j = 0;j < k;j++){
        if(adj[perm[i]][j] == t) flag = 1;
      }

      if(flag == 0) break;

      if(i == n - 2) cnt++;
    }
  }while(next_permutation(perm + 1,perm + n));

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    string s;
    cin >> s;
    int n = s.size() - 1;
    while (n > 0)
    {
        if (n % 2 == 0)
        {
            bool ok = true;
            repi(i, n / 2, 0)
            {
                if (s[i] != s[i + n / 2])
                    ok = false;
            }
            if (ok)
            {
                break;
            }
        }
        n--;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll A,B,N;
  cin>>A>>B>>N;
  ll i=min(B-1,N);
  ll ans=A*i/B-A*(i/B);
  cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	string s[101];
	int len,n;
	cin>>n>>len;
	for(int i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)
		cout<<s[i];
	return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
print("U"*y+"R"*x,end="")
print("D"*y+"L"*x,end="")
print("L"+"U"*(y+1)+"R"*(x+1)+"D",end="")
print("R"+"D"*(y+1)+"L"*(x+1)+"U")

Measured memory_bytes: 3060
#include<stdio.h>
#define N 200000

int main(void){
  int i,n,max,min,r[N];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d",&r[i]);
  
  max = r[1] - r[0];
  min = r[0];
  
  for(i=1;i<n;i++){
    if(max<r[i]-min) 
      
      max=r[i]-min;   
    
    if(min>r[i]) min=r[i];
  }  
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    cin >> N;
    vector<double> x(N),y(N);
    rep(i,N) cin >> x[i] >> y[i];
    double sum=0;
    vector<int> list(N);
    rep(i,N) list[i]=i;
    do{
        double d=0;
        rep(i,N-1){
            d+=sqrt((x[list[i]]-x[list[i+1]])*(x[list[i]]-x[list[i+1]])+(y[list[i]]-y[list[i+1]])*(y[list[i]]-y[list[i+1]]));
        }
        sum+=d;
    } while (next_permutation(list.begin(),list.end()));
    double z=1;
    rep(i,N) z*=(i+1);
    cout << fixed << setprecision(10);
    cout << sum/z << endl;
}

Measured memory_bytes: 256
N = int(input())

(fst, snd) = (0, 0)
for i in range(N):
    a = int(input())
    if a > fst:
        (fst, snd, argFst) = (a, fst, i)
    elif a > snd:
        snd = a

for i in range(N):
    if i == argFst:
        print(snd)
    else:
        print(fst)



Measured memory_bytes: 4668
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int n = sc.nextInt(), cnt = 0;
		int[] S = new int[n];
		for(int i = 0; i < n; ++i)
			S[i] = sc.nextInt();
		int q = sc.nextInt();
		for(int i = 0; i < q; ++i){
			int t = sc.nextInt();
			if(BinarySearch(S, t)) ++cnt;
		}
		System.out.println(cnt);
	}
	
	static boolean BinarySearch(int[] v, int key){
		int lt = 0, rt = v.length;
		while(lt < rt){
			int mid = (lt+rt) / 2;
			if(v[mid] == key) return true;
			else if(key < v[mid])
				rt = mid;
			else lt = mid + 1;
		}
		return false;
	}

}


class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 50924
//package MyJavaProject;
 
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException; 
import java.io.InputStreamReader;
import java.lang.Math;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigInteger; 
import java.io.PrintWriter;  

public class Main 
{
	static class FastReader 

	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreElements()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken(); 
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        } 
	    }
	
	
	static void print(String s)
	{
		System.out.print(s);
	}
	static void print(boolean s)
	{
		System.out.print(s);
	}
	static Boolean isOverflow( long a, long b) 
    { 
        // Check if either of them is zero 
        if (a == 0 || b == 0)  
            return false; 
      
        long result = a * b; 
        if (a == result / b) 
            return false; 
        else
            return true; 
    } 
	public static void main(String args[]) throws Exception
	{
		FastReader f=new FastReader();
		BufferedWriter w=new BufferedWriter(new OutputStreamWriter(System.out));
		 
		
		
			int n;
			n=f.nextInt();
			long a[]=new long[n];
			for(int i=0;i<n;i++)
				a[i]=f.nextLong();
			long p=1;
			int c=0;
      		Arrays.sort(a);
      		if(a[0]==0)
            {
              System.out.println(0);
              System.exit(0);
            }
			//BigInteger p=new BigInteger("1");
			//BigInteger big=new BigInteger("1000000000000000000");
			for(int i=0;i<n;i++)
			{
				if(isOverflow(p,a[i]))
				{
					System.out.println(-1);
					System.exit(0);
				}
				p*=a[i];
				
					
			}
			
			if(p>(long)(Math.pow(100, 9)))
			{	System.out.println(-1);
			
			}
			else
				
			System.out.println(p);
			
		
	}
}
	

	
	

	
	
	
	
	
	
	
	


Measured memory_bytes: 48944
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static int[] ans;
//	 static int mod = 998244353;
   public static void main(String[] args) {
	          
	   Scanner sc = new Scanner(System.in);
	   String S=sc.next();
	   int  N = sc.nextInt();
	   long[] a = new long[N];
	   long[] b = new long[N];
	   char[] c = new char[N];
	   for (int i=0 ; i<N; i++) {
		   a[i] = Long.parseLong(sc.next());
		   if(a[i]==2) {
			   b[i]=Long.parseLong(sc.next())*2-3;
			   String tmp=sc.next();
			   c[i]=tmp.charAt(0);
		   }
	   }
       
	   int tmp=1;
	   char[] sentou =new char[N];
	   char[] ato = new char[N];
	   int scnt=0;
	   int acnt=0;
	   for(int i=0;i<N;i++) {
		   if(a[i]==1) {
			   tmp=tmp*-1;
		   } else {
			   if(tmp*b[i]==-1) {
				   sentou[scnt]=c[i];
				   scnt++;
			   } else {
				   ato[acnt]=c[i];
				   acnt++;
			   }
		   }
	   }
	   
	   StringBuffer sf= new StringBuffer();
	   
	   if(tmp==-1) {
		   char[] d = S.toCharArray();
		   for(int i=acnt-1;i>=0;i--) {
			   sf.append(ato[i]);		   
		   }
		   for(int i=d.length-1;i>=0;i--) {
			   sf.append(d[i]);	
		   }
		   for(int i=0;i<scnt;i++) {
			   sf.append(sentou[i]);
		   }
	   } else {
		   for(int i=scnt-1;i>=0;i--) {
			   sf.append(sentou[i]);		   
		   }
		   sf.append(S);
		   for(int i=0;i<acnt;i++) {
			   sf.append(ato[i]);		   
		   }		   
	   }
       System.out.println(sf); 
       return;
   }

}


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

typedef unsigned long long  ULL;
typedef long long LL;

#define pb push_back
#define mp make_pair
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define F first 
#define S second

 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
//    cin>>T;
    T=1;
    while(T--){
       
       ULL n,a,b;
       cin>>n>>a>>b;
      ULL t=n/(a+b);
      ULL r=n%(a+b);
       if(r>a){
           cout<<(a*t+a);
       }
       else cout<<(a*t+r);
       
       
       
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int H;
    int W;
    int M;
    cin >> H >> W >> M;

    unordered_map <int, int> rowCnt;
    unordered_map <int, int> colCnt;
    unordered_map <long long, int> cell;
    vector <int> rv;
    vector <int> cv;
    vector <int> mrv;
    vector <int> mcv;

    int maxRow = 0;
    int maxCol = 0;
    const long long OFFSET = 10000000LL;

    for (int i = 0; i < M; ++i) {
        int r;
        int c;
        cin >> r >> c;
        maxRow = max(maxRow, ++rowCnt[r]);
        maxCol = max(maxCol, ++colCnt[c]);
        rv.push_back(r);
        cv.push_back(c);
        cell[r * OFFSET + c] = 1;
    }

    int ans = 0;
    sort(rv.begin(), rv.end());
    sort(cv.begin(), cv.end());

    for (int ri = 0; ri < rv.size(); ++ri) {
        if (ri && rv[ri] == rv[ri-1]) {
            continue;
        }
        if (rowCnt[rv[ri]] == maxRow) {
            mrv.push_back(rv[ri]);
        }
    }

    for (int ci = 0; ci < cv.size(); ++ci) {
        if (ci && cv[ci] == cv[ci-1]) {
            continue;
        }
        if (colCnt[cv[ci]] == maxCol) {
            mcv.push_back(cv[ci]);
        }
    }

    long long comb = (long long) mrv.size() * mcv.size();

    if (comb > M) {
        // pigeon hole
        ans = maxRow + maxCol;
    } else {
        for (int ri = 0; ri < mrv.size(); ++ri) {
            for (int ci = 0; ci < mcv.size(); ++ci) {
                int r = mrv[ri];
                int c = mcv[ci];

                int sum = rowCnt[r] + colCnt[c] - cell[r*OFFSET + c];
                ans = max(ans, sum);
            }
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 50412
#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 n;
	cin >> n;
	
	double res = 0;
	rep(i,n){
		double x;
		string u;
		cin >> x >> u;
		
		if(u=="JPY"){
			res += x;
		}
		else{
			res += x * 380000;
		}
		
	}
	
	printf("%.10f", res);
	return 0;
}

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


int main() {

    int x, y;
    cin >> x >> y;
    vector<int> a = {1,2,1,3,1,3,1,1,3,1,3,1};
    if (a[x-1] == a[y-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
> GREATER
< LESS
= EQUAL
 */
string a,b;

int main(){
  cin>>a>>b;
  if(a.length() > b.length())
    cout<<"GREATER\n";
  else if(a.length() < b.length())
    cout<<"LESS\n";
  else {
    if(a>b)
      cout<<"GREATER\n";
    else if(a<b)
      cout<<"LESS\n";
    else
      cout<<"EQUAL\n";
  }

  return 0;
}


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

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 548
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int dice[6],q,a,b;
    for(int i=0;i<6;i++){
        cin >> dice[i];
    }
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> a >> b;
        if(a==dice[0]){
            if(b==dice[1]){
                cout << dice[2];
            }
            else if(b==dice[2]){
                cout << dice[4];
            }
            else if(b==dice[4]){
                cout << dice[3];
            }
            else if(b==dice[3]){
                cout << dice[1];
            }
        }
        else if(a==dice[1]){
            if(b==dice[0]){
                cout << dice[3];
            }
            else if(b==dice[2]){
                cout << dice[0];
            }
            else if(b==dice[5]){
                cout << dice[2];
            }
            else if(b==dice[3]){
                cout << dice[5];
            }
        }
        else if(a==dice[2]){
            if(b==dice[0]){
                cout << dice[1];
            }
            else if(b==dice[1]){
                cout << dice[5];
            }
            else if(b==dice[4]){
                cout << dice[0];
            }
            else if(b==dice[5]){
                cout << dice[4];
            }
        }
        else if(a==dice[3]){
            if(b==dice[0]){
                cout << dice[4];
            }
            else if(b==dice[4]){
                cout << dice[5];
            }
            else if(b==dice[5]){
                cout << dice[1];
            }
            else if(b==dice[1]){
                cout << dice[0];
            }
        }
        else if(a==dice[4]){
            if(b==dice[0]){
                cout << dice[2];
            }
            else if(b==dice[2]){
                cout << dice[5];
            }
            else if(b==dice[5]){
                cout << dice[3];
            }
            else if(b==dice[3]){
                cout << dice[0];
            }
        }
        else if(a==dice[5]){
            if(b==dice[1]){
                cout << dice[3];
            }
            else if(b==dice[3]){
                cout << dice[4];
            }
            else if(b==dice[4]){
                cout << dice[2];
            }
            else if(b==dice[2]){
                cout << dice[1];
            }
        }
        cout << endl;
        
    }
    
}



Measured memory_bytes: 3092