akhauriyash/Code-Regression huggingface dataset:
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    double d; cin >> d;
    cout << d * d * d / 27 << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
const ll INF = 1LL << 60;

int main(){
  string s;
  cin >> s;
  if(s=="ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b,c,x=0;
  cin>>a;
  if(a%10==(a/100))
  {
    Yes
  }
  else
  {
    No
  }
  
  
  

}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxN = 5005;
int a[maxN];
vector < int > g[maxN];
ll dp[maxN][maxN];
bool positive[maxN][maxN];
bool nposs[maxN];
int n;
int sz[maxN];
const ll INF = (ll)1e18;
int f[maxN];
ll ndp[maxN];
void dfs(int v, int p) {
    if (a[v] < 0) {
        dp[v][0] = a[v];
        positive[v][0] = false;
    } else {
        dp[v][0] = a[v];
        positive[v][0] = true;
    }
    sz[v] = 1;
    for (int to : g[v]) {
        if (to == p) continue;
        dfs(to, v);
        for (int i = 0; i <= sz[v] + sz[to]; i++) {
            for (int flag = 0; flag < 2; flag++) {
                ndp[i] = INF;
                nposs[i] = false;
            }
        }
        for (int del_edges = 0; del_edges <= sz[v]; del_edges++) {
            for (int del_edges2 = 0; del_edges2 <= sz[to]; del_edges2++) {
                ndp[del_edges + del_edges2] = min(ndp[del_edges + del_edges2],
                                                  dp[v][del_edges] + dp[to][del_edges2]);
                nposs[del_edges + del_edges2] |= (positive[v][del_edges] & positive[to][del_edges2]);
                if (dp[to][del_edges2] < 0) {
                    ndp[del_edges + del_edges2 + 1] = min(ndp[del_edges + del_edges2 + 1],
                                                          dp[v][del_edges]);
                    nposs[del_edges + del_edges2 + 1] |= positive[v][del_edges];
                }
                if (positive[to][del_edges2]) {
                    ndp[del_edges + del_edges2 + 1] = min(ndp[del_edges + del_edges2 + 1], dp[v][del_edges]);
                    nposs[del_edges + del_edges2 + 1] |= positive[v][del_edges];
                }
            }
        }
        sz[v] += sz[to];
        for (int i = 0; i <= sz[v]; i++) {
            dp[v][i] = ndp[i];
            positive[v][i] = nposs[i];
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j] = INF;
            positive[i][j] = false;
        }
    }
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, -1);
    for (int edges = 0; edges <= n - 1; edges++) {
        if (dp[1][edges] < 0 || positive[1][edges]) {
            cout << edges;
            return 0;
        }
    }
    return 0;
}

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

int main() {
	string s,t;
	int n;
	cin >> s >> t;
	int l = s.length();
	n = 0;
	for (int i = 0; i < l; i++){
		if (s[i]!= t[i]) n++;
	}
	cout << n;
}


			



Measured memory_bytes: 3920
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
	int i, j;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> a[i];

	int mn = 1e9;
	int cnt = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] <= mn)
			cnt++;

		mn = min(a[i], mn);
	}
	cout << cnt;

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Measured memory_bytes: 1792
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for an in A:
  tmp = 0
  for a, b in zip(an, B):
    tmp += a*b
  tmp += C
  if tmp > 0:
    ans += 1

print(ans)

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

int main(void){
    string S;
    cin >> S;
    int Zbuf=0;
    int Z=0;
    multiset<int, greater<int>> csum;
    for(int i=0; i<S.size(); i++){
        if(S[i] == '1'){
            Zbuf++;
        }else Zbuf--;
        Z=max(Z, Zbuf);
        csum.insert(Zbuf);
    }
    Zbuf = 0;
    int Zbuf0 = 0;
    int Zbuf1 = 0;
    int fZ0 = 0;
    int fZ1 = 0;
    int Zbuf0diff = 0;
    int Zbuf1diff = 0;
    for(int i=0; i<S.size(); i++){
        switch(S[i]){
            case '0':
                Zbuf--;
                Zbuf0--;
                Zbuf1--;
                break;
            case '1':
                Zbuf++;
                Zbuf0++;
                Zbuf1++;
                break;
            default:
                Zbuf--;
                int MaxRight = *(csum.begin());
                if(MaxRight+Zbuf0diff+2 <= Z){
                    Zbuf0++;
                    Zbuf0diff += 2;
                }else{
                    Zbuf0--;
                }
                if(MaxRight+Zbuf1diff+2 <= Z+1){
                    Zbuf1++;
                    Zbuf1diff += 2;
                }else{
                    Zbuf1--;
                }
        }
        fZ0=min(fZ0, Zbuf0);
        fZ1=min(fZ1, Zbuf1);
        csum.erase(csum.find(Zbuf));
    }
    cout << min(Z-fZ0, Z+1-fZ1) << endl;
    return 0;
}

