akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int comp(const int *a,const int *b){
	return (*b - *a);
}

int main(int argc, char const *argv[])
{
	int n,*l;
	int cnt = 0;
	scanf("%d",&n);
	l = (int *)malloc(sizeof(int) * (2 * n));
	for (int i = 0; i < 2 * n; ++i)	scanf("%d",&l[i]);
	qsort(l,(2 * n),sizeof(int),comp);
	for (int i = 0; i < 2 * n; i += 2)
	{
		if(l[i] < l[i + 1])	cnt += l[i];
		else cnt += l[i + 1];
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = pow(10, 9) + 7;
//const int mod = 998244353;
//const int mod = ;
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int x, y;
  cin >> x >> y;

  int A = abs(abs(y) - abs(x));

  int B;
  if (x * y > 0)
  {
    if (x <= y) B = 0;
    else B = 2;
  }
  else if (x * y == 0)
  {
    if (x < y) B = 0;
    else B = 1;
  }
  else B = 1;
  
  int ans = A + B;
  cout << ans << endl;
}

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

int main() {
  int h,w,n,ans;
  cin >> h >> w >> n;
  ans = n/max(h,w);
  if(n%max(h,w) != 0) ans++;
  cout << ans << endl;
}

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

int main()
{
  ll n;cin>>n;
  ll arr[n+1],ans=0;
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i];
    if(i%2 !=0 && arr[i]%2 !=0) ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 3632
fn main() {
    let (a, b, k) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut ws = line.split_whitespace();
        let a: i32 = ws.next().unwrap().parse().unwrap();
        let b: i32 = ws.next().unwrap().parse().unwrap();
        let k: i32 = ws.next().unwrap().parse().unwrap();
        (a, b, k)
    };
    let list = (1 .. std::cmp::min(a, b) + 1)
        .filter(|x| a % x == 0 && b % x == 0)
        .collect::<Vec<i32>>();
    println!("{}", list[(list.len() as i32 - k) as usize]);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#define MOD_P 1000000007
#define ll long long
using namespace std;

struct point {
	int coord[10];
};

int distance2(point& ob1, point& ob2, int d)
{
	int dis = 0;
	for (int i = 0; i < d; i++) {
		dis += (ob1.coord[i] - ob2.coord[i]) * (ob1.coord[i] - ob2.coord[i]);
	}

	return dis;
}

bool isSquea(int dis)
{
	int i = 0;
	while (1) {
		if (i * i == dis)return true;
		if (i * i > dis)return false;
		i++;
	}

}

int main()
{
	int n, d;
	int ans = 0;
	cin >> n >> d;
	point* dp = new point[n];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> dp[i].coord[j];
		}
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (isSquea(distance2(dp[i], dp[j],d))) {
				ans++;
			}
		}
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
-- import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import GHC.Magic (oneShot)


