akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    string s; cin >> s;
    ll L = s.size();

    set<ll> se;
    // RLなるi
    FOR(i, 0, L-1){
        if(s[i]=='R' && s[i+1]=='L'){
            se.insert(i);
        }
    }

    vector<ll> C(L, 0); // 位置ごとに子供をカウント
    FOR(i, 0, L){
        if(s[i]=='R'){
            auto it = se.lower_bound(i);
            ll index = *it; // 最終的に落ちるRLの位置
            ll diff = abs(index - i);
            if(diff%2==0){
                C[index]++;
            }else{
                C[index+1]++;
            }
        }
        else{
            auto it = se.lower_bound(i);
            it--; // 自分より左側のRL
            ll index = *it;
            ll diff = abs(index - i);
            if(diff%2==0){
                C[index]++;
            }else{
                C[index+1]++;
            }
        }
    }
    vprint(C);

    return 0;
}

Measured memory_bytes: 4432
import sys

def i2s():
    return sys.stdin.readline().rstrip()

def ii2ss(n):
    return [sys.stdin.readline() for _ in range(n)]

def sp2nn(sp, sep=' '):
    return [int(s) for s in sp.split(sep)]

def ss2nn(ss):
    return [int(s) for s in list(ss)]

def main(S):
    st = set(('A', 'C', 'G', 'T'))
    cmax = 0
    c = 0
    for s in S:
        if s in st:
            c += 1
        else:
            if cmax < c:
                cmax = c
            c = 0
    if cmax < c:
        cmax = c
    print(cmax)

main(i2s())

Measured memory_bytes: 3064
s = gets.chomp
flag = false
while !flag
  if s.size.even? 
    s = s.slice(0,s.size - 2)
  else
    s = s.slice(0,s.size - 1)
  end
  if s[0..s.size/2 - 1] == s[s.size/2..-1]
    flag = true
  end
end

puts s.size

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

