akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int r, c;
	cin >> r; cin >> c;
	vector<vector<int>> input(r, vector<int>(c));
	vector<vector<int>> output(r + 1, vector<int>(c + 1, 0));

	for(int i = 0; i < input.size(); ++i){
		for(int j = 0; j < input[i].size(); ++j){
			int tmp;
			cin >> tmp;
			input[i][j] = tmp;
			output[i][j] = tmp;
		}
	}

	for(int i = 0; i < output.size(); ++i){
		if(output.size() - 1 > i){
			for(int j = 0; j < output[i].size() - 1; ++j){
				output[i].back() += output[i][j];
			}
		}else{
			for(int j = 0; j < output[i].size(); ++j){
				for(int k = 0; k < i; ++k){
					output[i][j] += output[k][j];
				}
			}
		}
	}

	for(int i = 0; i < output.size(); ++i){
		for(int j = 0; j < output[i].size(); ++j){
			cout << output[i][j];
			if(c > j) { cout << " "; }
		}
		// if(r > i) { cout << endl; }
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
const int Mod=1e9+7;
const int N=2e3+10;
int a[N]={0,0,0,1};
int main(){
	int n;
	cin>>n;
	for(int i=4;i<=n;i++)a[i]=(a[i-1]+a[i-3])%Mod;
	cout<<a[n]<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k, q; cin>>n>>k>>q;
	vector<int> p(n+1, k);
	vector<string> ans(n+1);
	int x;
	for (int i=0; i<q; ++i){
		cin>>x;
		p[x]++;
	}
	for (int i=1; i<=n; ++i) 
		cout<<(p[i] - q > 0 ? "Yes" : "No")<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define MAX 100000
typedef long long llong;

int n, k;

//最大積載量Pのk台のトラックで何個の荷物を積めるか
int check(int w[], llong P)
{
	int i=0;
	for(int j=0; j<k; j++){
		llong s = 0;
		while( s + w[i] <= P ){
			s = s + w[i];
			i++;
			if(i==n) return n;
		}
	}
	
	return i;
}

int solve(int w[], int n)
{
	llong left = 0;
	llong right = 100000*10000; //荷物の個数×一個あたりの最大重量
	llong mid;
	while( right-left>1 ){
		mid = (left+right) / 2;
		int v = check(w, mid);	//mid==Pｗｐ決めて何個積めるかチェック
		if( v>=n ) right = mid;
		else left =  mid;
	}
	return right;
}

int main(void)
{
	int i;
	scanf("%d %d",&n, &k);
	int w[n];
	for(i=0; i<n; i++){
		scanf("%d", &w[i]);
	}
	llong ans = solve(w, n);
	printf("%ld\n", ans);
}


Measured memory_bytes: 2244
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

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

  int n, m;
  cin >> n >> m;

  vector<int> a(n);

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

  for (int i = 0; i < n; i++) {
    if (i != 0) { a[i] += a[i-1]; }
    a[i] %= m;
  }

  map<int, int> mp;
  ll ans = 0;

  for (int i = 0; i < n; i++) {
    mp[a[i]]++;
    if (a[i] == 0) {
      ans += mp[0];
    } else {
      ans += mp[a[i]] - 1;
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

bool a[4] ;

int main() {
  int n ;
  scanf("%d\n", &n) ;
  n*=2 ;
  char s[n] ;

  for(int i = 0 ; i<n ;i++)
    scanf("%c", &s[i]) ;


  for(int i = 0 ; i<n;i++){
    if(s[i] == 'G') a[0] = true ;
    else if(s[i] == 'W') a[1] = true ;
    else if(s[i] == 'Y') a[2] = true ;
    else if(s[i] == 'P') a[3] = true ;
  }

  bool all = true ;
  for(int i = 0 ;i<4 ; i++)
    all&=a[i] ;

  if(all)printf("Four") ;
  else printf("Three") ;
  return 0 ;
}


Measured memory_bytes: 256
#include<iostream>

#define int long long
using namespace std;

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(a % b, b);
}

const long long MOD = 1e9 + 7;

string s;

signed main()
{	
    cin >> s >> s;
    cout << "A" << s[0] << "C";
}

Measured memory_bytes: 256
s=input()
t=input()
ls=len(s)
lt=len(t)
f=False
for i in range(ls-lt,-1,-1):
  f=True
  for j in range(lt):
    if not(s[i+j]=="?" or s[i+j]==t[j]):
      f=False
      break
  if f:
    ns=s[:i]+t+s[i+lt:]
    print("".join(map(lambda x:"a" if x=="?" else x,list(ns))))
    break
if not f:
  print("UNRESTORABLE")

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

#define M 1000000007
#define INF 999999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
 #define MAX 100005
using namespace std;
 typedef pair<int,int> ii;
 typedef vector <ii> vii;
 typedef vector <int> vi;
 typedef long long int ll;

int main()
{
//  freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);

 ll n;
 cin>>n;
 cout<<"ABC"<<n<<endl;
 
return 0;

}


Measured memory_bytes: 256
si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

N, T = mii()
t = lmii()

p = []
t.sort()

st = t[0]
ed = t[0] + T
for i in range(1, N):
    n_st = t[i]
    n_ed = n_st + T

    if st <= n_st <= ed:
        ed = n_ed
    else:
        p.append((st, ed))
        st, ed = n_st, n_ed

p.append((st, ed))

ans = 0
for st, ed in p:
    ans += ed - st

print(ans)



Measured memory_bytes: 25708
#include <iostream>
#include<vector>
#define ll long long
using namespace std;
#define mod 1000000007
int Candies(vector<int>& v,int n,int k )
{
    ll dp[n+2][k+2];
    for(int j=0;j<=k;j++)
    {
        dp[1][j]=(j>v[1]?0:1);
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=(mod+dp[i-1][j]+dp[i][j-1]-((j-v[i]-1)>=0?dp[i-1][j-v[i]-1]:0))%mod;
            }
        }
    }
    return dp[n][k];
}
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    cout<<Candies(v,n,k);
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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 (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


struct Prime {
    using P = pair<i64, i64>;

    vector<P> factor(i64 x) {
        vector<P> res;
        for (i64 i = 2; i * i <= x; i++) {
            if (x % i != 0) continue;
            i64 p = 0;
            while (x % i == 0) {
                p++;
                x /= i;
            }
            res.push_back({i, p});
        }
        if (x != 1) res.pb({x, 1});
        return res;
    }
};

int main() {
    i64 N; cin >> N;
    using P = pair<i64, i64>;
    Prime prime;
    vector<P> factor = prime.factor(N);

    i64 cnt = 0;
    for (auto pc : factor) {
        i64 p = pc.first;
        i64 c = pc.second;
        i64 n = 1;
        while ((n * (n + 1)) / 2 <= c) n++;
        n--;
        cnt += n;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main(void) {
  ll i, j, k;
  ll N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  
  ll cut=1;
  for(i=0; i<(ll)s.size()-1; i++) if(s[i]!=s[i+1]) cut++;
  
  ll t=N-cut;
  pt(min(N-1, t+K*2));
}


Measured memory_bytes: 512
/*
 *  Created on: 22 / 8 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define ld   long double

#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define endl    '\n'

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//const ld EPS = 1e-8;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
	//stp(0)
	Eslam__Waheed;
	int n; cin >> n;
	vector<ll>v(n);
	for (auto& it : v)
	{
		cin >> it;
	}
	ll ans = 0, mx = LLONG_MIN;
	for (size_t i = 0; i < n; i++)
	{
		mx = max(mx, v[i]);
		ans += (mx - v[i]);
	}
	cout << ans;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    Yes(s[2] == s[3] && s[4] == s[5]);
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

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

  ll c_od = 0;
  ll c_ev = 0;

  if (k & 1)
  {
    // 奇数
    c_od = n / k;
  }
  else
  {
    // 偶数
    ll cnt = n / (k / 2);
    c_od = (cnt + 1) / 2;
    c_ev = cnt / 2;
  }
  cout << c_od * c_od * c_od + c_ev * c_ev * c_ev;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main(){
	int t;
	cin >> t;
	for(int i=0 ; i < t ; i++ ){
		int X, Y, W, H, n, ans=0;
		cin >> X >> Y >> W >> H >> n;
		for(int j=0 ; j < n ; j++ ){
			int x,y;
			cin >> x >> y;
			if( X <= x && x <= X+W && Y <= y && y <= Y+H ){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll h,w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    if(h % 2 == 0){
        
            cout << (h/2)*w << endl;
        
            
        
    }else{
        if(w % 2 == 0){
            cout << (h/2)*w+w/2 << endl;
        }else{
            cout<< (h/2)*w+w/2+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<ll> way(n + 1);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    way[a] = -1;
  }
  way[0] = 1LL;
  for (int i = 1; i <= n; i++) {
    if (way[i] >= 0 && way[i - 1] >= 0) {
      way[i] = (way[i] + way[i - 1]) % MOD;
    }
    if (i > 1 && way[i] >= 0 && way[i - 2] >= 0) {
      way[i] = (way[i] + way[i - 2]) % MOD;
    }
  }
  cout << way[n] << endl;
  return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	int N,A,B;
	cin>>N>>A>>B;
	if((B-A)%2LL==0LL)cout<<(B-A)/2LL<<endl;
	else{
		int P,Q,R,S;
		P=(B-1);
		Q=(N-A);
		R=A+(B-A-1)/2LL;
		S=N-B+1+(B-A-1)/2LL;
		int ans=min(P,min(Q,min(R,S)));
		cout<<ans<<endl;
	}
		
}

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

int N, M;

vector<int> adjList[200005];
bool visited[200005];
int memo[200005];

int dfs(int src)
{
	int ans = 1;
		
	visited[src] = true;
	for(int i = 0; i < (int)(adjList[src].size()); i++)
	{
		if(visited[adjList[src][i]])
			continue;
		ans += dfs(adjList[src][i]);
	}
	
	memo[src] = ans;
	return ans;
}

int main()
{
	scanf("%d%d", &N, &M);
	
	for(int i = 1; i <= M; i++)
	{
		int Ai, Bi;
		scanf("%d%d", &Ai, &Bi);
		
		adjList[Ai].push_back(Bi);
		adjList[Bi].push_back(Ai);
	}
	
	for(int i = 1; i <= N; i++)
	{
		if(visited[i])
			continue;
		dfs(i);
	}
	
	int ans = 0;
	for(int i = 1; i <= N; i++)
		ans = max(ans, memo[i]);
	printf("%d", ans);
}

Measured memory_bytes: 25004
from heapq import heappush, heappop

infi = 10 ** 20
n, m, s = map(int, input().split())

s = min(s, 2500)

edges = [[] for _ in range(51 * 2501 + 1)]
# edge:1-50, max silver=0-2500

for _ in range(m):
    u, v, a, b = map(int, input().split())
    for i in range(a, 2501):
        edges[v + 50 * i].append((b, u + 50 * (i - a)))
        edges[u + 50 * i].append((b, v + 50 * (i - a)))


for edge_num in range(1, n + 1):
    c, d = map(int, input().split())
    # c枚, d分
    for i in range(2501):
        # 点edge_num+ i * 50のところに
        if edge_num + (i + c) * 50 <= 51 * 2501:
            edges[edge_num + i * 50].append((d, edge_num + min((i + c), 2500) * 50))
start = 1 + 50 * s


def dijkstra(edges, start):
    time = [infi] * (51 * 2501 + 1)
    used = [False] * (51 * 2501 + 1)
    time[start] = 0
    edgelist = []
    heappush(edgelist, (0, start))
    while edgelist:
        nowtime, nowedge = heappop(edgelist)
        if used[nowedge] is True:
            continue
        used[nowedge] = True
        time[nowedge] = nowtime
        for vt, v in edges[nowedge]:
            if used[v] is True:
                continue
            newtime = nowtime + vt
            heappush(edgelist, (newtime, v))
    return time


time = dijkstra(edges, start)

ans = [infi] * (51)
for i in range(1, 51 * 2501 + 1):
    temp = time[i]
    a = i % 50
    if a == 0:
        a += 50
    ans[a] = min(temp, ans[a])

print(*ans[2 : (n + 1)], sep="\n")


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

int main(void) {
	int L, R;
	cin >> L >> R;
	int ans = 0;
	for (int a = 1; a < 10; a++) {
		for (int b = 0; b < 10; b++) {
			for (int c = 0; c < 10; c++) {
				int x = 10001 * a + 1010 * b + 100 * c;
				if (x >= L && x <= R) {
					ans ++;
				}
			}
		}
	} cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int tmp;
	int ans = 0;
	int num[101] = { 0 };

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &tmp);
		if (!num[tmp])
		{
			num[tmp]++;
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {
    string s;
    cin>>s;
    int hf=s.size()/2;
    for (int i=hf-1;i>0;i--) {
        if (s.substr(0,i)==s.substr(i,i)) {
            cout<<i*2<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
M = 1
prev_M = 0
A = []
for i in range(N):
  a = int(input())
  A += [a]
  if a == M:
    prev_M = M
  elif a > M:
    prev_M = M
    M = a
  elif a > prev_M:
    prev_M = a
for i in range(N):
  if A[i] != M:
    print(M)
  else:
    print(prev_M)


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

#define MATHPI acos(-1)

template<class T> void chmax(T &a, T b) {
    if (a < b) a = b;
}
template<class T> void chmin(T &a, T b) {
    if (b < a) a = b;
}

using Mat = vector<vector<ll>>;
using Column = vector<ll>;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N,R;cin>>N>>R;
    if(N>=10) {
        cout << R<<"\n";
    } else {
        cout << R + 100*(10-N)<<"\n";
    }

    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  ss <- replicateM n getLine
  m <- read <$> getLine :: IO Int
  ts <- replicateM m getLine
  putStrLn $ show $ solve ss ts

solve ss ts = maximum $ 0 : (map reduction $ group' ss)
  where
    reduction (s, n) = n - (length . filter (== s)) ts

group' :: [String] -> [(String, Int)]
group' [] = []
group' (s:ss) = (s, 1 + (length . filter (== s)) ss) : (group' . filter (/= s)) ss


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

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

Measured memory_bytes: 256
n = str(input())
valor =1;index=0;banderita=0;array=[];m=0;igual=[];posicion=0;vacio=0
for i in range(3):
    while(valor!=4):
        if(n[index]==n[valor]):
            banderita=banderita+1
            igual.append(n[valor])
            posicion = valor
        valor=valor+1   
    if(banderita==1):
        array.append(banderita)
    elif(banderita>1):
        print('No')
        break
    else:
        if(n[posicion] in igual):
            vacio=0
        else:
            print('No')
            break
    banderita=0
    index=index+1
    valor=index+1
    posicion=0
if(len(array)==2):
    print('Yes')
elif(len(array)==1):
    print('No')

Measured memory_bytes: 3064
import java.util.*;
import java.math.*;
class Main {
    //
    static final long MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ary = new int[n];
        for(int i = 0;i < n; i++){
            ary[i] = sc.nextInt();
        }
        Arrays.sort(ary);
        int ans = MAX;
        for(int i = 0;i < 100;i++){
            int l = 0;
            for(int j = 0;j < n;j++){
                l += (ary[j] - i)*(ary[j] - i);
            }
            if(ans > l)ans = l;
        }

        
        System.out.println(ans);

    }
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T>
inline void arrayFill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

int d[305][305];
void warshall_floyd(int n) {
    rep(k, n)rep(i, n)rep(j, n) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
}

void Main() {
    int n, m, l;
    cin >> n >> m >> l;

    arrayFill(d, INF);
    rep(i, n)d[i][i] = 0;

    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        d[a][b] = c;
        d[b][a] = c;
    }

    warshall_floyd(n);

    rep(i, n)rep(j, n) {
        if (d[i][j] <= l) d[i][j] = 1;
        else d[i][j] = INF;
    }

    warshall_floyd(n);

    int q;
    cin >> q;
    rep(i, q) {
        int s, t;
        cin >> s >> t;
        --s; --t;
        int ans = d[s][t] - 1;
        if (d[s][t] == INF)ans = -1;
        cout << ans << 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: 896
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  int a[N];
  for (int i = 0; i < N; i ++) {
    scanf("%d", &a[i]);
  }
  std::sort(a, a + N);
  int result = 0;
  for (int i = 1; i <= N; i ++) {
    //printf("%d\n", a[N - i]);
    if (i % 2) {
      result += a[N - i];
    } else {
      result -= a[N - i];
    }
  }
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 128
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

X, Y, Z = map(int, readline().split())
print((X-Z) // (Y + Z))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,a,b;
	string ans = "NG";
	cin >> k >> a >> b;
	for(int i = a; i <= b;i++){
		if(i%k == 0){
			ans = "OK";
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228

#define tm tm228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << endl; 
#define TIME (ld)clock()/CLOCKS_PER_SEC
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 1e9 + 7, MAXN = 1e6 + 7;
const double eps = 1e-9;
const ll INF = 1e18, inf = 1e15;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int n, T; 
int a[maxn];  
int pref[maxn], suf[maxn]; 

void solve() {
    cin >> n >> T; 
    for (int i = 0; i < n; ++i) cin >> a[i];  
    pref[0] = inf; 
    for (int i = 0; i < n; ++i) pref[i + 1] = min(pref[i], a[i]); 
    for (int i = n - 1; i >= 0; --i) suf[i] = max(suf[i + 1], a[i]); 
    vector<int> ptr; 
    int mx = 0; 
    for (int i = 0; i < n - 1; ++i) {
        mx = max(mx, suf[i + 1] - pref[i + 1]); 
    }
    set<pii> res; 
    for (int i = 0; i < n - 1; ++i) {
        if (suf[i + 1] - pref[i + 1] == mx) res.insert(mp(pref[i + 1], suf[i + 1])); 
    } 
    cout << res.size(); 
}                               
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
} 

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

int main() {
    int h,w;
    while(1){
    cin >> h >> w;
    if(h==0&&w==0) break;
    for (int j=0; j<h; j++) {
        for (int i=0; i<w; i++) {
            if((j==0)||(j==h-1)||(i==0)||(i==w-1)) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    cout << endl;
    }
}



Measured memory_bytes: 3096
import scala.util.control.Exception._
import java.util.InputMismatchException

object Main {
  def calc(n: Int, op: String, m: Int): Int = {
    op match {
      case "+" => m + n
      case "-" => m - n
      case _ => m * n
    }
  }

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val st = scala.collection.mutable.Stack[Int]()

    st.push(sc.nextInt)
    st.push(sc.nextInt)
    while(sc.hasNext) {
      val n = sc.next
      n match {
        case "+" | "-" | "*" => st.push(calc(st.pop, n, st.pop))
        case x => st.push(x.toInt)
      }
    }
    println(st.pop)
  }
}



Measured memory_bytes: 45036
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)
#define REP(i, r) for(int i = (int)0; i < (int)r; ++i)
#define FORD(i, l, r) for(int i = (int)l; i >= (int)r; --i)
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
const int Nmax = 1e5 + 112;
const int inf = 2e9 + 112;

int n, mxl, mnr = inf, mn[Nmax], ans;
ii a[Nmax];

int main() {
    ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    cin >> n;
    FOR(i, 1, n) {
        cin >> a[i].X >> a[i].Y;
        ans = max(ans, a[i].Y - a[i].X + 1);
        mxl = max(mxl, a[i].X);
        mnr = min(mnr, a[i].Y);
    }
    ans += max(mnr - mxl + 1, 0);
    sort(a + 1, a + n + 1);
    mn[n] = a[n].Y;
    FORD(i, n - 1, 1) {
        mn[i] = min(mn[i + 1], a[i].Y);
    }
    FOR(i, 1, n - 1) {
        int tmp = max(mnr - a[i].X + 1, 0) + max(mn[i + 1] - mxl + 1, 0);
        ans = max(ans, tmp);
    }
    cout << ans;
}


Measured memory_bytes: 1408
#include <cstdio>

using namespace std;
void swap(int *xp, int *yp)  
{  
    int temp = *xp;  
    *xp = *yp;  
    *yp = temp;  
}  

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int a[n];
    for(int i = 0; i<n; i++){
        scanf("%d", &a[i]);
    }
     int i, j;  
    for (i = 0; i < n-1; i++)      
      
    // Last i elements are already in place  
    for (j = 0; j < n-i-1; j++)  
        if (a[j] > a[j+1])  
            swap(&a[j], &a[j+1]); 
    
    int sum = 0;
    for(i=0; i<n; i++){
        sum+=a[i];
    }
    double t = (double)1/(4*m);
    int count = 0;
    for(int i = n-1; i>=0; i--){
        double temp = (double)a[i]/sum;
        if(temp>=t){
            count +=1;
        }
    }
    
    if(count >= m){
        printf("Yes");
    }
    else{
        printf("No");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	vector<int>B(N - 1);
	REP(i, N - 1) cin >> B[i];
	int out = B[0];
	FOR(i, 1, N - 2) {
		out += min(B[i], B[i - 1]);
	}
	out += B[N - 2];

	cout << out << endl;

	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::min;

#[fastout]
fn main() {
    input! {
    l: usize,
    r: usize
    }
    let mut ans = std::usize::MAX;
    let range = (if r >= l + 2019 {0..=2019} else {l..=r}).collect::<Vec<usize>>();
    for &i in &range {
        for &j in &range {
            if i == j {continue}
            ans = min(i * j % 2019, ans);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2156
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int Q;
int mod = 1e9 + 7;

bool prime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        } else if (i != (n + 1) / 2 && (n + 1) / 2 % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> Q;
    vector<pair<int, int>> range(Q);
    int m = 0;
    for (int i = 0; i < Q; i++) {
        int r;
        cin >> range[i].first >> r;
        range[i].second = r;
        if (r > m) {
            m = r;
        }
    }
    
    vector<int> S(m / 2);
    for (int i = 1; i <= m / 2; i++) {
        if (prime(2 * i + 1)) {
            S[i] = S[i - 1] + 1;
        } else {
            S[i] = S[i - 1];
        }
    }
    
    for (int i = 0; i < Q; i++) {
        cout << S[(range[i].second - 1) / 2] - S[max(range[i].first - 3, 0) / 2] << endl;
    }
}

Measured memory_bytes: 1664
#include <stdio.h>

int main()
{
	char a[21];
	int i,t;
	
	scanf("%s",a);
	for(i=0;;i++){
		if(a[i]=='\0'){
			t=i;break;
		}
	}
	for(i=t-1;i>=0;i--){
		printf("%c",a[i]);
	}
	printf("\n");
	return 0;
}

	

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <bitset>
#include <cmath>
#include <ctime>
#define ff first
#define ss second
#define i1 fgvhdsjklfgh
#define j1 hvfdjsklfkgh
#define MAXN 100005
#define INF 1000000000000000071LL
#define ll long long
#define int long long

using namespace std;

const int mod = 1000000007;
int n, ans, i;

main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("terminator.in", "r", stdin);
    //freopen("terminator.out", "w", stdout);

    cin >> n;

    for(i = 1; i <= n - 1; i++){
        if(i < n - i)
            ans++;
    }

    cout << ans;

    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
int main(){
    string s; cin>>s;
    if(s.size()%2 xor (s[0]==s[s.size()-1]))cout<<"First"<<endl;
    else return puts("Second")*0;
}


Measured memory_bytes: 512
import numpy as np
import sys

input = sys.stdin.readline

A,B = map(int,input().split())

S = input()


res = True
if S.count('-') != 1:
    res = False
else:
    x,y = S.split('-')
    y = y[:-1]
    if len(x) != A or len(y) != B:
        res = False
    else:
        res = (x.isdecimal() and y.isdecimal())

if res:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12492
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

char g[100][100];
int main(){
	IOS;
	ll n, a, b;
	cin >> n >> a >> b;
	vec<ll> x(n);
	REP(i, n)cin >> x[i];
	ll sum = 0;
	REP(i, n - 1){
		sum += min((x[i + 1] - x[i]) * a, b);
	}
	dump(sum);
}

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

const string YES = "Yes";
const string NO = "No";

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A;
  vector<string> B;
  A.resize(N);
  B.resize(M);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }

  bool valid = true;
  for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N - M + 1; j++) {

      for (int a = 0; a < M and valid; a++) {
        for (int b = 0; b < M and valid; b++) {
          valid = B[a][b] == A[a + i][b + j];
        }
      }
      if (valid) {
        cout << "Yes" << endl;
        return 0;
      }
      valid = true;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

void	copy(int H, int W, int c[30][30], int grid[30][30])
{
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j)
			grid[i][j] = c[i][j];
	}
}

void	remove(int h, int w, int grid[30][30])
{
	for (int i = h; i > 0; --i)
		grid[i][w] = grid[i - 1][w];
	grid[0][w] = 0;
}

int	calc_score(int H, int W, int K, int grid[30][30], int score_grid[30][30]) 
{
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j)
			score_grid[i][j] = 0;
	}
	int	score = 0;
	for (int i = 0; i < H; ++i) {
		stack<pair<int, int>>	stk;
		stk.push({0, 1});
		for (int j = 1; j < W; ++j) {
			auto pr = stk.top(); stk.pop();
			if (grid[i][pr.first] == grid[i][j]) {
				pr.second += 1;
				stk.push(pr);
			} else {
				stk.push(pr);
				stk.push({j, 1});
			}
		}
		while (!stk.empty()) {
			auto pr = stk.top(); stk.pop();
			if (pr.second < K) continue;
			for (int j = pr.first; j < pr.first + pr.second; ++j)
				score_grid[i][j] = grid[i][j];
		}
	}
	score = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j)
			score += score_grid[i][j];
	}
	return score;
}

void	update(int H, int W, int grid[30][30], int score_grid[30][30])
{
	for (int j = 0; j < W; ++j) {
		int	top = H - 1;
		for (int i = H - 1; i >= 0; --i) {
			if (grid[i][j] == score_grid[i][j]) continue;
			grid[top][j] = grid[i][j];
			--top;
		}
		for (int i = top; i >= 0; --i)
			grid[i][j] = 0;
	}
}

int	main()
{
	int	c_grid[30][30] = {};
	int	grid[30][30] = {};
	int	score_grid[30][30] = {};
	int	H, W, K;
	cin >> H >> W >> K;
	char	c;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> c;
			c_grid[i][j] = static_cast<int>(c - '0');
		}
	}
	int	max_score = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int score = 0;
			copy(H, W, c_grid, grid);
			remove(i, j, grid);
			int	power = 1;
			int	tmp = 0;
			while ((tmp = calc_score(H, W, K, grid, score_grid)) > 0) {
				score += power * tmp;
				power *= 2;
				update(H, W, grid, score_grid);
			}
			if (max_score < score)
				max_score = score;
		}
	}
	cout << max_score << endl;
}



Measured memory_bytes: 256
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let nq = readInts()
    let (n, q) = (nq[0], nq[1])
    let s = readLine()!.map { String($0) }
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var count = 0
    var aryACIndex = [Int](repeating: 0, count: n)
    for i in 1..<n {
        if s[i - 1] == "A" && s[i] == "C" {
            count += 1
        }
        aryACIndex[i] = count
    }
    
    for _ in 1...q {
        let lr = readInts()
        let (l, r) = (lr[0] - 1, lr[1] - 1)
        
        print(aryACIndex[r] - aryACIndex[l])
    }
}
main()


Measured memory_bytes: 15736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, m;
  cin >> n >> m;
  vl cnt(n);
  ll a, b;
  rep(i, m) {
    cin >> a >> b;
    cnt[a-1]++;
    cnt[b-1]++;
  }

  bool f = 1;
  rep(i, n) {
    f &= !(cnt[i]%2);
  }
  if (f) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

int N, M, X, Y;
int x[100], y[100];

int main() {
    cin >> N >> M >> X >> Y;
    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];

    int max_x = *max_element(x, x + N);
    int min_y = *min_element(y, y + M);

    int left = max(max_x, X);
    int right = min(min_y, Y);

    // printf("max_x: %d,min_y: %d, left: %d, right: %d\n", max_x, min_y, left, right);
    cout << ((right - left) >= 1 ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
//https://abc113.contest.atcoder.jp/tasks/abc113_a
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b/2<<endl;
    return 0;
}

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

int main(void) {
    int N;
    cin >> N;
    vector< int > A(N), B(N), C(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> C[i];
    }
    int score, round;
    score = 0;
    for (int i = 0; i < N; ++i) {
        score += B[A[i] - 1];
        if (i > 0 && A[i] == A[i - 1] + 1) {
            score += C[A[i - 1] - 1];
        }
    }
    printf("%d\n", score);

    return 0;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(N, A));
    }

    /**
     * 方針1: 広義単調行列の分け方の最小値
     * http://kmjp.hatenablog.jp/entry/2019/07/20/0900
     * https://atcoder.jp/contests/abc134/submissions/6458571
     * @param N
     * @param A
     * @return
     */
    private static int solve(int N, int[] A) {
        int count = 0;

        TreeMap<Integer, Integer> map = new TreeMap();
        for (int i=0; i<N; i++) {
            Map.Entry<Integer, Integer> entry = map.lowerEntry(A[i]);
            int value = 0;

            if (entry == null) {
            } else {
                value = entry.getValue();
                if (entry.getValue() == 1) {
                    map.remove(entry.getKey());
                } else {
                    map.put(entry.getKey(), entry.getValue()-1);
                }
            }

            map.merge(A[i], 1, Integer::sum);
        }

        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            count += entry.getValue();
        }

        return count;
    }
}

Measured memory_bytes: 56508
// ABC172-E
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


vector<ll> fact(500020);
vector<ll> invfact(500020);
ll modpow(ll x,ll y,ll mod){ //x^y
    if(y==0) return 1;
    if(y==1) return x%mod;
    if(y%2==1) return x*modpow(x,y-1,mod)%mod;
    ll t=modpow(x,y/2,mod);
    return (t*t)%mod;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll n,m;
    ll mod=1000000007;
    cin>>n>>m;
    fact[0]=1;
    for(int i=1;i<=500010;i++){
        fact[i]=fact[i-1]*i%mod;
    }
    invfact[500010]=modpow(fact[500010],mod-2,mod);
    for(int i=500009;i>=0;i=i-1){
        invfact[i]=invfact[i+1]*(i+1)%mod;
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        ll cur=1;
        if(i%2==1) cur=-1;
        cur=cur*fact[n]*invfact[i]%mod;
        if(cur<0) cur+=mod;
        cur=cur*invfact[n-i]%mod;
        cur=cur*fact[m]%mod;
        cur=cur*invfact[m-i]%mod;
        ll nijo=fact[m-i]*invfact[(m-i)-(n-i)]%mod;
        nijo=modpow(nijo,2,mod);
        cur=cur*nijo%mod;
        ans+=cur;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11028
S = input()

num = len(S)//2
ans = []

if len(S) % 2!=0:
    num += 1
    for i in range(num):
        nn = 2*i
        ans.append(S[nn])
else:
    for i in range(num):
        nn = 2*i
        ans.append(S[nn])
        
        
print("".join(ans))

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<Int> p(A), q(B), r(C);
	for (int i = 0; i < A; ++i) { cin >> p[i]; }
	for (int i = 0; i < B; ++i) { cin >> q[i]; }
	for (int i = 0; i < C; ++i) { cin >> r[i]; }

	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());

	priority_queue<Int, vector<Int>, greater<Int>> que;
	Int sum = 0;
	for (int i = 0; i < X; ++i) {
		que.push(p[i]);
		sum += p[i];
	}
	for (int i = 0; i < Y; ++i) {
		que.push(q[i]);
		sum += q[i];
	}

	Int ans = sum;
	for (int i = 0; i < C; ++i) {
		que.push(r[i]);
		sum += r[i];
		sum -= que.top();
		que.pop();
		ans = max(ans, sum);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4724