akhauriyash/Code-Regression huggingface dataset:
h,w=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]

pos = 160*80
dp=[[0]*w for i in range(h)]
sub=abs(a[0][0]-b[0][0])
dp[0][0]=1<<(pos-sub)
dp[0][0]=1<<(pos+sub)

for c in range(h):
    for l in range(w):
        sub=abs(a[c][l]-b[c][l])
        if l!=0:
            dp[c][l]|=dp[c][l-1]<<sub
            dp[c][l]|=dp[c][l-1]>>sub
        if c!=0:
            dp[c][l]|=dp[c-1][l]<<sub
            dp[c][l]|=dp[c-1][l]>>sub
bit=dp[-1][-1]
for i in range(pos):
    if (bit&1<<(pos+i))or(bit&1<<(pos-i)):
        print(i)
        break

Measured memory_bytes: 20212
from collections import deque


s = deque(list(input()))
n = int(input())
flag = True
for _ in range(n):
    _input = input().split()
    if len(_input) == 1:
        if flag == True:
            flag = False
        else:
            flag = True
    else:
        if (_input[1] == '1' and flag == True) or (_input[1] == '2' and flag == False):
            s.appendleft(_input[2])
        else:
            s.append(_input[2])

if flag == True:
    print("".join(s))
else:
    print("".join([x for x in reversed(s)]))



Measured memory_bytes: 8932
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

long long int res;

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

    long long int H, W;
    cin >> H >> W;
    if (H == 1 || W == 1)
    {
        res = 1;
    }
    else if (H % 2 == 0 || W % 2 == 0)
    {
        res = H * W / 2;
    }
    else
    {
        res = H * W / 2 + 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp;
use std::collections::*;
use std::io::*;
use std::mem::swap;
#[allow(dead_code)]
struct Io<'a> {
    r: BufReader<StdinLock<'a>>,
    w: BufWriter<StdoutLock<'a>>,
    buf: VecDeque<String>,
    buf_str: String,
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn r<T: std::str::FromStr>(&mut self) -> T {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!())
    }
    fn r_s(&mut self) -> String {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf.pop_front().unwrap()
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        write!(self.w, "{}", v).unwrap();
    }
    fn wl<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.w, "{}", v).unwrap();
    }
    fn iter<'b, T: std::str::FromStr>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter {
            io: self,
            p: std::marker::PhantomData,
        }
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T: std::str::FromStr> {
    io: &'b mut Io<'a>,
    p: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a, 'b, T: std::str::FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<T> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let r = BufReader::new(stdin.lock());
    let w = BufWriter::new(stdout.lock());
    let mut io = Io {
        r,
        w,
        buf: VecDeque::new(),
        buf_str: String::new(),
    };
    problem(&mut io);
}

fn problem(io: &mut Io) {
    let a: usize = io.r();
    let b: usize = io.r();
    let c: usize = io.r();
    let d: usize = io.r();

    let attack_tk = (c + b - 1) / b;
    let attack_ao = (a + d - 1) / d;

    if attack_tk <= attack_ao {
        io.wl("Yes")
    } else {
        io.wl("No");
    }
}


Measured memory_bytes: 2144
#include <stdio.h>

int H, W, dp[2][10946][2][2], bits[10946], conv[1 << 19], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < H * W - 1; i++)
	{
		int s = i % 2;
		int t = (i + 1) % 2;

		for (int j = 0; j < maxbits; j++)
		{
			dp[t][j][0][0] = 0;
			dp[t][j][0][1] = 0;
			dp[t][j][1][0] = 0;
			dp[t][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int nxt = (bits[j] << 1) & (maxbit - 1);

			int sum0 = (dp[s][j][0][0] + dp[s][j][1][0]) % 100000;
			int sum1 = (dp[s][j][0][1] + dp[s][j][1][1]) % 100000;

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[t][conv[nxt]][0][0] += sum0;
				dp[t][conv[nxt]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[t][conv[nxt + 1]][1][0] += dp[s][j][0][0];
					dp[t][conv[nxt + 1]][1][1] += dp[s][j][0][1];

					dp[t][conv[nxt + 1]][1][0] %= 100000;
					dp[t][conv[nxt + 1]][1][1] %= 100000;

					dp[t][conv[nxt]][1][0] += dp[s][j][1][0];
					dp[t][conv[nxt]][1][1] += dp[s][j][1][1];
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
					dp[t][conv[nxt]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[t][conv[nxt]][1][1] += sum0;
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
				}

				dp[t][conv[nxt]][1][1] += sum1;
			}

			dp[t][conv[nxt]][1][0] %= 100000;
			dp[t][conv[nxt]][1][1] %= 100000;
		}
	}

	int ret = 0;

	int last = (H * W + 1) % 2;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[last][i][0][1];
		ret += dp[last][i][1][1];

		ret %= 100000;
	}

	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 3420
