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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n;
  ll _k;
  cin >> n >> _k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  map<int, vector<int>> mp;
  rep(i, n) mp[a[i]].push_back(i);
  
  mint in_n = 0, out_n = 0, k = _k;
  rep(i, n) {
    for(auto x : mp) {
      if(x.first >= a[i]) break;

      in_n += (int)distance(upper_bound(ALL(mp[x.first]), i), mp[x.first].end());
      out_n += (int)x.second.size();
    }
  }

  mint ans = -k*(k+1)/2;
  ans *= out_n;
  ans += (in_n + out_n*k)*k;
  cout << ans.x << endl;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;constexpr int32 INF=1<<30;constexpr ll INFLL=1LL<<62;
#define all(x) x.begin(),x.end()
#define LB(V,x) lower_bound(all(V),x)-V.begin()
#define uint uint32
void Main(){
    int A, B, C;
    cin >> A >> B >> C;
    int S = (A+B+C)/2;
    cout << pow(S*(S-A)*(S-B)*(S-C),0.5) << endl;
}
int main(){cin.tie(0);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,a,i;
    long min,max,sum=0;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&a);
        if(i==0) min=max=a;
        if(a<min) min=a;
        if(a>max) max=a;
        sum+=a;
    }
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2104
/*
  AOJ 0280
  Title:The Outcome of Bonze
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int N;
char c;
int p[10],ba;

int compare(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

main()
{
        int i,f;

        while(EOF!=scanf("%d ",&N) && N)
        {
                //printf("N=%d\n",N);

                ba=0;
                memset(p,0,10*sizeof(int));

                for(i=0;i<100;i++)
                {
                        scanf("%c",&c);
                        if(c=='M')
                                p[i % N]++;
                        else if(c=='S')
                        {       
                                ba+=(p[i % N]+1);
                                p[i % N]=0;
                        }
                        else if(c=='L')
                        {
                                p[i % N]+=(ba+1);
                                ba=0;
                        }
                }
                f=0;
                qsort(p,N,sizeof(int),compare);
                for(i=0;i<N;i++)
                {
                        if(f)
                                printf(" ");
                        f=1;
                        printf("%d",p[i]);
                }
                printf(" %d\n",ba);
        }
                return(0);
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,M;
  cin>>N>>M;
  int A[N][M];
  rep(i,N) rep(j,M) cin>>A[i][j];
  int ans=N;
  rep(i,M){
    VI cnt(M);
    rep(j,N){
      rep(k,M){
        if(A[j][k]){
          cnt[A[j][k]-1]++;
          break;
        }
      }
    }
    int tmp=0;
    int tmp2=0;
    rep(j,M){
      if(tmp<cnt[j]){
        tmp=cnt[j];
        tmp2=j;
      }
    }
    rep(j,N) rep(k,M) if(A[j][k]==tmp2+1) A[j][k]=0;
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <stack>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	string s;
	stack<int> st;
	while(cin>>s)
	{
	if(s=="+")
	{
		int x = st.top();st.pop();
		int y = st.top();st.pop();
		st.push(x+y);
	}
	else if(s=="-")
	{
		int x = st.top();st.pop();
		int y = st.top();st.pop();
		st.push(y-x);
	}
	else if(s=="*")
	{
		int x = st.top();st.pop();
		int y = st.top();st.pop();
		st.push(x*y);
	}
	else
	{
		int num = 0;
		sscanf(s.c_str(), "%d", &num);
		st.push(num);
	}
	}
	printf("%d\n",st.top());
	
	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;

int color[100000];

int revC(int i){
    if(i == 0){
        return 1;
    }
    else{
        return 0;
    }
}

void dfs(int node, vector<vector<pair<int, int>>>& E){
    for(auto e: E[node]){
        int nextNode = e.first;
        int cost = e.second;
        int nextColor = color[nextNode];
        if(nextColor != -1){
            continue;
        }
        if(cost % 2 == 0){
            color[nextNode] = color[node];
            dfs(nextNode, E);
        }
        else{
            color[nextNode] = revC(color[node]);
            dfs(nextNode, E);
        }
    }
}

int main(){

    int N;
    cin >> N;
    vector<vector<pair<int, int>>> E(N);

    int u, v, w;
    for(int i = 0; i < N - 1; i++){
        cin >> u >> v >> w;
        E[u - 1].push_back(make_pair(v - 1, w));
        E[v - 1].push_back(make_pair(u - 1, w));
    }

    memset(color, -1, sizeof(color));

    color[0] = 0;
    dfs(0, E);
    for(int i = 0; i < N; i++){
        cout << color[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  int mx = 0, sum = 0;
  rep(i, n){
    int in;
    cin >> in;
    sum += in;
    mx = max(mx, in);
  }
  if(mx < sum-mx) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<stack>
#include<set>
#include<queue>

using namespace std;

int main() {
	queue<pair<string, int> >v;
	int N, Q, T;
	string s;
	cin >> N >> Q;
	for (; N--;)cin >> s >> T, v.push(make_pair(s, T));
	for (T = 0; !v.empty();) {
		pair<string, int>p = v.front(); v.pop();
		if (p.second > Q)T += Q, p.second -= Q, v.push(p);
		else T += p.second, cout << p.first << " " << T << endl;
	}
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int dp[101010];

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[0]-h[1]);
  //rep(i,n) cout << h[i] << endl;
  rep(i,n){
    if(i==0) i+=2;
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  //rep(i,n-1) cout << dp[i] << endl;
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
N, M = gets.split.map(&:to_i)
X = gets.split.map(&:to_i).sort

r = []
X.each_cons(2) do |a, b|
  r << b - a
end 

if X.size <= N
  puts 0
else
  puts X.last - X.first - r.sort.reverse.take(N - 1).inject(0, :+)
end

Measured memory_bytes: 11248
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder(sc.nextLine());
		String p = sc.nextLine();
		sb.append(sb);
		String str = sb.toString();
		System.out.println(str.contains(p) ? "Yes" : "No");
	}
}


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

using namespace std;

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

int main(void){
    int H, W;
    vector <string> s;
    string sub;
    bool judge = true;
    
    cin >> H >> W;
    
    for(int i = 0; i < H; i++){
        cin >> sub;
        s.push_back(sub);
    }
    
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            
            if(s[i][j] == '#'){
                judge = false;
                
                for(int k = 0; k < 4; k++){
                    // cout << i << " " << j << " " << k << endl;
                    
                    if(i + dx[k] >= 0 && j + dy[k] >= 0 && i + dx[k] < H && j + dy[k] < W){
                        if(s[i + dx[k]][j + dy[k]] == '#'){
                            judge = true;
                            // cout << k << endl;
                            break;
                        }
                    }
                }
            }
            
            if(!judge){
                break;
            }
        }
        
        if(!judge){
            break;
        }
    }
    
    if(judge){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

map<int,int> m1;
vector<int> v1[110000];
vector<P> path[110000];
int ps[220000];
int dd[110000];
int col[110000];
bool used[110000];

bool check(int pos,int num,int c){
	if(used[pos])return true;
	col[pos]=c;
	used[pos]=true;
	bool flag=false;
	for(auto to:path[pos]){
		if(dd[to.first]==num && !used[to.first]){
			flag=true;
			ps[to.second]=num;
			check(to.first,num,1-c);
		}
	}
	return flag;
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0,j=0;i<n;i++){
		cin>>a;
		if(m1.find(a)==m1.end())m1[a]=j++;
		v1[m1[a]].push_back(i);
		dd[i]=a;
	}
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(make_pair(b,i));
		path[b].push_back(make_pair(a,i));
		ps[i]=1e9;
	}
	memset(col,-1,sizeof(col));
	bool flag=false,fflag=false;
	for(auto itr:m1){
		a=itr.second;
		for(auto node:v1[a]){
			//cout<<node<<endl;
			flag=false,fflag=false;
			if(col[node]==-1)col[node]=0;
			flag=check(node,itr.first,col[node]);
			if(flag)continue;
			for(auto to:path[node]){
				if(dd[to.first]<itr.first){
					col[node]=col[to.first];
					ps[to.second]=itr.first-dd[to.first];
					flag=true;
					break;
				}
			}
			if(!flag){
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	for(i=0;i<n;i++){
		if(col[i]==1)cout<<'W';
		else cout<<'B';
	}
	cout<<endl;
	for(i=0;i<m;i++){
		cout<<ps[i]<<endl;
	}
}

Measured memory_bytes: 22016
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())

typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef pair <ll, ll> pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;

const int N = 100010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;

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

void write(int x){
     if (x < 0) putchar('-'), x = - x ;
     if (x > 9) write(x / 10) ;
     putchar(x % 10 + '0') ;
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void PRINT(string x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

int n, m, Q ;
int ans[N], mx[N], a[N], b[N], c[N] ;
vector <int> e[N] ;

void dfs(int now) {
	if (!ans[now]) ans[now] = c[Q] ;
	for (int i = 0; i < SZ(e[now]); i++) {
		int to = e[now][i] ;
		if (mx[now] - 1 > mx[to]) mx[to] = mx[now] - 1, dfs(to) ;
	}
}

signed main(){
	ass(mx, -1) ;
	scanf("%d%d", &n, &m) ;
	for (int i = 1; i <= m; i++) {
		int a, b ;
		scanf("%d%d", &a, &b) ;
		e[a].pb(b) ;
		e[b].pb(a) ;
	}
	scanf("%d", &Q) ;
	for (int i = 1; i <= Q; i++) scanf("%d%d%d", &a[i], &b[i], &c[i]) ;
	for (; Q; Q--)
		if (b[Q] > mx[a[Q]]) mx[a[Q]] = b[Q], dfs(a[Q]) ;
	for (int i = 1; i <= n; i++) printf("%d\n", ans[i]) ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.实数精度有没有处理？
	3.特殊情况处理好了么？
	4.做一些总比不做好。
思考提醒：
	1.最大值和最小值问题可不可以用二分答案？
	2.有没有贪心策略？否则能不能dp？
*/


