akhauriyash/Code-Regression huggingface dataset:
#define ONSPEED ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define f(i,x,n) for(i=x;i<n;i++)
#define rf(i,x,n) for(i=n;i>x;i--)
#define ll long long
#define GCD(a,b) __gcd(a,b)
#define adios return 0;

/*
SHERAJUL ARIFIN
Dept. of CSE,
IUT.
*/


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

int main()
{
    ONSPEED;
    ll t,n,a=0,b,c,d,s=0,i,j,flag;
    string x,y;
    cin>>x;
    if(x.size()<3)
    {
        cout<<s;
        adios;
    }
    f(i,0,x.size())
    {
        if(x[i]=='A' )
        {
            a++;
        }
        else if(x[i]=='B' and x[i+1]=='C' and i+1<x.size())
            s+=a, i++;
        else a=0;
    }
    cout<<s<<endl;

    adios;
}


Measured memory_bytes: 720
#!/usr/bin/env python3
import sys


def solve(S: str):
    S = list(map(lambda x:int(x), S))
    zeros = len(list(filter(lambda x:x==0, S)))
    ones = len(list(filter(lambda x:x==1, S)))
    print(2*min(zeros, ones))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4980
#include<stdio.h>
#include<string.h>
 
int main()
{
  int N, K,p[200000];
  double max, tmp, p2[200000];
  
  scanf("%d %d", &N, &K);
  
  for(int i=0;i<N;i++)
  {
      scanf("%d", &p[i]);
      p2[i] = (1 + p[i])/2.0;
  }
  
  max=0.0;
  for(int i=0;i<K;i++)
  {
    max += p2[i];
  }
  
  tmp = max;
  for(int i=K;i<N;i++)
  {
	tmp -= p2[i-K];
    tmp += p2[i];
 
    if (tmp > max) max=tmp;
  }
  
  printf("%lf", max);
  
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 43;
const int inf = (signed) (~0u >> 2);

template <typename T>
boolean vmin(T& a, T b) {
  return (a > b) ? (a = b, true) : false;
}

int W, H;
char G[N][N];
int s[N][N];
int dp[N][N][N][N];

int g(int x1, int x2, int y1, int y2) {
  return (x1 > x2 || y1 > y2) ? 0 : (s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1]);
}

