akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
#define ll long long int
int const mod=1000000007;

int main()
{
    string s;
    cin>>s;
    int c=0,ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R')
        {
            c++;
            if(i==s.size()-1)
                ans=max(ans,c);
        }
        else
        {
            ans=max(ans,c);
            c=0;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>

using namespace std;

int main() {

  int n;

  int a,b,c;

  cin >> n;

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

    cin >> a >> b >> c;

    if(a*a+b*b==c*c || b*b+c*c==a*a || c*c+a*a==b*b) cout << "YES" << endl;

    else cout << "NO" << endl;

  }

  return 0;

}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f;
    cin >> a>>b>>c>>d>>e>>f;
    if(a+5*b+10*c+50*d+100*e+500*f>=1000){
        cout << 1;
        
    }
    else {
        cout<<0;
    }
    cout <<endl;
    
}



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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<int> c(n);
  vector<int> nc;
  vector<LL> p(200001,0);
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  nc.push_back(c[0]);
  for(int i=1;i<n;i++){
    if(c[i]!=c[i-1]) nc.push_back(c[i]);
  }
  n=nc.size();
  LL ans=1,tmp;
  for(int i=0;i<n;i++){
    tmp=ans;
    ans=(ans+p[nc[i]])%MOD;
    p[nc[i]]=(p[nc[i]]+tmp)%MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3704
n=int(input())
c=input()

from collections import Counter
cl = list(c)
cun= Counter(cl)
cn=cun["R"]
cnt=0
for i in  range(cn):
    if c[i]=="W" :
        rpos=c.rfind("R",cn)
        cl[i],cl[rpos]=cl[rpos],cl[i]
        cnt+=1

print(cnt)

Measured memory_bytes: 10860
package main

import (
  "fmt"
)

func main() {
  var n int
  fmt.Scan(&n)
  var quotient = n / 11
  var remainder = n % 11
  var c int
  switch {
  case remainder == 0:
    c = 0
  case remainder <= 6:
    c = 1
  case remainder > 6:
    c = 2
  }
  var answer = quotient * 2 + c
  fmt.Println(answer)
}


Measured memory_bytes: 512
n,w=map(int,input().split())
wv=[[int(i) for i in input().split()]for _ in range(n)]

dp=[0]*(w+1)
dp[wv[0][0]]=wv[0][1]
for i in range(1,n):
    ww = wv[i][0]
    v = wv[i][1]
    for j in range(w,ww-1,-1):
        dp[j]=max(dp[j],dp[j-ww]+v)
print(max(dp))

Measured memory_bytes: 41580
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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)]
mod = 1000000007

n = I()
s = S()


def z_algorithm(S):
    l = len(S)
    A = [0] * l
    i = 1; j = 0
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k


    ret = 0
    for p in range(l):
        if p >= A[p] > ret:
            ret = A[p]
    return ret


ans = 0
for i in range(n):
    ans = max(ans, z_algorithm(s[i:]))



print(ans)

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

const int NIL = -1;
const int MAX = 100000;
int root;

struct Node { 
  int id;
  int parent;
  int left;
  int right;
};

Node T[MAX];
int D[MAX];
int H[MAX];

void setDepth(int u, int p) {
  if (u == NIL) return;
  D[u] = p;
  if (T[u].left != NIL) setDepth(T[u].left, p + 1);
  if (T[u].right != NIL) setDepth(T[u].right, p + 1);
}

