akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        // ACになった数字をいれておくやつ
        Set<Integer> collectSet = new HashSet<>();

        // penaltyの番号、カウント
        Map<Integer, Integer> penaltyMap = new HashMap<>();

        for (int i = 0; i < m; i++) {
            int p = sc.nextInt();
            String s = sc.next();

            if ("AC".equals(s)) {
                collectSet.add(p);
            } else if (!collectSet.contains(p)) {
                int value = penaltyMap.getOrDefault(p, 0);
                penaltyMap.put(p, value + 1);
            }
        }

        int penaltyCount = 0;
        for (int num : collectSet) {
            penaltyCount += penaltyMap.getOrDefault(num, 0);
        }

        System.out.println(collectSet.size() + " " + penaltyCount);
    }

}

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

int main() {
  int N,h[100];
  cin>>N;
  for (int i(0);i<N;i++) cin>>h[i];
  int cnt(0);
  for (int hi(100);hi>0;hi--){
    int seq(0);
    for (int i(0);i<N;i++) {
      if (h[i]>=hi&&seq==0){
        // cout << h[i]<<" ";
        cnt+=1;
        seq=1;
      }else if(h[i]<hi){
        seq=0;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
let () =
    let input = read_int() in

    let h = input / 60 / 60 in
    let m = (input - h * 60 * 60) / 60 in
    let s = (input - h * 60 * 60) - (m * 60) in

    Printf.printf "%d:%d:%d\n" h m s;


Measured memory_bytes: 2344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
  ll n;
  cin>>n;
  vector<ll>d(n);
  rep(i,n){
    cin>>d[i];
  if((i>0&&d[i]==0)||d[0]!=0){
    cout<<0;
    return 0;
  }
  }
  vector<ll>s(n);
  rep(i,n){
   s[d[i]]++;
  }
  ll ans=1,mod=998244353;
  for(int i=1;i<n;i++){
    for(int j=0;j<s[i];j++)ans=ans*s[i-1]%mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

H,W = splitintinput()

if H == 1 or W == 1:
    print(1)
    exit()
if H % 2 == 0:
    print(int(H*W/2))
else:
    print(int((H-1)*W/2 + math.ceil(W/2)))

Measured memory_bytes: 22680
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main() 
{
    int a[3][3]={0},i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    int b[n],k=0;
    for(i=0;i<n;i++)cin>>b[i];
    for(k=0;k<n;k++)
    {
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
         if(b[k]==a[i][j])a[i][j]=1;   
        }
    }
    }
    int c,f=0,f1=0;
    if((a[0][0]==1&&a[1][1]==1&&a[2][2]==1)||(a[0][2]==1&&a[1][1]==1&&a[2][0]==1))cout<<"Yes";
    else
    {
    for(i=0;i<3;i++)
    {   c=0;
        for(j=0;j<3;j++)
        {
        if(a[i][j]==1)c++;
        }if(c==3){f=1;break;}
    }
    if(f==0)
    {
    for(i=0;i<3;i++)
    {   c=0;
        for(j=0;j<3;j++)
        {
        if(a[j][i]==1)c++;
        }
        if(c==3){f1=1;break;}
    }
    }
    if(f==1||f1==1)cout<<"Yes";
    else
    cout<<"No";
    }
}

   
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 1005;
const int maxm = 100;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
int n,m,a[maxn],st[maxn],dp[maxn][1<<12];
void print(int x){
	vector<int>ans;
	FOR(i,0,n)if((1<<i)&x)ans.push_back(1);else ans.push_back(0);
	ROF(i,ans.size()-1,0)printf("%d",ans[i]);
	printf("\n");
}
int dfs(int cur,int sta){
	if(cur==m)return sta==((1<<n)-1)?0:inf/2;
	int &ans=dp[cur][sta];
	if(ans<inf/4)return ans;
	if((sta|st[cur+1])!=sta){
		ans=min(ans,dfs(cur+1,sta|st[cur+1])+a[cur+1]); 
	}
	ans=min(ans,dfs(cur+1,sta));
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,m+1){
		int k;
		scanf("%d%d",&a[i],&k);
		while(k--){
			int u;
			scanf("%d",&u);
			st[i]|=(1<<(u-1));
		}
	}
	memset(dp,0x3f,sizeof(dp));
	dp[m][(1<<n)-1]=0;
	ROF(i,m-1,0)
	FOR(j,0,1<<n){
		if((j|st[i+1])!=j){
			dp[i][j]=min(dp[i][j],dp[i+1][j|st[i+1]]+a[i+1]);
		}
		dp[i][j]=min(dp[i][j],dp[i+1][j]);
	}
	int ans=dp[0][0];
	if(ans>=inf/4)ans=-1;
	printf("%d\n",ans);
}

Measured memory_bytes: 19724
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+1;
vector<vector<ll>> dp(101,vector<ll> (N,0));
int main(){
    ll n,sum;
    cin>>n>>sum;
    vector<ll> w(n+1,0),val(n+1,0);
    for(ll i=1;i<=n;i++)cin>>w[i]>>val[i];
    if(w[1]<=sum)dp[1][w[1]]=val[1];
    for(ll i=2;i<=n;i++){
        
        
        for(ll j=1;j<=sum;j++){
            dp[i][j]=dp[i-1][j];
            if(w[i]<=j)dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+val[i]);
        }
        
    }
    ll ans=0;
    for(ll i=1;i<=sum;i++)ans=max(ans,dp[n][i]);
    cout<<ans<<"\n";
    

}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
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 = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for(int i = 0; i < n; ++i) {
            par[i] = i; rank[i] = 0; diff_weight[i] = SUM_UNITY;
        }
    }

    int find(int x) {
        if(par[x] == x) return x;
        else {
            int r = find(par[x]);
            diff_weight[x] += diff_weight[par[x]];  // 累積和を取る
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        find(x);
        return diff_weight[x];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    bool unite(int x, int y, Abel w) {
        w += weight(x); w -= weight(y); // xとyそれぞれについて、rootとの重み差分を補正
        x = find(x); y = find(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y), w = -w;   // rank[x] >= rank[y]になるようにswap
        if(rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w; // xがyの親になるので、xとyの差分をdiff_weight[y]に記録
        return true;
    }

    // 重みを取得する
    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int n;

int xcalc(string z) {
    int zlen = z.length();
    int zfin = zlen - 3;
    string subz = z.substr(3, zfin);
    int ret = 0;
    if(subz.at(0) == '-') {
        subz.at(0) = '0';
        ret = stoi(subz);
        ret = -ret;
    }else {
        ret = stoi(subz);
    }
    return ret;
}

int main() {
    while(1) {
        cin >> n;
        if(n == 0) break;
        UnionFind<ll> uf(200);
        bool flg = true;
        map<string, int> mdata;
        int cnt = 0;
        for(int i = 0; i < n; ++i) {
            int one;
            string A, eq, x, B;
            cin >> one >> A >> eq >> x >> B;
            if(mdata[A] == 0) {
                mdata[A] = cnt+1; cnt++;
            }
            if(mdata[B] == 0) {
                mdata[B] = cnt+1; cnt++;
            }

            int ch = xcalc(x);
            if(uf.same(mdata[A]-1, mdata[B]-1)) {
                // もし繋がっていたら
                if(uf.diff(mdata[A]-1, mdata[B]-1) != ch) flg = false;
            }else {
                // 繋がっていなかったら
                uf.unite(mdata[A]-1, mdata[B]-1, ch);
            }
        }

        if(flg) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 3116
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if(abs(x-a) > abs(x-b)){
		cout << "B" << endl;
	}else{
		cout << "A" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V, string sep = " ", string end_ = "endl") {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << sep;
    }
    if(end_ == "endl")
        cout << endl;
    else
        cout << end_;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    ll ans = 0, l, u;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(all(A));
    sort(all(C));
    for(auto b : B) {
        l = lower_bound(all(A), b) - A.begin();
        u = C.end() - upper_bound(all(C), b);
        ans += l * u;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
import itertools

n = int(input())
m, a, r, c, h = 0, 0, 0, 0, 0

for _ in range(n):
    s = input()
    if s[0] == "M":
        m += 1
    if s[0] == "A":
        a += 1
    if s[0] == "R":
        r += 1
    if s[0] == "C":
        c += 1
    if s[0] == "H":
        h += 1

ans = 0

for a1, a2, a3 in itertools.combinations([m, a, r, c, h], 3):
    ans += (a1*a2*a3)

print(ans)


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

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

Measured memory_bytes: 512
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int dp[200010];
VI v[26];
signed main(void)
{
  string s;
  cin >> s;
  const int n = s.size();

  int k = 1, m = 26;
  bool used[m] = {};
  dp[n] = 1;
  for(int i=n-1; i>=0; --i) {
    used[s[i]-'a'] = true;
    bool res = true;
    REP(j, m) res &= used[j];
    if(res) {
      k++;
      memset(used, false, sizeof(used));
    }
    dp[i] = k;
    // cout << i << " " << k << endl;
    v[s[i]-'a'].PB(i);
  }
  REP(i, m) {
    sort(ALL(v[i]));
    // for(int j: v[i]) cout << j << " "; cout << endl;
    // if(v[i].size() == 0) {
    //   cout << (char)(i+'a') << endl;
    //   return 0;
    // }
  }

  int idx = 0;
  string ans = "";
  while(k>0) {
    // cout << "k:" << k << " idx:" << idx << endl;
    if(k == 1) {
      REP(i, 26) {
        if(lower_bound(ALL(v[i]), idx) == v[i].end()) {
          ans += (char)(i+'a');
          break;
        }
      }
      break;
    }
    REP(i, m) {
      // next(idx, 'a' + i)
      int nxt = *lower_bound(ALL(v[i]), idx);
      // cout << i << " " << nxt << endl;
      // 'a'+i は使用できる文字
      if(lower_bound(ALL(v[i]), idx) != v[i].end()
        && dp[idx] == dp[nxt+1]+1) {
        ans += (char)(i+'a');
        idx = nxt+1;
        k--;
        break;
      }
    }
    // cout << ans << endl;
  }

  cout << ans << endl;

  return 0;
}


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

#define N 100
#define INF 100000001

#define min(a, b) ((a) < (b) ? (a) : (b))

int main(){
  int i, l, j, k, n, p[N + 1], m[N + 1][N + 1];
  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    scanf("%d %d",&p[i - 1],&p[i]);
  }

  for(i = 1; i <= n; i++) m[i][i] = 0;
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      j = i+l-1;
      m[i][j] = INF;
      
      for(k = i; k <= j - 1; k++){
	m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
    printf("%d\n",m[1][n]);
  return 0;
}



Measured memory_bytes: 2148
#include<stdio.h>
#include<string.h>

int main(){
	char input[1024],word[32],word2[32],c_word[128],*p;
	char s_al[]="abcdefghijklmnopqrstuvwxyz",b_al[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int i,j,count=0,size;
	
	fgets(word,sizeof word,stdin);
	sprintf(word2,"%s",word);
	size=strlen(word2);
	
	for(i=0;i<size;i++){
		for(j=0;j<26;j++){
			if(word[i]==b_al[j]){
				word[i]=s_al[j];
				word2[i]=s_al[j];
				
			}
			
		}
		
		
	}
	
	word[size-1]='\0';
	
	while(1){
		fgets(input,sizeof input,stdin);
		
		p=strtok(input," ");
		sprintf(c_word,"%s",p);
		//printf("%s\n",c_word);
		size=strlen(c_word);
		
		if(strcmp(c_word,"END_OF_TEXT\n")==0||strcmp(c_word,"END_OF_TEXT\0")==0){
			break;
		}
		for(i=0;i<size;i++){
			for(j=0;j<26;j++){
				if(c_word[i]==b_al[j]){
					c_word[i]=s_al[j];
					
				}
				
			}
			
			
		}
		
		
		if(strcmp(c_word,word)==0||strcmp(c_word,word2)==0){
				count++;
				//printf("%d\n",count);
		}
		
		while(1){
			p=strtok(NULL," ");
			if(p==NULL){
				break;
			}
			sprintf(c_word,"%s",p);
			size=strlen(c_word);
			for(i=0;i<size;i++){
				for(j=0;j<26;j++){
					if(c_word[i]==b_al[j]){
						c_word[i]=s_al[j];
						
					}
					
				}
				
				
			}
			//printf("%s\n",c_word);
			if(strcmp(c_word,word)==0||strcmp(c_word,word2)==0){
				count++;
				//printf("%d\n",count);
			}
		}
	}
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = n / (a + b) * a;
  ans += min(n % (a + b), a);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int A,B;
	scanf("%d %d",&A,&B);
	if(A==1){
		A=14;
	}
	if(B==1){
    	B=14;
	}
	if(A>B){
    	printf("Alice");
    }
	else if(A<B){
    	printf("Bob");
    }
	else{
    	printf("Draw");
    }
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, M, Q = LI()
ABCD = LRI(Q)

def calc(A):
    ret = 0

    for a, b, c, d in ABCD:
        if A[b] - A[a] == c:
            ret += d
    
    return ret

ans = 0
def dfs(A):
    global ans
    
    if len(A) == N+1:
        ans = max(ans, calc(A))
        return
    
    back = A[-1]
    while back <= M:
        dfs(A + [back])
        back += 1

dfs([1])

print(ans)


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

int main(){
    ll N; cin >> N;
    vector<ll> v(5);
    for(int i = 0; i < 5; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    if(N % v[0] == 0){
        ans += N / v[0];
    }else{
        ans += N / v[0] + 1;
    }
    ans += 4;
    cout << ans << endl;
}

Measured memory_bytes: 384
from collections import Counter as c
n = int(input())
a = list(map(int,input().split()))
a.sort()

count, a_max = 0, a[-1]
li = [True] * (a_max+1)

for i in a:
  if li[i] == "x":
    count -= 1
    li[i] = "y"

  if li[i] == True:
    count += 1
    li[i] = "x"

  j = 2
  while i * j <= a_max:
    li[i*j] = False
    j += 1

print(count)

Measured memory_bytes: 118900
N=int(input())
a=list(map(int,input().split()))

sum = 0
for n in range(N-1):
	if a[n]>a[n+1]:
		dif=a[n]-a[n+1]
		a[n+1]=a[n+1]+dif
		sum=sum+dif
print(sum)

Measured memory_bytes: 32232
#include<iostream>
#include<cmath>
using namespace std;
static const int MAX_N = 100000;
static const int MOD = 100000;

int n, m;
int s[MAX_N];

int main(){
	cin >> n >> m;
	s[0] = 0;
	for(int i = 1; i < n; i++){
		cin >> s[i];
		s[i] += s[i - 1];
	}
	int cur = 0;
	int ans = 0;
	for(int i = 0; i < m; i++){
		int a;
		cin >> a;
		int prev = cur;
		cur += a;
		ans += abs(s[cur] - s[prev]);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n, m, x, y; cin >> n >> m >> x >> y;
    V<int> vx(n);
    for(int i = 0; i < n; i++) cin >> vx[i];
    V<int> vy(m);
    for(int i = 0; i < m; i++) cin >> vy[i];
    sort(ALL(vx));
    sort(ALL(vy));
    if(x < vx[n - 1] && vy[0] <= y && vx[n - 1] < vy[0]){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }



    return 0;
}


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

int main() {
    int n;
    cin >> n;
    ll num, ans = 1;
    while(n--) {
        cin >> num;
        ans = ans / __gcd(ans, num) * num;
    }
    cout << ans << endl;

    return 0;
}

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

namespace ACB61A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a <= c && c <= b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadKey();
        }
    }
}


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

int main() {
  int N, a;
  cin >> N;
  unordered_set<int> tier;
  for (int i=0; i<N; i++) {
    cin >> a;
    tier.insert(a);
  }
  cout << tier.size() << endl;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  cout << ((abs(a-c) <= d) || (abs(a-b) <= d && abs(c-b) <= d) ? "Yes" : "No") << endl;
}


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

int main()
{
    string str;

    while( cin >> str )
    {
        if( str == "0000" )
            break;
        if( str[0] == str[1] && str[2] == str[3] && str[0] == str[2] )
            cout << "NA" << endl;
        else
        {
            int cnt = 0;
            while( str != "6174" )
            {
                for( int i = 0; i < 4; i++ )
                {
                    for( int j = 3; j >= i + 1; j-- )
                    {
                        if( str[j] < str[j-1] )
                        {
                            char temp = str[j];
                            str[j] = str[j-1];
                            str[j-1] = temp;
                        }
                    }
                }

                int l = 0, r = 0, d = 1;
                for( int i = 0; i < 4; i++ )
                {
                    l += ( str[i] - '0' ) * d;
                    r += ( str[3-i] - '0' ) * d;
                    d *= 10;
                }

                l -= r;
                d = 1000;
                for( int i = 0; i < 4; i++ )
                {
                    str[i] = ( l / d ) % 10 + '0';
                    d /= 10;
                }
                cnt++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 1000;
int N, K;
ll a[MAX_N+1];
ll sum[MAX_N+1];
bool used[MAX_N*(MAX_N+1)/2];

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

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

  for (int i = 1; i <= N; ++i) sum[i] = sum[i-1] + a[i];

  vector<ll> vec;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < i; ++j) {
      vec.push_back(sum[i]-sum[j]);
    }
  }

  sort(all(vec));
  reverse(all(vec));

  ll ma = vec[0], ans = 0;
  int bitsize = 0;
  while ((1ll<<bitsize) <= ma) ++bitsize;
  memset(used, true, sizeof(used));

  for (int i = bitsize-1; i >= 0; --i) {
    int k = 0;
    vector<int> unused;
    for (int j = 0; j < vec.size(); ++j) {
      if (used[j] && (vec[j]>>i) & 1) {
        ++k;
      } else {
        if (used[j]) unused.push_back(j);
      }
    }

    if (K <= k) {
      ans += (1ll<<i);
      for (int j = 0; j < unused.size(); ++j) used[unused[j]] = false;
    }

  }


  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 8428
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader =
            new BufferedReader(new InputStreamReader(System.in));

        String line = reader.readLine();
        int x = Integer.parseInt(line);
        int answer = (int) Math.pow(x, 3);
        System.out.println(answer);
    }
}

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

typedef long long ll;
typedef pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	int a, b, c; cin >> a >> b >> c;
	int ans = 0;
	int m = max(a, max(b, c));
	ans += (m-a)/2 + (m-b)/2 + (m-c)/2;
	a += ((m-a)/2) * 2;
	b += ((m-b)/2) * 2;
	c += ((m-c)/2) * 2;
	m = min(a, min(b, c));
	ans += a + b + c - m * 3;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) ((x)&(-x))
#define X first
#define Y second
#define lc o<<1
#define rc o<<1|1
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100000+10;
const int maxm = 2000+10;
const int mod = 1e9+7;
const double eps = 1e-8;
int main() {
#ifdef local
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int a,b; cin>>a>>b;
    int ans=0,sum=1;
    for (;sum<b;sum+=a-1) ans++;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    std::vector<int> v;
    //v.resize(n);
    REP(i,n){
        int a;cin>>a;
        v.push_back(a);
    }

        int j = 0 ,count = 0 , i = 1;
        while (j<n){
            if(v[j] == i){
                i++;
            }
            else{
                count++;
            }
            j++;
        }
        if(count == n){
            cout<<"-1";

        }
        else{
            cout<<count;
        }
   return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	string s;cin>>s;
	rep(i,8){
		if(s.substr(0,i)+s.substr(len(s)-(7-i))=="keyence"){
			cout<<"YES\n";return 0;
		}
	}
	cout<<"NO\n";
}


Measured memory_bytes: 3600
import math

def main():
    data = list(input())
    pre = data[0]
    ans = len(data)
    for i in range(1, len(data)):
        if pre != data[i]:
            ans = min(ans, max(i, len(data) - i))
            pre = data[i]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 49648
#include <iostream>
#include <vector>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator& itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

template<class T> inline T at(const vector<T> &v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

template<class T> inline bool is_max(T &a, const T &b) {return a < b ? a = b, true : false;}
template<class T> inline bool is_min(T &a, const T &b) {return a > b ? a = b, true : false;}

int main() {
  while (true) {
    int n, res = 0;
    cin >> n;
    if (n == 0) break;
    string f, p;
    for (int i : range(n)) {
      p = f;
      cin >> f;
      if (f[0] != p[0] && f[1] == p[1]) ++res;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <unordered_set>
#include <map>

using namespace std;

int find_root(vector<int> &roots, int i){
  if (roots[i] == i) return i;
  else {
    int tmp = find_root(roots, roots[i]);
    roots[i] = tmp;
    return tmp;
  }
}

int main(){
  int N, M, K, t1, t2;
  cin >> N >> M >> K;
  vector<int> roots;
  vector<unordered_set<int>> block_rel;
  vector<unordered_set<int>> rel;
  for (int i=0; i<N; i++){
    roots.push_back(i);
    block_rel.emplace_back(unordered_set<int>());
    rel.emplace_back(unordered_set<int>());
  }
  vector<int> red(N, 0);
  for (int i=0; i<M; i++){
    cin >> t1 >> t2;
    red[t1 - 1]++;
    red[t2 - 1]++;
    int r1 = find_root(roots, t1 - 1);
    int r2 = find_root(roots, t2 - 1);
    rel[t1 - 1].insert(t2 - 1);
    rel[t2 - 1].insert(t1 - 1);
    if (r1 != r2){
      roots[r1] = r2;
    }
  }
  for (int i=0; i<N; i++){
    roots[i] = find_root(roots, i);
  }
  for (int i=0; i<N; i++){
    cerr << roots[i] << " ";
  }
  cerr << endl;
  
  for (int i=0; i<N; i++){
    cerr << red[i] << " ";
  }
  
  for (int i=0; i<K; i++){
    cin >> t1 >> t2;
    if (roots[t1 - 1] == roots[t2 - 1] && rel[t1 - 1].find(t2 - 1) == rel[t1 - 1].end()){
      red[t1 - 1]++;
      red[t2 - 1]++;
    }
  }
  
  map<int, int> sizes;
  for (int i=0; i<N; i++){
    sizes[roots[i]]++;
  }
  for (int i=0; i<N; i++){
    cout << max(sizes[roots[i]] - red[i] - 1, 0) << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 27148
/**
 *    author:  zjsdut
 *    created: 2020/03/23 10:46:01
 **/
#include <bits/stdc++.h>

using namespace std;

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

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define TOKENPASTE(x, y) x##y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define rep(n)                                                                 \
  for (int TOKENPASTE2(_iter_, __LINE__) = 0,                                  \
                               TOKENPASTE2(_num_, __LINE__) = (int)(n);        \
       TOKENPASTE2(_iter_, __LINE__) < TOKENPASTE2(_num_, __LINE__);           \
       ++TOKENPASTE2(_iter_, __LINE__))
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL && !defined DUIPAI
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  string s;
  scan(s);
  string t = s;
  reverse(all(t));
  if (s != t) {
    println("No");
    return 0;
  }
  t = s.substr((SZ(s) + 1) / 2);
  string tt = t;
  reverse(all(tt));
  if (t != tt) {
    return println("No"), 0;
  }
  println("Yes");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a[50];
	int n,w;
	int x,y;
	int dummy;
	while(scanf("%d", &n) != EOF){
		scanf("%d", &w);
		for(int i = 1; i <= n; i++){
			a[i] = i;
		}
		for(int i = 0; i < w; i++){
			scanf("%d,%d", &x, &y);
			dummy = a[y];
			a[y] = a[x];
			a[x] = dummy;
		}
		for(int i = 1; i <= n; i++){
			printf("%d\n", a[i]);
		}
	}
	return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

template <int n>
class SegTree{
public:
	vector<int> val;
	
	SegTree(){
		val.resize(2*n, inf);
	}

	int getval(int i){
		i += n;
		int res = val[i];
		while(i > 1){
			i >>= 1;
			chmin(res, val[i]);
		}
		return res;
	}

	void update(int x, int y, int v, int l=0, int r=n, int k=1){
		if(l >= r) return;
		if(x <= l and r <= y){
			chmin(val[k], v);
		}
		else if(l < y and x < r){
			int m = (l+r)/2;
			update(x, y, v, l, m, k*2);
			update(x, y, v, m, r, k*2+1);
		}
	}

	void print(){
		rep(i, 0, 30){
			cout << val[i+n] << " ";
		}
		cout << endl;
	}
};

signed main(){
	int n, q;
	cin >> n >> q;	

	vi s(n), t(n), x(n);
	rep(i, 0, n) cin >> s[i] >> t[i] >> x[i];

	vi d(q);
	rep(i, 0, q) cin >> d[i];

	vi c;
	c.pb(inf);
	c.pb(-inf);
	rep(i, 0, n){
		c.pb(s[i]-x[i]);
		c.pb(t[i]-x[i]);
	}
	rep(i, 0, q){
		c.pb(d[i]);
	}

	sort(all(c));
	c.erase(unique(all(c)), c.end());

	SegTree<1<<20> st;
	rep(i, 0, n){
		int a = lower_bound(all(c), s[i]-x[i]) - c.begin();
		int b = lower_bound(all(c), t[i]-x[i]) - c.begin();
		st.update(a, b, x[i]);
	}

	rep(i, 0, q){
		int a = lower_bound(all(c), d[i]) - c.begin();
		int ans = st.getval(a);
		if(ans >= inf) cout << -1 << endl;
		else cout << ans << endl;
	}

	return 0;
}


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

int main(){
 int n;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    a--;
    A[a]=i+1;
  }
  for(int i=0;i<n;i++){
    cout<<A[i]<<" ";
  }
  cout<<endl;
}
    

Measured memory_bytes: 1152
import java.util.Arrays;
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;


	static long pow=1000000007;




	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N =sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N];
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		int[] dp = new int[N];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for(int i= 0;i < N;i++){
			for(int j = i+1;j < N;j++){
				if(j == i+K+1){
					break;
				}
				dp[j] = Math.min(dp[j], dp[i]+ Math.abs(h[i]-h[j]));
			}
		}
		System.out.println(dp[N-1]);

	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 50580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

int main() {
    ll n;
    bool is_even;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    if(n%2==0)
        is_even = true;
    else
        is_even = false;
    ll cnt_odd = 0,  cnt_4 = 0;

    for(int i=0;i<n;i++) {
        if(a[i] % 2 ==1)
            cnt_odd++;
        else if(a[i] % 4 == 0)
            cnt_4++;
    }
    string ans;
    if(!is_even && cnt_odd == (n/2+1)) {
        if(cnt_odd <= cnt_4+1)
            ans = "Yes";
        else
            ans = "No";
    } else {
        if(cnt_odd <= cnt_4)
            ans = "Yes";
        else
            ans = "No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if(a>0) puts("Positive");
	else if(b>=0&&a<=0) puts("Zero");
	else if((b-a)&1) puts("Positive");
	else puts("Negative");
}

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=2e5+50;
int n;
LL X, ans=0x3f3f3f3f3f3f3f3f, a[N], s[N];
int main() {
	n=rd(); X=rd();
	for(int i=1;i<=n;i++) s[i]=(a[i]=rd())+s[i-1];
	for(int k=1;k<=n;++k) {
		LL sum=0;
		for(int j=1,l,r=n;r && sum+k*X<ans;++j, r=l-1) {
			l=max(r-k+1,1);
			sum+=(j==1 ? 5 : 2*j+1)*(s[r]-s[l-1]);
		} ans=min(ans,sum+k*X);
	}
	cout<<ans+n*X<<'\n';
}

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

int main(){
  int N; cin >> N;
  vector<int> h(N);
  for(int i = 0;i < N;i++)cin >> h[i];

  int ans = 0;
  int active = 0;
  for(int i = 0;i < N;i++){
    if(active >= h[i]){
      active = h[i];
    }
    else{
      ans += h[i] - active;
      active = h[i];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,m,gakusei[51][3],point[51][3],s,t=200000001,num,i,j;

	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
		for(j=0;j<2;j++)
			scanf("%d",&gakusei[i][j]);
	for(i=0;i<m;i++)
		for(j=0;j<2;j++)
			scanf("%d",&point[i][j]);

	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			s=abs(gakusei[i][0]-point[j][0])+abs(gakusei[i][1]-point[j][1]);
			if(t>s){
				t=s;
				num=j;
			}
		}
		printf("%d\n",num+1);
		t=200000001;
	}
	return 0;
}

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

int n, m;
int a[1000], b[1000], d[1000];
int dp[1001][4096];
const int INF = (1 << 30) - 1;

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

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

		d[i] = 0;

		for (int j = 0; j < b[i]; j++) {
			int c;

			cin >> c;
			d[i] += (1 << (c - 1));
		}
	}

	for(int i = 0; i < m; i++)
		dp[i][0] = 0;

	int w = 1 << n;

	for (int j = 1; j < w; j++) {
		if ((j & d[0]) == j)
			dp[0][j] = a[0];
		else
			dp[0][j] = INF;
	}

	for (int i = 1; i < m; i++) {
		for (int j = 1; j < w; j++) {
			int jd = j - (j & d[i]);
			dp[i][j] = min(dp[i - 1][j], dp[i - 1][jd] + a[i]);
		}
	}

	if (dp[m - 1][w - 1] == INF)
		cout << -1 << endl;
	else
		cout << dp[m - 1][w - 1] << endl;

	return 0;
}


Measured memory_bytes: 16256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: u64,
    }
    println!(
        "{}",
        if n % 2 == 1 {
            0
        } else {
            let mut ans: u64 = 0;
            let m = n / 2;
            let mut i = 1;
            while 5u64.pow(i) <= m {
                ans += m / 5u64.pow(i);
                i += 1;
            }
            ans
        }
    );
}


Measured memory_bytes: 2192
#include<cstdio>
#include<algorithm>

#define	rep(i,n)	for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int T;	scanf("%d",&T);
	while(T--){
		int n,Ea[80];	scanf("%d",&n);
		rep(i,n)	scanf("%d",Ea+i);

		int dp[80][161]={};	dp[0][0]=Ea[0];
		for(int i=1;i<n;i++)rep(s,161){
			int b=dp[i-1][s];
			dp[i][b]=max(dp[i][b],Ea[i]);
			if(b>0){
				dp[i][b-1]=max(dp[i][b-1],Ea[i]+s);
			}
		}

		printf("%d\n",*max_element(dp[n-1],dp[n-1]+161));
	}

	return 0;
}

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

using namespace std;

int n,x,y,z,now,ans,a[120000],cnt[16],f[1<<15];
vector<int> vec;

int main(){
	scanf("%d",&n);
	for (int i=1;i<n;++i){
		scanf("%d%d%d",&x,&y,&z);
		a[x]^=z; a[y]^=z;
	}
	for (int i=0;i<n;++i) ++cnt[a[i]];
	for (int i=1;i<=15;++i){
		ans+=cnt[i]/2;
		cnt[i]%=2;
		now|=cnt[i]<<(i-1);
	}
	memset(f,-1,sizeof f);
	f[now]=ans; vec.push_back(now);
	for (int i=0;i<(int)vec.size();++i){
		int S=vec[i];
		for (int j1=1;j1<=15;++j1)
			if (1<<(j1-1)&S){
				for (int j2=j1+1;j2<=15;++j2)
					if (1<<(j2-1)&S){
						for (int k=1;k<=15;++k){
							int t1=j1^k,t2=j2^k,T=S,tmp=1;
							T^=1<<(j1-1); T^=1<<(j2-1);
							if (1<<(t1-1)&T) ++tmp;
							if (1<<(t2-1)&T) ++tmp;
							if (t1) T^=1<<(t1-1); if (t2) T^=1<<(t2-1);
							if (f[T]==-1||f[S]+tmp<f[T]){
								f[T]=f[S]+tmp;
								vec.push_back(T);
							}
						}
					}
			}
	}
	printf("%d\n",f[0]);
	
	return 0;
}
			

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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
#define s second
#define db long double
#define pb push_back
#define sz(c) (int)(c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , ll> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <iii> viii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;


const int mod = 998244353;
//const db eps = 1e-13;
const ll oo = 1e18;
const int MAX = 1e6+6;
// basic operations
int mul( int a , int b ) {
    return (1ll*a*b)%mod;
}
int add( int a , int b ) {
    return (a+b)%mod;
}
int sub( int a , int b ) {
    return (a-b+mod)%mod;
}
void addSelf( int& a, int b, int m ) {
    a += b;
    b %= m;
}

int exp( int a, int b ) {

    int res = 1;
    while( b ) {

        if ( b % 2 ) {
            res = mul( res, a );
        }
        a = mul(a, a);
        b >>= 1;

    }
    return res;
}

//ll gcd[500005][20], A[500005], N, Q, a, b, r;
//void process2() {
//        int i, j;
//        for (i = 0; i < N; i++)
//                gcd[i][0] = i;
//        for (j = 1; 1 << j <= N; j++)
//                for (i = 0; i + (1 << j) - 1 < N; i++)
//                        gcd[i][j] = __gcd(gcd[i][j - 1], gcd[i + (1 << (j - 1))][j - 1]);
//}
//int RMQ(int a, int b) {
//        int k = (int) log2(b - a + 1);
//        return __gcd(gcd[a][k], gcd[b - (1 << k) + 1][k]);
//}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int A, B;
    cin>>A>>B;
    for( int i = 0; i <= 1000000; i++ ) {

        if( (int)(0.08*i) == A && (int)(0.10*i) == B ) {
            cout<<i<<"\n";
            return 0;
        }

    }
    cout<<"-1\n";


}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
double x[210];
double y[210];
double ABS(double a){return max(a,-a);}
double EPS=1e-9;
double PI=acos(-1.0);
double th[210];
int main(){
	int w,h,a;
	while(scanf("%d%d%d",&w,&h,&a),a){
		for(int i=0;i<2*a;i++)scanf("%lf%lf",x+i,y+i);
		x[2*a]=w;
		y[2*a]=0;
		x[2*a+1]=w;
		y[2*a+1]=h;
		vector<double>v;
		for(int i=0;i<2*a+2;i++)for(int j=i+1;j<2*a+2;j++){
			if(ABS(x[i]-x[j])<EPS)continue;
			double tmp=y[i]-x[i]*(y[i]-y[j])/(x[i]-x[j]);
			if(tmp<0||tmp>h)continue;
			v.push_back(tmp);
		}
		v.push_back(0);
		v.push_back(h);
		std::sort(v.begin(),v.end());
		double ret=0;
		for(int i=0;i<v.size()-1;i++){
			if(v[i+1]-v[i]<EPS)continue;
			double M=(v[i]+v[i+1])/2;
			for(int j=0;j<2*a+2;j++)th[j]=atan2(y[j]-M,x[j]);
			std::sort(th,th+2*a+2);
			if(th[a]<-PI/2+EPS)th[a]+=EPS;
			if(th[a+1]<-PI/2+EPS)th[a+1]+=EPS;
			if(th[a]>PI/2-EPS)th[a]-=EPS;
			if(th[a+1]>PI/2-EPS)th[a+1]-=EPS;
			
			double L=max(0.0,M+w*tan(th[a]));
			double R=min((double)h,M+w*tan(th[a+1]));
			ret+=max(0.0,R-L)*(v[i+1]-v[i]);
		}
		printf("%.12f\n",ret/h/h);
	}
}

Measured memory_bytes: 1364
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  // printf("Hello World\n") // Your code here!
    int a ,b ;
    cin >> a;  //ｘに読む
    cin >> b;
   
    cout <<a*b;
    cout <<" ";
    cout <<a+a+b+b;
    cout << endl;
}



Measured memory_bytes: 3084