akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}

//-----CODE------//

void solve(void)
{
  int A,B;
  cin>>A>>B;
  string stra,strb;
  for (int i = 0; i < B; i++)
  {
    stra = stra + to_string(A);
  }

  for (int i = 0; i < A; i++)
  {
    strb = strb + to_string(B);
  }

  if(stoi(stra) > stoi(strb))
  {
    cout<<stra<<endl;
  }
  else
  {
    cout<<strb<<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(8);
  solve();

 
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
	int n, x[10001] = {}, min = 1000001, max = -1000001;
		long long int sum=0;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
		sum += x[i];
		if (min > x[i]) min = x[i];
		if (max < x[i]) max = x[i];
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

signed main()
{
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    int sum = 0;
    for(int i = 1; i <= n; i++)
    {
        if(i % 3 && i % 5) sum += i;
    }
    cout << sum << "\n";



}


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

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

    int firstMod = 7 % k;
    if (firstMod == 0)
    {
        cout << "1" << endl;
        return 0;
    }

    int modSum = firstMod;
    int currentMod = firstMod;
    int ans = 2;
    while (true)
    {
        currentMod = (currentMod * 10) % k + (7 % k);
        currentMod %= k;
        if (currentMod == 0)
        {
            break;
        }
        ans++;

        //ごまかす
        if (10000000 < ans)
        {
            ans = -1;
            break;
        }
    }

    cout << ans << endl;
}




Measured memory_bytes: 3624
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BC.readInteger) . BC.words <$> BC.getLine
main = do
    [_,t] <- readIntegers
    ts <- readIntegers
    print $ (+t) . sum . map (min t) $ zipWith subtract ts (tail ts)

Measured memory_bytes: 4988
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int out=inf;
	cmin(out,abs(a+b-c-d));
	cmin(out,abs(a-b+c-d));
	cmin(out,abs(a-b-c+d));
	cmin(out,abs(-a+b+c-d));
	cmin(out,abs(-a+b-c+d));
	cmin(out,abs(-a-b+c+d));
	
	cout<<out<<endl;
}









Measured memory_bytes: 3204
#include <iostream>
using namespace std;
const int maxn = 4010;
char s[maxn];
int num[3];
int main()
{
	long long n, i, ans = 0;
	cin >> n >> s;
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'R')
			num[0]++;
		else if (s[i] == 'G')
			num[1]++;
		else if (s[i] == 'B')
			num[2]++;
	}
	ans = num[0] * num[1] * num[2];
	if (ans == 0)
	{
		cout << ans << endl;
		return 0;
	}
	for (long long distance = 1; distance <= n / 2; distance++)
	{
		for (i = 0; i < n; i++)
		{
			int j = i + distance;
			int k = j + distance;
			if (k >= n)
				break;
			if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i])
			{
				ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3200
#include <atcoder/scc>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    scc_graph g(n);

    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        g.add_edge(u, v);
    }

    auto scc = g.scc();

    printf("%d\n", int(scc.size()));
    for (auto v : scc) {
        printf("%d", int(v.size()));
        for (int x : v) {
            printf(" %d", x);
        }
        printf("\n");
    }

    return 0;
}


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

