akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;

const int M_N=200002;
LL N;
vector<LL> a;



struct BIT{
    //1-indexed
    LL bit[M_N+1],n;
    //iまでの総和を返す
    void init(){
        for (int i = 0; i < M_N+1; i++) {
            bit[i]=0;
        }
    }
    LL sum(int i){
        LL s=0;
        while(i>0){
            s+=bit[i];
            i=i&(i-1);
        }
        return s;
    }
    //iにx加算する
    void add(int i,LL x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }

};


bool check(LL x){
    vector<LL> t(N+1,0);
    BIT bit;
    bit.init();
    bit.n=M_N+1;
    t[0]=100001;
    for (int i = 0; i < N; i++) {
        t[i+1]=(x<=a[i]?1:-1)+t[i];
    }
    LL ret=0;
    for (LL i = 0; i <= N; i++) {
        ret+=i-bit.sum(t[i]);
        bit.add(t[i],1);
    }
    return 4*ret>N*(N+1);
}

int main(){
    cin >> N;
    for (int i = 0; i < N; i++) {
        LL A;
        cin >> A;
        a.pb(A);
    }
    LL l=0,r=1e10;
    while(r-l>1){
        LL m=(l+r)/2;
        if(check(m)) r=m;
        else l=m;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 3444
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  x <- getInt

  let solve i y | y >= x    = i
                | otherwise = let y' :: Int
                                  y' = floor (1.01 * fromIntegral y)
                              in solve (i+1) y'

  print $ solve 1 101

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

//方針：貪欲法(値段の高いものから割引券を適応していく
int main(void){
  //入力
  int N,M;
  cin >> N >> M;

  //高い金額から順に取り出すためのデータ構造
  priority_queue<long long> prices;

  //pricesに値段を記録していく．
  for(int i = 0; i < N; ++i){
    long long A;
    cin >> A;
    prices.push(A);
  }

  //割引券の使用(高いものから順に適応していく)
  while(M--){
    long long price = prices.top(); prices.pop();
    //割引券の利用
    price /= 2;

    //割引した後も割引券は使えるので割引後の値段を挿入
    prices.push(price);
  }

  //値段の合計
  long long sum = 0ll;
  while(!prices.empty()){
    sum += prices.top(); prices.pop();
  }

  //出力
  cout << sum << endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    int a1=n*(n-1)/2;
    if(n==1) a1=0;
    int a2= m*(m-1)/2;
    if(m==1) a2=0;

    cout<<a1+a2<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC169
{
    class B
    {
        static void Main(string[] args)
        {
            var N = BigInteger.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(BigInteger.Parse).ToArray();
            if (A.Contains(0)) { Console.WriteLine(0); return; }
            BigInteger res = 1;
            for (int i = 0; i < N; i++)
            {
                res = res * A[i];
                if (1000000000000000000 < res) { Console.WriteLine(-1); return; }
            }
            Console.WriteLine(res);
        }
    }
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;
int c[20][20];

int main() {
    int N;
    cin >> N;
    for (int i = 1; i < N + 1; i++) {
        string str = to_string(i);
        c[str.front() - '0'][str.back() - '0'] += 1;
    }

    long long ans = 0;
    REP(i, 9) REP(j, 9) ans += c[i + 1][j + 1] * c[j + 1][i + 1];

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////

/*（๑•﹏•๑｀) */


int main() {
    int ans1 = -1;
    int ans2 = 1;

    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    FORq(x,0,30){
        FORq(y,0,30){
            int water = 100*A*x + 100 * B*y;
            FORq(z,0,F-100*A*x-100*B*y+1){
                FORq(w,0,F-100*A*x-100*B*y-C*z+1){
                    int suger = C*z + D*w;
                    if (water + suger > F) continue;
                    if ((E * (water)) < 100 * (suger)) continue;

                    if (ans1 * water < suger * ans2){
                        ans1 = suger;
                        ans2 = water;
                    }
                }
            }
        }
    }

    cout << ans1 + ans2 << " " << ans1 << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

using namespace std;
int main() {
	int n, k; cin >> n >> k;

	int ans = 1;
	for (int i = 0; i < n; i++) {
		ans = min(ans * 2, ans + k);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    int N,H,W;
    cin>>N>>H>>W;
    int count=0;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        if(a>=H && b>=W) count++;
    }
    cout<<count<<endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#if defined(_MSC_VER)
#pragma warning(disable : 4996)  // VSでscanfを使う．
#endif

#define int long long

const int MOD = 1e9 + 7;

const int MAX = 2001;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
  COMinit();

  int n, k;
  cin >> n >> k;

  for (int i = 1; i <= k; i++) {
    int com = COM(n - k + 1, i);
    int p = COM(k - 1, i - 1);
    int ans = (com * p) % MOD;
    cout << ans << endl;
  }

  return 0;
}


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

int main(){
    vector<int> a;
    int b, k;
    for(int i = 0; i < 3; i++){
        cin >> b;
        a.push_back(b);
    }
    cin >> k;

    int max_ele = *max_element(a.begin(), a.end());

    int ans = 0;

    for(int i = 0; i < 3; i++){
        ans += a[i];
    }
    ans -= max_ele;

    for(int i = 0; i < k; i++){
        max_ele *= 2;
    }

    ans += max_ele;

    cout << ans << endl;
}

Measured memory_bytes: 256
N = input()
K = int(input())

dp = [[[0 for _ in range(5)] for _ in range(2)] for _ in range(len(N)+1)]
dp[0][0][0] = 1

for i in range(len(N)):
    dgt = int(N[i])
    for k in range(K+1):
        dp[i+1][1][k+1] += dp[i][1][k] * 9
        dp[i+1][1][k] += dp[i][1][k]

        if dgt > 0:
            dp[i+1][1][k+1] += dp[i][0][k] * (dgt-1)
            dp[i+1][1][k] += dp[i][0][k]

            dp[i+1][0][k+1] = dp[i][0][k]
        else:
            dp[i+1][0][k] = dp[i][0][k]

print(dp[len(N)][0][K] + dp[len(N)][1][K])


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;




}

Measured memory_bytes: 256
N,K = map(int, input().split())
A = list(map(int, input().split()))

move = 1
l = [1]
flag = [False]*(N+1)
flag[1] = True

for i in range(K):
    move = A[move-1]
    if flag[move]:
        break
    flag[move] = True
    l.append(move)

ind = l.index(move)
rest = (K-ind) % (len(l) - ind) + ind

print(l[rest])


Measured memory_bytes: 32364
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<tuple<int, long long int, int>> PY(M);
  for (int i = 0; i < M; i++){
    int P, Y;
    cin >> P >> Y;
    PY.at(i) = make_tuple(P, Y, i);
  }
  sort(PY.begin(), PY.end());
  vector<tuple<int, int, int>> ID(M);
  ID.at(0) = make_tuple(get<2>(PY.at(0)), get<0>(PY.at(0)), 1);
  int num = 1;
  for(int i = 1; i < M; i++){
    if (get<0>(PY.at(i-1)) != get<0>(PY.at(i))){
      num = 0;
    }
    num++;
    ID.at(i) = make_tuple(get<2>(PY.at(i)), get<0>(PY.at(i)), num);
  }
  sort(ID.begin(), ID.end());
  for (int i = 0; i < M; i++){
    printf("%06d%06d\n", get<1>(ID.at(i)), get<2>(ID.at(i)));
  }
  return 0;
}

Measured memory_bytes: 4992
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
 
    	final int INF = 10000000;
 
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int K = sc.nextInt();
 
        int startH=-1,startW=-1;
        boolean open[][] = new boolean[H][W];
 
        for(int h=0;h<H;h++){
        	String row = sc.next();
        	for(int w=0;w<W;w++){
        		if(row.charAt(w)=='S'){
        			open[h][w]=true;
        			startH=h;
        			startW=w;
        		}else open[h][w]=(row.charAt(w)=='.');
        	}
        }
        //input end
 
        int[][] directDistance = new int[H][W];
        for(int h=0;h<H;h++){
        	for(int w=0;w<W;w++){
        		directDistance[h][w]=INF;
        	}
        }
        directDistance[startH][startW]=0;
 
        ArrayList<Integer> visitedH =new ArrayList<>();
        ArrayList<Integer> visitedW =new ArrayList<>();
        visitedH.add(startH);
        visitedW.add(startW);
 
        while(!visitedH.isEmpty()){
        	int h = visitedH.remove(0);
        	int w = visitedW.remove(0);
        	
        	if(h>0 && open[h-1][w] && directDistance[h-1][w]>1+directDistance[h][w]){
        		directDistance[h-1][w] = 1+directDistance[h][w];
        		visitedH.add(h-1);
        		visitedW.add(w);
        	}
        	if(h<H-1 && open[h+1][w] && directDistance[h+1][w]>1+directDistance[h][w]){
        		directDistance[h+1][w] = 1+directDistance[h][w];
        		visitedH.add(h+1);
        		visitedW.add(w);
        	}        	
        	if(w>0 && open[h][w-1] && directDistance[h][w-1]>1+directDistance[h][w]){
        		directDistance[h][w-1] = 1+directDistance[h][w];
        		visitedH.add(h);
        		visitedW.add(w-1);
        	}  
        	if(w<W-1 && open[h][w+1] && directDistance[h][w+1]>1+directDistance[h][w]){
        		directDistance[h][w+1] = 1+directDistance[h][w];
        		visitedH.add(h);
        		visitedW.add(w+1);
        	}  
        }
 
        int ans = INF;
        for(int h = Math.max(0,startH-K);h<=Math.min(H-1,startH+K);h++){
        	for(int w = Math.max(0,startW-K);w<=Math.min(W-1,startW+K);w++){
        		if(directDistance[h][w]<=K){//first step: go to [h][w]
        			//and then go straight for the closest wall
        			
        			int toWall = Math.min(Math.min(h,H-h-1),Math.min(w,W-w-1));
        			int magic = 1+(toWall+K-1)/K;
        			if(magic<ans) ans = magic;
        		}
        	}
        }
 
 
        System.out.println(ans);
    }
}

Measured memory_bytes: 49640
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int               long long
#define ff                first
#define ss                second
#define md                1000000007
#define md1               998244353
#define inf               1000000000000000
#define minf              -1000000000000000
#define pb                push_back
#define in                insert
#define mkp               make_pair
#define mpll              map<ll,ll>
#define len(p)            (ll)p.size()
#define pll               pair<ll,ll>
#define all(v)            v.begin(),v.end()
#define mem(a,t)          memset(a,t,sizeof(a))
#define endl              "\n"
#define ar                array
#define vl                vector<ll>
#define vpll              vector<pair<ll,ll>>
#define f(i,yha,wha)      for(ll i=yha;i<wha;i++)
#define rf(i,wha,yha)     for(ll i=wha;i>=yha;i--)
#define f0(n)             for(ll i=0;i<n;i++)
#define f1(n)             for(ll i=1;i<=n;i++)
#define fg(i,yha,wha,gap) for(ll i=yha;i<wha;i+=gap)


void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    vector<int> states;
    vector<int> vis(n + 1);
    vis[1] = 1;
    int last = 0;
    int cur = v[1];
    while (!vis[cur]) {
        vis[cur] = 1;
        states.pb(cur);
        cur = v[cur];
    }
    last = cur;
    if (last == 1) {
        states.pb(1);
    }
    int cycle_length = states.size();
    if (k < cycle_length) {
        cout << states[k - 1] << endl;
        return;
    }
    if (last == 1) {
        cout << states[(k - 1) % cycle_length] << endl;
        return;
    }
    int start ;
    for (int i = 0; i < cycle_length; i++) {
        if (states[i] == last) {
            start = i + 1;
            break;
        }
    }
    if (k < cycle_length) {
        cout << states[k - 1] << endl;
        return;
    }
    k -= cycle_length;
    int left = cycle_length - start + 1;
    cout << states[start - 1 + (k - 1) % left] << endl;


}

int32_t main()
{
    flash();
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 8460
//
// Created by ryo on 2019/12/10.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

int solve(int a, int b, int r, int c, vector<string> C) {
    int dist[r][c];
    rep(i, r) rep(j, c) dist[i][j] = 100000;
    dist[a][b] = 0;
    using pi = pair<int,int>;
    queue<pi> que;
    que.push(pi(a,b));
    if (C[a][b] == '#') return 0;
    while (que.size()) {
        auto now = que.front();
        que.pop();
        auto x = now.second;
        auto y = now.first;

        rep(i, 4) {
            auto nx = dx[i] + x;
            auto ny = dy[i] + y;

            if (nx >= 0 && nx < c && ny >= 0 && ny < r && dist[ny][nx] == 100000 && C[ny][nx] == '.') {
                dist[ny][nx] = dist[y][x] + 1;
                que.push(pi(ny, nx));
            }
        }
    }

    ll ans = 0;
    rep(i, r) rep(j, c) {
      if (C[i][j] != '#') chmax<ll>(ans, dist[i][j]);
    }

    return ans;
}

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

    int r,c;
    cin >> r >> c;
    vector<string> C(r);
    rep(i, r) cin >> C[i];
    ll ans = 0;
    rep(i, r) rep(j, c) {
      chmax<ll>(ans, solve(i, j, r, c, C));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define OK 0;
#define START 0;
using namespace std;


int main(void) {
    unsigned int S = START;
    unsigned int h = START;
    unsigned int m = START;
    unsigned int s = START;

    //scanf
    cin >> S;

    h = S /3600;
    m = (S % 3600) / 60;
    s = S - (h * 3600 + m * 60);
    //printf
    cout << h << ":" << m << ":" << s << endl;

    return OK;
}

Measured memory_bytes: 1156
import sys
from collections import deque as dq
input = sys.stdin.readline

N = int(input())
S = [list(input())[: -1] for _ in range(2)]
#print(S)
h = 0
v = 0
x = [0] * N
mod = 10 ** 9 + 7
for i in range(N):
  if S[0][i] == S[1][i]:
    v += 1
    x[i] = 1
for i in range(N - 1):
  if S[0][i] == S[0][i + 1]:
    h += 1
    x[i] = 0
res = 3
i = 0
if x[0] == 0:
  i += 2
  res *= 2
else: i += 1
while i < N:
  #print(i)
  if x[i] == 0:
    if x[i - 1] == 0:
      res *= 3
      res %= mod
    else:
      res *= 2
      res %= mod
    i += 1
  else:
    if x[i - 1] != 0:
      res *= 2
      res %= mod
  i += 1
#print(h, v)
#print(x)
print(res)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		long sum = 0;
	    for(int i = 1; i <= num; i++){
	    	if(i % 3 != 0 && i % 5 != 0){
	    		sum += i;
	    	}
	    }
	    System.out.println(sum);
	}
}


Measured memory_bytes: 35796
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String str = stdIn.next();
		int len = str.length();
		int[] level = new int[len+1];
		int top = 0;
		int bottom = 0;
		int nowLevel = 0;

		for (int i=0; i<len; i++) {
			char c = str.charAt(i);
			level[i] = nowLevel;
			if (c == '\' || c == '\\') {
				nowLevel--;
			}else if(c == '/'){
				nowLevel++;
			}
			top = Math.max(top,nowLevel);
			bottom = Math.min(bottom,nowLevel);
		}
		level[len] = nowLevel;
		top = Math.max(top,nowLevel);
		bottom = Math.min(bottom,nowLevel);

		boolean[] water = new boolean[len];
		Map<Integer,Integer> map = new HashMap<Integer,Integer>();
		int sum = 0;

		for (int i=top; i>bottom; i--) {//高さ
			int start = -1;
			for (int j=0; j<len; j++) {//幅
				if (!water[j]) {//水は入っているか
					if ((start==-1?level[j]:level[j+1]) == i) {//levelの一致
						if (start == -1 && level[j]>level[j+1]) {//startが設定されているか '\'であるか
							start = j;
						}else if(start != -1){
							int count = 0;//傾斜数
							int vol = 0;
							for (int k=start; k<j+1; k++) {//面積計算
								vol += Math.abs(level[start] - Math.max(level[k],level[k+1]));
								if(Math.abs(level[k] - level[k+1]) > 0)
									count++;
								water[k] = true;//水を入れる
							}
							vol += count/2;
							sum += vol;//総面積に足す
							map.put(start,vol);
							start = -1;
						}
					}
				}
			}
		}

		System.out.println(sum);
		System.out.print(map.size());
		for (int i=0; map.size()!=0; i++) {
			if(map.containsKey(i)){
				System.out.print(" "+map.get(i));
				map.remove(i);
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 24908
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 2e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

vector<LL> ar(MAXN);
vector<vector<LL> > adj(MAXN);
LL BIT[MAXN];

LL max(LL a, LL b){
	return a>b?a:b;
}

int n;
int t[2*MAXN];

void modify(int p, int value) {  
  for (t[p += n+1] = value; p > 1; p >>= 1) t[p>>1] = max(t[p], t[p^1]);
}

int query(int l, int r) { 
  int res = 0;
  for (l += n+1, r += n+1; l < r; l >>= 1, r >>= 1) {
    if (l&1) res = max(res,t[l++]);
    if (r&1) res = max(res,t[--r]);
  }
  return res;
}

int an[MAXN];

void dfs(int u,int p){
	int old = query(ar[u], ar[u]+1);
	int	x = query(0, ar[u]); 
	int value = x + 1; 
	
	//cout<<u<<" "<<ar[u]<<" "<<x<<endl;
	modify(ar[u], max(value,old));
	an[u] = query(0,n+1);
	for(auto i:adj[u]){
		if(i!=p){
			dfs(i,u);
		}
	}
	modify(ar[u], old);
		//cout<<u<<" "<<p<<endl;
}

int main(){
  fio();
  cin>>n;
  vector<LL> v(n);
  set<LL> s;
  forn(i,n) {
  	cin>>v[i];
  	s.insert(v[i]);
  }
  int in = 0;
  map<LL,LL> mp;
  for(auto i:s){
  	mp[i] = ++in;
  }
  forn(i,n){
  	ar[i+1] = mp[v[i]];
  }
  forn(i,n-1){
  	int u, v; cin>>u>>v;
  	adj[v].pb(u);
  	adj[u].pb(v);
  }
  
  // for1(i,n) cout<<ar[i]<<" ";x
  // cout<<endl;
  
  dfs(1,0);
  for1(i,n) cout<<an[i]<<endl;

  return 0;
}


Measured memory_bytes: 51136
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll n;cin>>n;
	cout<<1-n<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3644
"""
?AGC
AG?C
A?GC
?ACG
?CAG
"""

n = int(input())

# dp i文字目までのパターン　前の3文字を保存する
import itertools
l = ["A", "G", "C", "T"]
pl = itertools.product(l, repeat=3)

dic = dict()
dic2 = dict()
from collections import defaultdict
ng_list = defaultdict(int)


for idx, p in enumerate(pl):
    dic[idx] = p
    dic2[p] = idx

pl = itertools.product(l, repeat=4)
for idx, p in enumerate(pl):
    if p[1] == "A" and p[2] == "G" and p[3] == "C":
        ng_list[p] = 1
    elif p[0] == "A" and p[1] == "G" and p[3] == "C":
        ng_list[p] = 1
    elif p[1] == "A" and p[2] == "C" and p[3] == "G":
        ng_list[p] = 1
    elif p[1] == "G" and p[2] == "A" and p[3] == "C":
        ng_list[p] = 1
    elif p[0] == "A" and p[2] == "G" and p[3] == "C":
        ng_list[p] = 1

pl = itertools.product(l, repeat=3)
dic3 = dict()
dic4 = dict()
for idx, p in enumerate(pl):
    dic3[idx] = p
    dic4[p] = idx

dp = [[0 for _ in range(4**3)] for _ in range(n+1)]
dp[0][dic4[("T", "T", "T")]] = 1
MOD = 10 ** 9 + 7
for i in range(n):
    for j in range(4**3):
        for k in l:
            if ng_list[dic3[j] + (k,)] == 0:
                dp[i+1][dic4[dic3[j][1:] + (k,)]] += dp[i][j]
                dp[i+1][dic4[dic3[j][1:] + (k,)]] %= MOD

print(sum(dp[-1]) % MOD)



Measured memory_bytes: 40944
#include <bits/stdc++.h>
using namespace std;
struct po{int x,y,a,b;};
int w,h;
int mp[55][55];
int tx,ty,kx,ky;
int dis[55][55][55][55];

po mkp(int a,int b,int c,int d){
  po res;
  res.x=a, res.y=b, res.a=c,res.b=d;
  return res;
}

int bfs(){
  int dx[]={0,0,-1,1};
  int dy[]={1,-1,0,0};
  memset(dis,0,sizeof(dis));
  queue <po> Q;
  Q.push(mkp(tx,ty,kx,ky));

  while(!Q.empty()){
    po t=Q.front();Q.pop();

    if(dis[t.y][t.x][t.b][t.a]>=100) return -1;
    if(t.x==t.a&&t.y==t.b) return dis[t.y][t.x][t.b][t.a];
    

    for(int i=0;i<4;i++){
      int nx=t.x+dx[i],ny=t.y+dy[i];
      int na=t.a-dx[i],nb=t.b-dy[i];
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx])nx=t.x,ny=t.y;
      if(na<0||nb<0||na>=w||nb>=h||mp[nb][na])na=t.a,nb=t.b;
      if(nx==t.x&&ny==t.y&&na==t.a&&nb==t.b)continue;
      if(dis[ny][nx][nb][na])continue;
      dis[ny][nx][nb][na]=dis[t.y][t.x][t.b][t.a]+1;
      Q.push(mkp(nx,ny,na,nb));
    }
  }
  return -1;
}

int main(){

  while(1){
  cin>>w>>h;
  if(!w&&!h)break;
  cin>>tx>>ty>>kx>>ky;
  tx--,ty--,kx--,ky--;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) cin>>mp[i][j];
  int res=bfs();
  if(res==-1) cout << "NA"<<endl;
  else cout <<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 37264
#-*- coding: utf-8 -*-  
### 二つの数値a, bをスペース区切りで入力し、
### a/b(int), a%b, a/b(float) を求める

# 数値入力・変換
str_in = raw_input()
int_in = map(int, str_in.split())

# 計算
int_div = int_in[0] / int_in[1]
remainder = int_in[0] % int_in[1]
float_div = round( float( int_in[0] )/ float( int_in[1] ), 5)

# 出力
print( repr(int_div) + ' '+ repr(remainder) + ' ' + repr(float_div))



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

int main(){
    while (true) {

        int m,f,r;
        cin >> m >> f >> r;
        if (m < 0 && f < 0 && f < 0){
            return 0;
        }
        if (m < 0 || f < 0){
            cout << 'F' << endl;
        } else if (m + f >= 80) {
            cout << 'A' << endl;
        } else if (m + f >= 65) {
            cout << 'B' << endl;
        } else if (m + f >= 50) {
            cout << 'C' << endl;
        } else if (m + f >= 30 && r >= 50) {
            cout << 'C' << endl;
        } else if (m + f >= 30) {
            cout << 'D' << endl;
        } else {
            cout << 'F' << endl;
        }

    }
}



Measured memory_bytes: 3088
def solve():
    s = list(input())
    if (s[0] == "A") and (s[2:-1].count("C") == 1):
        s.remove("A")
        s.remove('C')
        if str(s).islower():
            print("AC")
        else:
            print('WA')
    else:
        print('WA')


if __name__ == "__main__":
    solve()


Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main (void)
{
  int n,a[100],i,j,k;
    cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    
  }
   for(i=0;i<n;i++)
  {
    if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0){cout<<"DENIED"<<endl;return 0;}
  }
  
  
  cout<<"APPROVED"<<endl;
  return 0;
}