Measured memory_bytes: 8440
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define F first
#define S second


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double x,k,d;
    cin>>x>>k>>d;
    ll y = k;
    if(y%2 != 0)
    {
    	long double r = (k+1)/2;
    	long double l = (-1)*(r-1);
    	long double temp = l;
    	long double mid;
    	while(l < r)
    	{
    		mid = floor((l+r)/2);
    		if((2*mid-1)*d+x >= 0)
    		{
    			r = mid;
    		}
    		else
    		{
    			l = mid+1;
    		}
    	}
    	if(l == temp)
    	{
    		cout<<(ll)abs(x+(2*l-1)*d)<<endl;
    	}
    	else
    	{
    		cout<<(ll)min(abs(x+(2*l-1)*d),abs(x+(2*l-3)*d))<<endl;
    	}
    }
    else
    {
    	long double r = k/2;
    	long double l = (-1)*r;
    	long double temp = l,mid;
    	while(l < r)
    	{
    		mid = floor(((l+r)/2));
    		if(2*mid*d+x >= 0)
    		{
    			r = mid;
    		}
    		else
    		{
    			l = mid+1;
    		}
    	}
    	if(l == temp)
    	{
    		cout<<(ll)abs(x+2*l*d)<<endl;
    	}
    	else
    	{
    		cout<<(ll)min(abs(x+2*l*d),abs(x+(2*l-2)*d))<<endl;
    	}
    }
}