#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

// http://noshi91.hatenablog.com/entry/2019/03/31/174006

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)

using mint = modint<1000000000 + 7>;
mint solve(int r, int c) {
  auto n = r + c + 2;
  vector<mint> fac(n), inv(n);
  fac[0] = 1;
  for (int i = 1; i < n; i++) {
    fac[i] = fac[i - 1] * i;
  }
  inv[n - 1] = mint(1) / fac[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    inv[i] = inv[i + 1] * (i + 1);
  }
  auto binom = [&](int a, int b) -> mint {
    if (a < 0 or b < 0) return 0;
    if (a < b) return 0;
    return fac[a] * inv[b] * inv[a - b];
  };
  auto countPath = [&](int a, int b) { return binom(a + b, b); };
  auto res = mint(0);
  for (int i = 0; i <= r; i++) {
    res += countPath(i + 1, c);
  }
  return res;
}

int main() {

  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  auto ans = solve(r2, c2);
  ans -= solve(r1 - 1, c2);
  ans -= solve(r2, c1 - 1);
  ans += solve(r1 - 1, c1 - 1);
  cout << ans.a << endl;

  return 0;
}


Measured memory_bytes: 31488
import itertools

N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [list(map(int,input().split())) for i in range(M)]
# print(AB)
uni = list(itertools.chain.from_iterable(AB))
uni = list(set(uni))
# print(uni)
ans = 0
# ans += N-len(uni)
# print(ans)
AB_del = []
for i in range(M):
    hikaku = AB[i]
    if H[hikaku[0]-1] > H[hikaku[1]-1]:
        AB_del.append(hikaku[1]-1)
    elif H[hikaku[0]-1] == H[hikaku[1]-1]:
        AB_del.append(hikaku[1]-1)
        AB_del.append(hikaku[0]-1)
    else:
        AB_del.append(hikaku[0]-1)


# print(AB_del)
ans = N-len(list(set(AB_del)))-ans
print(ans)


Measured memory_bytes: 40080
#include <bits/stdc++.h>
#define rip(a,b) for(int (a)=0;(a)<(b);(a)++)
using namespace std;

int main(){
    long long X;
    cin >> X;

    long long hundred=0;
    long long five=0;
    hundred=X/500;
    five=(X-hundred*500)/5;
    cout << hundred*1000+five*5 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel
//anscii A-65 Z-90   a-97 z-112
//vector<int>v;
//vector<char>v;
//char arr[100005];
//int a[26];
//a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t,
signed main()
{
    fasterthanlight;
    string s;
    string t;
    cin >> s >> t;
    int sum = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
            sum++;
    }
    cout << sum;

    //cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  
  ll n,a,b,c,d,e;
  cin >>n>>a>>b>>c>>d>>e;
  if( min(a,min(b,min(c,min(d,e))))==a ){
    if(n%a==0) cout <<n/a+4 << endl;
    else cout <<n/a+1+4 << endl;
  }
  else if( min(a,min(b,min(c,min(d,e))))==b ){
    if(n%b==0) cout <<n/b+4 << endl;
    else cout <<n/b+1+4 << endl;
  }
  else if( min(a,min(b,min(c,min(d,e))))==c ){
    if(n%c==0) cout <<c/a+4 << endl;
    else cout <<n/c+1+4 << endl;
  }
  else if( min(a,min(b,min(c,min(d,e))))==d ){
    if(n%d==0) cout <<n/d+4 << endl;
    else cout <<n/d+1+4 << endl;
  }
  else{
    if(n%e==0) cout <<n/e+4 << endl;
    cout <<n/e+1+4 << endl;
  }
  
}

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

