akhauriyash/Code-Regression huggingface dataset:
import unittest
import itertools


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([1, 3, 2], [3, 1, 2]), 3)

    def test_2(self):
        self.assertEqual(think([7, 3, 5, 4, 2, 1, 6, 8], [3, 8, 2, 5, 4, 6, 7, 1]), 17517)

    def test_3(self):
        self.assertEqual(think([1, 2, 3], [1, 2, 3]), 0)


def solve():
    p, q = read()
    result = think(p, q)
    write(result)


def read():
    n = read_int(1)[0]
    p = read_int(n)
    q = read_int(n)
    return p, q


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(p, q):
    base = list(p)
    base.sort()
    index_of_p = 0
    index_of_q = 0
    for i, perm in enumerate(itertools.permutations(base)):
        if perm == tuple(p):
            index_of_p = i
        if perm == tuple(q):
            index_of_q = i
    return abs(index_of_p - index_of_q)


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 52844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, t;
  cin >> n >> t;
  ll ans = t;
  vl a(n);
  rep(i, n) cin >> a[i];
  rep(i, n - 1) ans += min(t, a[i + 1] - a[i]);
  cout << ans << endl;
}

Measured memory_bytes: 4680
x1,y1,x2,y2 = map(int,input().split())
vec = (x2-x1, y2-y1)
x3 = x2 - vec[1]
y3 = y2 + vec[0]
x4 = x3 - vec[0]
y4 = y3 - vec[1]

print('{} {} {} {}'.format(x3,y3,x4,y4))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

struct Edge {
	int from, to, cost;
	Edge() {}
	Edge(int f, int t, int c) {
		from = f;
		to = t;
		cost = c;
	}
	bool operator>(const Edge &r) const {
		return cost > r.cost;
	}
};

struct UF {
	int par[200000];
	bool isNamori[200000];
	UF() {
		for (int i = 0; i < 200000; i++) {
			par[i] = i;
			isNamori[i] = false;
		}
	}
	
	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	
	bool can_marge(int x, int y) {
		x = root(x);
		y = root(y);
		if (same(x, y)) {
			return isNamori[x] == false;
		}
		return isNamori[x] == false || isNamori[y] == false;
	}
	
	void marge(int x, int y) {
		x = root(x);
		y = root(y);
		par[x] = y;
		isNamori[y] |= isNamori[x];
	}
	
	void setNamori(int x) {
		x = root(x);
		isNamori[x] = true;
	}
};

int n, h, w;
int r[100000], c[100000], a[100000];
vector<Edge> edges;
UF uf;

