akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  tourist
 *    created: 31.07.2019 14:31:59       
**/
#include <bits/stdc++.h>

using namespace std;

vector<string> p[8] = {{}, {}, {},
 
 {"aa.",
  "..a",
  "..a"},

 {"aabc",
  "ddbc",
  "bcaa",
  "bcdd"},

 {"aabba",
  "bcc.a",
  "b..cb",
  "a..cb",
  "abbaa"},

 {"aabc..",
  "ddbc..",
  "..aabc",
  "..ddbc",
  "bc..aa",
  "bc..dd"},

 {"aabbcc.",
  "dd.dd.a",
  "..d..da",
  "..d..db",
  "dd.dd.b",
  "..d..dc",
  "..d..dc"}};


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

  // sample output
  if (n == 6) {
    cout << "aabb.." << '\n';
    cout << "b..zz." << '\n';
    cout << "ba...." << '\n';
    cout << ".a..aa" << '\n';
    cout << "..a..b" << '\n';
    cout << "..a..b" << '\n';
    return 0;
  }

  if (n == 2) {
    cout << -1 << '\n';
    return 0;
  }
  vector<string> s(n, string(n, '.'));
  auto Put = [&](int x, int y, int d) {
    for (int i = 0; i < d; i++) {
      for (int j = 0; j < d; j++) {
        s[x + i][y + j] = p[d][i][j];
      }
    }
  };
  while (n >= 8) {
    Put(n - 4, n - 4, 4);
    n -= 4;
  }
  Put(0, 0, n);
  for (int i = 0; i < (int) s.size(); i++) {
    cout << s[i] << '\n';
  }
  return 0;
}


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

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long double a, b, x; cin >> a >> b >> x;
    x /= a;

    long double area, h1, b1, theta, mid, left = 1e-18, right = 1e18;

    for(int i = 0; i < 30000; ++i){
        mid = (left + right) / 2;
        area = mid * b / 2.0;
        if(mid > a){
            area -= (mid - a) * (b / mid) * (mid - a) / 2.0;
        }
        //cout << mid << " " << area << endl;
        if(area < x){
            left = mid;
        } else {
            right = mid;
        }
    }

    cout << setprecision(10) << fixed <<  atan(b / right) * 180.0/3.141592653589793238463;

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int solve(){
  string s; cin >> s;
  int sn = s.length();
  int ans = 0;
  for(int i=0; i<sn/2; i++){
    if(s[i]!=s[sn-i-1]) ans++;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
//15DTG
//16072020
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef long double ld;
const ld pi=3.1415926535897932384626433;
const int mod = 1e9+7;
int main()
{
   bolt;
   char c;
   cin>>c;
   if (c<='z' and c>='a')
      cout<<'a';
   else
      cout<<'A';
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdlib>
#include <string.h>

struct Rest
{
public:
    int n;
    char S[11];
    int P;
};

int compar(const void *a, const void *b)
{
    Rest *s = (Rest *)a;
    Rest *t = (Rest *)b;
    if(strcmp(s->S, t->S) == 0)
        return t->P - s->P;
    return strcmp(s->S, t->S);
}

int main()
{
    int N;
    scanf("%d", &N);
    Rest R[N];
    for(int i=0; i<N; i++){
        R[i].n = i+1;
        scanf(" %s %d", R[i].S, &(R[i].P));
    }
    qsort(R, N, sizeof(Rest), compar);
    for(int i=0; i<N; i++)
        printf("%d\n", R[i].n);
}

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

int main(){

    int H, W;
    cin >> H >> W;
    string board[50];

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

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

    for (int i =0; i < H; i ++)    {
        for (int j = 0; j < W; j ++)    {
            if (board[i][j] == '#')   
                continue;
            int num = 0;
            for (int d = 0; d < 8; d ++){
                const int ni = i + dy[d];
                const int nj = j + dx[d];            

                if (ni < 0 or ni >= H) continue;
                if (nj < 0 or nj >= W) continue;
                if (board[ni][nj] == '#') num ++;
            }
            board[i][j] = char(num + '0');
        }
    }
  for (int i =0; i < H; i ++)    {
        cout << board[i] << endl;
    }    

}

Measured memory_bytes: 3596
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

bool dfs(int cnt, int sum,string sym);
string ans_s,s,sym;

int main() {
	cin >> s;
	int i = 0,sum=0;

	if (dfs(i, sum, sym)) {
		cout << s[0];
		for (int i = 1; i < 4; i++) {
			cout << ans_s[i] << s[i];
		}
		cout <<"=7\n";
	}
	return 0;
}

bool dfs(int cnt, int sum,string sym) {
	if (cnt==4) {
		ans_s = sym;
		return sum == 7;
	}
	int num = s[cnt] - '0';
	//cout << ans_s << endl;
	if (dfs(cnt + 1, sum + num, sym + "+")) return true;
	if (dfs(cnt + 1, sum - num, sym + "-")) return true;
	return false;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;
    vector<ll> A(N);
    rep(i,N){
        cin>>A[i];
        A[i]--;
    }

    vector<bool> seen(N);
    seen[0] = 1;
    ll now = 0,next;
    ll  po;
    ll st;
    vector<ll> root;
    rep(i,N+1){
        next= A[now];
        root.pb(now);
        if(seen[next]==1){
            po = next;
            st = i+1;
            break;
        }
        seen[next] = 1;
        now = next;
    }
    vector<ll> roop;
    roop.pb(po);
    now = A[po];
    while(now != po){
        roop.pb(now);
        now = A[now];
    }


    /*rep(i,root.size()){
        cout<<root[i]<<endl;
    }*/
    if(K<st){
        cout<<root[K]+1<<endl;
    }else{
        cout<<roop[(K-st)%roop.size()]+1<<endl;
    }




    return 0;
    

}

Measured memory_bytes: 9172
n = int(input())
*A, = map(int, input().split())
num = 1
ans = 0
for i in range(n):
    if A[i] != num:
        ans += 1
    else:
        num += 1
if num == len(A)+1:
    print(0)
elif ans == len(A):
    print(-1)
elif ans:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 85452
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
namespace AtCoder_Beginner_Contest_127
{
    class Program
    {
        static public List<int> SIn() { return ReadLine().Split().Select(int.Parse).ToList(); }
        static void Main(string[] args)
        {
            var Q = SIn()[0];
            long sumb = 0;
            var alst = new List<int>(Q);
            long fx = 0;
            {
                var query = SIn();
                if (1 == query[0])
                {
                    var a = query[1];
                    var b = query[2];
                    sumb += b;
                    alst.Add(a);
                }
                else
                {
                    Console.WriteLine($"{0} {0}");//-infやな…
                }
            }
            for (int i = 1; i < Q; ++i)
            {
                var query = SIn();
                if(1==query[0])
                {
                    var a = query[1];
                    var b = query[2];
                    sumb += b;
                    if (alst.Count % 2 == 0)//偶数
                    {
                        var left = alst[alst.Count / 2 - 1];
                        var right = alst[alst.Count / 2];
                        if (right < a) fx += a - right;
                        else if (a < left) fx += left - a;
                    }
                    else
                    {
                        var mid = alst[alst.Count / 2];
                        fx += Math.Abs(mid - a);
                    }
                    SortedAdd(alst, a);
                }
                else
                {
                    var minx = 0;
                    if (alst.Count % 2 == 0)//偶数
                    {
                        minx = alst[alst.Count / 2 - 1];
                    }
                    else
                    {
                        minx = alst[alst.Count / 2];
                    }
                    Console.WriteLine($"{minx} {sumb+fx}");
                }
            }
        }
        static void SortedAdd(List<int> lst, int key)
        {
            int min = 0;
            int max = lst.Count - 1;
            lst.Insert(binary_search(lst, key, min, max), key);
        }
        static int binary_search(List<int> lst, int key, int min, int max)
        {
            if (max < min)
                return min;

            int mid = min + (max - min) / 2;
            if (key < lst[mid])
            {
                return binary_search(lst, key, min, mid - 1);
            }
            if (lst[mid] < key)
            {
                return binary_search(lst, key, mid + 1, max);
            }
            else
            {
                return mid;
            }
        }
    }
}


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

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
								Integer[] comb = {i, j, k};
								Arrays.sort(comb);
								boolean is_contain = false;
								for(int l = 0; l< result.size(); l++){
									if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
										is_contain = true;
									}
								}
									if(!is_contain){
										result.add(comb);
									}
						}
					}
				}
			}
			result_size = result_size + result.size() + "\n" ;
			System.out.print(result_size);
		}
	}
}