main :: IO ()
main = do
  n <- read <$> getLine
  ls <- VU.unfoldrN n (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  print $ binSearch ls 0 n

{-# INLINE binSearch #-}
binSearch :: VU.Vector Int -> Int -> Int -> Int
binSearch !ls = go
  where
    go ng ok | ok - ng <= 1          = ok
             | isPossibleWith mid ls = go ng  mid
             | otherwise             = go mid ok
      where
        mid = (ok + ng) `shiftR` 1

{-# INLINE isPossibleWith #-}
isPossibleWith :: Int -> VU.Vector Int -> Bool
isPossibleWith 1 !ls = VU.and $ VU.zipWith (<) ls (VU.tail ls)
isPossibleWith numChars !ls
  = VU.foldr loop (\ !len_ !chars_ -> True) ls 0 Nil
  where
    {-# INLINE loop #-}
    loop = \ !reqLen cont -> oneShot $ \ !wordLen -> oneShot $ \ !chars ->
      if reqLen > wordLen
      then cont reqLen chars
      else countUpCps (cont reqLen) numChars (cutOff chars reqLen) (reqLen-1) 

data List = Nil | Snoc !List {-# UNPACK #-} !Int {-# UNPACK #-} !Int
 deriving Show

-- assumes numChars > 1
{-# INLINE countUpCps #-}
countUpCps :: (List -> Bool) -> Int -> List -> Int -> Bool
countUpCps cont !numChars = go
  where
    go !xs !ind | ind < 0 = False
    go (Snoc xs i e) ind | i == ind = if | e >= numChars - 1 -> go xs (ind-1)
                                         | otherwise -> cont $! Snoc xs i (e+1)
    go xs ind = cont $! Snoc xs ind 1

{-# INLINE cutOff #-}
cutOff :: List -> Int -> List
cutOff !xs !till = go xs
  where
    go (Snoc xs i e) | i >= till = go xs
    go xs = xs


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

namespace ABC136_E_Max_GCD
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NK[0];
            var K = NK[1];
            var Ai = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            var AiSum = Ai.Sum();
            var candidates = new List<long>();
            for (long i = 1; i <= Math.Sqrt(AiSum); i++)
            {
                if (AiSum % i == 0)
                {
                    candidates.Add(i);
                    candidates.Add(AiSum / i);
                }
            }
            candidates = candidates.OrderByDescending(s => s).ToList();

            long answer = 0;
            foreach (long candidate in candidates)
            {
                var AiMod = Ai.Select(s => s % candidate).OrderByDescending(s => s).ToArray();
                var manupilationCount = AiMod.Skip((int)(AiMod.Sum() / candidate)).Sum();
                if (manupilationCount <= K)
                {
                    answer = candidate;
                    break;
                }
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 17652
/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define mp make_pair
#define sz size()
#define eps 1e-8

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN(100005);

int n;

long long a[MAXN];

long long f(int c){

    long long num = 0, ans = 0;

    REP(i,n)
    {
        long long t = a[i]+num;

        if(c > 0 && t <= 0)
        {
            num += (1-t);
            ans += (1-t);
        }

        else if(c < 0 && t >= 0)
        {
            num += (-1-t);
            ans += (t-(-1));
        }

        c *= -1;
    }

    return ans;

}

int main(){

    S("%d",&n);
    REP(i,n)
    {
        int x;
        S("%d",&x);
        a[i] = x;
    }

    REP(i,n-1)
        a[i+1] += a[i];

    cout << min(f(1), f(-1)) << endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int N; 
long long h[100010];
long long dp[100010];
int main(){
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i] ;
    for (int i = 0; i < N; ++i) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < N; ++i){
        chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
cout << dp[N - 1] << endl;    
    
    
    
    
}

Measured memory_bytes: 1792
def main():
    from collections import defaultdict, deque

    N, K = map(int, input().split())
    a = map(int, input().split())

    def accumulate(a, mod):
        s = 0
        yield s
        for x in a:
            s = (s + x - 1) % mod
            yield s

    *acc, = accumulate(a, mod=K)

    d = defaultdict(int)
    dq = deque()
    ans = 0
    for x in acc:
        ans += d[x]
        d[x] += 1
        dq.append(x)
        if len(dq) >= K:
            r = dq.popleft()
            d[r] -= 1
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

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

	int t[N+1], b[N+1];
	rep(i,N) {
		t[i] = 0;
		b[i] = 0;
	}
	for (int i = 1; i <= N; i++) {
		int a;
		cin >> a;
		t[i] = t[i-1] + a;
	}
	int totb = 0;
	for (int i = 1; i <= N; i++) {
		int a;
		cin >> a;
		b[i] = b[i-1] + a;
		totb += a;
	}
	for (int i = N; i > 0; i--) {
		b[i] = totb - b[i-1];
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans = max(ans,t[i]+b[i]);
	}

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


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s.at(i);
    for(int i=0; i<2*h; i++){
        cout << s.at(i/2) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 1;

int main() {
  int N;
  // auto H = vector<int>(N);
  cin >> N;
  int max_cnt = 0;
  int cnt = 0;
  int prev = 0;
  REP(i, N) {
    int H;
    cin >> H;
    if(H <= prev) {
      cnt++;
    } else {
      max_cnt = max(max_cnt, cnt);
      cnt = 0;
    }
    prev = H;
  }
  max_cnt = max(max_cnt, cnt);
  cout << max_cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner
import Math._

object Main {
  def main(args: Array[String]): Unit = {

    val sc = new Scanner(System.in)
    val a = sc.nextDouble()
    val b = sc.nextDouble()
    val h = sc.nextDouble()
    val m = sc.nextDouble()

    val needleM = 360D * m / 60D
    val needleH = 360D * (h * 60 + m) / (12D * 60D)


    val angC = abs(needleH - needleM) match {
      case x if x > 180D => 360D - x
      case x => x
    }

    val c = sqrt(pow(a, 2D) + pow(b, 2D) - (2D * a * b) * cos(Math.toRadians(angC)))

    println(c)
  }

}


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

const int INF=99999999;

void get_dinetwork(int N,vector<vector<int>>& array){
    int u,k,x;

    for(int i=0;i<N;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>x;
            array[u-1][x-1]=1;
        }
    }

}

int bfs(int n,vector<vector<int>>& A,int v,vector<int>& d,vector<int>& flag){
        d[v]=0;
        flag[v]=1;
        queue<int> Q;
        for(int i=0;i<n;i++){if(A[v][i]==1){Q.push(i);}}
        int dmin;
        while(!Q.empty()){
                dmin=INF;
                for(int i=0;i<n;i++){if(A[i][Q.front()]==1 && d[i]<dmin){dmin=d[i];}}
                d[Q.front()]=dmin+1;
                flag[Q.front()]=1;
                for(int i=0;i<n;i++){if(A[Q.front()][i]==1 && flag[i]!=1){Q.push(i);}}
                Q.pop();
        }
}

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

        int n;
        cin>>n;
        vector<vector<int>> array(n,vector<int>(n,0));
        get_dinetwork(n,array);

        //
        vector<int> d(n,INF);
        vector<int> flag(n,-1);
        //
        bfs(n,array,0,d,flag);
        //

        for(int i=0;i<n;i++){
                if(d[i]==INF){d[i]=-1;}
                cout<<i+1<<" "<<d[i]<<"\n";
        }

        return 0;

}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

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

	map<int,bool> mp;
	rep(i,k){
		int d;
		cin >> d;
		rep(j,d){
			int x;
			cin >> x;
			mp[x]=true;
		}
	}
	int ans = n;
	for(auto x: mp){
		ans--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }



signed main() {
	int N, K;
	cin >> N >> K;
	if (N % 2 == 1) N++;
	if (K * 2 <= N) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int input() {
    int h, m;
    std::cin >> h >> m;
    return h * 60 + m;
}

void solve() {
    int t1 = input(),
        t2 = input();
    int k;
    std::cin >> k;

    std::cout << t2 - t1 - k << "\n";
}

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

    solve();

    return 0;
}


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


signed main() {
    ll A;
    string B;
    cin >> A;
    cin >> B;

    B[1] = B[2];
    B[2] = B[3];
    B[3] = '\0';
    ll num = atoi(B.c_str());

    A *= num;
    A /= 100;

    cout << A << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("03")
#pragma GCC optimize ("unroll-loops")
#define ll long long
#define ms(a,b) memset(a,b,sizeof(a))
#define endl '\n'
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define mpp(a,b,c) make_pair(a,make_pair(b,c))
#define fi first
#define se second
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repp(a,b,c) for(int a=b;a>=c;a--)
ll val[200]={0},wei[200]={0};
ll n,maxw,memo[200][100100]={0},res;
ll dp(ll idx,ll wnow){
	if(wnow>maxw)return -1e18;
	if(idx>n)return 0;
	else if(memo[idx][wnow])return memo[idx][wnow];
	else{
		ll temp;
		temp = max(dp(idx+1,wnow),dp(idx+1,wnow+wei[idx])+val[idx]);
		return memo[idx][wnow]=temp;
	}
}
int main(){
/////////////////////////////////////////////
	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
/////////////////////////////////////////////
	cin >> n >> maxw;
	rep(i,1,n){
		cin >> wei[i] >> val[i];
	}
	res = dp(1,0);
	cout << res << endl;


	return 0;
}


Measured memory_bytes: 78080
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <climits>

using namespace std;

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

    vector<int> x;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        x.push_back(tmp);
    }

    int ans = INT_MAX;
    for(int i=0; i + k-1 < n; i++){
        int diff = abs(x[i] - x[i+k-1]);
        diff += min(abs(x[i]), abs(x[i+k-1]));
        ans = min(ans, diff);
    }

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

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    char A[60][60];
    char B[60][60];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> A[i][j];
        }
    }

    for(int i = 0; i < M; i++){
        for(int j = 0; j < M; j++){
            cin >> B[i][j];
        }
    }

    bool exist = false;
    for(int ly = 0; ly < N; ++ly){
        for(int lx = 0; lx < N; ++lx){
            if(ly + M - 1 >=  N || lx + M -1 >= N) continue;

            bool match = true;
            for(int y = 0; y < M; y++){
                for(int x = 0; x < M; x++){
                    if(A[ly+y][lx+x] != B[y][x]) match = false;
                }
            }
            if(match) exist = true;
        }
    }
    if(exist) 
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}
/*
方針はあってた，実装力が身につかない→問題の中で身につけていく必要あり
今回の場合4重のうちの 中側2つはM×Mの全探索
外側2つはN×Nの全探索でif文で例外を除く
for文は基本0~定数でif文continueなどで例外を除く方が良いか
*/

Measured memory_bytes: 3540
open Batteries
open BatPrintf
open BatBigarray

let scan fmt f =
  BatScanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> BatString.split_on_char ' '
  |> List.map cnv

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let n = scan "%s" identity
let k = scan "%d" identity

let () =
  let len = String.length n in
  let dp = Array3.create Int C_layout 2 (len+1) len in
  Array3.set dp 0 0 0 1;
  if len < k then
    printf "%d\n" 0
  else
    let open BatEnum in
    iter (fun i ->
        let d = int_of_string @@ String.of_char @@ String.get n (i-1) in
        iter (fun j ->
            Array3.set dp 1 i j @@ (Array3.get dp 1 (i - 1) j) * 9 +
                                   (if j > 0 then
                                      Array3.get dp 1 (i - 1) (j - 1)
                                    else 0) +
                                   if d > 0 then
                                     (d - 1) * (Array3.get dp 0 (i - 1) j) + (if j > 0 then Array3.get dp 0 (i - 1) (j - 1) else 0)
                                   else
                                     0;
            Array3.set dp 0 i j @@
            if d > 0 then
              Array3.get dp 0 (i-1) j
            else if j > 0 then
              Array3.get dp 0 (i-1) (j-1)
            else
              0
          ) (0 --^ len);
      ) (1 -- len);
    printf "%d\n" @@ Array3.get dp 1 len (len - k) + Array3.get dp 0 len (len - k)


Measured memory_bytes: 4992
using System;

public class p0004{
	p0004(){
		string str;
		string[] s;
		double[] a = new double[6];
		double r1, r2, t;
		
		while((str = Console.ReadLine()) != null){
			s = str.Split(' ');
			for(int i = 0; i < 6; ++i)
				a[i] = (double)(int.Parse(s[i]));
			t = a[0]*a[4]-a[1]*a[3];
			r1 = (a[4]*a[2]-a[1]*a[5])/t;
			r2 = (a[0]*a[5]-a[3]*a[2])/t;
			Console.WriteLine("{0} {1}", r1.ToString("f3"), r2.ToString("f3"));
		}
	}
	
	public static int Main(string[] args){
		new p0004();
		return 0;
	}
}

Measured memory_bytes: 5680
#include<iostream>
using namespace std;
#include<algorithm>
#include<functional>

int main(){
	int n,k,i;
	long long int num = 0;
	cin >> n;
	cin >> k;
	int h[n];
	for(i = 0; i < n; i++){
		cin >> h[i];
	}
	sort(h, h+n, greater<int>());
	for(i = k; i < n; i++){
		num = num + h[i];
	}

	cout << num;
	return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n = int(input())
S = [ input() for _ in range(n)]

left = 0
right = 0

LMR = [0] * n
MIN_LMR = [0] * n

for i,s in enumerate(S):
    l = 0
    r = 0
    lok = True
    for j,c in enumerate(s):
        if c == "(":
            l += 1
        else:
            r += 1
            if r > l:
                lok = False
        MIN_LMR[i] = min(MIN_LMR[i], l-r)
    LMR[i] = l - r

    left += l
    right += r

if left != right:
    print("No")
    exit()


positives = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x > 0 ]
zeros     = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x == 0 ]
negatives = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x < 0]
for i in range(len(negatives)):
    # 負の要素だけ、裏返して末尾から見た値に変換する
    min_lmr, lmr = negatives[i]
    min_lmr = min_lmr - lmr
    lmr = -1 * lmr
    negatives[i] = (min_lmr, lmr)

positives.sort(reverse=True)
negatives.sort(reverse=True)

h = 0
for min_lmr, lmr in positives + zeros:
    if h+min_lmr < 0:
        print("No")
        exit()
    h += lmr

h = 0
for min_lmr, lmr in negatives:
    if h+min_lmr < 0:
        print("No")
        exit()
    h += lmr

print("Yes")


Measured memory_bytes: 193700
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007
#define MAXN 3010
using namespace std;

int Dp[MAXN][MAXN][2][2];
int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	
	memset(Dp,0,sizeof(Dp));
	for(int i=1;i<=n;i++)Dp[0][i][1][0]=1;
	Dp[0][0][1][1]=1;
	
	for(int i=1;i<=m;i++)
	{
		for(int j=0;j<=n-1;j++)
		{
			if(j==0)
			{
				Dp[i][j][0][0]=0;
				Dp[i][j][0][1]=((Dp[i-1][j+1][1][0]+Dp[i-1][j+1][1][1])%MOD+Dp[i-1][j][1][1])%MOD;
			}
			else
			{
				Dp[i][j][0][0]=(Dp[i-1][j+1][1][0]+Dp[i-1][j][1][0])%MOD;
				Dp[i][j][0][1]=(Dp[i-1][j+1][1][1]+Dp[i-1][j][1][1])%MOD;
			}
		}
		for(int j=0;j<=n;j++)
		{
			if(j==0)
			{
				Dp[i][j][1][0]=0;
				Dp[i][j][1][1]=Dp[i][j][0][1];
			}
			else
			{
				Dp[i][j][1][0]=(Dp[i][j][0][0]+Dp[i][j-1][0][0])%MOD;
				Dp[i][j][1][1]=(Dp[i][j][0][1]+Dp[i][j-1][0][1])%MOD;
			}
		}
	}
		

	
	
	
	ll res=0;
	
	for(int i=0;i<=n;i++)	
	{
		res=(res+(ll)Dp[m][i][1][1]+(ll)MOD)%MOD;
	}
	
	printf("%I64d\n",res);
	return 0;	
} 

Measured memory_bytes: 141824
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter

n, *a = map(int, read().split())

c = Counter(a)
ans =0
for k, v in c.items():
    if v >= k:
        ans += v - k
    elif v < k:
        ans += v
print(ans)


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string w;
    cin>>w;
    int arr[26]={0};
    for (char i:w){
        arr[i-'a']++;
    }for (int i:arr){
        if (i%2==1){
            cout<<"No"<<endl;
            return 0;
        }
    }cout<<"Yes"<<endl;
    return 0;

}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  map<int, int> mo;
  map<int, int> me;
  rep(i, n) ((i % 2) ? me : mo)[v[i]]++;
  vector<pair<int, int>> vo;
  vector<pair<int, int>> ve;
  for(auto x: mo) vo.emplace_back(x.second, x.first);
  for(auto x: me) ve.emplace_back(x.second, x.first);
  sort(vo.begin(), vo.end()); reverse(vo.begin(), vo.end());
  sort(ve.begin(), ve.end()); reverse(ve.begin(), ve.end());
  int ans;
  if(vo[0].second != ve[0].second){
    ans = n - vo[0].first - ve[0].first;
  }else{
    ans = n + 1;
    if(vo.size() > 1) ans = min(ans, n - vo[1].first - ve[0].first);
    if(ve.size() > 1) ans = min(ans, n - vo[0].first - ve[1].first);
    if(ans == n + 1) ans = n / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6520
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int a[3];
  for (int i = 0; i < 3; ++i) scanf("%d", &a[i]);
  sort(a, a + 3);
  if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}


Measured memory_bytes: 256
import heapq

def check(h, T, A, B):
    # T回の爆破でいける？ -> BがT回行われる下で、残ったモンスターをT回のA - Bダメ攻撃で倒せる？
    que = []
    for hi in h:
        if hi - B * T > 0:
            que.append(- hi + B * T)
    que.sort()
    A_count = 0
    for q in que:
        count = (-q + (A - B) - 1) // (A - B)
        A_count += count
    
    return A_count <= T


N, A, B = map(int, input().split(" "))
h = []
for _ in range(N):
    h.append(int(input()))

lower, upper = 0, 10 ** 15

while upper - lower > 1:
    mid = (upper + lower) // 2
    if check(h, mid, A, B):
        upper = mid
    else:
        lower = mid

print(upper)

Measured memory_bytes: 119128
n = gets.chomp.to_i
al = gets.chomp.split.map(&:to_i)

a = Array.new(n, 0)
# 1:+, -1:-
n.times do |i|
  next if i == 0
  a[i] = 1 if al[i] - al[i-1] > 0
  a[i] = -1 if al[i] - al[i-1] < 0
  a[i] = a[i-1] if al[i] == al[i-1]
end

ans = 1000
kabu = 0
(a.length - 1).times do |i|
  # buy
  if a[i+1]-a[i] > 0
    kabu = ans / al[i]
    ans = ans % al[i]
    next
  end
  # sell
  if a[i+1]-a[i] < 0
    ans += kabu * al[i]
    kabu = 0
    next
  end
end
ans += kabu * al[-1] if kabu > 0

p ans

Measured memory_bytes: 14344
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    ll h,w;cin>>h>>w;
    vector<vector<ll>> ab(h,vector<ll>(w,0));
    vector<vector<ll>> b(h,vector<ll>(w));
    REP(i,h)REP(j,w)cin>>ab[i][j];
    REP(i,h)REP(j,w){cin>>b[i][j];ab[i][j]-=b[i][j];}
    ll r=2*80*80+1;
    vector<vector<vector<bool>>> dp(h,vector<vector<bool>>(w,vector<bool>(r,false)));
    dp[0][0][abs(ab[0][0])]=true;
    REP(i,h){
        REP(j,w){
            REP(k,r){
                if(dp[i][j][k]){
                    if(i!=h-1)dp[i+1][j][abs(k+ab[i+1][j])]=true;
                    if(i!=h-1)dp[i+1][j][abs(k-ab[i+1][j])]=true;
                    if(j!=w-1)dp[i][j+1][abs(k+ab[i][j+1])]=true;
                    if(j!=w-1)dp[i][j+1][abs(k-ab[i][j+1])]=true;
                }
            }
        }
    }
    REP(k,r)if(dp[h-1][w-1][k]){cout<<k<<endl;return 0;}
}