Measured memory_bytes: 3596
def main():
    N = int(input())
    A = input().split()
    B = [int(A[i])-(i+1) for i in range(len(A))]
    B = sorted(B)

    m = len(B)
    prefix = [0]
    for i in range(m):
        prefix.append(prefix[-1]+B[i])

    min_v = float('inf')
    for i in range(m):
        b = B[i]
        v = -b*(N-2*i)
        v += prefix[-1] - prefix[i]*2
        min_v = min(min_v, v)
    return min_v

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 36844
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int cnt = 0;
	int n;
	cin >> n;
	f1 (n) {
		int x;
		cin >> x;
		if (x % 2) {
			cnt++;
		}
	}
	if (cnt % 2) {
		cout << "NO\n";
	}
	else {
		cout << "YES\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  cin >> n;
  V<int> a;
  a.resize(n);

  rep(i, n) {
    cin >> a[i];
  }

  int count = 1;
  bool uping = false;
  bool downing = false;
  repf(i, 1, n) {
    int diff = a[i] - a[i - 1];

    if(uping && diff < 0) {
      uping = false;
      count++;
      continue;
    }
    if(downing && diff > 0) {
      downing = false;
      count++;
      continue;
    }

    unless(uping || downing) {
      uping = diff > 0;
      downing = diff < 0;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 3740
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

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

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int n, a[MXN];

inline int calc(int x) {
	int res = 0;
	rep(i,1,n) res += (a[i]-x)*(a[i]-x);
	return res;
}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin >> n;
	rep(i,1,n) cin >> a[i];
	int l = -100, r = 100;
	while(r-l > 1) {
		int mid = (r+l)>>1;
		if(calc(mid-1) > calc(mid)) l = mid;
		else r = mid;
	}
	cout << min(calc(r),calc(l)) << endl;
//	cerr << calc(l) << " " << l << endl;
//	cerr << calc(r) << " " << r << endl;
	return 0;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int ModInverse(int a,int m)
{
	int x=1;
	for(int b=m,u=0;b;){
		ll t=a/b;
		swap(a-=b*t,b);
		swap(x-=u*t,u);
	}
	return (x+m)%m;
}

struct ModOperation{
	int p;
	vi fact,ifact;
	vvi pmemo,cmemo;
	ModOperation(int p):p(p),fact(p),ifact(p),pmemo(p,vi(p,-1)),cmemo(p,vi(p,-1)){
		fact.resize(p);
		fact[0]=1;
		repi(i,1,p)
			fact[i]=ll(fact[i-1]*i)%p;
		ifact.resize(p);
		rep(i,p)
			ifact[i]=ModInverse(fact[i],p);

		rep(i,p){
			pmemo[i][0]=1;
			repi(j,1,p)
				pmemo[i][j]=(ll)pmemo[i][j-1]*i%p;
		}

		rep(i,p)
			rep(j,i+1)
				cmemo[i][j]=(ll)fact[i]*ifact[i-j]%p*ifact[j]%p;
	}
	int pow(int a,int r){
		return pmemo[a][r];
	}
	int choose(int n,int r){
		return cmemo[n][r];
	}
};

// (1-pow(x-i,p-1)) mod p
vi calc(ModOperation& mo,int i,int p)
{
	vi c(p);
	rep(j,p){
		ll t=ll(j%2==0?1:-1)*mo.choose(p-1,j)*mo.pow(i,p-1-j);
		c[j]=(t%p+p)%p;
	}
	c[0]=(1-c[0]+p)%p;
	repi(j,1,p)
		c[j]=(-c[j]+p)%p;
	return c;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int p;cin>>p&&p;){
		vi a(p);
		rep(i,p) cin>>a[i];

		ModOperation mo(p);

		vi b(p);
		rep(i,p) if(a[i]){
			vi c=calc(mo,i,p);
			rep(j,p)
				(b[j]+=c[j])%=p;
		}

		rep(i,p)
			cout<<b[i]<<"\n "[i+1<p];
	}
}


Measured memory_bytes: 70912
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
using namespace std;
#define F first
#define S second
const int INF = 1 << 31, MAX_N = 5000;
typedef pair<int, int> P;

void dijkstra();
void bfs(int s, int dis, int cost);
int n, k;
vector<int> road[MAX_N + 1];
int taxi[MAX_N + 1][2];
int reach[MAX_N + 1];

int main(){
	fill(reach + 2, reach + MAX_N + 1, INF);
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
		scanf("%d%d", &taxi[i][0], &taxi[i][1]);
	}
	for (int i = 0; i < k; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		road[a].push_back(b);
		road[b].push_back(a);
	}
	dijkstra();
	cout << -reach[n] << endl;
	return 0;
}

priority_queue<P> pq;

void dijkstra(){
	bfs(1, taxi[1][1], -taxi[1][0]);
	while (!pq.empty()){
		P p = pq.top();
		pq.pop();
		if (reach[p.S] < p.F){
			reach[p.S] = p.F;
			bfs(p.S, taxi[p.S][1], p.F - taxi[p.S][0]);
		}
	}
}



void bfs(int s, int dis, int cost){
	queue<P> que;
	bool rea[5001] = {};
	que.push(P(s, dis));
	while (!que.empty()){
		P p = que.front();
		que.pop();
		if (p.S){
			for (int i = 0; i < road[p.F].size(); i++){
				if (!rea[road[p.F][i]]){
					rea[road[p.F][i]] = 1;
					que.push(P(road[p.F][i], p.S - 1));
						if (reach[road[p.F][i]] < cost){
						pq.push(P(cost, road[p.F][i]));
					}
				}
			}
		}
	}
}

Measured memory_bytes: 67640
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	cout<<(n/2)*(n/2+n%2)<<"\n";
	return 0;
}






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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i <= b; i++)