Measured memory_bytes: 3744
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;
 
#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);
 
int n, k;
int a[100100];
 
int gcd(int p, int q) {
    if (q == 0) return p;
    return gcd(q, p%q);
}
 
bool solve() {
    sort(a, a+n);
    if (n == 1) return a[0] == k;
    if (a[n-1] < k) return false;
    int g = a[0];
    for (int i = 1; i < n; i++) g = gcd(g, a[i]);
    return k % g == 0;
}
 
void input() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
 
    input();
    cout << (solve()?"POSSIBLE":"IMPOSSIBLE") << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <deque>

using namespace std;

int main(int argc, char const *argv[])
{
	int a,b,c,x;

	cin >> a;
	cin >> b;
	cin >> c;
	cin >> x;

	int res = 0;

	for (int i = 0; i <= a; ++i)
	{
		for (int j = 0; j <= b; ++j)
		{
			for (int k = 0; k <= c; ++k)
			{
				if(500*i+100*j+50*k == x) res++;
			}
		}
	}

	cout << res << "\n";

	return 0;
}

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

char t[10][10];

void rotate(void){
	char tmp[10][10];
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			tmp[j][7-i] = t[i][j];
		}
	}

	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			t[i][j] = tmp[i][j];
		}
	}
}

int main(void){
	for(int i=0;i<8;i++){
		cin>>t[i];
	}

	for(int i=1;i<=3;i++){
		rotate();
		cout<<i*90<<endl;
		for(int j=0;j<8;j++){
			cout<<t[j]<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d",&a,&b);
	c=a%1000;
	if(c==500)printf("Yes\n");
	if(c>500){
		if(c-500>b)printf("No\n");
		else printf("Yes\n");
	}
	if(c<500){
		if(c>b)printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll N,M,K;
  cin >> N >> M >> K;
  vector<ll> A(N+1);
  vector<ll> B(M+1);
  ll a = 0,b = 0;
  rep(i,N + 1){
    if(i == 0){
      A.at(i) = 0;
      continue;
    }
    ll p;
    cin >> p;
    a += p;
    A.at(i) = a; 
  }
  rep(i,M + 1){
    if(i == 0){
      B.at(i) = 0;
      continue;
    }
    ll q;
    cin >> q;
    b += q;
    B.at(i) = b;
  }
  ll ans = 0;
  ll best = M;
  rep(i,N + 1){
    ll lim = K - A.at(i);
    if(lim < 0){
      break;
    }
    for(ll j = best; j >= 0; j--){
      if(B.at(j) > lim){
        continue;
      }
      best = j;
      ans = max(ans,i + j);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define MAX 20000005
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll vis[MAX], cycle[MAX];
map<ll, ll>ttime;
map<ll, ll>inverstime;

void solve(){
	ll n, k;
	cin >> n >> k;
	
	ll v[n+1];
	
	for(int i=1; i<=n; i++) cin >> v[i];
	
	ll j=1, t=0;
	while(vis[j] == 0){
		ttime[t] = j;
		inverstime[j] = t;
		vis[j] = 1;
		j = v[j];
		t++;
	}	
	
	if(k < t){
		cout << ttime[k] << endl;
		return;		
	}
	
	ll init = j, d = t-inverstime[j];
	cycle[0] = init;
	j = v[init];
	
	for(int i=1;;i++){
		if(j == init) break;
		cycle[i] = j;
		j = v[j];
	}
	
	k -= t-d;
		
	cout << cycle[k%d] << endl;
}

int main(){

	fastcin
	solve();      
	return 0;
}
	

Measured memory_bytes: 31400
from itertools import accumulate
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))[::-1]

a1=list(accumulate(a1))
a2=list(accumulate(a2))[::-1]

MAX=0
for i in range(n):
    MAX=max(a1[i]+a2[i],MAX)
print(MAX)

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	string str;
	cin >> str;
	cout << str[0] << str.size() - 2 << str.back() << "\n";
}

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


Measured memory_bytes: 256
s = str(input())
n = len(s)
cur = s[0]
cnt = 0
L = []
for i in range(n):
    if s[i] != cur:
        L.append(cnt)
        cur = s[i]
        cnt = 1
    else:
        cnt += 1
else:
    L.append(cnt)
#print(L)
print(len(L)-1)


Measured memory_bytes: 45168
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

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

    for (int i = n; i < 100000; ++i) {
        string s = to_string(i);
        int count = 0;
        for (int j = 0; j < k; ++j) {
            for (char l : s) {
                if(l == d[j])count++;
            }
        }
        if(count > 0)continue;
        else{
            print(s);
            break;
        }
    }
}

Measured memory_bytes: 256
c = [[i for i in map(int,input().split())] for j in range(3)]
for i in range(101):
    para = [0]*6
    para[0] = i 
    para[3] = c[0][0] - para[0]
    para[4] = c[0][1] - para[0]
    para[5] = c[0][2] - para[0]
    para[1] = c[1][0] - para[3]
    para[2] = c[2][0] - para[3]
    if c[1][1] == para[1]+para[4] and c[1][2] == para[1] + para[5]:
        if c[2][1] == para[2] + para[4] and c[2][2] == para[2] + para[5]:
            print("Yes") 
            exit()
print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin>>n;
  ll b[n];
  vector<ll> a;
  for(int i=0;i<n;i++){
    cin>>b[i];
    if(i!=0){
      if(b[i]==b[i-1]) continue;
    }
    a.push_back(b[i]);
  }
  vector<bool> bo(200010,false);
  vector<ll> t(200010);
  ll dp[a.size()];
  dp[0]=1;
  bo[a[0]]=true;
  t[a[0]]=0;
  for(int i=1;i<a.size();i++){
    if(!bo[a[i]]){
      dp[i]=dp[i-1];
      bo[a[i]]=true;
    }else{
      dp[i]=dp[t[a[i]]]+dp[i-1];
      dp[i]%=1000000007;
    }
    t[a[i]]=i;
  }
  cout<<dp[a.size()-1];
}

Measured memory_bytes: 6640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

int solve(string s){
	set<string> st;
	rep(i,s.size()-1){
		string a[4];
		rep(j,2)a[j] = s.substr(0,i+1);
		rep(j,2)a[2+j] = s.substr(i+1,(int)s.size()-(i+1));
		reverse(all(a[1]));
		reverse(all(a[3]));
		
		rep(j,4){
			rep(k,4){
				if((k<2&&j<2) || (k>=2&&j>=2))continue;
				st.insert(a[k]+a[j]);
			}
		}
	}
	return st.size();
}

int main(){
	int n;
	cin>>n;
	
	rep(i,n){
		string s;
		cin>>s;
		
		cout<<solve(s)<<endl;
		
	}
}

Measured memory_bytes: 3228
#!/usr/bin/env python3
from itertools import permutations

def solve(n,a):
    def dist(a1,a2):
        d2 = (a1[0]-a2[0])**2 + (a1[1]-a2[1])**2
        return d2 ** (1/2)
    
    l = []
    p_list = permutations(range(n))
    cnt = 0
    for p in p_list:
        s = 0
        for i in range(n-1):
            s += dist(a[p[i+1]],a[p[i]])
        l.append(s)
        cnt += 1
    return sum(l)/cnt


def main():
    N = int(input())
    a = [list(map(int,input().split())) for _ in range(N)]
    print(solve(N,a))
    return

if __name__ == '__main__':
    main()


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

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

takeEven :: [Int] -> Int -> Int
takeEven as 0 = 0
takeEven (a0 : a1 : as) n = a1 + takeEven as (n -1)

main = do
  n <- getInt
  as <- getIntList
  let alen = length as
  let al = alen `div` 3
  let as' = sortOn Down as
  print $ takeEven as' al


Measured memory_bytes: 72220
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}