signed main() {
	int i;
	
	cin >> n >> h >> w;
	rep(i, n) {
		cin >> r[i] >> c[i] >> a[i];
		r[i]--; c[i]--;
		edges.push_back(Edge(r[i], c[i] + h, a[i]));
	}
	sort(edges.begin(), edges.end(), greater<Edge>());
	
	int ans = 0;
	rep(i, edges.size()) {
		int u = edges[i].from;
		int v = edges[i].to;
		
		if (uf.can_marge(u, v)) {
			if (uf.same(u, v)) {
				uf.setNamori(u);
			}
			else {
				uf.marge(u, v);
			}
			ans += edges[i].cost;
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:u32 = read();
    let b:u32 = read();
    if a * b % 2 == 0 {
        println!("Even")
    } else {
        println!("Odd")
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a>0){cout << "Positive" << endl;}
  else{
    if(b>=0){
      cout << "Zero" << endl;
    }else{
      if((b-a)%2 == 0){
        cout << "Negative" << endl;
      }else{
        cout << "Positive" << endl;
      }
    }
  }
}

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

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define li long long
#define ld long double
#define x first
#define y second
#define pt pair<int, int>
#define pll pair<li, li>
#define forn(i, t) for(int i = 0; i < (t); i++)
#define fore(i, f, t) for(int i = (f); i < (t); i++)
#define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
#define all(x) (x).begin(), (x).end()
#define ins insert

using namespace std;


const int INF = 1e9;
const int MOD = 1e9 + 7;
const li INF64 = 1e18;
const ld EPS = 1e-7;

mt19937 myrand(time(NULL));

const int N = 100 + 7;

int n;
int a[N];

bool read(){
	if(scanf("%d", &n) != 1)
		return 0;
	forn(i, n)
		scanf("%d", &a[i]);
	return 1;
}

void solve(){
	int ans = 0;
	forn(i, n){
		int j = i;
		while (j + 1 < n && a[j + 1] == a[i])
			++j;
		ans += (j - i + 1) / 2;
		i = j;
	}
	printf("%d\n", ans);
}


int main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
	#endif
	while(read())
		solve();
	return 0;
}

Measured memory_bytes: 256
N, X = list(map(int, input().split()))
A = list(map(int, input().split()))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
for i in range(N):
    A[i] = abs(A[i] - X)
g = A[0]
for i in range(1, N):
    g = gcd(g, A[i])
print(g)


Measured memory_bytes: 15020
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    k = int(input())
    q = collections.deque([])
    for i in range(1,10):
        q.append(i)
    for i in range(k-1):
        x = q.popleft()
        if x%10 != 0:
            q.append(10*x + x%10 -1)
        q.append(10*x + x%10)
        if x%10 != 9:
            q.append(10*x + x%10 +1)
    print(q.popleft())

Measured memory_bytes: 18768
#include <stdio.h>
#include <stdlib.h>
int main()
{
	int n;
   scanf("%d",& n);
    int i, N = 0;
	i = 1;
	while (i <= n)
	{
		N = N + i;
		i = i + 1;
	}
	printf("%d\n", N);
	system("pause");
}


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

std::vector<int> v(61),w(61);
const int INF=1e9+7;
int dp[600000][50];//メモリ制限ギリギリまで宣言
int dfs(int S,int X){
  //dfs(S,X)=２進法X桁で表される２数(a,b)で合計がS以下のものの個数　ただし各桁において(aのi桁目)>=(bのi桁目)
  if(S<600000&&S>=0&&X<50&&X>=0){
    int &res=dp[S][X];
    if(res!=-1)return res;
    if(S<0){res=0;return res;}
    if(S>(v[X]-1)*2){res=w[X];return res;}//全パターン
    if(S==0&&X==0){res=1;return res;}
    res=(dfs(S,X-1)+dfs(S-v[X-1],X-1)+dfs(S-v[X],X-1))%INF;return res;
    //((aのi桁目),(bのi桁目))が(0,0),(1,0),(1,1)だった場合の総和で考える
  }
  else{
    int res;
    if(S<0){res=0;return res;}
    if(S>(v[X]-1)*2){res=w[X];return res;}
    if(S==0&&X==0){res=1;return res;}
    res=(dfs(S,X-1)+dfs(S-v[X-1],X-1)+dfs(S-v[X],X-1))%INF;return res;
  }
}

signed main(){
  v[0]=1;for(int i=1;i<61;i++)v[i]=v[i-1]*2;
  w[0]=1;for(int i=1;i<61;i++)w[i]=w[i-1]*3%INF;
  memset(dp,-1,sizeof(dp));
  int N;
  cin>>N;
  cout<<dfs(N,60)<<endl;
}


Measured memory_bytes: 234624
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;

int main() {
	int K, S;
	cin >> K >> S;
	int ans = 0, Z = 0;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			Z = S - i - j;
			if (Z >= 0 && Z <= K) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main(){
    long long int N,K,x,y;
    cin >> N>>K;
    x = N%K;
    if(!x){
        cout << 0;
    }else{
        y=K-x;
        if(x>=y){
            cout << y;
        }else{
            cout << x;
        }
    }
    return 0;
}

Measured memory_bytes: 256
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

  var t = parseInt(readline());
  if (t == 25) print("Christmas");
  else if (t == 24) print("Christmas Eve");
  else if (t == 23) print("Christmas Eve Eve");
  else print("Christmas Eve Eve Eve"); 
}


Measured memory_bytes: 29596
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  int n, i;
  cin>>n;
  int num[100005] = {};
  int a[n];
  for(i = 0; i<n; i++)
  {
      cin>>a[i];
      num[a[i]]++;
      if(a[i]-1>=0) num[a[i]-1]++;
      num[a[i]+1]++;
  }
  cout<<*max_element(num, num + 100005)<<endl;
  //YAY.




return 0;
}



Measured memory_bytes: 4400
import math

n, d = map(int, input().split())

x=[0]*n
y=[0]*n

for i in range(n):
    x[i], y[i] = map(int, input().split())


count = 0
for i in range(n):
    if math.sqrt(x[i]**2 + y[i]**2) <= d:
        count +=1

print(count)