int main () {
  int  a, b, c;
  cin >> a >> b >> c; 
  
  if ((a > b) && (a > c)) cout << a*10 + b + c << endl;
  else if (b > c) cout << a + 10*b + c << endl;
  else cout << a + b + 10*c << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			while (true) {
				String str = br.readLine();
				String s[] = str.split(" ");
				int n = Integer.parseInt(s[0]);
				int m = Integer.parseInt(s[1]);
				if (n == 0 && m == 0)
					break;
				int obj[] = new int[n];
				int sumObj[] = new int[n * n - n];
				int maxM = 0;
				String str2 = br.readLine();
				String s2[] = str2.split(" ");
				for (int i = 0; i < n; i++) {
					obj[i] = Integer.parseInt(s2[i]);
				}
				int count = 0;
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						if (i != j) {
							sumObj[count++] = obj[i] + obj[j];
						}
					}
				}
				Arrays.sort(sumObj);
				if (sumObj[0] > m) {
					System.out.println("NONE");
				} else {
					for (int i = 0; i < sumObj.length; i++) {
						if (sumObj[i] <= m)
							maxM = Math.max(maxM, sumObj[i]);
					}
					System.out.println(maxM);
				}
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 61644
#include<iostream>

using namespace std;

int main(void){
	int n;
	while(cin>>n,n){
		int cnt=0;
		while(n!=1){
			if(n%2==0)n/=2;
			else n=n*3+1;
			cnt++;
		}
		cout<<cnt<<endl;
	}
	
}

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

int main() {
	int a, b, point = 0;
	scanf("%d %d", &a, &b);

	if (a > b) {
		point += a;
		a --;
	}
	else {
		point += b;
		b --;
	}

	point += a > b ? a : b;
	printf("%d\n", point);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

bool isnum(char c){
    return (c>='0'&&c<='9');
}

void pr(string ans){
    cout1(ans)
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    string s;
    cin>>a>>b>>s;
    
    rep(i,a)if(!isnum(s[i])) pr("No");
    if(isnum(s[a])) pr("No");
    rep(i,b)if(!isnum(s[i+a+1])) pr("No");
    pr("Yes");
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	xs := make([][]int, n)
	for i := range xs {
		xs[i] = make([]int, d)
		for j := range xs[i] {
			fmt.Scan(&xs[i][j])
		}
	}

	var cnt int
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			sum := 0
			for k := 0; k < d; k++ {
				diff := xs[i][k] - xs[j][k]
				sum += diff * diff
			}
			if isInteger(math.Sqrt(float64(sum))) {
				cnt++
			}
		}
	}

	fmt.Println(cnt)
}

func isInteger(f float64) bool {
	return math.Floor(f) == f
}


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

typedef long long ll;
typedef pair<int,int> pii;
#define FOR(i,ii,iii)for(int i=ii;i<iii;i++)
#define RFOR(i,ii,iii)for(int i=iii-1;i>=ii;i--)
#define OUT(a)cout<<a<<endl
#define ALL(s) s.begin(),s.end()
#define PB push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define ANS(a) OUT(res.size());for(auto i:a)cout<<i<<" ";ENDL
#define PRINT(a,init,end) FOR(i,init,end) cout<<a[i]<<" ";ENDL
#define PRINTV(a) for(auto i:a)cout<<i<<" ";ENDL
#define F first
#define S second

const int N=3000+15;
int n,k;
ll a[N],dp[N][N][3];
ll solve(int i,int j,int c) {
  ll res;
  if(i==j)res = c*a[i];
  else {
    if(dp[i][j][c+1]!=-1)return dp[i][j][c+1];
    if(c>0) {
      res=max(c*a[i]+solve(i+1,j,-c),
                 c*a[j]+solve(i,j-1,-c));
    } else {
      res=min(c*a[i]+solve(i+1,j,-c),
                 c*a[j]+solve(i,j-1,-c));
    }
  }
  dp[i][j][c+1]=res;
  //cout<<i<<" "<<j<<" "<<c<<" : "<<res<<endl;
  return res;
}