// -100 -10 -3 0 2 9 17
// INF   90  7 3 2 7 8
// x      x          x

// int arr[100010][3];

bool cmp1(vi& a, vi& b) {
  return a[0] < b[0];
}
bool cmp2(vi& a, vi& b) {
  return a[1] > b[1];
}
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  if(n >= m) {
    cout << "0\n";
    return 0;
  }
  vector< vector<int> > arr(m, vi(3));
  fi(0, m) {
    cin >> arr[i][0];
  }
  sort(all(arr), cmp1);
  arr[0][1] = INF;
  fi(1, m) {
    arr[i][1] = arr[i][0] - arr[i - 1][0];
  }
  sort(all(arr), cmp2);
  fi(0, n) {
    arr[i][2] = 1;
  }
  sort(all(arr), cmp1);
  // fi(0, m) {
  //   fj(0, 3) {
  //     cout << arr[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  fi(0, m) {
    if(!arr[i][2])
      ans += arr[i][1];
  }
  cout << ans << endl;
  return 0;
}



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

#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

ld solve(int i,int countH,vector <ld>& p,vector <vector <ld> >& dp){
	if(dp[i][countH]!=-1) return dp[i][countH];
	int n = (int)p.size();
	if(i==n){
		/*if(n==1){
			if(countH==1) return ans;
			else return 0;
			} */
		if(countH>n/2) return 1.0;
		else return 0.0;
	}
	dp[i][countH]=solve(i+1,countH+1,p,dp)*p[i]+solve(i+1,countH,p,dp)*(1-p[i]);
	return dp[i][countH];
}
int main(){
	int n;
	cin>>n;
	vector <ld> p (n);
	for(int i=0;i<n;i++) cin>>p[i];
	vector <vector <ld> > dp (n+1,vector <ld> (n+1,-1));
	cout<<setprecision(10)<<solve(0,0,p,dp)<<"\n";
	return 0;
}