int main() {
  string S; cin >> S;
  bool is_YYMM = false;
  bool is_MMYY = false;
  int s = stoi(S);
  if (s % 100 >= 1 && s % 100 <= 12) {
    is_YYMM = true;
  }
  if (s >= 100 && s <= 1299) {
    is_MMYY = true;
  }
  if (is_YYMM && is_MMYY) {
    cout << "AMBIGUOUS" << endl;
  }
  else if (is_YYMM) {
    cout << "YYMM" << endl;
  }
  else if (is_MMYY) {
    cout << "MMYY" <<endl;
  }
  else if (!is_YYMM && !is_MMYY) {
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    string s;
    cin>>s;
    if(s.size()==6){
        if(s[2]==s[3] && s[4]==s[5]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import           Control.Monad.Trans.State.Strict
import qualified Data.ByteString.Char8            as B
import           Data.Char
import           Data.Coerce
import qualified Data.List                        as L

main :: IO ()
main = do
    [n, m] <- map read.words <$> getLine :: IO [Int]
    pairs <- map (\(x,y)->(x-1,y-1)).L.unfoldr (runStateT parseInt2) <$> B.getContents
    print $ solve pairs

inf :: Int
inf = 0x3f3f3f3f

solve :: [(Int, Int)] -> Int
solve pairs = go 0 inf $ L.sort pairs
  where
    go !res minR ((l, r):lrs)
        | minR <= l = go (res + 1) inf ((l, r):lrs)
        | otherwise = go res (min minR r) lrs
    go res minR []
        | minR == inf = res
        | otherwise = res + 1

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = coerce $ B.readInt . B.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = (,) <$> parseInt <*> parseInt

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = (,,) <$> parseInt <*> parseInt <*> parseInt


Measured memory_bytes: 34172
# coding: utf-8
# Your code here!
N=int(input())

P=list(map(float,input().split()))

dp=[[0 for i in range(N+1)] for j in range(N+1)]
dp[0][0]=1

for i in range(N):
    for j in range(N-i):
        dp[i+1][j]+=dp[i][j]*P[i+j]
        dp[i][j+1]+=dp[i][j]*(1-P[i+j])        

ans=0
start=(N+1)//2
j=0
for i in range(start,N+1)[::-1]:
    ans+=dp[i][j]
    j+=1
print(ans)
#print(dp)




Measured memory_bytes: 270344
from bisect import bisect_left
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sa = [0]*(n+1)
sb = [0]*(m+1)
for i in range(n):
    sa[i+1] = sa[i] + a[i]
for j in range(m):
    sb[j+1] = sb[j] + b[j]
#print(sa)
#print(sb)
ans = 0
for i in range(n+1):
    if k - sa[i] >= 0:
        j = bisect_left(sb, k-sa[i])
        #print(k-sa[i])
        #print(j)
        if j <= m and k - sa[i] == sb[j]:
            ans = max(ans, i+j)
        else:
            ans = max(ans, i+j-1)
print(ans)

Measured memory_bytes: 110896
import sys

def main():
    N = int(input())
    A_list = list(map(int, input().split()))

    h_list = [0] * N

    for i, i_A in enumerate(A_list):
        if i - i_A >= 0:
            h_list[i-i_A] += 1

    total_pair = 0
    for i, i_A in enumerate(A_list):
        if i+i_A <= N-1:
            total_pair += h_list[i+i_A]

    print(total_pair)
    return
    
if __name__ == '__main__':
    main()
    sys.exit(0)

Measured memory_bytes: 92844
x = int(input())
li = list(map(int, input().split()))
k = 1
s = 0
for i in range(len(li)):
    if k == li[i] :
        k += 1
        s += 1
    if i == len(li)-1 and k == 1:
        s = len(li) + 1
print(len(li)-s)

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

int main() {
    int n,g;
    char a;
    bool array[4][13] = {};
    cin >> g;
    for (int i = 0; i < g;i++){
        cin >> a >> n;
        if(a == 'S') array[0][n -1] = true;
        if(a == 'H') array[1][n -1] = true;
        if(a == 'C') array[2][n -1] = true;
        if(a == 'D') array[3][n -1] = true;
    }
    for(int i=0;i<4;i++) {
        for(int j=0;j<13;j++) {
            if(array[i][j]) continue;
            
            if(i==0) a = 'S';
            if(i==1) a = 'H';
            if(i==2) a = 'C';
            if(i==3) a = 'D';
            
            cout << a << ' ' << j+1 << endl;
        }
    }
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int f[(1<<26)+10];
const int oo=1e9;
int main(){
  for(int i=0;i<(1<<26);i++)f[i]=oo;
  string s;
  cin>>s;
  int h=0,fi;
  f[0]=0;
  for(char ch:s){
    h^=( 1<<(ch-'a') );
    fi=1+f[h];
    for(int i=0;i<26;i++){
      int m=(h^(1<<i));
      fi=min(fi,1+f[m]);
    }
    f[h]=min(f[h],fi);
  }
  printf("%d\n",fi); 
  return 0;
}


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

int main(void){
  int c[3][3];
  bool flag = false;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }
  int b0, b1, b2, a0, a1, a2;
  //a0を0-100で固定。1行目からb0 - b2の値を決定
  for(a0 = 0; a0 <= 100; a0++){
    b0 = c[0][0] - a0;
    b1 = c[0][1] - a0;
    b2 = c[0][2] - a0;
    //1列目からa1 - a2を決定
    a1 = c[1][0] - b0;
    a2 = c[2][0] - b0;
    //残り4つの成分をチェック
    if(c[1][1] == a1 + b1 && c[1][2] == a1 + b2
      && c[2][1] == a2 + b1 && c[2][2] == a2 + b2){
        flag = true;
        break;
      }
  }
  if(flag){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int h[n],dp[n];
	rep(i,n)cin>>h[i];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	rep(i,n){
		if(i<2)continue;
		dp[i]=min({dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i])});
	}
	cout<<dp[n-1]<<endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++)
		cin >> l[i];
	
	int count = 0;
	for (int i = 0; i < n - 2; i++)
		for (int j = i + 1; j < n - 1; j++)
			for (int k = j + 1; k < n; k++)
			{
				if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k])
					continue;
				if ((l[i] + l[j] > l[k]) && (l[i] + l[k] > l[j]) &&
					(l[j] + l[k] > l[i]))
					count++;
			}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3632
import os
import sys
from io import BytesIO, IOBase
from math import ceil
def main():
    n,x,t=map(int,input().split())
    print(ceil(n/x)*t)
# region fastio
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef priority_queue<P,vector<P>,greater<P> > PQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;

ll gcd(ll a,ll b){
    if(!b) return a;
    else return gcd(b,a%b);
}

int main(){
    ll x,y;
    cin >> x >> y;
    cout << gcd(x,y) << endl;
    return 0;
}



Measured memory_bytes: 3108
import java.io.*;
import java.util.ArrayList;

class Main{

    static int N;
    static ArrayList<ArrayList<Integer>> shop = new ArrayList<>();
    static ArrayList<ArrayList<Integer>> P = new ArrayList<>();
    static int[] a = new int[10];
    static int ans = Integer.MIN_VALUE;

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        N = Integer.parseInt(str);
        ArrayList<Integer> sp = new ArrayList<>();
        for (int i=0;i<N;i++){
            str = br.readLine();
            sp.clear();
            for (String s:str.split(" ")){
                sp.add(Integer.parseInt(s));
            }
            shop.add((ArrayList<Integer>)sp.clone());
        }
        ArrayList<Integer> c = new ArrayList<>();
        for (int i=0;i<N;i++){
            str = br.readLine();
            c.clear();
            for (String s:str.split(" ")){
                c.add(Integer.parseInt(s));
            }
            P.add((ArrayList<Integer>)c.clone());
        }
        dfs(0);
        dfs(1);
        System.out.println(ans);
    }

    static void func(){
        int cnt = 0;
        for (int i:a){
            if (i==1){
                cnt++;
            }
        }
        if (cnt==0){
            return;
        }
        int score = 0;
        for (int i=0;i<N;i++){
            cnt = 0;
            for (int j=0;j<10;j++){
                if (a[j]==1 && shop.get(i).get(j)==1){
                    cnt++;
                }
            }
            score += P.get(i).get(cnt);
        }
        
        ans = Math.max(ans,score);
    }

    static void dfs(int pos){
        if (pos==10){
            func();
        } else {
            a[pos] = 0;
            dfs(pos+1);
            a[pos] = 1;
            dfs(pos+1);
        }
    }
}