int main() {
  scanf("%d%d", &W, &H);
  int px = -1, py = -1;
  for (int i = 1; i <= W; i++) {
    scanf("%s", G[i] + 1);
    for (int j = 1; j <= H; j++) {
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (G[i][j] == '#');
      if (G[i][j] == 'P') {
        px = i, py = j;
      }
    }
  }
  int ans = inf;
  fill(&dp[1][1][1][1], &dp[W][W][H][H], inf);
  dp[1][W][1][H] = 0;
  for (int w = W; w; w--) {
    for (int h = H; h; h--) {
      for (int xl = 1, xr = w; xr <= W; xl++, xr++) {
        for (int yl = 1, yr = h; yr <= H; yl++, yr++) {
          int& v = dp[xl][xr][yl][yr];
          if (v == inf) {
            continue;
          }
          if (xl <= px && px <= xr && yl <= py && py <= yr) {
            // left upper
            for (int x = px; x <= xr; x++) {
              for (int y = py; y <= yr; y++) {
                if ((x ^ xr) || (y ^ yr)) {
                  vmin(dp[xl][x][yl][y], v + g(x + 1, xr, yl, y) + g(xl, x, y + 1, yr));
                }
              }
            }
            // left lower
            for (int x = px; x <= xr; x++) {
              for (int y = yl; y <= py; y++) {
                if ((x ^ xr) || (y ^ yl)) {
                  vmin(dp[xl][x][y][yr], v + g(x + 1, xr, y, yr) + g(xl, x, yl, y - 1));
                }
              }
            }
            // right upper
            for (int x = xl; x <= px; x++) {
              for (int y = py; y <= yr; y++) {
                if ((x ^ xl) || (y ^ yr)) {
                  vmin(dp[x][xr][yl][y], v + g(x, xr, y + 1, yr) + g(xl, x - 1, yl, y));
                }
              }
            }
            // right lower
            for (int x = xl; x <= px; x++) {
              for (int y = yl; y <= py; y++) {
                if ((x ^ xl) || (y ^ yl)) {
                  vmin(dp[x][xr][y][yr], v + g(x, xr, yl, y - 1) + g(xl, x - 1, y, yr));
                }
              }
            }
            vmin(ans, v + g(xl, px, yl, py));
            vmin(ans, v + g(xl, px, py, yr));
            vmin(ans, v + g(px, xr, yl, py));
            vmin(ans, v + g(px, xr, py, yr));
          }
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 12672
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn = 100005;
int N, a[maxn * 3];
ll f[maxn], g[maxn];
priority_queue<int> q;
int main() {
    scanf("%d", &N);
    for(int i = 1; i <= N + N + N; ++i) scanf("%d", a + i);
    
    for(int i = 1; i <= N; ++i) 
	q.push(-a[i]), f[0] += a[i];
    for(int i = 1; i <= N; ++i) {
	if(a[i + N] > -q.top()) {
	    f[i] = f[i - 1] - (-q.top()) + a[i + N];
	    q.pop(), q.push(-a[i + N]);
	} else f[i] = f[i - 1];
    }
    
    while(!q.empty()) q.pop();

    for(int i = 1; i <= N; ++i) 
	q.push(a[i + N + N]), g[0] += a[i + N + N];
    for(int i = 1; i <= N; ++i) {
	int k = N - i + 1;
	if(a[k + N] < q.top()) {
	    g[i] = g[i - 1] - q.top() + a[k + N];
	    q.pop(), q.push(a[k + N]);
	} else g[i] = g[i - 1];
    }
    
    ll ans = -(~0ULL>>1);
    for(int i = 0; i <= N; ++i) ans = max(ans, f[i] - g[N - i]);
    printf("%lld\n", ans);
    return 0;
}


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

int main()
{
  ios::sync_with_stdio(0);
  int n,k;
  cin >> n >> k;

  ll ans = 0;
  for(ll i = k; i <= n + 1 ; i++)
  {
    ll mi = (i * (i - 1)) / 2;
    ll ma = n * i - mi;
    ans += ma - mi + 1; 
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
long long n,a,b,x[100010],s=0;
int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++) cin>>x[i];
	for(int i=2;i<=n;i++){
		if((x[i]-x[i-1])*a<b) s=s+(x[i]-x[i-1])*a;
		else s+=b;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
    ll n, q;
    cin >> n >> q;
    dsu d(n);
    while(q--){
        ll t, u, v;
        cin >> t >> u >> v;
        if (t == 0) d.merge(u, v);
        else
            co(d.same(u, v));
    }

    return 0;
}


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

signed main(void)
{
	int n, x, y, ans;
	cin >> n;
	int v[n], c[n];
	vector<int> s(n);
	ans = 0;
	rep(i, n) cin >> v[i];
	rep(i, n) cin >> c[i];
	rep(i, n) s[i] = v[i] - c[i];
	sort(s.rbegin(), s.rend());
	rep(i, n)
	{
		if (s[i] > 0) ans += s[i];
	}
	cout << ans << endl;
	return 0;
}


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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int& i : a) cin >> i;

  int maxa = *max_element(a, a + n);
  vector<int> sieve(maxa + 1);

  for (int i = 0; i < n; ++i) {
    for (int j = a[i]; j <= maxa; j += a[i]) {
      sieve[j]++;
    }
  }

  int ans = 0;

  for (int& num : a) {
    if (sieve[num] == 1)
      ans++;
  }

  cout << ans;
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  // }

  return 0;
}

Measured memory_bytes: 7948
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;


ll m=1000000007;

int mod=1e9+7;
int dp[2000+4];

int main()
{
 int x;
	   	cin>>x;
	   	
	   	dp[0]=1;
	  	for(int sum=0; sum<=x; sum++){
	  		for(int coin =3;coin<=sum;coin++){
	  			dp[sum]+=dp[sum-coin];
	  			dp[sum]%=mod;
	  		}
	  	}
	  	cout<<dp[x]<<endl;
	    return 0;
}
 


 

 




Measured memory_bytes: 3616
import java.util.*;
public class Main {

		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int r = sc.nextInt();
			// スペース区切りの整数の入力
			int D = sc.nextInt();
			int x0 = sc.nextInt();
			int x [] = new int [11];
			x[0]=x0;
			for (int i = 1; i<11 ; i++){
					x[i]=r*x[i-1]-D;
				System.out.println(x[i]);
			}
		}

	}

Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            
            while((line = stdReader.readLine()) != null) {
                String[] input = line.split(" ", 0);
                int n = Integer.parseInt(input[0]); 
                int x = Integer.parseInt(input[1]);
                
                if(n == 0  && x == 0) {
                    break;
                }
                
                int count = 0;
                
                for(int i = 1; i <= (n - 2); i++) {
                    if(i > (x - 2)) {
                        break;
                    }
                    for(int j = (i + 1); j <= (n - 1); j++) {
                        if(i + j > x - 1) {
                            continue;
                        }
                        for(int k = (j + 1); k <= n; k++) {
                            int sum = i + j + k;
                            if(sum == x) {
                                count++;
                            }
                        }
                    }
                }
                
                System.out.println(count);
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 25300
from itertools import permutations as perm
N,C = map(int, input().split())
colors = []
for i in range(C):
    colors.append(list(map(int, input().split())))

grids = {0:{}, 1:{}, 2:{}}
for i in range(1,N+1):
    A =list(map(int, input().split()))
    for j in range(N):
        if A[j] not in grids[(i+j+1)%3]:
            grids[(i+j+1)%3][A[j]] = 1
        else:
            grids[(i+j+1)%3][A[j]] += 1
mn = 10**9
for color in perm([i for i in range(1,C+1)], 3):
    tmp = 0
    for i in range(3):
        for k,v in grids[i].items():
            tmp += colors[k-1][color[i]-1] * v
    mn = min(mn, tmp)
print(mn)

Measured memory_bytes: 3064
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

def digit(n, m):
    n = str(n)
    while m - len(n):
        n = '0' + n
    return n

n, m = MAP()
dp = [[inf for _ in range(2 ** n)] for _ in range(m)]
for i in range(m):
    dp[i][0] = 0
for i in range(m):
    a, b = MAP()
    c = LIST()
    arr = [1 if i + 1 in c else 0 for i in range(n)]
    cnum = 0
    for j in range(n):
        cnum += arr[j] * (2 ** (n - j - 1))
    if i == 0:
        for j in range(1, 2 ** n):
            if (cnum ^ j) & j != 0:
                continue
            dp[i][j] = a
    else:
        for j in range(1, 2 ** n):
            former = (cnum & j) ^ j
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][former] + a)
    debug(dp[i])
if dp[m - 1][2 ** n - 1] >= inf:
    print(-1)
else:
    print(dp[m - 1][2 ** n - 1])


Measured memory_bytes: 99416
#include<iostream>
#include<numeric>
#include<vector>

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

int main(){
    int n; std::cin >> n;
    std::vector<int> a(n);
    std::vector<int> c(SIZE,0);
    rep(i,n){
        std::cin >> a[i];
        ++c[a[i]];
    }

    bool f=true;
    for(int i=2; i<SIZE; ++i){
        int cnt=0;
        for(int j=i; j<SIZE; j+=i) cnt += c[j];

        if(cnt > 1) f = false;
    }

    int g=0;
    rep(i,n) g = std::gcd(g, a[i]);
    if(f){
        std::cout << "pairwise coprime" << std::endl;
    }else if(g == 1){
        std::cout << "setwise coprime" << std::endl;
    }else{
        std::cout << "not coprime" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 11104
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long h[200009],tot;
int main() {
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%lld",h+i);
	sort(h,h+n);
	for(int i=0;i<n-k;i++) tot+=h[i];
	printf("%lld\n",tot);
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define dbg(x) cout << #x << " = " << x << endl
#define F_OR(i, a, b, s) for(int i = (a); (s) > 0 ? i < (b) : i >= (b); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define ite(i, x) for(auto& i: x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef vector<pii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;


int main() {
    #ifdef LOCAL
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    int ans = 1;
    bool a, b;
    a = b = 0;
    int ant; cin >> ant;
    FOR(i, n - 1){
        int m; cin >> m;
        if(m > ant) a = 1;
        if(m < ant) b = 1;
        if(a && b) a = b = 0, ++ans;
        ant = m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
fn main() {
    let s: String = read();
    let t: String = read();
    let mut a: usize = read();
    let mut b: usize = read();

    let u: String = read();

    if s == u {
        a -= 1;
    } else if t == u {
        b -= 1;
    }
    println!("{} {}", a, b);
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
s = input()
c = 0
if len(s) == 1:
  print(s)
else:
  for i in range(2**(len(s)-1)):
    now = 0
    b = bin(i)[2:]
    b = "0"*(len(s)-len(b)-1) + b + "1"
    for j in range(len(s)):
      if b[j] == "1":
        c += int(s[now:j+1])
        now = j+1
  print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char nazo;
  cin>>nazo;
  if(nazo=='A'){
    cout<<"A";
  }
  if(nazo=='B'){
    cout<<"A";
  }
  if(nazo=='C'){
    cout<<"A";
  }
  if(nazo=='D'){
    cout<<"A";
  }
  if(nazo=='E'){
    cout<<"A";
  }
  if(nazo=='F'){
    cout<<"A";
  }
  if(nazo=='G'){
    cout<<"A";
  }
  if(nazo=='H'){
    cout<<"A";
  }
  if(nazo=='I'){
    cout<<"A";
  }
 if(nazo=='J'){
    cout<<"A";
  }
  if(nazo=='K'){
    cout<<"A";
  }
  if(nazo=='L'){
    cout<<"A";
  }
  if(nazo=='N'){
    cout<<"A";
  }
  if(nazo=='M'){
    cout<<"A";
  }
  if(nazo=='O'){
    cout<<"A";
  }
  if(nazo=='P'){
    cout<<"A";
  }
  if(nazo=='Q'){
    cout<<"A";
  }
  if(nazo=='R'){
    cout<<"A";
  }
  if(nazo=='S'){
    cout<<"A";
  }
  if(nazo=='T'){
    cout<<"A";
  }
  if(nazo=='U'){
    cout<<"A";
  }
  if(nazo=='V'){
    cout<<"A";
  }
  if(nazo=='W'){
    cout<<"A";
  }
  if(nazo=='X'){
    cout<<"A";
  }
  if(nazo=='Y'){
    cout<<"A";
  }
  if(nazo=='Z'){
    cout<<"A";
  }
   if(nazo=='a'){
    cout<<"a";
  }
  if(nazo=='b'){
    cout<<"a";
  }
  if(nazo=='c'){
    cout<<"a";
  }
  if(nazo=='d'){
    cout<<"a";
  }
  if(nazo=='e'){
    cout<<"a";
  }
  if(nazo=='f'){
    cout<<"a";
  }
  if(nazo=='g'){
    cout<<"a";
  }
  if(nazo=='h'){
    cout<<"a";
  }
  if(nazo=='i'){
    cout<<"a";
  }
 if(nazo=='k'){
    cout<<"a";
  }
  if(nazo=='j'){
    cout<<"a";
  }
  if(nazo=='l'){
    cout<<"a";
  }
  if(nazo=='n'){
    cout<<"a";
  }
  if(nazo=='m'){
    cout<<"a";
  }
  if(nazo=='o'){
    cout<<"a";
  }
  if(nazo=='p'){
    cout<<"a";
  }
  if(nazo=='q'){
    cout<<"a";
  }
  if(nazo=='r'){
    cout<<"a";
  }
  if(nazo=='s'){
    cout<<"a";
  }
  if(nazo=='t'){
    cout<<"a";
  }
  if(nazo=='u'){
    cout<<"a";
  }
  if(nazo=='v'){
    cout<<"a";
  }
  if(nazo=='w'){
    cout<<"a";
  }
  if(nazo=='x'){
    cout<<"a";
  }
  if(nazo=='y'){
    cout<<"a";
  }
  if(nazo=='z'){
    cout<<"a";
  } 
}


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

int main() {
  int64_t  a, b;
  
  cin >> a >> b;
  
  int64_t sub=a*b/2;
  
  int count;
  
  count=a*b-sub*2;
  
  if(count==0){
   cout << "Even" << endl;
  } else {
   cout << "Odd" << endl; 
  }
  
  return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int x; cin >> x;
    vector<bool> e(x+1);
    e[1] = true;
    rreps(i, x) {
        if (i == 1) break;
        int v = i * i;
        while(v <= x) {
            e[v] = true;
            v *= i;
        }
    }
    rreps(i, x) {
        if (e[i]) { cout << i << endl; return 0;}
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	string s;
	cin>>s;
	bool f=true;
	if (s[0]!='A') f=false;
	else {
		int cnt=0;
		for (int i=2; i<s.size()-1; i++) if (s[i]=='C') ++cnt;
		if (cnt!=1) f=false;
		else {
			for (int i=1; i<s.size(); i++) {
				if (s[i]>='a' && s[i]<='z') continue;
				else if (s[i]=='C' && i>=2 && i<s.size()-1) continue;
				else f=false;
			}
		}
	}
	if (f) printf("AC\n");
	else printf("WA\n");
	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include<iostream>
using namespace std;
int n,a,s[2];
priority_queue<int> q;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a,q.push(a);
    for(int i=1;i<=n;i++){a=q.top();q.pop();s[i&1]+=a;}
    cout<<s[1]-s[0];
    return 0;
}

Measured memory_bytes: 256
// abc168_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int K;
    cin >> K;
    string S;
    cin >> S;

    if (S.size() <= K){
        print(S);
    } else {
        string ans = S.substr(0, K);
        ans += "...";
        print(ans);
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;
    int n;
    cin>>n;
    string s1;
    cin>>s1;
    int c = 0 ,c1 = 0;
    vi v1;
    v1.pb(0);
    loop(i,0,n)
    {
        if(s1[i]=='R'){
            v1.pb(i+1);
            c++;
        }

    }

    loop(i,0,c)
    {
      if(s1[i]=='R'){
            //v1.pb(i+1);
            c1++;
        }

    }
    cout<<c-c1<<endl;
    return 0;
}


Measured memory_bytes: 4424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {

			//学生の数
			int n = sc.nextInt();

			if (n == 0) {
				break;
			}

			//点数表
			int p[] = new int[n];

			//合計
			double t = 0;
			//平均
			double a = 0;
			//標準偏差
			double v = 0;

			double std = 0;

		
				for (int i = 0; i < n; i++) {

					//点数p
					p[i] = sc.nextInt();
					t += p[i];

				}

				a = t / n;

				for (int i = 0; i < n; i++) {
					v += ((p[i] - a) * (p[i] - a));
				}

				std = Math.sqrt(v / n);

				System.out.println(std);
			}
			sc.close();
		}

	}



Measured memory_bytes: 31080
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
int H,W,h,w;
int main(){
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if (!(H%h)&&!(W%w)) return puts("No"),0;
	puts("Yes");
	For(i,1,H){
		For(j,1,W)
			if (W%w) printf("%d ",(j-1)%w?-10000:10000*(w-1)-1);
			else printf("%d ",(i-1)%h?-10000:10000*(h-1)-1);
		puts("");
	}
}

Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int main()
{
    int x;

    for(int i = 0; i < 10000; i++)
        {
             cin >> x;

             if(x == 0)
                  {break;}
             
             cout << "Case " << i + 1 << ": " << x << endl;
        }   
}


Measured memory_bytes: 3012
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	int n, m;
	VI v;
	cin >> n >> m;
	v.resize(n);
	REP(i, m)
	{
		int a, b;
		cin >> a >> b;
		v[a-1]++;
		v[b-1]++;
	}
	REP(i,n)
	{
		cout << v[i] << endl;
	}
	return 0;
}

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    transform(a.begin(), a.end(),a.begin(),::toupper);
    transform(b.begin(), b.end(),b.begin(),::toupper);
    transform(c.begin(), c.end(),c.begin(),::toupper);
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll n;
    cin >> n;
    ll ans = 1;
    ll num = 1;
    bool chk = true;
    vl a(n);
    for(auto &it: a) cin >> it;
    sort(all(a));
    for(int i = 0; i < n; ++i) {
        if(((ans > 1000000000) && (a[i] > 1000000000)) || ((ans * a[i]) > 1000000000000000000ll)) {
            chk = false;
            break;
        }
        ans *= a[i];
        //cout << ans << "\n";
    }
    if(chk)
        cout << ans;
    else
        cout << -1;
}


Measured memory_bytes: 4028
#for _ in range(int(input())):
n=int(input())
if n>=400 and n<=599:print(8)
elif n>=600 and n<=799:print(7)
elif n>=800 and n<=999:print(6)
elif n>=1000 and n<=1199:print(5)
elif n>=1200 and n<=1399:print(4)
elif n>=1400 and n<=1599:print(3)
elif n>=1600 and n<=1799:print(2)
elif n>=1800 and n<=1999:print(1)

Measured memory_bytes: 61640
//
// Created by 中野誠大 on 2019-02-10.
//

#include<iostream>

#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;


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

    int count4=0,countodd=0;
    for (int i=0;i<n;i++){
        if (a[i]%4==0) count4+=1;
        if (a[i]%2!=0) countodd+=1;
    }

    if (count4>=countodd) cout << "Yes";
    else if(count4+countodd == n && countodd==count4+1) cout << "Yes";
    else{cout<<"No";}

    return 0;

}





Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S')
        cout<<"0\n";
    if(s[0] == 'S' && s[1] == 'S' && s[2] == 'R')
        cout<<"1\n";
    if(s[0] == 'S' && s[1] == 'R' && s[2] == 'S')
        cout<<"1\n";
    if(s[0] == 'S' && s[1] == 'R' && s[2] == 'R')
        cout<<"2\n";
    if(s[0] == 'R' && s[1] == 'S' && s[2] == 'S')
        cout<<"1\n";
    if(s[0] == 'R' && s[1] == 'S' && s[2] == 'R')
        cout<<"1\n";
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'S')
        cout<<"2\n";
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
        cout<<"3\n";
    
        return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int N, K, a[1010], sum[1010];
vector<int> v;

signed main()
{
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i + 1];
        sum[i + 1] += a[i + 1] + sum[i];
    }
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < i; j++){
            v.pb(sum[i] - sum[j]);
        }
    }
    sort(v.begin(), v.end(), greater<int>() );
    int n = (int)v.size();
    /*for(int i = 0; i < n; i++){
        printf("v:%lld\n", v[i]);
    }
    printf("n:%lld\n", n);
    */
    int sta = v[0];
    int cnt = 0;
    while(sta){
        sta = (sta >> 1ll);
        cnt++;
    }
    cnt--;
    int ans = 0;
    int tmp = 0;
    for(int i = cnt; i >= 0; i--){
        int ks = 0;
        tmp |= (1ll << i);
        for(int j = 0; j < n; j++){
            if((v[j] & tmp) == tmp){
                ks++;
                //printf("j:%lld v[j]:%lld\n", j, v[j]);
            }
        }
        if(ks >= K){
            ans = tmp;
        }
        else{
            tmp = ans;
        }
        //printf("i:%lld ans:%lld\n", i, ans);
    }
    cout << ans << endl;

    return 0;
}
/*


*/