Measured memory_bytes: 26728
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,ans=0;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    

    while(k--)
    {
        int small = p[0];
        for (int j = 0; j < n; j++)
        {
            if(p[j] < small)
                small = p[j];
        }
        ans += small;
        p.erase(find(p.begin(),p.end(),small));
        n = p.size();
    }
    cout << ans << endl;


    
    
    
}

Measured memory_bytes: 3616
s = int(input())
tmp = s
a = [s]
while(True):
  if(tmp % 2 == 0):
    tmp /= 2
  else:
    tmp = 3*tmp + 1
  if(tmp in a):
    print(len(a)+1)
    break
  else:
    a.append(tmp)
      

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

bool can_make_sum(const vector<int> &a, int init, int sum)
{
	set<int> s;
	s.insert(init);
	for (int x : a) {
		set<int> t;
		for (auto y : s) {
			t.insert(y + x);
			t.insert(y - x);
		}
		s.swap(t);
	}
	return s.count(sum) != 0;
}

int main()
{
	string s;
	int x, y;
	cin >> s >> x >> y;
	s += 'T';

	bool first = true;
	bool dirx = true;
	int d = 0;
	int init_x = 0;
	vector<int> xs;
	vector<int> ys;
	for (auto c : s) {
		if (c == 'F') {
			++d;
		}
		else {
			if (first) {
				init_x = d;
				first = false;
			}
			else if (dirx) {
				xs.push_back(d);
			}
			else {
				ys.push_back(d);
			}
			dirx = !dirx;
			d = 0;
		}
	}

	if (can_make_sum(xs, init_x, x) && can_make_sum(ys, 0, y)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 640
import numpy as np
import sys
sys.setrecursionlimit(100000)

directions = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])