int getHeight(int u) {
  int h1 {0}, h2 {0};
  if (T[u].left != NIL) {
    h1 = getHeight(T[u].left) + 1;
  }
  if (T[u].right != NIL) {
    h2 = getHeight(T[u].right) + 1;
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
  if (T[u].parent == NIL) return NIL;
  if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) {
    return T[T[u].parent].left;
  }
  if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
    return T[T[u].parent].right;
  }
  return NIL;
}

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

  for (int i = 0; i < n; i++) {
    T[i].id = T[i].left = T[i].right = T[i].parent = NIL;
  }

  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    cin >> T[v].left >> T[v].right;
    if (T[v].left != NIL) {
      T[T[v].left].parent = v;
    }
    if (T[v].right != NIL) {
      T[T[v].right].parent = v;
    }
  }

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) {
      root = i;
      break;
    }
  }

  setDepth(root, 0);
  getHeight(root);

  for (int i = 0; i < n; i++) {
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", ";
    cout << "sibling = " << getSibling(i) << ", ";
    int deg {0};
    if (T[i].left != NIL) deg++;
    if (T[i].right != NIL) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[i] << ", ";
    cout << "height = " << H[i] << ", ";
    if (T[i].parent == NIL)  {
      cout << "root";
    } else if (T[i].left == NIL && T[i].right == NIL) {
      cout << "leaf"; 
    } else {
      cout << "internal node";
    }
    cout << endl;
  }
}



Measured memory_bytes: 3104
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[100009], ans[100009];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        ans[a[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << " ";
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, x = 1e6, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        sum += p;
        if (p % 10 != 0) {
            x = min(x, p);
        }
    }
    if (sum % 10) {
        cout << sum << endl;
    }
    else {
        cout << max(0, sum - x);
    }
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const long long mod = 1000000007;
const double eps = 1e-11;
const int inf = 1ll << 61;

signed main() {
	int a, b, k; cin >> a >> b >> k;
	if (a + k - 1 < b - k + 1) {
		for (int i = a; i < a + k; i++)cout << i << endl;
		for (int i = b - k + 1; i <= b; i++)cout << i << endl;
	}
	else {
		for (int i = a; i <= b; i++)cout << i << endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int a[1000];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int sum=1,ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]&1) ans+=sum*2*pow(3,n-i);
		else ans+=sum*pow(3,n-i),sum*=2;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll p=a*c,q=a*d,r=b*c,s=b*d;
    cout<<max(max(p,q),max(r,s))<<endl;
    return 0;
}


Measured memory_bytes: 3624
object Main extends App {
  import scala.annotation.tailrec

  def high(x: Int): Int = x * x
  def rectangle(y: Int, d: Int): Int = y * d
  def area(x: Int, d: Int): Int = {
    if (x == d) 0
    else {
      val n = x - d
      area(n, d) + rectangle(high(n), d)
    }
  }

  @tailrec
  def loop() {
    val line = scala.io.StdIn.readLine()
    if (line == null) return
    else {
      val d = line.toInt
      println(area(600, d))
      loop()
    }
  }

  loop()
}

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans, N, K;
vll A;