Measured memory_bytes: 6512
import java.util.Scanner


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    
    val as = new Array[Int](n)
    for (i <- as.indices) {
      as(i) = sc.nextInt()
    }
    
    var ans = 1
    var increase = 0
    var m = as(0)
    
    for (i <- as.indices) {
      if (increase == 0) {
        if (m < as(i)) {
          increase = 1
          m = as(i)
        } else if (m > as(i)) {
          increase = 2
          m = as(i)
        }
      } else if (increase == 1) {
        if (m > as(i)) {
          ans += 1
          increase = 0
          m = as(i)
        } else {
          m = as(i)
        }
      } else {
        if (m < as(i)) {
          ans += 1
          increase = 0
          m = as(i)
        } else {
          m = as(i)
        }
      }
    }
    
    println(ans)
  }
  
  def printArray[T](arr: Array[T]): Unit = {
    for (i <- arr.indices) {
      print(s"${arr(i)} ")
    }
    println()
  }
}

Measured memory_bytes: 51636
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;




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

	int B[200];

	for (int i = 1; i <= N - 1; i++) {
		cin >> B[i];
	}

	int ans = B[1];

	for (int i = 1; i <= N - 2; i++) {
		ans += min(B[i], B[i + 1]);
	}

	ans = ans + B[N - 1];

	cout << ans;

	system("PAUSE");
}


Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
  int a,b,c;
  cin >> a >> b >>c;
  if(a==b){
    cout << c;
  }else{
    cout << a+b-c;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
#define M 1010

int main(void){
  int i,num,j,k;
  int n,m;
  int p[M];
  int swp,sf;
  int ans[N];

  for(i=0;;i++){
    ans[i]=0;
    scanf("%d%d",&n,&m);
    if(n==0 && m==0)
      break;

    for(j=0;j<n;j++)
      scanf("%d",&p[j]);

    for(;;){
      sf=1;
      for(j=0;j<n-1;j++){
        if(p[j]<p[j+1]){
          sf=0;
          swp=p[j];
          p[j]=p[j+1];
          p[j+1]=swp;
        }
      }
      if(sf==1)
        break;
    }

    for(j=m-1;j<n;j+=m)
      p[j]=0;

    for(j=0;j<n;j++)
      if(p[j])
        ans[i]+=p[j];
  }

  num=i;

  for(i=0;i<num;i++)
    printf("%d\n",ans[i]);

  return 0;
}

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

int N, Q, A[100001];
int64_t S[100001], Sdiv[100001];
pair<int, int> X[100000];
int64_t ans[100000];

int main(){
    cin >> N >> Q;
    for(int i=1; i<=N; i++){
        cin >> A[i];
        S[i] = S[i-1] + A[i];
        Sdiv[i] = A[i];
        if(i-2 > 0) Sdiv[i] += Sdiv[i-2];
    }
    for(int i=0; i<Q; i++){
        int x;
        cin >> x;
        X[i] = {x, i};
    }
    sort(X, X+Q);

    int y = 1;
    for(int q=0; q<Q; q++){
        int x = X[q].first;
        while(y<=N && A[y] < x) y++;
        while(y<=N){
            int upper = N - y + 1;
            int lower = y - (lower_bound(A, A+N+1, max(1, 2*x-A[y])) - A) + 1;
            if(upper > lower){
                y++;
            }else{
                break;
            }
        }
        int64_t result = S[N] - S[y-1];
        int t_first = N - (N-y+1)*2;
        if(t_first > 0) result += Sdiv[t_first];
        ans[X[q].second] = result;
    }
    for(int i=0; i<Q; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N,A; cin >> N >> A;
    int x[N]; for(int i=0; i<N; i++) cin >> x[i];
    vector<vector<vector<long long>>> dp(N+1,vector<vector<long long>>(N+1,vector<long long>(N*A+1,0)));
    dp[0][0][0]=1;

    for(int i=0; i<N+1; i++){
        for(int j=0; j<N+1; j++){
            for(int k=0; k<N*A+1; k++){
                if(i>0 && k<x[i-1]){
                    dp[i][j][k] = dp[i-1][j][k];
                }else if(i>0 && j>0 && x[i-1] <= k) {   
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]];
                }
            }
        }
    }
    long long ans = 0;
    for(int i=1; i<N+1; i++){
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;


    /* 部分点解
    int N,A; cin >> N >> A;
    vector<int> x(N); for(int i=0; i<N; i++) cin >> x[i];
    int ans=0;
    for(int bit=0; bit<(1<<N); bit++){
        if(!bit) continue;
        int sum=0;
        int num=0;
        for(int i=0; i<N;i++){
            if(bit & (1<<i)){
                sum+=x[i];
                num++;
            }
        }

       if(sum==(A*num)){
            ans++;
        }
    }
    cout << ans << endl;
    */
}

Measured memory_bytes: 52224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  int x[9],y[9];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  vector<int>p;
  for(int i=0;i<n;i++){
    p.push_back(i);
  }

  double ans=0;
  int cnt=0;
  do{
    for(int i=0;i<n-1;i++){
      ans+=sqrt(pow(x[p[i]]-x[p[i+1]],2)+pow(y[p[i]]-y[p[i+1]],2));
    }
    cnt++;
  }while(next_permutation(p.begin(),p.end()));

  printf("%.10f\n",ans/cnt);

  return(0);
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
  int n=kbd.nextInt();
  int m=kbd.nextInt();
   int[] A= new int[m];
   for(int i=0;i<m;i++){
     A[i]=kbd.nextInt();
}
long a=0;
   for(int i=0;i<m;i++){
     a=a+A[i];
   }
   if(a<=n){
     System.out.println(n-a);
   }else{
     System.out.println(-1);
   }
}
}