int main() {
  mset(dp,-1);
  ios::sync_with_stdio(false);
  cin>>n;
  ll s=0;
  FOR(i,0,n)cin>>a[i],s+=a[i];
  cout<<solve(0,n-1,1)<<endl;
  //cout<<solve(0,n-1,1)-s<<endl;
}

Measured memory_bytes: 213632
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
int main (){
	int n;
	int d;
	cin >> n >> d;
	vector<vector<int> > x(n,vector<int>(d));
	for (int i=0; i< n; i++){
	  for (int j=0; j<d; j++){
		cin >> x.at(i).at(j);
	   }
	}
    /*
    for (int i=0; i<n; i++){
        for (int j=0; j<d; j++){
            cout << x.at(i).at(j) << endl;
        }
    }
    */
    int num;
    int dis;
    int dis2;
    num = 0;
    for (int i=0; i<n-1; i++){
        for (int k=i+1; k<n; k++){ 
            for (int j =0; j<d; j++){
                dis2 = dis2 +  pow( abs(x.at(i).at(j)-x.at(k).at(j)), 2);
            }

            dis = sqrt(dis2);
            if ( dis2 == pow(dis,2)){
                num++;
            }

            // initialization
            dis = 0;
            dis2 = 0;
        }
    }
    
    cout << num << endl;

}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long LL;

const int MX=200111;
int n,l,t;
int pos[MX];
int rightc;//times that go clockwise cross L-0.5

int main(){
	scanf("%d%d%d",&n,&l,&t);
	for(int i=1;i<=n;i++){
		static int x,w;
		scanf("%d%d",&x,&w);
		if(w==1){
			pos[i]=(x+t)%l;
			rightc=(rightc+(t/l)+(t%l+x>=l))%n;
		}else{
			pos[i]=((x-t)%l+l)%l;
			rightc=((rightc-((t/l)+(x-t%l<0)))%n+n)%n;
		}
	}
	sort(pos+1,pos+n+1);
	for(int i=1;i<=n;i++)printf("%d\n",pos[(i+rightc-1+n)%n+1]);
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
 

int dp[100][2];

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


 int n;

cin>>n;

map<string ,int>m;
vector<int>v(n+1);

for(int i=1;i<=n;i++)
{
  string s;
  cin>>s;
  int t;
  cin>>t;
  m[s]=i;
  v[i]=t;
  v[i]+=v[i-1];
}
string  x;
cin>>x;
int k=m[x];
cout<<v[n]-v[k];
 }

    


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

ll combimax = 2999;
vvll combi(combimax+1,vll(combimax+1,0));
ll p;