void solve(){
    for(int i = 0; i < N - K; i++){
        if(A[i] < A[i + K]){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

    A.resize(N);
    rep(i, N) cin >> A[i];

    solve();
}


Measured memory_bytes: 4816
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var year = int.Parse(S.Substring(0, 4));
            var month = int.Parse(S.Substring(5, 2));
            var day = int.Parse(S.Substring(8, 2));
            var heisei = false;
            if (year < 2019) heisei = true;
            else if (year > 2019) heisei = false;
            else if (month <= 4) heisei = true;

            Console.WriteLine(heisei ? "Heisei" : "TBD");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 11092
x, k, d = gets.chomp.split(" ").map(&:to_i)
x = x.abs

if(x>=k*d)
  puts(x-k*d)
else
  m = x%d;
  div = x/d;
  if ( (k-div) % 2 == 0) 
    puts(m)
  else
    puts(d-m)
  end
end


Measured memory_bytes: 14404
n, k = map(int, input().split( ))
a = list(map(int, input().split( )))

a_sum = sum(a)

rt_sm = int(a_sum**(1/2) + 0.01)

fct = []
fct2 = []

for p in range(1,rt_sm+1):
    if a_sum%p == 0:
        fct.append(p)
        fct2.append(a_sum//p)

if fct[-1] == fct2[-1]:
    fct.pop() 

fct += fct2
fct.sort(reverse=True)


for f in fct:
    tmp = []
    for t in a:
        tmp.append(t%f)
    tmp_sum = sum(tmp)
    cnt = 0

    sb = tmp_sum // f
    tmp.sort()
    for i in range(n-sb,n):
        tmp[i] -= f

    if sum(tmp[:n-sb]) <= k:
        ans = f 
        break

print(ans)
    


Measured memory_bytes: 42732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

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

	string inp = "";
	cin >> inp;
	vector <char> ans;
	rep(i, inp.length()) {
		if(inp[i] == 'B' && !ans.empty()) {
			ans.pop_back();
		}
		else if(inp[i] == '0' || inp[i] == '1') {
			ans.pb(inp[i]);
		}
	}
	rep(i, ans.size()) {
	cout << ans[i];
	}
	cout << endl;
	//cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,temp,score[100]={},res=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> temp;
    for(int j=0;j<100;j++){
      score[j]+=(temp>=j+1)?1:0;
    }
  }
  for(int i=0;i<100;i++){
    res=(score[i]>=i+1)?i+1:res;
  }
  cout << res << endl;
}



Measured memory_bytes: 3108
n = int(input())
a = list(map(int, input().split()))

dp = [float('inf')]*n
dp[0] = 0

for i in range(1, n):
  dp[i] = min(dp[i], dp[i-1] + abs(a[i] - a[i-1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]))

print(dp[-1])

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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N],B[MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  for(int i=0;i<n;i++)
    cin >> A[i] >> B[i];
  
  ll ans = 0;
  for(int i=n-1;i>=0;i--){
    ll a = A[i] + ans;
    ll val = a % B[i];
    if(val) val = B[i] - val;
    ans += val;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    int N;
    cin >> N;
    vector<int> C(4);
    rep(i, N) {
        string T;
        cin >> T;
        if (T == "AC") C.at(0)++;
        if (T == "WA") C.at(1)++;
        if (T == "TLE") C.at(2)++;
        if (T == "RE") C.at(3)++;
    }
    vector<string> test = {"AC", "WA", "TLE", "RE"};
    rep(i, 4) {
        cout << test.at(i) << " x " << C.at(i) << "\n";
    }
}

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

using namespace std;

int main(){
    int n, i, k , j;
    scanf("%d %d",&n, &k);
    int height[n+5];
    for(i = 1; i <= n; i++){
        scanf("%d",&height[i]);
    }
    int ans = 1e9;
    int dp[n+5];
    for(i = 1; i<=n; i++){
        dp[i] = 1e9;
    }
    dp[1] = 0;
    for(i = 2; i<=n; i++){
        for(j=1; j<=k && j < i;j++){
            if(i > j) dp[i] = min(dp[i], dp[i-j] + abs(height[i] - height[i-j]));
        }
    }
    printf("%d\n", dp[n]);
    return 0;
}


Measured memory_bytes: 1024
n=input()
l=len(n)
m=int(n)
if l==1:
  a=m
elif l==2:
  a=9
elif l==3:
  a=9+(m-99)
elif l==4:
  a=9+900
elif l==5:
  a=9+900+(m-9999)
else:
  a=9+900+90000
print(a)

Measured memory_bytes: 2940
import java.io.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _err = new PrintWriter(System.err);

    private int N;
    private int K;
    private long[] a;

    private void solve(Scanner sc, PrintWriter out) {
        N = sc.nextInt();
        K = sc.nextInt();
        a = new long[N];
        long max = 0;
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextLong();
            max += Math.max(a[i], 0);
        }
        long add = 0;
        long sub = 0;
        for (int i = 0; i < K; ++i) {
            add += Math.max(a[i], 0);
            sub += Math.min(a[i], 0);
        }
        long min = Math.min(add, -sub);
        for (int i = K; i < N; ++i) {
            add += Math.max(a[i], 0) - Math.max(a[i - K], 0);
            sub += Math.min(a[i], 0) - Math.min(a[i - K], 0);
            min = Math.min(min, Math.min(add, -sub));
        }

        out.println((max - min));
    }
    private long C(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        for (long i = r; i > 1; --i) {
            res /= i;
        }
        return res;
    }
    private long P(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(sc, out);
        out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

int n,L,x[300010],t[300010],dir[300010],col[300010],cn;
long long ans;

//0:don't change  1:change   2:--  3:(    4:)

int main()
{
	scanf("%d%d",&n,&L);
	for (int i=1; i<=n; i++) scanf("%d",&x[i]);
	for (int i=1; i<=n; i++) scanf("%d",&t[i]);
	for (int i=1; i<=n; i++)
	{
		long long t1=((t[i]%(2*L))<=(2*x[i])&&(t[i]%(2*L)!=0))?t[i]+(2ll*x[i]-(t[i]%(2*L))):t[i]+(2ll*L-(t[i]%(2*L)));
		long long t2=((t[i]%(2*L))<=(2*(L-x[i]))&&(t[i]%(2*L)!=0))?t[i]+(2ll*(L-x[i])-(t[i]%(2*L))):t[i]+(2ll*L-(t[i]%(2*L)));
		if (t[i]%(2*L)==0) t1-=(2*L),t2-=(2*L);
		long long ans1=(t1/(2*L))*2+((t[i]%(2*L))<=(2*x[i])&&(t[i]%(2*L)!=0)),ans2=(t2/(2*L))*2+((t[i]%(2*L))<=(2*(L-x[i]))&&(t[i]%(2*L)!=0));
		ans+=min(ans1,ans2);
		if (ans1<ans2)
		{
			if ((t[i]%(2*L))<=(2*x[i])&&(t[i]%(2*L)!=0)) dir[i]=3; else dir[i]=2;
		} else
		if (ans1>ans2)
		{
			if ((t[i]%(2*L))<=2*(L-x[i])&&(t[i]%(2*L)!=0)) dir[i]=4; else dir[i]=2;
		} else
		if ((t[i]%(2*L))<=(2*x[i])&&(t[i]%(2*L)!=0)) dir[i]=1; else dir[i]=0;
	}
	for (int i=1; i<=n; i++) 
		if (dir[i]==1) col[++cn]=0; else
		if (dir[i]==3) col[++cn]=1; else
		if (dir[i]==4) col[++cn]=2;
	if (dir[n]==0||dir[n]==2) col[++cn]=2,ans++;
	int l=0,r=0;
	for (int i=1; i<cn; i++)
	{
		if (col[i]==0) l--,r++; else
		if (col[i]==1) l++,r++; else l--,r--;
		if (r<0) ans-=r,l=r=0; else
		if (l<0) l=(r&1);
	}
	if (col[cn]==0) l--,r++; else
	if (col[cn]==1) l++,r++; else l--,r--;
	ans+=(l+1);
	printf("%lld\n",(ans+1)*L);
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define de(x) cout << #x << "=" << x << ", "
#define dd cout << '\n';
#define XinAi ios::sync_with_stdio(0), cin.tie(0);
#define F first
#define S second
#define int long long
using namespace std;
typedef pair<int,int> pii;
const int N = 1e5+10;

int a[N];

signed main()
{
    int n;
    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i++)
    {
        if (a[i] == 0)
        {
            cout << 0 << '\n';
            return 0;
        }
    }
    __int128 res = 1;
    for (int i=0; i<n; i++)
    {
        res *= a[i];
        if (res > (int)1e18)
        {
            cout << -1 << '\n';
            return 0;
        }
    }
    int owo = res;
    cout << owo << '\n';
}
/*
x * res > 1e18
*/

Measured memory_bytes: 4376
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		byte N = sc.nextByte();
		byte M = sc.nextByte();
		int X = sc.nextInt();
		int[] C = new int[N];
		int[][] A = new int[N][M];
		int[] cost = new int[(short) Math.pow(2, N)];
		int[][] reach = new int[(short) Math.pow(2, N)][M];
		//boolean ans = true;
		int a = -1;
		for (byte i = 0; i < N; i++) {
			C[i] = sc.nextInt();
			for (byte j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		sc.close();
		for (short i = 0; i < (short) Math.pow(2, N); i++) {
			for (byte j = 0; j < N; j++) {
				if ((1 & i >> j) == 1) {
					cost[i] += C[j];
					for (byte k = 0; k < M; k++) {
						reach[i][k] += A[j][k];
					}
				}
			}
			for (byte j = 0; j < M; j++) {
				if (reach[i][j] < X) {
					cost[i] = -1;
					break;
				}
			}
		}
		for (short i = 0; i < (short) Math.pow(2, N); i++) {
			if (cost[i] != -1) {
				if (a == -1) {
					a = cost[i];
				} else {
					a = Math.min(a, cost[i]);
				}
			}
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 37176
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int c=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2==1)
            c++;
    }
    float r=(float)c/(float)n;
    cout<<fixed<<setprecision(7)<<r;

}



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

def digit_sum(X):
    s = 0
    while(X > 0):
        s += X % 10
        X = int(X / 10)
    return s

min_ = 10 ** 5
for A in range(1, int(N/2)+1):
    B = N - A
    val = digit_sum(A) + digit_sum(B)
    min_ = min(min_, val)

print(min_)


Measured memory_bytes: 3060
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int64 MOD = 1000000007;

string convert(const string& s) {
  string ret = "";
  for (size_t i = 0; i < s.size(); ++i) {
    if (s[i] == 'W') {
      ret += 'L';
    } else {
      ret += 'R';
    }
  }
  return ret;
}

int64 fact(int n) {
  int64 res = 1;
  for (int i = 1; i <= n; ++i) {
    (res *= (int64) i) %= MOD;
  }
  return res;
}

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

  int n; cin >> n;
  string s; cin >> s;
  int SIZE = 2 * n;

  for (int i = 0; i < SIZE; ++i) {
    if (i & 1) {
      continue;
    } else {
      if (s[i] == 'W') {
        s[i] = 'B';
      } else {
        s[i] = 'W';
      }
    }
  }

  string t = convert(s);
  int cntw = count(all(s), 'W');
  if (cntw != n) {
    cout << 0 << endl; return 0;
  }

  int cur = 0;
  int64 ans = 1;

  for (size_t i = 0; i < t.size(); ++i) {
    if (t[i] == 'L') {
      ++cur;
    } else {
      (ans *= cur) %= MOD;
      --cur;
    }
  }

  (ans *= fact(n)) %= MOD;

  cout << ans << endl;

  return 0;
}

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