def acinput():
    return list(map(int, input().split(" ")))


sys.setrecursionlimit(100000)


directions = [[1, 0], [0, 1], [-1, 0], [0, -1]]
directions = list(map(np.array, directions))


def acinput():
    return list(map(int, input().split(" ")))


N, K = acinput()
h = np.array(acinput())

print(np.count_nonzero(h >= K))




Measured memory_bytes: 20924
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    int x1, x2, x3, x4;
    int y1, y2, y3, y4;
    int a, b;

     
    cin >> x1 >> y1 >> x2 >> y2;



    if ((x2-x1>0)&&((y2-y1>0)||(y2-y1==0))){
        a = abs(x2 - x1);
        b = abs(y2 - y1);
        
        x3 = x2 - b;
        y3 = y2 + a;

        x4 = x3 - a;
        y4 = y3 - b;
    }
    else if (((x2-x1<0)||(x2-x1==0))&&(y2-y1>0)){
        a = abs(y2 - y1);
        b = abs(x2 - x1);
        
        x3 = x2 - a;
        y3 = y2 - b;

        x4 = x3 + b;
        y4 = y3 - a;
    }
    else if ((x2-x1<0)&&((y2-y1<0)||(y2-y1==0))){
        a = abs(x2 - x1);
        b = abs(y2 - y1);
        
        x3 = x2 + b;
        y3 = y2 - a;

        x4 = x3 + a;
        y4 = y3 + b;
    }
    else {
        a = abs(y2 - y1);
        b = abs(x2 - x1);
        
        x3 = x2 + a;
        y3 = y2 + b;

        x4 = x3 - b;
        y4 = y3 + a;
    }

    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4  << endl;
 }


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

Measured memory_bytes: 256
/* ex3-3
   Sagzar1993  */


#include <stdio.h>