void combination(){
    for(int i=1;i<=combimax;i++){
        combi[i][0]=1;
        for(int j=1;j<=i-1;j++){
            combi[i][j]=combi[i-1][j]+combi[i-1][j-1];
            combi[i][j]%=p;
        }
        combi[i][i]=1;
    }
}
ll pow(ll x, ll ntimes) {
    ll ret = 1;
    while (ntimes > 0) {
        if ((ntimes & 1) == 1) {
            ret = ret * x;
            if(ret>=p){
                ret%=p;
            }
        }
        x = x * x;
        if(x>=p){
            x%=p;
        }
        ntimes >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> p;
    combination();
    vll b(p,0);
    REP(i,p){
        ll a;
        cin >> a;
        if(a==1){
            b[0]+=1;
            b[0]%=p;
            ll tmp2 = 1;
            for(ll k=p-1;k>=0;--k){
                ll tmp = combi[p-1][k];
                if(k==p-1){
                    tmp2 = 1;
                }else{
                    tmp2 *= i;
                    if(tmp2>=p){
                        tmp2%=p;
                    }
                }
                tmp *= tmp2;
                tmp%=p;
                if((p-1-k)%2==0){
                    b[k]-=tmp;
                    b[k] = ((b[k])%p+p)%p;
                }else{
                    b[k]+=tmp;
                    b[k] = (((b[k])%p)+p)%p;
                }
            }
        }
    }
    REP(i,p-1){
        cout << b[i] << " ";
    }
    cout << b[p-1] << endl;

    return 0;
}

Measured memory_bytes: 72832
#include <bits/stdc++.h>
#define ref(i,n) for(int i=0;i<n;i++)
using namespace std;
#define INF 10000000

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

    int n=s.size(),x=(n-1)/2,y=(n+1)/2;

    ref(i,x) if(s[i]!=s[x-1-i]||s[i]!=s[y+i]) {
        cout<<"No";
        return 0;
    }

    cout<<"Yes";

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A;
    A.push_back(0);
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    A.push_back(0);
    int fare = 0;
    rep(i, N+1) fare += abs(A[i+1] - A[i]);
    rep(i, N) {
        int t = fare;
        t -= abs(A[i] - A[i+1]);
        t -= abs(A[i+1] - A[i+2]);
        t += abs(A[i] - A[i+2]);
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 1784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H;
		int W;
		int count;
		int[] detaH = new int[300];
		int[] detaW = new int[300];
		for (count = 0; true; count++) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			detaH[count] = H;
			detaW[count] = W;
		}
		for (int i = 0; i < count; i++) {
			for (int i2 = 0; i2 < detaH[i]; i2++) {
				if ((i2 + 2) % 2 == 0) {
					for (int i3 = 0; i3 < detaW[i]; i3++) {
						if ((i3 + 2) % 2 == 0) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.print("\n");
				} else {
					for (int i3 = 0; i3 < detaW[i]; i3++) {
						if ((i3 + 2) % 2 != 0) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.print("\n");
				}
			}
			System.out.print("\n");
		}
		sc.close();
	}
}


Measured memory_bytes: 38144
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
i=0
j=0
#N=int(input())
#Nori=N
D, N=input().split()
#S=input()
#T=input()
#S_list=list(S)
#h_list=  list(map(int, input().split(" ")))
#M=int(input())
#drink_list = [list(map(int, input().split(" ")))for i in range(M)]
#print(T_list[1])
D=int(D)
N=int(N)
#不本意だが内包表記で二次元の空のリストを作成する
     
#dp=[['' for i in range(2)] for j in range(N)]
#absTH=[''for i in range(N)]
#K=int(K)
#S_list=[]
#sentence_list=[]
#total=0
#mojiretu=""
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
#for i in range(K):
# ID_list.append(i+1)
#print(ID_list)
#for i in range(H)
#この下の行が二次元リストの読み込
#intを消して記号を読み込めるようにしたしかしこれでは文字列から読み込んでいるのと同じ
#weight_value_list =  [list(input())for i in range(N)]#一文字づつばらして入れてしまう
#s = [input() for i in range(N)]
#複数行に複数の入力値を取得し、出力する
#sentence_list =  (list(input())for i in range(N))
#for i in range(H):
#  ppixel_list=list(input())
    
#print(pixel_list)
#high_pixel_list =[['' for i in range(W)]for j in range(2*H)]
#print(high_pixel_list)
#print(pixel_list[0][1])#行　列の順番にかっこが並んでいる
#print(a_list)
first_term=0
second_term=0
#整数二次元配列を読み込む時のやり方
#a_b_c_list =  [list(map(int, input().split(" ")))for i in range(N)]
     
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
  
     
#x, y = [0]*N, [0]*N#N個の空のリストを作成
#l = list(range(N))#範囲がNのリストを作成する
     
#for i in range(N):
#  x[i], y[i] = map(int, input().split())
#分けて入力する形式を設定することで可読性が高く仕上がっている
#素晴らしいことだ
     
     
distance = 0
#comb = list(itertools.permutations(l))
#prmutation:英語の意味としては順列である
'''p[, r]で
長さrのタプル列、重複なしのあらゆる並びを表す
今回はリストlの重複なしの並び替え順序を新たなリストに収納している
並び方を計算しリストに収納しているイメージ
l[0,1,2]
l[0,2,1]これにもリスト番号が0,1,2と割り振られている
これが全通り入っている
これ作った人はすごい
自分も早く理解したい
'''
#for i in range(0, len(comb)):#i番目のパターンの時を考える。
#  for j in range(0, N-1):#lのリスト番号を読み込み
#    distance += math.sqrt((x[comb[i][j]]-x[comb[i][j+1]])**2 + (y[comb[i][j]]-y[comb[i][j+1]])**2)
'''
各経路の距離を足していき全距離分を経路数
で割れば平均距離が出るので各経路ごとの距離は
不必要と判断されている。
'''
#print(distance/len(comb))
# dp[i+1][j]=max(dp[i][j]+a_b_c_list[i],dp[i][j],dp[i][j])
#リストを一周するようにすればいいのか
number_list=[int(i+1) for i in range(99)]
#number=[]
number_list.append(int(101))
#print(number_list)
number=list(map(lambda x: x* math.pow(int(100), D), number_list))
print(int(number[N-1]))


Measured memory_bytes: 3064
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	int n=sc.nextInt();
	int f=sc.nextInt();
	int min=f;
	int max=f;
	long sum=f;
	for(int i=0;i<n-1;i++){
	    int x=sc.nextInt();
	    if(min>x)min=x;
	    if(max<x)max=x;
	    sum+=x;
	}
        System.out.println(min+" "+max+" "+sum);
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

Measured memory_bytes: 42120
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  FOR(i,0,100) {
    FOR(j,0,100) {
      if(i * 4 + j * 7 == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int c = 2;
	string s;
	cin >> s;
	int n = s.size();
	REP(i, n) {
		if (c == 2) {
			if (s[i] == 'C')c--;
		}
		else if (c == 1) {
			if (s[i] == 'F')c--;
		}
	}
	if (c) {
		put("No");
	}
	else {
		put("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*
import kotlin.math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val errPrint: (String)->Unit = { msg -> System.err.println(msg) }


fun main(args: Array<String>) {
    val (N, M) = readListInt()
    val H = readListInt()

    var st = mutableSetOf<Pair<Int, Int>>()
    var good = BooleanArray(N){true}
    for(i in 0 until M) {
        var (A,B) = readListInt()
        A--; B--;
        if (st.contains(Pair(A, B))){
            continue
        }

        if (H[A] > H[B]) {
            good[B] = false
        } else if (H[A] < H[B]) {
            good[A] = false
        } else {
            assert(H[A] == H[B])
            good[A] = false
            good[B] = false
        }

        st.add(Pair(A, B))
    }
    errPrint(good.joinToString(separator = ", "))

    val ans = good.count({it})
    println(ans)
}


Measured memory_bytes: 80780
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;
        int ret = 0;
        for(int i=0; i<n/4; ++i){
            int tmp;
            cin >> tmp;
            ret += tmp;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
    int i,j,k,l;
    while(scanf("%d%d",&i,&j)!=EOF)
    {
         k=i+j;
         for(l=0;k;l++)
             k/=10;

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

Measured memory_bytes: 600
#include "stdio.h"

int main() {

	int i,j,t,at=0,bt=0;
	char a[101], b[101];

	scanf("%s%s", &a, &b);
	while(a[at] != '\0')at++;
	while(b[bt] != '\0')bt++;
	

	for (j = 0; j < at; j++) {
		t = 1;
		for (i = 0; i < bt; i++) {
			if (a[(i + j) % at] != b[i]) {
				t = 0;
			}
		}
		if (t == 1)
			break;
	}

	if (t == 1) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2132
/**
 * Training to the municipal stage of ROI
**/ 
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=0;i<n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define kek cout<<"\n"
#define all(v)        ((v).begin()), ((v).end())
#define pob pop_back()
int main()
{
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
int n;
cin>>n;
string s;
cin>>s;

int ans=1;
for(int i=1;i<n;i++)
{
          if(s[i]!=s[i-1]) ans++;
} cout<<ans;
return 0;

 
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll l = 0;
  cin >> l;
  cout << fixed << setprecision(10) << pow(l,3) / 27 << endl;
  return 0;
}

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

using namespace std;

typedef long long i64;

//bool check(const vector<pair<int, int>>& ans, const vector<pair<int, int>>& a) {
//
//}

int main() {
    int n;
    while (cin >> n) {
        vector<pair<int, int>> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i].first;
            a[i].second = i;
        }

        pair<int, int> maxa(-1e9, -1);
        pair<int, int> mina(1e9, -1);
        for (int i = 0; i < n; i++) {
            maxa = max(maxa, a[i]);
            mina = min(mina, a[i]);
        }

        auto target = (abs(maxa.first) > abs(mina.first) ? maxa : mina);

        vector<pair<int, int> > ans;
        for (int i = 0; i < n; i++) {
            if (i != target.second) {
                ans.emplace_back(target.second + 1, i + 1);
                a[i].first += target.first;
            }
        }

        if (target.first < 0) {
            for (int i = n - 1; i > 0; i--) {
                if (a[i] < a[i - 1]) {
                    ans.emplace_back(i + 1, i);
                    a[i - 1].first += a[i].first;
                }
            }

        } else {
            for (int i = 0; i < n - 1; i++) {
                if (a[i] > a[i + 1]) {
                    ans.emplace_back(i + 1, i + 2);
                    a[i + 1].first += a[i].first;
                }
            }
        }

        cout << ans.size() << endl;
        for (auto& p : ans) {
            cout << p.first << " " << p.second << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
import math
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, H = list(map(int, input().split()))
A = []
B = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

B.sort()
amax = max(A)

hp = H
cnt = 0
for i in reversed(range(N)):
    if B[i] < amax or hp <= 0:
        break
    hp -= B[i]
    cnt += 1
cnt += max(0, math.ceil(hp / amax))

print(cnt)


Measured memory_bytes: 11340
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;


int X,A;
signed main(){
    cin>>X>>A;
    if(X<A){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

// /////////////////////////////////////////////

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

// ////////////////////////////////

#define int long long
const int mod = 998244353;
void solve(){

	int k , n;
	cin>>k>>n;
	int a[n];
	for(int i = 0 ; i < n; ++i)
		cin>>a[i];
	int cost[n];
	cost[0] = 0;
	int lf = (k - a[n-1]) + a[0];
	for(int i = 1 ; i < n;  ++i){

		cost[i] = cost[i-1];
		cost[i]+=(a[i] - a[i-1]);
	}
	int ans = 1e13;
	for(int i = 0 ; i < n ; ++i){

		if(i==0){

			ans = min(ans , cost[n-1]);
		}
		else{

			ans = min(ans , cost[n-1] - cost[i] + lf + cost[i-1]);
		}
	}
	// for(int i = 0 ; i < n ; ++i)
	// 	cout<<cost[i]<<" ";
	// cout<<endl;
	cout<<ans<<endl;
}

signed main(){

    //fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}




Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;

    int S = A[0] + A[1];
    int X = 0; FOR(i, 2, N) X ^= A[i];
    int C = (S - X) / 2;

    if(S < X || (S - X) % 2 != 0 || (X & C) != 0){
        Out(-1);
        return 0;
    }
    //debug(S); debug(X); debug(C);

    int ans = -1, t = 0;
    IREP(i, 60){
        if(((C >> i) & 1) == 1) t += bit(i);
        else if(((X >> i) & 1) == 1){
            //if((t >> i) < (A[0] >> i)){
            if(true){
                int t0 = t;
                REP(j, i) if(((C >> j) & 1) || ((X >> j) & 1)) t0 += bit(j);
                if(t0 > 0 && t0 <= A[0]) chmax(ans, t0);
            }

            if((t >> i) < (A[0] >> i)) t += bit(i);
            else if((t >> i) > (A[0] >> i)) break;
        }
    }
    if(t > 0 && t <= A[0]) chmax(ans, t);
    chOut(ans >= 0, A[0] - ans, ans);

    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,b;
    cin>>n>>b;
    if(n>9 || b>9){
        cout<<"-1";
    }
    else {
        cout<<n*b;
    }
    
    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<string> S;
  for(int i=0; i<N; i++){
    string in;
    cin >> in;
    S.push_back(in);
  }
  int M;
  cin >> M;
  vector<string> T;
  for(int i=0; i<M; i++){
    string in;
    cin >> in;
    T.push_back(in);
  }

  int ret = 0;
  for(int i=0; i<N; i++){
    int p = 0;
    string s = S[i];
    for(int j=0; j<N; j++)
      if(S[j] == s) p++;
    for(int j=0; j<M; j++)
      if(T[j] == s) p--;
    if(p > ret)
      ret = p;
  }
  cout << ret << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int A, B;
  cin >> A >> B;

  int ret = 0;
  int tmp = 1;
  while(tmp < B) {
    tmp += A - 1;
    ret++;
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], C = ip[1];
	auto D = readMatrix!int(C, C);
	auto c = readMatrix!int(N, N);
	int res = int.max;
	auto arr = new int[][](3, C);

	 foreach(a; 0..C) foreach(x; 0..N) foreach(y; 0..N) {
		arr[(x+y)%3][a] += D[c[x][y]-1][a];
	}

	foreach(i; 0..C) foreach(j; 0..C) foreach(k; 0..C) {
		if(i==j||j==k||k==i) continue;
		res = min(res, arr[0][i]+arr[1][j]+arr[2][k]);
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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


int main()
{
    int k;
    cin>>k;
    if(k>=400&&k<=599) puts("8");
    else if(k<=799) puts("7");
    else if(k<=999) puts("6");
    else if(k<=1199) puts("5");
    else if(k<=1399) puts("4");
    else if(k<=1599) puts("3");
    else if(k<=1799) puts("2");
    else if(k<=1999) puts("1");
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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())

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

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//main code

int main(int argc, char const* argv[])
{
	int n,k;
	string s;
	cin >> n >> k >> s;
	bool is0 = false;
	int cnt0 = 0;
	int p = 0;
	int l = 0;
	int ans = 0;
	VL pp;
	int pp_ind = 0;
	for (int i = 0; i < n; i++) {
		if (!is0 and s[i] == '0') {
			is0 = true;
			cnt0++;
			if (cnt0 == k+1) {
				ans = max(ans, i - l);
				l = pp[pp_ind];
				pp_ind++;
				cnt0--;
			}
		}
		else if (is0 and s[i] == '1') {
			is0 = false;
			pp.push_back(i);
			if (cnt0 > 0) {
				p = i;
			}
		}
	}
	ans = max(ans, n - l);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> p(n);
  rep(i, n) cin >> p[i];

  sort(p.begin(), p.end());

  cout << accumulate(p.begin(), p.begin()+k, 0ll) << endl;

  return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int v[n];
	int big = 0, done = 0;
	cin >> v[0];
	int gcd = v[0];
	for(int i = 1; i < n; ++i){
		cin >> v[i];
		gcd = __gcd(v[i], gcd);
	}
	sort(v, v+n);
	for(int i = n-1; i >= 0 and v[i] >= k; ++i) {
		if((v[i] - k) % gcd == 0) return cout << "POSSIBLE" << endl, 0;
	}
	cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int  a , b  ;
	cin>>a>>b;
	if((a+b)>=24)
    {
        cout<<a+b-24<<"\n";
    }
    else if((a+b)<24 && (a+b)>=0 )
    {
        cout<<a+b<<"\n";
    }
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**1
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = [I() for _ in range(n)]
    t = a[0]
    for c in a[1:]:
        t = t * c // fractions.gcd(t,c)

    return t



print(main())



Measured memory_bytes: 5532
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
using namespace std;
 
#define len(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define vi vector<int> 
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
 
#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i; 
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.x >> a.y;
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.x << " " << a.y;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();    
    return 0;
}
 
const int INF = 1e18, MAXN = 1e4 + 10, MOD = 1e9 + 7, BASE = 37;

void solve() {
    int n;
    cin >> n;
    
    int _min = INF;
    int d = 1;
    while (d * d <= n) {
    	if (n % d == 0) {
    		_min = min(_min, d + n / d - 2);
    	}
    	d++;
    }

    cout << max(0ll, _min) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
char s;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s=='R') a++;
		else b++;
	}
	if(a>b) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256