akhauriyash/Code-Regression huggingface dataset:
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, x;
  cin >> n >> x;

  if (n == 2) {
    if (x == 2) {
      cout << "Yes\n";
      rep(i, 3) cout << i + 1 << '\n';
    }
    else cout << "No\n";
    return 0;
  }
  if (x == 1 || x == 2 * n - 1) {
    cout << "No\n";
    return 0;
  }
  vector<int> a(2 * n - 1, 0);
  vector<bool> used(2 * n, false);
  a[n - 1] = x;
  used[x] = true;
  if (x == 2) {
    a[n - 2] = 1;
    a[n - 3] = 3;
    a[n] = 4;
    used[1] = true, used[3] = true, used[4] = true;
  }
  else {
    a[n - 2] = 2 * n - 1;
    a[n - 3] = 1;
    a[n] = 2;
    used[1] = true, used[2] = true, used[2 * n - 1] = true;
  }
  int res = 1;
  rep(i, 2 * n - 1) {
    if (a[i]) continue;
    while (used[res]) res++;
    a[i] = res;
    used[res] = true;
  }
  cout << "Yes\n";
  rep(i, 2 * n - 1) cout << a[i] << '\n';



  
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

ll N, Ans = 0;


ll F(ll N, ll a, ll p){
 
  if(a == 0)return 1;
 
  if(a%2 == 0 && a != 0)return (F(N, a/2, p)*F(N, a/2, p))%p;
 
  if(a%2 == 1)return N*F(N, a - 1, p)%p;
 
}

int main(){
cin >> N;
  
  Ans = F(10, N, PP) - 2*F(9, N, PP) + F(8, N, PP);
  
  if(Ans < 0)Ans += PP*2;
  
  Ans %= PP;

cout << Ans;

}

Measured memory_bytes: 3584
#include <iostream>
#include <numeric>

using namespace std;
long long int gcd(long long int x,long long int y){
    if(x > y){return gcd(y,x);}  
    if(x == 0){return y;}
    return gcd(y%x,x);
}
int main(){
    long long int a,b,c,d, x,y, z;
    cin >> a >> b >> c >> d;
    if(c == 1 || d == 1){ 
        cout << 0 << endl;
        return 0;
    }
    long long int lcm {c * d/gcd(c,d)};
    x = b/c - (a-1)/c;
    y = b/d - (a-1)/d;
    z = b/lcm - (a-1)/lcm;
    cout << b - a + 1 - (x + y - z) << endl;
    return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
// #define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 2e5 + 10;
const ll MOD = 1e9 + 7;

int n;
vector <int> adl[N];
pair<ll, ll> dp[N]; // chance, count
pair<ll, ll> prop[N];
ll ans[N];

ll perm[N];

ll fpow(ll a, ll b){
    if (b == 0) return 1;
    ll temp = fpow(a, b / 2);
    temp = temp * temp % MOD;
    if (b & 1) temp = temp * a % MOD;
    return temp;
}

ll inv(ll a){
    return fpow(a, MOD - 2);
}

void dfs1(int node, int p){
    dp[node] = mp(1, 1);

    vector <ll> v;
    ll tot = 0;
    for (auto x : adl[node]){
        if (x == p) continue;
        dfs1(x, node);
        dp[node].fi = dp[node].fi * dp[x].fi % MOD;
        dp[node].se += dp[x].se;
        v.pb(dp[x].se);
        tot += dp[x].se;
    }
    ll temp = perm[tot];
    for (auto x : v){
        temp = temp * inv(perm[x]) % MOD;
    }
    dp[node].fi = dp[node].fi * temp % MOD;
}

void dfs(int node, int p){
    ans[node] = 1;
    vector <ll> v;
    ll tot = 0;

    if (node != p){
        prop[p] = mp(ans[p] * inv(dp[node].fi) % MOD , (n - dp[node].se) % MOD);
        prop[p].fi = ((prop[p].fi * inv(perm[n - 1]) % MOD) * perm[n - 1 - dp[node].se] % MOD) * perm[dp[node].se] % MOD;
    } else{
        prop[node].fi = 1;
        prop[node].se = n - dp[node].se + 1LL;
    }
    for (auto x : adl[node]){
        if (x == p){
            ans[node] = ans[node] * prop[x].fi % MOD;
            tot += prop[x].se;
            v.pb(prop[x].se);
        } else{
            ans[node] = ans[node] * dp[x].fi % MOD;
            tot += dp[x].se;
            v.pb(dp[x].se);
        }
    }
    ll temp = perm[tot];
    for (auto x : v){
        temp = temp * inv(perm[x]) % MOD;
    }
    ans[node] = ans[node] * temp % MOD;

    for (auto x : adl[node]){
        if (x != p) dfs(x, node);
    }
}

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

    cin >> n;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adl[a].pb(b);
        adl[b].pb(a);
    }

    perm[0] = 1;
    for (ll i=1;i<=n;i++){
        perm[i] = perm[i - 1] * i % MOD;
    }

    dfs1(1, 1);
    dfs(1, 1);

    for (int i=1;i<=n;i++){
        cout << ans[i] << el;
    }

    return 0;
}