int main(void) {
    //表す整数と基数を定義
    int num, numBase;

    //入力を受け取る
    scanf("%d %d", &num, &numBase);

    //桁数
    int digit = 0;

    //整数を基数で割っていき、桁数を１足していく
    while(num >= 1){
        num = num / numBase;
        digit++;
    }

    //結果を出力
    printf("%d\n", digit);
    
    return 0;
}

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

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

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

  double d;
  rep(i, n){
    double a;cin>>a;
    d += 1/a;
  }
  double ans;
  ans = 1/d;
  printf("%.12f", ans);
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<long> H(N);

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

    long cnt = 0;
    long ans = -1;

    for (long i = 0; i < N - 1; i++) {
        if (H[i] - H[i + 1] >= 0)
            cnt++;
        else
            cnt = 0;
        // else {
        ans = max(ans, cnt);
        //     cnt = 0;
        //     // cout << i << " ";
        // }
    }
    ans = max(ans, cnt);

    cout << ans << endl;
}

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

class Program {
  public static void Main() {
    int[] input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
    long[] h = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
    Array.Sort(h);
    
    long total = 0;
    if (input[0] > input[1])
      for (int i = 0; i < input[0] - input[1]; i++)
        total += h[i];
    
    Console.WriteLine(total);
  }
}


Measured memory_bytes: 41472
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int W=in.nextInt();
		int v[]=new int[n];
		int w[]=new int[n];
		for(int i=0;i<n;i++)
		{
			w[i]=in.nextInt();
			v[i]=in.nextInt();
		}
		long dp[][]=new long[n+1][W+1];
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=W;j++)
			{
				if(i==0 || j==0)
					dp[i][j]=0;
				else if(j>=w[i-1])
					dp[i][j]=Math.max(dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]]);
				else
					dp[i][j]=dp[i-1][j];
			}
		}
		System.out.println(dp[n][W]);
	}
}