using namespace std;

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
        if(n==i*j){
            cout<<"Yes";
            return 0;
        }
    }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int a, b;
    cin >> a >> b;

    auto f = [&](int x){
        vector<int> v = {x, 1, x + 1, 0};
        return v[(x+4)%4];
    };
    cout << (f(a-1) ^ f(b)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 2e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n, m;
int s, t;
int dis[N][3];
vi e[N];
void init() {
	mt(dis, -1);
	rep(i, 1, n + 1) e[i].clear();
}
int dij() {
	priority_queue<piii, vector<piii>, greater<piii> > q;
	q.push({0,{0,s}});
	dis[s][0] = 0;
	while(sz(q)) {
		piii tmp = q.top(); q.pop();
		int d = tmp.fi, r = tmp.se.fi, u = tmp.se.se;
		// dd(r);dd(u);de(d);
		if(u == t && r == 0) return d;
		for(auto v : e[u]) {
			int nr = (r + 1) % 3;
			int nd = dis[u][r];
			if(nr == 0) nd++;
			if(dis[v][nr] == -1 || dis[v][nr] > nd) {
				dis[v][nr] = nd;
				q.push({dis[v][nr],{nr, v}});
			}
		}
	}
	return -1;
}
int main() {
	while(~scanf("%d%d",&n,&m)) {
		init();
		rep(i, 0, m) {
			int u, v; scanf("%d%d",&u,&v);
			e[u].pb(v);
		}
		scanf("%d%d",&s, &t);
		printf("%d\n", dij());
	}
    return 0;
}


Measured memory_bytes: 10368
import math
 
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
 
    m = sum(s) / n
    a = 0
    for i in range(n):
        a += (s[i] - m) ** 2
    a = math.sqrt(a / n)
    print("{:5f}".format(a))


Measured memory_bytes: 5704
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

	string T;
	for (int i = S.size() - 1; i >= 0; i--)
	{
		T.push_back(S[i]);
	}

	for (int i = 0; i < T.size();)
	{
		string p = T.substr(i, 5);
		string q = T.substr(i, 6);
		string r = T.substr(i, 7);

		if (p == "maerd" || p == "esare")
		{
			i += 5;
		}
		else if (q == "resare")
		{
			i += 6;
		}
		else if (r == "remaerd")
		{
			i += 7;
		}
		else {
			cout << "NO" << endl;
			return 0;
			break;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 640
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] element = br.readLine().split(" ");
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(element[i]);
        }
        
        int count = selectionSort(A);

        StringBuilder output = new StringBuilder("");
        for (int i = 0; i < N; i++) {
            output.append(A[i]);
            if (i != N-1) {
                output.append(" ");
            }
        }
        System.out.println(output.toString());
        System.out.println(count);
    }

    public static int selectionSort (int[] a) {
        int i, j, temp;
        int n = a.length;
        int count = 0;
        int mini;
        for (i = 0; i < n; i++) {
            mini = i;
            for (j = i; j < n; j++) {
                if (a[j] < a[mini]) {
                    mini = j;
                }
            }
            if (i != mini) {
                temp = a[i];
                a[i] = a[mini];
                a[mini] = temp;
                count++;
            }
        }
        return count;
    }
}