Measured memory_bytes: 25556
n = int(input())
s = []
r = []
sr = []
for i in range(n):
    s, r = map(str, input().split())
    sr.append([i+1, s, int(r)])
# print(sr)
sr1 = sorted(sr, key=lambda x:x[2], reverse=True)

ans = sorted(sr1, key=lambda x:x[1])

for i in range(n):
    print(ans[i][0])

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

using namespace std;
typedef long long ll;

int read() {
  int res = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) res = res * 10 + c - '0', c = getchar();
  return res;
}

const int maxn = 2e5 + 5;
char s[maxn];

int main() {
  int n = read(), k = read();
  scanf("%s", s + 1);
  if (k > (n << 1)) k -= n << 1, k &= 1, k += n << 1;
  int p = 1, A = 'A';
  while (k--) {
    if (s[p] == A)
      s[p] = 'A' + 'B' - s[p];
    else {
      A = 'A' + 'B' - A, ++p;
      if (p > n) p = 1;
    }
  }
  for (int i = p; i <= n; i++) putchar("BA"[s[i] == A]);
  for (int i = 1; i < p; i++) putchar("BA"[s[i] == A]);
  puts("");
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

int check(int x, int l, int r)
{
    int sum = 0;
    int val = x;
    while(x > 0)
    {
        sum += (x % 10);
        x /= 10;
    }
    
    if(l <= sum  && sum <= r)
    {
        return val;
    }
    return 0;
}

void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    int res = 0;
    for(int i = 1; i <= n; i++)
    {
        res += check(i, l, r);
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

const int mod = 1000000007;

long long b[5001];
long long dp[5001][5001];

int main() {
    int n, m, i, j;
    
    scanf("%d %d", &n, &m);
    
    b[0] = 1;
    for (i = 1; i <= m; i++) b[i] = b[i - 1] * 2 % mod;
    
    for (i = 0; i <= m; i++) dp[0][i] = 1;
    
    for (i = 0; i < n; i++) {
        long long sum = 0;
        
        for (j = 0; j <= m; j++) {
            dp[i + 1][j] = (dp[i][j] * (j + 1) + sum) % mod;
            
            sum *= 2;
            sum += dp[i][j] * j;
            sum %= mod;
        }
    }
    
    printf("%lld\n", dp[n][m] % mod);
    
    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end()
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

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

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            C();
        }

        static void C()
        {
            var N = ReadInt();
            var ok = true;
            for (int i = 0; i < N; i++)
            {
                var txy = ReadSplitInt();
                var t = txy[0];
                var x = txy[1];
                var y = txy[2];
                if (t < (x+y) || !((t % 2 == 0 && (x + y) % 2 == 0) ||
                    (t % 2 != 0 && (x + y) % 2 != 0)))
                {
                    ok = false;
                }

            }
            Println(ok ? "Yes" : "No");
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 15408
#include<cstdio>
int n,a,b,c,d,t=-1;
char s[200100];
int main()
{
	scanf("%d%d%d%d%d%s",&n,&a,&b,&c,&d,s+1);
	s[0]=s[n+1]='#';
	for(int i=a;i<c;i++)
		if(s[i+1]=='#'&&s[i]=='#')
		{
			puts("No");
			return 0;
		}
	for(int i=b;i<d;i++)
		if(s[i+1]=='#'&&s[i]=='#')
		{
			puts("No");
			return 0;
		}
	if(c>d)
	{
		for(int i=b;i<=d;i++)
			if(s[i-1]=='.'&&s[i+1]=='.'&&s[i]=='.')
			{
				puts("Yes");
				return 0;
			}
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}



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

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

    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else if(s=="ARC") cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int main(){
int n;
  cin>>n;
  vector<int> a(n);
  vector<vector<pair<int,int>>> b(0);

  int x,y;
  rep(i,n){
      vector<pair<int,int>> c(0);
     cin>>a.at(i);
    rep(j,a.at(i)){
       cin>>x>>y;
      c.push_back(make_pair(x,y));
    }
    b.push_back(c);
  }
  
 
  int ans=0;
  int cnt;
  int tftf=0;
  bool bol;
  //cout<<b.at(1).at(0).second<<endl;
  for (int tmp = 0; tmp < (1 <<n); tmp++) {
    bitset<15> tf(tmp);
 
    //cout<<tf<<endl;
    rep(i,n){
       if(!tf.test(i)) continue;
     // else cout<<1<<endl;
      rep(j,a.at(i)){
        bol =(b.at(i).at(j).second==1);
        x= b.at(i).at(j).first;
        
      if((bol && tf.test(x-1)) || (!bol && !tf.test(x-1))) continue;
        else
      {tftf=1; break;}//goto SKIP;
      }//repj
    }//repi
    if(tftf==0){cnt = tf.count();
               // if(cnt>0) cout<<tf<<endl;          cout<<tf<<endl;
    ans=max(cnt,ans);}
    tftf =0;
    //SKIP:
  }//reptmp
  cout<<ans;
}//main


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int W= sc.nextInt();
    int H= sc.nextInt();
    int x= sc.nextInt();
    int y= sc.nextInt();
    int r= sc.nextInt();

    if((x + r)> W){
       System.out.println("No");
    }else if((x-r)<0){
      System.out.println("No");
    }else if((y+r)>H){
      System.out.println("No");
    }else if((y-r)<0){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }

    

  }
}



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

int main(){
    int n;
    long long d;
    cin>>n>>d;
    d = pow(d,2);
    int ans=0;
    for(int i=0; i<n; ++i){
        double x,y;
        cin>>x>>y;
        double temp = pow(x,2)+pow(y,2);
        if(temp<=d) ++ans;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3764
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long n,m;
	long long ans=1;
	scanf("%lld%lld",&n,&m);
	if(m<n)
	{
		printf("0");
		return 0;
	}
	else if(m%n==0)
	{
		printf("%lld",m/n);
		return 0;
	}
	else 
	{
		for(long long i=1;i<=m;i++)
		{
			if(m%i==0&&m/i>=n)
			ans=i;
			if(m<n*i)
			break;
		}
		printf("%lld",ans);
	}
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
using namespace std;
const int mod=1e9+7;
const int MAX=1e7+7;
 ll a[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);
    ll n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	for(int j=i;j<=n;j+=i)
    	{
    		a[j]++;
		}
	}
    for(int i=1;i<=n;i++)
    {
    	ans+=i*a[i];
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 81736
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const ll INF = 1e15;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



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

    ll res=INF;
    if(A%2==0 || B%2==0 || C%2==0)cout<<0<<endl;
    else{
        cout<<min({B*C, C*A, A*B})<<endl;
    }

    return 0;
}

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

string airport_code(string s) {
    string ret = "";
    ret += s[0];
    for (int i = 1; i < s.size(); i++) {
        for (auto c : "aiueo") {
            if (s[i - 1] == c) ret += s[i];
        }
    }
    return ret;
}

bool check_duplicate(vector<string> &codes, int k) {
    set<string> s;
    for (auto code : codes) {
        if (code.size() < k)
            s.insert(code);
        else
            s.insert(code.substr(0, k));
    }
    return (s.size() == codes.size());
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<string> acode(n);
        int max_len = -1e9;
        for (int i = 0; i < n; i++) {
            string s; cin >> s;
            acode[i] = airport_code(s);
            max_len = max(max_len, (int)acode[i].size());

        }

        if (!check_duplicate(acode, max_len)){
            cout << -1 << endl;
            continue;
        }
        for (int i = 1; i <= max_len; i++) {
            if (check_duplicate(acode, i)) {
                cout << i << endl;
                break;
            }
        }
    }
}



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

int main() {
  string a, b; cin >>a >>b;
  string ans;
  string more = "GREATER";
  string less = "LESS";
  string same = "EQUAL";
  if (a.size() > b.size()) ans = more;
  else if (a.size() < b.size()) ans = less;
  else if (a>b) ans = more;
  else if (a<b) ans = less;
  else ans = same;
  
  cout <<ans <<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W;
char C[303][303];
int cost[303][603];
const int OFS = 300;

int dp[303][303];
int waf[303][303];

int solve(int c)
{
	for (int i = H; i >= 0; --i) {
		for (int j = H; j >= 0; --j) {
			waf[i][j] = waf[i + 1][j + 1];
			if (i < H && j < H) {
				if (C[H - i - 1][c] == C[H - j - 1][c + 1]) ++waf[i][j];
			}
		}
	}
	for (int i = 0; i <= H; ++i) {
		for (int j = 0; j <= H; ++j) {
			if (i == 0 && j == 0) {
				dp[i][j] = 0;
				continue;
			}
			int best = MOD - 1;
			if (i > 0) {
				best = min(best, dp[i - 1][j] + waf[i - 1][j]);
			}
			if (j > 0) {
				best = min(best, dp[i][j - 1] + waf[i][j - 1]);
			}
			dp[i][j] = best;
		}
	}
	return dp[H][H];
}

int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) scanf("%s", C[i]);

	int ret = 0;
	for (int i = 0; i < W - 1; ++i) {
		ret += solve(i);
	}
	printf("%d\n", ret);

	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int s[15] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1};

void disp(int a, int b){
	for(int i = a+1;;i++){
		cout << " " << s[i%15];
		if(s[i%15] == b){cout << endl;break;}
	}
}

int main(){
	int n, a, b;cin >> n;
	while(n--){
		cin >> a >> b;cout << a;
		if(6 <= a && a <= 9)disp(a, b);
		else disp(0 < b-a ? a : 15-a, b);
	}
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N;
    cin>>N;
    vector<int> X(N);
    for(int i=0;i<N;i++)cin>>X.at(i);
    int ans=1000000;
    for(int i=1;i<=100;i++){
        int sum=0;
        for(int j=0;j<X.size();j++)sum+=(i-X.at(j))*(i-X.at(j));
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
typedef pair<ll, ll> edge;
//typedef tuple<ll, ll, ll> tp;
const ll INF = 1e18;
const ll mod = 1e9+7;

int main() {
  ll a, b, q;
  cin >> a >> b >> q;
  ll A[a+2];
  A[0] = 0;
  A[a+1] = INF;
  for(int i=1;i<a+1;i++) cin >> A[i];
  ll B[b];
  B[0] = 0;
  B[b+1] = INF;
  for(int i=1;i<b+1;i++) cin >> B[i];
  ll Q[q];
  for(int i=0;i<q;i++) cin >> Q[i];
  
  for(int i=0;i<q;i++){
    ll key = Q[i];
    auto it_a = lower_bound(A, A+a+2, key);
    ll idx_a = distance(A, it_a);
    auto it_b = lower_bound(B, B+b+2, key);
    ll idx_b = distance(B, it_b);
    //cout << idx_a << idx_b << endl;
    
    ll ans = INF;
    for(int i=0;i<=1;i++){
      for(int j=0;j<=1;j++){
        if(A[idx_a-i] == 0 || A[idx_a-i] == INF) continue;
        if(B[idx_b-j] == 0 || B[idx_b-j] == INF) continue;
        
        ll da = abs(A[idx_a-i] - key);
        ll db = abs(B[idx_b-j] - key);
        ll bet = abs(A[idx_a-i] - B[idx_b-j]);
        ans = min(ans, da+bet);
        ans = min(ans, db+bet);
        
      }
    }
    
    cout << ans << endl;
  }

}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    int A;
    cin>>A;

    if(A<1200){
        cout<<"ABC"<<endl;
    }
    else{
        cout<<"ARC"<<endl;
    }
}

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

int main() {

  int H,W;
  cin >> H >> W;

  string S[H];
  int K[H][W];
  
  for(int i=0;i<H;i++){
    cin >> S[i];
  }
  
  
  int l=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S[i][j]=='.'){
        int count = 0;
        for(int k=max(i-1,0);k<=min(i+1,H-1);k++){
          for(int m=max(j-1,0);m<=min(j+1,W-1);m++){
            if(S[k][m]=='#')
              count++;
          }          
        }
        K[i][j]=count;
      }   
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S[i][j]=='.')
	      cout << K[i][j];
      else
          cout << S[i][j];
    }
    cout << endl;
  }
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	int k;
	vector<int> T;
	int b;
	cin >> k;
	for (int i = 0; i < k; i++) {
		cin >> b;
		T.push_back(b);
	}

	for (int i = 0; i < (1 << n); i++) {
		vector<int> v;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j))	v.push_back(j);
		}

		int check = 1;
		for (auto it = T.begin(); it != T.end(); it++) {
			auto itr = find(v.begin(), v.end(), *it);
			if (itr == v.end()) {
				check = 0;
				break;
			}
		}

		if (check) {
			cout << i << ":";
			for (int l = 0; l < v.size(); l++) {
				cout << " " << v[l];
			}
			cout << endl;
		}
	}
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int n=s.size();
  Int ans=n;
  for(Int k=0;k<2;k++){
    Int res=0;
    for(Int i=0;i<n;i++)
      if(((i+k)&1)!=s[i]-'0') res++;
    
    chmin(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string number to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, d; cin >> n >> d;
    d = d * d;
    ll ans = 0;
    rep(i, n){
        ll x, y; cin >> x >> y;
        if(x*x + y*y <= d){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int K, S; cin >> K >> S;
	int ans = 0;
	rep(i, 0, K + 1) {
		rep(j, 0, K + 1) {
			int xy = i + j;
			if (S - xy >= 0 && S - xy <= K)++ans;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int size = sc.nextInt();

    int[] elements = new int[size];
    for (int i = 0; i < size; i++) {
      elements[i] = sc.nextInt();
    }

    int searchSize = sc.nextInt();
    int[] searches = new int[searchSize];
    for (int i = 0; i < searchSize; i++) {
      searches[i] = sc.nextInt();
    }

    search(elements, searches);
  }

  public static void search(int[] elements, int[] searches) {
    int count = 0;
    for (int search : searches) {
      for (int elem : elements) {
        if (elem == search) {
          count++;
          break;
        }
      }
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 40392
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 998244353;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

int main(){

  int w = in();
  int a = in();
  int b = in();
  if(a > b){
    swap(a, b);
  }

  int ans = 0;
  if(b > a + w){
    ans = b - (a + w);
  }
  cout << ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
/*
17/10/2017
*/
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
ll ans=0;
ll sm=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
sm=(sm+a[i])%mod;
}
for(int i=0;i<n;i++)
{
sm=(sm-a[i]+mod)%mod;
ans=(ans+(sm*a[i])%mod)%mod;
}
cout<<ans;
}


Measured memory_bytes: 4400
<?php
  $n = trim(fgets(STDIN));
  $h = explode(' ',trim(fgets(STDIN))) ;
$dp[0] = 0 ;
for($i=1;$i<$n;++$i){
	$dp[$i] = 100000000000 ;
}
for($i=1;$i<$n;++$i){
	if($i>1){
 			 $list = [$dp[$i],$dp[$i-1]+abs($h[$i]-$h[$i-1]),$dp[$i-2]+abs($h[$i]-$h[$i-2])];   
  	}else{
   		  $list = [$dp[$i],$dp[$i-1]+abs($h[$i]-$h[$i-1])] ;
} 
    $dp[$i] = min($list) ;
}
echo $dp[$n-1] ;

Measured memory_bytes: 18932
# N = gets.chomp.to_i
N,K = gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

p.sort!
s = 0
0.upto(K-1).each do |i|
  s += p[i]
end
p s



Measured memory_bytes: 14304
n = gets.chomp("").to_i
s = gets.chomp("")

alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
h = alpha.chars

a = s.chars

ans = Array.new
a.each do |i|
  if 25 < (h.index(i) + n)
    ans << alpha[h.index(i) + n - 26]
  else
      ans << alpha[h.index(i) + n]
  end
end

puts ans.join


Measured memory_bytes: 2684
import std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm, std.typecons;

void main(){
    auto buf = readln().strip().split().map!(to!int)();
    immutable K = buf[0];
    immutable A = buf[1];
    immutable B = buf[2];

    if(B - A <= 2 || K <= A - 1) {
        writeln(K + 1);
        return;
    }

    long t = cast(long)K - A + 1;
    if(t % 2 == 0) {
        writeln(A + (B-A) * (t/2));
    } else {
        writeln(A + (B-A) * (t/2) + 1);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll i, j, k, l, m, n;
	string a, b;
	cin>>a>>b;
	m = a.size(), n = b.size();
	vector<vector<ll>> v(m+1,vector<ll>(n+1,0));
	for(i=1; i<=m; i++)
	{
	    for(j=1; j<=n; j++)
	    {
	        if(a[i-1] == b[j-1]) v[i][j] = v[i-1][j-1] + 1;
	        else v[i][j] = max(v[i-1][j],v[i][j-1]);
	    }
	}
	string s = "";
	for(i=0,k=m,l=n; i<v[m][n]; i++)
	{
	    if(a[k-1] == b[l-1]) 
	    {
	        s += a[k-1];
	        k -= 1; l -= 1;
	    }
	    else
	    {
	        if(v[k-1][l] >= v[k][l-1]) k-=1;
	        else l-=1;
	        --i;
	    }
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 70784
let N = Int(readLine()!)!
let AN = readLine()!.split(separator: " ").compactMap { Int($0) }

var money = 1000
for i in 0..<N-1 {
    if AN[i] < AN[i+1] {
        money += Int(money/AN[i])*(AN[i+1]-AN[i])
    }
}
print(money)


Measured memory_bytes: 8244
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;

int main() {
	int a;
	while (cin >> a, a) {
		int n[105], m[105], l[2][105], s[2][105], k[2] = { 1,0 };
		memset(s, -1, sizeof(s));
		for (int b = 0; b < a; b++)cin >> n[b];
		for (int b = 0; b < a; b++)cin >> m[b];
		int xMAX = 0, yMAX = 0;
		for (int i = 0; i < a; i++) {
			switch (n[i]) {
			case 2: l[0][i] = xMAX; break;
			default: xMAX = i; break;
			}
			switch (m[i]) {
			case 2: l[1][i] = yMAX; break;
			default: yMAX = i; break;
			}
		}
		xMAX = yMAX = a + 5;
		for (int i = a - 1; i >= 0; i--) {
			switch (n[i]) {
			case 0: l[0][i] = i; break;
			case 1: if (n[i + 1] != 1)xMAX = i;
				l[0][i] = xMAX;
			}
			switch (m[i]) {
			case 0: l[1][i] = i; break;
			case 1:
				if (m[i + 1] != 1)yMAX = i;
				l[1][i] = yMAX;
			}
		}
		queue<P>Q;
		Q.push(P(0, l[0][0]));
		Q.push(P(1, l[1][0]));
		s[0][l[0][0]] = s[1][l[1][0]] = 0;
		while (Q.size()) {
			P o = Q.front(); Q.pop();
			if (o.second >= a - 1) { cout << s[o.first][o.second] << endl; goto m; }
			for (int i = 0; i <= 2; i++) {
				if (o.second + i < a&&s[k[o.first]][l[k[o.first]][o.second + i]] == -1) {
					s[k[o.first]][l[k[o.first]][o.second + i]] = s[o.first][o.second] + 1;
					Q.push(P(k[o.first], l[k[o.first]][o.second + i]));
				}
			}
		}
		puts("NA");
	m:;
	}
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int dp[3][2020];

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

    string s;
    cin>>s;
    ll ans = 0;
    dp[0][s[0] - '0'] = 1;
    rep(i,1,s.size()){
        int dig = s[i] - '0';
        rep(j,2020)dp[i%3][j] = 0;
        dp[i%3][dig]++;
        rep(j,2019){
            dp[i%3][(dig + j * 10) % 2019] += dp[(i-1)%3][j];
            if((dig + j * 10) % 2019 == 0)ans+= dp[(i-1)%3][j];
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<map>
#include<string>
using namespace std;

int main()
{
	map<string , int> cpp;
	string str, v;
	int n, com, q;
	cin >> q;

	while (q--)
	{
		cin >> com >> str;

		switch (com)
		{
		case 0:
			cin >> n;
			cpp[str] = n;
			break;
		case 1:
			cout << cpp[str] << endl;  
			break;
		case 2:
			cpp[str]=0;
			break;
		case 3:
			cin  >> v;
			map<string,int>::iterator prev;
			for(prev = cpp.lower_bound(str);prev != cpp.upper_bound(v);prev++)
                                if(prev->second!=0)
				cout << prev->first << " " << prev->second << endl; 
			break;
		}
	}
	return 0;	
}


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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    int N,K;
    int x[101];

    scanf("%d%d",&N,&K);

    REPI(N){
        scanf("%d",&x[i]);
    }
    
    int res = 0;
    int mid = K/2;
    
    REPI(N)
    {
        if(x[i]<=mid)
            res+=2*x[i];
        else
            res+=2*(K-x[i]);        
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define M 20000
#define N 400
int A[N],B[N],E[N],F[N],G[N],H[N],I[N],J[N],S,T,a[N],b[M],c[M],g[N],i,j,k,l,m,n,q[N],r,t,x;bool d[M],h[N];long long C[N],e[M],f[N],y,z;char D[N];
inline int add(int u,int v,long long w){b[++t]=a[u],c[a[u]=t]=v,d[t]=true,e[t]=w,b[++t]=a[v],c[a[v]=t]=u,d[t]=false,e[t]=-w;}
int u;
inline bool bfs()
{
    for(q[l=0]=S,r=1,memset(f+1,0x80,T<<3);l!=r;)for(h[u=q[l++]]=false,i=a[u],l=l==N?0:l;i;i=b[i])if(d[i]&&f[c[i]]<f[u]+e[i])if(f[c[i]]=f[u]+e[g[c[i]]=i],!h[c[i]])h[q[r++]=c[i]]=true,r=r==N?0:r;
    if(f[T]==0x8080808080808080ll)return false;
    for(x++,y+=f[i=T];i!=S;i=c[g[i]^1])d[g[i]]=false,d[g[i]^1]=true;
    return true;
}
inline bool solve()
{
    t=1,x=y=0,T=n+n+k+k+1,memset(a,0,T<<2);
    for(i=1;i<=k;i++)G[i]=I[i]=1,H[i]=J[i]=100,add(S,n+n+i,0),add(n+n+k+i,T,0);
    for(i=1;i<=n;i++)add(i,n+i,C[i]);
    for(i=1;i<=m;i++)
    if(D[i]=='L')F[i]<k?G[F[i]+1]=E[i]+1<G[F[i]+1]?G[F[i]+1]:E[i]+1:0;
    else if(D[i]=='R')F[i]<k?H[k-F[i]]=E[i]-1<H[k-F[i]]?E[i]-1:H[k-F[i]]:0;
    else if(D[i]=='D')F[i]<k?I[F[i]+1]=E[i]+1<I[F[i]+1]?I[F[i]+1]:E[i]+1:0;
    else F[i]<k?J[k-F[i]]=E[i]-1<J[k-F[i]]?E[i]-1:J[k-F[i]]:0;
    for(i=2;i<=k;i++)G[i]=G[i-1]<G[i]?G[i]:G[i-1],I[i]=I[i-1]<I[i]?I[i]:I[i-1];
    for(i=k;--i;)H[i]=H[i]<H[i+1]?H[i]:H[i+1],J[i]=J[i]<J[i+1]?J[i]:J[i+1];
    for(i=1;i<=k;i++)for(j=1;j<=n;j++)if(G[i]<=A[j]&&A[j]<=H[i])add(n+n+i,j,0);
    for(i=1;i<=k;i++)for(j=1;j<=n;j++)if(I[i]<=B[j]&&B[j]<=J[i])add(n+j,n+n+k+i,0);
    while(bfs());
    return x==k;
}
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)scanf("%d%d%lld",A+i,B+i,C+i);
    scanf("%d",&m);
    for(i=1;i<=m;i++)scanf("%s%d%d",D+i,E+i,F+i);
    for(k=1;solve();k++)z=y<z?z:y;
    return 0*printf("%lld\n",z);
}

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

int main() {
  int N = 0, t = 0, p = 0;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  for(int j = 0; j < d.size(); j++) {
    if(d.at(j) == 0) {
      continue;
    }
    
    if(t < d.at(j)) {
      t = d.at(j);
      p += 1; 
    }
    
  }
  
  cout << p << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

namespace HuRanZhiZhang_23333
{
	const int N=2010;
	int col[N][N],row[N][N];
	int G[N][N];
	int n,m,Q;

	inline bool got(){for(char c;c=getchar(),1;)if(isdigit(c))return c-48;}
	void initialize()
	{
		scanf("%d%d%d",&n,&m,&Q);
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				G[i][j]=got();
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
			{
				if(G[i][j] && G[i+1][j])col[i][j]=1;
				if(G[i][j] && G[i][j+1])row[i][j]=1;
			}
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
			{
				G[i][j]+=G[i-1][j]+G[i][j-1]-G[i-1][j-1];
				row[i][j]+=row[i-1][j]+row[i][j-1]-row[i-1][j-1];
				col[i][j]+=col[i-1][j]+col[i][j-1]-col[i-1][j-1];
			}
	}

	inline int ask1(int *sum,int L,int R){return sum[R]-(L>0?sum[L-1]:0);}
	inline int ask2(int sum[N][N],int x0,int x1,int y0,int y1){return ask1(sum[x1],y0,y1)-(x0>0?ask1(sum[x0-1],y0,y1):0);}

	int x0,x1,y0,y1;
	inline int query()
	{
		int ret=0;

		ret+=ask2(G,x0,x1,y0,y1);
		if(y0!=y1)ret-=ask2(row,x0,x1,y0,y1-1);
		if(x0!=x1)ret-=ask2(col,x0,x1-1,y0,y1);
		return ret;
	}

	void solve()
	{
		initialize();
		while(Q--)
		{
			scanf("%d%d%d%d",&x0,&y0,&x1,&y1);
			printf("%d\n",query());
		}
	}
}

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


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;

void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
    string answer = (N == 1 ? "0" : "1");
    rep(i,0,N-1) answer += '0';
    vector<unordered_set<int>> conditions(N+1);
    rep(i,0,M) {
        conditions[s[i]].insert(c[i]);
        if (conditions[s[i]].size() > 1 || (N > 1 && s[i] == 1 && c[i] == 0)) {
            cout << -1 << endl;
            return;
        }
        answer[s[i]-1] = (int)c[i] + '0';
    }
    cout << answer << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
c = [0] * (10**5 + 1)
for _ in range(n):
    a, b = map(int, input().split())
    c[a] += b
d = 0
for i in range(10**5 + 1):
    d += c[i]
    if d >= k:
        print(i)
        break


Measured memory_bytes: 5736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc119b
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var ans = 0.0;

            for(var i = 0; i < N; i++)
            {
                var xu = Console.ReadLine().Split();
                if(xu[1] == "JPY")
                {
                    ans += double.Parse(xu[0]);
                }
                else if (xu[1] == "BTC")
                {
                    ans += double.Parse(xu[0]) * 380000.0;
                }
            }
            
            Console.WriteLine(ans);
#if DEBUG
            Console.ReadKey();
#endif
        }

        double BTC2JPY(double btc) => btc * 380000.0;

        private static bool IsRange(int a, int from, int to) => (from <= a && a <= to);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static List<int> ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
        private static double ReadDouble() => double.Parse(Console.ReadLine());
        private static List<double> ReadDoubleList() => Console.ReadLine().Split().Select(double.Parse).ToList();
        private static List<int> Int2Digits(int a) => a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
    }
}


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

int main() {
	int K, A, B;
	cin >> K >> A >> B;
	bool isAchieved = false;

	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			isAchieved = true;
			break;
		}
	}
	if (isAchieved) {
		cout << "OK";
	}
	else {
		cout << "NG";
	}
	return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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;
};

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

  int N;
  cin >> N;
  int K;
  cin >> K;

  int ma = (N-1)*(N-2)/2;
  if (K > ma) {
    cout << -1 << endl;
  } else {
    set<PI> s_all;
    rep(i, 1, N) {
      rep(j, i+1, N+1) {
        s_all.insert(make_pair(i, j));
      }
    }

    set<PI> ans;
    rep(i, 1, N) {
      ans.insert(make_pair(i, N));
    }

    int cur = ma;

    for (auto pi: s_all) {
      if (cur == K) break;
      if (Find(ans, pi)) continue;
      ans.insert(pi);
      cur--;
    }

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

  return 0;
};


Measured memory_bytes: 768
#include <stdio.h>

int main(void){
  long long H,W;
  scanf("%lld%lld",&H,&W);

  long long x,y;
  scanf("%lld%lld",&x,&y);

  int ans = 0;
  if(x*2 == H && y*2 == W) ans = 1;

  printf("%.9lf %d",(double)(H*W)/2,ans);

  return 0;
}

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

int main(){
    int N;
    string s;
    cin >> N >> s;
    int cnt = 0;
    while(s[cnt]){
        if(s[cnt] + N > 90){
            s[cnt] = 64 + (s[cnt] + N - 90);
        }
        else s[cnt] += N;
        cnt++;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

paths = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    paths[a].add(b)
    paths[b].add(a)

rooms = [-1] * N
rooms[0] = 0
marks = [-1] * (N-1)
key_rooms = [[0]]
for step in range(1, N):
    next_key_rooms = set()
    for key_room in key_rooms[-1]:
        for else_room in paths[key_room]:
            if rooms[else_room] == -1:
                rooms[else_room] = step
                next_key_rooms.add(else_room)
                marks[else_room-1] = key_room
    key_rooms.append(next_key_rooms)

print('Yes')
for i in marks:
    print(i+1)


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

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

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

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  // 操作回数をインクリメント
    }

    cout << res << endl;
}

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

typedef long long ll;

int main() {
  int N, A;  // N:カードの枚数, A:選んだカードの平均の目標値
  cin >> N >> A;
  int x[N+1];
  for (int i=1; i<=N; i++) {
    cin >> x[i];
  }

  ll dp[N+1][N+1][50*N+1];
  for (int i=0; i<=N; i++) {
    for (int j=0; j<=N; j++) {
      for (int k=0; k<=50*N; k++) {
        dp[i][j][k] = 0;
      }
    }
  }

  dp[0][0][0] = 1;
  for (int i=1; i<=N; i++) {  // 何枚のカードを使うか
    for (int j=0; j<=N; j++) {  // 何枚のカードを選ぶか
      for (int k=0; k<=50*N; k++) {
        if (x[i] > k) {
          dp[i][j][k] = dp[i-1][j][k];
        } else if (x[i] <= k && j >= 1) {
          dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]];
        }
      }
    }
  }

  ll ans=0;
  for (int i=1; i<=N; i++) {
    ans += dp[N][i][A*i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 51072
// Problem : A - Odds of Oddness
// Contest : AtCoder Beginner Contest 142
// URL : https://atcoder.jp/contests/abc142/tasks/abc142_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;
  
  int n;
  cin >> n;
  
  int cnt = 0;
  
  for (int i = 1; i <= n; ++i)
    cnt += i % 2 != 0;
  
  cout << 1.0 * cnt / n;
}


Measured memory_bytes: 256