Measured memory_bytes: 126420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int N, M;
set<int> G[200100];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, M) {
        int a, b; cin >> a >> b;
        G[a-1].insert(b-1);
        G[b-1].insert(a-1);
    }
    bool flag = false;
    rep(i, N) if (G[i].find(0)!=G[i].end() && G[i].find(N-1)!=G[i].end()) flag = true;
    if (flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 28416
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = vs[0];
			int b = vs[1];
			int q = vs[2];
			long[] s = new long[a + 2];
			long[] t = new long[b + 2];
			s[0] = -20000000000;
			for (int i = 1; i <= a; i++) {
				s[i] = long.Parse(Console.ReadLine());
			}
			s[a + 1] = 20000000000;
			t[0] = -20000000000;
			for (int i = 1; i <= b; i++) {
				t[i] = long.Parse(Console.ReadLine());
			}
			t[b + 1] = 20000000000;
			for (int i = 0; i < q; i++) {
				long x = long.Parse(Console.ReadLine());

				int[,] trg = new int[2, 2];
				trg[0, 1] = Array.BinarySearch(s, x);
				if (trg[0, 1] < 0) {
					trg[0, 1] = ~trg[0, 1];
				}
				trg[0, 0] = trg[0, 1] - 1;
				trg[1, 1] = Array.BinarySearch(t, x);
				if (trg[1, 1] < 0) {
					trg[1, 1] = ~trg[1, 1];
				}
				trg[1, 0] = trg[1, 1] - 1;
				//System.Diagnostics.Debug.WriteLine($"{x} s[{trg[0, 0]}]={s[trg[0, 0]]} s[{trg[0, 1]}]={s[trg[0, 1]]} t[{trg[1, 0]}]={t[trg[1, 0]]} t[{trg[1, 1]}]={t[trg[1, 1]]} ");
				long ans = long.MaxValue;
				for (int j = 0; j < 2; j++) {
					for (int k = 0; k < 2; k++) {
						ans = Math.Min(ans, Math.Abs(x - s[trg[0, j]]) + Math.Abs(s[trg[0, j]] - t[trg[1, k]]));
						ans = Math.Min(ans, Math.Abs(x - t[trg[1, k]]) + Math.Abs(t[trg[1, k]] - s[trg[0, j]]));
					}
				}
				Console.WriteLine(ans);
			}


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 19532
#include <stdio.h>
#include<string.h>

int main(void)
{
  char S[256];
  char T[256];
  scanf("%s %S", S, T);
  int A, B;
  scanf("%d %d", &A, &B);
  char U[256];
  scanf("%s", U);

  if (strcmp(U, S) == 0)
    printf("%d %d\n", A - 1, B);
  else
    printf("%d %d\n", A, B - 1);

  return 0;
}

Measured memory_bytes: 128
H, W = map(int, input().split())

line_list = []

for i in range(H):
    line = input()
    line_list.append(line)

flag = True
for i in range(len(line_list)):
    for j in range(len(line_list[i])):
        if flag == False:
            break
        if line_list[i][j] == "#":
            if i == 0:
                if j == 0:
                    if "#" not in [line_list[i + 1][j], line_list[i][j + 1]]:
                        flag = False
                elif j == W - 1:
                    if "#" not in [line_list[i + 1][j], line_list[i][j - 1]]:
                        flag = False
                else:
                    if "#" not in [line_list[i + 1][j], line_list[i][j - 1], line_list[i][j + 1]]:
                        flag = False
            elif i == H - 1:
                if j == 0:
                    if "#" not in [line_list[i - 1][j], line_list[i][j + 1]]:
                        flag = False
                elif j == W - 1:
                    if "#" not in [line_list[i - 1][j], line_list[i][j - 1]]:
                        flag = False
                else:
                    if "#" not in [line_list[i - 1][j], line_list[i][j - 1], line_list[i][j + 1]]:
                        flag = False
            else:
                if j == 0:
                    if "#" not in [line_list[i - 1][j], line_list[i + 1][j], line_list[i][j + 1]]:
                        flag = False
                elif j == W - 1:
                    if "#" not in [line_list[i - 1][j], line_list[i + 1][j], line_list[i][j - 1]]:
                        flag = False
                else:
                    if "#" not in [line_list[i - 1][j], line_list[i + 1][j], line_list[i][j - 1], line_list[i][j + 1]]:
                        flag = False

print("Yes" if flag else "No")


Measured memory_bytes: 3188
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	ex := make([]float64, N+1)
	for i := 1; i <= N; i++ {
		var p int
		fmt.Scan(&p)
		ex[i] = ex[i-1] + float64(1+p)/2
	}

	max := 0.0
	for i := K; i <= N; i++ {
		v := ex[i] - ex[i-K]
		if max < v {
			max = v
		}
	}
	fmt.Println(max)
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li r, c, kk;

// dp[i][j][k] : (i, j)でk個拾った時の最大値
li dp[3030][3030][4];

li val[3030][3030];

int main() {
    cin >> r >> c >> kk;
    rep(i, kk) {
        li rr, cc, v;
        cin >> rr >> cc >> v;
        val[rr][cc] = v;
    }

    repp(rr, 1, r + 1) {
        repp(cc, 1, c + 1) {
            // 左から(ry
            rep(k, 4) {
                dp[rr][cc][k] = max(dp[rr][cc][k], dp[rr][cc - 1][k]);
                if (k > 0) {
                    dp[rr][cc][k] = max(dp[rr][cc][k], dp[rr][cc - 1][k - 1] + val[rr][cc]);
                }
            }
            rep(k, 4) {
                dp[rr][cc][0] = max(dp[rr][cc][0], dp[rr - 1][cc][k]);
                dp[rr][cc][1] = max(dp[rr][cc][1], dp[rr - 1][cc][k] + val[rr][cc]);
            }
        }
    }


    li res = 0;
    rep(k, 4) {
        res = max(res, dp[r][c][k]);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 358500
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x[]=new int[3],tmp;
		for(int i=0;i<x.length;i++) {
			x[i]=scan.nextInt();
		}
		for(int i=0;i<x.length-1;i++) {
			for(int j=i+1;j<x.length;j++) {
				if(x[i]>x[j]) {
					tmp=x[i];
					x[i]=x[j];
					x[j]=tmp;
				}
			}
		}
		System.out.println(x[0]+" "+x[1]+" "+x[2]);
        scan.close();
	}

}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

	FAST;

	cin >> n;
	cout << 48 - n << '\n';

	return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> data(n );
  vector<int> sum(n);
  rep(i, n) {
    cin >> data.at(i);
  }
  rep(i, n) {
    sum.at(i) = data.at(i);
  }
  sum.at(n-1)  = data.at(n-2);
  int ans = sum.at(0);
  rep(i, n) {
    if (data.at(i) >= sum.at(i + 1)) {
      ans += sum.at(i+1);
  } else {
     sum.at(i + 1) = data.at(i);
     ans += sum.at(i+1);
  }
}
cout << ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013



int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		int n,k;
		cin>>n>>k;
		int a[n];
		fi(0,n) cin>>a[i];
		int dp[n];
		fill(dp,dp+n,1000000000);
		dp[0]=0;
		fi(1,n)
		{
			fj(1,k+1)
				if(i-j>=0)
				dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
		cout<<dp[n-1];
		
		
		
	}
}