int main() {
	int N;
	pi cards;
	
	cin >> N;
	int n;
	for(int i = 0; i < N; i++){
		cin >> n;
		cards.PB(n);
	}
	sort(cards.begin(), cards.end());
	reverse(cards.begin(), cards.end());
	int al = 0;
	int bob = 0;
	for(int i = 0; i < N; i++){
		if(i % 2 == 0){
			al += cards[i];
		}
		else{
			bob += cards[i];
		}
	}
	cout << al - bob << "\n";

}


Measured memory_bytes: 384
import java.util.Scanner;
//【156A】
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	int ans =digCount(sc.nextInt(),sc.nextInt());
	System.out.println(ans);
	
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
	//----------------------------------------
	//置き場
	static int digCount(int n,int k) {
		int res = 0;
		while(n > 0) {
			res ++;
			n /= k;
			}
		return res;
	}
	//----------------------------------------
}

Measured memory_bytes: 21844
#include<cstdio>
#include<vector>

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

using namespace std;

typedef	vector<int>	vi;

int main(){
	const int Ne=1200;
	static bool er[Ne]; er[0]=er[1]=true;
	for(int i=2;i*i<Ne;i++) if(!er[i]) for(int j=i*i;j<Ne;j+=i) er[j]=true;
	vi p; rep(i,Ne) if(!er[i]) p.pb(i);

	static int cnt[196][15][1121];	cnt[0][0][0]=1;
	rep(i,p.size()){
		if(i>0){
			rep(k,15)rep(j,1121)	cnt[i][k][j]=cnt[i-1][k][j];
		}
		for(int k=min(i+1,14);k>=1;k--){
			for(int j=p[i];j<=1120;j++){
				if(cnt[i][k-1][j-p[i]]>0)	cnt[i][k][j]+=cnt[i][k-1][j-p[i]];
			}
		}
	}

	for(int n,k;scanf("%d%d",&n,&k),n;)	printf("%d\n",cnt[p.size()-1][k][n]);

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    string S;int K;
    cin>>S>>K;
    map<string,int>memo;
    for(int i=1;i<=K;i++){
        for(int j=0;j+i<=S.size();j++){
            string D=S.substr(j,i);
            memo[D]++;
        }
    }
    auto it=memo.begin();
    advance(it,K-1);
    cout<<it->first<<endl;
}

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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }




void solve(void)
{
  int N;cin>>N;
  int flg = 0;
  for (int i = 0; i < N; i++)
  {
    int X;cin>>X;
    if(X%2 == 1)flg = 1;
  }
  if(flg)
  {
    cout<<"first"<<endl;
  }
  else
  {
    cout<<"second"<<endl;
  }
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL MOD = 998244353;
vector<LL> base;
template <bool P = 0> struct SegmentTree {
  #define lson L, R, N[u].l
  #define rson L, R, N[u].r
  #define OUT R <= N[u].L || N[u].R <= L
  #define IN  L <= N[u].L && N[u].R <= R
  struct Node { int L, R, l, r;
    LL v; int chg;
  };
  vector<Node> N; int p, n; vector<int> rt;
  inline void init(int _n) { N.resize(_n * (P ? 40:4));
    n = _n; p = 1; rt.assign(1, build(0, n));
  }
  inline int copy(Node u) { return N[p] = u, p++; }
  int build(int L, int R) {
    int u = copy({L, R}), M = (L + R) >> 1;;
    if (R - L == 1) return u;
    return pull(u, build(L, M), build(M, R));
  }
  inline int push(int u) {
    if (N[u].chg) {
        LL x = base[N[u].R - 1];
        if (N[u].L - 1 >= 0)
            x -= base[N[u].L - 1];
        x += MOD; x %= MOD;
        N[u].v = (N[u].chg * x) % MOD;
        if (N[u].l) {
            N[N[u].l].chg = N[u].chg;
        }
        if (N[u].r) {
            N[N[u].r].chg = N[u].chg;
        }
        N[u].chg = 0;
    }
    return u;
  }
  inline int pull(int u, int l, int r) {
    if (!l || !r) return l ? l : r;
    N[u].L = N[l].L; N[u].R = N[r].R;
    push(N[u].l = l); push(N[u].r = r);
    N[u].v = (N[l].v + N[r].v) % MOD;
    return u;
  }
  int m(int L, int R, int u, LL v) {
    if (OUT) return u; push(u);
    if (P) u = copy(N[u]);
    if (IN) return N[u].chg = v, u;
    return pull(u, m(lson, v), m(rson, v));
  }
  int q(int L, int R, int u) {
    if (OUT) return 0; push(u); if (IN) return u;
    return pull(copy(N[u]), q(lson), q(rson));
  }
  inline void modify(int L, int R, int ver, LL v) {
    rt[ver] = m(L, R, rt[ver], v);
  }
  inline Node& query(int L, int R, int ver) {
    if (!P) p = 2 * n; return N[q(L, R, rt[ver])];
  }
};
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    base.assign(2e5 + 5, 0);
    base[0] = 1;
    LL x = 1;
    for (int i = 1 ; i < 2e5 + 5 ; i++) {
        x *= 10; x %= MOD;
        base[i] = base[i - 1] + x;
        base[i] %= MOD;
    }
    int n, q; cin >> n >> q;
    SegmentTree sol; sol.init(n);
    sol.modify(0, n, 0, 1);
    while (q--) {
        int l, r, v; cin >> l >> r >> v;
        l = n - l;
        r = n - r;
        swap(l, r);
        r++;
        sol.modify(l, r, 0, v);
        cout << sol.query(0, n, 0).v << '\n';
    }
}


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

