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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

constexpr int CHAR_LEN = 10;
constexpr int ALP_LEN = 26;
constexpr ll LL_MAX = 205891132094649;

int ctoi(char c) { return int(c - 'a'); }

ll stoi(char str[CHAR_LEN]) {
    ll ans = 0;
    ll mod = 1;
    rep(i, 0, CHAR_LEN) {
        if (str[i] == '\0') { break; }
        ans += ctoi(str[i]) % mod;
        mod *= CHAR_LEN;
    }
    return ans;
}

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

    map<string, int> memo;

    // O(n log(n))
    rep(i, 0, n) {
        char str[CHAR_LEN];
        scanf("%s", str);
        memo[string(str)] += 1;
    }

    // O(n)
    int maxv = 0;
    for(auto p: memo) {
        maxv = max(maxv, p.second);
    }

    for(auto itr = memo.begin(); itr != memo.end(); ++itr) {
        if (itr->second == maxv) {
            cout << itr->first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 23808
#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::max;

#[fastout]
fn main() {
    input!{
        a:usize,
        b:usize,
        x:usize,
    }

    let n_max : i64 = (b/x) as i64;
    let n_min : i64 = if a == 0 { -1 } else {((a - 1)/x) as i64}; 

    println!("{}",n_max-n_min);

}



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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    unordered_set<string> s;
    int n;

    cin >> n;
    while(n--){
        string i;
        cin >> i;
        s.insert(i);
    }
    cout << s.size();
    return 0;
}

Measured memory_bytes: 17732
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n=s.length();
    for(int i=0;i<n;i++)
        if(s[i]!=t[i])
        {
            cout<<"No\n";
            return 0;
        }
        cout<<"Yes\n";
    
    
    return 0;   
}




 
 


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> res(4, 0);
    vector<string> s = {"AC", "WA", "TLE", "RE"};
    rep(i, n) {
        string tmp;
        cin >> tmp;
        rep(j,4)if(tmp==s[j])res[j]++;
    }
    rep(i,4)cout<<s[i]<<" x "<<res[i]<<endl;
}

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

using namespace std;
typedef long long LL;
const int MAXN = 200005;
int x[MAXN], y[MAXN];
pair<LL, int> p[4][MAXN];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d %d", x + i, y + i);
        for (int j = 0; j < 4; j++)
        {
            if (j & 1)
                p[j][i].first += y[i];
            else
                p[j][i].first -= y[i];
            if (j & 2)
                p[j][i].first += x[i];
            else
                p[j][i].first -= x[i];
            p[j][i].second = i;
        }
    }
    for (int i = 0; i < 4; i++)
    {
        sort(p[i] + 1, p[i] + n + 1);
    }
    LL mx = 0;
    for (int i = 0; i < 2; i++)
    {
        if (i == 0)
        {
            for (int j = 1; j <= n; j++)
            {
                if (p[i][j].second == p[3][n].second)
                {
                    mx = max(p[i][j].first + p[3][n - 1].first, mx);
                }
                else
                {
                    mx = max(mx, p[i][j].first + p[3][n].first);
                }
            }
        }
        else
        {
            for (int j = 1; j <= n; j++)
            {
                if (p[i][j].second == p[2][n].second)
                {
                    mx = max(p[i][j].first + p[2][n - 1].first, mx);
                }
                else
                {
                    mx = max(mx, p[i][j].first + p[2][n].first);
                }
            }
        }
    }
    printf("%lld\n", mx);
    // int T;
    // cin >> T;
}

Measured memory_bytes: 17856
def partition(A, p, r):
  x = A[r]
  i = p - 1
  for j in range(p, r):
    if A[j] <= x:
      i += 1
      A[i], A[j] = A[j], A[i]
  A[i + 1], A[r] = A[r], A[i + 1]
  return i + 1

N = int(input())
A = list(map(int, input().split()))

q = partition(A, 0, len(A) - 1)
result = []
for i in range(len(A)):
  s = "[" + str(A[i]) + "]" if i == q else str(A[i])
  result.append(s)
print(" ".join(result))