Measured memory_bytes: 4380
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        String[] a = new String[h];
        for (int i = 0; i < h; i++) {
            a[i] = sc.next();
        }

        // 主処理
        int countSum = 0;
        for (int i = 0; i < h; i++) {
            int count = a[i].length() - a[i].replace("#", "").length();
            countSum += count;
        }
        boolean judge = countSum == w + h - 1;
        String result = judge ? "Possible" : "Impossible";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 23636
n, d = map(int, input().split())
x = []
for i in range(n):
  xi = list(map(int, input().split()))
  x.append(xi)

def dis(xa, xb):
  dis_ = 0
  for a, b in zip(xa, xb):
    dis_ += (a - b) ** 2
  dis_ = dis_ ** 0.5
  return dis_

cnt = 0
for i in range(n):
  for j in range(i+1, n):
    d = dis(x[i], x[j])
    if d % 1.0 == 0:
      cnt += 1
print(cnt)

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

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

typedef long long ll;
vector<string>A,B;
bool same(int r,int c){
	rep(i,B.size())rep(j,B.size())if(A[i+r][j+c]!=B[i][j])return false;
	return true;
}
const int INF=1e9+7;

int main(){
	int n,m;
	cin>>n>>m;
	rep(i,n){
		string str;
		cin>>str;
		A.push_back(str);
	}
	rep(j,m){
		string str;
		cin>>str;
		B.push_back(str);
	}
	bool ans=false;
	rep(i,n-m+1)rep(j,n-m+1)ans|=same(i,j);
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
from math import ceil, log2
m_list = [(1/2)**ceil(log2(K/(n+1))) if n+1<K else 1 for n in range(N)]
#print(m_list) #各nに対し勝つのに必要な表の数
print(sum(m_list)/N)

Measured memory_bytes: 3864
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    int N;
    string S;
    cin >> N >>S;
    
    int w=0,b=0;
    for (int i=0; i<N; i++) {
        if (S[i]=='.') {
            w++;
        }
        else{
            b++;
        }
    }
    int ans=b;
    if (b>w) {
        ans=w;
    }
    int count_w=0,count_b=0;
    for (int i=0; i<N; i++) {
        if(ans>count_b+(w-count_w)){
            ans=count_b+(w-count_w);
        }
        if (S[i]=='.') {
            count_w++;
        }
        else{
            count_b++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

const int MAXN = 100000 + 5;

int n;
int A[MAXN], B[MAXN];

void exec() {
  long long ans(0);
  int i;
  scanf("%d", &n);
  for (i=0; i<n; ++i) {
    scanf("%d%d", A+i, B+i);
  }
  for (i=n-1; i>=0; --i) {
    A[i] = (A[i] + ans) % B[i];
    ans += (B[i] - A[i]%B[i]) % B[i];
  }
  printf("%lld\n", ans);
}

int main() {
  if (fopen("A.in", "r") != NULL) {
    freopen("A.in", "r", stdin);
    freopen("A.out", "w", stdout);
  }
  exec();
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int Q=998244353;
inline int inv(int x){
	int r=1,y=Q-2;
	while(y){
		if(y&1) r=1LL*r*x%Q;
		x=1LL*x*x%Q;
		y>>=1;
	}
	return r;
}
int main(){
	int n,p3=1,cur=2;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		p3=p3*3LL%Q;
	}
	for(int i=0;i<n/2;i++){
		p3=(p3+Q-cur)%Q;
		cur=2LL*cur*(n-i)%Q*inv(i+1)%Q;
	}
	printf("%d\n",p3);
	return 0;
}

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

int main(){

  int N,u,k,v;
  cin>>N;
  int graph[N][N];

  //init
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      graph[i][j]=0;

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

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout<<graph[i][j];
      if(j==N-1) cout<<endl;
      else cout<<" ";
    }
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 x(n);
  cin >> x;
  auto sx = x;
  sort(all(sx));
  rep(i, n) {
    if (x[i] <= sx[n / 2 - 1]) {
      cout << sx[n / 2] << endl;
    } else {
      cout << sx[n / 2 - 1] << endl;
    }
  }
}

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	string s;
	cin >> s;

	if(s[s.size()-1] == 's'){
		s = s + "es";
	}
	else{
		s = s + "s";
	}

	cout << s << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 100010;
string S,T;
int Q;
int sum_S[MAX_N];
int sum_T[MAX_N];
int main() {
  cin >> S;
  cin >> T;
  cin >> Q;
  for (int i = 0; i < S.size(); i++){
    if (S[i] == 'A'){
      sum_S[i + 1] += 1;
    }else{
      sum_S[i + 1] += 2;
    }
    sum_S[i + 1] += sum_S[i];
  }
  for (int i = 0; i < T.size(); i++){
    if (T[i] == 'A'){
      sum_T[i + 1] += 1;
    }else{
      sum_T[i + 1] += 2;
    }
    sum_T[i + 1] += sum_T[i];
  }
  for (int i = 0; i < Q; i++){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int res1 = sum_S[b] - sum_S[a - 1];
    int res2 = sum_T[d] - sum_T[c - 1];
    res1 %= 3;
    res2 %= 3;

    if (res1 == res2){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }

  }
  return 0;
}


Measured memory_bytes: 1664
function main( input ) {
    const A = input.split('\n')[0];
    const B = input.split('\n')[1];
    const C = input.split('\n')[2];
    const X = input.split('\n')[3];
  
    let ans = 0;
    for(let a = 0; a <= A; a++ ){
        for( let b = 0; b <= B; b++ ){
            for( let c = 0; c <= C; c++ ) {
                if( (a * 500 + b * 100 + c * 50) == X ){
                    ans++;
                }
            }
        }
    }

    console.log(ans);
}

main( require('fs').readFileSync('/dev/stdin', 'utf8') );

Measured memory_bytes: 32380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int common(string a, string b) {
    int c[26] = {0};
    rep(i, SZ(a)) {
        c[a[i] - 'a']++;
    }
    int sum = 0;
    rep(i, SZ(b)) {
        if (c[b[i] - 'a']) {
            sum++;
            c[b[i] - 'a'] = 0; // 同じ文字を許可するなら = 0 を -- にする
        }
    }
    return sum;
}
int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i, SZ(s)) {
        string a = s.substr(0, i + 1);
        string b = s.substr(i + 1, SZ(s) - SZ(a));
        chmax(ans, common(a, b));
    }
    out(ans);
}