Measured memory_bytes: 73216
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	string n; cin >> n;
	REP(i,3) {
		if (n[i] == '1') cout << 9;
		else cout << 1;
	}
	cout << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807/2;
const int MOD = 1000000007;
const int H_MAX = pow(10,4);
const int W_MAX = pow(10,4);

vector<vector<ll>> dp(H_MAX, vector<ll>(H_MAX, -1)); 
vector<vector<bool>> m(W_MAX, vector<bool>(H_MAX, true));

ll dfs(int h, int w) {
  if (h==0 && w==0) return dp[0][0] = 1;
  if (dp[h][w] != -1) return dp[h][w];

  ll result = 0;
  if (h!=0&&m[h-1][w]) result += dfs(h-1, w);
  if (w!=0&&m[h][w-1]) result += dfs(h, w-1);
  return dp[h][w] = result % MOD;
}

int main() {
  int H, W; cin >> H >> W;
  rep(i, H) {
    string row; cin >> row;
    rep(j, W) if (row[j]=='#') m[i][j]=false;
  }

  dfs(H, W);
  // rep(i, H) { rep(j, W) {cout << dp[i][j] << " ";} cout << endl; }
  cout << dp[H-1][W-1] << endl;
  return 0;
}

Measured memory_bytes: 794752
import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    long mod = 1000000000+7;
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = sc.nextInt();
        long ans = 0;
        // first compute in-array situation
        long latterAdd = k*(k+1)/2, earlierAdd = k*(k-1)/2;
        for(int i=0;i<n;i++){
            // first consider the cases that originally index bigger
            for(int j=i+1;j<n;j++){
                if(a[j]<a[i]) ans = (ans+latterAdd)%mod;
            }
            // then consider the cases that originally smaller
            for(int j=i-1;j>=0;j--){
                if(a[j]<a[i]) ans = (ans + earlierAdd)%mod;
            }
        }
        return ans;
    }
}



Measured memory_bytes: 25544
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >> n;
    unordered_map<ll, ll> hmap;
    rep(i,0,n)
    {
        ll a;
        cin >> a; 
    
        if (1<=a && a<400)    
            hmap[0]++; 
        else if (400<=a && a<800)    
            hmap[1]++; 
        else if (800<=a && a<1200)    
            hmap[2]++; 
        else if (1200<=a && a<1600)    
            hmap[3]++; 
        else if (1600<=a && a<2000)    
            hmap[4]++; 
        else if (2000<=a && a<2400)    
            hmap[5]++; 
        else if (2400<=a && a<2800)    
            hmap[6]++; 
        else if (2800<=a && a<3200)    
            hmap[7]++; 
        else if (a>=3200)
            hmap[8]++; 
    }
   
    ll _min(0), _max(0); 
    rep(i,0,8)
        if (hmap[i]!=0)
            _min++; 

    _max = _min + hmap[8];

    cout << max(_min,1ll) << ' ' << _max << endl;

    return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  if(a*b<=0)cout<<"Zero"<<endl;
  else if(a>0)cout<<"Positive"<<endl;
  else if((b-a)%2==1)cout<<"Positive"<<endl;
  else cout<<"Negative"<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Prog{
  static void Main(){
    var n = int.Parse(Console.ReadLine());
    int[] lsa = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int[] lsb = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int[] lsc = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int k = 0;
    for(int i = 0;i<n-1;i++){
      if(lsa[i+1] - lsa[i] == 1){
        k += lsc[lsa[i]-1];
      }
    }
    Console.WriteLine(k + lsb.Sum());
  }
}









