akhauriyash/Code-Regression huggingface dataset:
//author : Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln "\n"
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << "[" << p.fi << ", " << p.se << "]";
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << " ";
	cout << "}" << ln;
}

const int N = 3e5 + 5;
int arr[N];
ll fwd[N],bwd[N];
ll sum = 0;

int main()
{
	FASTIO;
	int n;
	cin >> n;
	for(int i = 0;i < 3 * n;i++)
        cin >> arr[i];
    priority_queue<int,vector<int>,greater<int>> Q;
    for(int i = 0;i < 3 * n;i++)
    {
        if(Q.size() < n)
        {
            Q.push(arr[i]);
            sum += arr[i];
        }
        else if(arr[i] > Q.top())
        {
            sum += (arr[i] - Q.top());
            Q.pop();
            Q.push(arr[i]);
        }
        if(Q.size() == n)
            fwd[i] = sum;
    }

    sum = 0;
    while(!Q.empty())
        Q.pop();
    for(int i = 3 * n - 1;i >= 0;i--)
    {
        if(Q.size() < n)
        {
            Q.push(-arr[i]);
            sum += arr[i];
        }
        else if(Q.top() + arr[i] < 0)
        {
            sum += (arr[i] + Q.top());
            Q.pop();
            Q.push(-arr[i]);
        }
        if(Q.size() == n)
            bwd[i] = sum;
    }

    ll ans = -1e18;
    for(int i = n - 1;i < 2 * n;i++)
        ans = max(fwd[i] - bwd[i + 1],ans);
    cout << ans << ln;
	return 0;
}