Measured memory_bytes: 256
// Written by newbiechd
#include <cstdio>
#include <cctype>
#include <algorithm>
#define int long long
using namespace std;

const int BUF = 1000003;
inline char getChar() {
  static char buf[BUF], *bufS, *bufT;
  if (bufS == bufT) {
    bufT = (bufS = buf) + fread(buf, 1, BUF, stdin);
    if (bufS == bufT)
      return EOF;
  }
  return *bufS++;
}
inline int read() {
  int f = 0;
  char ch;
  while (!isdigit(ch = getChar())) {}
  do f = f * 10 + (ch ^ 48);
  while (isdigit(ch = getChar()));
  return f;
}

signed main() {
  int n = read(), a = read(), b = read(), ans = 0;
  if (a > b)
    swap(a, b);
  if ((a ^ b) & 1) {
    if (a - 1 < n - b)
      ans = a, b -= a, a = 1;
    else
      ans = n - b + 1, a += n - b + 1, b = n;
  }
  printf("%lld\n", (b - a) / 2 + ans);
  return 0;
}


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

using namespace std;

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

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

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int ret = a[m - 1] - a[0];
  for (int i = m; i < n; ++i) {
    ret = min(ret, a[i] - a[i - m + 1]);
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (B - A <= 0) {
            System.out.println("delicious");
        } else if (B - A <= X) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}