Measured memory_bytes: 51244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll n, m;
    scanf("%lld%lld", &n, &m);
    ll ans = 0;
    // 偶数回裏返すと表、奇数回裏返すと裏
    // 制約n <= m
    // N = 1 かつ M = 1 のとき
    if(n == 1 && m == 1) {
       ans = 1;
    }
    // ???
    else if(n == 1 || m == 1) {
        ans = max(n, m) - 2;
    }
    // N >= 2 かつ N <= M かつ M >= 2
    // 四隅は4回、四隅以外の端は6回、それ以外は9回
    else {
        // ans = n * m - (2 * (n + m) - 4);
        ans = (n - 2) * (m - 2); 
    }
    printf("%lld\n", ans);
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

string s;

int main() {
    std::ios::sync_with_stdio(false);
    cin >> s;
    int ns[4] = {s[0]-'0', s[1]-'0', s[2]-'0', s[3]-'0'};
    char op[2] = {'+', '-'};
    for(int i=0;i<2;i++){
        int ni = ns[0] + (i?-ns[1]:ns[1]);
        for(int j=0;j<2;j++){
            int nj = ni + (j?-ns[2]:ns[2]);
            for(int k=0;k<2;k++){
                int nk = nj + (k?-ns[3]:ns[3]);
                if(nk == 7){
                    cout << s[0];
                    cout << op[i] << s[1];
                    cout << op[j] << s[2];
                    cout << op[k] << s[3];
                    cout << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

X = int(sys.stdin.buffer.readline())
x = 100
cnt = 0
while True:
    x *= 1.01
    x = int(x)
    cnt += 1
    if x >= X:
        print(cnt)
        exit()



Measured memory_bytes: 9184
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    rep(i,2){
        int cnt = 0;
        rep(j,n){
            if(s[j] == 'R') ++cnt;
            else{
                ans[j] += cnt/2;
                ans[j-1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }
        reverse(ans.begin(), ans.end());
        reverse(s.begin(), s.end());
        rep(j,n){
            if(s[j] == 'L') s[j] = 'R';
            else s[j] = 'L';
        }
    }
    rep(i,n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  string S;
  cin >> S;

  int a = 0,b = 0;
  REP(i,S.size()){
    if(S.at(i) == '0'){
      a++;
    }else{
      b++;
    }
  }

  cout << min(a,b)*2 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

ll n, m, ans;

int main(){
    cin >> n >> m;
    vector<ll> x(m), l(m - 1);
    for (int i = 0; i < m; i++){
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    for (int i = 0; i + 1 < m; i++){
        ll d = abs(x[i] - x[i + 1]);
        ans += d;
        l[i] = d;
    }
    sort(l.rbegin(), l.rend());
    for (int i = 0; i < min(n - 1, m - 1); i++){
        ans -= l[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<bitset>
using namespace std;
int main(){
  int N=100001;
  bool isprime[N];
  for(int i=0;i<N;i++)
    isprime[i]=1;
  isprime[0]=isprime[1]=0;
  for(int i=0;i*i<N;i++){
    if(isprime[i]){
      for(int j=2;i*j<N;j++)
        isprime[i*j]=0;
      }
    }
  int num[100001];
  num[0]=1;
  for(int i=1;i<N;i++){
    if(isprime[i]&&isprime[(i+1)/2])
      num[i]=num[i-1]+1;
    else
      num[i]=num[i-1];
    }
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int l,r;
    cin>>l>>r;
    cout<<num[r]-num[l-1]<<endl;
    }
  return 0;
  }

  
  


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if (isupper(s[0]))
    {
        cout<<"A";
    }
    if(islower(s[0]))
    {
        cout<<"a";
    }
    
    
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	    String s[]=br.readLine().split(" ");
      	int a=Integer.parseInt(s[0]);
		float b=Float.parseFloat(s[1]);
      	System.out.printf("%.0f",a*b);
      System.out.println();

    }
}


Measured memory_bytes: 25552
import math
a,b,h,m = map(int,input().split())
kakudoh = (h + (m/60)) * 30 
kakudom = m * 6
c = math.fabs(kakudoh-kakudom)
long = (a**2 + b**2 - (2*a*b*math.cos(math.radians(c))))**(1/2)
print(long)

Measured memory_bytes: 9512
n, p = map(int, input().split())
s = list(input())
s.reverse()
ans = 0

if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += n - i
else:
    modlist = [0] * (n + 1)
    ten = 1
    for i in range(n):
        mod_now = (int(s[i]) * ten) % p
        modlist[i + 1] = (modlist[i] + mod_now) % p
        ten *= 10
        ten %= p
    countlist = [0] * p
    for i in range(n + 1):
        ans += countlist[modlist[i]]
        countlist[modlist[i]] += 1
print(ans)

Measured memory_bytes: 12404
#include<iostream>
using namespace std;
int main(void)
{
	int n,i,j,p[50],cnt=0;
	cin>>n;
	for(i=0;i<n;i++) cin>>p[i];
	for(i=0;i<n;i++){if(p[i]!=(i+1)) cnt++;}
	if(cnt==0 || cnt==2) 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)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    string S, T, U;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    cin >> U;
    if (S == U) {
        cout << A-1 << " " << B << endl;
    } else {
        cout << A << " " << B-1 << endl;
    }
    return 0;
}

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

typedef long long ll;


int main() 
{
    ll n,k;
    cin>>n>>k;
    ll c=0;
    while(n>0)
    {
        n=n/k;
        c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   while(1){
       int m,f,r;
       scanf("%d%d%d",&m,&f,&r);
       
       if(m==-1&&f==-1&&r==-1)
       break;
       else if(m==-1||f==-1||m+f<30)
       printf("F\n");
       else if(m+f>=80)
       printf("A\n");
       else if(m+f>=65)
       printf("B\n");
       else if(m+f<50&&r<50)
       printf("D\n");
       else
       printf("C\n");
   }
    return 0;
}

Measured memory_bytes: 2600
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 3000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
int n,cnt0,cnt1,cnt2;
int arr[100005];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cin>>n;
int x=1;
while(x<=n)
{
	int z=x*1.08;
	if(z==n){

	cout<<x;
	return 0;}
	x++;
}
cout<<":(";



}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
typedef pair<ll,ll> pii;
const int maxn=100005;
const int mod=1e9+7;
char s[maxn];
int pre[maxn][26];
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    IOS;
    cin>>s+1;
    int n=strlen(s+1);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<26;j++)
            pre[i][j]=pre[i-1][j];
        pre[i][s[i]-'a']++;
    }
    for(int j=0;j<26;j++)
    {
        int mark=-1;
        int mn=1e9;
        for(int i=1;i<=n;i++)
        {
            if(s[i]-'a'==j)
            {
                if(mn<2*pre[i][s[i]-'a']-i)
                {
                    cout<<mark<<' '<<i<<endl;
                    return 0;
                }
                if(mn>2*pre[i-1][s[i]-'a']-i+1)
                {
                    mn=2*pre[i-1][s[i]-'a']-i+1;
                    mark=i;
                }
            }
        }
    }
    cout<<"-1 -1\n";
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

int dp[10][201];

signed main(){
    int N; cin >> N;
    vector<int> p( 4 ), t( 4 );
    REP( i, 4 ) cin >> p[i];
    REP( i, 4 ) cin >> t[i];

    fill( dp[0], dp[4], INF );
    REP( i, 4 ) dp[i][0] = 0;
    REP( i, 4 ) dp[0][t[i]] = p[i];

    REP( i, 4 ){
        REP( j, 201 ){
            if( j < t[i] ){
                dp[i + 1][j] = dp[i][j];
            }else{
                dp[i + 1][j] = min( dp[i][j], dp[i + 1][j - t[i]] + p[i] );
            }
        }
    }


    int ans = INF;
    FOR( i, N, 201 ){
        chmin( ans, dp[4][i] );
    }

    cout << ans << endl;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef long double ld;
#define mkp make_pair
int main()
{
	ll n;
	cin>>n;
	ll k = n/500;
	ll m = n%500;
	m/=5;
	cout<<k*1000+m*5<<endl;
	return 0;
 } 

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

int main(){
  int a,b;
  cin >> a>>b;
  int miaximum = 0;
  rep(i,b){
    int s;
    cin >> s;
    miaximum += s;
  }
  if(miaximum >= a)cout << "Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import math
import copy

s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
e = a + b
f = a - b
g = c + d
h = c - d
if e + g == 7:
    a,b,c,d = map(str,(a,b,c,d))
    print(a+'+'+b+"+"+c+"+"+d+"=7")
elif e + c-d == 7:
    a,b,c,d = map(str,(a,b,c,d))
    print(a+'+'+b+"+"+c+"-"+d+"=7")
elif e + d-c == 7:
    a,b,c,d = map(str,(a,b,c,d))
    print(a+'+'+b+"-"+c+"+"+d+"=7")
elif e - c-d == 7:
    a,b,c,d = map(str,(a,b,c,d))
    print(a+'+'+b+"-"+c+"-"+d+"=7")
elif f + g == 7:
    a,b,c,d = map(str,(a,b,c,d))
    print(a+'-'+b+"+"+c+"+"+d+"=7")
elif f + c-d == 7:
    a,b,c,d = map(str,(a,b,c,d))
    print(a+'-'+b+"+"+c+"-"+d+"=7")
elif f + d-c == 7:
    a,b,c,d = map(str,(a,b,c,d))
    print(a+'-'+b+"-"+c+"+"+d+"=7")
elif f - c-d == 7:
    a,b,c,d = map(str,(a,b,c,d))
    print(a+'-'+b+"-"+c+"-"+d+"=7")

Measured memory_bytes: 3444
import java.util.Scanner;

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

		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(b%a==0){
			System.out.println(a+b);
		}else{
			System.out.println(b-a);
		}

	}
}

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

void solve() {
  int64_t n, k;
  cin >> n >> k;

  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  auto pos = lower_bound(a.begin(), a.end(), 0);
  auto rpos = make_reverse_iterator(pos);
  auto non_zero_pos = upper_bound(a.begin(), a.end(), 0);

  auto pos_cnt = a.end() - pos;
  auto neg_cnt = n - pos_cnt;
  auto non_zero_pos_cnt = a.end() - non_zero_pos;
  auto zero_cnt = pos_cnt - non_zero_pos_cnt;

  constexpr int64_t limit = 1'000'000'001LL;
  int64_t left = -limit * limit;
  int64_t right = limit * limit;
  while (1 < right - left) {
    int64_t lcnt = 0;
    int64_t ucnt = 0;
    auto mid = (left + right) / 2;

    if (mid == 0) {
      lcnt = neg_cnt * non_zero_pos_cnt;
      ucnt = lcnt;
      for (int i = 0; i < zero_cnt; ++i) {
        ucnt += n - 1 - i;
      }
      assert(lcnt <= ucnt);
    } else if (mid < 0) {
      for (auto it = a.begin(); it != pos; ++it) {
        auto lcmp = [=](int64_t elem, int64_t val) {
          assert(val == mid);
          return elem * *it < val;
        };
        auto ucmp = [=](int64_t val, int64_t elem) {
          assert(val == mid);
          return elem * *it > val;
        };
        auto lit = lower_bound(a.rbegin(), rpos, mid, lcmp);
        auto uit = upper_bound(a.rbegin(), rpos, mid, ucmp);
        auto dl = lit - a.rbegin();
        auto du = uit - a.rbegin();
        assert(dl <= du);
        lcnt += dl;
        ucnt += du;
      }
    } else {
      for (auto it = a.begin(); it != pos; ++it) {
        auto lcmp = [=](int64_t elem, int64_t val) {
          assert(val == mid);
          return elem * *it < val;
        };
        auto ucmp = [=](int64_t val, int64_t elem) {
          assert(val == mid);
          return elem * *it > val;
        };
        auto end = make_reverse_iterator(it + 1);
        auto lit = lower_bound(rpos, end, mid, lcmp);
        auto uit = upper_bound(rpos, end, mid, ucmp);
        auto dl = pos_cnt + lit - rpos;
        auto du = pos_cnt + uit - rpos;
        assert(dl <= du);
        lcnt += dl;
        ucnt += du;
      }
      for (auto it = pos; it != a.end(); ++it) {
        auto lcmp = [=](int64_t elem, int64_t val) {
          assert(val == mid);
          return elem * *it < val;
        };
        auto ucmp = [=](int64_t val, int64_t elem) {
          assert(val == mid);
          return elem * *it > val;
        };
        auto lit = lower_bound(it + 1, a.end(), mid, lcmp);
        auto uit = upper_bound(it + 1, a.end(), mid, ucmp);
        auto dl = lit - it - 1;
        auto du = uit - it - 1;
        assert(dl <= du);
        lcnt += dl;
        ucnt += du;
      }
    }
    assert(lcnt <= ucnt);
    if (k <= lcnt) {
      right = mid;
    } else if (ucnt < k) {
      left = mid;
    } else {
      cout << mid << endl;
      return;
    }
  }
  assert(false);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int x=1,t=0,ans=0;
    while(x<n+1)
    {
        if(a[x]==x)
            {
                t++;

            }
        if(a[x]!=x)
        {
            if(t!=0)
                ans+=(t+1)/2;
            t=0;
        }
        x++;
    }
     cout<<ans+(t+1)/2;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int m; cin >> m&&m;) {
		set<pair<int, int>> st;
		vector<int> tx(m), ty(m); rep(i, 0, m) { cin >> tx[i] >> ty[i]; }
		int n; cin >> n;
		vector<int> sx(n), sy(n); rep(i, 0, n) {
			cin >> sx[i] >> sy[i];
			st.emplace(sx[i], sy[i]);
		}

		rep(i, 0, n) {
			bool flag = true;
			int dx = sx[i] - tx[0], dy = sy[i] - ty[0];
			rep(j, 0, m) {
				if (!st.count(pair<int, int>(tx[j] + dx, ty[j] + dy))) {
					flag = false;
					break;
				}
			}
			if (flag) {
				cout << dx << " " << dy << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main()
{
  int n, p;
  while(1){
    cin >> n >> p;
    if(n==0 && p==0){
      break;
    }else{
      int c[50] = {};
      int i = 0, b = p;
      while(1){
        if(p){
          c[i]++;
          p--;
        }else{
          p += c[i];
          c[i] = 0;
        }
        if(c[i]==b){
          cout << i << endl;
          break;
        }
        i++;
        if(i>n-1)
        i=0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    int n;
    cin >> n;
    string s;
    map<string, unsigned long long> all;
    for(int i = 0; i < n; i++)
    {
        cin >> s;
        sort(s.begin(), s.end());
        all[s]++;
    }
    unsigned long long ans = 0;
    for(auto &e : all)
        ans += e.second * (e.second - 1) / 2;
    cout << ans;
    return 0;
}


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

namespace _0028
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] countNum = new int[101];
            List<int> modes = new List<int>();
            string inputNum;
            while ((inputNum = Console.ReadLine()) != null)
            {
                countNum[int.Parse(inputNum)] += 1;
            }
            int numModes = countNum.Max();
            for (int i = 1; i < 101; ++i)
            {
                if (numModes == countNum[i])
                    modes.Add(i);
            }
            modes.Sort();
            foreach (int mode in modes)
                Console.WriteLine(mode);
        }
    }
}



Measured memory_bytes: 16232
// AtCoder Beginners Selection
// ABC175B - Making Triangle
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum = 0;
  cin >> N;
  
  vector<int> L(N);
  for (int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
    
  //loop
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      for (int k = 0; k < N; k++){
        if (i < j && j < k 
            && L.at(i) != L.at(j) && L.at(j) != L.at(k) 
            && L.at(i) != L.at(k) 
            && L.at(i) + L.at(j) > L.at(k)){
            //cout << i+1 << j+1 << k+1 <<endl;   
            sum++;
        }
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main () {
  string A, B;
  cin >> A >> B;
  A += B;
  int sub = stoi(A);
  int ans = sqrt(sub);
  if(ans * ans == sub)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
MOD = 10**9 + 7
SLen = len(S)
targets = "ABC"
dp = [[0 for i in range(SLen + 1)] for _ in range(4)]
dp[0][0] = 1
for i in range(SLen):
    for j in range(4):
        if S[i] == '?':
            if j < 3:
                dp[j + 1][i + 1] = (dp[j + 1][i + 1] + dp[j][i]) % MOD
            dp[j][i + 1] = (dp[j][i + 1] + dp[j][i] * 3) % MOD
        else:
            if j < 3 and S[i] == targets[j]:
                dp[j + 1][i + 1] = (dp[j + 1][i + 1] + dp[j][i]) % MOD
            dp[j][i + 1] = (dp[j][i + 1] + dp[j][i]) % MOD

print(dp[3][SLen])


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

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

    ll p = -1;
    REP(i,1,100000) {
        if((ll)(i * 0.08) == A && (ll)(i * 0.10) == B) {
            p = i;
            break;
        }
    }
    PR(p);

    return 0;
}

/*



*/

Measured memory_bytes: 764
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1611&lang=jp
// ほぼ自力AC
// 国内予選2016D: ダルマ落とし (☆☆)

/*
Problem.
条件を満たす隣り合う２要素を任意に選び削除していくとき、
削除可能な最大要素数はいくらか？

Point.
手順１:dp[上][下] = max(2, dp[上-1][下+1]+2, dp[上][中間：上+1,2...下] + dp[中][下])
iからjまでの連続した区間の削除数(iからjまで削除可能なとき)
手順２:dp[i][j] = dp[i][k] + dp[k+1][j];
iからjまでの区間の最大削除数
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n;
  while(cin >> n && n){
    vi w(n);
    for(int &i:w) cin >> i;
    vvi dp(n, vi(n, 0));
    for(int bot = 0; bot < n; bot++){
      for(int top = bot-1; top >= 0; top--){
        if(bot == top+1 && abs(w[top]-w[bot]) < 2){
          dp[top][bot] = 2;
          continue;
        }
        if(dp[top+1][bot-1] > 0 && abs(w[top]-w[bot]) < 2){
          dp[top][bot] = dp[top+1][bot-1] + 2;
        }
        for(int mid = top+1; mid < bot; mid++){
          if(dp[top][mid-1] > 0 && dp[mid][bot] > 0) dp[top][bot] = max(dp[top][bot], dp[top][mid-1]+dp[mid][bot]);
        }
      }
    }
    for(int j = 0; j < n; j++){
      for(int k = 0; k < j; k++){
        dp[0][j] = max(dp[0][j], dp[0][k] + dp[k+1][j]);
      }
    }
    cout << dp[0][n-1] << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



Measured memory_bytes: 3312
$n=<>;
map{push@$_,$%for glob;$%++}<>;
map{$i=%u=();map{0while$u{$A[$_]=++$i}}grep{$u{$A[$_]}=1;!$A[$_]}@$_;$m+=$-=$i-$m}1..$n;
print"$m @A"

Measured memory_bytes: 90652
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,d=LI()
  ans=0
  for _ in range(n):
    x,y=LI()
    dis=math.sqrt(x*x+y*y)

    if dis<=d:
      ans+=1

  return ans

# main()
print(main())


Measured memory_bytes: 10688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define f_in freopen("test.in","r",stdin);
#define f_out freopen("test.in","w",stdout);
#define debug(x) cerr << #x << " : " << x << "\n";
#define _ cin.sync_with_stdio(0); cin.tie(0);
#define tl cout <<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms\n"
#define Func {ans += solve(i); ++i;}


typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

template<typename T = int>
inline T nxt(){
    char c=nc();T x=0; int f=1;
    for(;c>'9'||c<'0';c=nc())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
    x*=f;
    return x;
}


int main(){
#ifdef LOCAL_DEFINE
    f_in
#else
    _
#endif
    set<char> s;
    int n;
    cin >> n;
    char c;
    rep(i,0,n) cin >> c, s.insert(c);
    if(sz(s) == 4) cout << "Four\n";
    else           cout << "Three\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    static int count = 0;
    static int input = 0;
 
    public static int sum(int x, int y) {
        return (x + y) * (y - x + 1) / 2;
    }
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        while (true) {
            input=0;
            count=0;
            String num = br.readLine();
            if (num.equals("0")) {
                return;
            }
 
            input = Integer.parseInt(num);
 
            for (int i = 1; i < input; i++) {
                for (int j = i+1; j < input; j++) {
                    if (input == sum(i, j)) {
                        count++;
                        break;
                    }
                    if (input < sum(i, j)) {
                        break;
                    }
                }
            }
            System.out.println(count);
        }
    }
 
}


Measured memory_bytes: 24912
#include<stdio.h>


int main(){

  int card[4][13]={};
  int n, num, i, j;
  char m;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf(" %c %d", &m, &num);
    if(m=='S') card[0][num-1]=1;
    else if(m=='H') card[1][num-1]=1;
    else if(m=='C') card[2][num-1]=1;
    else if(m=='D') card[3][num-1]=1;
  }

  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(i==0&&card[i][j]==0) printf("S %d\n", j+1);
      else if(i==1&&card[i][j]==0) printf("H %d\n", j+1);
      else if(i==2&&card[i][j]==0) printf("C %d\n", j+1);
      else if(i==3&&card[i][j]==0) printf("D %d\n", j+1);
    }
  }

  
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
//typedef int64_t int;
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define pb push_back
#define mk make_pair
#define endl "\n"
#define int int64_t
#define ll long long
#define in(num,n) std::vector<int> num(n); for (int i = 0; i < n; i++)cin >> num[i]
const ll Inf = 1e9 + 7;
void solve() {
    int n;
    cin >> n;
    std::vector<int> num(n); for (int i = 0; i < n; i++)cin >> num[i];
    sort(all(num));
    int high = num[num.size() - 1], low = num[0];
    int indi, re = 10000000, sum = 0;
    for (int i = low; i <= high; i++) {
        sum = 0;
        for (int j = 0; j < n; j++) {
            sum = sum + (num[j] - i) * (num[j] - i);
        }
        //cout << sum << endl;
        re = min(sum, re);
    }

    cout << re << endl;
}


int32_t main()
{
    fastio;
    precise;
    //int test; cin >> test; while (test--)
    solve();
    return 0;
}

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

int main(){
	int match;
	while(1){
		cin >> match;
		if(match == 0)break;
		int a,b;
		int score_a=0,score_b=0;
		for(int i=0;i<match;i++){
			cin >> a >> b;
			if(a > b) score_a += (a+b);
			else if(a < b) score_b+=(a+b);
			else{
				score_a+=a;score_b+=b;
			}
		}
		cout << score_a << " " << score_b<<endl;
	}
	return 0;
}

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

int main()
{
	string s;
	int K;
	cin >> s >> K;
	for (int i = 0; i < s.size(); i++) {
		if (((int)'z' - s[i] + 1) % 26 <= K) {
			K -= ((int)'z' - s[i] + 1) % 26;
			s[i] = 'a';
		}
	}
	s.back() = 'a' + (s.back() - 'a' + K) % 26;
	cout << s << endl;
	return 0;
}


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

int op(int a,int b){
	return max(a,b);
}

int e() {
	return (int)(0);
}

int main()
{
	int n,k;cin >> n >> k;
	vector<int> a(n);
	for(auto &i:a)cin >> i;
	atcoder::segtree<int,op,e> ST(300001);
	for(int i = 0;i<n;i++)
	{
		int in = ST.prod(max(0,a[i]-k),min(300001,a[i]+k+1));
		in++;
		ST.set(a[i],in);
		//for(int j = 0;j<n;j++)cout<<ST.get(j)<<' ';cout<<endl;
	}
	cout<<ST.all_prod()<<endl;
	
	
}


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

#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define mem(a,b) memset(a,b,sizeof(a))

int a,b,c;

int main()
{
    cin>>a>>b>>c;
    if(a==b) cout<<c;else
    {
        if(b!=c) cout<<b;else cout<<a;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int n,m,x,y;cin>>n>>m>>x>>y;
  int xm=x,ym=y;
  rep(i,n){
    int a;cin>>a;
    xm = max(a,xm);
  }
  rep(i,m){
    int a;cin>>a;
    ym = min(a,ym);
  }
  if(xm<ym){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	double x;
	while(cin >>x){
		for(int i=1;;i++){
			double hight=5*i-5,v=sqrt(4*4.9*hight);
			if(v>=x){cout <<i<<endl;break;}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };



int main()
{
    int h, w;
    Vs G;
    cin >> h >> w;
    int sx, sy;
    cin >> sx >> sy;
    sx--;
    sy--;
    int gx, gy;
    cin >> gx >> gy;
    gx--;
    gy--;
    G.resize(h);
    rep(i, h) cin >> G[i];


    // BFS のためのデータ構造
    Vii dist(h, Vi(w, 1e8)); // 全頂点を「未訪問」に初期化
    deque<Pi> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[sx][sy] = 0;
    que.push_back({ sx,sy });

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        Pi v = que.front(); // キューから先頭頂点を取り出す
        que.pop_front();
        // v から辿れる頂点をすべて調べる
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                Pi nv = { v.first + i,v.second + j };
                if (nv.first < 0 || nv.first >= h || nv.second < 0 || nv.second >= w)  continue;
                //if (dist[nv.first][nv.second] != 1e8)  continue;
                if (dist[nv.first][nv.second] <= dist[v.first][v.second]) continue;
                if (G[nv.first][nv.second] == '#') continue;
                if ((i == -1 && j == 0) || (i == 0 && j == 1) || (i == 1 && j == 0) || (i == 0 && j == -1)) {
                    dist[nv.first][nv.second] = dist[v.first][v.second];
                    que.push_front(nv);
                }
                else {
                    dist[nv.first][nv.second] = dist[v.first][v.second] + 1;
                    que.push_back(nv);
                }
                //cout << nv.first << " " << nv.second << endl;
            }
        }
    }

    if (dist[gx][gy] != 1e8) {
        cout << dist[gx][gy] << endl;
    }
    else {
        cout << -1 << endl;
    }

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


Measured memory_bytes: 10152
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

ll C(ll N) {
	return N * (N - 1) / 2;
}

int main() {
	ll N; cin >> N;
	vector<ll> A(N); rep(i, N)cin >> A[i];

	ll cnt[N + 1] = {};
	rep(i, N) cnt[A[i]]++;
	ll ans = 0;
	rep(i, N+1) {
		ans += C(cnt[i]);
	}

	ll tmp = ans;
	rep(i, N) {
		ans = tmp;
		ll n = A[i];
		ans -= C(cnt[A[i]]);
		ans += C(cnt[A[i]] - 1);
		cout << ans << endl;
	}
}

Measured memory_bytes: 5760
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        t: usize,
    };

    println!("{:?}", ( t / a ) * b);

}



Measured memory_bytes: 4352
#!/usr/bin/python3

def main():
    N = int(input())
    height = list(map(int, input().split()))

    dp = [10 ** 4 for _ in range(N)]

    dp[0] = 0
    dp[1] = abs(height[1] - height[0])

    for i in range(2, N):
        dp[i] = min(dp[i-1] + abs(height[i] - height[i-1]), dp[i-2] + abs(height[i] - height[i-2]))

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13976
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a[4];
  int e,f;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> e >> f;
  sort(a,a+4);

  cout << a[3]+a[2]+a[1]+max(e,f)<< endl;
  return 0;
}

Measured memory_bytes: 3104
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

void Main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;;
}

int main() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3656