Measured memory_bytes: 141312
// F - LCS
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

#define MAX 3000
int dp[MAX+1][MAX+1]; // Sのs文字目まで、Tのt文字目までのLCSの長さ

int main(){
	string S,T; cin>>S>>T;
	int N = S.size(), M = T.size();
	S = "*" + S; T = "*" + T; // 1 index に補正

	rp(s, 1, N+1) // s:[1,N]
		rp(t, 1, M+1){ // t:[1,M]
			// S[s]を使いT[t]を使わず, T[t]を使いS[s]を使わず いずれか長い方
			dp[s][t] = max(dp[s][t-1], dp[s-1][t]);
			if(S[s] == T[t])
				// S[s], T[t] が同じ文字なら、LCSを伸ばせるので、
				// S[s], T[t] ともに使わないときのLCSの長さに +1
				dp[s][t] = max(dp[s][t], dp[s-1][t-1] + 1);
		}
	// LCS の長さから、LCSの文字列を復元
	string ans;
	while(N>0 && M>0){
		// S[N] を使わないときの長さと同じなら、S[N] は使っていない
		if(dp[N][M] == dp[N-1][M]) N--;
		// T[M] を使わないときの長さと同じなら、T[M] は使っていない
		else if(dp[N][M] == dp[N][M-1]) M--;
		// どれでもないなら、S[N],T[M]が同じで、
		// ともに使っていない状態から、長さを伸ばしたはずなので、使っている
		else{ ans += S[N]; N--; M--; }
	}
	reverse(ans.begin(), ans.end()); // 逆順に作ったので反転
	cout<< ans <<endl;
}


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