Measured memory_bytes: 18948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) {
		cout << "No" << endl;
	}
	else { cout << "Yes" << endl; }

	
	

	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

unsigned long long nCr(long n, long r) {
    unsigned long long ans = 1;
    for (long i = 1 ; i < r + 1; ++i) {
        ans = ans * (n-i+1)/ i;
    }
    return ans;
}
ll ans = 0;
string s;
ll idx = 0;
void solve(ll k, bool stat, ll p){
//    cout << ans << endl;
//    cout << "solve " << k << " " << stat << " " << p << " called" << endl;
    if(stat == false){
        if(p < 0 or k < p)
            return;
        ans += (ll)(pow(9, p)) * nCr(k,p);
        return;
    }
    if(k==0){
        if(p == 0)ans++;
//        ans++;
        return;
    }
    ll a = s[idx] - '0';
    for(ll i=1;i<a;i++){
        solve(k-1, false, p-1);
    }
    if(a != 0){
        solve(k-1, false, p);
        idx++;
        solve(k-1, true, p-1);
    }else{
        idx++;
        solve(k-1, true, p);
    }
}

int main() {
   

    ll c;
    cin >> s >> c;
    solve(s.length(), true, c);
    cout << ans << endl;

}

Measured memory_bytes: 256
# @uthor : Kaleab Asfaw
from sys import stdin, stdout
# Fast IO
def input():
	a = stdin.readline()
	if a[-1] == "\n": a = a[:-1]
	return a
def print(*argv, end="\n", sep=" "):
	n = len(argv)
	for i in range(n):
		if i == n-1: stdout.write(str(argv[i]))
		else: stdout.write(str(argv[i]) + sep)
	stdout.write(end)
# Others
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def comb(lst, x):
	from itertools import combination as c
	return list(comb(lst, x))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}
def smaller(lst, x): return bisect_left(lst, x) -1
def smallerEq(lst, x): return bisect_right(lst, x) -1

def solve(l, r, d):
	cnt = 0
	for i in range(l, r+1):
		if i % d == 0: cnt += 1
	return cnt

l, r, d = list(map(int, input().split()))
print(solve(l, r, d))

