akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b;
cin>>a>>b;
if(a==1)a+=13;
if(b==1)b+=13;

if(a>b)cout<<"Alice"<<endl;
else if(a==b)cout<<"Draw"<<endl;
else cout<<"Bob"<<endl;
//system("pause");
return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

int par[100005];
ll rank_[100005];
void init(int n){
  for(int i=0; i<n; i++){
    par[i] = i;
    rank_[i] = 1;
  }
}

int find(int x){
  if(x==par[x]){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

ll unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x==y) return 0;
  ll tmp = rank_[x]*rank_[y];
  if(rank_[x]<rank_[y]){
    par[x]=y;
    rank_[y] += rank_[x];
    rank_[x] = rank_[y];
    return tmp;
  }else{
    par[y]=x;
    rank_[y] += rank_[x];
    rank_[x] = rank_[y];
    return tmp;
  }
}

bool same(int x, int y){
  return find(x)==find(y);
}

 
int main(){
  int n, m;
  cin >> n >> m;
  init(n);
  vector<P> G;
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G.push_back(make_pair(a,b));
  }
  vector<ll> cnt(m);
  for(int i=m-1; i>=0; i--){
    cnt[i] = unite(G[i].first, G[i].second);
  }
  cout << cnt[0] << endl;
  for(int i=1; i<m; i++){
    cnt[i] += cnt[i-1];
    cout << cnt[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 5924
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  set<string> st;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 19292
N=gets.to_i
A= gets.split.map(&:to_i)
B= gets.split.map(&:to_i)
C= gets.split.map(&:to_i)
feel=0
for i in 0..N-1 do
  if ((A[i]+1)==A[i+1]) then
    feel=feel+C[A[i]-1]
  end
  feel=feel+B[A[i]-1]
end
puts (feel)

Measured memory_bytes: 1788
#include "bits/stdc++.h"

using ll = long long;

const int MOD = 1000000007;

const int size = 1003;

const int numberOfCandies = 100005;

const int numberOfChildren = 102;

void Break()
{
#if _MSC_VER
	static int x = 0;
	++x;
	switch (x)
	{
		__debugbreak();
	}
#endif
}

int dp[numberOfCandies];

int main()
{
#if _MSC_VER
	freopen("input.txt", "r", stdin);
#endif
	std::vector<int> children(numberOfChildren);
	int n, k;
	std::cin >> n >> k;
	for (int i = 1; i <= n; ++i)
	{
		std::cin >> children[i];
	}
	dp[0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		std::vector<int> sum(k + 1);
		sum[0] = dp[0];
		for (int j = 1; j <= k; ++j)
		{
			sum[j] = (dp[j] + sum[j - 1]) % MOD;
		}
		for (int j = 0; j <= k; ++j)
		{
			if (j > children[i])
			{
				dp[j] = (sum[j] - sum[j - children[i] - 1] + MOD) % MOD;
			}
			else
			{
				dp[j] = sum[j];
			}
		}
	}
	std::cout << dp[k] << '\n';
	return 0;
}

Measured memory_bytes: 4372
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
  std::ios_base::sync_with_stdio(false);
  
  int N, K;
  std::vector<int> h;

  std::cin >> N >> K;
  h.reserve(N + 1);
  for (int _h, i = 0; i < N; ++i)
  {
    std::cin >> _h;
    h.emplace_back(_h);
  }
  std::stable_sort(h.begin(), h.end());

  auto answer = h.back();
  for (auto i = 0; i + K <= N; ++i) answer = std::min(answer, h[i + (K - 1)] - h[i]);
  std::cout << answer << std::endl;

  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>

using namespace std;

int R, S, P;

int tokuten(char t){
  if(t == 'r') return R;
  if(t == 's') return S;
  if(t == 'p') return P;
}

char kachite(char t){
  if(t == 'r') return 'p';
  if(t == 's') return 'r';
  if(t == 'p') return 's';
}

string dasute(int R, int S, int P){
  int a[] = {R, S, P};
  int m;
  string s = {"rsp"};
  char c;

  for(int i=0; i<2; i++){
    for(int j=0; j<2; j++){
      if(a[j]>a[j+1]){
        m=a[j];
        c=s[j];
        a[j]=a[j+1];
        s[j]=s[j+1];
        a[j+1]=m;
        s[j+1]=c;
      }
    }
  }

  return s;
}

int main(void){

  int N, K;
  int x = 0;
  string T;
  string te, l;

  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  l = dasute(R, S, P);
  //cout << l << endl;

  for(int i=0; i<N; i++){
    if(i<K || kachite(T[i])!=te[i-K]){
      te+=kachite(T[i]);
      x+=tokuten(te[i]);
      //cout << x << endl;
    }
    else{
      for(int j=0; j<3; j++){
        //cout << "test" << endl;
        if(l[j]!=te[i-K] && l[j]!=kachite(T[i+K])){
          te+=l[j];
          break;
        }
      }
    }
  }
  //cout << te << endl;
  cout << x << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  string s;
  cin>>s;
  int ans=0;
  if(s[0]=='1') ans++;
  if(s[1]=='1') ans++;
  if(s[2]=='1') ans++;
  cout<<ans;

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int cnt[MAXN][2],fa[MAXN],f[MAXN];
struct heapnode
{
	int x,y,id;
	bool operator < (const heapnode &a) const { return 1ll*x*a.y<1ll*y*a.x; }
};
priority_queue<heapnode> heap;
int find(int x){ return f[x]==x?f[x]:f[x]=find(f[x]); }
int main()
{
	int n=read();
	for (int i=2;i<=n;i++) fa[i]=read();
	for (int i=1;i<=n;i++) 
	{
		int x=read();
		cnt[i][x]++;
		f[i]=i;
	}
	for (int i=2;i<=n;i++) heap.push((heapnode){cnt[i][0],cnt[i][1],i});
	ll ans=0;
	while (!heap.empty())
	{
		int u=find(heap.top().id),x=heap.top().x,y=heap.top().y; heap.pop();
		if (cnt[u][0]==x&&cnt[u][1]==y)
		{
			int v=find(fa[u]);
			ans+=1ll*cnt[v][1]*cnt[u][0];
			cnt[v][0]+=cnt[u][0];
			cnt[v][1]+=cnt[u][1];
			f[u]=v;
			if (v!=1) heap.push((heapnode){cnt[v][0],cnt[v][1],v});
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11892
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long double ll;

int main(){
    ll r;
    cin >> r;
    cout << 2 * M_PI *r << endl;
}



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

int main() {
	int N, C[500], S[500], F[500];
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		cin >> C[i] >> S[i] >> F[i];
	}
	for (int i = 0; i < N; i++) {
		int t = 0;
		for (int j = i; j < N - 1; j++) {
			if (t < S[j]) t = S[j];
			else if (t % F[j] != 0) t = (t / F[j] + 1) * F[j];
			t += C[j];
		}
		cout << t << endl;
	}
}

Measured memory_bytes: 256
import numpy as np

n,m,x=map(int,input().split())
c=[]
a=[]
ans=10**8

for k in range(n):
  line=list(map(int,input().split()))
  c.append(line[0])
  a.append(line[1:])

a=np.array(a)


for i in range(2**n):
  level=np.zeros(m)
  price=0
  for j in range(n):
    if ((i>>j)&1):
      level+=a[j]
      price+=c[j]
  bottom=int(np.amin(level))
  if bottom>=x and price<ans:
    ans=price
if ans==10**8:
  print(-1)
else:
  print(ans)


Measured memory_bytes: 27164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int d,t,s;
  scanf("%d%d%d",&d,&t,&s);
  if (d <= t*s) yn;
  return 0;
}






















Measured memory_bytes: 3760
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void){
	
	int n, m, x, y, z, num;
	int k[30], a[30][30],like[30];

	num = 0;

	cin >> n >> m;

	for (x = 0; x < m; x++) {
		like[x] = 0;
	}

	for (x = 0; x < n; x++) {
		cin >> k[x];
		for (y = 0; y < k[x]; y++) {
			cin >> a[x][y];
			for (z = 0; z < m ; z++) {
				if (a[x][y] == z+1) {
					like[z]++;
	//				printf("like[%d]==%d\n",z+1,like[z]);
				}
			}
		}
	}

	for (z = 0; z < m; z++) {
		if (like[z] == n) {
			num++;
		}
	}

	cout << num << "\n";

/*	for (x = 0; x < n; x++) {
		cout << k[x]<<"  ";
		for (y = 0; y < k[x]; y++) {
			cout<< a[x][y]<<" ";
		}
		cout << "\n";
	}*/

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << 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; }

int N,x1,x2,yy,y2;
int grid[1002][1002]={};
int main(){
    cin>>N;
    rep(i,N){
        cin>>x1>>yy>>x2>>y2;
        grid[yy][x1]++;
        grid[y2][x1]--;
        grid[yy][x2]--;
        grid[y2][x2]++;
    }
    rep(i,1002){
        repi(j,1,1002){
            grid[j][i]+=grid[j-1][i];
        }
    }
    repi(i,1,1002){
        rep(j,1002){
            grid[j][i]+=grid[j][i-1];
        }
    }
    int maxi=0;
    rep(i,1001){
        rep(j,1001){
            maxi=max(maxi,grid[i][j]);
        }
    }
    out(maxi);
}



Measured memory_bytes: 7040
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int L,R;cin>>L;
    if(L==2){
        cout<<2<<" "<<2<<endl;
        cout<<1<<" "<<2<<" "<<0<<endl;
        cout<<1<<" "<<2<<" "<<1<<endl;
    }
    else{
    L--;R=L;
    int l[20];
    int i=0;
    vec v0,v1,v2;
    while(i<20){
        l[i]=L%2;
        L/=2;
        i++;
    }
    int j=19,sum=0;
    while(l[j]==0)j--;
    sum+=pow(2,j);
    int n=1,x=j-1;
    while(x>=0){
        v0.push_back(n);v1.push_back(n+1);v2.push_back(0);
        v0.push_back(n);v1.push_back(n+1);v2.push_back(pow(2,x));
        n++;x--;
    }
    j--;
    while(j>=1){
        while(l[j]==0 && j>=1)j--;
        if(j==0)break;
        v0.push_back(1);v1.push_back(n-j);v2.push_back(sum);
        sum+=pow(2,j);
        j--;
    }

    if(l[0]==0)
        v0.push_back(1);v1.push_back(n);v2.push_back(R);
    
    if(l[0]==1){
        v0.push_back(1);v1.push_back(n);v2.push_back(R-1);
        v0.push_back(1);v1.push_back(n);v2.push_back(R);
    }
    cout<<n<<" "<<v0.size()<<endl;
    for(int i=0;i<v0.size();i++)
        cout<<v0[i]<<" "<<v1[i]<<" "<<v2[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		int[] x=new int[N+1];
		for(int i=0;i<N;i++)x[i+1]=sc.nextInt();
		long count=0;
		//dp[i][j][k]:i枚目まででj枚使って合計kを作る
		long[][][]dp=new long[N+1][N+1][2501];
		
		for(int i=0;i<=N;i++){
			for(int j=0;j<=i;j++){
				for(int k=0;k<2501;k++){
					if(i==0 && j==0 && k==0)dp[i][j][k]=1;
					else if(i>=1 &&x[i]>k)dp[i][j][k]=dp[i-1][j][k];
					else if(i>=1 && j>=1 && x[i]<=k)dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
				}
			}
		}
		for(int j=1;j<=N;j++){
				count+=dp[N][j][j*A];
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 85720
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int a,b,c;
  cin>>a>>b>>c;
  //vector<int> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << c<<" "<< a<<" "<<b<< endl;
}


Measured memory_bytes: 256
a ='abcdefghijklmnopqrstuvwxyz'
s = input()
k = int(input())
sl =len(s)
nl =[(123-ord(l)) % 26 for l in s]

i = 0
while k > 0 and i < sl:
    if nl[i] !=0 and k >=nl[i]:
        k -= nl[i]
        nl[i] = 0
        i += 1
    else:
        i += 1
if k > 0:
    nl[-1] += 26- k
print(''.join([a[(26-i) % 26] for i in nl]))

Measured memory_bytes: 4980
menu_num = int(input())
order = list(map(int, input().split()))
manzoku = list(map(int, input().split()))
additional = list(map(int, input().split()))

score = int()
before_order = int()
for x in range(menu_num):
    score += manzoku[order[x]-1]
    try:
        if order[x]+1 == order[x+1]:
            score += additional[order[x]-1]
    except:
        pass

print(score)


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

ll n;

vector<int>v,w;
ll m[101][100007];

ll fun(ll i,ll b)
{
  if(i==n || b<=0)
    return 0;
   
    
  if(m[i][b]!=-1)
    return m[i][b];
    
     ll ans=fun(i+1,b);
    
    
    if(b>=w[i])
    {
       ans=max(ans,fun(i+1,b-w[i])+v[i]);   
       }
       
       return m[i][b]=ans;
       
 }




int main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  memset(m,-1,sizeof(m));
  cin>>n;
  ll b;
  cin>>b;
  w.resize(n);
  v.resize(n);
  for(ll i=0;i<n;i++)
    cin>>w[i]>>v[i];
    
    ll ans=fun(0,b);
    cout<<ans<<endl;
  
return 0;
}


Measured memory_bytes: 79232
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>

int GCD(int a, int b){
    if(!b) return a;
    return GCD(b, a%b);
}
int LCM(int a, int b){
    return a/GCD(a, b)*b;
}

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

    int a, b;
    while(std::cin >> a >> b){
        std::cout << GCD(a, b) << " " << LCM(a, b) << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
 
int main(void){
    int a, b, c, d, e;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
        e = a * b - (a * d + b * c -c * d);
    printf("%d", e);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
ll ev(ll c){
    ll a=0;
    while(c%2==0){
        c/=2;
        a++;
    }
    return a;
}


int main() {

    ll n;
    cin>>n;
    vector<ll> v;
    ll odd=0,even=0;
    rep(i,n){
        ll c;
        cin>>c;
        if(c%2==0){
          even+=ev(c);
        }else{
            odd++;
        }
    }
    if(odd==n){
        cout<<0<<endl;return 0;
    }else{
        cout<<even<<endl;


    }




    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
 
counter = 0
begin_b = []
end_a = []
begin_b_and_end_a = []
for i in range(n):
    counter += s[i].count('AB')
    if s[i][0] == 'B':
        begin_b.append(i)
    if s[i][-1] == 'A':
        end_a.append(i)
    if s[i][0] == 'B' and s[i][-1] == 'A':
        begin_b_and_end_a.append(i)
 
if len(begin_b) == len(begin_b_and_end_a) and len(begin_b_and_end_a) == len(end_a) and len(end_a) > 0:
    print(counter + min(len(begin_b), len(end_a)) - 1)
else:
    print(counter + min(len(begin_b), len(end_a)))

Measured memory_bytes: 4340
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int ans = INF;
	rep(i, 0, 26) {
		char c = 'a' + i;
		string t = s;
		bool exist = false;
		rep(j, 0, s.size())
			if (s[j] == c)
				exist = true;
		if (!exist)continue;
		while (true) {
			bool flag = true;
			rep(j, 0, t.size()) {
				if (t[j] != c)
					flag = false;
			}
			if (flag)break;
			string u = t;
			u.pop_back();
			rep(j, 1, u.size()) {
				if (u[j] == c)
					u[j - 1] = c;
			}
			t = u;
		}
		chmin(ans, (int)s.size() - (int)t.size());
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    int[] W = new int[n+1];
    int[] E = new int[n+1];

    for (int i = 0; i < n; i++) {
      if (i >= 1) W[i+1] = W[i];
      if (c[i] == 'W') W[i+1]++;
    }

    for (int i = 0; i < n; i++) {
      if (i >= 1) E[i+1] = E[i];
      if (c[i] == 'E') E[i+1]++;
    }

    int min = 300000;

    for (int i = 0; i < n; i++) {
      int gap = W[i]+(E[n]-E[i+1]);
      if (gap < min) min = gap;
    }

    System.out.println(min);

  }

}


Measured memory_bytes: 32956
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, m;
    cin >> n >> m;
    int ans = n * (n - 1) / 2;
    ans += m * (m - 1) / 2;
    cout << ans << endl;
}

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

#define ll long long
#define sc(n) int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define scArr(n) int n; scanf("%d", &n); int a[n]; for(int i=0; i<n; i++) scanf("%d", &a[i]);
#define pi acos(-1)

int main()
{
    ll n, a, b;
    cin>>n>>a>>b;
    if(a+b==0) cout<<"0";
    else cout<<(a*(n/(a+b)))+ min(n%(a+b), a);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define ll long long
//#define ull unsigned long long
const int maxm=3e5+5;
pair<int,int>p[maxm];
int r[maxm],c[maxm];
int n,m,k;
signed main(){
    ios::sync_with_stdio(0);
    cin>>n>>m>>k;
    for(int i=1;i<=k;i++){
        int x,y;cin>>x>>y;
        p[i]={x,y};
        r[x]++,c[y]++;
    }
    int ma1=-1;
    for(int i=1;i<=n;i++)ma1=max(ma1,r[i]);
    int num1=0;
    for(int i=1;i<=n;i++)num1+=(r[i]==ma1);
    int ma2=-1;
    for(int i=1;i<=m;i++)ma2=max(ma2,c[i]);
    int num2=0;
    for(int i=1;i<=m;i++)num2+=(c[i]==ma2);
    int cnt=0;
    for(int i=1;i<=k;i++){
        int x=p[i].first,y=p[i].second;
        cnt+=(r[x]==ma1&&c[y]==ma2);
    }
    cout<<ma1+ma2-(cnt==num1*num2)<<endl;
    return 0;
}
/*
令r[i]为第i行的点数和,
令c[i]为第i列的点数和.
显然答案一定是从最大行和最大列中选一个配对.
需要判断交点处是否被标记.


*/


Measured memory_bytes: 13032
#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 ALL(v) (v).begin(),(v).end()
#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;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
//---------------------------------//

int N;
ll a[212345];
ll sum[212345];

int main() {
	cin >> N;
	REP(i, N) scanf("%lld", a + i);
	
	ll s = 0;
	REP(i, N) s += a[i];
	REP(i, N) sum[i] += a[i];
	FOR(i, 1, N) sum[i] += sum[i - 1];
	
	ll ans = 1ll<<60;
	REP(i, N - 1) {
		ll A = sum[i];
		ll B = s - sum[i];
		chmin(ans, abs(A - B));
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {

	static HashMap<Integer, ArrayList<Integer>> map;
	static boolean[] reached;

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

		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();

		int before = x;
		for(int i=1; i<=10; i++) {
			before = r*before-D;
			System.out.println(before);
		}
	}

	public static void println(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 21716
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int a[2][101];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }
  int res = 0;
  for(int i = 0; i < n; i++){
    int tmp = 0;
    for(int j = 0; j <= i; j++)tmp += a[0][j];
    for(int j = i; j < n; j++)tmp += a[1][j];
    res = max(res, tmp);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;
    for (ll i = 0; i < S.size(); i++) {
        if (i % 2 == 0 && S[i] == 'L'
         || i % 2 == 1 && S[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5;
const int mod=998244353;
bool check[N];
int prime[N];
int mu[N];
void mo(){
    memset(check,false,sizeof check);
    mu[1]=1;int tot=0;
    for(int i=2;i<N;++i){
        if(!check[i]){
            prime[tot++]=i;
            mu[i]=-1;
        }
        for(int j=0;j<tot;++j){
            if(i*prime[j]>=N) break;
            check[i*prime[j]]=true;
            if(i%prime[j]==0){
                mu[i*prime[j]]==0;
                break;
            }else{
                mu[i*prime[j]]=-mu[i];
            }
        }
    }
}
ll quick_pow(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
int a[N];
int pre[N];
ll sol(ll x){
    ll anx=0;
    /*if(x<1e6){
        if(pre[x]) return pre[x];
    }*/
    for(int i=x;i<=(1e6);i+=x){
        anx+=1ll*(i/x)*a[i];
        anx%=mod;
    }
    //if(x<1e6) return pre[x]=anx*anx%mod;
    return anx*anx%mod;
}
int main(){
    mo();
    ll inv2=quick_pow(2,mod-2);
    int n;scanf("%d",&n);
    int x;
    ll sum=0;
    memset(a,0,sizeof a);
    for(int i=1;i<=n;++i){
        scanf("%d",&x);
        a[x]++;sum+=x;
    }
    int NN=1000000;
    ll anx=0;
    //cout<<"cic\n";
    for(int i=1;i<=NN;++i){
        ll tmp=0;
        for(int j=1;j<=NN/i;++j){
            //if(mu[j])
            tmp=tmp+1ll*mu[j]*j*j%mod*sol(1ll*i*j)%mod;
            tmp%=mod;
        }
        anx=anx+1ll*i*tmp%mod;anx%=mod;
    }
    anx=(anx-sum)%mod*inv2%mod;if(anx<0) anx+=mod;
    printf("%lld\n",anx);
}

Measured memory_bytes: 12800
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  vector<vector<int>> c(3, vector<int> (3));
  rep(i,3) rep(j,3) cin >> c[i][j];
  vector<int> a(3), b(3);

  a[0] = 0;
  rep(i,3) b[i] = c[0][i];
  a[1] = c[1][1] - c[0][1];
  a[2] = c[2][1] - c[0][1];

  bool flag = true;
  rep(i,3) {
    rep(j,3) {
      if(c[i][j] != a[i]+b[j]) flag = false;
    }
  }

  YesorNo(flag);
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    sa = sum(a)
    f = [x for x in a if x * 4 * m >= sa]
    print("Yes" if len(f) >= m else "No")

if __name__ == "__main__":
    main()


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

int main(){
    int N;
    long long K;
    cin >> N >> K;
    int a[N], b[N];
    long long c[100010]={};
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
        c[a[i]] += b[i];
    }
    int ans = 0;
    for(int i = 1; i <100010; i++){
        K -= c[i];
        if(K <= 0 ){
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    ll count = 0;
    char prev;
    cin >> S;
    prev = S.front();
    iter(c, S) {
        if(prev != c) count++;
        prev = c;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 512
/*
AtCoder Library Practice Contest - B - Fenwick Tree
https://atcoder.jp/contests/practice2/tasks/practice2_b
*/

#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


void solve() {

}

int main()
{
    FAST_INP;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
    // #endif

//    int tc; cin >> tc;
//    TC(tc) solve();
	ll n, q, a, x, y, z;
	cin >> n >> q;
	fenwick_tree<ll> bit(n);
	REP(i,n){
		cin >> a;
		bit.add(i,a);
	}
	REP(i,q){
		cin >> x >> y >> z;
		if(x==0) bit.add(y,z);
		else OUT(bit.sum(y,z));
	}

    return 0;
}


Measured memory_bytes: 8236
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1e9
typedef pair<int, int> pii;
 
struct Point{
    int x,y;
};
 
int cnt[5];
int dp[5][1002];
Point cr[5][1002];
 
int getMD(const Point &p1, const Point &p2){
    return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}
 
int main()
{
    int H, W;
    while (cin >> W >> H, W) {
	char in;    
	int sx, sy, gx, gy;
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < H; i++) {
	    for (int j = 0; j < W; j++) {
		cin >> in;
		if (in == 'S') {
		    sx = j; sy = i;
		} else if (in == 'G') {
		    gx = j; gy = i;
		} else if (isdigit(in)) {
		    int n = in-'1';
		    cr[n][cnt[n]++] = (Point){j, i};
		}
	    }
	}
	for (int i = 0; i < 5; i++) { 
	    cr[i][cnt[i]++] = (Point){sx, sy};
	}
	int res = INF, num = -1;
	for (int i = 0; i < 5; i++) {
	    for (int j = 0; j < 5; j++) {
		for (int k = 0; k < cnt[j]; k++) {
		    dp[j][k] = INF;
		}
	    }
	    dp[i][cnt[i]-1] = 0;
	    int nj = i, j = (i+1) % 5, ej = (i > 0 ? i-1 : 4);
	    while (true) {
		int m = nj == i ? 0 : 1;
		for (int k = 0; k < cnt[nj]-m; k++) {
		    if (dp[nj][k] == INF) continue;
		    for (int l = 0; l < cnt[j]-m; l++) {
			dp[j][l] = min(dp[j][l], dp[nj][k]+getMD(cr[nj][k], cr[j][l]));
		    }
		}
		if (j == ej) {
		    for (int k = 0; k < cnt[j]; k++) {
			int d = dp[j][k] + getMD(cr[j][k], (Point){gx, gy});
			if (d < res) {
			    res = d;
			    num = i+1;
			}
		    }
		    break;
		}
		nj++; nj %= 5;
		j++; j %= 5;
	    }
	}
	if (res == INF) {
	    cout << "NA" << endl;
	} else {
	    cout << num << " " << res << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3148
main :: IO ()
main = do
  (pr, sf) <- splitAt 2 <$> getLine :: IO (String, String)
  putStrLn $ case (pr `elem` months, sf `elem` months) of
    (True, True) -> "AMBIGUOUS"
    (True, False) -> "MMYY"
    (False, True) -> "YYMM"
    (False, False) -> "NA"

months :: [String]
months = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]


Measured memory_bytes: 380
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from bisect import bisect

a,b,q=nii()
s=[-10**18]+[int(input()) for i in range(a)]+[10**18]
t=[-10**18]+[int(input()) for i in range(b)]+[10**18]

for i in range(q):
  x=int(input())
  s_inx=bisect(s,x)
  t_inx=bisect(t,x)

  s_l=s[s_inx-1]
  s_r=s[s_inx]

  t_l=t[t_inx-1]
  t_r=t[t_inx]

  ans=10**18
  for i in [s_l,s_r]:
    for j in [t_l,t_r]:
      ans=min(ans,abs(i-x)+abs(j-i))

  for i in [t_l,t_r]:
    for j in [s_l,s_r]:
      ans=min(ans,abs(i-x)+abs(j-i))

  print(ans)

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

const ll logx=30;
const ll N=2e5+5;
const ll M=3e5+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll x=(b/c)-((a-1)/c);
  ll y=(b/d)-((a-1)/d);
  ll lcm=LCM(c,d);
  ll z=(b/lcm)-((a-1)/lcm);
  ll divi=x+y-z;
  ll ans=(b-a+1)-divi;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
    int N; cin >> N;
    unordered_map<string, int> Map;
    for (int i = 0; i < N; ++i) {
        string s; cin >> s;
        Map[s]++;
    }
    cout << "AC x " << Map["AC"] << endl;
    cout << "WA x " << Map["WA"] << endl;
    cout << "TLE x " << Map["TLE"] << endl;
    cout << "RE x " << Map["RE"] << endl;
}


Measured memory_bytes: 3544
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int a, b, c, d, N, M, x, y;
	string s, t;

	cin >> N;

	cout << (N%1000==0 ?0: 1000 - (N%1000)) << endl;
	return 0;
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	s := input()
	cnt1 := 0
	cnt2 := 0
	black := "0"
	white := "1"
	for i := 0; i < len(s); i++ {
		color := s[i : i+1]
		if i%2 == 0 {
			if color == black {
				cnt1++
			} else {
				cnt2++
			}
		} else {
			if color == white {
				cnt1++
			} else {
				cnt2++
			}
		}
	}

	fmt.Println(min(cnt1, cnt2))
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

ll mmul(int x, int y)
{
	ll m = (ll)x * (ll)y;
	m %= MOD_P;
	return m;
}



int main()
{
	int n;
	cin >> n;
	ll ans = 0LL;
	queue<int>que;
	ll sum = 0LL;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		sum += (ll)tmp;
		sum %= MOD_P;
		que.push(tmp);

	}

	while (!que.empty()) {
		int x = que.front();
		que.pop();
		sum -= (ll)x;
		//printf("%d * %lld = %lld->%lld\n", x, sum, (ll)x * sum, ((ll)x * sum) % MOD_P);
		if (sum < 0) {
			sum += MOD_P;
		}
		ans += mmul(x, sum);
		ans %= MOD_P;
	}

	printf("%lld", ans);

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

string s;
ll a,b;

int main(){
  cin >> s;
  a = (s[0]-'0')*10 + s[1]-'0';
  b = (s[2]-'0')*10 + s[3]-'0';
  cerr << a << " " << b << endl;
  if(a > 0 && a <= 12 && b > 0 && b <= 12) cout << "AMBIGUOUS" << endl;
  else if(a > 0 && a <= 12) cout << "MMYY" << endl;
  else if(b > 0 && b <= 12) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        x: u32,
        y: u32,
    }

    let mut f: bool = false;
    for i in 0..x+1 {
        if i * 2 + (x - i) * 4 == y {
            f = true;
            break;
        }
    }
    println!("{}", if f { "Yes" } else { "No" })
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	int n; cin >> n;
	string s; cin >> s;
	vector<int> a(n);
	for(int i=0; i<n; i++) a[i] = s[i]-'1';

	vector<int> p2(n);
	for(int i=2; i<n; i*=2){
		for(int j=1; i*j<n; j++){
			p2[i*j]++;
		}
	}
	vector<int> fact_n2(n);
	for(int i=2; i<n; i++) fact_n2[i] = fact_n2[i-1]+p2[i];

	int n2 = 0;
	for(int i=0; i<n; i++){
		n2 += (a[i]%2)*(fact_n2[n-1]-fact_n2[i]-fact_n2[n-i-1]==0?1:0);
		dbg(i, fact_n2[n-1]-fact_n2[i]-fact_n2[n-i-1]);
	}
	dbg(n2);

	if(n2%2){
		cout << 1 << endl;
		return 0;
	}

	bool b1=false;
	for(int i=0; i<n; i++){
		if(a[i]==1) b1 = true;
	}

	if(b1){
		cout << 0 << endl;
		return 0;
	}

	int m2 = 0;
	for(int i=0; i<n; i++){
		m2 += (a[i]/2)*(fact_n2[n-1]-fact_n2[i]-fact_n2[n-i-1]==0?1:0);
	}

	if(m2%2){
		cout << 2 << endl;
	} else {
		cout << 0 << endl;
	}

	return 0;
}


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

int main(){
 int n,m;
 cin>>n>>m;
 int a[100][100];
for(int i=0;i<n;i++)
 for(int j=0;j<m;j++)cin>>a[i][j];

 int b[100];
 for(int i=0;i<m;i++) cin>>b[i];
 int c[100]={};
 for(int i=0;i<n;i++)
  for(int j=0;j<m;j++) c[i]+=a[i][j]*b[j];
 for(int i=0;i<n;i++) cout<<c[i]<<endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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 Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n, k;
	cin >> n >> k;
	V a(n);
	int M = 0;
	rep(i, n) {
		cin >> a[i];
		chmax(M, a[i]);
	}
	int GCD = a[0];
	rep1(i, n - 1) {
		GCD = gcd(GCD, a[i]); // GCDをとるという発想はあるべきだった
	}
	if (M < k || k % GCD) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << "POSSIBLE" << endl;
	}
	return 0;
}

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

int d[201];

int main() {
    int n,k,t,u,v,l;
    cin>>n>>k>>t>>u>>v>>l;
    for(int i=0; i<n; ++i) cin>>d[i];
    d[n] = l;

    double rem = 0.0,ans = 0.0;
    int now = 0,carrot = 0;

    for(int i=0; i<=n; ++i) {
        double diff = d[i] - now;
        while(diff > 0) {
            if(rem == 0) {
                if(carrot > 0) {
                    carrot--;
                    rem += t;
                }else {
                    ans += (double)diff/u;
                    diff = 0;
                }
            }else{
                if(rem*v >= diff) {
                    ans += (double)diff/v;
                    rem -= (double)diff/v;
                    diff = 0;
                }else{
                    ans += rem;
                    diff -= rem*v;
                    rem = 0;
                }
            }
        }

        if(carrot == k) {
            rem = t;
        }else carrot++;
        now = d[i];
    }

    printf("%.12f\n", ans);
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
	long long a,b;
	char s;
	scanf("%lld %c %lld",&a,&s,&b);
	long long ans;
	if(s=='+')	ans = a+b;
	else if(s=='-')	ans = a-b;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128