akhauriyash/Code-Regression huggingface dataset:
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

def solve():
	N = I()

	def fizzBuzz(i):
		if i % 15 == 0:
			return 0
		elif i % 3 == 0:
			return 0
		elif i% 5 == 0:
			return 0
		else:
			return i

	a = 0
	for i in range(1, N+1):
		a += fizzBuzz(i)

	print(a)

if __name__ == '__main__':
	solve()


Measured memory_bytes: 9960
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI d(n);
    REP(i,0,n) cin >> d[i];
    LL ans = 0;
    REP(i,0,n) REP(j,i+1,n) ans += d[i] * d[j];
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
import heapq
n,heap = raw_input(), map(float, raw_input().split(' '))
heapq.heapify(heap)
while(len(heap)>1): heapq.heappush(heap,  (heapq.heappop(heap) + heapq.heappop(heap)) * 0.5)
print heap[0]

Measured memory_bytes: 28396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 100;

int n;
int r[MAX_N], c[MAX_N];

int dp[MAX_N][MAX_N];

int main() {
    cin >> n;
    REP(i, n) cin >> r[i] >> c[i];

    REP(i, n) {
        REP(j, n) dp[i][j] = MOD;
    }

    REP(i, n) dp[i][i] = 0;

    REP2(k, 1, n) {
        REP(i, n - k) {
            int j = i + k;
            REP2(l, i, j) {
                dp[i][j] = min(dp[i][j], dp[i][l] + dp[l+1][j] + r[i]*c[l]*c[j]);
            }
        }
    }

    PRINT(dp[0][n-1]);
    return 0;
}


Measured memory_bytes: 3128
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    char c;
    cin >> c;
    cout << char(c + 1) << "\n";
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;

  string Yes = "Yes";
  string No = "No";

  ll t = c - a - b;
  if (t < 0) drop(No);

  if (4 * a * b < t * t) {
    cout << Yes << endl;
  } else {
    cout << No << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    double sum = 0;
    int x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        sum += 1.0/x;
    }

    cout.precision(7);
    cout << 1.0/sum;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