Measured memory_bytes: 9224
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << b + (b - a);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        for(int j=0;j<H;j++){
            for(int i=0;i<W;i++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3120
n=int(input())
a=list(map(int,input().split()))
cnt=[]
def divis(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            a[i-1]^=1
            if i != n // i :
                ij=n//i
                a[ij-1]^=1
for i in reversed(range(n)):
    if a[i]==1:
        cnt.append(i+1)
        divis(i+1)
if len(cnt)>0:
    print(len(cnt))
    print(*cnt)
else:
    print(0)



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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数（ll）
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

//素因数分解
vector<pair<ll, int>>factorize(ll n){
  vector<pair<ll, int>> res;
  for(ll i = 2; i * i <= n; ++i){
    if(n % i) continue;
    res.emplace_back(i, 0);
    while(n % i == 0){
      n /= i;
      res.back().second++;
    }
  }
if(n != 1) res.emplace_back(n, 1);
return res;
}






int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  sort(all(A));

  ll sum = A.at(0);
  int ans = N;
  REP(i, N - 1){
    if(sum * 2 < A.at(i + 1)){
      ans = N - (i + 1);
    }
    sum += A.at(i + 1);
  
  }  

 print(ans);

}




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

int main(){
  int sum=0,a=0,N,K; cin>>N>>K;
  int l[50]; 
  for(int i=0;i<N;i++){
    cin>>l[i];
  }
  sort(l,l+N,greater<int>());
    for(int i=0;i<K;i++){
      sum+=l[i];
      a++;
      if(a==K)break;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b,c*d) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
	  if (S[i] == T[i]) {
		  ans++;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($i = 0; $i < $H; $i++){
  $str = trim(fgets(STDIN));
  $map[$i] = $str."#";
}
$map[$H] = str_repeat("#", $W);
for($i = 0; $i < $H; $i++){
  $h = 0;
  for($j = 0; $j < $W+1; $j++){
    if($map[$i][$j] === "#"){
      for($k = 0; $k < $h; $k++){
        $p[$i][$j - 1 - $k] = $h;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
for($i = 0; $i < $W; $i++){
  $h = 0;
  for($j = 0; $j < $H+1; $j++){
    if($map[$j][$i] === "#"){
      for($k = 0; $k < $h; $k++){
        $p[$j - 1 - $k][$i] += $h;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
$max = 0;
for($i = 0; $i < $H; $i++){
  $max = max($max, max($p[$i]));
}
echo $max - 1;

Measured memory_bytes: 154104
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	double x,ans=0;
	string s;
	rep(i,n){
		cin>>x>>s;
		ans+=(x*((s=="JPY")?1:380000));
	}
	fcout(6)<<ans<<endl;
}


Measured memory_bytes: 256
eval"N,K,*A,D=#{`tr -! ,`}(R=0..255).map{[0]*101}"
D[0][0]=1
A.map{|a|N.times{|j|R.map{D[_1^a][i=N-j]+=D[_1][i-1]*i}}}
p D[K].sum.%10**9+7

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


signed main(void){
    int H,N;
    int A[1514],B[1514];
    int maxA=0;
    cin >> H >> N;
    REP(i,N){
        cin >> A[i] >> B[i];
        maxA=max(maxA,A[i]);
    }
    int dp[30200];
    REP(i,30200){dp[i]=INF;}
    dp[0]=0;
    REP(i,H+maxA){
        if(dp[i]==INF)continue;
        REP(j,N){
            dp[i+A[j]]=min(dp[i+A[j]],dp[i]+B[j]);
        }
    }
    
    //REP(i,H+maxA){cout << dp[i] << " ";}
    
    RREP(i,30200-1){
        if(dp[i]==INF){
            dp[i]=dp[i+1];
        }
    }
    int Ans=INF;
    for(int i=H;i<30200;i++){
        Ans=min(Ans,dp[i]);
    }
    cout << Ans << endl;
    return 0;
}



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

int main(void){
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(),greater<int>());
    
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3096
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (c1).begin(),(c1).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

set<int> st;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		st.insert(a);
	}
	cout << st.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,c=0;
    string s,a;
    map<string,int>mp;
    cin>>n;
    for(i=0;i<n;i++)
    {
       cin>>s;
       mp[s]++;
       if(c<mp[s])
       {
           c=mp[s];
           a=s;
       }
    }
    cout<<mp.size()<<endl;
}


Measured memory_bytes: 19168
require 'scanf'

def op(a, b)
    a[0]*b[1]-a[1]*b[0]
end

while str = STDIN.gets
    l = str.scanf("%f,%f,%f,%f,\
                   %f,%f,%f,%f")
    f1, f2 = true, true
    for i in 0..(4-1) do
        x1, y1 = l[i*2+0], l[i*2+1]
        x2, y2 = l[(i*2+2)%8], l[(i*2+3)%8]
        x3, y3 = l[(i*2+4)%8], l[(i*2+5)%8]
        a = [x1-x2, y1-y2]
        b = [x3-x2, y3-y2]
        f1 &= (op(a,b)>0.0)
        f2 &= (op(a,b)<0.0)
    end
    print(if f1 or f2; "YES\n" else "NO\n" end)
end

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, C;
  cin >> N;
  if(N % 1000 == 0) C = N / 1000;
  else if(N >1000) C = N / 1000 + 1;
  else C = 1;
  
  cout << C * 1000  - N << endl;
}

Measured memory_bytes: 3624
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()

ab = []
for _ in range(n):
    a,b = li()
    if a <= k:
        ab.append((a,b))

binn = len(bin(k))-2
bink = bin(k)[2:]

# binの候補を挙げる
cands = [bink]
for i, s in enumerate(list(bink)):
    if int(s):
        cands.append(bink[:i] + "0" + "1"*(binn-i-1))
        
ans = 0
for cand in cands:
    tmp = 0    
    cand = int("0b"+cand, 0)
    
    for a, b in ab:

        if cand | a <= cand:
            tmp += b
                
    ans = max(ans, tmp)
    
print(ans)

Measured memory_bytes: 16644
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
	int n, m, f[10001] = { 0 }, s[10001] = { 0 }, ss[501] = {0}, f_, s_, cnt = 0;
	int up = 0, down = 0;
	cin >> n >> m;
	ss[1] = 3;
	while (n != 0 && m != 0)
	{
		memset(ss, 0, sizeof(ss));
		for (int i = 0; i < m; i++)
		{
			cin >> f[i] >> s[i];
			if (f[i] == 1)
			{
				ss[s[i]] = 2;
			}
		}
		for (int i = 0; i < m; i++)
		{
			if (ss[s[i]] == 2 && ss[f[i]] == 0)
				ss[f[i]] = 1;
			if (ss[f[i]] == 2 && ss[s[i]] == 0)
				ss[s[i]] = 1;
		}
		for (int i = 2; i <= n; i++) {
			if (ss[i] != 0)cnt++;
		}
		cout << cnt << endl;
		cnt = 0;
		cin >> n >> m;
	}
	return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

/* 二項係数 nCr mod p を計算する。

nCr = n! / (r! * (n -r)!)
    = n! * (r!)^{-1} * ((n-r)!)^{-1}
を利用する。

n!、(r!)^{-1}、((n-r)!)^{-1}は予め求めておく必要がある。
また、逆元^{-1}は拡張ユークリッドの互除法により求めることができる。

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;


constexpr int MAX = 1010000;
constexpr int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// nCr 計算用初期化処理
// O(MAX)
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for(int i = 2; i < MAX; ++i) {
        fac[i] = fac[i - 1] * i % MOD; // 累乗の累積
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; // 逆元
        finv[i] = finv[i - 1] * inv[i] % MOD; // 逆元の累積
    }
}

// nCr mod MOD を計算する。
// O(1)
ll comb(int n, int r) {

    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll X, Y;

int main(void) {

    comb_init();

    cin >> X >> Y;
    if (X < Y) swap(X, Y);

    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll n = (X + Y) / 3;
    ll r = Y - n;

    cout << comb(n, r) << endl;

    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

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




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

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

    ll q,h,s,d;
    ll n;
    cin >> q >> h >> s >> d;
    cin >> n;

    int cp = min(q*8, min(h*4, min(s*2, d)));
    int cp_wd = min(q*4, min(h*2, s));
    ppp(n/2 * cp + n%2 * cp_wd);

    return 0;
}


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

bool solve();

int main()
{
	if (solve()) puts("First");
	else puts("Second");

	return 0;
}

using pii = std::pair<int, int>;

struct Node {
	bool visited{};
	std::list<int> edge;
};
std::vector<Node> graph;

pii dfs(int);

bool solve()
{
	// 次数1を全部むしるか好きな一個残して他全部むしるかのゲーム
	int N;
	scanf("%d", &N);
	graph.resize(N);

	for (int i{}; i < N - 1; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		graph[a].edge.push_back(b);
		graph[b].edge.push_back(a);
	}
	int side{};
	side = dfs(0).second;
	for (auto& e: graph) e.visited = false;
	int length{dfs(side).first};
	return length % 3 != 2;
}

pii dfs(int index)
{
	if (graph[index].visited) return pii(-1, -1);
	graph[index].visited = true;
	pii ret(1, index);
	for (auto& e: graph[index].edge)
	{
		pii tmp{dfs(e)};
		tmp.first++;
		ret = std::max(ret, tmp);
	}
	return ret;
}

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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(a) sort(a.begin(), a.end()) //reverse()で反転
#define lower(a, n) lower_bound(a.begin(), a.end(), n);
#define upper(a, n) upper_bount(a.begin(), a.end(), n);
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int sum(int a){
  if(a == 0) return 0;
  return sum(a - 1) + a;
}
int main(){
  int n;
  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    if(i % 5 == 0 || i % 3 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int main() {
	int A, B;
	scanf("%d %d", &A, &B);

	int ans = A;
	if (A > B) ans--;
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = sc.nextInt();
		int k = sc.nextInt();

		if (k != 1) {
			System.out.print(n - k);
		} else {
			System.out.print("0");
		}

	}
}

Measured memory_bytes: 21844
/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[8][2] = {{0, 1}, {1, 0}, {0, -1}, { -1, 0}, {1, 1}, {1, -1}, { -1, -1}, { -1, 1}};
const int mod = 1e9 + 7;
const int gakki = 5 + 2 + 1 + 19880611 + 1e9;
const int N = 2e5 + 5;
ll num[N];
int last = 0;
int Left[N];
ll yihuo;
ll pre;
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        int n;
        cin >> n;
        ll anser = 0;
        for (int i = 1; i <= n; i++)
        {
                cin >> num[i];
                Left[i] = last;
                if (num[i])
                {
                        last = i;
                }
        }
        ll now;
        ll i, j;
        for (i = 1; i <= n; i++)
        {
                yihuo = pre = num[i];
                for (j = Left[i]; j >= 1;j = Left[j])
                {
                        yihuo = yihuo ^ num[j];
                        pre += num[j];
                        if (yihuo != pre)
                        {
                                break;
                        }
                }
                anser+=i-j;
        }
        cout << anser << endl;
        return 0;
}


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

using namespace std;

typedef long long int ll;

const int N = 1e5 + 5;

vector < vector < int > > adj(N, vector < int > ());
vector < int > depth(N);

void dfs(int u){
  depth[u] = 0;
  vector < int > v;
  for(auto to : adj[u]){
    dfs(to);
    v.push_back(depth[to]);
  }

  sort(v.begin(), v.end(), greater < int > ());
  for(int i = 0; i < v.size(); i++){
    depth[u] = max(depth[u], v[i] + i + 1);
  }
}

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

  int n;
  cin >> n;
  for(int i = 2; i <= n; i++){
    int a;
    cin >> a;
    adj[a].push_back(i);
  }

  depth[1] = 0;
  dfs(1);

  cout << *max_element(depth.begin(), depth.end()) << '\n';
}


Measured memory_bytes: 13952
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int N;
  cin >> N;
  if(N==1) cout << "Hello World" <<endl;
  else{
  	int A, B;
  	cin >> A >> B;
  	cout << A+B <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n,A[50];
int solve(int i,int m){
  if (m==0) return 1;
  if (i>=n)return 0;
  int res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}
int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2680
/******************************************
* AUTHOR : GEEOTHERMAL/CODEFORCES
  USED BY : Shivam Jalotra
  COLLEGE : Nit Kurukshetra
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin >> N;
	cout <<  pow(N,3);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    int ans = A[0];
    REP(i, N) ans = gcd(ans, A[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while all(i%2 == 0 for i in a):	#all()はすべてiterがtrueならtrueを返す
  a = [i/2 for i in a]			#式"i%2==0"を評価するとbool型が帰る
  cnt += 1
  
print(cnt)


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

int main(){

  int n,m;
  int vote[1000];
  int cost[1000];
  int b;
  int max=0,indx=1000;

  cin >> n >> m;

  for(int i=0; i<n; i++){
    cin >> cost[i];
    vote[i]=0;
  }

  for(int i=0; i<m; i++){
    cin >> b;
    int j=0;
    while(cost[j] > b){
      j++;
    }
    vote[j]++;
  }

  for(int i=0; i<n; i++){
    if(max < vote[i]){
      max = vote[i];
      indx = i;
    }
  }

  cout << indx+1 << endl;

  return 0;
}

Measured memory_bytes: 1168
#include<stdio.h>
#include<math.h>
#define N 100000
int a[100005]={0}; 
int main()
{
	a[1]=0;
	for(int i=2;i<=sqrt(N);i++)
	{
		if(a[i]==0)
		{
			for(int j=i*i;j<=N;j+=i)
				a[j]=1;	
		}
	}
	int p[100005];
	p[0]=1;
	p[1]=1;
	for(int i=3;i<=N;i+=2)
	{
		p[i]=p[i-2];
		if(a[i]==0&&a[(i+1)/2]==0)
			p[i]+=1;
	}
	
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x==1)
			x=2;
		printf("%d\n",p[y]-p[x-2]);
	}
	
	
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto in : x) {cerr << " [" << in << "]";} cerr << '\n';
using namespace std;
using ll = long long;
using ld = long double;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18 + 100;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	int it1 = 0, it2 = 0;
	for (int i = 0; i < n; i++){
		 if(a[i] != i + 1){
			 it1 = i;
			 break;
		 }
	}
	for (int i = it1 + 1; i < n; i++){
		if(a[i] != i + 1){
			 it2 = i;
			 break;
		 }
	}
	swap(a[it1], a[it2]);
	bool ok = true;
	for (int i = 1; i < n; i++){
		ok &= a[i] > a[i - 1];
	}
	cout << (ok ? "YES\n" : "NO\n");
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func node(cur, used, n int) int {
	if cur > n {
		return 0
	}
	ans := 0
	if used == 7 {
		ans++
	}
	ans += node(cur*10+3, used|1, n)
	ans += node(cur*10+5, used|2, n)
	ans += node(cur*10+7, used|4, n)
	return ans
}

func main() {
	var n int
	fmt.Scan(&n)
	ans := node(0, 0, n)
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
using namespace std;
int main(){
	string N;
	cin>>N;
	for(int i=0;i<N.length();i++){
		if(N[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	} 
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 3624
from collections import defaultdict
N = int(input())
dic = defaultdict(int)
for i in range(N):
    A = int(float(input())*10**9+0.1)
    two = 0
    five = 0
    while A % 2 == 0:
        A //= 2
        two += 1
    while A % 5 == 0:
        A //= 5
        five += 1
    dic[(two,five)] += 1
ans = 0
for T1,F1 in dic.keys():
    for T2,F2 in dic.keys():
        if T1+T2 >= 18 and F1+F2 >= 18:
            X = dic[(T1,F1)]
            Y = dic[(T2,F2)]
            if T1 == T2 and F1 == F2:
                ans += X*(X-1)
            else:
                ans += X*Y
print(ans//2)

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

int main() {
    int n;
    cin >> n;
  long long int a[100010]={0};
  long long int ans =0 , res =0;
  
  for(int i=0;i<n;i++){
    cin >> a[i] ;
    
  }
  
  for(int i=0;i<n;i++){
    
    
    if(a[i] ==0){
      res += ans / 2;
      ans = 0;
    }
    
    else{
      ans += a[i];
    }
    
  }
    res += ans / 2;
  
  cout << res << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<set>
using namespace std;

int main() 
{
  int N = 0;
  cin >> N;

  int order[N];
  int presure[N];
  int addPresure[N - 1];

  int total = 0;
  int previous = 0;

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

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

    for (int k = 0; k < N - 1; k++) {
    cin >> addPresure[k];
  }

  for (int l = 0; l < N; l++) {
    total += presure[order[l] - 1];
    if (previous != 0 && previous == order[l] - 1) {
      total += addPresure[previous - 1];
    }
    previous = order[l];
  }

  cout << total << endl;
  
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}


int main() {
    ll a, b;
    cin >> a >> b;
    if (a % 2 == 1 && b % 2 == 1) {
        cout << "Odd" << endl;
    } else {
        cout << "Even" << endl;
    }

    return 0;
}

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

using namespace std;

int rec( int i, int K, const vector<int>& h, vector<int>* memo )
{
    if ( i == 1 ) return 0;
    if ( i == 2 ) return abs( h[ i - 1 ] - h[ i - 2 ] );

    if ( ( *memo )[ i ] != -1 ) return ( *memo )[ i ];

    static const long long INF = 1LL << 60;
    long long minCost = INF;
    for ( int j = 1; j <= K && j < i; ++j )
    {
        int temp = rec( i - j, K, h, memo ) + abs( h[ i - 1 ] - h[ i - j - 1 ] );
        if ( temp < minCost ) minCost = temp;
    }

    return ( *memo )[ i ] = minCost;
}

int main()
{
    int N;
    cin >> N;

    int K;
    cin >> K;

    vector<int> h( N );
    for ( int i = 0; i < N; ++i ) cin >> h[ i ];

    vector<int> memo( N + 1, -1 );
    cout << rec( N, K, h, &memo ) << endl;
}

Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int A[305][305];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll H,W,D; cin >> H >> W >> D;
    vector<pair<ll,ll>> v(H*W+1);
    for(ll i=1;i<=H;i++){
        for(ll j=1;j<=W;j++){
            cin >> A[i][j];
            v[A[i][j]] = make_pair(i,j);
        }
    }

    ll S[90005];
    Fill(S,0);
    for(ll d=1;d<=D;d++){
        for(ll l=0;d+(l+1)*D <= H*W;l++){
            S[d+(l+1)*D] = S[d+l*D] + abs(v[d+(l+1)*D].first - v[d+l*D].first) + abs(v[d+(l+1)*D].second - v[d+l*D].second); 
        }
    }

    ll Q; cin >> Q;
    for(ll i=0;i<Q;i++){
        ll L,R; cin >> L >> R;
        cout << S[R] - S[L] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NKL = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, K, L) = (NKL[0], NKL[1], NKL[2]);
            var uf1 = new UnionFind(N);
            for (var i = 0; i < K; i++)
            {
                var pq = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                uf1.Union(pq[0] - 1, pq[1] - 1);
            }
            var uf2 = new UnionFind(N);
            for (var i = 0; i < L; i++)
            {
                var rs = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                uf2.Union(rs[0] - 1, rs[1] - 1);
            }

            var dict = new Dictionary<(int, int), int>();
            for (var i = 0; i < N; i++)
            {
                var p1 = uf1.Find(i);
                var p2 = uf2.Find(i);
                if (!dict.ContainsKey((p1, p2))) dict[(p1, p2)] = 0;
                dict[(p1, p2)]++;
            }

            var answer = new int[N];
            for (var i = 0; i < N; i++)
            {
                var p1 = uf1.Find(i);
                var p2 = uf2.Find(i);
                answer[i] = dict[(p1, p2)];
            }

            Console.WriteLine(string.Join(" ", answer));
        }

        public class UnionFind
        {
            private int[] _parents;
            private int[] _counts;

            public UnionFind(int length)
            {
                _parents = Enumerable.Range(0, length).ToArray();
                _counts = Enumerable.Repeat(1, length).ToArray();
            }

            public int Find(int x)
            {
                if (_parents[x] == x) return x;
                return _parents[x] = Find(_parents[x]);
            }

            public bool Union(int x, int y)
            {
                var rootX = Find(x);
                var rootY = Find(y);
                if (rootX == rootY) return false;

                if (_counts[rootX] < _counts[rootY])
                {
                    var tmp = rootX;
                    rootX = rootY;
                    rootY = tmp;
                }
                _counts[rootX] += _counts[rootY];
                _parents[rootY] = rootX;
                return true;
            }

            public int Size(int x)
            {
                return _counts[Find(x)];
            }

            public bool IsSame(int x, int y)
            {
                return Find(x) == Find(y);
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int c;
  cin >> c;
  c < 1200 ? cout << "ABC" << endl : cout << "ARC" << endl;



  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n, m = LI()
G = [set(range(n)) for _ in range(n)]
for i in range(n):
    G[i].remove(i)

for _ in range(m):
    a, b = LI()
    G[a - 1].remove(b - 1)
    G[b - 1].remove(a - 1)

color = [0] * n
def bipartite_or_not(s):
    color[s] = 1
    dq = deque([s])
    b = 1
    w = 0
    while dq:
        u = dq.popleft()
        for v in G[u]:
            if color[v] and color[u] != color[v]:
                continue
            elif color[v] and color[u] == color[v]:
                print(-1)
                exit()
            color[v] = -color[u]
            if color[v] == 1:
                b += 1
            else:
                w += 1
            dq += [v]
    return b, w

bit = 1 << n
for i in range(n):
    if color[i]:
        continue
    x = bipartite_or_not(i)
    p, q = x
    d = abs(p - q)
    bit = bit << d | bit >> d

for j in range(n):
    if bit >> (n - j) & 1:
        y, z = (n + j) // 2, (n - j) // 2
        print(y * (y - 1) // 2 + z * (z - 1) // 2)
        break


Measured memory_bytes: 64988