akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

int H, W, S, U;
int a[35][35];
Pii dp[35][35][35][35];

Pii merge(Pii p, Pii q) {
    return Pii(p.first + q.first, min(p.second, q.second));
}

int calcSum(int x1, int y1, int x2, int y2) {
    return a[x1][y1] - a[x2][y1] - a[x1][y2] + a[x2][y2];
}

Pii dfs(int x1, int y1, int x2, int y2) {
    // cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    Pii& ret = dp[x1][y1][x2][y2];    // (#group, mergin)
    if (ret != Pii(0, inf)) return ret;

    if (calcSum(x1, y1, x2, y2) >= U) {
        ret = Pii(1, calcSum(x1, y1, x2, y2) - U);
    } else {
        return ret;
    }

    rep2(c, y1 + 1, y2) {
        ret = max(ret, merge(dfs(x1, y1, x2, c), dfs(x1, c, x2, y2)));
    }
    rep2(r, x1 + 1, x2) {
        ret = max(ret, merge(dfs(x1, y1, r, y2), dfs(r, y1, x2, y2)));
    }

    return ret;
}

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

    while (cin >> H >> W >> S, H) {
        rep(i, H + 1) rep(j, W + 1) a[i][j] = 0;
        rep(i, H) rep(j, W) cin >> a[i][j];
        rep(i, H) {
            rrep(j, W) {
                a[i][j] += a[i][j + 1];
            }
        }
        rep(j, W) {
            rrep(i, H) {
                a[i][j] += a[i + 1][j];
            }
        }
        U = calcSum(0, 0, H, W) - S;
        assert(U > 0);

        rep(i, H + 1) rep(j, W + 1) rep(k, H + 1) rep(l, W + 1) dp[i][j][k][l] = Pii(0, inf);
        printP(dfs(0, 0, H, W));
    }

}

Measured memory_bytes: 24176
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

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

int main(){
   int w, n,array[100],a,b;
   char c;
   
   cin >> w >> n;
   FOR(i,1,w+1) array[i]=i;
   REP(i,n){
      cin >> a >> c >> b;
      swap(array[a],array[b]);
   }
   FOR(i,1,w+1) cout << array[i]<< endl;
   return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string a, b; cin >> a >> b;
    rep(i, b.size())cout << a.at(i) << b.at(i);
    if (a.size() - b.size() == 1)cout << a.at(a.size() - 1) << endl;
    else cout << endl;
}