Measured memory_bytes: 13960
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int w, h, x, y, r;
    cin>>w>>h>>x>>y>>r;
    if(0<=x-r && x+r<=w && 0<=y-r && y+r<=h) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 1172
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int c =0;
    
    for(int i=A; i<B+1; i++) {
      if(String.valueOf(i).substring(0,1).equals(String.valueOf(i).substring(4, 5)) && 
        String.valueOf(i).substring(1,2).equals(String.valueOf(i).substring(3, 4))) {
      c++;
      }
    }
      
    System.out.println(c);
  }
}

Measured memory_bytes: 38740
n,m = map(int,input().split())
h = list(map(int,input().split()))
nf = [1] * n
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if h[a] > h[b]:
    nf[b] = 0
  elif h[a] < h[b]:
    nf[a] = 0
  else:
    nf[a] = 0
    nf[b] = 0
print(nf.count(1))

Measured memory_bytes: 20044
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Counting Roads
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

/* global variables */

int cs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int ai, bi;
    cin >> ai >> bi;
    ai--, bi--;
    cs[ai]++, cs[bi]++;
  }

  for (int i = 0; i < n; i++) printf("%d\n", cs[i]);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main()
{
    int h,w,n,sum=0;
    cin>>h>>w>>n;
    if(h>=w){
        rep(i,w){
            sum+=h;
            if(sum>=n){
                cout<<i+1;
                return 0;
            }
        }
    }
    else{
        rep(i,h){
            sum+=w;
            if(sum>=n){
                cout<<i+1;
                return 0;
            }
        }
    }
}

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