Measured memory_bytes: 13268
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int K = in.nextInt();
            int H[] = CPUtils.readIntArray(N, in);
            Arrays.sort(H);
            int i;
            for (i = N - 1; i >= 0 & K > 0; i--)
            {
                K--;
            }
            long attacks = 0;
            for (; i >= 0; i--)
            {
                attacks += H[i];
            }
            out.print(attacks);
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 87596
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int dp[1 << 15][110];
int solve_testcase() {
    int N, M; scanf("%d%d", &N, &M);
    if(N == 0 and M == 0) return 1;

    vector<int> S(N), D(M);
    for(int i=0; i<N; i++) scanf("%d", &S[i]);
    for(int i=0; i<M; i++) scanf("%d", &D[i]);
    sort(D.begin(), D.end());

    vector<int> S_sum(1 << N);
    for(int bit=0; bit<(1<<N); bit++) {
        for(int i=0; i<N; i++) {
            if(bit >> i & 1) S_sum[bit] += S[i];
        }
    }
    
    fill(dp[0], dp[1<<N], INF);
    dp[0][0] = 0;
    for(int i=0; i<M; i++) {
        for(int bit=0; bit<(1<<N); bit++) {
            // そのまま使う
            chmin(dp[bit][i+1], dp[bit][i] + abs(S_sum[bit] - D[i]));

            // 1 個増やす
            for(int j=0; j<N; j++) {
                if(bit >> j & 1) continue;
                int nbit = bit | (1 << j);
                chmin(dp[nbit][i], dp[bit][i]);
            }
        }
    }

    int ans = INF;
    for(int bit=0; bit<(1<<N); bit++) chmin(ans, dp[bit][M]);
    printf("%d\n", ans);
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



Measured memory_bytes: 17500
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll len = S.size();
    ll ans[2] = {0, 0};
    REP(i, 0, len) {
        if (S[i] == '0') {
            ans[0]++;
        } else {
            ans[1]++;
        }
    }
    cout << min(ans[0], ans[1]) * 2 << endl;
}


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

int main()
{
  string S,T;cin>>S>>T;
  S+=S;
  for(int i=0;i<(int)S.size()-(int)T.size();i++)
  {
    bool check=true;
    for(int j=0;j<(int)T.size();j++)
    {
      if(T[j]!=S[i+j])check=false;
    }
    if(check){printf("Yes\n");return 0;}
  }
  printf("No\n");
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int n,m;
  cin >> n >> m;
  if(n == m) cout << "Yes";
  else cout << "No" << endl;
}


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

int main(){
    int n;
    int a[5];
    for(int i=0 ; i < 5 ; i++ ){
        cin >> a[i];
    }
    sort( a , a+5 );
    for(int i=4 ; i >= 0 ; i-- ){
        if( i != 4 ) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

Measured memory_bytes: 1176
fun main(args: Array<String>) {
    val (N, X) = listOfInt()
    val x = listOfInt()
    val d = x.map { Math.abs(X - it) }
    val ans = d.reduce { acc, value -> gcd(acc, value) }
    println(ans)
}
fun gcd(a: Int, b: Int): Int = if (b > 0) gcd(b, a % b) else a

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 51592
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, noe=0;
	cin>>n;
	int a[100], b[100]={0};
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		if(a[i]%2==0)
		{
			b[i]=a[i];
			noe++;
		}
	}
	int cnt=0;
	for (int i = 0; i < n; ++i)
	{
		if(b[i]!=0)
		{
			if(b[i]%3==0 || b[i]%5==0)
				cnt++;
		}

	}
	if(noe==0)
		cout<<"APPROVED"<<endl;

	else if(cnt==noe)
		cout<<"APPROVED"<<endl;

	else
		cout<<"DENIED"<<endl;

return 0;
}

Measured memory_bytes: 256
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int n, k;
    cin >> n >> k;
    vi arr(n);
    forn(i, n) cin >> arr[i];
    sort(all(arr));
    int ans = 0;
    forn(i, k) ans += arr[i];
    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;    
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>                          
using namespace std;
int n,d,x,a[105],tmp;
long long m;
int main(){
    cin>>n>>d>>x;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++)
	{
        tmp=a[i];
        if(tmp<d) tmp++,m+=2;
        else{m++;continue;}
        while(tmp<d)
        {
            tmp+=a[i];
            if(tmp<=d) m++;
            else break;
        }
    }
    cout<<m+x<<endl;
    return 0;
}
//68871358
//76140264

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

using namespace std;
typedef long long ll;