int inf = 1e5;
int calc(string S, string T){
    int res = 0;
    int n = S.size(),m = T.size();
    if(n<m){
        for(int i=0;i<m-n;i++){
            if(T.substr(i,n)==S) return inf;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(n-i<=m && S.substr(i,n-i)==T.substr(0,n-i)) res = n-i;
    }
    return res;
}
int main(){
    int N;
    while(cin >> N && N){
        vector<string> S(N);
        vector<int> use(N,0);
        vector<vector<int>> cost(N,vector<int>(N,0)),dp(1<<N,vector<int>(N,0));
        int goal = (1<<N)-1;
        int sum = 0;
        for(int i=0;i<N;i++){
            cin >> S[i];
            sum += S[i].size();
        }
        for(int i=0;i<N;i++) for(int j=0;j<N;j++){
            if(i!=j){
                cost[i][j] = -calc(S[i],S[j]);
                if(cost[i][j]==-inf){
                    use[i] = 1;
                    goal &= ~(1<<i);
                }
            }
        }
        for(int i=0;i<N;i++) if(use[i]) sum -= S[i].size();
        for(int S=0;S<(1<<N);S++){
            for(int i=0;i<N;i++) for(int j=0;j<N;j++){
                if(use[i] || use[j]) continue;
                if(S==0){
                    dp[(1<<i)][i] = 0;
                    continue;
                }
                if(!(S&(1<<i))) continue;
                if(S&(1<<j)) continue;
                int T = S|(1<<j);
                dp[T][j] = min(dp[T][j],dp[S][i]+cost[i][j]);
            }
        }
//        cerr << sum << endl;
//        for(int i=0;i<N;i++) for(int j=0;j<N;j++) cerr << cost[i][j] << (j!=N-1? " ":"\n");
        int ans = 0;
        for(int i=0;i<N;i++) ans = min(ans,dp[goal][i]);
        cout << sum+ans << endl;
    }
}


Measured memory_bytes: 4580
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
typedef  long long  ll;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
int n,m,x,y,num[maxn],ans;
bool is[maxn];
int main() {
    is[1] = 1;
    scanf("%d %d",&n,&m);
    for (int i=1; i<=n; i++) num[i] = 1;
    for (int i=0; i<m; i++) {
        scanf("%d %d",&x,&y);
        //printf("%d %d: %d %d\n",x,y,num[x],num[y]);
        if (is[x]) {
            if (num[x] == 1) {
                is[x] = 0;
            }
            is[y] = 1;
        }
        num[x]--;
        num[y]++;
        //printf("%d %d: %d %d\n",x,y,num[x],num[y]);
    }
    for (int i=1; i<=n; i++) if (is[i])
        ans++;
    printf("%d\n", ans);
    return 0;
}

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

int main() {
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
  return 0;
}



Measured memory_bytes: 3544
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))





n,m=input2()
sc_list=[]
for _ in range(m):
	sc_list.append(input_array())

result=0
flag=True
result_dict={}
for sc in sc_list:
	sc0=sc[0]
	sc1=sc[1]
	if n!=1 and sc0==1 and sc1==0:
		#2桁以上かつ先頭が0である
		flag=False
		break
	elif sc0 in result_dict:
		if result_dict[sc0]==sc1:
			#既に入力済である場合
			continue
		else:
			#数字の衝突
			flag=False
			break
	else:
		result+=10**(n-sc0)*sc1
		result_dict[sc0]=sc1