Measured memory_bytes: 6136
main(){int q,w,e,a,s,d,z,x,c;scanf("%d%d%d%d%d%d%d%d%d",&q,&w,&e,&a,&s,&d,&z,&x,&c);puts((q-w==a-s&&a-s==z-x&&w-e==s-d&&s-d==x-c&&q-a==w-s&&w-s==e-d&&a-z==s-x&&s-x==d-c)?"Yes":"No");}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int h,w,k;
  cin >> h >> w >>k;
  string s[h];
  rep(i,h) cin >> s[i];
  int ans[h][w];
  int tmp=0;
  bool find=true;
  bool emp[h];
  rep(i,h) emp[i]=false;
  rep(hi,h){
    if(find){
      tmp++;
      find=false;
    }
    rep(wi,w){
      if(s[hi][wi]=='#'){
	if(find){
	  tmp++;
	  ans[hi][wi]=tmp;
	}
	else{
	  ans[hi][wi]=tmp;
	  find=true;
	}
      }
      else{
	ans[hi][wi]=tmp;
      }
    }
    if(!find){
      emp[hi]=true;
    }
  }
  rep(hi,h){
    if(!emp[hi]) continue;
    bool ed=false;
    for(int i=hi+1;i<h;i++){
      if(!emp[i]){
	rep(j,w){
	  ans[hi][j]=ans[i][j];
	}
	ed=true;
	break;
      }
    }
    if(!ed){
      for(int i=hi-1;i>=0;i--){
	if(!emp[i]){
	rep(j,w){
          ans[hi][j]=ans[i][j];
	}
	break;
	}
      }
    }    
  }
  rep(i,h){
    rep(j,w) cout << ans[i][j] <<" ";
    cout << "" << endl;
  }

  
  return 0;
    

}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
int main(){
    using namespace std;
    int h,w,i,j,k;
    vector<int> v;
    h = 1;
    w = 1;
    while(h!=0||w!=0){
        cin >> h >> w;
        if(h==0&&w==0){
            break;
        }
        v.push_back(h);
        v.push_back(w);
    }
    int size = v.size();
    for(i=0;i<(size/2);i++){
        h = v[2*i];
        w = v[2*i+1];
        for(j=0;j<w;j++){
            cout << "#";
        }
        cout << endl;
        for(j=1;j<h-1;j++){
            cout << "#";
            for(k=1;k<w-1;k++){
                cout << ".";
            }
            cout << "#" <<  endl;
        }
        for(j=0;j<w;j++){
            cout << "#";
        }
        cout << endl << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (auto &i : A) cin >> i;
  
  sort(A.begin(), A.end());
  cout << A[N-1] - A[0] << endl;
}

Measured memory_bytes: 256
nm = list(map(int, input().split()))

N = nm[0]
M = nm[1]

A = []
for i in range(0,N):
    A.append( list(map(int, input().split())) )

B = []
for i in range(0,M):
    B.append( list(map(int, input().split())) )

for a in A:
    min_d = 1000000000000000000000000
    min_i = 0
    d = 0
    for i, b in enumerate(B):
        d = abs(a[0]-b[0])+abs(a[1]-b[1])
        if d < min_d:
            min_i = i
            min_d = d
    print(min_i+1) 


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def warshall_floyd(g):
    d = defaultdict(dict)
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    for i in V:
        for j in V:
            if i in g and j in g[i]:
                d[i][j] = g[i][j]
            else:
                d[i][j] = sys.maxsize
    for k in g:
        for i in g:
            for j in g:
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d


@mt
def slv(N, A):
    c = Counter(A)
    ks = list(c.keys())
    ks.sort()

    ans = 0
    for k in ks:
        if c[k] % 2 == 1:
            c.pop(k)
            ans += 1
        else:
            c[k] = 2

    ans += len(c)
    if len(c) % 2 == 1:
        ans -= 1

    return ans


def main():
    N = read_int()
    A = read_int_n()

    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20660
# -*- coding: utf-8 -*-
MOD = 10**9 + 7
n = int(input())
al = list(map(int, input().split()))

b = [0]*100

for a in al:
    for i in range(100):
        b[i] += (a>>i)&1

res = 0
for i in range(100):
    res += b[i]*(n-b[i])*(1<<i)
    res %= MOD

print(res)

Measured memory_bytes: 122808
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;
int B[1000];

signed main()
{
	cin >> N;
	REP(i, N - 1) cin >> B[i];

	int ans = B[0] + B[N - 2];

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

	cout << ans << endl;
}



Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	x, n = LI()
	p = LI()
	i = 0
	while True:
		if x - i not in p:
			print(x-i)
			break
		elif x + i not in p:
			print(x+i)
			break
		i += 1



if __name__ == '__main__':
    main()

Measured memory_bytes: 27140
/*
隣り合う同じ数のペアを最小化する問題である.
->最大となるaの値を見つけて, 他の残りをその間に挟み込んでいく.
*/

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(void){
    int k, t;
    cin >> k >> t;
    
    vector<int> a(t);
    for (int i = 0; i < t; i++) cin >> a[i];
    
    sort(a.rbegin(),a.rend());
    
    int max_a = a[0];
    
    int temp = (max_a - 1 - (k - max_a ) );
    int ans = max(0,temp);
    
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>

struct syain{
  int num;
  int money;
};

int main(void)
{
  struct syain data[1000] = {0};
  int data_num;
  int over_check;
  int number, a1, a2;
  int i, n;

  scanf( "%d", &data_num );
  while( data_num != 0 ) {

    n = 0;
    over_check = 0;
    while( data_num -- > 0 ) {

      scanf( "%d %d %d", &number, &a1, &a2 );
      for( i = 0; i < n; i++) {
        if (data[i].num == number)
          break;
      }
      if ( i == n ) {
        data[i].num = number;
        data[i].money = a1 * a2;
        n ++;
      }
      else {
        data[i].money += a1 * a2;
      }

    }

    for( i = 0; i < n; i++) {
      if (data[i].money >= 1000000) {
        printf( "%d\n", data[i].num );
        over_check ++;
      }
    }
    if ( over_check == 0 )
      printf( "NA\n" );

    scanf("%d", &data_num);
  }

  return 0;
}

Measured memory_bytes: 616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int n = 0;
		int tmp;
		
		
		while(n++ < 3000) {
			
			int x = scan.nextInt();
			int y = scan.nextInt();
			
			if(x > y) {
				tmp = x;
				x = y;
				y = tmp;
			}
			
			if(x == 0 && y == 0) break;
			
			System.out.println(x + " " + y);
			
		}
	}

}