Measured memory_bytes: 24412
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h,w;
		String[] temp = new String[1024];
		String[][] area = new String[10][1024];
		int i,j;
		int x = 0;
		boolean flag = true;
		boolean endflag = false;
		boolean startflag = true;
		h = sc.nextInt();
		w = sc.nextInt();
		for (i = 0;i < h ;i++ ) {
			temp[i] = sc.next();
		}
		for (i = 0;i<h ;i++) {
			for (j=0;j<w;j++) {
				area[i][j] = String.valueOf(temp[i].charAt(j));
			}
		}
		for (i = 0;i < h ;i++ ) {
			startflag = false;
			endflag =false;
			for (j = 0;j < w ;j++ ) {
				if(flag == false){
					break;
				}
				else if(area[i][j].equals("#")){
					if(endflag){
						flag = false;
					}
					else if(!startflag){
						if(j<x){
							flag = false;
						}
						else{
							startflag = true;
						}
					}
					else{
						x++;
					}
				}
				else if(area[i][j].equals(".")){
					if(startflag){
						endflag = true;
					}
				}
			}
		}
	

		if(flag){
			System.out.println("Possible");
		}
		else{
			System.out.println("Impossible");
		}
	}
}

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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

struct Point { int64_t x, y; bool operator<(const Point& o) const { return (x == o.x) ? y < o.y : x < o.x; } };
istream& operator>>(istream& in, Point& p) { return in >> p.x >> p.y; }