if len(str(result))<n:
	result+=10**(n-1)

if flag:
	print(result)
else:
	print(-1)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){	
			final int N = sc.nextInt();
			
			final int SIZE = 10000000;
			boolean[] isPrime = new boolean[SIZE + 1];
			Arrays.fill(isPrime, true);
			
			isPrime[0] = isPrime[1] = false;
			for(int i = 2; i <= SIZE; i++) {
				if(!isPrime[i]) { continue; }
				
				for(int j = 2 * i; j <= SIZE; j += i) {
					isPrime[j] = false;
				}
			}
			
			for(int i = N; ; i++) {
				if(!isPrime[i]) { continue; }
				
				System.out.println(i);
				break;
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	ll X, K, D; cin >> X >> K >> D;
	ll ans;
	if(K % 2 == 0) {
		if(X > 0) {
			ll n = ceil((double)X / (double)D);
			if(n % 2 != 0) n++;
			if(n > K) ans = X - K * D;
			else ans = min(-(X - n * D), X - (n - 2) * D);
		}
		else if(X < 0) {
			ll n = ceil((-1.0) * (double)X / (double)D);
			if(n % 2 != 0) n++;
			if(n > K) ans = -(X + K * D);
			else ans = min(X + n * D, -(X + (n - 2) * D));
		}
		else ans = 0;
	}
	else {
		if(X > 0) {
			ll n = ceil((double)X / (double)D);
			if(n % 2 == 0) n++;
			if(n > K) ans = X - K * D;
			else ans = min(-(X - n * D), X - (n - 2) * D);
		}
		else if(X < 0) {
			ll n = ceil((-1.0) * (double)X / (double)D);
			if(n % 2 == 0) n++;
			if(n > K) ans = -(X + K * D);
			else ans = min(X + n * D, abs(X + (n - 2) * D));
		}
		else ans = D;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
 
long long s[100000];
long long t[100000];
long long x[100000];
 
int binary_search(long long a[] , int src,int dst,long long key){
  int ok=0;
  int ng=dst;
  while(ng-ok>1){
    int middle=(ok+ng)/2;
    if(a[middle]<=key){
      ok=middle;
    }else{
      ng=middle;
    }
  }
  return ok;
}
 
int main(){
  
  int A,B,Q;
  std::cin>>A>>B>>Q;
  for(int i=0;i<A;++i){
    std::cin>>s[i];
  }
  for(int i=0;i<B;++i){
    std::cin>>t[i];
  }
 
  for(int i=0;i<Q;++i){
    long long ans=999999999999999999LL;
    std::cin>>x[i];
    int u=binary_search(s,0,A,x[i]);
    int v=binary_search(t,0,B,x[i]);
    for(int j=std::max(0,u-10);j<std::min(A,u+10);++j){
      for(int k=std::max(0,v-10);k<std::min(B,v+10);++k){
	ans=std::min(ans,std::abs(x[i]-s[j])+std::abs(s[j]-t[k]));
	ans=std::min(ans,std::abs(x[i]-t[k])+std::abs(t[k]-s[j]));
      }
    }
    std::cout<<ans<<std::endl;
    
 
  }
  
 
  return 0;
}

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

int main(){
    int n,k;cin>>n>>k;

    vector<double> p(n);
    for(int i = 0; i < n; i++){
        double t; cin>>t;
        p[i] = (t+1)/2.0;
    }
    for(int i = 1; i < n; i++){
        p[i]+=p[i-1];
    }
    double ans = 0;
    double prev = 0;
    for(int i = k-1; i < n ;i++){
        ans = max(ans,p[i]-prev);
        prev = p[i-(k-1)];
    }
    cout<<fixed<<setprecision(12)<<ans;
    
}


Measured memory_bytes: 1792
import java.util.*;
 
class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    long[] H = new long[N];
    for(int i=0; i<N; i++){
      H[i]=sc.nextLong();
    }
    long l = 0;
    Arrays.sort(H);
    for(int i=0; i<N-K; i++){
      l += H[i];
    }
    System.out.println(l);
  }
}
    

Measured memory_bytes: 61788
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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;
}

class UnionFind {
  public:
    // 親の番号を格納する。親の場合 -1 になる
    vector<int> Parent;