Measured memory_bytes: 24020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d;
    double  x,y;
    cin>>a>>b>>c;
    d=c-a-b;
    if(d>0 && (d*d>(4*a*b)))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,p=0;
  cin>>n;
  char s[n];
  for(int i=0;i<n;i++)
    cin>>s[i];
  for(int i=0;i<n;i++)
  {
    if(s[i]==s[i+1])
      p++;
  }
  cout<<n-p;
  return 0;
}

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

using namespace std;

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

	int ans = 0;
	int n;
	int a , s;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a >> s;
		ans += s - a + 1;
	}
	cout << ans << endl;

}

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

int main() {

  int64_t a, b, c; 
  cin >> a >> b >> c;


  int64_t check = 0;

  if (c <= a+b) check = 0;
  else check = c*c - 2*c*(a+b) + (a+b)*(a+b) - 4*a*b;
  
  if (check > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


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

signed main(void)
{
	int n, m, cnt, ans;
	cin >> n >> m;
	vector<int> s[m];
	int p[m];
	bool ok;

	rep(i, m)
	{
		int k;
		cin >> k;
		rep(j, k)
		{
			int st;
			cin >> st; 
			s[i].push_back(st);
		}
	}
	rep(i, m) cin >> p[i];
	ans = 0;
	for(int bit = 0; bit < (1 << n); bit++)
	{
		vector<int> v;
		for(int i = 0; i < n; i++)
		{
			if (bit & (1 << i))
			{
				v.push_back(i + 1);
			}
		}
		ok = true;
		rep(j, m)
		{
			cnt = 0;
			rep(k, s[j].size())
			{
				rep(i, v.size())
				{
					if (v[i] == s[j][k])
						cnt++;
				}
			}
			if (cnt % 2 != p[j])
				ok = false;
		}
		if (ok) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int n;
ll x,a[400001],sum[400001];
int main() {
	scanf("%d%lld",&n,&x);
	fdn(i,n,1,1)scanf("%lld",a+i);
	fup(i,1,2*n,1)sum[i]=sum[i-1]+a[i];
	ll ans=INF;
	fup(k,1,n,1)
	{
		ll t=k*x+5*sum[k];
		for(int i=2;(i-1)*k<=n;i++)
		{
			t+=(sum[i*k]-sum[(i-1)*k])*(2*i+1);
			if(t>=INF)
			{
				t=INF;
				break;
			}
		}
		if(t!=INF)ans=min(ans,t);
	}
	printf("%lld",ans+x*n);
}

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
const int INF = 10000000,MAX = 21;
int main(){
	int n,m,edge[MAX][MAX],a,b,c,d,s,g,p,pp;
	cin >> n >> m;
	for(int i = 0;i < MAX;++i){
		for(int j = 0;j < MAX;++j){
			edge[i][j] = INF;
		}
		edge[i][i] = 0;
	}
	for(int i = 0;i < m;++i){
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		edge[a][b] = c;
		edge[b][a] = d;
	}
	scanf("%d,%d,%d,%d",&s,&g,&p,&pp);
	p -= pp;
	for(int k = 1;k <= n;++k){
		for(int i = 1;i <= n;++i){
			for(int j = 1;j <= n;++j){
				edge[i][j] = min(edge[i][j],edge[i][k] + edge[k][j]);
			}
		}
	}
	cout << p - (edge[s][g] + edge[g][s]) << endl;
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var n,k int
	fmt.Scan(&n,&k)
	
	rem := n % k
	fmt.Println(min(rem,abs(rem,k)))
	
}

func min(num1,num2 int)int {
	if num1 < num2 {
		return num1
	}
	return num2
}

func abs(num1,num2 int) int{
	ans := num1 - num2
	if ans < 0 {
		ans = -ans
	}
	return ans
}

Measured memory_bytes: 1756
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n;
pair<ll, ll> a[100005];

bool cmp(pair<ll, ll> b, pair<ll, ll> c){
	return ((b.fi - b.se) < (c.fi - c.se));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n;
	ll sum = 0, sum1 = 0;
	rep(i, n) cin >> a[i].fi, sum += a[i].fi;
	rep(i, n) cin >> a[i].se, sum1 += a[i].se;
	if(sum < sum1){
		cout << -1 << endl;
		return 0;
	}
	ll tot = sum - sum1;
	int ans = 0;
	sort(a, a + n, cmp);
	rep(i, n){
		if(a[i].fi - a[i].se >= 0){
			if(tot < (a[i].fi - a[i].se)) break;
			else{
				ans++;
				tot -= a[i].fi - a[i].se;
			}
		}
	}
	cout << n - ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define ll long long 
#define mp make_pair
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0) 
#define sz(a) (a).size()
#define triple pair<pill, ll>
#define pinode pair<node*, node*>
#define quadra pair<pill, pill>
using namespace std;

/*
 tips :
 Sqrt opt
 Binary search
 Try to find the easiest solution
 Recursiya
 FUCK YOU pishi kod akuratnee daun yobani
 sdohni v adu nahui blyat' y ub'uy tebya
 esli ti blyad' budesh pisat' kod gryaznim
 to ya tebya v rot viebu
*/

const ll N = 1e6 + 10;
const ll big = 1e18;
const ll shift = 1000;
const ll block = 500;
const long long mod = 1e9 + 7;

ll dp[N];
ll F[N];
ll pw[N];
ll bp(ll a, ll b) {
	ll ans = 1;
 	while(b) {
 	 	if(b&1)
 	 		ans = ans * a % mod;
		b >>= 1;
		a = a * a % mod;
 	}
 	return ans;
}

ll inv(ll a) {
 	return bp(a, mod - 2);
}

ll C(ll n, ll k) {
 	return F[n] * inv(F[k] * F[n - k] % mod) % mod;
}

int main() {	
  	speed;
	ll n;
	cin >> n;
	F[0] = pw[0] = 1;
	for(int i = 1; i <= n; i++)
		F[i] = i * F[i - 1] % mod, pw[i] = pw[i - 1] * 8 % mod;
	ll ans = 1;
	for(int i = 1; i <= n; i++) 
		ans *= 10ll, ans %= mod;
	ans = (ans - pw[n] + mod) % mod;
	for(int j = 1; j <= n; j++) {
	 	ll z = C(n, j) * pw[n - j] % mod;
	 	z = z * 2 % mod;
	 	ans = (ans - z + mod) % mod;
	}
	cout << ans;
}             

/*

*/          

Measured memory_bytes: 19232
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;
ll K;
char ans;

void solve(){
    ans = '1';

    for(int i = 0;i < K; i++){
        if(S[i] != '1'){
            ans = S[i];
            break;
        }
    }
    
    cout << ans << endl;
}

int main(){
    cin >> S >> K;

    solve();
}


Measured memory_bytes: 256
//解説AC
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main(){
ll N,Q; cin >> N >> Q;
  
  vector<pair<ll,pair<ll,ll>>>v;
  //挿入を-1,クエリを0,削除を1とする
  for(ll i = 0; i < N; i++){
    ll s,t,x; cin >> s >> t >> x;
    v.push_back(make_pair(s-x,make_pair(-1,x)));
    v.push_back(make_pair(t-x,make_pair(0,x)));
  }
  
  for(ll j = 0; j < Q; j++){
    ll d; cin >> d;
    v.push_back(make_pair(d,make_pair(1,j)));} 
  
  sort(v.begin(),v.end());
  
  multiset<ll> se;
  vector<ll> answer(Q);
  
  sort(v.begin(),v.end());
  
  for(auto ne : v){ 
    ll p = ne.first;
    ll q = ne.second.first;
    ll r = ne.second.second;
    
    if( q == -1){//挿入
      se.insert(r);}
    else if( q == 0){//削除
      se.erase(se.lower_bound(r));}
    else{// クエリ　seがすでに空だったら-1をres[r]に入れないといけない
       answer[r] = (se.empty() ? -1 : *(se.begin()));} 
  }
  
  for(ll k = 0; k < Q; k++){
    cout << answer[k] << endl;}
    
    return 0;}
  

Measured memory_bytes: 27108
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double 
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t; t=1; //cin>>t;
	while(t--){
		int n; cin>>n;
		while(n!=0){
			if(n%10==7) {
				cout<<"Yes\n";
				return 0;
			}
          n/=10;
		}
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b>>c;
  cout<<min(a*b,c)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(x,to) for(x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;

bool chks(int a, int b, int c){
	if( a * a == b * b + c * c ) return true;
	if( b * b == a * a + c * c ) return true;
	if( c * c == b * b + a * a ) return true;
	return false;
}

int main(void){

int N,i;
bool sss;
	cin >> N;
	vector<vector<int> > s(N,vector<int>(3));

	rep(i,N) cin >> s[i][0] >> s[i][1] >> s[i][2];
	rep(i,N){
		sss = chks(s[i][0] , s[i][1] , s[i][2]);
		cout << (sss? "YES": "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
                int h = a/60/60;
                int m =  (a % 3600)/60;
                int s = a - (h*3600) - (m*60);
                System.out.println(h +":"+m +":"+s);
	}
}

Measured memory_bytes: 26344
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;

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

    ll minl = 0;
    for(int i = 0; i < N; ++i){
        for(int j = i+1; j < N; ++j){
            minl += a[i][j];
            for(int k = 0; k < N; ++k){
                if(k == i || k == j) continue;
                if(a[i][j] > a[i][k] + a[k][j]){
                    cout << -1 << endl;
                    return 0;
                }else if(a[i][j] == a[i][k] + a[k][j]){
                    minl -= a[i][j];
                    break;
                }
            }
        }
    }
    cout << minl << endl;
    return 0;
}

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

int main(){
  long long mod = 1000000007;
  int s;
  cin >> s;
  int n = s/3;
  long long dp[n+1][s+1];
  memset(dp,0,sizeof dp);
  
  dp[0][0] = 1;
  for(int pos = 1; pos <= n; pos++){
    for(int prev_sum = 0; prev_sum <= s; prev_sum++){
      for(int digit = 3; digit <= s; digit++){
        if(prev_sum+digit <= s){
          dp[pos][prev_sum+digit] += dp[pos-1][prev_sum];
          dp[pos][prev_sum+digit] %= mod;
        }
        else
          break;
      }
    }
    
    for(int prev_sum = 0; prev_sum <= s; prev_sum++){
      dp[pos][prev_sum] %= mod;
    }
  }
  
  long long ways = 0;
  for(int pos = 1; pos <= n; pos++){
    ways += dp[pos][s];
    ways %= mod;
  }
  
  cout << ways << '\n';
}

Measured memory_bytes: 13932
#include<stdio.h>
int main() {
  int n,a[101],i,j;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&a[i]);
  int cnt=0;
  for(i=0; i<n; i++) {
    for(j=n-1; j>i; j--) {
      if(a[j]<a[j-1]) {
    int tmp=a[j];
    a[j]=a[j-1];
    a[j-1]=tmp;
    cnt++;
      }
    }
  }
  for(i=0; i<n; i++) {
    if(i) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",cnt);
  return 0;
}


Measured memory_bytes: 2000
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int n,m;
int cx,cy;
int dx,dy;
int c;
int arr[5]={-2,-1,0,1,2};
char mat[1001][1001];
bool vis[1001][1001];
int lead[1001][1001];
int a[5]={0,1,0,-1,0};
void dfs(int x,int y){
	lead[x][y]=c;
	vis[x][y]=1;
	for(int i=0;i<4;i++){
        int chx=x+a[i];
        int chy=y+a[i+1];
        if(chx>0&&chx<=n&&chy>0&&chy<=m){
        	if(!vis[chx][chy]&&mat[chx][chy]!='#'){
        		dfs(chx,chy);
        	}
        }
	}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
 cin>>n>>m;
 cin>>cx>>cy;
 cin>>dx>>dy;
 for(int i=1;i<=n;i++){
 	for(int j=1;j<=m;j++){
 		cin>>mat[i][j];
 	}
 }
 memset(vis,0,sizeof(vis));
 memset(lead,-1,sizeof(lead));
 c=1;
 vector<vector<int> >adj(1000001);
 for(int i=1;i<=n;i++){
 	for(int j=1;j<=m;j++){
 		if(mat[i][j]=='#')continue;
 		if(!vis[i][j]){
 			dfs(i,j);
 			c++;
 		}
 	}
 }
 map<pii,bool>ma;
 for(int i=1;i<=n;i++){
 	for(int j=1;j<=m;j++){
 		if(lead[i][j]==-1)continue;
 		int a=lead[i][j];
 		for(int k=0;k<5;k++){
 			for(int l=0;l<5;l++){
 				int chx=i+arr[k];
 				int chy=j+arr[l];
 			    if(chx>0&&chx<=n&&chy>0&&chy<=m){
 			    	if(lead[chx][chy]==-1)continue;
 			    	int b=lead[chx][chy];
 			    	if(!ma[mk(a,b)]){
 			    		adj[a].pb(b);
 			    		adj[b].pb(a);
 			    		ma[mk(a,b)]=true;
 			    		ma[mk(b,a)]=true;
 			    	}
 			    }
            }
        }
    }
}
 queue<int>q;
 int d[1000001];
for(int i=0;i<1000001;i++)d[i]=1e9;
	d[lead[cx][cy]]=0;
bool hog[1000001];
memset(hog,0,sizeof(hog));
hog[lead[cx][cy]]=1;
q.push(lead[cx][cy]);
while(!q.empty()){
	int u=q.front();
	q.pop();
	if(u==lead[dx][dy]){
		break;
	}
	for(int i=0;i<adj[u].size();i++){
		int ch=adj[u][i];
		if(!hog[ch]){
			hog[ch]=1;
			d[ch]=1+d[u];
			q.push(ch);
		}
	}
}
if(d[lead[dx][dy]]>=1e9)cout<<-1<<endl;
else cout<<d[lead[dx][dy]]<<endl;
return 0;
}

Measured memory_bytes: 74908
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int a[10];
int main()
{
  int flag = 1;
  for (int i = 0; i < 6; i++)
  {
    scanf("%d", &a[i]);
  }

  for (int i = 0; i < 5; i++)
  {
    for (int j = i + 1; j < 5; j++)
    {
      if (abs(a[i] - a[j]) > a[5])
      {
        flag = 0;
        break;
      }
    }
  }
  puts(flag ? "Yay!" : ":(");
  return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case)]
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 reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
use std::collections::HashSet;
 
const MOD : u64 = 1_000_000_000 + 7;
 
fn main() {
    
    let n = read::<usize>();
    let k = read::<i64>();
    let q = read::<usize>();
    
    let a : Vec<usize> = (0..q).map(|_| read::<usize>() - 1 ).collect();
    
    let mut point = vec![0i64; n];
    
    for p in a {
        point[p] += 1;
    }
    
    for item in point {
        if k - (q as i64 - item) > 0 {println!("Yes");}
        else {println!("No");}
    }
}

Measured memory_bytes: 6780
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000
#define MOD 1000000007

int main(){

    int n,tmp;
    cin >> n;
    vector<int> a(MAX_A,0);

    REP(n){
        cin >> tmp;
        a[tmp]++;
    }
    /*REP(n){
        cout << a[i] << endl;
    }*/

    int ans = 1;
    bool exist = true;
    if(n%2 == 0){//偶数
        //cout << "a" << endl;
        for(int i = 1;i < n;i+=2){
            if(a[i]%2 != 0){
                //cout << "n" << endl;
                exist = false;
            }
        }
        if(exist){
            for(int i = 1;i < n;i+=2){
                ans = (ans*2)%MOD;
            }
        }
    }else{//奇数

        if(a[0]%2 != 1){
            exist = false;
        }
        for(int i = 2;i < n;i+=2){
            if(a[i]%2 != 0){
                exist = false;
            }
        }
        if(exist){
            for(int i = 2;i < n;i+=2){
                ans = (ans*2)%MOD;
            }
        }
    }

    if(exist){
        cout << ans << endl;
    }else{
        cout << "0" << endl;
    }






    return 0;
}

Measured memory_bytes: 4096
N = int(input())
S = str(input())
cl = [0]*N
for i in range(1,N):
  Y = S[i:]
  X = S[:i]
  X = list(set(X))
  Y = list(set(Y))
  count = 0
  for j in range(len(X)):
    for k in range(len(Y)):
      if X[j] == Y[k]:
        count += 1
  cl[i] = count

print(max(cl))

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>

using namespace std;

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	for (int i = 1; i <= dy; i++) {
		cout << "U";
	}
	for (int i = 1; i <= dx; i++) {
		cout << "R";
	}
	for (int i = 1; i <= dy; i++) {
		cout << "D";
	}
	for (int i = 1; i <= dx; i++) {
		cout << "L";
	}

	cout << "L";
	for (int i = 1; i <= dy+1; i++) {
		cout << "U";
	}
	for (int i = 1; i <= dx+1; i++) {
		cout << "R";
	}
	cout << "D";

	cout << "R";
	for (int i = 1; i <= dy+1; i++) {
		cout << "D";
	}
	for (int i = 1; i <= dx+1; i++) {
		cout << "L";
	}
	cout << "U";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int a,b;
        scanf ("%d%d\n",&a,&b);
        if (a % 2 == 0){
        printf ("No");
        }
        else{
            if(b % 2 == 0){
                printf("No");
            }
            else{
                printf("Yes");
            }
        }
        return 0;
}

Measured memory_bytes: 128
from collections import Counter
n = int(input())
s = [input().rstrip() for _ in range(n)]
m = int(input())
t = [input().rstrip() for _ in range(m)]
sc = Counter(s)
tc = Counter(t)
for k in tc:
    sc[k] -= tc[k]

mc = sc.most_common(1)
if len(mc) and mc[0][1] > 0:
    print(mc[0][1])
else:
    print(0)


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++)cin >> a.at(i);
    sort(a.begin(), a.end());
    cout << a.at(n - 1) - a.at(0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int n; cin >> n; long res = 0;
    rep(i,n){
        long a; cin >> a;
        while(a > 0){
            if(a % 2 != 0) break;
            res++; a /= 2;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int total = 0;
		while (t-- > 0) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			total += r - l + 1;
		}

		System.out.println(total);
	}
}


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

using namespace std;

int main(){
    int k, n;
    cin >> k >> n;
    int a[n + 1];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    a[n] = a[0];
    int res = k;
    for (int i = 0; i < n - 1; i++){
        res = min(res, abs(a[i] + k - a[i + 1]));
    }
    res = min(res, a[n - 1] - a[0]);
    cout << res << endl;
    return 0;
}


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

int main()
{
	int N,M;
	cin >> N >> M;
	string S;
	cin >> S;
	int i = N;
	while (i > 0)
	{
		int temp;
		if (i - M < 0) temp = 0;
		else temp = i - M;
		bool flag = false;
		while (temp != i)
		{
			if (S[temp] == '0')
			{
				ans.push_back(i - temp);
				i = temp;
				flag = true;
				break;
			}
			temp++;
		}
		if (!flag)
		{
			 cout << "-1" << endl;
			 return 0;
		}
	}
	reverse(ans.begin(), ans.end());
	rep(i,ans.size())
	{
		if (i != 0) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

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

int main(void)
{
    
    long n = 0;
    long sum = 0;
    
    cin >> n;
    
    for(long i = 0; i <= n; i++)
    {
        if(i % 3 == 0 || i % 5 == 0 || i % 15 == 0)
        {
            
        }
        else
        {
            sum += i;
        }
    }
    
    cout << sum << endl;

}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
"""
Created on Wed Jun  3 18:19:05 2020

@author: NEC-PCuser
"""

S = input()

i = len(S)
ans = "YES"
while i > 0:
    if i >= 5 and (S[i-5:i] == 'dream' or S[i-5:i] == 'erase'):
        i -= 5
    elif i >= 7 and S[i-7:i] == 'dreamer':
        i -= 7
    elif i >= 6 and S[i-6:i] == 'eraser':
        i -= 6
    else:
        ans = "NO"
        break

print(ans)

Measured memory_bytes: 3316
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,k=MI()
    aa=LI1()
    pos=[-1]*n
    i=aa[0]
    pos[0]=0
    log=[0]
    j=1
    while pos[i]==-1:
        log.append(i)
        if j==k:
            print(log[-1]+1)
            exit()
        pos[i]=j
        i=aa[i]
        j+=1
    pre=pos[i]
    k-=pre
    t=len(log)-pre
    k%=t
    print(log[pre+k]+1)

main()

Measured memory_bytes: 32992
import numpy as np


n = int(input())
ajs_str = input().split()
ajs = [int(aj) for aj in ajs_str]

ajs_sorted = np.sort(ajs)[::-1]

score = ajs_sorted[0]
count = 1
current_idx = 1


max_idx = int( (n-2) / 2 )

for idx in range(1, 1+max_idx):
  score += 2 * ajs_sorted[idx]

if (n-2) % 2 != 0:
  score += ajs_sorted[1+max_idx]

print(score)

Measured memory_bytes: 52716
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> g(n, vector<int>(n, 0));
    int u, k;
    REP(i, n) {
        cin >> u >> k;
        u--;
        int v;
        REP(j, k) {
            cin >> v;
            v--;
            g[u][v] = 1;
        }
    }
    REP(i, n) {
        REP(j, n) {
            cout << g[i][j] << (j == n - 1 ? endl : ' ');
        }
    }
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      	string s;
      	cin>>s;
      
      	int len=0;
      	int ma=0;
      
      	for(int i=0;i<3;i++)
        {
          	if(s[i]=='R')
              	len++;
          	else
            {
              	ma=max(ma,len);
              	len=0;
            }
        }
      
      if(len)
      {
        	ma=max(ma,len);
      }
      cout<<ma<<endl;
      	return 0;
    }

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int A[200010];
int X[200010];
int Y[200010];

int C[200010];
int S[200010];

int main () {
  cin >> N >> M;
  for (auto i = 0; i < N; ++i) {
    cin >> A[i];
    A[i]--;
  }
  for (auto i = 0; i < M; ++i) {
    cin >> X[i] >> Y[i];
    X[i]--;
    Y[i]--;
  }
  // assert(N <= 200 && M <= 200);
  fill(C, C+200010, 0);
  fill(S, S+N, 0);
  for (auto i = 0; i < N; ++i) {
    C[A[i]]++;
  }
  /*
  for (auto i = 0; i < N; ++i) {
    cerr << C[i] << " ";
  }
  cerr << endl;
  */
  for (auto i = 0; i < N; ++i) {
    for (auto j = max(0, i-C[i]+1); j <= i; ++j) {
      S[j]++;
    }
  }
  int ans = 0;
  for (auto i = 0; i < N; ++i) {
    if (S[i] == 0) ++ans;
  }
  for (auto k = 0; k < M; ++k) {
    int before = A[X[k]];
    int after = Y[k];
    if (before != after) {
      int kezuru = before - C[before] + 1;
      int fuyasu = after - C[after];
      if (kezuru >= 0) {
        S[kezuru]--;
        if (S[kezuru] == 0) {
          ans++;
        }
      }
      if (fuyasu >= 0) {
        if (S[fuyasu] == 0) {
          ans--;
        }    
        S[fuyasu]++;      
      }
      C[before]--;
      C[after]++;
      A[X[k]] = after;
      /*
      cerr << "A: ";
      for (auto i = 0; i < N; ++i) {
        cerr << A[i] << " ";
      }
      cerr << endl;
      cerr << "S: ";
      for (auto i = 0; i < N; ++i) {
        cerr << S[i] << " ";
      }
      cerr << endl;
      */
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 5376
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int k,x,cnt=0;cin>>k>>x;
    int ans[20000];
    for(int i=x-k+1;i<x;i++){
        ans[cnt]=i;
        cnt++;
    }
    
    for(int i=x;i<x+k;i++){
    
        ans[cnt]=i;
        cnt++;
    }
    
    for(int i=0;i<cnt;i++){
        cout<<ans[i]<<' ';
    }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n;
vector<long long int> x,temp;
int main(){
  cin >> n;
  x.resize(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
    temp.push_back(x[i]);
  }
  sort(temp.begin(),temp.end());
  for(int i=0;i<n;i++){
    if(x[i]<temp[n/2]){
      cout << temp[n/2] << endl;
    }else{
      cout << temp[n/2-1] << endl;
    }
  }
}


Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
using INT = uint64_t;
int main() {
  INT H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
  }
  else {
    cout << ( H * W + 1) / 2 << endl;
  }
}

Measured memory_bytes: 256