akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABC = ReadSplitInt();
            Println(ABC[1] / ABC[0] > ABC[2] ? ABC[2] : ABC[1] / ABC[0]);
        }

        static List<int> ReadLines(int n)
        {
            var l = new List<int>();
            for (int i = 0; i < n; i++)
            {
                l.Add(ReadInt());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11348
n,a,b=map(int,input().split())
x=n//(a+b)
y=n%(a+b)
print(a*x+min(y,a))
# if a==0:
#     print(0)
# else:
    # x=n//(a+b)
    # y=n%(a+b)
    # print(a*x+min(y,a))

Measured memory_bytes: 3060
import math
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

mod = 10 ** 9 + 7
ans = 0
def eratos(num):
    dp = [True] * (num)
    dp[0] = dp[1] = False # 0, 1をFalseに
    sqrt_num = int(num ** 0.5) + 1
    for i in range(2, sqrt_num):
        if dp[i]:
            for j in range(i**2, num, i):
                dp[j] = False
    primes = []
    for index, k in enumerate(dp):
        if k:
            primes.append(index)
    return primes
primes = eratos(n + 1)

m = []
for p in primes:
    t = 0
    for i in range(1, n + 1):
        while i % p == 0:
            t += 1
            i //= p
    m.append(t)
ans = 1
for k in m:
    ans *= (k + 1) % mod
print(ans % mod)


Measured memory_bytes: 39280
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  int n;
  scanf("%d", &n);
  int cx = 0;
  int cy = 0;
  int ct = 0;
  REP(i, n) {
    int x, y, t;
    scanf("%d%d%d", &t, &x, &y);
    int d = abs(cx-x) + abs(cy-y);
    int parity = (x ^ y) & 1;
    if(!(d <= t-ct && t % 2 == parity)) {
      puts("No");
      return 0;
    }
    ct = t;
    cx = x;
    cy = y;
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
class Main{
	
	static int gcd(int a, int b){
		return b==0 ? a:gcd(b,a%b);
	}
    public static void main(String[] args){
    BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
    try {
		int n = Integer.valueOf(sc.readLine());
		String[] st = sc.readLine().split(" ");
		int map[] = new int[n];
		for(int i=0; i<n; i++)
			map[i] = Integer.valueOf(st[i]);
		int c = gcd(Math.max(map[0],map[1]),Math.min(map[0],map[1]));
		if(n==3)
			c = gcd(Math.max(c,map[2]),Math.min(c,map[2]));
		for(int i=1; i<=c; i++)
			if(c%i==0)
				System.out.println(i);
    }catch(Exception e){
        System.out.println("Error");
    }
    }
}

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

check = 0
ans = 0
for n in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        check += 1
        ans = max(ans,check)
    else:
        check = 0
        ans = max(ans,check)
print('Yes' if ans >= 3 else 'No')

Measured memory_bytes: 9192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/

int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	vector<lint>B(N);
	vector<lint>C(N);
	lint cnt = 0;
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) {
		cin >> B[i];
	}
	rep(i, N) {
		cin >> C[i];
	}
	sort(A);
	sort(C);
	lint ans = 0;
	rep(i, N) {
		cnt = (upper_bound(A.begin(), A.end(), B[i]-1) - lower_bound(A.begin(), A.end(), 0))*(N-(upper_bound(C.begin(), C.end(), B[i]) - lower_bound(C.begin(), C.end(), 0)));
		ans += cnt;
	}
	cout << ans << endl;
}




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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second

#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

#define rv(type,name,count) vector<type> name(count); FOR(_i,0,count) cin >> name[_i];
#define grid(type,name,c1,c2) vector<vector<type>> name(c1, vector<type>(c2)); FOR(_i,0,c1)FOR(_j,0,c2)cin >> name[_i][_j];

int main() {
	ll n;
	cin >> n;
	vl best(3);
	while(n--) {
		vl x(3); FOR(i,0,3) cin >> x[i];
		vl nb(3);
		FOR(i,0,3) {
			nb[i] = x[i] + max(best[(i+1)%3], best[(i+2)%3]);
		}
		best = nb;
	}
	cout << max(best[0], max(best[1], best[2])) << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
restB1 = 0
restB2 = 0
for i in range(N):
  restB1 = B[i]-A[i]
  if restB1 <= 0:
    ans += B[i]
  else:
    restB2 = restB1-A[i+1]
    if restB2 <= 0:
      A[i+1] -= restB1
      ans += B[i]
    else:     
      ans += A[i]+A[i+1]
      A[i+1] = 0

print(ans)  


Measured memory_bytes: 18376
#include <stdio.h>

int main(void) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    if ( a - b < c ) {
        printf("%d\n", (c - (a-b)));
    }
    else {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
#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>;

const int INF = 1001001001;

int a[12][12];

int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i, n)
  {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  int ans = INF;

  rep(s, 1 << n)
  {
    int cost = 0;
    vector<int> d(m);
    rep(i, n)
    {
      if (s >> i & 1)
      {
        cost += c[i];
        rep(j, m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j, m) if (d[j] < x) ok = false;
    if (ok)
      ans = min(ans, cost);
  }

  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3576
n, m, x=map(int, input().split())
a=list(map(int, input().split()))

a.append(x)
a.sort()

cut=0
for i in range(n):
    if a[i]==x:
        cut=i
        break

R=len(a[cut+1:])
L=len(a[:cut])

print(min(R, L))

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

namespace abc155_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var A = CIn.ReadIntArray(N);

      var b = A.Where(e => e % 2 == 0).All(e => e % 3 == 0 || e % 5 == 0);

      Console.WriteLine(b ? "APPROVED" : "DENIED");
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 11348
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTP(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;

bool palindrome(std::string s) {
    int l = 0;
    int n = s.size();
    while (l < n - l) {
        if (s[l] != s[n-1-l])
            return false;
        l++;
    }
    return true;
}

int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    std::string s;
    std::cin >> s;
    int n = s.size();
    std::string sub1 = s.substr(0, (n-1)/2);
    std::string sub2 = s.substr((n-1)/2+1, n - n/2);
    std::cout << (palindrome(s) && palindrome(sub1) && palindrome(sub2) ? "Yes" : "No");

    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 256
#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)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];


    int ans = 0;

    rep(i, n)  {
        bool flag = true;
        int tmp_h = h[i];
        int tmp_ans = 0;
        for(int j=i+1; j < n; j++) {
            if(tmp_h >= h[j]) tmp_ans++;
            else {
                chmax(ans, tmp_ans);
                flag = false;
                break;
            }
            tmp_h = h[j];
        }
        if(flag) {
            chmax(ans, tmp_ans);
            break;
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	char c;
	std::cin >> c;
	std::cout << ((c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o') ? "vowel" : "consonant") << std::endl;
}

Measured memory_bytes: 256
#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) {
    string B;
    ll A, A2, B1, B2;
    cin >> A >> B;
    auto iter = find(B.begin(), B.end(), '.');
    B1 = stoll(string(B.begin(), iter));
    if(iter == B.end()) B2 = 0;
    else B2 = stoll(string(iter + 1, B.end()));
    cout << A * (B1 * 100 + B2) / 100 << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(void)
{
	int payment;
	int num_1yen;
	cin >> payment >> num_1yen;

	if ((payment % 500) <= num_1yen) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
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 main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	set<int>values;
	rep(i, n) {
		values.insert(a[i]);
	}
	cout << values.size() << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 100000 + 5

int n, k, seg;
char s[N];

int main()
{
	scanf("%d%d", &n, &k);
	scanf("%s", s);
	for (int i = 0; i < n; i ++)
		seg += (!i || s[i] != s[i - 1]);
	if (seg / 2 <= k)
		printf("%d\n", n - 1);
	else printf("%d\n", n - seg + 2 * k);
	return 0;
}

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

int main() {
  int n; cin >> n;
  int L[n];
  for(int i = 0; i < n; i++) cin >> L[i];

  sort(L, L+n);
  int sum = 0;
  for(int i = 0; i < n-1; i++) sum += L[i];
  cout << (L[n-1] >= sum ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main() {
  int N, D; cin >> N >> D;

  int ans = 1;
  for (int i = 2 * D + 2; i <= N; i += 2 * D + 1) {
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

public class Test{
    public static void Main(){
        var line = System.Console.ReadLine();
      	string[] str = line.Split(' ');
      	int[] num = new int[str.Length];
		for(int i=0; i<num.Length; ++i){
          num[i] = int.Parse(str[i]);
        }
      	rep(num, 0, 1);
      	rep(num, 0, 2);
		for(int i=0; i<num.Length; ++i){
          if(i != num.Length){
            System.Console.Write(num[i] + " ");
          } else {
            System.Console.WriteLine(num[i]);
          }
        }
    }
  
  	public static void rep(int[] num, int a, int b){
      	int tmp = num[a];
      	num[a] = num[b];
      	num[b] = tmp;
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {

	ULL n; cin >> n;
	ULL ans = (ULL)-1;
	for(ULL i = 1; i*i <= n; i++) {
		if (n % i == 0)
			ans = min(ans, (i - 1) + ((n / i) - 1));
	}
	cout << ans << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int l,r,d;
  cin >> l >> r >> d;
  cout << r/d-(l-1)/d << endl;
}


Measured memory_bytes: 3632
#include<stdio.h> 
#include<string.h>
#include<math.h>
int main(){
char a[5];
int i;
		scanf("%s",a);
	 	for(i=1;i<4;i++)
	{
		if(a[i-1]==a[i])
		{
			printf("Bad\n");
			return 0;
		}
	 } 
	 printf("Good\n");
return 0;
}


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

int a[2 * 100000 + 5];

int main() {
  memset(a, 0, sizeof(a));

  int N;
  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> a[i];

  std::sort(a, a + N);

  std::map<int, int> remaining;
  for (int i = 0; i < N; ++i) {
    if (remaining.count(a[i]) == 0)
      remaining[a[i]] = 0;
    remaining[a[i]]++;
  }

  int ans = 0;
  int max_b = 31;
  for (int i = N - 1; i >= 0; --i) {
    int x = a[i];
    if (remaining.at(x) == 0) continue;
    for (int b = max_b; b >= 0; --b) {
      long long target = (1ll << b);
      int y = target - x;
      if (remaining.count(y) == 0) continue;
      if (remaining.at(y) <= 0) continue;
      if (x == y && remaining.at(x) <= 1) continue;
      ans++;
      remaining[y]--;
      remaining[x]--;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){

    int h,w;

    while(true){
        cin >> h >> w;
        if(h==0 && w==0){
            break;
        }
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                // 一行目 or 最終行のとき
                if(i==0 || i==h-1){
                    if(j==w-1){
                        cout << "#" << endl;
                        break;
                    }
                    cout << "#";
                }else{
                    if(j==0){
                        cout << "#";
                        continue;
                    }else if(j==w-1){
                        cout << "#" << endl;
                        continue;
                    }else{
                        cout << ".";
                    }
                }
            }
        }
        cout << "" << endl;
    }

    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 18) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 300010;

int n;
int a[MAXN];
char s[MAXN];

int main()
{
	
	scanf("%d", &n);
	scanf("%s", s+1);
	for (int i = 1; i <= n; ++ i)
		a[i] = a[i-1]+(s[i] == 'E');
	int ans = n;
	for (int i = 1; i <= n; ++ i)
	{
		ans = min(ans, (i-1-a[i-1])+(a[n]-a[i]));
	}
	printf("%d\n", ans);
	
	return 0;
}


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

typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int BIG = 1e9 + 555;
const int maxN = 1e5 + 55;

int n;
ll fact[maxN], rev[maxN];

ll quickPow(ll x, ll y){
	if(y == 0){
		return 1;
	}

	ll tmp = quickPow(x, y / 2);
	if(y % 2){
		return (((tmp * tmp) % MOD) * (x % MOD)) % MOD;
	}

	return (tmp * tmp) % MOD;
}

void preCal(){
	fact[0] = 1;
	for(int i = 1; i < maxN; i++){
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	
	
	for(int i = 1; i < maxN; i++){
		rev[i] = quickPow(i, MOD - 2);
	}

	for(int i = 1; i < maxN; i++){
		rev[i] = (rev[i] + rev[i - 1]) % MOD;
	}
}

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

	preCal();

	cin >> n;
	
	ll fRes = 0;

	for(int i = 1; i <= n; i++){
		ll x;	cin >> x;
		ll rt = (((rev[i] + rev[n - i + 1]) % MOD) - 1 + MOD) % MOD;
		
		rt = (fact[n] * rt) % MOD;

		fRes = (fRes + ((x * rt) % MOD)) % MOD;
	}
	
	cout << fRes << '\n';

	return 0;
}

Measured memory_bytes: 1792
from sys import stdin
input = stdin.readline

q = int(stdin.readline())

def solve():
    xs = input()
    ys = input()
    len_x = len(xs)-1
    len_y = len(ys)-1
    # [i,j]までで一番長い数値とする
    dp = [0] * (len_x+1)
    memo = [0] * (len_x+1)

    for j in range(len_y):
        yj = ys[j]
        # 参照コピーにならない
        memo = dp[:]
        for i in range(len_x):
            if xs[i] == yj:
                dp[i+1] = memo[i] + 1
            elif dp[i+1] < dp[i]:
                dp[i+1] = dp[i]
    return dp[len_x]


ret = [ solve() for i in range(q)]
print(*ret, sep="\n")


Measured memory_bytes: 5636
#pragma region Imports
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#pragma endregion
#pragma region Macros
#pragma GCC optimize (2)
#define uns unsigned
#define out cout
#define in cin
#define au auto
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define elif else if
#define sz(x) x.size()
#define fl(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define fli(i, a, b, c) for(int (i)=a;(i)<(b);(i)+=(c))
#define fr(i, x) for(int (i)=(x)-1;(i)>=0;(i)--)
#define fb(i, x) for(int (i)=0;(i)<(x);(i)++)
#define fa(i, x) for(auto& (i):(x))
#define ia(a, n) for(int qw=0;qw<(n);qw++)cin>>(a)[qw];
#define oa(a, n) for(int qw=0;qw<(n);qw++)cout<<(a)[qw]<<" ";
#define im(a, n, m) fb(i,(n))fb(j,(m))cin>>(a)[i][j];
#define om(a, n, m) fb(i,(n))fb(j,(m))cout<<(a)[i][j]<<" \n"[j==(m)-1];
#define eb(v, x) (v).emplace_back(x);
#define seb(s, x) (s).emplace(x);
#define pr(x, y) pair<x,y>
#define vr(x) vector<x>
#define mp(x, y) make_pair(x,y)
#define hm(x, y) map<x,y>
#define um(x, y) unordered_map<x,y>
#define stk(x) stack<x>
#define qu(x) queue<x>
#define dq(x) deque<x>
#define pq(x) priority_queue<x>
#define pqm(x) priority_queue<x,vector<x>,greater<(x)>>
#define mem(a, x) memset(a,(x),sizeof(a));
#define fi(x) (x).first
#define se(x) (x).second
#define ql(x) int tc;tc=(x);if(tc==-1)cin>>tc;while(tc--)
#define srt(x) sort((x).begin(),(x).end());
#define pops(y, x) auto (y)=(x).front();(x).pop();
#define ppc(x) __builtin_popcount((x))
#define all(x) (x).begin(),(x).end()
#define sieve(b, n) bool (b)[(n)];mem((b),true);int sq=int(sqrt(n))+1;(b)[0]=(b)[1]=false;fl(i,2,sq)if((b)[i])fli(j,i*i,n,i)(b)[j]=false;
#define dbg(x) cout<<#x<<" "<<(x)<<"\n";
#pragma endregion
#pragma region Typedefs and Consts
typedef long long int ll;
typedef unsigned long long int ull;
typedef string stg;
typedef float flo;
typedef char chr;
typedef vector<int> vi;
const ull mod = 1000000007;
const int imx = INT_MAX;
const int imn = INT_MIN;
const ll lmx = LLONG_MAX;
const ll lmn = LLONG_MIN;
#pragma endregion
#pragma region Functions
inline ull powm(ull x,ull y,bool b=false,ull m=mod){ if(b){ ull t=1;x%=m;while(y>0){ if(y%2)t=(t*x)%m;y=y>>1;x=(x*x)%m; }return t; }else
    { ull t=1;while(y>0){ if(y&2)t*=x;y=y>>1;x*=x; }return t;}}
inline ll gcd(ll a,ll b){a=abs(a);b=abs(b); while(b!=0){ ll c=a%b;a=b;b=c;}return a;}
#pragma endregion
ll d[100][100001];
//cout<<"Case #"+to_string(tc+1)+": "+to_string(z)<<endl;
ll f(ll a[][2],int n,int i,int v,int s){
  if(v==0)
    return 0;
  if(i==n or v<0 or v-s>0)
    return 1000000000000L;
  if(d[i][v]==-1){
    d[i][v]=min(f(a,n,i+1,v-a[i][1],s-a[i][1])+a[i][0],f(a,n,i+1,v,s-a[i][1]));
  }
  //out<<i<<" "<<v<<" "<<d[mp(i,v)]<<endl;
  return d[i][v];
}
int main() {
    fio
    int n;
    ll w;
  	in>>n>>w;
  	ll a[n][2];
  	fb(i,n)
      in>>a[i][0]>>a[i][1];
    int s=0;  
    fb(i,n)
      s+=a[i][1];
    fb(i,n)
    fb(j,s+1)
    d[i][j]=-1;
  	for(int i=s;i>=0;i--)
      if(f(a,n,0,i,s)<=w){
        out<<i;
        break;
      }
    return 0;
}

Measured memory_bytes: 78336
#include<iostream>
#include<set>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
#define pb push_back
template<typename T>void read(T &x)
    {
        register T c = getchar(); x = 0; int t = 0;
        if (c == '-') t = 1, c = getchar();
        for (; (c < 48 || c > 57); c = getchar());
        for (; c > 47 && c < 58; c = getchar()) {
            x = (x << 1) + (x << 3) + c - 48;
        }
        if (t) x = -x;
    }
int main()
{
//ios_base::sync_with_stdio(false); cin.tie(NULL);
string s1,s2;
cin>>s1>>s2;
if(s1[0]==s2[2] && s1[1]==s2[1] && s1[2]==s2[0])cout<<"YES";
else cout<<"NO";
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    bool used[14]={},ans;
    for(int i=0,a;i<6;i++)
      cin>>a,used[a]=1;
    if(used[13]&&used[1])ans=0;
    else if(!used[1]&&!used[13])ans=1;
    else{
      int l=6,r=8,t=0;
      if(used[1]){
	while(1){
	  if(t){
	    if(!used[r])r++;
	    else if(!used[l])l--;
	  }
	  else{
	    if(used[l])l--;
	    else if(used[r])r++;
	  }
	  if(r==13){ans=0;break;}
	  if(l==1){ans=1;break;}
	  t=!t;
	}
      }
      else{
	while(1){
	  if(t){
	    if(!used[l])l--;
	    else if(!used[r])r++;
	  }
	  else{
	    if(used[r])r++;
	    else if(used[l])l--;
	  }
	  if(r==13){ans=1;break;}
	  if(l==1){ans=0;break;}
	  t=!t;
	}
      }
    }
    if(ans)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY")
      ans += x;
    else
      ans += x * 380000.0;
  }
  printf("%11lf", ans);
}


Measured memory_bytes: 256
sa=list(input())
sb=list(input())
sc=list(input())
sa.append('A')
sb.append('B')
sc.append('C')
s=sa
for _ in range(len(sa+sb+sc)+1):
  if len(s)==1:
    print(s[0])
    exit()
  if s[0]=='a':
    s.pop(0)
    s=sa
  elif s[0]=='b':
    s.pop(0)
    s=sb
  elif s[0]=='c':
    s.pop(0)
    s=sc 

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
   int i,j,n;
    scanf("%d",&n);
    double m[n+1][n+1];
    double p[n],k=0.0;
    for(i=0;i<n;i++)
        scanf("%lf",&p[i]);
    for(i=0;i<n+1;i++)
    {
        for(j=0;j<n+1;j++)
            m[i][j]=0.0;
    }
    m[0][0]=1;
    for(i=1;i<n+1;i++)
    {
        for(j=0;j<n+1;j++)
        {
            if(j==0)
                m[i][j]=m[i-1][j]*(1-p[i-1]);
            else
                m[i][j]=p[i-1]*m[i-1][j-1]+m[i-1][j]*(1-p[i-1]);
        }
    }
    for(i=n/2+1;i<n+1;i++)
        k +=m[n][i];
    printf("%0.10lf",k);
    return 0;


}


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

int A, B, C, X;
int main(){
  cin >> A >> B >> C >> X;
  int res =0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; 
        if (total == X) ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define pb push_back
 
int main(){
    while(1){
        ll n,p,j;
        ll sum = 0 , cnt[1002] = {};
        scanf("%lld",&n);
        if(n == 0)break;
        for(int i = 0 ; i < n ; i ++){
            scanf("%lld",&p);
            sum += p;
        }
        for(int i = 0 ; i < n-1 ; i ++){
            scanf("%lld",&j);
            sum += j;
            cnt[j] ++;
        }
        ll ret = sum , num = 1 , t = 0;
        while(num < n){
            while(cnt[t] == 0)t ++;
            sum -= t;
            num ++;
            cnt[t] --;
            ret = max ( ret , sum*num );
        }
        printf("%lld\n",ret);
    }
}

Measured memory_bytes: 3204
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	h, e := intScanln(n)
	if e != nil {
		panic(e)
	}

	var c int
	for _, hi := range h {
		if hi >= k {
			c++
		}
	}

	fmt.Println(c)
}

func intScanln(n int) ([]int, error) {
	x := make([]int, n)
	y := make([]interface{}, len(x))
	for i := range x {
		y[i] = &x[i]
	}
	n, err := fmt.Scanln(y...)
	x = x[:n]
	return x, err
}


Measured memory_bytes: 3200
n = gets.to_i
s = Hash.new { 0 }
n.times do
  s[gets.chomp] += 1
end

s.sort { |(_k1, v1), (_k2, v2)| v2 <=> v1 }

t = Hash.new { 0 }
m = gets.to_i
m.times do
  t[gets.chomp] += 1
end

tmp = 0

s.each do |k, _v|
  next if (s[k] - t[k]) < 0
  tmp = (s[k] - t[k]) if tmp < (s[k] - t[k])
end

puts tmp


Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		char[][] data = { { '.', ',', '!', '?', ' ' }, { 'a', 'b', 'c' },
				{ 'd', 'e', 'f' }, { 'g', 'h', 'i' }, { 'j', 'k', 'l' },
				{ 'm', 'n', 'o' }, { 'p', 'q', 'r', 's' }, { 't', 'u', 'v' },
				{ 'w', 'x', 'y', 'z' } };

		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		for (int i = 0; i < n; i++) {
			String str = s.next();
			int keta = str.length();

			int[] input = new int[keta];
			char[] inputc = new char[keta];
			String output = new String();

			for (int k = 0; k < keta; k++) {
				inputc[k] = str.charAt(k);
				// input[k] = Integer.parseInt("" + inputc[k]);
				input[k] = inputc[k] - '0';
				// System.out.println(input[k]);
			}

			// &#65533;&#521;&#65533;&#65533;A&#65533;&#65533;&#65533;&#65533;&#65533;&#89486;&#65533;&#65533;&#65533;&#594;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;

			int in_count = 0;
			// int out_count = 0;
			int start;

			for (int m = 0; m < keta - 1; m++) {
				start = input[m];
				if (start == 0) {

				} else if (input[m + 1] == start) {
					in_count++;
				} else {
					int d = 3;
					if (start == 7 || start == 9)
						d = 4;
					else if (start == 1)
						d = 5;
					output += data[start - 1][in_count % d];
					// out_count++;
					in_count = 0;
				}
			}

			/*
			 * for (int t = 0; t < output.length; t++) { if (output[t] !=
			 * '\u0000') System.out.print(output[t]); }
			 */
			System.out.println(output);
		}
		s.close();
	}
}

Measured memory_bytes: 25376
# -*- coding:utf-8 -*-

"""解説
http://drken1215.hatenablog.com/entry/2019/05/12/004500

N//m = N%m = k （kは約数。かつ余り）とすると、

N = mk + k ...(1)
N = k(m+1)

k は MOD m の余りなので、m > k である。
よって、

N = k*(m+1) > k*k

よって、

N > k**2
√N > k

これに気づけばOK。あとはkについて全探索。O(√N)


(例)
・N=8, m=3のとき
3*2 + 2 = 8
m*k + k = N

・N=8, m=7のとき
7*1 + 1 = 8
m*k + k = N

"""
import math

def solve():
    N = int(input())

    ans = 0
    for k in range(1, math.floor(math.sqrt(N))+1):
        if N%k != 0: continue # kはNの約数より
        # N = k(m+1)
        # m = (N/k) - 1
        m = (N/k) - 1
        if m <= 0: continue
        if N//m == N%m:
            ans += m
    print(int(ans))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3188
s = input()
t = input()
n = len(s)
m = len(t)
ans = []

for i in range(n-m+1):
  	#tと同じ文字数をsから抜き出す
    c = 0
    for j in range(m):
        if s[i+j] == '?' or s[i+j] == t[j]:
          	#sの文字が"?"またはt[j]と同じ場合
            c += 1
    if c == m:
      	#文字の変換
        s_ = s[0:i] + t + s[i+m:]
        s_ = s_.replace('?', 'a')
        ans.append(s_)
if len(ans)>0:
    print(sorted(ans)[0])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 9076
v, e = map(int, input().split())

from heapq import heappush, heappop
edges = []
for _ in range(e):
    s, t, w = map(int, input().split())
    heappush(edges, (w, s, t))

# initialize
par = [-1] * v
rank = [0] * v
# Union Find Tree
def find(x):
    """ 根ノードの値を見つけて返す """
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    """xとyを結合する"""
    rootx = find(x)
    rooty = find(y)

    if rootx == rooty:
        return False
    else:
        if rank[rootx] < rank[rooty]:
            par[rootx] = rooty
        else:
            par[rooty] = rootx
            if rank[rootx] == rank[rooty]: rank[rootx] += 1
        return True

def same(x, y):
    """ xとyが同じ集合に属しているか """
    return find(x) == find(y)

ans = 0
while edges:
    w, s, t = heappop(edges)
    if not same(s, t):
        ans += w
        unite(s, t)

print(ans)



Measured memory_bytes: 22952
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int sum,ans = 1e9;
  for(int i = -100; i <= 100; i++){
    sum = 0;
    for(int j = 0; j < n; j++){
      sum += (a[j]-i) * (a[j]-i);
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3F3F3F3F;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++) {
        ans += (i % d == 0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
var a=[1];
for(var i=1;i<1000000;i++)a[i]=a[i-1]+i+1;
var b=[1];
var i=1;
while(true){
   b[i]=b[i-1]+a[i];
   if(b[i]>1000000)break;
   i++;
}
var dpA=[];
var dpB=[];
for(var i=0;i<1000000;i++)dpA[i]=Infinity;
for(var i=0;i<1000000;i++)dpB[i]=Infinity;
dpA[0]=0;
dpB[0]=0;
for(var i=0;i<1000000;i++){
   for(var j=0;j<b.length;j++){
      if(i-b[j]>=0)dpA[i]=Math.min(dpA[i-b[j]]+1,dpA[i]);
      if(b[j]%2==1 && i-b[j]>=0)dpB[i]=Math.min(dpB[i-b[j]]+1,dpB[i]);
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n").map(Number);
while(true){
   var n=arr.shift();
   if(n==0)break;
   console.log(dpA[n]+" "+dpB[n]);
}

Measured memory_bytes: 102156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });
 
int main(){
	ll N;
	cin >> N;
	vector<ll> L(N);
	REP(i, N) cin >> L[i];

	bool can = false;
	DESC(L);
	ll longest = L[0];
	ll sum = 0;
	FOR(i, 1, N) sum += L[i];
	if (longest < sum) can = true;
	if (can) cout << "Yes\n";
	else cout << "No\n";
}


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

int main(void){
  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int count = 0;

  for(int i = 0; i <= a; i ++){
    for(int j = 0; j <= b; j ++){
      for(int k = 0; k <= c; k ++){
        if(i*500 + j*100 + k*50 == x) count ++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


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

using ll = long long;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (ll i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (ll i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

template<typename T> using pop_max = std::priority_queue<T>;
template<typename T> using pop_min = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T> void LOG(const T& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T> void LOG(const vector<vector<T>>& a) { for (const auto& x : a) LOG(x); }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }
ll gcd(ll a, ll b) { while (b != 0) { ll t = b; b = a % b; a = t; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll gcd(const vector<ll>& v) { return accumulate(v.begin(), v.end(), 1LL, static_cast<ll(*)(ll, ll)>(gcd)); }
ll lcm(const vector<ll>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<ll(*)(ll, ll)>(lcm)); }
ll pow(ll x, ll y, ll z) { ll a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
ll inv(ll x, ll m) { return pow(x, m - 2, m); }

template<typename T> bool chmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<typename T> bool chmin(T& x, const T& y) { return x > y ? x = y, true : false; }

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

const ll INF = inf<ll>;
using P = pair<ll, ll>;
const ll M = 1000000007;
signed main() {
  ll n;
  cin>>n;
  set<ll> S;
  REP(_,n){
    ll a;
    cin>>a;
    if(S.count(a)){
      cout<<"NO"<<endl;
      exit(0);
    }
    S.insert(a);
  }
  cout<<"YES"<<endl;
}


Measured memory_bytes: 9600
mo=10**9+7
t=input()[::-1]
dp=[0]*13
dp[0]=1
for d in range(len(t)):
  p=[0]*13
  if t[d]=='?':
    for x in range(10):
      r=int(x)*pow(10,d,13)
      for i in range(13):
        p[(i+r)%13]+=dp[i]
  else:
    r=int(t[d])*pow(10,d,13)
    for i in range(13):
      p[(i+r)%13]=dp[i]
  dp=[j%mo for j in p]
print(dp[5]%mo)


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

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = [ai + bi for bi in b[:k] for ai in a[:k]]
ab.sort(reverse=True)

s = [ci + abi for abi in ab[:k] for ci in c[:k]]
s.sort(reverse=True)

for si in s[:k]:
    print(si)

Measured memory_bytes: 146748
# 上皿天秤は、左の皿に乗っているおもりの重さの合計を L とし、
# 右の皿に乗っているおもりの重さの合計を R としたとき、
# L>R なら左に傾き、L=R なら釣り合い、L<R なら右に傾きます。
# 高橋君は、上皿天秤の左の皿に重さ A のおもりと重さ B のおもりを、
# 右の皿に重さ C のおもりと重さ D のおもりを置きました。
# 上皿天秤が左に傾くなら Left を、釣り合うなら Balanced を、
# 右に傾くなら Right を出力してください。

input_line = gets.chomp.split
a = input_line[0].to_i
b = input_line[1].to_i
c = input_line[2].to_i
d = input_line[3].to_i

left_weight = a + b
right_weight = c + d

if left_weight > right_weight
  puts "Left"
elsif left_weight == right_weight
  puts "Balanced"
else
  puts "Right"
end


Measured memory_bytes: 1788
import java.util.Scanner; 
 
public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int w = sc.nextInt();
	int[] values = new int[w + 1];
	int n = sc.nextInt();
	for(int i = 1; i < values.length; i++){
	    values[i] = i;
	}
	for(int i = 1; i <= n; i++){
	    String str = sc.next();
	    String[] ab = str.split(",");
	    int a = Integer.parseInt(ab[0]);
	    int b = Integer.parseInt(ab[1]);
	    int temp = 0;
	    temp = values[a];
	    values[a] = values[b];
	    values[b] = temp;
	}
	for(int i = 1; i < values.length; i++){
	    System.out.printf("%d\n", values[i]);
	}
    }
}

Measured memory_bytes: 26124
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;

int main() {
	vi L(3);
	bool judge = false;
	Loop(i, 3) {
		cin >> L[i];
		if (L[i] % 2 == 0) judge = true;
	}
	if (judge) cout << 0 << endl;
	else {
		sort(L.begin(), L.end());
		cout << (ll)L[0] * L[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
    int n,len,len2,sum=0;
    char str[201],str2[201];
    memset(str2,NULL,sizeof(str2));
    cin>>n;
    cin>>str;
    len=strlen(str);
    for(int i=0;i<n;i++){//??????????????\???
        cin>>str2;
        len2=strlen(str2);
        for(int j=0;j<len2;j++){//????????????????????????????????????????????´?¢
            if(str2[j]==str[0]){
                for(int y=1;y<len2;y++){
                    for(int x=1;x<len;x++){
                        if(str2[j+y*x]!=str[x]||j+y*x>len2){
                            goto ruio;
                        }
                        if(x==len-1){
                            sum++;
                            goto sugii;
                        }
                    }
                    ruio:;
                }
            }
        }
        sugii:;
    }
    cout<<sum<<endl;
}       

Measured memory_bytes: 3088
#include<stdio.h>

int main(void){
int i,j,k,n,b,f,r,v;
static int pe[4][3][10];
scanf("%d",&n);

for(i=0;i<n;i++){
scanf("%d%d%d%d",&b,&f,&r,&v);
pe[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++)
printf(" %d",pe[i][j][k]);
printf("\n");
}
if(i<3) printf("####################\n");
}
return 0;
}


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

#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    faster();

    int n;
    string s = "";
    cin>>n;
    for(int i=0;i<n;i++){
        s += "ACL";
    }
    cout<<s<<endl;

    return 0;
}




Measured memory_bytes: 3640
#include<stdio.h>
#define N 8
#define FREE 1
#define NOT_FREE -1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1], X[N][N];


void printBoard(){
  int i,j;
  
  for(i = 0;i<N;i++){
    for(j = 0; j < N; j++){
      if(X[i][j] == 1&&row[i] != j ) return;
    }
  }
  for(i = 0; i<N;i++){
    for(j = 0; j<N;j++){
      if(row[i] == j){
	printf("Q");
      }else{
	printf(".");
      }
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i == N){
    printBoard();

    return;
  }
  for(j = 0; j<N;j++){
    if(NOT_FREE == col[j] ||NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    recursive(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;    
  }
}

int main(){
  int i,j,k,r,c;
  for(i = 0; i<N;i++){
    for(j = 0; j<N; j++) X[i][j] = 0;
  }
  for(i = 0; i<N;i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(i = 0; i<2*N;i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
 scanf("%d",&k);
  for(i = 0; i<k; i++){
    scanf("%d%d",&r,&c);
    X[r][c] = 1;
  }
  recursive(0);
  return 0;
}


Measured memory_bytes: 2088