Measured memory_bytes: 35568
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(N):
    M = Mod(10**9 + 7)
    ans = M.pow(10, N)
    ans = M.sub(ans, M.pow(9, N))
    ans = M.sub(ans, M.pow(9, N))
    ans = M.add(ans, M.pow(8, N))


    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78300
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(head,u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
const int N=1e6+5;
struct eg{int v,nx;}e[N<<1];int bl[N],rd[N],tot;
inline void add(R int *head,R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int fr[N],to[N],dep[N],fa[N],dfn[N],low[N],ok[N],vis[N],dis[N],tim,n,S,T;
void dfs(int *head,int u){
	dfn[u]=++tim;
	go(head,u)if(v!=fa[u])fa[v]=u,dep[v]=dep[u]+1,dfs(head,v);
	low[u]=tim;
//	printf("%d %d\n",u,dep[u]);
}
inline bool ck(R int u,R int v){
	if(dfn[u]>dfn[v])swap(u,v);if(low[u]>=low[v])return dep[v]-dep[u]>2;
	if(fa[u]==fa[v])return false;return true;
}
int q[N];
void bfs(){
	int h=1,t=0,u;q[++t]=S,vis[S]=1;
	while(h<=t){
		u=q[h++];
		go(rd,u)if(!vis[v]){
			dis[v]=dis[u]+1;
			if(dis[v]<dep[v])vis[v]=1,q[++t]=v;
		}
	}
}
int main(){
	scanf("%d%d%d",&n,&S,&T);
	for(R int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),fr[i]=u,to[i]=v;
	for(R int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),add(bl,u,v),add(bl,v,u);
	dfs(bl,T);
	for(R int i=1,u,v;i<n;++i){
		u=fr[i],v=to[i];
		if(ck(u,v))ok[u]=ok[v]=1;
		else add(rd,u,v),add(rd,v,u);
	}
	bfs();
	fp(i,1,n)if(vis[i]&&ok[i])return puts("-1"),0;
	R int res=0;
	fp(i,1,n)if(vis[i])cmax(res,dep[i]<<1);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 50048
from sys import stdin
f_i = stdin

N = int(f_i.readline())

a = list(map(int, f_i.readline().split()))

ans = N
idx = 0
num = 1

while True:
    try:
        idx = a.index(num, idx)
        ans -= 1
        num += 1
    except ValueError:
        break

if ans == N:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 24988
a, b = gets.split(" ").map(&:to_i)

ary = []
b.times do
  ary << gets.split(" ").map(&:to_i)
end

ary_l = []
ary_r = []

ary.each do |x|
    ary_l << x[0]
    ary_r << x[1]
end

if ary_r.min - ary_l.max >= 0
    c = ary_r.min - ary_l.max + 1
else 
    puts 0
    exit
end

puts c > a ? a : c


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri();
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int x = ri();
		while (x % 2 == 0) cnt++, x /= 2;
	}
	std::cout << cnt << std::endl;
	return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const long long MOD = 1000000007;
const int MAX_N = 100000;
int n,m;
bool bad[MAX_N+1];
ll dp[MAX_N+1];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> m;
  forn(i,m) {
    int a; cin >> a;
    bad[a] = true;
  }

  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    if (i+1 <= n && !bad[i+1]) dp[i+1] = (dp[i+1] + dp[i]) % MOD;
    if (i+2 <= n && !bad[i+2]) dp[i+2] = (dp[i+2] + dp[i]) % MOD;
  }

  cout << dp[n] << endl;


  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define ld long double
int main()
{
    ll n;
    ll k;
    ll total = 0;
    ll ans;
    ll zero_max = 0;
    std::vector<ll> A;
    std::cin >> n >> k;
    for (ll i = 0; i < n; ++i) {
        ll temp;
        std::cin >> temp;
        A.push_back(temp);
        total += temp;
        zero_max = std::max(temp, zero_max);
    }
    if (k == 0) {
        std::cout << zero_max << std::endl;
        return 0;
    }
    ll mid;
    ll left = 0;
    ll right = zero_max;
    while ((right - left) > 1) {
        mid = (left + right) / 2;

        ll temp_count = 0;
        for (ll j = 0; j < n; ++j) {
            temp_count += ((A[j] + mid - 1) / mid - 1);
        }
        //std::cout << mid << " " << temp_count << std::endl;

        if (temp_count <= k) {
            right = mid;
        } else {
            left = mid;
        }
    }
    std::cout << right << std::endl;
    return 0;
}


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




int main(){
    int n,h,w;
    cin>>n>>w>>h;
    vector<int>x(n,0),y(n,0),d(n,0);
    vector<int> imosx(w+2,0),imosy(h+2,0);
   
    rep(i,n)cin>>x[i]>>y[i]>>d[i];
    rep(i,n){

        int sx=max(0,x[i]-d[i]);
        int ex=min(w,x[i]+d[i]);
        imosx[sx]+=1;
        imosx[ex]-=1;

        int sy=max(0,y[i]-d[i]);
        int ey=min(h,y[i]+d[i]);
        imosy[sy]+=1;
        imosy[ey]-=1;
    }

    rep(i,w){  
        imosx[i+1]+=imosx[i];
    }
    rep(i,h){     
        imosy[i+1]+=imosy[i];
    }
   
    bool f=true;
    rep(i,w)
    if (imosx[i]==0){
        f=false;
    } 

    if (f==true){
        cout<<"Yes"<<endl;
        return 0;
    }
    
    f=true;
    rep(i,h) if (imosy[i]==0){
        f=false;
    } 
    if (f==true){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 4576
using System;

namespace _0009
{
    class Program
    {
        // 合成数xはp≦√xを満たす素因子pをもつ
        static bool checkPrime(int n)
        {
            if(n <= 1 || (n > 2 && n % 2 == 0))
            {
                return false;
            }

            for(int i = 3; i <= Math.Sqrt(n); i += 2)
            {
                if(n % i == 0)
                {
                    return false;
                }
            }

            return true;
        }

        static void Main(string[] args)
        {
            const int MAX_NUM = 1000000;
            int[] primeNum = new int[MAX_NUM];

            primeNum[0] = 0;
            for(int i = 1; i < MAX_NUM; i++)
            {
                primeNum[i] = primeNum[i - 1] + (checkPrime(i) ? 1 : 0); 
            }

            string tmp;
            while((tmp = Console.ReadLine()) != null)
            {
                int n = int.Parse(tmp);
                Console.WriteLine(primeNum[n]);
            }
        }
    }
}



Measured memory_bytes: 17236
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<LL> a(n);
		REP(i,n) cin >> a[i];
		LL sum = 0;
		REP(i, n) {
			sum += a[i];
		}

		LL csum = 0;
		LL INF = 1e18;
		LL ans = INF;
		REP(i, n) {
			csum += a[i];
			chmin(ans, abs(sum - csum - csum));
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    int n;
    cin >> n;
    int A[n], B[n];
    REP(i, n) cin >> A[i];
    REP(i, n) cin >> B[i];

    int ma = 0, cnt;
    REP(i, n){
        cnt = 0;
        for(int j = 0; j <= i; j++){
            cnt += A[j];
        }
        for(int j = i; j < n; j++){
            cnt += B[j];
        }
        ma = max(ma, cnt);
    }
    cout << ma << endl;
    


    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	ss, _ := reader.ReadString('\n')
	tmp := strings.Split(strings.Replace(ss, "\n", "", -1), " ")
	k := p(tmp[3])

	m := map[int64]int64{
		1:  p(tmp[0]),
		0:  p(tmp[1]),
		-1: p(tmp[2]),
	}

	var result int64 = 0
	for _, i := range []int64{1, 0, -1} {
		n := m[i]
		if n > k {
			result = result + i*k
			k = 0
		} else {
			result = result + i*n
			k = k - n
		}
	}
	fmt.Println(result)
}

func p(s string) int64 {
	i, _ := strconv.ParseInt(s, 0, 64)
	return i
}

Measured memory_bytes: 1756
#include <stdio.h>
int main(void){
	int N;
	int cnt;
	double ans_pre=0;
  	scanf("%d", &N);
	double A[N];
	for (cnt=0;cnt<N;cnt++) {
		scanf("%lf", &A[cnt]);
	}
	for (cnt=0;cnt<N;cnt++) {
      	ans_pre = ans_pre + 1/(A[cnt]);
	}
	printf("%lf", 1/ans_pre);
	return 0;
}

Measured memory_bytes: 128
def is_prime(num: int) -> bool:
    # 6k +- 1 <= √n
    if num <= 1:
        return False

    if num <= 3:
        return True

    if num % 2 == 0 or num % 3 == 0:
        return False

    i = 5
    while i * i <= num:
        if num % i == 0 or num % (i+2) == 0:
            return False
        i += 6

    return True


x = int(input())
for i in range(x,1000000):
    if is_prime(i):
        print(i)
        break


Measured memory_bytes: 9204
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    # N = int(input())
    a, b, c = [int(a) for a in input().split()]
    # # A = [
    # #     int(input())
    # #     for _ in range(N)
    # # ]
    # A = [int(a) for a in input().split()]

    print(max(0,c - a + b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        int h, w;
        scanf("%d%d", &h, &w);
        vector<string> s(h + 2);
        s[0] = s[h + 1] = string(w + 2, '.');
        for (int i = 1; i <= h; i ++) {
                s[i] = ".";
                string t;
                cin >> t;
                s[i] += t;
                s[i] += ".";
        }
        vector<vector<string>> ans(h, vector<string> (w));
        for (int i = 1; i < h + 1; i ++) {
                for (int j = 1; j < w + 1; j ++) {
                        if (s[i][j] == '#') {
                                ans[i - 1][j - 1] = "#";
                        } else {
                                int cnt = 0;
                                cnt += s[i + 1][j - 1] == '#';
                                cnt += s[i + 1][j] == '#';
                                cnt += s[i + 1][j + 1] == '#';

                                cnt += s[i][j - 1] == '#';
                                cnt += s[i][j + 1] == '#';

                                cnt += s[i - 1][j - 1] == '#';
                                cnt += s[i - 1][j] == '#';
                                cnt += s[i - 1][j + 1] == '#';

                                ans[i - 1][j - 1] = '0' + cnt;
                        }
                }
        }
        for (int i = 0; i < h; i ++) {
                for (int j = 0; j < w; j ++) {
                        cout << ans[i][j];
                }
                cout << endl;
        }
        return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	double n;
	double s[1000];
	double m;
	double temp;
	double a = 0.0;

	while (cin >> n && n) {
		m = 0.0;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			m += s[i];
		}
		m /= n;

		temp = 0.0;

		for (int j = 0; j < n; j++) {
			temp += pow(s[j] - m, 2.0);
		}

		a = sqrt(temp / n);

		cout << fixed << setprecision(8) << a << endl;
	}
}


Measured memory_bytes: 3292
def solve(P):
    A, B, C, D = P
    if A<B or D<B:
        return False
    if C >= B-1:
        return True
    g = gcd(B,D)
    return A%B+(B-A%B-1)//g*g <= C

from math import gcd

T = int(input())
for _ in range(T):
    P = map(int, input().split())
    print("Yes" if solve(P) else "No")

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

char s[1000][1001];
int h, w, dp[1000][1000][1 << 5], dx[]{ -1,0,1,0 }, dy[]{ 0,-1,0,1 };
int a[]{ 0,2,4,3 }, b[]{ 0,2,3,1 };

int tate(int t) {
	if (t == 3)return 0;
	if (t == 4)return 2;
	return -1;
}
int yoko(int t) {
	if (t == 1)return 0;
	if (t == 3)return 2;
	return -1;
}
int s1(int t) {
	int u = 0;
	rep(i, 5) {
		if (t >> i & 1) {
			int a = tate(i); if (a != -1)u |= 1 << a;
		}
	}
	return u;
}
int s2(int t) {
	int u = 0;
	rep(i, 5) {
		if (t >> i & 1) {
			int a = yoko(i); if (a != -1)u |= 1 << a;
		}
	}
	return u;
}
int rec(int x, int y, int t) {
	int T = t;
	if (dp[x][y][t] != -1)return dp[x][y][t];
	int res = INT_MAX, p = 0;
	if ((!(t >> 3 & 1)) && '1' <= s[x][y] && s[x][y] <= '9') {
		t |= 1 << 3; p = s[x][y] - '0';
	}
	if (x == h - 1 && y == w - 1)return dp[x][y][t] = p;
	vector<P>v;
	rep(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx < 0 || ny < 0 || nx >= h || ny >= w || s[nx][ny] < '1' || '9' < s[nx][ny])continue;
		if (i < 2 && (t >> a[i] & 1))continue;
		v.push_back(P(s[nx][ny] - '0', i));
	}
	if (v.empty()) {
		if (x + 1 < h)res = min(res, rec(x + 1, y, s1(t)) + p);
		if (y + 1 < w)res = min(res, rec(x, y + 1, s2(t)) + p);
	}
	rep(i, v.size()) {
		if (x + 1 < h) {
			int sum = p, r = t, u = 0;
			rep(j, v.size()) {
				if (i == j)continue;
				sum += v[j].first;
				if (v[j].second >= 2)u |= 1 << b[v[j].second];
				else r |= 1 << b[v[j].second];
			}
			res = min(res, rec(x + 1, y, s1(r) | u) + sum);
		}
		if (y + 1 < w) {
			int sum = p, r = t, u = 0;
			rep(j, v.size()) {
				if (i == j)continue;
				sum += v[j].first;
				if (v[j].second >= 2)u |= 1 << a[v[j].second];
				else r |= 1 << a[v[j].second];
			}
			res = min(res, rec(x, y + 1, s2(r) | u) + sum);
		}
	}
	return dp[x][y][T] = res;
}
int main() {
	scanf("%d%d", &h, &w);
	rep(i, h)scanf("%s", s[i]);
	memset(dp, -1, sizeof(dp));
	printf("%d\n", rec(0, 0, 0));
}

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

using namespace std;

string s;
void back(int x, int d){
    for(int j=0; j< d; j++){
        if(s[x-1] == 'z') s[x-1] = 'a';
        else s[x-1]++;
    }
}

int main(){
    int n;
    while(cin >> n, n){
        cin >> s;
        vector<pair<int, int> > v;
        for(int i=0; i< n; i++){
            int a, b;
            cin >> a >> b;
            v.push_back(make_pair(a, b));
        }
        reverse(v.begin(), v.end());
        for(int i=0; i< v.size(); i++){
            int d = abs(v[i].first - v[i].second);
            back(v[i].first, d);
            back(v[i].second, d);
            swap(s[v[i].first-1], s[v[i].second-1]);
        }
        cout << s << endl;
    }
}

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

int main() {
  long double ans;
  long double theta;
  long double PI = 3.14159265358979323846;
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  theta = 30*H - 5.5*M;
  if (theta < 0) {
    theta = - theta;//度数
  }
  theta = theta*PI/180.0;
  ans = sqrt(A*A + B*B - 2*A*B*cos(theta));
  if (ans < 0) {
    ans = - ans;
  }
  cout << fixed;
  cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4172
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007
 

int main() {
	string s;
	cin >> s;
	for (int i = 1; i < s.length(); i++) {
		if (s[i] == 'C'&&s[i - 1] == 'A') {
			print("Yes");
			return 0;
		}

	}
	print("No");



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
 using namespace std;
 typedef long long ll;
 int main()
 {
 	ll n,r;
 	cin>>n>>r;
 	if(n>=10) cout<<r<<endl;
 	else{
 		r=r+100*(10-n);
 		cout<<r<<endl;
	}
 	return 0;
 }

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

using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> PP;

const int MAX = 101;
const int INF = (1<<20);

vector<P> Edge[MAX];
int node[2][MAX];
int n,m;
int pre[MAX];

void init(){
  for(int i = 0; i < MAX; i++)
    Edge[i].clear();
  fill(node[0],node[0]+MAX,INF);
  fill(node[1],node[1]+MAX,INF);

}

int find(int f, int t){
  for(int i = 0; i < Edge[f].size(); i++){
    if(Edge[f][i].first == t) return Edge[f][i].second;
  }
}


void solve(int from, int to){
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(0,P(0,1)));


  node[0][1] = 0;
  while(!Q.empty()){
    PP now = Q.top(); Q.pop();
    if(now.first > node[now.second.first][now.second.second]) continue;

    for(int i = 0; i < Edge[now.second.second].size(); i++){
      int from = now.second.second;
      int times = Edge[from][i].second+ now.first;
      int to = Edge[from][i].first;
      int tf = now.second.first;

      //do not use ticket 
      if(node[tf][to] > times){
	//pre[to] = from;
	node[tf][to] = times;
	Q.push(PP(times,P(tf,to)));
      }

      //use ticket
      //   if(tf == 0)
      //	if(node[1][to] > now.first)
      if(tf == 0)
	for(int j = 0; j < Edge[to].size(); j++){
	  int nextto = Edge[to][j].first;
	  if(nextto == from) continue;
	  //node[1][to] = now.first;
	  //Q.push(PP(now.first,P(1,to)));
	  if(node[1][nextto] > now.first){
	    node[1][nextto] = now.first;
	    Q.push(PP(now.first,P(1,nextto)));
	  }
	}
      
      
    }
  }
  cout << min(node[0][to],node[1][to]) << endl;

}
int main(){
  while(cin >> n >> m && n+m){
    init();
    for(int i = 0; i < m; i++){
      int a,b,mon;
      cin >> a >> b >> mon;
      Edge[a].push_back(P(b,mon));
      Edge[b].push_back(P(a,mon));
    }
    solve(1,n);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
	
int S,W;

	     Scanner sc = new Scanner(System.in);
	     S = sc.nextInt();
	     W=sc.nextInt();
	     if(S<=W) {
	    	 System.out.println("unsafe");	
	     }else {
	    	 System.out.println("safe");	}
	     sc.close();
	}

}


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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> as(n);
        int sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> as[i];
            sum += as[i];
        }
        int ans = 1 << 29;
        for (int i = 1, size = 1 << (n-1); i < size; i++) {
            int a = 0;
            for (int j = 0; j < n-1; j++) {
                if (i & (1 << j)) {
                    a += as[j];
                }
            }
            ans = min(ans, abs(sum - 2 * a));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1192
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int t[123456],x[123456],y[123456];
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int i,val;
    t[0]=0;
    x[0]=0;
    y[0]=0;
    f(i,1,n+1){
    	cin>>t[i]>>x[i]>>y[i];
    	val=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    	if(val>t[i]-t[i-1]){
    		cout<<"No"<<endl;
    		return 0;
    	}
    	val=t[i]-t[i-1]-val;
    	if(val%2){
    		cout<<"No"<<endl;
    		return 0;
    	}
    }
    cout<<"Yes"<<endl;
    return 0;  
    
}



Measured memory_bytes: 1408
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;
int main(void){

  int n;
  cin >> n;
  int kami=n/100;//上二桁
  int simo=n-kami*100;//下二桁;
  //cout <<"kami0:"<< kami;

  //yymm
  if((kami==0&&(simo>=1&&simo<=12))||((kami>=13&&kami<=99)&&(simo>=1&&simo<=12))){
    cout << "YYMM";
  }
  else if((kami==0&&(simo>=13&&simo<=99))||(kami==0&&simo==0)||((kami>=13&&kami<=99)&&simo==0)||(kami>=13&&kami<=99)&&(simo>=13&&simo<=99)){
    cout << "NA";
  }
  else if(((kami>=1&&kami<=12)&&(simo==0||(simo>=13&&simo<=99)))){
    cout <<"MMYY";
  }
  else if((kami>=1&&kami<=12)&&(simo>=1&&simo<=12)){
    cout<< "AMBIGUOUS";
  }

  return 0;
}


Measured memory_bytes: 256
n, d = map(int, input().split())
point_list = []
for i in range(n):
    point_list.append(list(map(int,input().split())))

cnt = 0

for i in range(n):
    if point_list[i][0]**2 + point_list[i][1]**2 <= d*d:
        cnt += 1

print(cnt)

Measured memory_bytes: 45324
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		int n = ia[0];
		int m = ia[1];
		int o = n - m;
		double ans = 1900.0 * m + 100.0 * o;
		for (int i = 0; i < m; i++) {
			ans *= 2.0;
		}
		pln((int) ans);
	}

	void solve1() {
		int[] ia = readNums();
		int n = ia[0];
		int m = ia[1];
		int o = n - m;
		double ans = 0;
		double div = 2;
		int cnt = 1;
		while (cnt < 100) {
			double delta = cnt * 1900.0 * m / div;
			ans += delta + 100.0 * o;
			div *= 2.0;
			cnt++;
		}
		pln(ans);
	}

	void solve0() {
		int[] ia = readNums();
		int n = ia[0];
		int m = ia[1];
		int o = n - m;
		int ans = 0;
		int div = 2;
		int cnt = 1;
		while (true) {
			int delta = cnt * 1900 * m / div;
			if (delta < 1)
				break;
			ans += delta + 100 * o;
			div *= 2;
			cnt++;
		}
		pln(ans);
	}

	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	long abs(long a) {
		return (a >= 0) ? a : -a;
	}

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

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

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	long min(long a, long b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	long readLong() {
		String line = readLine();
		return plong(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = pint(flds[i]);
		return nums;
	}

	long[] readLongs() {
		String[] flds = readFlds();
		long[] nums = new long[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = plong(flds[i]);
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed)
			System.err.println((end - start) + "ms");
	}
}


Measured memory_bytes: 23252
#include<stdio.h>

#define N 10000
#define Q 500

int num, renum;

int LinearS(int *x, int *y){
  int rslt=0, i, j;
  
  for(i=0; i<renum; i++)
    for(j=0; j<num; j++)
      if(*(x+j)==*(y+i)){
	rslt++;
	break;
      }


  return rslt;
}



int main (){

  int i, rslt;
  int num1[N], num2[Q];

  scanf("%d", &num);

  for(i=0; i<num; i++)
    scanf("%d", &num1[i]);

  scanf("%d", &renum);

  for(i=0; i<renum; i++)
    scanf("%d", &num2[i]);

  rslt = LinearS(num1, num2);

  printf("%d\n", rslt);
  
  return 0;
  
}

Measured memory_bytes: 636
//作者：中国江苏省南京市李硕睿
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int a[309][309],b[309][309];
bool c[309][309];
int d[309],e[309];
int main(){
    int n,m;
    cin>>n>>m;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
			cin>>a[i][j];
			a[i][j]--;
			b[i][a[i][j]]=j;
		}
    }
    for (int i=1;i<=n;i++){
    	for (int j=0;j<n;j++){for(int k=0;k<m;k++)c[j][k]=false;d[j]=0;}
        int cnt=0;
        while (cnt<m){
            for (int j=0;j<m;j++)
				e[j]=0;
            for (int j=0;j<n;j++)
				e[a[j][d[j]]]++;
            bool OK=false;
            for (int j=0;j<m;j++){
                if(e[j]>i){
                    OK=true;
                    for (int k=0;k<n;k++)
						c[k][b[k][j]]=true;
                    break;
                }
            }
            for (int j=0;j<n;j++){
                while (c[j][d[j]]==true)
					d[j]++;
            }
            if (OK==false)
				break;
            cnt++;
        }
        if (cnt!=m){
        	cout<<i<<endl;
        	break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.next();
        String t = input.next();
        int counter = 0;
        int j = 0;
        for(int i = 0; i < s.length();i++){
                if(s.charAt(i) != t.charAt(j))
                    counter++;
            j++;
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 41428
import java.util.*;

public class Main {
    static long mod = 1000000007;

    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] lis = new long[n];

        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
        }

        long r = 0;
        for (int x = 0; x <= k; ++x) {
            for (int y = 0; y <= k - x; ++y) {
                if (x + y > n) continue;

                long sum = 0;
                int z = k - x - y;

                TreeSet<Long> picked = new TreeSet<Long>();
                for (int i = 0; i < x; ++i) {
                    picked.add(lis[i]);
                    sum += lis[i];
                }
                for (int i = 0; i < y; ++i) {
                    picked.add(lis[n - 1 - i]);
                    sum += lis[n - 1 - i];
                }
                for (int i = 0; i < z && picked.size() > 0; ++i) {
                    long tmp = picked.pollFirst();
                    if (tmp < 0) {
                        sum -= tmp;
                    }
                }
                // System.out.println(String.format(">> %d %d %d %d", x, y, z, sum));
                r = Math.max(r, sum);
            }
        }

        System.out.println(r);
    }
}


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


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while (1) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}

		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int a, int b)
{if (a%b == 0){ return(b);}
   else { return(gcd(b, a%b));}
}
int gcd(int a, int b,  int c){return gcd((gcd(a,b)),(gcd(b,c)));}
int main() {
  
  int k,m;
  m=0;
  cin>>k;
  for(int i=0;i<k;i++){for(int j=0;j<k;j++){for(int h=0;h<k;h++){
  m+=gcd(i+1,j+1,h+1);
  }}}
cout<<m<<endl;
}

Measured memory_bytes: 3632
n = input().rstrip()

total = 0
carry = 0
for i in range(len(n)-1, -1, -1):
    v = int(n[i]) + carry
    if v > 5:
        total += 10 - v
        carry = 1
    elif v == 5:
        if i == 0:
            total += 5
            carry = 0
        else:
            if int(n[i-1]) >= 5:
                total += 5
                carry = 1
            else:
                total += 5
                carry = 0
    else:
        total += v
        carry = 0

print(total + carry)

Measured memory_bytes: 5492
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

int h[N], dp[N];

int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i ++)
        cin >> h[i];
    fill(dp, dp + N, 2e9);
    dp[0] = 0;
    for (int i = 1; i < n; i ++)
        for (int j = 1; j <= min(i, k); j ++)
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024