using namespace std;

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

int main(){
    int n; cin>>n;
    rep(i,n){
        cout << "Case " << i+1 << ":" << endl;
        int a; cin >> a;
        rep(j,10){
            a*=a;
            a/=100;
            a = a-a/10000*10000;
            cout << a << endl;
        }
    }
}
 

Measured memory_bytes: 1160
import scala.io.StdIn._
import scala.math._

object Main {
  def calDebt(n: Int, debt: Int): Int = {
    n match {
      case 0 => debt
      case _ =>
        val debtNum = (BigDecimal(debt) * 1.05).setScale(-3, BigDecimal.RoundingMode.CEILING).toInt
        calDebt(n - 1, debtNum)
    }
  }

  def main(args: Array[String]): Unit = {
    val weeks = readInt()
    println(calDebt(weeks, 100000))
  }
}

Measured memory_bytes: 43768
case = 1
while True:
    N = int(raw_input())
    if N == 0: break
    
    mat = [[0 for i in range(N)] for j in range(N)]
    
    n = 1
    for i in range(N): # upper half
        for j in range(i,-1,-1):
            if i%2==0:
                mat[j][i-j] = n
                n += 1
            elif i%2==1:
                mat[i-j][j] = n
                n += 1
                
    for i in range(N,2*N-1): # lower half
        for j in range(N-1,i-N,-1):
            if i%2==0:
                mat[j][i-j] = n
                n += 1
            elif i%2==1:
                mat[i-j][j] = n
                n += 1
                
    print 'Case %d:'%(case);  case += 1
    
    for s in mat:
        print ''.join(map(str,[str(st).rjust(3) for st in s]))
    