int main(){
  ll N;
  cin >> N;
  ll ans=0;
  /*
  for(ll i=1;i<N;i++){
    ll k=N-i;
    ll an =0;
    ll t;
    for(ll j=1;j*j<=k;j++){
      if(k%j==0) an++;
      t=j;
    }
    if(t*t==k){
      ans += 2*an - 1;
    }else{
      ans += 2*an;
    }
    */
  for(int i=1;i<N;i++){
    ans += (N-1)/i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3192
import Data.List(find,delete)
import Data.Maybe

slice :: Int -> [a] -> [[a]]
slice _ [] = []
slice n xs = let (y,ys) = splitAt n xs
             in  y : slice n ys

insert :: Int -> a -> [a] -> [a]
insert _ _ [] = []
insert n y xs = let (z,zs) = splitAt n xs
                in  ins n y z zs
    where   ins _ _ z [] = z
            ins n y z zs = z ++ y : insert n y zs

num xs y = val $ find (\x -> take 3 x == y) xs
    where val Nothing = "0"
          val (Just xs) = show $ last xs

f :: [[Int]] -> [[Int]]
f [] = []
f (x:xs) =  let x2 = find (\x2 -> take 3 x2 == take 3 x) xs
            in  if (x2 == Nothing) then
                    x : (f xs)
                else
                    let x2' = fromJust x2
                    in  f $ ((take 3 x) ++ [last x + last x2']) : (delete x2' xs)

main = do
    _ <- getLine
    cs <- getContents
    let xs = f (zipWith ($) (repeat (\c -> map read $ words c)) (lines cs))
    let ys = [[b,f,r] | b <- [1..4], f <- [1..3], r <- [1..10]]
    putStr $ unlines $ insert 3 (replicate 20 '#') $ slice 20 (' ' : (unwords $ map (num xs) ys))

Measured memory_bytes: 4316
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, sum, last, cnt, ans, a[100000];
string str,ss;
bool f;
char c[10000][10000];
struct Edge { LL to,cost; };
vector<Edge>vec[1000];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	rep(i, 3) {
		cin >> a[i];
	}
	sort(a, a + 3);
	ans += a[2] - a[1];
	a[0] += a[2] - a[1];
	ans += (a[2] - a[0]) / 2+((a[2]-a[0])%2==0?0:2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<random>
using namespace std;

int main(){
    int H,W;
    cin>>H>>W;

    vector<string> a(H);
    vector<vector<char>> A(H,vector<char>(W));

    for (int i=0;i<H;i++){
        cin>>a[i];
    }

    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            A[i][j]=a[i][j];
        }
    }

    queue<long int> q;
    queue<long int> sub;

    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            if (A[i][j]=='#'){
                q.push(W*i+j);
            }
        }
    }

    int ans=0;

    while (q.size()){
        while (q.size()){
            long int i=q.front();
            q.pop();
            int h=i/W;
            int w=i%W;
            if (h!=H-1 && A.at(h+1).at(w)=='.'){
                A.at(h+1).at(w)='#';
                sub.push(i+W);
            }

            if (h!=0 && A.at(h-1).at(w)=='.'){
                A.at(h-1).at(w)='#';
                sub.push(i-W);
            }

            if (w!=W-1 && A.at(h).at(w+1)=='.'){
                A.at(h).at(w+1)='#';
                sub.push(i+1);
            }

            if (w!=0 && A.at(h).at(w-1)=='.'){
                A.at(h).at(w-1)='#';
                sub.push(i-1);
            }
        }
        if (sub.size()){
            ans+=1;
        }
        while (sub.size()){
            long int i=sub.front();
            sub.pop();
            q.push(i);
        }

    }

    cout<<ans;
}

Measured memory_bytes: 10512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int n,m;
  cin>>n>>m;

  int a=1;
  for(int i=0;i<m;i++){
    a*=2;
  }

  cout<<(100*(n-m)+1900*m)*a<<endl;


  return 0;
}


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

int gcd(int a, int b){
	int tmp;
	if (a < b){
		tmp = b % a;
		if (tmp == 0) return a;
		else gcd(a, tmp);
	}else{
		tmp = a % b;
		if (tmp == 0) return b;
		else gcd(b, tmp);
	}
}

int main(void){
	int a, b;
	cin >> a >> b;
	cout << gcd(a,b) << endl;
	return 0;
}