using namespace std;

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

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

    int sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
tbl = [ [True for i in range(13)] for j in range(4) ]
n = int(input())
for i in range(n):
 S,C = input().split()
 c = int(C)
 if S=="S":
  s = 0
 elif S=="H":
  s = 1
 elif S=="C":
  s = 2
 elif S=="D":
  s = 3
 tbl[s][c-1] = False
for s in range(4):
 for c in range(13):
  if tbl[s][c]:
   if s==0:
    S="S"
   elif s==1:
    S="H"
   elif s==2:
    S="C"
   elif s==3:
    S="D"
   print(" ".join([S,str(c+1)]))




Measured memory_bytes: 5604
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .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")
}
use std::cmp::max;
fn main() {
    let n = read::<usize>();
    let m = read::<usize>();

    let sum = n * m;
    
    if n == 1 && m == 1 {
        println!("{}", sum)
    } else if n == 1 || m == 1 {
        println!("{}", max(n, m) - 2)
    } else {
        println!("{}",sum - (2*(m+n) - 4));
    }
}

Measured memory_bytes: 4352
fn main() {
    proconio::input! {
        n: usize,
    }
    let mut r = vec![0u64; n];

    for x in 1.. {
        if x * x >= n {
            break;
        }
        for y in 1.. {
            if x * x + y * y >= n {
                break;
            }
            for z in 1.. {
                if x * x + y * y + z * z + x * y + y * z + z * x > n {
                    break;
                }
                r[x * x + y * y + z * z + x * y + y * z + z * x - 1] += 1;
            }
        }
    }
    for i in 0..n {
        println!("{}", r[i]);
    }
}


Measured memory_bytes: 2120