akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int n=Integer.parseInt(scan.next());
    long[] array=new long[n];
    for(int i=0;i<array.length;i++){
      array[i]=Long.parseLong(scan.next());
    }

    if(n==1){
      System.out.println(array[0]+" "+array[0]+" "+array[0]);
    }else{
      long min=array[0];
      for(int i=0;i<array.length-1;i++){
        min=Math.min(min,array[i+1]);
      }
      long max=array[0];
      for(int i=0;i<array.length-1;i++){
        max=Math.max(max,array[i+1]);
      }
      long sum=0;
      for(int i=0;i<array.length;i++){
        sum+=array[i];
      }
      System.out.println(min+" "+max+" "+sum);
    }
  }
}



Measured memory_bytes: 41704
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <math.h>
#include <algorithm>

const long long MOD = 1000000007;

using namespace std;


long long wa(long long n) {
    return (n * (n - 1)) / 2;
}


int main(void) {

    long long i, j;
    long long n, m;
    long long sum = 0;
    long long temp, temp_b;
    long long min, max;
    string s;
    long long a, b;
    long long mod = 2019;
    vector<long long> t;
    vector<long long> dp;

    cin >> s;
    
    reverse(s.begin(), s.end());


    dp.resize(2020);
    a = 1;
    t.push_back(int(int(s[0]) - '0'));
    dp[0]++;
    dp[t[0]]++;

    for (i = 1; i < s.length(); i++) {
        a *= 10;
        a %= mod;
        temp = (t[i - 1] + int(int(s[i]) - '0') * a) % mod;
        t.push_back(temp);
        dp[t[i]]++;
    }

    // for (i = 0; i < t.size(); i++) {
    //     cout << t[i] << endl;
    // }


    for (i = 0; i < dp.size(); i++) {
        sum += wa(dp[i]);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 5452
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;
const int N = 200010;
int d1[N], d2[N], n;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        d1[i] = x + y;
        d2[i] = x - y;
    }
    sort(d1 + 1, d1 + 1 + n);
    sort(d2 + 1, d2 + 1 + n);
    cout << max(d1[n] - d1[1], d2[n] - d2[1]) << '\n';
    return 0;
}


Measured memory_bytes: 5152
#include <iostream>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int N,K,i,n,b[200005]={0},minp,num=0,answer=0;
    scanf("%d %d",&N,&K);
    n=N;
    while(n--)
    {
        scanf("%d",&i);
        if(b[i]==0)
            num++;
        b[i]++;
    }
    sort(b,b+N+1);
    i=0;
    if(num<=K)
        printf("0\n");
    else
    {
        while(b[i]==0)
        {
            if(b[i+1]!=0)
                minp=i+1;
            i++;
        }
        for(i=minp;i<minp+(num-K);i++)
            answer+=b[i];
        printf("%d\n",answer);
    }
    return 0;
}

Measured memory_bytes: 1024
"use strict";

const App  = (arg:any) => {
  const value = arg.trim().split("\n");
  const N:number = parseInt(value[0].split(" ")[0], 10);
  const A:number = parseInt(value[1].split(" ")[0], 10);

  const SquaredN = N * N;
  const result = SquaredN - A;
  console.log(result);
}

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

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    int count = 0;
    rep(i, 0, m)
    {
        int a;
        cin >> a;
        count += a;
    }

    int ans = n - count;
    if (ans >= 0)
    {
        cout << n - count << endl;
        return 0;
    }

    cout << "-1" << endl;

    return 0;
}


Measured memory_bytes: 3660
#3
import itertools
import numpy as np

n,m,x = input().split(' ')
book_list = []
for i in range(int(n)):
    book_list.append([int(s) for s in input().split(' ')])
    
ok_list = []
for num in range(1,len(book_list)+1):
    for i in itertools.combinations(book_list,num):
        goukei = np.sum(np.array(i),axis=0)
        flag = True
        for j in range(1,len(goukei)):
            if goukei[j] < int(x):
                flag = False
                break
        if flag:
            ok_list.append(goukei.tolist())
            
if ok_list:
    print(sorted(ok_list)[0][0])
else:
    print(-1)

Measured memory_bytes: 28996
#  --*-coding:utf-8-*--

N = int(input())

X = {}
M = 0

for i in range(N):
    S = input()
    if not (S in X):
        X[S] = 0

    X[S] += 1
    M = max(M, X[S])

Y = sorted(map(lambda item:item[0],
               filter(lambda item:item[1] == M, X.items())))