Measured memory_bytes: 1164
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = parseInt(input[0][0], 10);
    let K = parseInt(input[0][1], 10);
    let bitVec = Array.from({length:N}, () => true);
    let A = [];
    for (let i = 0; i < K; i++){
        A = input[2 * i + 2].map(e => parseInt(e, 10));
        for (x of A){
            bitVec[x - 1] = false;
        }
    }
    let ans = 0;
    for (let x of bitVec){
        if (x) ans++;
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < (int)v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

int N,M,T;
int p[100],t[100],c[100];
bool d[100][100];
vector<int> g[100],idx[100];
bool vis[100];
int dp[100][10001];
bool loop[100];

void dfs(int v){
  vis[v]=true;
  rep(j,T+1)dp[v][j]=0;
  for(int nv : g[v]){
    if(!vis[nv])dfs(nv);
    rep(j,T+1)maxch(dp[v][j],dp[nv][j]);
  }
  for(int i : idx[v]){
    int num=c[i];
    for(int k=1;num>0;k<<=1){
      int ml=min(k,num);
      for(int j=T;j>=t[i]*ml;j--){
        maxch(dp[v][j],dp[v][j-t[i]*ml]+p[i]*ml);
      }
      num-=ml;
    }
  }
}

int main(){
  while(1){
    cin>>N>>M>>T;
    if(N==0)break;
    UnionFind uf(N);
    vector<P> es;
    rep(i,N)cin>>p[i]>>t[i]>>c[i];
    memset(d,0,sizeof(d));
    rep(i,N){
      g[i].clear();
      idx[i].clear();
      vis[i]=false;
      loop[i]=false;
      d[i][i]=true;
    }
    rep(i,M){
      int a,b;
      cin>>a>>b;
      a--;b--;
      if(a==b){
        loop[a]=true;
        continue;
      }
      es.push_back(P(a,b));
      d[a][b]=true;
    }
    M=es.size();
    rep(k,N)rep(i,N)rep(j,N)d[i][j]|=(d[i][k]&d[k][j]);
    rep(i,N)rep(j,N){
      if(d[i][j]&&d[j][i])uf.unite(i,j);
    }
    rep(i,M){
      g[uf.find(es[i].fi)].push_back(uf.find(es[i].se));
    }
    rep(i,N){
      rep(j,N){
        if(uf.find(j)==i)idx[i].push_back(j);
      }
      if(idx[i].size()==1&&!loop[idx[i][0]])c[idx[i][0]]=1;
    }
    int res=0;
    rep(i,N){
      if(idx[i].size()==0)continue;
      if(!vis[i])dfs(i);
      maxch(res,dp[i][T]);
    }
    cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 7060
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	for ( int n, w; cin >> n >> w, n | w; )
	{
		int num_bars = 0;
		VI occur( 100 );

		REP( i, 0, n )
		{
			int v;
			cin >> v;

			occur[ v / w ] ++;
			num_bars = max( num_bars, v / w + 1 );
		}

		const int max_height = *max_element( ALL( occur ) );

		double res = 0.01;
		REP( i, 0, num_bars )
		{
			res += ( 1. * occur[i] / max_height ) * ( 1. * ( num_bars - i - 1 ) / ( num_bars - 1 ) );
		}
		cout << res << endl;
	}
	
	return 0;
}

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

double absd(double x){
  if(x<0.0){
    x *= -1.0;
  }
  return x;
}

int main(){
  double n, sum=0.0, ave;
  int ii;
  double sa;
  cin >> n;
  vector<double> a(n);
  for (int i = 0; i < n;i++){
    cin >> a[i];
    sum += a[i];
  }
  ave = sum / n;
  sa = absd(ave - a[0]);
  ii = 0;
  for (int i = 0; i < n;i++){
    double tmp = absd(ave - a[i]);
    if(sa>tmp){
      sa = tmp;
      ii = i;
    }
  }
  cout << ii << endl;
  return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
    #define loop(i,a,b) for(int i=a;i<b;i++)
    #define loopb(i,a,b) for(int i=a;i>=b;i--)
    #define loopm(i,a,b,step) for(int i=a;i<b;i+=step)
    #define loopbm(i,a,b,step) for(int i=a;i>=b;i-=step)
    #define pb(a) push_back(a)
    #define mp(a,b) make_pair(a,b)
    #define init(arr,val) memset(arr,val,sizeof(arr))
    #define INF 1000000007
    #define MOD 1000000007
    #define BINF 1000000000000000001
    #define int long long int
    #define double long double
     
    using namespace std;
 

  
    
     
    #undef int
    int main()
    {
    #define int long long int
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        //freopen("input.txt","r",stdin);
        
        int t=1;
        //cin>>t;
        while(t--)
        {
        	int n;
        	cin>>n;
        	if(n<=999) cout<<"ABC";
        	else cout<<"ABD";
        }
             
            
        
        return 0;
    } 

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

#define se second
#define fi first
#define mod 1000000007

typedef pair<int,int> pii;

int N,M;
vector<pii> V[500];
int dp[310][310][310];

int P(int a,int b,int c)
{
    if(dp[a][b][c] != -1)return dp[a][b][c];
    long long res = 0;
    int A,B,C;
    A = max(a,max(b,c));
    C = min(a,min(b,c));
    B = a + b + c - A - C;
    //printf(" %d %d %d\n",a,b,c);
    for(int i = 0; i < V[A].size(); i++)
    {
        pii now = V[A][i];
        int cou = 1;
        if(B >= now.fi)cou++;
        if(C >= now.fi)cou++;
        if(cou != now.se)return dp[a][b][c] = 0;
    }
    if(A == N)return 1;
    res = P(A + 1,b,c);
    res += P(a,A + 1,c);
    res %= mod;
    res += P(a,b,A + 1);
    res %= mod;
    return dp[a][b][c] = res;
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= N; j++)
        {
            for(int k = 0; k <= N; k++)
            {
                dp[i][j][k] = -1;
            }
        }
    }
    for(int i = 0; i < M; i++)
    {
        int l,r,k;
        scanf("%d%d%d",&l,&r,&k);
        V[r].push_back(make_pair(l,k));
    }
    printf("%d\n",P(0,0,0));
    /*for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= N; j++)
        {
            for(int k = 0; k <= N; k++)
            {
                printf(" %d %d %d   %d\n",i,j,k,P(i,j,k));
            }
        }
    }*/
    return 0;
}


Measured memory_bytes: 114944
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string s, t;
    cin >> s >> t;
    int n = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) n++;
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int M;
	cin >> M;
	cout << 24 + (24 - M) << endl;
}

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