ll fact(ll n){
  ll res=1;
  rrep(i,n){
    res*=i;
    res%=MOD;
  }
  return res;
}
int main(){
  ll n,m;
  cin>>n>>m;
  ll ans;
  if(abs(n-m)>=2){
    cout<<0<<endl;
    return 0;
  }
  if(abs(n-m)==1){
    ans=(fact(n)*fact(m))%MOD;
  }
  if(n==m){
    ans=((fact(n)*fact(m))%MOD*2)%MOD;
  }
  if(ans<0) ans+=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 3608
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma endregion

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	lint n; cin >> n;
	lint ans = 0;
	for (int i = 1; i <= n; i++) 
		for (int j = i; j <= n; j += i) 
			ans += j;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public class Program
{
    public static void Main()
    {
        string[] inputSplit = ReadLine().Split(' ');
        int numH = int.Parse(inputSplit[0]);
        int numW = int.Parse(inputSplit[1]);
        List<string> canvas = new List<string>(numH + 2);
        canvas.Add(new string('0', numW + 2));
        for (int i = 0; i < numH; i++) canvas.Add("0" + ReadLine() + "0");
        canvas.Add(new string('0', numW + 2));
        
        for (int i = 1; i < numH + 1; i++)
        {
            for (int j = 1; j < numW + 1; j++)
            {
                if (canvas[i][j] == '#')
                {
                    if (canvas[i - 1][j] == '#' || canvas[i][j - 1] == '#' || canvas[i][j + 1] == '#' || canvas[i + 1][j] == '#') { }
                    else
                    {
                        WriteLine("No");
                        return;
                    }
                }
            }
        }
        WriteLine("Yes");
    }
}

Measured memory_bytes: 13140
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

num = Ss()
num.sort(reverse=True)
ans = int("".join(num[:2])) + int(num[-1])
print(ans)

Measured memory_bytes: 63212
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, a, b;

int main() {
    n = read(), a = read(), b = read();
    cout << min(a * n, b) << endl;
    return 0;
}


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

int main() {
  long int a, b;
  cin >> a >> b;
  long int c[a],d[a];
  int counter = 0;
  for(int i = 0;i<a;i++){
    cin >> c[i] >> d[i];
    if(c[i]*c[i]+d[i]*d[i]<=b*b) counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 6724
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

template<class Container>
Container reversed(const Container& c) {
  using std::begin;
  using std::end;
  Container r;
  r.reserve(c.size());
  std::reverse_copy(begin(c), end(c), std::back_inserter(r));
  return r;
}

int main(){

  ll n,m;
  cin >> n>> m;
  ll a[n];
  for(int i=0;i<n;i++)cin >> a[i];

  sort(a,a+n);

  vector<vector<ll>> v;
  ll b,c;
  for(int i=0;i<m;i++){
    cin >> b >> c;
    v.push_back({c,b});
  }
  sort(v.begin(),v.end());
  //vector<vector<ll>> v2=reversed(v);
  reverse(v.begin(),v.end());

  vector<ll> d={};

  ll count=0;
  for(int i=0;i<v.size();i++){
    for(int j=0;j<v[i][1];j++){
      if(count>=n)break;
      d.push_back(v[i][0]);
      count++;
    }
    if(count>n)break;
  }

  for(int i=0;i<n;i++){
    d.push_back(a[i]);
  }

  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());

  ll s=0;
  for(int i=0;i<n;i++)s+=d[i];

  cout << s << endl;

}

Measured memory_bytes: 10800
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void solve(string b) {
  string ans;
  if (b == "A") {
    ans = "T";
  } else if (b == "T") {
    ans = "A";
  } else if (b == "G") {
    ans = "C";
  } else {
    ans = "G";
  }
  cout << ans << endl;
}

int main() {
  string b;
  cin >> b;
  solve(b);
  return 0;
}


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

int main()
{
    int n;cin>>n;
    vector<int> heights(n);
    for(int &a : heights)
    {
        cin>>a;
    }
    vector<int> p(n);
    p[0] = 0;p[1] = abs(heights[0]-heights[1]);
    for(int i = 2; i < n; i++)
    {
        p[i] = min(p[i-1]+abs(heights[i]-heights[i-1]), p[i-2]+abs(heights[i]-heights[i-2]));
    }
    cout<<p[n-1]<<"\n";
}

Measured memory_bytes: 1024
// 2

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<29;
const bool debug = 0;

int main() {
	int c1,c2,c3,c4,c5,c6;
	
	cin >> c1 >> c2 >> c3 >> c4 >> c5 >> c6;
  ll sum = c1 + c2*5 + c3*10 + c4*50 + c5*100 + c6*500;
  if(sum >= 1000)cout << 1 << endl;
  else cout << 0 << endl;
  
	return 0;
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

constexpr int MAX = 101010;

int n;
ll c;
ll x[MAX], y[MAX], v[MAX], a[MAX], b[MAX], d[MAX];


ll solve() {
	a[0] = v[0];
	Rep(i, n) a[i] = a[i - 1] + v[i];

	rep(i, n) y[i] = c - x[i];
	b[n - 1] = v[n - 1];
	for (int i = n - 2; i >= 0; --i) b[i] = b[i + 1] + v[i];

	d[n - 1] = b[n - 1] - y[n - 1];
	for (int i = n - 2; i >= 0; --i) {
		d[i] = b[i] - y[i];
		chmax(d[i], d[i + 1]);
	}

	ll ans = 0;
	rep(i, n) {
		ll sm = 0;

		sm -= x[i];
		sm += a[i];
		chmax(ans, sm);

		sm -= x[i];
		if (i < n - 1) sm += d[i + 1];
		chmax(ans, sm);
	}
	return ans;
}

int main() {
	cin >> n >> c;

	rep(i, n) cin >> x[i] >>  v[i];

	ll ans = 0;
	chmax(ans, solve());

	reverse(v, v + n);
	rep(i, n) x[i] = c - x[i];
	reverse(x, x + n);

	chmax(ans, solve());
	cout << ans << endl;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int w = sc.nextInt();


        char chr[][] = new char[h][w];

        Queue<int []> queue = new ArrayDeque<int []>();
        for (int i=0; i<h; i++){
            String row = sc.next();
            for (int j=0; j<w; j++){
                chr[i][j] = row.charAt(j);
                if (chr[i][j]=='#'){
                    int start[] = {i, j, 0};
                    queue.add(start);
                }
            }
        }

        int flag[][] = new int[h][w];
        int count = 0;

        int dx[] = {1,0,-1,0};
        int dy[] = {0,1,0,-1};
        while(!queue.isEmpty()){
            int temp[] = queue.remove();
            int y = temp[0];
            int x = temp[1];
            int depth = temp[2];
            for (int i=0; i<4; i++){
                if (0<=y+dy[i] && y+dy[i]<= h-1 && 0<=x+dx[i] && x+dx[i]<=w-1){
                    if (flag[y+dy[i]][x+dx[i]]==0 && chr[y+dy[i]][x+dx[i]]=='.'){
                        flag[y+dy[i]][x+dx[i]]=1;
                        int add_queue[] = {y+dy[i], x+dx[i], depth+1};
                        queue.add(add_queue);
                        count = depth+1;
                    }
                }
            }
        }
        System.out.println(count);

    }

}



Measured memory_bytes: 70816
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int sum=0, ans=0; // 配ったお菓子の合計と喜ぶ子供の数
  for (int i=0; i<N; i++) {
    if (a[i]+sum<=x&&i!=N-1) {
      sum += a[i];
      ans++;
    }
    else if (a[i]+sum==x&&i==N-1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
N,Q=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
acc=[0]*N
cnt=0
flag=0
for index,i in enumerate(list(S)):
    if i == "C" and flag == 1:
        cnt+=1
        flag=0
    if i != "C":
        flag=0
    if i == "A":
        flag=1
    acc[index]=cnt
for j in range(Q):
    n1,n2=[int(x) for x in stdin.readline().rstrip().split()]
    print(acc[n2-1]-acc[n1-1])

Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define tddd tuple<double,double,double>
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 10005
typedef long long int ll;
ll dp[N];
bool cmp(pair<ii,int> A,pair<ii,int> B)
{
    if(min(A.F.S,B.F.S-A.F.F)!=min(B.F.S,A.F.S-B.F.F))
        return (min(A.F.S,B.F.S-A.F.F)>min(B.F.S,A.F.S-B.F.F));
    return false;
}
int main()
{
    int i,j,n,w,c,v;
    int C=0;
    in(n);
    viii ad(n);
    rep(i,n)
    {
        in3(w,c,v);
        C=max(C,c);
        ad[i]={{w,c},v};
    }
    sort(all(ad),cmp);
    ll x,ans=0;
    rep(i,n)
    {
        w=ad[i].F.F,c=ad[i].F.S,v=ad[i].S;
        x=0;
        rep(j,c+1)
            x=max(x,dp[j]);
        ans=max(ans,x+v);
        for(j=min(C,c+w);j>=w;j--)
            dp[j]=max(dp[j],v+dp[j-w]);
    }
    outl(ans);
}








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

using namespace std;

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

	int x, y;
	cin >> x >> y;

	int tmp1=y-(2*x), tmp2=(4*x)-y;
	if(tmp1>=0 && tmp2>=0 && tmp1%2==0 && tmp2%2==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3652
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (K, S) = (input[0], input[1])
var ans = 0
for X in 0...K {
    for Y in 0...K {
        let Z = S - X - Y
        if 0...K ~= Z {
            ans += 1
        }
    }
}
print(ans)


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "-1" << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(){
    int N;
    int v[57];
    cin >> N;
    REP(i,N){
        cin >> v[i];
    }
    sort(v,v+N);
    double Ans=v[0];
    REP(i,N-1){
        Ans=(Ans+v[i+1])/2;
    }
    printf("%.8f\n",Ans);
    return 0;
}   


Measured memory_bytes: 256
import collections
from itertools import combinations
import sys
input = sys.stdin.readline

N = int(input())
s = [''.join(sorted(list(input()))) for _ in range(N)]
c = collections.Counter(s)

cnt = 0
for i in c.values():
    if i > 1:
        cnt += i*(i-1)//2
print(cnt)

Measured memory_bytes: 64860
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll r,g,b,x;
    cin>>r>>g>>b;
    x=g*10+b;
    if (x%4==0)cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}



Measured memory_bytes: 256
////////////////////////////////////////////    _LeMur_
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 20005;
const int inf = 1000 * 1000 * 1000;
const int mod = 998244353;

int n , k;
string s;

pair < pair<int,int>,int > p[N];
int R[N];

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n >> k;
    cin >> s;
    k = min(k , 16);
    while(k--){
        string t = s;
        reverse(t.begin() , t.end());
        string S = s + t;
        for(int i=0;i<=16;i++){
            for(int j=0;j<(int)S.size();j++){
                if(i == 0){
                    p[j].first = make_pair(S[j] - 'a' , 0);
                    p[j].second = j;
                }
                else{
                    if(j + (1 << (i - 1)) >= (int)S.size()){
                        p[j].first = make_pair(R[j] , -1);
                        p[j].second = j;
                    }
                    else{
                        p[j].first = make_pair(R[j] , R[j + (1 << (i - 1))]);
                        p[j].second = j;
                    }
                }
            }
            sort(p , p + (int)S.size());
            int it = 0;
            for(int j=0;j<(int)S.size();j++){
                ++it;
                pair <int,int> x = p[j].first;
                while(j < (int)S.size() && p[j].first == x){
                    R[ p[j].second ] = it;
                    ++j;
                }
                --j;
            }
        }
        int mn = inf;
        int id;
        for(int i=0;i<n;i++){
            if(R[i] < mn){
                mn = R[i];
                id = i;
            }
        }
        if(k == 0){
            int it = 0;
            while(it < n){
                s[it++] = S[id++];
            }
        }
        else{
            int it = n - 1;
            id = 2 * n - 1 - id;
            while(it >= 0){
                s[it--] = S[id--];
            }
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;cin >> n;
    ll sum = 0;
    for(int i=1;i<=n;++i){
        if(i%3!=0 && i%5!=0){
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3624
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n, k; cin >> n >> k;
    map<int, int> mp;
    rep(i, n) {
        int a, b; cin >> a >> b;
        mp[a] += b;
    }
    int cnt = 0;
    for(auto p: mp) {
        cnt += p.sc;
        if(cnt >= k) {
            cout << p.fr << endl;
            return;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 4224
S = input()
N = len(S)
L = [0 for _ in range(N)]
a = 0
b = 1
while a != N:
    if S[a] == 'R':
        while b != N and S[a] == S[b]:
            b += 1
        if b-a == 1:
            L[a] += 1
        elif (b-a) % 2 == 1:
            L[b] += (b-a) // 2
            L[b-1] += (b-a)//2+1
        else:
            L[b] += (b-a)//2
            L[b-1] += (b-a)//2
    else:
        while b != N and S[a] == S[b]:
            b += 1
        if b-a == 1:
            L[a] += 1
        elif (b-a) % 2 == 1:
            L[a-1] += (b-a) // 2
            L[a] += (b-a)//2+1
        else:
            L[a-1] += (b-a)//2
            L[a] += (b-a)//2
    a = b
    b = a+1
print(*L)

Measured memory_bytes: 49660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int H,W,M;
  cin >> H >> W >> M;
  vi h(M),w(M),counth(H),countw(W);
  rep(i,M) {
    cin >> h[i] >> w[i];
    h[i]--;w[i]--;
    counth[h[i]]++;
    countw[w[i]]++;
  }
  
  int mh=0,mw=0,ch=1,cw=1;
  rep(i,H) {
    if(mh<counth[i]) {
      ch=1;
      mh=counth[i];
    }
    else if(mh==counth[i]) ch++;
  }
  rep(i,W) {
    if(mw<countw[i]) {
      cw=1;
      mw=countw[i];
    }
    else if(mw==countw[i]) cw++;
  }
  
  int count=0;
  rep(i,M) {
    if(counth[h[i]]==mh&&countw[w[i]]==mw) count++;
  }
  if((ll)ch*cw>count) cout << mh+mw << endl;
  else cout << mh+mw-1 << endl;
}

Measured memory_bytes: 7984
program V801;
 var
  a:array[0..301,0..301] of longint;
  b,d,f:array[0..301] of longint;
  i,j,m,n,maxp,smax:longint;
 begin
  readln(n,m);
  for i:=1 to n do
   a[i,m+1]:=0;
  for i:=1 to n do
   begin
    for j:=1 to m do
     read(a[i,j]);
    readln;
   end;
  fillchar(d,sizeof(d),0);
  maxp:=0;
  for i:=1 to n do
   begin
    inc(d[a[i,1]]);
    if d[a[i,1]]>d[maxp] then maxp:=a[i,1];
   end;
  smax:=d[maxp];
  for i:=1 to m do
   f[i]:=1;
  for i:=1 to n do
   b[i]:=1;
  for i:=2 to m do
   begin
    fillchar(d,sizeof(d),0);
    f[maxp]:=0;
    maxp:=0;
    for j:=1 to n do
     begin
      while f[a[j,b[j]]]=0 do inc(b[j]);
      if b[j]<>m+1 then
       begin
        inc(d[a[j,b[j]]]);
        if d[a[j,b[j]]]>d[maxp] then maxp:=a[j,b[j]];
       end;
     end;
    if d[maxp]<smax then smax:=d[maxp];
   end;
  writeln(smax);
 end.


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int ar[100001],m[100001];
int inline findmin(int start, int end)
{   int min = m[start +1] + abs(ar[start] - ar[start + 1]);
 //cout<<min<<"m"<<endl;
	for(int i=start+1;i<=end;i++)
	{
		int temp = m[i] + abs(ar[i] - ar[start]);
		// cout<<temp<<"t"<<endl;
		if(temp < min)
		    min = temp;
	}
	
	return min;
}
int main() {
	int N,K;
	cin>>N>>K;
	for(int i=0;i<N;i++)
	cin>>ar[i];
	
	m[N-1] = 0 ;
	m[N-2] = abs(ar[N-1] - ar[N-2]);
	for(int i=N-3 ; i>-1;i--)
	{
		// cout<<min(i+K,N-2)<<i<<endl;
		m[i] = findmin(i,min(i+K,N-1));
	}
	cout<<m[0]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
using namespace std;
int n,m,p;
int fld[7][7][7];
int top[7][7];
bool ok(int x,int y,int z,int dx,int dy,int dz){
    if(fld[x][y][z]==-1||x<0||y<0||z<0||x>=n||y>=n||z>=n)return false;
    rep(i,m-1){
        int px=x+dx*i,py=y+dy*i,pz=z+dz*i;
        int nx=x+dx*(i+1),ny=y+dy*(i+1),nz=z+dz*(i+1);
        if(nx>=n||ny>=n||nz>=n||nx<0||ny<0||nz<0)return false;
        if(nz>top[nx][ny])return false;
        if(fld[nx][ny][nz]!=fld[px][py][pz])return false;
    }
    return true;
}
bool rec(int x,int y){
    rep(i,n){
        if(ok(i,y,top[x][y],1,0,0))return true;
        if(ok(x,i,top[x][y],0,1,0))return true;
        if(ok(x,y,i,0,0,1))return true;
        if(ok(x-i,y-i,top[x][y],1,1,0))return true;
        if(ok(x+i,y+i,top[x][y],1,1,0))return true;
        if(ok(x-i,y+i,top[x][y],1,-1,0))return true;
        if(ok(x+i,y-i,top[x][y],1,-1,0))return true;
        if(ok(x+i,y,top[x][y]+i,1,0,1))return true;
        if(ok(x-i,y,top[x][y]-i,1,0,1))return true;
        if(ok(x+i,y,top[x][y]-i,1,0,-1))return true;
        if(ok(x-i,y,top[x][y]+i,1,0,-1))return true;
        if(ok(x,y+i,top[x][y]+i,0,1,1))return true;
        if(ok(x,y-i,top[x][y]-i,0,1,1))return true;
        if(ok(x,y+i,top[x][y]-i,0,1,-1))return true;
        if(ok(x,y-i,top[x][y]+i,0,1,-1))return true;
        if(ok(x+i,y+i,top[x][y]+i,1,1,1))return true;
        if(ok(x-i,y-i,top[x][y]-i,1,1,1))return true;
        if(ok(x+i,y-i,top[x][y]-i,1,-1,-1))return true;
        if(ok(x-i,y+i,top[x][y]+i,1,-1,-1))return true;
        if(ok(x+i,y+i,top[x][y]-i,1,1,-1))return true;
        if(ok(x-i,y-i,top[x][y]+i,1,1,-1))return true;
        if(ok(x+i,y-i,top[x][y]+i,1,-1,1))return true;
        if(ok(x-i,y+i,top[x][y]-i,1,-1,1))return true;
    }
    return false;
}
int main(){
    while(1){
        string ans1="Draw";
        int ans2=-1;
        cin>>n>>m>>p;
        if(n+m+p==0)break;
        int x[p],y[p];
        memset(fld,-1,sizeof(fld));
        memset(top,0,sizeof(top));
        rep(i,p){cin>>x[i]>>y[i];x[i]--;y[i]--;}
        rep(i,p){
            if(i%2){
                fld[x[i]][y[i]][top[x[i]][y[i]]]=1;
            }else{
                fld[x[i]][y[i]][top[x[i]][y[i]]]=0;
            }
            if(rec(x[i],y[i])){
                if(i%2==0){
                    ans1="Black";ans2=i+1;
                }else{
                    ans1="White";ans2=i+1;
                }
                break;
            }
            top[x[i]][y[i]]++;
        }
        if(ans1=="Draw"){
            cout<<"Draw"<<endl;
        }else{
            cout<<ans1<<" "<<ans2<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 2948
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  map<string,vector<int> >m;
  string s;int x,f;
  for(;cin>>s>>x;)
    m[s].push_back(x);
  map<string,vector<int> >::iterator it=m.begin();
  for(;it!=m.end();it++){
    cout<<(*it).first<<endl;
    vector<int>v=(*it).second;
    sort(v.begin(),v.end());
    for(f=0;f<v.size();f++){
      if(f)cout<<' ';
      cout<<v[f];
    }
    cout<<endl;
  }
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(B==C){
  	cout << A << endl;
  }else if(C==A){
  	cout << B << endl;
  }else if(A==B){
  	cout << C << endl;
  }else{
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i];
	}
	int answer = inf;
	for (int i = 0; i <= 100; ++i) {
		int cur = 0;
		for (int j = 0; j < n; ++j) {
			cur += (x[j] - i) * (x[j] - i);
		} 
		answer = min(answer, cur);
	}
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int xa, ya, xb, yb;
int main() {
	cin >> xa >> ya >> xb >> yb;
	cout << xb - (yb - ya) << ' ' << yb - (xa - xb) << ' ' << xa - (yb - ya) << ' ' << ya - (xa - xb) << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n;
    map<int,int>m;
    rep(i,n-1){
        int temp;
        cin>>temp;
        m[temp]++;
    }
    for(int i=1;i<=n;i++){
        cout<<m[i]<<"\n";
    }
}


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

#define ntest 0

using namespace std;
int x;
void solve() {
    cin >> x;
    cout << ((x + 999) / 1000) * 1000 - x;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> a(m);//w, x
    vector<int> b(m);//h, y
    vector<int> x(w, 0);
    vector<int> y(h, 0);
    set<pair<int, int> > bomb;
    rep(i, m) {
        cin >> b.at(i) >> a.at(i);
        x.at(a.at(i) - 1)++;
        y.at(b.at(i) - 1)++;
        pair<int, int> pp;
        pp = make_pair(b.at(i), a.at(i));
        bomb.insert(pp);
    }
    int maxx = 0, maxy = 0;
    rep(i, w) {
        maxx = max(maxx, x.at(i));
    }
    rep(i, h) {
        maxy = max(maxy, y.at(i));
    }
    if (maxx == h || maxy == w) {
        cout << maxx + maxy - 1 << endl;
        return 0;
    }
    vector<int> kx(0);
    vector<int> ky(0);
    rep(i, w) {
        if (maxx == x.at(i)) {
            kx.push_back(i + 1);
        }
    }
    rep(i, h) {
        if (maxy == y.at(i)) {
            ky.push_back(i + 1);
        }
    }
    /*sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    set<int> sx;
    set<int> sy;
    rep(i, a.size()) {
        sx.insert(a.at(i));
    }
    rep(i, b.size()) {
        sy.insert(b.at(i));
    }*/
    rep(i, kx.size()) {
        rep(j, ky.size()) {
            pair<int, int> aaa;
            aaa = make_pair(ky.at(j), kx.at(i));
            if (!bomb.count(aaa)) {
                cout << maxx + maxy << endl;
                return 0;
            }
        }
    }
    cout << maxx + maxy  - 1 << endl;
}

Measured memory_bytes: 26196
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<59; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 1e5+7;
ll s[MX];
ll t[MX];
int A,B,Q;

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> A >> B >> Q;
    s[0] = -LINF;
    s[A+1] = LINF;
    t[0] = -LINF;
    t[B+1] = LINF;
    FOR(i,1,A) {
        cin >> s[i];
    }
    FOR(i,1,B) {
        cin >> t[i];
    }
    A += 2;
    B += 2;
    while(Q--) {
        ll x; cin >> x;
        ll su, sd, tu, td;
        ll ans = LINF;
        su = *lower_bound(s, s+A, x)-x;
        sd = x - *(upper_bound(s, s+A, x)-1);
        tu = *lower_bound(t, t+B, x)-x; 
        td = x - *(upper_bound(t, t+B, x)-1);
        chmin(ans, max(su, tu));
        chmin(ans, max(sd, td));
        chmin(ans, min(su,td)+su+td);
        chmin(ans, min(sd, tu)+sd+tu);
        cout << ans  << endl;
    }
    return 0;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int a = -1, b = -1;
    for (int i = 1; i < n; i++)
    {
        if (s.at(i - 1) == s.at(i))
        {
            a = i;
            b = i + 1;
            break;
        }
        if (i > 1 && s.at(i) == s.at(i - 2))
        {
            a = i - 1;
            b = i + 1;
            break;
        }
    }

    cout << a << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

int dp[105][100100];
int MAX_W = 100100;

// i番目まで使用して価値 j の時の最小の重さ
void solve(istream& cin, ostream& cout) {
  int N, W;
  cin >> N >> W;
  vector<int> w(N + 1), v(N + 1);
  FOR(i, 1, N) cin >> w[i] >> v[i];
  REP(i, N) REP(j, MAX_W) dp[i][j] = MOD;
  dp[0][0] = 0;
  FOR(i, 1, N) {
    REP(j, MAX_W) {
      if (j < v[i]) dp[i][j] = dp[i - 1][j];
      else if(j - v[i] >= 0) dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
    }
  }
  int ans = 0;
  for (int i = 0; i < 100100; i++) {
      if (dp[N][i] <= W) ans = i;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 41216
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int x=scan.nextInt();
            if(x>=400&&x<600){
                out.println(8);
            }if(x>=600&&x<800){
                out.println(7);
            }if(x>=800&&x<1000){
                out.println(6);
            }if(x>=1000&&x<1200){
                out.println(5);
            }if(x>=1200&&x<1400){
                out.println(4);
            }if(x>=1400&&x<1600){
                out.println(3);
            }if(x>=1600&&x<1800){
                out.println(2);
            }if(x>=1800&&x<2000){
                out.println(1);
            }
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 32376
N = int(input())
S = input()

# print(ord('A'), ord('Z'))

def getConverseCodes(args):
    converseCodes = ''
    for s in args:
        #アスキーコードに変換
        s = ord(s)
        if s + N <= 90:
            s = s + N
        else:
            s = (s + N - 65) % 26 + 65
       #アスキーコードから文字を取得
        s = chr(s)
        converseCodes += s
    return converseCodes


print(getConverseCodes(S))


Measured memory_bytes: 3060