int main() {
    int n;
    cin >> n;
    vector<Point> xys(n);
    cin >> xys;

    map<Point, int> pq2cnt;
    for (const auto& a : xys) {
        for (const auto& b : xys) {
            if (a.x == b.x && a.y == b.y) continue;
            pq2cnt[{b.x - a.x, b.y - a.y}]++;
        }
    }
    int max_cnt = 0;
    for (const auto& p : pq2cnt) {
        max_cnt = max(max_cnt, p.second);
    }
    cout << n - max_cnt << '\n';
}


Measured memory_bytes: 384
s = input()
t = input()

slen = len(s)
tlen = len(t)

ans = 0
for i in range(slen-tlen+1):
    tmp = s[i:i+tlen]
    count = 0
    for tm, tt in zip(tmp, t):
        if tm == tt:
            count += 1
    ans = max(ans, count)
print(tlen - ans)

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

int H, W;
char S[50][50];

typedef pair<int, int> P;

int main(){
    cin >> H >> W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++)    cin >> S[i][j];
    }

    int white = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if( S[i][j] == '.' )    white++;
        }
    }

    queue<P> q;
    q.push(P(0, 0));

    int ans[50][50];
    memset(ans, -1, sizeof(ans));
    ans[0][0] = 0;

    int dy[] = {0, 1, 0, -1}, dx[] = {1, 0, -1, 0};
    while( !q.empty() ){
        P yx = q.front();
        q.pop();

        if( yx.first == H-1 && yx.second == W-1 )   break;

        for(int i=0;i<4;i++){
            int ny = yx.first + dy[i];
            int nx = yx.second + dx[i];

            if( 0<=ny && ny<H && 0<=nx && nx<W && S[ny][nx] == '.' && ans[ny][nx] == -1 ){
                ans[ny][nx] = ans[yx.first][yx.second] + 1;
                q.push(P(ny, nx));
            }
        }
    }
    
    if( ans[H-1][W-1] == -1 )   cout << -1 << endl;
    else cout << white - 1 - ans[H-1][W-1] << endl;
    
}

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