//panasonic programming contest 2020 d

void dfs(string S,int n,string lis){
    if(S.size()==n) cout << S << endl;
    else{
        for(auto c : lis){
            S.push_back(c);
            dfs(S,n,lis);
            S.pop_back();
        }
        char last = lis[lis.size()-1]+1;
        S.push_back(last);
        lis.push_back(last);
        dfs(S,n,lis);
    }
}


int main(){
    int n;
    cin >> n;
    string s = "a";
    dfs(s,n,s);
}




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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll s[333333];
ll t[333333];

int main() {
   int n;
   cin >> n;
   vec<ll> a(3*n);
   for (ll &x : a) cin >> x;

   pq<ll, vector<ll>, greater<ll>> Q;
   ll sum = 0;
   rep (i, 3*n) {
      Q.push(a[i]);
      sum += a[i];
      if (Q.size() > n) {
         sum -= Q.top();
         Q.pop();
      }
      s[i] = sum;
   }

   pq<ll> P;
   sum = 0;
   for (int i = 3*n-1; i >= 0; i--) {
      P.push(a[i]);
      sum += a[i];
      if (P.size() > n) {
         sum -= P.top();
         P.pop();
      }
      t[i] = sum;
   }

   // rep (i, 3*n) printf("%3lld ", s[i]);
   // cout << endl;
   // rep (i, 3*n) printf("%3lld ", t[i]);
   // cout << endl;

   ll ans = -1e18;
   for (int i = n-1; i < 2*n; i++) {
      ans = max(ans, s[i] - t[i+1]);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 9204
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long[] a = new long[n + 1];
		int cnt = 0;
		for (int i = 1; i < n + 1; i++) {
			int tmp = sc.nextInt();
			if (tmp > n) {
				cnt++;
				continue;
			}
			a[tmp]++;
		}
		for (int i = 1; i < n + 1; i++) {
			if (a[i] > i)
				cnt += a[i] - i;
			else if (a[i] < i)
				cnt += a[i];
		}
		System.out.println(cnt);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22480
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	 ll n;
	 cin>>n;
	 ll p1=1;
	 ll p2=n;
	 for(ll i=1;i*i<=n;i++)
	 {
	 	if(n%i==0)
	 	{
	 		if(i+n/i<p1+p2)
	 		{
	 			p1=i;
	 			p2=n/i;
			 }
		 }
	 }
	 ll ans=(p1-1)+(p2-1);
	 cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    map<string, int> memo;
    int n; cin>>n;
    rep(i, n){
        string s;
        cin>>s;
        memo[s] += 1;
    }
    int maxv=0;
    for(const auto& x : memo){
        int v=x.second;
        if(v > maxv) maxv=v;
    }
    for(auto it=memo.begin(); it != memo.end(); it++){
        if(it->second == maxv){
            cout<<it->first<<endl;
        }
    }
}

Measured memory_bytes: 19092