Measured memory_bytes: 21844
A = int(input())
B = list(map(int, input().split()))
ans = 0

for i in range(1, A-1):
  if B[i-1] > B[i] > B[i+1]:
    ans += 1
  elif B[i-1] < B[i] < B[i+1]:
    ans += 1
    
print(ans)


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

int main() {
    std::string s, t;
    std::cin >> s >> t;

    std::sort(s.begin(), s.end());
    std::sort(t.begin(), t.end());
    std::reverse(t.begin(), t.end());

    if (s < t) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int N, Ma, Mb;
int a[40], b[40], c[40];
int dp[40][401][401];
//dp(i,j,k):=薬iまで見てAがjBがkの時の最低コスト

const int INF810 = 1145141919;

int main() {
	cin >> N >> Ma >> Mb;
	for (int i = 0; i < N; i++)cin >> a[i] >> b[i] >> c[i];

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 400; j++) {
			for (int k = 0; k <= 400; k++) {
				dp[i][j][k] = INF810;
			}
		}
	}
	dp[0][0][0] = 0;
	dp[0][a[0]][b[0]] = c[0];

	for (int i = 1; i < N; i++) {
		for (int j = 0; j <= 400; j++) {
			for (int k = 0; k <= 400; k++) {
				dp[i][j][k] = dp[i - 1][j][k];
				if (j - a[i] >= 0 && k - b[i] >= 0) {
					dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - a[i]][k - b[i]] + c[i]);
				}
			}
		}
	}
	int ans = INF810;
	for (int i = 1; i <= 400; i++) {
		if (Ma * i > 400 || Mb * i > 400)break;
		ans = min(ans, dp[N - 1][Ma * i][Mb * i]);
	}
	if (ans == INF810)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 25344
# coding: utf-8
# Your code here!

while 1:
  x = input()
  if x == "0":
    break
  a = 0
  b = 0
  for i in range(1,len(x)):
    if x[i] == "A":
      a += 1
    else:
      b += 1
  if a > b:
    a += 1
  else:
    b += 1
  print(a,b)


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

int main() {
	int N, M;
  cin >> N >> M;
  
  vector<vector<int>> vec(M, vector<int>(2));
  vector<int> data(N);
  
  for(int i = 0; i < M; i++){

    for(int j = 0; j < 2; j++){
      
      cin >> vec.at(i).at(j);
      

      for(int k = 1; k <= N; k++){
        if(vec.at(i).at(j) == k){
          data.at(k - 1)++;
        }
      }

    }
  }
  for(int x : data){
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <cmath>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
  string S,T;
  int x = 0;
  cin >> S;
  cin >> T;
  for(int i = 0;i < S.size();i++){
    if(S.at(i) != T.at(i)){
      x++;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 3916
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	int[] S, C;
	foreach(i; 0..M) {
		auto ip2 = readAs!(int[]), s = ip2[0], c = ip2[1];
		S ~= s;
		C ~= c;
	}
	foreach(i; 0..(10 ^^ (N))) {
		auto st = i.to!string;
		if(st.length != N) continue;
		bool flag = true;
		foreach(k; 0..M) {
			if(!(st[S[k]-1] - '0' == C[k])) flag = false;
		}
		if(flag) {
			writeln(i);
			return;
		}
	}
	writeln(-1);
}

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

import std.stdio;
import std.string;
import std.functional;
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: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,ans=0;
  cin >> n;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    ans += -a+b+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256