    // 宣言されたとき Parent の値はすべて -1 にする
    UnionFind(int N) { Parent = vector<int>(N, -1); }

    // 与えられた値 x がどの親であるか調べる
    int root(int x) {
        if (Parent[x] < 0)
            return x;
        return Parent[x] = root(Parent[x]);
    }

    // 木の全体の数を返す
    int size(int x) { return -Parent[root(x)]; }

    // 2つの引数を同じ親にする
    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (size(x) < size(y))
            swap(x, y);
        Parent[x] += Parent[y];
        Parent[y] = x;
        return true;
    }

    // 引数の親が同じか判定する
    bool is_same(int x, int y) { return root(x) == root(y); }
};

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

    int N, Q;
    cin >> N >> Q;
    auto uni = UnionFind(N);
    REP(i, Q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            uni.merge(x, y);
        } else {
            std::cout << uni.is_same(x, y) << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

int main ()
{
    string str;
    map<string,int> m;
    m["A"] = 0;
    m["B"] = 0;
    m["AB"] = 0;
    m["O"] = 0;
    while (cin >> str) {
        for (int i = 0; i < str.size(); i++) {
            if (str[i] == ',') {
                str[i] = ' ';
            }
        }
        stringstream ss;
        int num;
        string s;
        ss << str;
        ss >> num >> s;
        m[s]++;
    }
    cout << m["A"] << endl;
    cout << m["B"]  << endl;
    cout << m["AB"] << endl;
    cout << m["O"] << endl;

    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    
    int count=0;
    if(a>=b){
        count=a;
        a--;
    }
    else{
        count=b;
        b--;
    }

    if(a>=b){
        count+=a;
        a--;
    }
    else{
        count+=b;
        b--;
    }
    cout << count << endl;
    return 0;
}

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

int main(){
	int n,m,l;
	long long A[100][100],B[100][100],C[100][100];

	cin >> n >> m >> l;
	for(int i = 0; i < n ; i++)
		for(int j = 0; j < m ; j++)cin >> A[i][j];
	for(int i = 0; i < m ; i++)
		for(int j = 0; j < l ; j++)cin >> B[i][j];

	for( int i = 0; i < n; i++){
		for( int j = 0; j < l; j++){
			C[i][j] = 0;
			for( int k = 0; k < m; k++){
				C[i][j] += A[i][k]*B[k][j];
			}
		}
	}

	for(int i = 0; i < n; i++){
		for( int j = 0; j < l; j++){
			if( j )cout << " ";
			cout << C[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3292
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    std::vector<std::vector<int>> a(3, std::vector<int>(3));
    int N;
    scan(a);
    scan(N);
    vector<int> b(N);
    scan(b);

    for (auto &&i : a) {
        for (auto &&j : i) {
            for (auto &&k : b) {
                if (j == k) {
                    j = INF32;
                }
            }
        }
    }
    auto yes = []() {
        print("Yes");
        exit(0);
    };

    for (size_t i = 0; i < 3; i++) {
        if (a[i][0] == INF32 && a[i][1] == INF32 && a[i][2] == INF32) {
            yes();
        }
        if (a[0][i] == INF32 && a[1][i] == INF32 && a[2][i] == INF32) {
            yes();
        }
    }
    if (a[0][0] == INF32 && a[1][1] == INF32 && a[2][2] == INF32) {
        yes();
    }
    if (a[0][2] == INF32 && a[1][1] == INF32 && a[2][0] == INF32) {
        yes();
    }
    print("No");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a;
  cin >> a;
  int tmp;
  REP(i,10){
    if(i == 0){continue;}
    tmp = i*111;
    if(tmp >= a){
      cout << tmp << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long s, x, y, c, d, t;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	c = 1e9;
	x = c;
	y = (s + c - 1) / c;
	d = x * y - s;
	t = c - d;
	cout << t << " " << 0 << " " << 0 << " " << y - 1 << " " << c << " " << y << E;
	//system("pause");
	return 0;
}

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

int main()
{
	//freopen("1.in","r",stdin);
	int x,y;
	cin>>x>>y;
	int ans=abs(x)-abs(y);
	if(ans<0)
	{
		ans=-ans;
		if(x<0){++ans;x=-x;}
		x=abs(y);
	}
	else
	if(ans>0)
	{
		if(x>0){++ans;x=-x;}
		x=-abs(y);
	}
	ans+=x!=y;
	cout<<ans;
}

Measured memory_bytes: 256