int power(int a,int b) {
	long long int mul=1;
	while(b>0) {mul*=a; b--;}
	return mul;
}

int main() {
	int n,a,d=0,sum=0; cin>>n;
	a=n;
	while(a>0) { a/=10; d++; }
	if(d%2==0){  d--;
    while(d>0) { sum+=9*power(10,d-1); d-=2;}
  }
	else {
		sum = n-(power(10,d-1))+1;
		d-=2;
    while(d>0) { sum+=9*power(10,d-1); d-=2;}
	}
	cout<<sum<<endl;
	return 0;
}


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

int n;
long long a, b, t;
vector<pair<long long, long long> > v;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a >> b;
		v.push_back({b, a});
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n; i++){
		t += v[i].second;
		if(t > v[i].first)
			return cout << "No", 0;
	}
	cout << "Yes";
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

// const int mxN = 1e9 + 7;
const int M = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % M;
		b = (b * b) % M;
		e >>= 1; // e/=2;
	}
	return res;
}

int main()
{
	fast;
	int n, cnt = 0;
	cin >> n;
	vll a(n), b;
	FOR(n)
	cin >> a[i];
	sort(all(a), greater<int>());
	ll ans = 0;
	for (int i = 0; cnt < n - 1 && i < n; i++)
	{
		ans += a[i];
		cnt++;
		if (cnt < n - 1 && i)
		{
			ans += a[i];
			cnt++;
		}
	}
	cout << ans << en;
}