Measured memory_bytes: 4264
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
#include <map>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
int main()
{
    string S; cin >> S;
    cout << count(S.begin(), S.end(), '1') << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
# C = [int(i) for i in input().split()]
town = []
for i in range(N):
    x, y = [int(_) for _ in input().split()]
    town.append([i, x, y])

T = itertools.combinations(town, 2)
d_sum = 0
for t in T:
    xi = t[0][1]
    yi = t[0][2]
    xj = t[1][1]
    yj = t[1][2]
    d = ((xi - xj)**2 + (yi - yj)**2)**0.5
    d_sum += d

print(d_sum*2/N)


Measured memory_bytes: 38640
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "

using namespace std;
///check n=1;
///check corner case;

int main()
{
   ll n,i,j,cc=INT_MIN;
   vector<string>str;
   map<string,ll>check;
   set<string>ans;
   cin>>n;
   for(i=0;i<n;i++){
    string c;
    cin>>c;
    str.push_back(c);
    check[c]++;
    ll x=check[c];
    if(x>cc)cc=x;
   }
   for(i=0;i<n;i++){
    if(cc==check[str[i]])ans.insert(str[i]);
   }
   for(auto it : ans)cout<<it<<endl;
return 0;
}


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

int main() {
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	int cnt = 0;
	int max = 0;
	for (int i = 0; i < n-1; i++) {
		if (h[i+1] <= h[i]) {
			cnt++;
		} else {
			if (max < cnt) {
				max = cnt;
			}
			cnt = 0;
		}
	}
	if (max < cnt) {
		max = cnt;
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 4004
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()
    T = input().strip()

    ans = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            ans += 1

    print(ans)




if __name__ == '__main__':
    main()



Measured memory_bytes: 9364
import sys
s = input()
dic = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(s),0,-1):
    for j in dic:
        if not j in s[:i]:
            if i == len(s):
                print(s[:i]+j)
                sys.exit()
            else:
                if dic.index(s[i]) < dic.index(j):
                    print(s[:i]+j)
                    sys.exit()
else:
    if s[0] != "z":
        print(dic[dic.index(s[0])+1])
    else:
        print(-1)

Measured memory_bytes: 3064
<?php

$rate = (int)fgets(STDIN);
$rank = 0;

if($rate >= 1800){
	$rank = 1;
}
else if($rate >= 1600){
	$rank = 2;
}
else if($rate >= 1400)
{
	$rank = 3;
}
else if($rate >= 1200)
{
	$rank = 4;
}
else if($rate >= 1000)
{
	$rank = 5;
}
else if($rate >= 800)
{
	$rank = 6;
}
else if($rate >= 600)
{
	$rank = 7;
}else
{
	$rank = 8;
}

printf($rank);

?>


Measured memory_bytes: 16252
#include<stdio.h>

int main(void){

    int n;
    int w[100];
    int i,t,k;//制御
    int s1=0,s2=0;
    int premin;
    int realmin;

scanf("%d",&n);

for(i=0;i<n;i++){
    scanf("%d",&w[i]);
}

for(t=0;t<n-1;t++){
    s1=0;
    s2=0;
    for(i=0;i<=t;i++){
        s1=s1+w[i];
    }
    for(i=t+1;i<n;i++){
        s2=s2+w[i];
    }
    if(s2>s1){
    premin=s2-s1;
}
else{
    premin=s1-s2;
}
if(t==1){
    realmin=premin;
}

if(premin<realmin){
    realmin=premin;
}
}



printf("%d",realmin);




return 0;

}


Measured memory_bytes: 128
import math
def f(n):
    cnt=0
    while n!=0:
        n = int(n/10)
        cnt += 1
    return cnt
a,b = map(int,input().split())
x = a*(10**f(b))+b
if math.sqrt(x)==int(math.sqrt(x)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 505;
const ll mod = 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;

int n,m;
char mp[maxn][maxn];
const int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

int dfs(int x,int y)
{
    int ans=0;
    for(int i=0;i<8;i++)
    {
        int tx=x+dir[i][0];
        int ty=y+dir[i][1];
        if(tx>=0&&tx<n&&ty>=0&&ty<m&&mp[tx][ty]=='#')
            ans++;
    }
    return ans;
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%s",mp[i]);
    }
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
    {
        if(mp[i][j]=='#') continue;
        int ans=dfs(i,j);
        mp[i][j]=ans+'0';
    }
    for(int i=0;i<n;i++)
    {
        printf("%s\n",mp[i]);
    }
    return 0;
}


Measured memory_bytes: 128
def find(x):
    while x!=T[x][0]:
        x = T[x][0]
    return x
def union(x,y):
    a = find(x)
    b = find(y)
    if T[a][1]>T[b][1]:
        T[b][0] = a
    elif T[a][1]==T[b][1]:
        T[b][0] = a
        T[a][1] += 1
    else:
        T[a][0] = b
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
T = {i:[i,1] for i in range(1,N+1)}
for j in range(M):
    x,y,z = A[j]
    a = find(x)
    b = find(y)
    if a!=b:
        union(a,b)
C = [0 for _ in range(N+1)]
for i in range(1,N+1):
    a = find(i)
    if C[a]==0:
        C[a] = 1
print(sum(C))

Measured memory_bytes: 109420
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A;
map<ll,ll> sh;
void input(){
    fast_io();
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        ll a; cin >> a;
        A.push_back(a);
        sh[a] = 0;
    }
}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


int WAsolve(){
    int i=0;
    for(auto &p:sh){
        p.second = i;
        i++;
    }
    for(auto &a:A) a = sh[a];
    DBG(A)
    for (int i = 0; i < N-2; i++)
    {
        if(A[i]>A[i+2]) swap(A[i],A[i+2]);
    }

    for (int i = N-1; i >= 2; i--)
    {
        if(A[i-2]>A[i]) swap(A[i-2],A[i]);
    }
    DBG(A)
    BinaryIndexedTree<int> bit(N+1);
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(i) ans += i-bit.sum(A[i]);
        bit.add(A[i],1);
    }
    cout << ans << endl;
    return 0;
}   