Measured memory_bytes: 46160
#include<bits/stdc++.h>
using namespace std;
long long p[100],q[100],cnt[100],f[100];
int main()
{
	long long n,i,j,k,x,y,a;
	f[0]=1;
	for (i=1;i<=10;i++)
	{
		f[i]=i*f[i-1];
	}
	x=0;
	y=0;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>p[i];
	}
	for (i=0;i<n;i++)
	{
		a=0;
		for (j=1;j<p[i];j++)
		{
			if (cnt[j]==0)
			{
				a++;
			}
		}
		x=x+f[n-i-1]*a;
		cnt[p[i]]=1;
	}
	//cout<<x+1<<endl;
	for (i=0;i<n;i++)
	{
		cin>>q[i];
	}
	for (i=0;i<=10;i++)
	{
		cnt[i]=0;
	}
	for (i=0;i<n;i++)
	{
		a=0;
		for (j=1;j<q[i];j++)
		{
			if (cnt[j]==0)
			{
				a++;
			}
		}
		y=y+f[n-i-1]*a;
		cnt[q[i]]=1;
	}	
	//cout<<y+1<<endl;
	cout<<abs(x-y)<<endl;	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int s=sc.nextInt();
        if(s==1000000000){
            
        }
        for(int i=0;i<n;i++){
            if(i<k){
                System.out.print(s+" ");
            }else{
                if(s==1000000000){
                    System.out.print(1+" ");
                }else{
                    System.out.print(1000000000+" ");
                }
                
            }
        }
        System.out.println();
 
    }



}