m,s = a[-1],a[0]
if m!=a[-2] or (m+1)//2!=s or (m%2 and s-a[1]) or ((not m%2) and s==a[1]) or any(a.count(i)<2 for i in range(s+1,m)) or (n!=2 and s==a[1]==a[2]): print("Impossible")
else: print("Possible")

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
int main(void)
{
    char **s;

    int h, w;
    cin >> h >> w;
    
    s = new char*[h];
    for (int i = 0; i < h; i++) {
        s[i] = new char[w];
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int count = 0;
            if (s[i][j] == '#') {
                continue;
            }
            for (int k = -1; k <= 1; k++) {
                for (int l = -1; l <= 1; l++) {
                    if (k == 0 && l == 0) {
                        continue;
                    }
                    if (i+k < 0 || i+k >= h || j+l < 0 || j+l >= w) {
                        continue;
                    }
                    if (s[i+k][j+l] == '#') {
                        count++;
                    }
                }
            }
            s[i][j] = '0' + count;
        }
    }


    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << s[i][j];
        }
        cout << endl;
    }

    for (int i = 0; i < h; i++) {
        delete[] s[i];
    }

    delete[] s;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int h,w,n;
	cin >> h >> w >> n;
	vector<int> a(n);
	REP(i,n) cin >> a[i];
	
	int count = 1;
	int index = 0;
	vector<vector<int>> g(h,vector<int>(w));
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(i%2==0) g[i][j] = index+1;
			else g[i][w-1-j] = index+1;
			count++;
			if(count > a[index]){
				index++;
				count = 1;
			}
		}
	}
	
	REP(i,h){
		REP(j,w){
			if(j!=0) cout << " ";
			cout << g[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		List<Integer> list= new ArrayList<>();
		boolean judge =false;

		list.add(a);
		list.add(b);
		list.add(c);
		Collections.sort(list);

		for(int i=0;i<list.size();i++) {
			if(i==0) {
				if(list.get(i)==5) {
					judge=true;
				}
				else {
					judge=false;
				}
			}
			if(i==1) {
				if(judge&&list.get(i)==5) {
					judge=true;
				}
				else {
					judge=false;
				}
			}
			if(i==2) {
				if(judge&&list.get(i)==7) {
					judge=true;
				}
				else {
					judge=false;
				}
			}
		}
		
		if(judge) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long n; cin >> n;
    long f = 1000000007;
    long a = 1;
    for(int i=0;i<n;i++){
        a *= 10; a %= f;
    }
    long b = 1;
    for(int i=0;i<n;i++){
        b *= 9; b %= f;
    }
    b *= 2; b %= f;
    long c = 1;
    for(int i=0;i<n;i++){
        c *= 8; c %= f;
    }
    long ans;
    ans = (a - b) % f;
    ans = (ans+c)%f;
    if(ans < 0)ans += f;
    cout <<ans  << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(){
  string S;
  cin >> S;
    int ans=0;
  for(int i=0;i<S.size()/2;i++){
if(S[i]!=S[S.size()-1-i]) ans++; 
}cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 2e5 + 5;

void solve(string s) {
    if (s.size() & 1) {
        cout << "No\n";
        return;
    }
    for (int i = 0 ; i < s.size() ; i += 2) {
        if (s[i] != 'h' || s[i+1] != 'i') {
            cout << "No\n";
            return;
        }
    }
    //if (cnt >= 1) {
        cout << "Yes\n";
    //}
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    while(cin >> s) {
        solve(s);
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N=int(input())
A=list(map(int,input().split()))

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

    if (N-i)%2==1:
        SUM[i]+=A[i]

#print(SUM)
        
from functools import lru_cache
@lru_cache(maxsize=None)
def calc(i,select):
    rest=N-i

    if rest==0 or select==0:
        return 0

    if rest%2==1 and rest//2+1==select:
        return SUM[i]
    
    elif rest%2==0 and rest//2==select:
        return max(calc(i+1,select),A[i]+calc(i+2,select-1))

    elif rest%2==1 and rest//2==select:
        return max(calc(i+1,select),A[i]+calc(i+2,select-1))

print(calc(0,N//2))

    


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

// 要するに3辺の長さの和Lの立方体の体積を求めよと?
int main()
{
  int L;
  cin >> L;
  
  double cubeEdge = (double)L / 3;
  
  cout << setprecision(12) << fixed << cubeEdge * cubeEdge * cubeEdge << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
KS = M.times.map { gets.split.map(&:to_i) }
P = gets.split.map(&:to_i)

ans = 0

digits = N
max = 2 ** digits - 1
0.upto(max) do |i|
  all = true
  KS.each_with_index do |ks, idx|
    on = 0
    1.upto(ks.size - 1) do |j|
      s = ks[j]
      on += 1 if i[ks[j] - 1] == 1
    end
    all = P[idx] == 1 && on.odd? || P[idx] == 0 && on.even?
    break unless all
  end
  ans += 1 if all
end

puts ans


Measured memory_bytes: 1788
#include<iostream>
main(){for(int n,a[20],S,s,m,i,j,t;std::cin>>n,n;printf("%d\n",m)){for(i=S=0;i<n;S+=a[i++])std::cin>>a[i];m=1<<30;for(i=(1<<n);i-->0;t=S-s-s,t=t>0?t:-t,m>t&&(m=t))for(j=s=0;j<n;j++)if(i&1<<j)s+=a[j];}}

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

int main(){
  int num1,num2;
  stack<int>sck;
  string str;
  int num[10];
  int cnt;
  while(cin>>str){
    if(str=="+"){
      num1=sck.top();sck.pop();
      num2=sck.top();sck.pop();
      sck.push(num1+num2);
    }
    else if(str=="*"){
      num1=sck.top();sck.pop();
      num2=sck.top();sck.pop();
      sck.push(num1*num2);
    }
    else if(str=="-"){
      num1=sck.top();sck.pop();
      num2=sck.top();sck.pop();
      sck.push(num2-num1);
    }
    else {
      sck.push(atoi(str.c_str()));
    }
  }
  cout<<sck.top()<<endl;
}

Measured memory_bytes: 1200
N = int(input())
As = list(map(int, input().split()))
from itertools import accumulate
acc = list(accumulate(As))
s = sum(As)
mn = 10**10
for i,x in enumerate(acc[:-1]):
    y = s - x
    if mn >= abs(x-y):
        mn = abs(x-y)
print(mn)

Measured memory_bytes: 24824
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  temp = input[1].split(" ");
  a = new Array(n).fill(0);
  for(i=0;i<n;i++){
    a[i]=parseInt(temp[i]);
  }
  var ans =0;
  var m=0;
  for(i=0;i<n;i++){
    m+=a[i];
  }
  var l = Math.round(m/n);
  for(i=0;i<n;i++){
    ans+=Math.pow(a[i]-l,2);
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  int a, b, c;  
  scanf("%d%d%d", &a, &b, &c);
  swap(a, b);
  swap(a, c);
  printf("%d %d %d\n", a, b, c);
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = s()
n = len(S)
num = 1
num2 = 1
ans = 0
Flag = 0

for i in range(n-1):
    if S[i] == S[i+1]:
        ans += num
        num += 1
    if S[i] == "<" and S[i+1] == ">":
        num2 = num
        num = 1
        Flag = 1
    if S[i] == ">" and S[i+1] == "<":
        ans += max(num,num2)
        num = 1
        Flag = 0

if Flag:
    ans += max(num,num2)
else:
    ans += num

print(ans)


Measured memory_bytes: 10768
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<lli> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
#define MAXN 10005
lli dp[MAXN][105][3];
string s;
int d,n;

lli solve(int pos, int sum, int f){
	if(pos == n){
		if(sum == 0) return 1;
		return 0;
	}

	if(dp[pos][sum][f] != -1) return dp[pos][sum][f];
	
	int limit = 9;
	if(!f) limit = s[pos] - '0';
	lli ans = 0ll;
	for(int i=0; i <= limit; i++){
		ans = (ans + solve(pos+1,(sum + i)%d,(i < (s[pos]-'0')) | f)%mod)%mod;
	}
	return dp[pos][sum][f] = ans;
}

int main(){__
	cin >> s;
	n = s.size();
	cin >> d;
	memset(dp,-1,sizeof(dp));
	lli ans = solve(0,0,0) % mod;
	cout << (ans + mod -1 ) % mod << endl;
	return 0;
}


Measured memory_bytes: 25728
A, B, H, M = map(int, input().split())

import math

s = 30*(H+M/60)
t = 6*M

r = abs(s-t)

if r>180:
  r = 360-r

a = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(r)))

print(a)

Measured memory_bytes: 9440
import java.util.Scanner;

public class Main {

	public static void main(String... args) {

		try (Scanner sc = new Scanner(System.in)) {

			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = 0;

			for (int i = a; i <= b; i++) {

				String s = String.valueOf(i);
				int l = s.length();

				boolean eq = true;
				for (int j = 0; j < l >> 1; j++) {

					eq &= s.charAt(j) == s.charAt(l - j - 1);
					if (!eq) {
						break;
					}

				}

				if (eq) {
					c++;
				}

			}

			System.out.println(c);

		}

	}

}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}
double pw,vw[100000],pf[100000],vf[100000],th[100000];

void solve(int n){
    scanf("%lf",&pw);
    rep(i,0,n) scanf("%lf%lf%lf%lf",vw+i,pf+i,vf+i,th+i);

    vector<double> v={0};
    rep(i,0,n) if(vw[i]!=0 and th[i]/vw[i]>=0) v.push_back(th[i]/vw[i]);

    double ans=inf;
    for(double w:v){
        double d=w*pw;
        rep(i,0,n){
            if(d>=ans) break;
            d+=pf[i]*max(0.,(th[i]-w*vw[i])/vf[i]);
        }
        ans=min(ans,d);
    }
    printf("%f\n",ans);
}

int main(){
    while(true){
        int n;
        scanf("%d",&n);
        if(!n) break;
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 7860
#include <iostream>
#include <cmath>
#include <functional>
using namespace std;

int main() {
  int A,B,C,D,E,F,sugarwater,sugar,ans1,ans2;
  double den = -1;
  cin >> A >> B >> C >> D >> E >> F;
  for(int a=0; 100*A*a <= F; a++){
    for(int b=0; 100*B*b <= F - 100*A*a; b++){
      if(a + b != 0){
        for(int c=0; C*c <= F - 100*A*a - 100*B*b; c++){
          for(int d=0; D*d <= F - 100*A*a - 100*B*b - C*c; d++){
            if(E*(A*a + B*b) >= C*c + D*d){
              sugar = (C*c + D*d);  
              sugarwater = 100*(A*a + B*b) + sugar;
              if(den < (double)sugar/sugarwater){
                den = (double)sugar/sugarwater;
                ans1 = sugarwater; 
                ans2 = sugar;
              }
            }
          }
        }
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
count=0
while h!=[0]*n:
    for i in range(n):
        if h[i]!=0:
            start=i
            break
    end=n-1
    for j in range(i+1,n):
        if h[j]==0:
            end=j-1
            break
    for k in range(start,end+1):
        h[k]-=1
    count+=1
print(count)


Measured memory_bytes: 8940
require "prime"

class Problem
  attr_accessor :a, :b, :n, :s, :ans
  N = 100000

  def initialize
    @n = gets.to_s.to_i
    @a = Array.new(N+1,0)
    @b = Array.new(N+1,0)
    Prime.each(N+1) do |i|
      a[i] = 1
      b[i] = 1 if a[(i+1)/2] == 1
    end
    @c = @b.each_with_object([0]) { |v, h| h << h[-1] + v }
  end

  def solve
    n.times do
      lo,hi = gets.to_s.split.map{ |v| v.to_i }
      puts @c[hi+1] - @c[lo]
    end
  end

end

pr = Problem.new
pr.solve

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

int main() {
  string S;
  cin >> S;
  int zero = 0, one = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '0') zero++;
    else one++;
  }
  cout << min(zero, one) * 2 << endl;
}

Measured memory_bytes: 512
function Main(input) {
	input = input.trim();
	//input = input.trim().split("");
	//input = input.trim().split("\n");
	input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  	var A = input[0];
  var B = input[1];
  var X = input[2];
  if(A > X || A + B < X){
     console.log("NO");
     }else{
     console.log("YES");
     }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

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

  vector<long long> a(n), b(n), c(n);
  for (auto& i : a) cin >> i;
  for (auto& i : b) cin >> i;
  for (auto& i : c) cin >> i;

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    auto ai = lower_bound(a.begin(), a.end(), b[i]);
	long long na = distance(a.begin(), ai);
    auto ci = upper_bound(c.begin(), c.end(), b[i]);
	long long nc = distance(ci, c.end());
	ans += na * nc;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

enum POSITION{ONLINE_BACK = -2, CCW = -1, ON_SEGMENT = 0,
              CW = 1, ONLINE_FRONT = 2};

struct Point{
    long x;
    long y;
    Point(long x, long y) : x(x), y(y) {}
    Point(){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}

struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
    Segment(){}
};
typedef vector<Point> Polygon;

POSITION get_position(Segment s, Point p){
    double c = cross(s.p2 - s.p1, p - s.p1);
// cout << c << endl;
    if (c > 0) return CCW;
    if (c < 0) return CW;
    double d = dot(s.p2 - s.p1, p - s.p1);
    if (d < 0) return ONLINE_BACK;
    if (d > dot(s.p2 - s.p1, s.p2 - s.p1)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersect(Segment s1, Segment s2){
// cout << get_position(s1, s2.p1) << " " << get_position(s1, s2.p2)  << endl;
    if (get_position(s1, s2.p1) * get_position(s1, s2.p2) != -1) {
        return false;
    }
// cout << endl;
// cout << get_position(s2, s1.p1) << " " << get_position(s2, s1.p2)  << endl;
    if (get_position(s2, s1.p1) * get_position(s2, s1.p2) != -1) {
        return false;
    }
    return true;
}

int determine_containment(Point p, Polygon poly){
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (get_position(Segment(poly[i], poly[(i+1)%n]), p) == ON_SEGMENT) {
            return 1;
        }
    }
    Segment s_right(p, Point(p.x + 1e5, p.y));
    int count = 0;
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (intersect(s_right, Segment(poly[i], poly[(i+1)%n]))) {
            // poly[i].pprint();
            // poly[(i+1)%n].pprint();
            // cout << endl;
            count++;
        }
    }
// cout << "s " << count << endl;
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (get_position(s_right, poly[i]) == ON_SEGMENT) {
            int i_pre = (i == 0 ? n - 1 : i - 1);
            while (get_position(s_right, poly[i_pre]) != CCW && get_position(s_right, poly[i_pre]) != CW) {
                i_pre = (i_pre == 0 ? n - 1 : i_pre - 1);
            }
            int i_aft = (i + 1) % n;
            while (get_position(s_right, poly[i_aft]) != CCW && get_position(s_right, poly[i_aft]) != CW) {
                i_aft = (i_aft + 1) % n;
            }
            if (get_position(s_right, poly[i_pre]) * get_position(s_right, poly[(i+1)%n]) == -1) {
                count++;
            }
        }
    }
// cout << "p " << count << endl;
    if (count % 2) return 2;
    return 0;
}
int main(){
    int q;
    cin >> q;
    Polygon poly(q);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        poly[i].x = x;
        poly[i].y = y;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cout << determine_containment(Point(x, y), poly) << endl;
    }
    return 0;
}



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

int main()
{

	int a, b;

	cin >> a >> b;

	int l = a;
	int s = b;

	if(a < b){
		l =  b;
		s = a;
	}

	string numStr = std::to_string(s);
	string outStr = "";

	for (int i = 0; i < l; i++)
	{
		outStr += numStr;
	}
	

	cout << outStr << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define S 100
 
int main(){
  int i,j,n,x,y;
  int r[S+1],m[S+1][S+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&r[i-1],&r[i]);
  }
  for(i=0;i<=n;i++){
    m[i][i]=0;
  }
 
  for(x=2;x<=n;x++){
    for(i=0;i<=n-x+1;i++){
      j=i+x-1;
      m[i][j]=(1<<21);
      for(y=i;y<=j-1;y++) if(m[i][j]>m[i][y]+m[y+1][j]+r[i-1]*r[y]*r[j]) m[i][j]=m[i][j]=m[i][y]+m[y+1][j]+r[i-1]*r[y]*r[j];
    }
  }
  printf("%d\n",m[1][n]);
 
  return 0;
}



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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0; i < N; i++){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int sum = 0;
    for(int i=0; i < K; i++){
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  ll k = n;
  vector<string> s;
  while(n != 0){
    ll bi = n % (-2);
    if(bi<0)  bi += 2;
    n = (n-bi)/(-2);
    s.push_back(to_string(bi));
  }
  reverse(s.begin(), s.end());
  for(int i=0 ; i<s.size() ; i++){
    cout << s[i];
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X, Y, A, B, C = map(int, readline().split())
P = sorted(map(int, readline().split()), reverse=True)
Q = sorted(map(int, readline().split()), reverse=True)
R = sorted(map(int, readline().split()), reverse=True)

P = P[:X]
Q = Q[:Y]
nums = P + Q + R
nums.sort(reverse=True)
answer = sum(nums[:X + Y])
print(answer)


Measured memory_bytes: 21088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String y = sc.next();
        int a = Integer.parseInt(x, 16);
        int b = Integer.parseInt(y, 16);
        if (a == b) {
            System.out.println("=");
        } else if (a < b) {
            System.out.println("<");
        } else {
            System.out.println(">");
        }

    }
}

Measured memory_bytes: 21844
#include <cstdio>

int main()
{
	char ch;
	int n = 0;

	while ((ch = getchar())!= '0' || n != 0)
	{
		if (ch == '\n')
		{
			printf("%d\n",n);
			n = 0;
		}
		else
		{
			ch &= 0x0F;
			n += ch;
		}
	}
	return 0;
}

Measured memory_bytes: 2688
N, M, X = list(map(int,input().strip().split(' ')))
A = list(map(int,input().strip().split(' ')))
costV = [0 for i in range(N)]
for a in A:
    costV[a] = 1 

left_cost = sum(costV[:X])
right_cost = sum(costV[X+1:])
print(min(left_cost,right_cost))

Measured memory_bytes: 3064
W, H, x, y = map(int, input().split())
answer = float(W) * float(H) / 2.0
solution = -1
if(float(x) == float(W) / 2.0 and float(y) == float(H) / 2.0):
    solution = 1
else:
    solution = 0
print(answer,solution)

Measured memory_bytes: 3060
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        var t = long.Parse(Console.ReadLine().Trim());
        var n = getN(t);
        getAns(t, n);
    }
    static void getAns(long t, int n)
    {
        var t2 = t - 2 * (long)Pow(3, n) + 2;
        var n2 = n;
        var res = 0L;
        while (n2 >= 0)
        {
            var pow3 = (long)Pow(3, n2);
            var w = t2 / pow3;
            res += w;
            t2 -= w * pow3;
            n2--;
        }
        Console.WriteLine(2 * n + res);
    }
    static int getN(long t)
    {
        var n = 0;
        var a = 1L;
        while (2 * a <= t + 2)
        {
            a *= 3;
            n++;
        }
        return n - 1;
    }
}



Measured memory_bytes: 17956
#include<stdio.h>
int main()
{
	int a;
	long long sum=0;
	scanf("%d",&a);
	for(int i=1;i<a+1;i++)
	{
		if((i%3!=0)&&(i%5!=0))sum+=i;
	}
	printf("%lld",sum);
	return 0;
}

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

int main() {
  int N;  cin >> N;
  vector<int> a(N);

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

  sort(a.begin(), a.end());

  cout << ((a[a.size() / 2]) - (a[a.size() / 2 - 1])) << endl;

  return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,N,M=0,ans=0;
  cin>>N;
  vector<ll> v(N),clist;
  set<ll> se;
  rep(i,N){
    cin>>v[i];
    M=M^v[i];
    auto p=se.insert(v[i]^(v[i]-1));
    if(p.second)clist.push_back(v[i]^(v[i]-1));
  }

  vrsort(clist);
  rep(i,(ll)clist.size()){
    if(M>(M^clist[i])){
      M=M^clist[i];
      ans++;
    }
  }
  if(M){
    cout<<-1<<endl;
  }else{
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// 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>

#if __cplusplus >= 201103L
#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>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	string O, E;
	cin >> O >> E;
	for (int i = 0; i < O.size() || i < E.size(); i++) {
		if (i < O.size()) {
			cout << O.substr(i, 1);
		}
		if (i < E.size()) {
			cout << E.substr(i, 1);
		}
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
int N,a,b,c,d;
bool f=false;
while(1){
cin>>N;if(N==0)break;
if(f==true)cout<<endl;
f=true;
cin>>a>>b>>c>>d;

int min=a+b+c+d;
int y=0;
int s=0,t=0,u=0,v=0;
int sum=0;
sum+=10*a;
sum+=50*b;
sum+=100*c;
sum+=500*d;
sum=sum-N;


v=sum/500;sum=sum%500;
u=sum/100;sum=sum%100;
t=sum/50;sum=sum%50;
s=sum/10;sum=sum%10;


if(a-s>0)cout<<"10 "<<a-s<<endl;
if(b-t>0)cout<<"50 "<<b-t<<endl;
if(c-u>0)cout<<"100 "<<c-u<<endl;
if(d-v>0)cout<<"500 "<<d-v<<endl;

}

return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

//---------------------------------------------------------------
// ------ graph ------ //
using Weight = int;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) { }
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // pqが降順のため
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
struct Graph {
    vector<Edges> adj;
    Graph(int n) : adj(n) { }
    int size() { return adj.size(); }
    Edges operator [] (int v) { return adj[v]; }
    void add_edge(int a, int b, Weight w = 1) { // graph
        adj[a].emplace_back(a, b, w);
        adj[b].emplace_back(b, a, w);
    }
    void add_arc(int a, int b, Weight w = 1) {  // digraph
        adj[a].emplace_back(a, b, w);
    }
};
using Array = vector<Weight>;
using Matrix = vector<Array>;

// ------ Topological Sort (bfs) ------ //
vector<int> tsort(Graph &g) {
    int n = g.size();
    vector<int> indeg(n, 0), visited(n, 0), ord;
    for (int i = 0; i < n; i++) for (Edge &e : g[i]) indeg[e.dst]++;
    auto bfs = [&](int s){
        queue<int> q; q.push(s); visited[s] = true;
        while (!q.empty()) {
            int u = q.front(); q.pop(); ord.push_back(u);
            for (Edge &e : g[u]) {
                int v = e.dst;
                if (--indeg[v] == 0 && !visited[v]) { visited[v] = true; q.push(v); }
            }
        }
    };
    for (int i = 0; i < n; i++) if (indeg[i] == 0 && !visited[i]) bfs(i);
    return ord;
}
//---------------------------------------------------------------

int main() {
    int V, E; cin >> V >> E;
    Graph g(V);
    for (int i = 0; i < E; i++) {
        int s, t; cin >> s >> t;
        g.add_arc(s, t);
    }
    vector<int> ord = tsort(g);
    for (int x : ord) cout << x << endl;
    return 0;
}


Measured memory_bytes: 4280
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M = map(int,input().split()) 
S = [list(map(int,input().split())) for i in range(M)]
 
ans = []
for i in range(N):
    ans.append(-1)
 
for i in range(M):
    if ans[S[i][0]-1] == -1:
        ans[S[i][0]-1] = S[i][1]
    else:
        if ans[S[i][0]-1] != S[i][1]:
            print(-1)
            sys.exit()

if N>1 and ans[0]==0:
    print(-1)
    sys.exit()

if N>1 and ans[0]==-1:
    ans[0]=1
if N==1 and ans[0]==-1:
    ans[0]=0

for i in range(N):
    if ans[i] == -1:
        print(0, end='')
    else:
        print(ans[i],end='')
print()

Measured memory_bytes: 77152
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
#include <functional>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back


int main()
{
	int N;
	cin >> N;
	vector<string> blue(N);
	for (int i = 0; i < N; i++) {
		cin >> blue[i];
	}
	int M;
	cin >> M;
	vector<string> red(M);
	for (int i = 0; i < M; i++) {
		cin >> red[i];
	}
	string word;
	int ans = 0, cnt = 0;
	for (int i = 0; i < N; i++) {
		word = blue[i];
		for (int j = 0; j < M; j++) {
			if (word == red[j]) {
				cnt--;
			}
		}
		for (int k = 0; k < N; k++) {
			if (word == blue[k]) {
				cnt++;
			}
		}
		ans = max(ans, cnt);
		cnt = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c,as,af,end;
  cin >> a >> b >> c;
  as=0,af=a;
  end=c-af;
  while(1){
    if(as<=c&&c<=af){
      cout << c << endl;
      break;
    }
    as+=a+b,af+=a+b;
    if(as>c) c+=60;
    if(c-af==end){
      cout << -1 << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
n = int(input())

arr = [];
flag=0;
for i in range(n):
	arr.append(input())

for i in range(n):
	if i>0:

		j = i-1;

		if ( arr[i][0] == arr[i-1][-1] ):
			
			while( j >=0 ):

				if arr[i]==arr[j]:
					flag=1;
					break;
				j-=1;
			if flag==1:
				break;
		else:
			flag=1;
			break;


if flag==1:
	print("No")
else:
	print("Yes")


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

int main() {
  int N,M,i;
  cin>>N>>M;
  vector<bool> B(N,true);
  vector<int> H(N);
  for (i=0;i<N;i++) {
    cin>>H[i];
  }
  int a,b;
  for (i=0;i<M;i++) {
    cin>>a>>b;
    if (H[a-1] <= H[b-1]) B[a-1] = false;
    if (H[a-1] >= H[b-1]) B[b-1] = false;
  }
  int ans=0;
  for (i=0;i<N;i++) {
    if (B[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	long long n,s=0;
	cin >> n;
	for (long long i = 0; i <= n; ++i) {
		if (i % 3 == 0 || i % 5 == 0) {
			
		}
		else {
			s += i;
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	//freopen("input.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	string arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int cnt = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (arr[i][j] == '#')
				cnt++;
	if (cnt != m + n - 1) {
		cout << "Impossible" << endl;
		return 0;
	}
	int a = 0, b = 0;
	while (a < n - 1 && b < m - 1) {
		if (b < m - 1) {
			if (arr[a][b + 1] == '#')
				b++;
			else if (a < n - 1) {
				if (arr[a + 1][b] != '#') {
					cout << "Impossible" << endl;
					return 0;
					break;
				}
				else
					a++;
			}
			else {
				cout << "Impossible" << endl;
				return 0;
				break;
			}
		}
		else if (arr[a + 1][b] != '#') {
			cout << "Impossible" << endl;
			return 0;
		}
		else
			a++;
	}
	cout << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

const int N=3e4+20,MAX=1e9;

int h,n,a[N],b[N],dp[N];

int main()
{
	scanf("%d%d",&h,&n);
	for(int i=0;i<n;i++) scanf("%d%d",&a[i],&b[i]);

	for(int i=0;i<N;i++) dp[i]=MAX;
	dp[0]=0;
	for(int i=0;i<n;i++)
		for(int j=a[i];j<N;j++)
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
	printf("%d",*min_element(dp+h,dp+N));
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 100005
#define LL long long
#define rep(i,j,k) for(i=j;i<=k;++i)
LL n,m,i,j,K;
LL x[N],d[N],to[N],tmp[N],sum[N];
void read(LL &p){
	p=0; char x=getchar(); bool fu=false;
	if(x=='-') fu=true;
	while(x<'0' || x>'9'){x=getchar(); if(x=='-') fu=true;}
	while(x>='0'&&x<='9'){p=p*10+x-'0'; x=getchar();}
	if(fu) p=-p;
}
void quick_mi(LL b){
	for(;b;b>>=1){
		if(b&1){
			rep(i,1,n) sum[i]=to[sum[i]];
		}
		rep(i,1,n) tmp[i]=to[i];
		rep(i,1,n) to[i]=tmp[to[i]];
	}
}
int main(){
	read(n);   
	rep(i,1,n){
		read(x[i]);
		d[i]=x[i]-x[i-1];
		sum[i]=tmp[i]=to[i]=i;
	}
	read(m); read(K);
	rep(i,1,m){
		read(j);
		swap(tmp[j],tmp[j+1]); 
	}
	rep(i,1,n) to[tmp[i]]=i;
	quick_mi(K);
	rep(i,1,n) x[sum[i]]=d[i];
	rep(i,1,n){
		x[i]+=x[i-1];
		printf("%lld\n",x[i]);
	}
	return 0;
}

Measured memory_bytes: 5120
/* ex 7_2
   offNaria */

#include <stdio.h>

typedef struct point
{
    int x_elem;
    int y_elem;
} point;

//b-aベクトルをaを中心として反時計まわりに90度回転し，始点をbにしたものの終点を計算する関数
point shift_point(point a, point b);

int main(void)
{
    point p_1, p_2, p_3, p_4;
    scanf("%d %d %d %d", &p_1.x_elem, &p_1.y_elem, &p_2.x_elem, &p_2.y_elem);
    p_3 = shift_point(p_1, p_2); //p_2-p_1ベクトルをp_1を中心として反時計回りに90度回転し，始点をp_2としたベクトルの終点がp_3
    p_4 = shift_point(p_2, p_3); //p_3-p_2ベクトルをp_2を中心として反時計回りに90度回転し，始点をp_3としたベクトルの終点がp_4
    printf("%d %d %d %d\n", p_3.x_elem, p_3.y_elem, p_4.x_elem, p_4.y_elem);
    return 0;
}

point shift_point(point a, point b)
{
    point rotatedVec = {b.x_elem + (a.y_elem - b.y_elem), b.y_elem + (b.x_elem - a.x_elem)};
    return rotatedVec;
}

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

int main(){
    map<char , int> count;
    string s;
    
    while(cin >> s){
        
        for(int i=0;i<(int)s.size(); ++i){
            if( isupper(s[i])){
                s[i] = tolower(s[i]);
            }
        }
        
        for(int i=0;i<(int)s.size(); ++i){
            count[s[i]]++;
        }
    }
    
    
    for(char ch = 'a'; ch<='z'; ++ch){
        cout << ch << " : " << count[ch] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3236
#pragma GCC optimize ("O3")
    #include<bits/stdc++.h>
    using namespace std;



    /// Info.
    ///****************************************************************************************************************************************///
    /// author                : BAHAA El_DEEN OSAMA .
    /// Problem name          : Knapsack 1
    /// Method                : IM
    /// Online judge          : VC
    /// Date                  : 20/7/2020
    ///****************************************************************************************************************************************///


    #define ll               long long
    #define RE0              return 0
    #define loop(x)          while(x--)
    #define repRot0(i,n)     for(int i=0;i*i<=n;++i)
    #define all(v)           ((v.begin()),((v.end())
    #define mm(v,d)          memset(v,d,sizeof(v))
    #define MP               make_pair
    #define SZ(v)            ((int) ( (v).size() ) )
    #define ull              unsigned long long
    #define pi               3.1415926536
    #define oo               1e9
    #define OO               1e18
    #define Fx(n)            fixed<<setprecision(n)
    #define FasterIO           std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
    #define RE1              return 1
    #define mp(a,b)          make_pair(a,b)
    #define X                first
    #define Y                second
    #define pii              pair(int a, int b)
    #define rep(i,x,xx)        for(int i=x;i<xx;i++)
    #define RE               return
    #define LD               long double
    ///#define all(v) ((v).begin()),((v).end())
    #define revLoop(i,x)     for(int i=x-1 ;i>=0;--i)

    const  int   N  = (int) 1e6;
  /*const  int   M  = (int) 1e4+4;
    const  int  INF = (int) 0x3f3f3f3f;
    const double ESP = 1e-7;
    const ll MOD=4*1e4;
  */


 ll n,ans,w;
ll dp[110][N],a[110],b[110];
ll solve( ll i, ll r )
{
	if(r<0) return INT_MIN;
	if(i==n || r==0 ) return 0;
	if(dp[i][r]!=-1) return dp[i][r];

	dp[i][r] = max( solve(i+1,r) , solve(i+1,r-a[i])+b[i] );

	return dp[i][r];
}
    int Solve0()
    {

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

	memset(dp,-1,sizeof(dp));

	cout << solve(0,w);

     RE0;
    }





    int main()
    {
    Solve0();
    RE0;
    }


Measured memory_bytes: 862968