int solve(){
    int i=0;
    for(auto &p:sh){
        p.second = i;
        i++;
    }
    for(auto &a:A) a = sh[a];
    int ans = 0;
    DBG(A)
    for (int i = 0; i < N; i++)
    {
        if(i%2==0 && A[i]%2==1) ans++;
        else if(i%2==1 && A[i]%2==0) ans++;
    }
    cout << ans/2 << endl;
    return 0;
}

int main()
{
    input();
    solve();
    return 0;
}

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

int main(){
	int t;
	string str;
	cin>>t>>str;
	if(t&1)cout<<"No\n";
	else {
		int i=0,j=t/2,f=1;
		for(int c=0;c<t/2;c++){
			if(str[i]==str[j]){
				i++;j++;
			}
			else{
				f=0;
				cout<<"No\n";
				break;
			}
		}
		if(f)cout<<"Yes\n";
		
	}
	return 0;
} 

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

public class Main {

 public static void main(String[] args){
       InputStream in = System.in;
       Scanner sc = new Scanner(in);
       
       int N = sc.nextInt();
       int Y = sc.nextInt();
       
       for(int x = 0; x <= N; x++){
       		for(int y = 0; y <= N - x; y++){
			int z = N - (x + y);
			int checker = (x * 10000) + (y * 5000) + (z * 1000);
			
			if(checker == Y){
				System.out.println(x + " " + y + " " + z);
				System.exit(0);
			}
       		}
       }
       
       System.out.println("-1 -1 -1");
       
 }

}

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

typedef long long ll;
using namespace std;

int main(){
	
	int n;
	cin >> n;
	vector<int> heights(n);
	for(auto& x:heights){
		cin >> x;
	}
	int INF = 1<<30;
	//we need to define how to get to the i'th stone with minimum cost
	vector<int> dp(n+1, INF); //dp[i] mejor costo en i
	
	dp[0]=0;
	for(int i=0;i<n;++i){
		if(i-1>=0)
			dp[i]=min( dp[i], dp[i-1]+abs(heights[i]-heights[i-1]));
		if(i-2>=0)
			dp[i]=min( dp[i], dp[i-2]+ abs(heights[i]-heights[i-2]));
	}
	
	cout << dp[n-1];
	

	return 0;
}


Measured memory_bytes: 1024