Measured memory_bytes: 4780
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b, c;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> c;
    int tmp = a - b;
    c -= tmp;
    if (c < 0) c = 0;
    cout << c << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vector<ll>A(N);
    cin >> A;

    vector<ll> s(N);
    REP(i, N) {
        s[i] = A[i] - (i + 1);
    }

    SORT(s);

    ll ans = 0;
    if (N % 2 == 1) {
        ll mid = s[N / 2];
        REP(i, N) {
            ans += abs(A[i] - (mid + i + 1));
        }
    }
    else {
        ll mid1 = s[N / 2];
        ll mid2 = s[N / 2 - 1];
        ll tmp = 0;
        REP(i, N) {
            ans += abs(A[i] - (mid1 + i + 1));
            tmp += abs(A[i] - (mid2 + i + 1));
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3456
#include<stdio.h>

int main(){
  int x, y, tmp;
  scanf("%d%d",&x, &y);

  if(x > y){
    tmp = x;
    x = y;
    y = tmp;
  }
  
  tmp = y % x;
  while(tmp != 0){
    y = x;
    x = tmp;
    tmp = y % x;
  }

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



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//素因数分解
map<ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
    ll n,p;cin>>n>>p;
    map<ll, ll> mp = prime_factor(p);
    ll ans = 1;
    for(auto itr = mp.begin(); itr!=mp.end(); itr++){
        ll f = itr->first,s = itr->second;
        ans *= pow(f, s/n);
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        for (int j =i-1; j >=0; j--)
        {
            if(s[i] == s[j]){
                 cout << "no" << endl;
                 return 0;
            }
        }
    }
    cout << "yes" << endl;
    return 0;
}

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

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

    string S;
    cin >> S;
    int cnt0 = 0, cnt1 = 0;
    for (auto &c : S) {
        if (c == '0') {
            cnt0++;
        } else {
            cnt1++;
        }
    }
    cout << 2 * min(cnt0, cnt1) << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef double db; 
#define fi first
#define se second 
#define pb push_back
#define vi vector<int>
#define SZ(x) (int)(x.size())
#define sci(x) scanf("%d",&(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
ll modpow(ll x,ll n,ll mod){ll res=1;for(;n;n>>=1,x=x*x%mod)if(n&1)res=res*x%mod;return res;} 
const db eps=1e-8,PI=acos(-1.0);
const int N=33,M=1e6+10,INF=0x3f3f3f3f,mod=1e9+7;//998244353
ll a,b;
int main(){
	scanf("%lld%lld",&a,&b);
	if(a>b)swap(a,b);
	if(a==1)putchar('1');
	else printf("%lld",a*b-(a*b/2));
	return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;

    ll za = a / x;
    if(a != 0 && a % x == 0) --za;
    ll zb = b / x;
    if(a == 0) ++zb;

    cout << zb - za << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;
 
ll N, A[200005], A2[200005];
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        A2[i] = A[i] - (i+1);
    }
    sort(A2, A2+N);
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ans += abs(A[i] - (A2[N/2]+i+1));
    }
    
    cout << ans << "\n";
    
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a,b;cin>>a>>b;
  if(a*b*(a+b)%3==0)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (){
int a,b,k,i,j,c=0;
  scanf ("%d",&k);
  for (i=0;i*4<101;i++){
  for (j=0;(j*7)+(i*4)<101;j++){
  if((j*7)+(i*4)==k){
  c=1;
    break;
  }
  }
  }
  if (k==0){
  printf ("No");
  }
  else if (c==1){
  printf ("Yes");
  }
  else {
  printf ("No");
  }
return 0;
}

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

using namespace std;

int main()
{
        int ans = 0;
        int N;

        cin >> N;
        vector< vector< pair<int, int> > > A(N, vector<pair<int, int>>());
        for (int i = 0; i < N; i++) {
                int a;
                int x, y;

                cin >> a;
                for (int j = 0; j < a; j++) {
                        cin >> x >> y;
                        A.at(i).push_back(pair<int, int>(x, y));
                }
        }
        for (int i = 0; i < pow(2,N); i++) {
                bitset<16> honest(i);
                bool cont = false;
                int sum = 0;

                for (int j = 0; j < N && cont == false; j++) {
                        if (honest.test(j)) {
                                for (int k = 0; k < A.at(j).size(); k++) {
                                        pair<int, int> a = A.at(j).at(k);
                                        if ((honest.test(a.first - 1) && a.second == 0) ||
                                                (!honest.test(a.first - 1) && a.second == 1)) {
                                                cont = true;
                                                break;
                                        }
                                }
                        }
                }
                if (cont == false) {
                        sum = honest.count();
                        if (sum > ans) ans = sum;
                }
        }
        cout << ans << endl;
		return 0;
}

Measured memory_bytes: 256
def input_int_list():
    return [int(thing) for thing in input().split(" ")]

def int_input():
    return int(input())


def print_ans(string):
    print(string)
    exit()

def yes():
    print("Yes")
    exit()

def no():
    print("No")
    exit()

S=input()
T=input()
if len(S)+1!=len(T):
    no()
else:

    if S==T[0:len(S)]:
        yes()
    else:
        no()

Measured memory_bytes: 9008
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<=b){
        for(int i=1;i<=b;i++){
            printf("%d",a);
        }
    }else{
        for(int i=1;i<=a;i++){
            printf("%d",b);
        }
    }
    printf("\n");
}

Measured memory_bytes: 128