Measured memory_bytes: 42252
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 2;
    int count = 0;
    List<Integer> prime = new ArrayList<>();
    while (count < N) {
      int tmp = 5*i + 1;
      if (isPrime(tmp)) {
        prime.add(tmp);
        count++;
      }
      i++;
    }
    for (i=0;i<N;i++) {
      System.out.print(prime.get(i));
      if (i!=N-1) {
        System.out.print(" ");
      }
    }
  }

  private static boolean isPrime(int a) {
    double sqrt = Math.pow(a, 0.5);
    if (a == 2 || a == 3) {
      return true;
    }
    for (int i=2; i<sqrt+1; i++) {
      if (a % i == 0) {
        return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}

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

  int n; cin >> n;
  vector<LLI> a(n);
  REP(i,n) cin >> a[i];

  if(any_of(ALL(a), [](LLI x){return x%2==1;})){
    cout << "first" << endl;
  }else{
    cout << "second" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,s;
  cin>>a>>s;
  for(int i=s-a+1;i<s+a;i++){
    if(i!=s+a){
      
    cout<<i<<" ";
   
  }
    else{
      cout<<i<<endl;
    }
  }
  
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  string n;
  int ans = 0;
  cin >> n;
  REP(i, 4){
      if(n[i] == '2' ) ans++;
    }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
    
using namespace std;
    
string str[2];
int s, n, t, m, lt, rt, t_w, t_t;
double p;
    
int conv(string s){
  string data[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};  
  for(int i=0;i<7;i++) if(s == data[i]) return i;
  return -1;
}
    
int calc(int s_w, int s_t){
  int cnt = 0;
  for(int k=0;k<m;k++){
    int f_w = s_w;
    int f_t = s_t + s;
    if(f_t >= 24 * 60){
      f_t -= 24 * 60;
      f_w = (f_w + 1) % 7;
    }
    bool f = false;
    if(t_w == -1 || (t_w == s_w && t_w == f_w)){
      if(t_t == 0 && 0 <= s_t && s_t < 24 * 60 && 0 <= f_t && f_t < 24 * 60) f = true;
      if(t_t == 1 && 6 * 60 <= s_t && s_t < 18 * 60 && 6 * 60 <= f_t && f_t < 18 * 60) f = true;
      if(t_t == 2 && (18 * 60 <= s_t && s_t < 24 * 60 || 0 <= s_t && s_t < 6 * 60)
         && (18 * 60 <= f_t && f_t < 24 * 60 || 0 <= f_t && f_t < 6 * 60)) f = true;
    }
    if(f) cnt++;
    s_t += t;
    if(s_t >= 24 * 60){
      s_t -= 24 * 60;
      s_w = (s_w + 1) % 7;
    }
  }
  return cnt;
}
    
main(){
  while(cin >> s >> n >> t >> str[0] >> str[1] >> p >> m && (s|n|t|m) && str[0] != "None" && str[1] != "None"){
    t_w = conv(str[0]);
    if(str[1] == "All") t_t = 0;
    if(str[1] == "Day") t_t = 1;
    if(str[1] == "Night") t_t = 2;
    int ans = 0;
    for(int i=0;i<7;i++) for(int j=0;j<24*60;j++) ans = max(ans, calc(i, j));
    printf("%.10f\n", 1.0 - pow(1.0 - 1.0 / p, n * ans));
  }
}

Measured memory_bytes: 1296
from collections import defaultdict
N = int(input())
ans = 0
d1 = defaultdict(int)
d2 = defaultdict(int)
for i, j in enumerate(map(int, input().split())):
    d1[i-j]+=1
    d2[i+j]+=1
for i in d1.keys():
    ans += d1[i]*d2[i]
print(ans)


Measured memory_bytes: 66328
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

int main(int argc, const char * argv[]) {
    // input from txt
  
    /////////
    //write//
    /////////
    
    int n;
    int *a;
    a = new int[MAX];
    
    cin >> n;
    rep(i, n)cin >> a[i];
    
    sort(a, a+n);
    
    int res = a[n/2]-a[n/2-1];
    
    cout << res << endl;
    
    return 0;
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k; cin >> n >> k;

  if (k % 2 == 0) {
    ll x = n / (k / 2);
    ll y = (x + 1) / 2;

    ll z = n / k;
    cout << y * y * y + z * z * z << endl;
  } else {
    ll x = n / k;
    cout << x * x * x << endl;
  }
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <string>

int main()
{
    int h, w;
    std::cin >> h >> w;
    std::vector<std::string> img(h);
    for (int i = 0; i < h; ++i)
    {
        std::cin >> img[i];
    }

    for (int i = 0; i < w + 2; ++i)
    {
        std::cout << '#';
    }
    std::cout << std::endl;
    for (int i = 0; i < h; ++i)
    {
        std::cout << '#' << img[i] << '#' << std::endl;
    }
    for (int i = 0; i < w + 2; ++i)
    {
        std::cout << '#';
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3620