Measured memory_bytes: 3516
#include <iostream>
using namespace std;
int main(){
	long long A,B,C,X,Y,sum=0;
	cin>>A>>B>>C>>X>>Y;
	if(2*C<A+B){
		if(X>Y){
			sum=2*C*Y;
			if(A<=2*C)sum+=A*(X-Y);
			else sum+=2*C*(X-Y);
		}else{
			sum=2*C*X;
			if(B<=2*C)sum+=B*(Y-X);
			else sum+=2*C*(Y-X);
		}
	}else{
		sum=A*X+B*Y;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;cin>>N>>K;
    vector<int> cnt(N);
    for(int i=0;i<K;i++){
        int x;cin>>x;
        for(int j=0;j<x;j++){
            int a;cin>>a;
            a--;
            cnt[a]=1;
        }
    }
    
    int ans=0;
    for(int i=0;i<N;i++) if(cnt[i]==0) ans++;
    
    cout<<ans<<endl;
}



Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }
ll mod = 1e9+7;
signed main() {
    vl ret; ll n; cin>>n;
    vector<double>v(n);
    rep(i,n)cin>>v[i];
    sort(v.begin(),v.end());
    double ans = (v[0]+v[1])/2;
    if(n>2){
        for(int i=2;i<n;i++){
            ans=(ans+v[i])/2;
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
    using namespace std;
 
    typedef long long ll;
    typedef long double ld;
 
    typedef pair<int, int> pi;
    typedef pair<ll,ll> pl;

    typedef vector<int> vi;
    typedef vector<ll> vl;
    typedef vector<pi> vpi;
    typedef vector<pl> vpl;
    typedef vector<vi> vvi;

    #define FOR(i, a, b) for (int i=a; i<(b); i++)
    
    #define sz(x) (int)(x).size()
    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
    #define lb lower_bound
    #define ub upper_bound
    #define all(x) x.begin(), x.end()
 
    template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
    template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
    
    #define trav(container, it) for(typeof(container.begin()) it=container.begin(); it!=container.end(); it++)
 
    #define PI 3.14159265358979323846264338327950L
    const int MOD = 1000000007;
    const char nl = '\n';
 
    int main() 
    {
        ios_base::sync_with_stdio(0); cin.tie(0);
        int n,m;cin>>n>>m;
        vi h(n+1);
        FOR(i,1,n+1) cin>>h[i];

        vvi adj(n+1);

        int x,y;
        FOR(i,1,m+1)
        {
            cin>>x>>y;
            adj[x].pb(y);
            adj[y].pb(x);
        }
        
        bool flag;
        int count=0;

        FOR(i,1,n+1)
        {
            flag=true;

            for(auto child : adj[i])
            {
                if(h[child] >= h[i]) flag=false;
            }
            if(flag) count++;
        }

        cout<<count;
    }


Measured memory_bytes: 8700
#include<stdio.h>
int main(void){
      int i,j,a,b;

  while(1){
    scanf("%d %d",&a,&b);
     if(a==0&&b==0) break;
     for(i=0;i<a;i++){
         for(j=0;j<b;j++){
           printf("#");
         }
       printf("\n");
       }
   printf("\n");
   }
return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  int m = 0, s = 0, l;
  REP(i,n) {
    cin >> l;
    s += l;
    m = max(m,l);
  }
  
  cout << (m < s - m ? "Yes" : "No") << endl;

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a, b, c, x, y, ans=0, piz;
    cin >> a >> b >> c >> x >> y;
    if(a+b<=2*c) {
        ans=a*x+b*y;
        cout << ans <<endl;
        return 0;
    }
    else ans=2*c*min(x, y);
    if(x<=y) piz=b;
    else piz=a;
    if(2*c<=piz) ans+=2*c*abs(x-y);
    else ans+=piz*abs(x-y);
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    a = LI()
    for i in range(n):
        a[i] -= 1
    p = [[a[i]] for i in range(n)]
    for i in range(60):
        for x in range(n):
            p[x].append(p[p[x][i]][i])
    x = 0
    while k:
        i = int(math.log(k,2))
        x = p[x][i]
        k -= 1<<i
    print(x+1)
    return

#Solve
if __name__ == "__main__":
    solve()


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



int N;
vector<int> L;

int main(){
	cin >> N;
	
	L.resize(N);
	for ( int i = 0; i < N; i++ ){
		cin >> L[i];
	}
	
	sort( L.begin(), L.end() );
	
	ll count = 0;
	for ( int i = 0; i < N-2; i++ ){
		for ( int j = i+1; j < N-1; j++ ){
			auto it = lower_bound(L.begin(), L.end(), L[i]+L[j]);
			int l = it - L.begin();
			count += ( l - (j+1) );
		}
	}
	
	cout << count << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector> 
using namespace std; //cin, coutを使う
int main()
{
    int K;
    string S;

    cin >> K >> S;

    if(K >= S.size()){
        cout << S << endl;
    }else{
        cout << S.substr(0,K) + "..." << endl;
    }

}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int vec_sum(vector<int> A, vector<int> B, int C, int M)
{
    int sum = 0;
    for (int i = 0; i < M; ++i)
        sum += A[i]*B[i];

    return sum + C;
}

int main()
{
    int N, M, C; cin >> N >> M >> C;
    vector<int> B(M, 0);
    for (int i = 0; i < M; ++i)
        cin >> B[i];


    vector <int> A(M, 0);

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

        if (vec_sum(A, B, C, M) > 0)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
    int a,b;
    cin >> a >> b;
    cout << a+b/2 << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    for (int i = 0; i <3; i++) cin >> s, cout << (char)toupper(s[0]);
}


Measured memory_bytes: 256
import java.util.*;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		if (d <= s * t) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 35624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll k,s;cin >> k >>s;
    ll ans=0;
    rep(i,k+1){
        rep(j,k+1){
            if(s-i-j<=k&&s-i-j>=0){
                ans++;
            }
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoderTest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var v = cin.ReadIntArray(n);
            var c = cin.ReadIntArray(n);
            var m = 0;
            for (int i = 0; i < n; i++)
            {
                if ((v[i] - c[i]) > 0)
                {
                    m += (v[i] - c[i]);
                }
            }
            WriteLine($"{m}");
//            var wait = cin.Read;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

struct DICE {
int d1,d2,d3,d4,d5,d6;
};

void MoveDice(struct DICE *p,char c);

int main(){
struct DICE p;char compass;struct DICE *pp;
scanf("%d %d %d %d %d %d\n",&p.d1,&p.d2,&p.d3,&p.d4,&p.d5,&p.d6);
scanf("%c", &compass);
while(compass!='\n'){
MoveDice(&p,compass);
scanf("%c", &compass);
}
printf("%d\n",p.d1);
return 0;
}

void MoveDice(struct DICE *p,char c){
int tmp;
tmp=p->d1;
switch(c){
case 'W':
p->d1=p->d3;p->d3=p->d6;p->d6=p->d4;p->d4=tmp;
break;
case 'E':
p->d1=p->d4;p->d4=p->d6;p->d6=p->d3;p->d3=tmp;
break;
case 'N':
p->d1=p->d2;p->d2=p->d6;p->d6=p->d5;p->d5=tmp;
break;
case 'S':
p->d1=p->d5;p->d5=p->d6;p->d6=p->d2;p->d2=tmp;
break;
}
}

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

int main() {
    int N; cin >> N;
    vector<int> A1(N), A2(N);
    for (int i = 0; i < N; i++){
        cin >> A1[i];
    }
    for (int i = 0; i < N; i++){
        cin >> A2[i];
    }
    vector<int> r1(N), r2(N);
    r1[0] = A1[0]; r2[N-1] = A2[N-1];
    for (int i = 1; i < N; i++){
        r1[i] = r1[i - 1] + A1[i];
        r2[N-1-i] = r2[N-i] + A2[N -i - 1];
    }
    int m = 0;
    for (int i = 0; i < N; i++){
        m = max(m, r1[i] + r2[i]);
    }
    cout << m << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(size_t i = 0; i < n; i++) {
        cin >> a[i];
    }
    //[0,j)までの累積和
    vector<ll> rui(n + 1, 0);
    for(size_t i = 1; i < n + 1; i++) {
        rui[i] = rui[i - 1] + a[i - 1];
    }
    //切る位置
    ll P, Q, R, S, ans = LLONG_MAX;
    ll Po, Qo, Ro, So;
    for(int i = 2; i < n - 1; i++) {
        int l, r;
        l = 0;
        r = i;
        while(l + 1 < r) {
            int m = (l + r) / 2;
            if(rui[m + 1] <= rui[i] / 2) {
                l = m;
            } else {
                r = m;
            }
        }
        P = rui[l + 1];
        Po = rui[r + 1];
        Q = rui[i] - rui[r];
        Qo = rui[i] - rui[r + 1];
        l = i;
        r = n;
        while(l + 1 < r) {
            int m = (l + r) / 2;
            if(rui[m + 1] - rui[i] <= (rui[n] - rui[i]) / 2) {
                l = m;
            } else {
                r = m;
            }
        }
        R = rui[l + 1] - rui[i];
        Ro = rui[r + 1] - rui[i];
        S = rui[n] - rui[r];
        So = rui[n] - rui[r + 1];
        // cout << P << ":" << Q << ":" << R << ":" << S << endl;
        ans = min(ans, max({P, Q, R, S}) - min({P, Q, R, S}));
        if(min({Po, Qo}) > 0) {
            ans = min(ans, max({Po, Qo, R, S}) - min({Po, Qo, R, S}));
        }
        if(min({Ro, So}) > 0) {
            ans = min(ans, max({P, Q, Ro, So}) - min({P, Q, Ro, So}));
        }
        if(min({Po, Qo, Ro, So}) > 0) {
            ans = min(ans, max({Po, Qo, Ro, So}) - min({Po, Qo, Ro, So}));
        }
    }
    cout << ans << endl;
}


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

const int MD = 998244353;
const int M = 3030;
int n, s;
vector<int> a;

int main() {
    while (scanf("%d %d", &n, &s) == 2) {
        a.assign(n, 0);
        for (int i = 0; i < n; i++) cin >> a[i];
        
        vector<int> sum(M, 0);
        int res = 0;
        for (int i = 0; i < n; i++) {
            int x = a[i];
            sum[0] = i + 1;
            if (s - x >= 0) {
                //cerr << "i: " << i << ", res: " << res << "->";
                res = (res + 1ll * sum[s - x] * (n - i) % MD) % MD;
                //cerr << res << "\n";
            }

            vector<int> nSum = sum;
            for (int i = 0; i < M; i++) {
                if (i + x >= M) continue;
                nSum[i + x] = (nSum[i + x] + sum[i]) % MD;
            }
            sum = nSum;
        }
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 int N =sc.nextInt();
      
      
      for(int i=1; i<=9; i++)for(int a=1; a<=9; a++){

        if(i*a==N){
        System.out.println("Yes");
          return;
        }
      }
        System.out.println("No");
    }
}

Measured memory_bytes: 22740
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInts :: IO [Integer]
readInts = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readStrings :: IO [BS.ByteString]
readStrings = BS.words <$> BS.getLine

main :: IO ()
main = do
  readInts
  s <- getLine
  print $ solve 0 "" s

solve :: Int -> String -> String -> Int
solve acc before [] = acc
solve acc before (x:xs)
  | before == "A" && x == 'B' = solve acc (before ++ [x]) xs
  | before == "AB" && x == 'C' = solve (acc + 1) "" xs
  | x == 'A' = solve acc "A" xs
  | otherwise = solve acc "" xs

Measured memory_bytes: 380
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<long,long> P;
const long INF = 1000000;

long N,M,Q;
long c[100000],v[100000];
int d[100000];

vector<long> G[100000];

long dp[100000][10];
long col[100000];

void rec(long s,int n,long co);

int main(){
	scanf("%ld %ld",&N,&M);
	for(long i=0;i<M;i++){
	  	long a,b;
		scanf("%ld %ld",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	scanf("%ld",&Q);
	for(long i=0;i<Q;i++){
		scanf("%ld %d %ld",&v[i],&d[i],&c[i]);
		v[i]--;
	}

	for(long i=Q-1;i>=0;i--){
		rec(v[i],d[i],c[i]);
	}



	for(long i=0;i<N;i++){
		printf("%ld\n",col[i]);
	}


	return 0;
}

void rec(long s,int n,long co){
	if(n==0){
		if(col[s]==0) col[s] = co;
		return;
	}
	if(dp[s][n]!=0) return;
	dp[s][n] = 1;
	rec(s,n-1,co);
	for(int i=0;i<G[s].size();i++){
		rec(G[s][i],n-1,co);
	}

}


Measured memory_bytes: 17524
N = int(input())
A = list(map(int, input().split()))
count = 0
judge = False
while True:
    for i in range(N):
        if A[i] % 2 != 0:
            judge = True
    if judge:
        break;
    for j in range(N):
        A[j] /= 2
    count += 1
print(count)


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


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def is_same(self, x, y):
        if self.root(x) == self.root(y):
            return True
        else:
            return False

    def unite(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]



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



s = S()
t = S()
s_len= len(s)
t_len = len(t)
if s_len < t_len:
    s *= (t_len // s_len + 1)
s *= 2


A = z_algorithm(t + '?' + s)[t_len + 1: ]
graph = [[] for _ in range(s_len)]
U = UnionFind(s_len)

flag = False
for i in range(s_len):
    if A[i] == t_len:
        if U.is_same(i, (i + t_len) % s_len):
            flag = True
            break
        U.unite(i, (i + t_len) % s_len)


if flag:
    print(-1)
else:
    print(max(U.size) - 1)

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

int	main() {
	long N;
	cin >>N;
	for (long i=1; i<=3500; i++)
		for (long j=1; j<=3500; j++) {
			long D=N*i*j;
			long E=4*i*j - N*(i+j);
			if (0>=E)
				continue;
			if (0==D%E) {
				long k= D/E;
				cout <<i <<' ' <<j <<' ' <<k <<endl;
				return 0;
			}
		}
	return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int c[10][100000];
int k[100000];
bool d[10];
int h,w,v,z;
int main(){
	while(true){
	cin>>h>>w;
	if(!h&&!w)break;
	v=1;
	rep(i,w)k[i]=0;
	rep(i,h){
		d[i]=false;
		rep(j,w){
			cin>>c[i][j];
			k[j]+=c[i][j];
		}
		v*=2;
	}
	int ans=0;
	rep(r,v){
		int cnt=0;
		rep(i,w)cnt+=max(k[i],h-k[i]);
		ans=max(ans,cnt);
		z=1;
		rep(i,h){
			if(!((r+1)%z)){
				rep(j,w){
					k[j]++;
					if(c[i][j]-d[i])k[j]-=2;
				}
				d[i]=1-d[i];
			}
			z*=2;
		}
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3524
#include<stdio.h>
main(){
  int n;
  int i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    if(i%3==0){
      printf(" %d",i);
    }else{
      j = i;
      while(j>0){
        if(j%10==3){
          printf(" %d",i);
          break;
        }
        j /= 10;
      }
    }
  }
  printf("\n");
}

Measured memory_bytes: 1028
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
int x[20][20];
int ans;
signed main(){
  int n,d;
  cin >> n >> d;
  REP(i,n){
    REP(j,d){
      cin >> x[i][j];
    }
  }
  REP(i,n-1){
    for(int j = i+1;j<n;j++){
      int dis = 0;
      REP(k,d){
        dis += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      int a = (int)(sqrt((double)dis)+eps);
      if(a*a == dis) ans ++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define deque vector
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );
void Oli(){
    int n;
    cin>>n;
    vector<int> L(n);
    for(int i=0;i<n;i++){
        cin>>L[i];
    }
    int sum = 0;
    for(int a= 0;a<L.size();a++){
        for(int b= a + 1;b<L.size();b++){
            for(int c= b +1;c<L.size();c++){
                if (a!=b && b!=c && c!=a && L[a]!=L[b]&& L[b]!=L[c] && L[c]!=L[a]){
                    if ( L[a] < L[b] + L[c] &&
                    L[a] > L[b] - L[c]&&
                    L[b] < L[a] + L[c]&&
                    L[b] > L[a] - L[c]&&
                    L[c] < L[a] + L[b] &&
                    L[c] > L[a] - L[b]){
                    sum ++;
                //cout<<" "<<L[a]<<" "<<L[b]<<" "<<L[c]<<endl;
                    }
                }
            }
        }
    }
    cout<<sum;

}
int main(){
int times = 1;
//cin>>times;
while(times--)
Oli();
}


Measured memory_bytes: 3584
import sys
input = sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
b={}
cnt=0
for i in a:
    if i<3200:
        b[i//400]=1
    else:
        cnt+=1
if sum(b.values())==0:
    print(1,cnt)
    exit()
print(sum(b.values()),sum(b.values())+cnt)


Measured memory_bytes: 38384
import sys


INF = sys.maxsize
V, E = map(int, input().split())

costs = [[INF] * V for _ in range(V)]

for _ in range(E):
  s, t, d = map(int, input().split())
  costs[s][t] = d
  
for i in range(V):
  costs[i][i] = 0
  
for k in range(V):
  for i in range(V):
    for j in range(V):
      if costs[i][k] == INF or costs[k][j] == INF:
        continue
      costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j])

if any(costs[i][i] < 0 for i in range(V)):
  print('NEGATIVE CYCLE')
else:
  for row in costs:
    print(' '.join('INF' if x == INF else str(x)  for x in row))  
    


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n;
  while (cin >> n, n) {
    vector<int> M(n), mask(n);
    vector<ll> L(n);
    for (int i = 0; i < n; i++) {
      cin >> M[i] >> L[i];
      for (int j = 0; j < M[i]; j++) {
        int s, e;
        cin >> s >> e;
        for (int k = s; k < e; k++) {
          mask[i] |= 1 << (k - 6);
        }
      }
    }

    vector<ll> dp(1 << 16, 0);
    for (int i = 0; i < n; i++) {
      for (int j = (1 << 16) - 1; j >= 0; j--) {
        if ((j & mask[i]) != 0) continue;
        dp[j | mask[i]] = max(dp[j | mask[i]], dp[j] + L[i]);
      }
    }

    ll ans = 0;
    for (int i = 0; i < 1 << 16; i++) {
      ans = max(ans, dp[i]);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3692
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n;
  double x[8]={},y[8]={},cnt=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> x[i] >> y[i];
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(i!=j) {
        cnt+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
      }
    }
  }
  cout << fixed << setprecision(10) << cnt/n << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for(llong i = 0; i < times; i++)
#define rloop(i, times) for(llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl <<msec << " msec" << endl;
}

#endif


class ABC122B
{
public:
	ABC122B()
	{
		cin >> input_;
	}
	void Run(void)
	{
		llong max = 0;
		llong count = 0;
		for (const auto & e: input_)
		{
			if (CheckACGT(e))
			{
				count++;
			}
			else
			{
				count = 0;
			}
			if (max < count)
				max = count;
		}
		cout << max;
	}
private:
	string input_;
	bool CheckACGT(char b)
	{
		if (b == 'A' || b == 'T' || b == 'G' || b == 'C')
			return true;

		return false;
	}

};


int main()
{
	ABC122B abc122b;
	abc122b.Run();

	return 0;
}

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

counter = 0
tsuzu = 0
for i,a in enumerate(a_list):
  if i <= n-2:
    if a == a_list[i+1]:
      if tsuzu == 0:
        tsuzu = 2
      else:
        tsuzu += 1
    else:
      counter += int(tsuzu/2)
      tsuzu = 0
  else:
    counter += int(tsuzu/2)
    tsuzu = 0

print(counter)


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

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

    if(H==0 && W==0){break;}

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(i==0 || i==H-1){cout<<"#";}
        else if(j==0 || j==W-1){cout<<"#";}
        else{cout<<".";}
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
    int a = 0, b = 0, c = 0, d = 0, e = 0,f=0, min = 0, ma = 0, ans = 0, ansb = 0, counter = 0,countb, crowdy[101] = {},  bu = 0;
	int reset = 0,w=0;
	char hairetu[200] = {};
	int number[10000000] = {}, price[10000] = {}, sort[100000] = {}, kisu[10000] = { 100000 }, gusu[10000] = { 100000 };
	using namespace std;
	int x = 0, y = 0, z = 0, play[200] = {}, acount = 0, bcount = 0;
	std::string toki, tokit, fun,funt;

	
int main()
{
	bool okada=true;
	cin >> a;

	if (a == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	if (a==23) {
		cout << "Christmas Eve Eve" << endl;


	}
	if (a == 24) {

		cout << "Christmas Eve" << endl;
	}
	if (a == 25) {
		cout << "Christmas" << endl;
	}
		

	
}

		
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int a, b;
    cin >> a >> b;
    for(int i = 1; i <= 3; i++) {
        if(i != a && i != b) {
            cout << i << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e5+10;
namespace MAIN{
    int n,l;
    int a[N];
    int tot;
    int step[N],stepx;
    inline void MAIN(){
        n=read(),l=read();
        for(res i=1;i<=n;i++)a[i]=read();
        res j=1;
        for(res i=1;i<n;i++)if(a[i]+a[i+1]>a[j]+a[j+1])j=i;
        if(a[j]+a[j+1]<l)puts("Impossible");
        else {
            puts("Possible");
            for(res i=n-1;i>j;i--)printf("%d\n",i);
            for(res i=1;i<=j;i++)printf("%d\n",i);
        }
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define po pop_back
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd


int main()
{
    fast;
   ll a,b;cin>>a>>b;
   cout<<(a*b)/(gcd(a,b))<<endl;
}


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

ll n,a[100000],ans=0;
map<int,bool> mp;
int main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(mp[a[i]]==0){
            ans++;
            mp[a[i]]=1;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  int k,f=0;
  cin >> k;
  long long sum=0;
  for(int i=1;i<1000001;i++){
    sum=((sum*10)+7)%k;
    if(sum==0){
    cout << i <<endl ;
    f=1;
      break;
    }
  }
  if(!f)
    cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n; vector<int> s(n);
   rep(i, 0, n) cin >> s[i];
   int q;
   cin >> q;
   vector<int> t(q);
   rep(i, 0, q) cin >> t[i];

   auto search = [&](int x) {
      int l = 0, r = n;
      while (r - l > 1) {
         int mid = (l + r) / 2;
         if (s[mid] <= x)
            l = mid;
         else
            r = mid;
      }
      if (l == n) return false;

      return s[l] == x;
   };
   int ans = 0;
   rep(i, 0, q) {
      if (search(t[i])) ans++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3384
import sys
X = int(input())
k = 0

for l in range(1,2*(10**4)):
    a =l
    mod = (a%10-X%10)%10
    for b in range(mod,a+1,10):
        if a**5 - b**5 == X:
            print(a,b)
            sys.exit()
    mod = (X%10-a%10)%10
    for b in range(mod,a+1,10):
        if a**5 + b**5 == X:
            print(a,-b)
            sys.exit()


Measured memory_bytes: 62620
import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int b[] = new int[n];
    int c[] = new int[n];
    for(int i = 0; i < n; ++i)
    {
      a[i] = sc.nextInt();
    }
    for(int i = 0; i < n; ++i)
    {
      b[i] = sc.nextInt();
    }
    for(int i = 0; i < n-1; ++i)
    {
      c[i] = sc.nextInt();
    }
    int ans = 0;
    for(int i = 0; i < n; ++i)
    {
      ans += b[a[i] - 1];
      if(i > 0 && a[i] == a[i-1] + 1)
        ans += c[a[i-1]-1];
    }

    System.out.println(ans);
  }

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        long long n;
        cin>>n;
        ll a[n],b[n];
        for(ll i=0;i<n;i++)
            cin>>a[i]>>b[i];
        sort(a,a+n);
        sort(b,b+n);
        ll ans;
        if(n%2==1){
            ans=abs(b[n/2]-a[n/2]+1);
        }
        else{
            ans=abs(b[n/2]-a[n/2]+b[(n-1)/2]-a[(n-1)/2]+1ll);
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
int a[100];

int main(){
  int n, k;
  cin >> n >> k;
  int h[n];
  int peak[n];
  
  for(int i = 0; i < n; i++) {
    cin >> h[i];
    peak[i] = h[i];
  }
  for(int i = 0; i < k; i++){
    int a, b;
    cin >> a >> b;
    peak[a-1] = min(peak[a-1], h[a-1]-h[b-1]);
    peak[b-1] = min(peak[b-1], h[b-1]-h[a-1]);
  }
  int sum = 0;
  for(int i = 0; i < n; i++) {
    if(peak[i] >0 ) sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 4344
#include <bits/stdc++.h> 
#include<cmath>
#include<string>
#define pb push_back
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern




signed main() {    
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	
	int ans = n;
	for(int i =0 ;i  <= n - m ;i++){
		int temp = 0;
		for(int j = 0; j < m; j++){
			if(s[i+j] != t[j])
				temp += 1;
		}
		ans = min(ans , temp);
	}
	cout<<ans;
	 
	return 0;
}


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

int main(){
  int a, b, k;
  cin >> a >> b >> k;

  if(a+k-1<b-k+1){
    for(int i=a; i<a+k; ++i){
      cout << i << endl;
    }
    for(int i=b-k+1; i<=b; ++i){
      cout << i << endl;
    }
  }else{
    for(int i=a; i<=b; ++i){
      cout << i << endl;
    }
  } 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, a;
  in2(n, m);
  a = 0;
  ll b;
  rep(i, m){
    in(b);
    a += b;
  }
  out(max(n - a, -1ll));
  memi;
}

Measured memory_bytes: 3648
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_064_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(3).

    01 INP    PIC X(800).
    01 maxlen PIC 9(3).
    01 cur    PIC 9(3)  VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 len    PIC 9(3).

    01 mn     PIC 9(4) VALUE 1001.
    01 mx     PIC 9(4) VALUE 0.

    01 ans    PIC X(4).

    01 a      PIC 9(4).

    01 ZS     PIC Z(4)9.
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.
    ACCEPT INP.

    MOVE N TO maxlen.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO a

        COMPUTE mn = FUNCTION min(mn, a)
        COMPUTE mx = FUNCTION max(mx, a)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    SUBTRACT mn FROM mx.

    MOVE mx TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 636