for y in Y:
    print(y)
           



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

const int MAXN = 10e5+10;

int N, K;
int h[MAXN];
int dp[MAXN];

int main() {
    cin >> N >> K;
    for(int i=1; i<=N; i++) {
        cin >> h[i];
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[1] = 0;
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=K; j++) {
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 6400
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main(){
string s,c;
int g=0,i,a,b;
cin>>c;
while(1){
cin>>s;
for(i=0;i<s.size();i++){
	b=s[i];
	a=c[i];
	if(a==b+32)s[i]=b+32;
	if(a==b-32)s[i]=b-32;
}
if(s==c)g++;
if(s=="END_OF_TEXT")break;
}
cout<<g<<endl;
return 0;
}

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

using namespace std;

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> D(N + 1, 0);
  for (int i = 2; i <= N; i++) {
    int n = i;
    for (int j = 2; j <= i; j++) {
      while (n % j == 0) {
        D[j]++;
        n /= j;
      }
    }
  }
  int res = 1;
  for (int i = 1; i <= N; i++) {
    res = 1LL * res * (D[i] + 1) % MOD;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
import collections
adj = collections.defaultdict(list)
for _ in range(n-1):
	u,v,w = map(int,raw_input().split())
	adj[u].append((v,w))
	adj[v].append((u,w))

dist =  {}
qq,k = map(int, raw_input().split())
vis = set([])
q = collections.deque([(k,0)])
while(q):
	u, c = q.popleft()
	dist[u]  = c
	for v,w in adj[u]:
		if v not in vis: 
			vis.add(v)
			q.append((v,w+c))
for _ in range(qq):
	u,v = map(int, raw_input().split())
	print dist[u] + dist[v]


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

class Dice{
    int _num[6];
  public:
    void set(int num[6]){
        for(int i=0;i<6;i++){
            _num[i] = num[i];
        }
    }
    void printTop(){
        cout << _num[0] << endl;
    }
    void N(){
        int buf = _num[0];
        _num[0] = _num[1];
        _num[1] = _num[5];
        _num[5] = _num[4];
        _num[4] = buf;
    }
    void S(){
        int buf = _num[0];
        _num[0] = _num[4];
        _num[4] = _num[5];
        _num[5] = _num[1];
        _num[1] = buf;
    }
    void W(){
        int buf = _num[0];
        _num[0] = _num[2];
        _num[2] = _num[5];
        _num[5] = _num[3];
        _num[3] = buf;
    }
    void E(){
        int buf = _num[0];
        _num[0] = _num[3];
        _num[3] = _num[5];
        _num[5] = _num[2];
        _num[2] = buf;
    }
};




int main(void){
    int num[6];
    for(int i=0;i<6;i++){
        int n;
        cin >> n;
        num[i] = n;
    }
    
    Dice d;
    d.set(num);
    
    string txt;
    cin >> txt;
    
    while(txt.size()>0){
        char c = txt[0];
        txt = txt.substr(1);
        
        if(c == 'N')
            d.N();
        else if(c == 'S')
            d.S();
        else if(c == 'W')
            d.W();
        else if(c == 'E')
            d.E();
    }
    
    d.printTop();

}

Measured memory_bytes: 1212
<?php
fscanf(STDIN, "%s", $s);
$len = strlen($s);
while($len >= 2) {
    $s = substr($s, 0, $len - 1);
    $len = strlen($s);
    if($len % 2 != 0) {
        continue;
    }
    if(substr($s, 0, $len / 2) == substr($s, $len / 2, $len)) {
        echo $len. "\n";
        break;
    }
}

Measured memory_bytes: 4856
from itertools import accumulate

def solve():
    N = int(input())
    Ss = input().rstrip()

    Rs, Gs, Bs = [], [], []
    numRs = [0] * N
    numGs = [0] * N
    numBs = [0] * N
    for i in range(N):
        S = Ss[i]
        if S == 'R':
            Rs.append(i)
            numRs[i] = 1
        elif S == 'G':
            Gs.append(i)
            numGs[i] = 1
        else:
            Bs.append(i)
            numBs[i] = 1

    lenR, lenG, lenB = len(Rs), len(Gs), len(Bs)
    setR = set(Rs)
    setG = set(Gs)
    setB = set(Bs)

    accNumRevRs = list(accumulate(numRs[::-1]))[::-1]
    accNumRevGs = list(accumulate(numGs[::-1]))[::-1]
    accNumRevBs = list(accumulate(numBs[::-1]))[::-1]

    ans = 0
    for j in range(N):
        S = Ss[j]
        if S == 'R':
            for i in Gs:
                if i > j:
                    break
                ans += accNumRevBs[j]
                k = 2*j-i
                if k in setB:
                    ans -= 1
            for i in Bs:
                if i > j:
                    break
                ans += accNumRevGs[j]
                k = 2*j-i
                if k in setG:
                    ans -= 1
        elif S == 'G':
            for i in Rs:
                if i > j:
                    break
                ans += accNumRevBs[j]
                k = 2*j-i
                if k in setB:
                    ans -= 1
            for i in Bs:
                if i > j:
                    break
                ans += accNumRevRs[j]
                k = 2*j-i
                if k in setR:
                    ans -= 1
        else:
            for i in Rs:
                if i > j:
                    break
                ans += accNumRevGs[j]
                k = 2*j-i
                if k in setG:
                    ans -= 1
            for i in Gs:
                if i > j:
                    break
                ans += accNumRevRs[j]
                k = 2*j-i
                if k in setR:
                    ans -= 1

    print(ans)


solve()


Measured memory_bytes: 9812
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt=0;
long long a[20],ans=0;
void tom(int l,int w)
{
  if(l==0)
   {
     if(w!=s.size())
      return ;
     if(cnt==0)
      for(int i=0;i<s.size();i++)
        ans=ans*10+s[i]-'0';
     else
        for(int i=1;i<=cnt;i++)
          ans+=a[i];
     return ;
   }
  for(int i=1;i<=s.size()-w;i++)
    {
      cnt++;
      for(int j=1;j<=i;j++)
        a[cnt]=a[cnt]*10+(s[w+j-1]-'0');
      tom(l-1,w+i);
      a[cnt]=0;
      cnt--;
    }
}
int main()
{
  cin>>s;
  for(int i=1;i<=s.size();i++)
    tom(i,0);
  cout<<ans<<endl;
  return 0;
}

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

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int a[110], b[110];
int n,m;

bool chk(){
    int s = 0, t = 0;
    rep(i,n) s += a[i];
    rep(i,m) t += b[i];
    return s == t;
}

int main(){
    while(cin >> n >> m && n){
        rep(i,n) cin >> a[i];
        rep(i,m) cin >> b[i];
        sort(a,a+n); sort(b,b+m);
        int x = -1, y = -1;
        rep(i,n)rep(j,m)if(x == -1){
            swap(a[i], b[j]);
            if(chk()) x = i, y = j;
            swap(a[i], b[j]);
        }
        if(x != -1){
            cout << a[x] << " " << b[y] << endl;
        } else {
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int n;
    cin>>n;
    n %= 10;
    if(n==2||n==4||n==5||n==7||n==9){
        cout<<"hon"<<endl;
    }
    else if(n==3){
        cout<<"bon"<<endl;
    }
    else{
        cout<<"pon"<<endl;
    }
}

Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
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<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int n,m; cin >> n >> m;
    VVI s(m);
    REP(i,m){
        int k; cin >> k;
        REP(j,k){
            int a; cin >> a; a--;
            s[i].push_back(a);
        }
    }
    VI p(m); REP(i,m) cin >> p[i];

    int res = 0;
    for(int bit = 0; bit<(1<<n); bit++){ //全スイッチの状態
        bool ok = 1;
        REP(i,m){
            int count = 0;
            for(auto x:s[i]) if(bit&(1<<x)) count++;
            if(count%2!=p[i]) ok = 0;
        }
        if(ok) res++;
    }
    out(res);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<fixed;
    cout<<setprecision(9);
    long long int n,m,i=0,j=0,k=0,p,q,l;
    long long int a=1,b=1,c=1;
    cin>>n;
    for(i=1; i<=n; i++)
    {
       for(j=1; j<=n; j++)
       {
           for(l=1; l<=n; l++)
           {
               p = __gcd(i,j);
               k+=__gcd(p,l);
           }
       }
    }
    cout<<k;
}


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

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

  long long ans = 0;
  int cnt = 0;
  for (int i=3*n - 2; i> 0 && cnt < n; i-=2) {
    ans += a[i];
    ++cnt;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int X;
int Y;
char A[100][102];
int main(){
  int i, j;
  rd(X);
  rd(Y);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(X);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=0;i<(Y+2);i++){
    wt_L('#');
  }
  wt_L('\n');
  for(i=0;i<(X);i++){
    wt_L('#');
    wt_L(A[i]);
    wt_L("#\n");
  }
  for(i=0;i<(Y+2);i++){
    wt_L('#');
  }
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int X, Y;
// char A[100][102];
// {
//   int i, j;
//   rd(X,Y,A(X));
//   rep(i,Y+2) wtN('#'); wtN('\n');
//   rep(i,X) wtN('#', A[i], "#\n");
//   rep(i,Y+2) wtN('#'); wtN('\n');
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	int n, k;
	long long int total = 0;
	cin >> n >> k;
	int arr[n];
	rarr(arr, n);
	sort(arr, arr + n);
	for(int i = 0; i < k; i++){
		total += arr[i];
	}
	cout << total;
} 

Measured memory_bytes: 3624
from bisect import bisect_right
s = list(map(int,list(input())))
s.insert(0,-1)
n = len(s)-1
flag = 0
if s[n]==1 or s[1]==0 or s[n-1]==0:
    flag = 1
else:
    for i in range(2,n-1):
        if s[i]!=s[n-i]:
            flag = 1
            break
if flag==1:
    print(-1)
else:
    print(n,n-1)
    A = [1,n-1]
    cur = 1
    for i in range(2,n-1):
        if s[i]==1:
            print(cur,i)
            cur = i
            A.append(i)
    print(cur,n-1)
    A = sorted(A)
    for i in range(2,n-1):
        if s[i]==0:
            ind = bisect_right(A,i)
            print(i,A[ind])

Measured memory_bytes: 59128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 200007;
const int MOD = 1000000007;

void solve() {
    string s;
    cin >> s;
    if (s == "ARC") {cout << "ABC";}
    else {cout << "ARC";}
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}

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

int main() {
	int n, a[100010], pmin, mmin, mnum;
	pmin = 1000000010;
	mmin = -1000000010;
	mnum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] >= 0) {
			if (a[i] < pmin) pmin = a[i];
		}
		else {
			mnum++;
			if (a[i] > mmin) mmin = a[i];
		}
	}
	long long ans = 0;

	if (mnum % 2 == 0) {
		for (int i = 0; i < n; i++) {
			ans += abs(a[i]);
		}
	}
	else {
		if (n == mnum) {
			for (int i = 0; i < n; i++) {
				ans += abs(a[i]);
			}
			ans = ans + 2 * mmin;
		}
		else {
			for (int i = 0; i < n; i++) {
				ans += abs(a[i]);
			}
			long long ansa, ansb;
			ansa = ans + 2 * mmin;
			ansb = ans - 2 * pmin;
			ans = max(ansa, ansb);
		}
	}
	cout << ans <<endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 640
import math
def In(): return map(int, raw_input().split())

toll = {}
P=[6,10,12,14,27,33,7,9,12,23,30,5,8,20,27,5,17,26,12,23,10]
c=0
for i in range(0,6):
  for j in range(i+1,7):
    toll[(i,j)] = toll[(j,i)] =P[c]*50
    c += 1
D=[0, 6, 13, 18, 23, 43, 58]

while 1:
  i1 = input()-1
  if i1<0: break
  h1, m1 = In()
  i2 = input()-1
  h2, m2 = In()
  x = toll[(i1, i2)]
  if (1050<=h1*60+m1<=1170 or 1050<=h2*60+m2<=1170) and abs(D[i1]-D[i2])<=40:
    x = int(math.ceil(x/100.0))*50
  print x

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

int main(){
    ll h,w;
    cin >> h >> w;
    // corner case
    if(h==1 or w==1) cout << 1 << endl;
    else if(h%2==0 or w%2==0) cout << h*w/2 << endl;
    else cout << (h*w/2) +1 << endl;
    return 0;
}

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

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

void addEdge(vector<int> adj[], int u, int v)
{
	adj[u].push_back(v);
	adj[v].push_back(u);
}

int main()
{
	FASTIO
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for(int i=0; i<n; i++) cin >> h[i];
	vector<int> adj[n];
	for(int i=0; i<m; i++)
	{
		int a, b;
		cin >> a >> b;
		addEdge(adj,a-1,b-1);
	}
	int cnt = 0;
	for(int i=0; i<n; i++)
	{
		int height = h[i];
		for(auto x : adj[i])
		{
			if(h[x] >= height)
			{
				cnt++;
				break;
			}
		}
	}
	cout << n-cnt << "\n";
	return 0;
}

Measured memory_bytes: 8780
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

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

    vector<int> joushi(n, 0);
    int a;
    rep(i, 1, n) {
        cin >> a;
        a--;
        joushi[a]++;
    }

    for (int num : joushi) {
        cout << num << endl;
    }

    return 0;
}


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

int main()
{
    int m, k; scanf("%d%d", &m, &k);
    if (k>=1<<m or (m==1 and k==1)) {
        cout<<-1<<endl;
        return 0;
    }
    if (k==0) {
        for(int i=0; i<1<<m; ++i) cout<<i<<' '<<i<<' ';
        cout<<endl;
    }
    else {
        cout<<0<<' '<<k<<' '<<0<<' ';
        for(int i=1; i<1<<m; ++i) if (i!=k) cout<<i<<' ';
        cout<<k<<' ';
        for(int i=(1<<m)-1; i>0; --i) if (i!=k) cout<<i<<' ';
        cout<<endl;
    }
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int a, b;
int main() {
	scanf("%d%d", &a, &b);
	if((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0)printf("Possible\n");
	else printf("Impossible\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
bool check(long long time,long long h[],long long a,long long b,int n){
    long long cnt = 0;
    rep(i,n) cnt+=((max(0LL,h[i]-b*time)+(a-b-1))/(a-b));
    if(cnt<=time) return true;
    return false;
}
int main(){
    int n;
    long long a,b;
    cin >> n >> a >> b;
    long long h[n];
    rep(i,n) cin >> h[i];
    long long left = 0;
    long long right = 1e9+5;
    while((right-left)>1){
        long long middle = (right+left)/2;
        if(check(middle,h,a,b,n)) right = middle;
        else left = middle;
    }
    cout << right << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int r,g;
	int ans=0;
	
	cin>>r>>g;
	ans = 2*g-r;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    double q;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            q = sc.nextDouble();
            if(q==-1) break;

            double x = q/2.0;
            while((double)Math.abs(x*x*x-q)>=(double)0.00001*q){
                x = x - (x*x*x-q)/(3*x*x);
            }

            System.out.printf("%.6f\n",x);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

int main(){

	int count, n,ans;
	ans = 0;
	cin >> n;

	for (int i = 1; i <= n; i=i+2) {
		count = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0) {
				count++;
				if (count == 8) {
					ans++;
					break;

				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

n = int(input())
an = [int(num) for num in input().split()]

if 0 in an :
  print(0)
  sys.exit()

answer = 1
check = 10**18
for i in range(len(an)) :
  answer *= an[i]
  if answer > check:
    print(-1)
    sys.exit()

print(answer)


Measured memory_bytes: 21460
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	a, b := getInt(), getInt()
	fa := calc(a - 1)
	fb := calc(b)

	ans := fa ^ fb
	fmt.Fprintln(wr, ans)
}

func calc(n int) int {
	ret := 0
	switch n % 4 {
	case 0:
		ret = n
	case 1:
		ret = 1
	case 2:
		ret = n + 1
	case 3:
		ret = 0
	}

	return ret
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  int i = 1;
  while(true) {
    if(n < pow(k,i)) {
      break;
    }
    i++;
  }
  cout << i << endl;
}


Measured memory_bytes: 384
x,k,d=input().split()
x=abs(int(x))
k=int(k)
d=int(d)
a=x//d
b=x-a*d
c=(x-b)/d
i=int(c)
if k<=i:
  print(abs(x)-d*k)
else:
  if (k-(i))%2==0:
    print(abs(x)-d*(i))
  else:
    print(abs(abs(x)-d*(i+1)))

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

using namespace std;

int a,b,c,x;
int dp[20010];
int ans;

int main()
{
	cin>>a>>b>>c>>x;
	int i,j,k;
	for (i=0;i<=a;i++){
		for (j=0;j<=b;j++){
			for (k=0;k<=c;k++){
				if (i*500+j*100+k*50==x)ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

using namespace std;

using ll = long long;
using ull = unsigned long long;

// 文字列分解
std::vector<std::string> split(const std::string &str, char sep){
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}


/* solver
 * 後ろから解いていく
 *		前から解いてもいいのだけれど、vectorにはpop_backしかないので
 * 今、点nにいて、mだけ動く命令があったら、過去にはn-mかn+mの時点にいるはず
 * それらの候補をひたすらsetに挿入していく
 */
set<int> solve(std::vector<int> v, set<int> st){
	if (v.size() == 0) {
		return st;
	}

	int last = v.back();
	v.pop_back();

	if (last == 0) {
		return solve(v,st);
	}
	else {
		set<int> newst;
		for(auto itr = st.begin(); itr != st.end(); itr++){
			newst.insert(*itr + last);
			newst.insert(*itr - last);
		}
		return solve(v,newst);
	}

}

int main(int argc, char const *argv[]) {
	string s;
	std::cin >> s;
	int x,y;
	std::cin >> x >> y;

	std::vector<int> vecx;
	std::vector<int> vecy;
	std::vector<string> splits(split(s,'T'));

	// Tで方向転換なので、Tで文字列分解して、
	// 奇数個目のFの列はx軸方向に、偶数個目のFの列はy軸方向への移動なので、
	// x方向、y方向にどれだけ進むかをいれる
	for (size_t i = 1; i < splits.size(); i++) {
		if (i % 2 == 0) {
			vecx.push_back(splits[i].size());
		}
		else {
			vecy.push_back(splits[i].size());
		}
	}

	// 解く
	set<int> xx = solve(vecx, set<int> {x});
	set<int> yy = solve(vecy, set<int> {y});

	// 最初はx軸正方向に進むので、(splits[0].size(),0)にいる可能性があったらYes
	if (xx.find(splits[0].size()) != xx.end() && yy.find(0) != yy.end()) {
		std::cout << "Yes" << '\n';
	}
	else {
		std::cout << "No" << '\n';
	}
	return 0;
}


Measured memory_bytes: 348800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main() {
	string s;
	cin >> s;
	
	string month = s.substr(5, 2);
	if(month[0] == '1') {
		cout << "TBD" << endl;
	}
	else {
		if(month[1] >= '5') {
			cout << "TBD" << endl;
		}
		else {
			cout << "Heisei" << endl;
		}
	}
	
    return 0;
}

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

int main() {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	int ans = (a[1] - a[0]) / 2;
	if ((a[1] - a[0]) % 2 == 1) ++ans, ++a[2];
	a[0] = a[1];
	ans += a[2] - a[0];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
   ll n;
   cin>>n;
   ll a[n],sum=0;
   for(ll i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
   }
   ll pre[n];
   memset(pre,0,sizeof(pre));
   pre[0]=a[0]-1;
   for(ll i=1;i<n;i++){
    pre[i]=pre[i-1]+a[i]-1;
   }
    ll ans=1e18,x=0;
    for(ll i=0;i<n;i++){
        x=x+a[i];
        ll y=sum-x;
        ll z=pre[i];
        ll w=pre[n]-pre[i];
        ans=min(ans,abs(y-x));
        if(x>y){
            if(z>=x-y)ans=min(ans,x-y);
        }
        else if(y>x){
            if(w>=y-x)ans=min(ans,y-x);
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

int main(){
	int x,a,b;
	cin>>x;
	if (x==1){
		cout<<"Hello World";
	}else{
		cin>>a>>b;
		cout<<a+b;
	}
	re 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

  int a, b, r, tmp;


  scanf("%d %d", &a, &b);

  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  /* 最大公約数を出力 */
  printf("%d\n",b);

  return 0;
}



Measured memory_bytes: 2124
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()[:-1].decode()

    ans = 0
    result = [False] * n
    for i in range(n):
        if k <= i and t[i] == t[i - k] and result[i - k]:
            continue
        if t[i] == 'r':
            ans += p
        elif t[i] == 's':
            ans += r
        elif t[i] == 'p':
            ans += s
        result[i] = True

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 42096
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll N;
  cin >> N;
  ll a[N];
  ll sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }

  //一回の操作で取り除く石の数
  ll S = N * (N + 1) / 2;
  if(sum % S != 0){
    //cout << "hoge" << endl;
    cout << "NO" << endl;
    return 0;
  }
  //操作回数
  ll T = sum / S;

  //右の項との差分b
  ll b[N];
  for(int i = 0; i < N - 1; i++){
    b[i] = a[i+1] - a[i];
  }
  b[N-1] = a[0] - a[N-1];

  //iがm回選ばれるとすると、
  //-m(N-1)+(T-m)=b[i]
  //m=(T-b)/N;

  //選ばれる回数m
  ll m[N];
  for(int i = 0; i < N; i++){
    ll tmp = T - b[i];
    if(tmp % N != 0 || tmp < 0){
      //cout << i << endl;
      //cout << "Hoge1" << endl;
      cout << "NO" << endl;
      return 0;
    }
    m[i] = tmp / N;
  }

  ll cnt = 0;
  for(int i = 0; i < N; i++) cnt += m[i];

  if(cnt != T){
    //cout << "Hoge12" << endl;
    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;
  return 0;
}


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

int main(void){
    vector<long> a(3);
    for(int i = 0;i < 3;i++){
          cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < 3;i++){
          if(a[i] % 2 == 0){
                cout << 0 << endl;
                return 0;
          }
    }
    cout << a[0] * a[1] << endl;
}


Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <bitset>
#define ll long long

using namespace std;

const ll bitsz = 4194304;

int main() {
	
	ll n, i, x, sum = 0;
	cin >> n;
	
	bitset<bitsz> bs;
	bs[0] = 1;
	for (i = 1; i <= n; i++) {
		cin >> x;
		sum += x;
		bs |= bs << x;
	}
	
	ll rez = 0;
	for (int i = 0; i <= sum / 2; i++)
		if (bs[i])	rez = sum - i;
	cout << rez << "\n";
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) {
        cin >> A[i];
    }
    sort(ALL(A), greater<int>());
    vector<int> vec(8, 0);
    int cnt = 0;
    for(auto x : A) {
        if(x >= 3200) cnt++;
        else vec[x / 400]++;
    }
    int v = 0;
    rep(i, 8) {
        if(vec[i]) v++;
    }
    int minv = 0, maxv = cnt;
    if(v == 0) minv = 1;
    cout << minv + v << " " << maxv + v << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 1e7+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n,cnt[maxn];

int main()
{
    fastio();
    cin>>n;
    rep(i,2,n){
        for(ll j=i;j<=n;j+=i){
            cnt[j]++;
        }
    }
    ll ans = 0;
    rep(i,1,n) ans += (ll)i*((ll)cnt[i]+1);
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

vector<vector<pair<int, int>>> edges;
vector<int> colors;

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

  int N;
  cin >> N;

  edges.resize(N + 1);
  for (int i = 1; i < N; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    edges[u].emplace_back(v, w % 2);
    edges[v].emplace_back(u, w % 2);
  }
  colors.resize(N + 1);

  unordered_set<int> tbd;
  for (int i = 2; i <= N; ++i) {
    tbd.emplace(i);
  }
  queue<int> q;
  q.emplace(1);
  for (; !q.empty(); q.pop()) {
    auto cur = q.front();
    auto& nexts = edges[cur];
    for (auto next : nexts) {
      auto it = tbd.find(next.first);
      if (it != tbd.end()) {
        tbd.erase(it);
        colors[next.first] = next.second ^ colors[cur];
        q.emplace(next.first);
      }
    }
  }

  for (auto it = colors.begin() + 1; it != colors.end(); ++it) {
    cout << (*it ? 1 : 0) << endl;
  }
}


Measured memory_bytes: 10916
#include <iostream>
#include <stack>
using namespace std;
int main( void )
{
  int d;
  stack<int> s;
  while( 1 ){
    cin >> d;
    if( cin.eof() ) break;
    if( d ) s.push( d );
    else { cout << s.top() << endl; s.pop(); }
  }
  return 0;
}

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

const int Maxn = 505;

int n, k;
int a[Maxn];
int sum;

bool Check(int g)
{
    vector <int> seq;
    for (int i = 0; i < n; i++) {
        int el = a[i] % g;
        if (el) seq.push_back(el);
    }
    sort(seq.begin(), seq.end());
    int l = 0, r = int(seq.size()) - 1;
    int res = 0;
    while (l < r)
        if (seq[l] == 0) l++;
        else if (seq[r] == g) r--;
        else {
            int tk = min(seq[l], g - seq[r]);
            res += tk;
            seq[l] -= tk; seq[r] += tk;
        }
    return res <= k;
}

int main()
{
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    vector <int> dvs;
    for (int i = 1; i * i <= sum; i++) if (sum % i == 0) {
        dvs.push_back(i);
        if (i * i < sum)
            dvs.push_back(sum / i);
    }
    sort(dvs.begin(), dvs.end());
    for (int i = int(dvs.size()) - 1; i >= 0; i--)
        if (Check(dvs[i])) {
            printf("%d\n", dvs[i]);
            break;
        }
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ans_set = {i for i in range(1,m+1)}
for i in range(n):
  a = list(map(int,input().split()))
  del a[0]
  a_set = set(a)
  ans_set = ans_set & a_set
print(len(ans_set))
  
  




Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int n=nextInt();
		int c=0;
		for(int i=1;i<=n;i++)
		{
			int a=nextInt();
			if(i%2==1 && a%2==1)
				c++;
		}
		out.println(c);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 33028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n;
  cin >> n;
  int odd = 0, div4 = 0, div2 = 0;
  rep(i,n) {
    int a; cin >> a;
    if (a % 2 == 1) odd++;
    else if (a % 4 == 0) div4++;
    else div2++;
  }
  if (odd <= div4) cout << "Yes" << endl;
  else if (div2 == 0 && n%2 == 1 && odd == div4 + 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N;
    vector<int> h(N,0);
    vector<ll> dp(N,0);
    rep(i,N) cin >> h.at(i);
    int step1,step2;
    rep(i,N){
        if(i == 0) continue;
        if(i == 1) {
            dp.at(i) = abs(h.at(i) - h.at(i-1));
            continue;
        }
        step1 = abs(h.at(i) - h.at(i-1));
        step2 = abs(h.at(i) - h.at(i-2));
        dp.at(i) = min(dp.at(i-1) + step1, dp.at(i-2) + step2);
    }
    cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  rep (i, 100) {
    if ( (b*(i+1) + c) % a == 0) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 1e6 + 10;

int n, dp[N][2];
string s;

int solve(int idx, int extra){
   if(idx >= n){
      return extra;
   }
   int &ans = dp[idx][extra];
   if(ans != -1)
      return ans;
   ans = inf;
   int curr = extra + s[idx] - '0';
   if(curr < 10){
      smin(ans, curr + solve(idx+1, 0));//we
   }
   //clerk
   smin(ans, 10 - curr + solve(idx+1, 1));
   return ans;
}

void solve(){
   cin >> s;
   n = (int)(s.size());

   memset(dp, -1, sizeof dp);

   reverse(s.begin(), s.end());
   cout<<solve(0, 0);
}

int32_t main(){_
   
   int t = 1;
   //cin >> t;

   while(t--){
     solve();
     cout << endl;
   }
   

   return 0;
}

Measured memory_bytes: 63900
#include <bits/stdc++.h>
#define LL long long


const int maxn = 2e5+7;

using namespace std;

LL suma[maxn],sumb[maxn],n;

int main()
{
    std::ios::sync_with_stdio(false);
    cin>>n;
    memset(suma,0,sizeof(suma));
    memset(sumb,0,sizeof(sumb));

    for (int i=1;i<=n;i++)
    {
        int temp;
        cin>>temp;
        suma[i]=sumb[i]=temp;
        suma[i]=suma[i-1]+temp;
        sumb[i]=sumb[i-1]^temp;
    }

    LL l=0,r=1,r1=1,l1=0;
    LL ans=0;
    while (1)
    {
        l++;
        if (l>n) break;
        while (((suma[r]-suma[l-1])==(sumb[r]^sumb[l-1])) && (r<=n)) r++;
        LL d=r-l,dd=r1-l;
        ans+=d*(d+1)/2-dd*(dd+1)/2;
        r1=r;l1=l;
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 3328
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,a,b;
void solve(){
	cin>>a>>b;
	cout<<(b-1+(a-2))/(a-1);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 384
#include <stdio.h>
int main(void){
  int a;
  scanf("%d", &a);
  if(a <= 111){
    printf("111\n");
  }else if(a <= 222){
    printf("222\n");
  }else if(a <= 333){
    printf("333\n");
  }else if(a <= 444){
    printf("444\n");
  }else if(a <= 555){
    printf("555\n");
  }else if(a <= 666){
    printf("666\n");
  }else if(a <= 777){
    printf("777\n");
  }else if(a <= 888){
    printf("888\n");
  }else if(a <= 999){
    printf("999\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[5];
int main(){
  int i, res=0;
  rd(S);
  for(i=0;i<3;i++){
    if(S[i]=='1'){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// char S[5];
// {
//   int i, res = 0;
//   rd(S);
//   rep(i,3) if(S[i]=='1') res++;
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<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 <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll h, w, k;
	cin >> h >> w >> k;
	VecS s(h);
	rep(i, h) cin >> s[i];

	ll ans = 0;
	rep(i, pow2(h)){
		bitset<10> H(i);
		rep(j, pow2(w)){
			bitset<10> W(j);
			ll cnt = 0;
			rep(k, h){
				rep(l, w){
					if (H[k] && W[l] && s[k][l] == '#') cnt++;
				}
			}
			if (cnt == k) ans++;
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 3640