akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);
int main(){
    int n,k;cin >> n >>k;
    vl v(n);
    rep(i,n)cin >> v[i];
    sort(all(v));
    mint mini=0,maxi=0;
    rep(i,n-k+1){
        mint c=comb(n-1-i,k-1);
        mini+=(c*v[i]);
    }
    rev(all(v));
    rep(i,n-k+1){
        mint c=comb(n-1-i,k-1);
        maxi+=(c*v[i]);
    }
    cout << (maxi-mini) <<endl;
}

Measured memory_bytes: 4096
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        _n: usize,
        s: Chars,
    }

    let mut rs = std::collections::HashSet::new();
    let mut gs = std::collections::HashSet::new();
    let mut bs = std::collections::HashSet::new();

    for (idx, &c) in s.iter().enumerate() {
        if c == 'R' {
            rs.insert(idx);
        } else if c == 'G' {
            gs.insert(idx);
        } else {
            bs.insert(idx);
        }
    }

    let mut ans = 0;

    for &r in rs.iter() {
        for &g in gs.iter() {
            let larger = std::cmp::max(r, g);
            let smaller = std::cmp::min(r, g);
            let diff = larger - smaller;

            let mut size = bs.len();

            if smaller >= diff {
                let b = smaller - diff;
                if let Some(_) = bs.get(&b) {
                    size -= 1;
                }
            }

            let b = larger + diff;

            if let Some(_) = bs.get(&b) {
                size -= 1;
            }

            if (larger + smaller) % 2 == 0 {
                let b = (larger + smaller) / 2;
                if let Some(_) = bs.get(&b) {
                    size -= 1;
                }
            }

            ans += size;
        }
    }

    echo!(ans);
}


Measured memory_bytes: 2204
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    char[][] m = new char[H][W];
    for (int i = 0; i < H; i++) {
      String s = sc.next();
      for (int j = 0; j < W; j++) {
        m[i][j] = s.charAt(j);
      }
    }
    
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (m[i][j] == '.') {
          System.out.print(count(m, i, j));
        } else {
          System.out.print(m[i][j]);
        }
      }
      System.out.println();
    }
  }

  private static int count(char[][] m, int i, int j) {

    int ret = 0;

    if (0 < i && 0 < j && m[i-1][j-1] == '#') {
      ret++;
    }
    if (0 < i && m[i-1][j] == '#') {
      ret++;
    }
    if (0 < i && j < m[i].length-1 && m[i-1][j+1] == '#') {
      ret++;
    }
    
    if (0 < j && m[i][j-1] == '#') {
      ret++;
    }
    if (j < m[i].length-1 && m[i][j+1] == '#') {
      ret++;
    }
    
    if (i < m.length-1 && 0 < j && m[i+1][j-1] == '#') {
      ret++;
    }
    if (i < m.length-1 && m[i+1][j] == '#') {
      ret++;
    }
    if (i < m.length-1 && j < m[i].length-1 && m[i+1][j+1] == '#') {
      ret++;
    }
    
    return ret;
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(string, s);
	string t;
	inc(i, SI(s) / 2) { t += "hi"; }
	OUT(s == t ? "Yes" : "No");
}


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

int main() {
  int N,Ni,ans;
  cin >> N;
  vector<int> d(101,0);
  
  for (int i=0;i<N; i++) {
    cin >> Ni;
    ++d.at(Ni);
  }
  
  ans=N;
    
  for (int i=0; i<101; i++){
    if (d.at(i)!=0 && d.at(i)!=1){
      ans=ans-(d.at(i)-1);
    }
  }
 cout << ans << endl;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;

ll fac[MAX]; // n!
ll finv[MAX]; // n!の逆元
ll inv[MAX]; // nの逆元


// n!(fac)とその逆元(finv)を先に計算しておく
void comInit(){
	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を計算(先にcomInit()が必須)
ll com(ll n, ll r){
	if (n < r) return 0;
	if (n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
	}
	comInit(); // 先にn!とその逆元を計算

	sort(A.begin(),A.end());

	ll maxsum = 0;
	rep(i, N) {
		maxsum += (com(i, K -1) * A[i]) % MOD;
		maxsum %= MOD;
	}

	reverse(A.begin(), A.end());
	ll minsum = 0;
	rep(i, N) {
		minsum += (com(i, K - 1) * A[i]) % MOD;
		minsum %= MOD;
	}

	cout << (maxsum - minsum) % MOD << endl;

	return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K;
    cin >> N >> K;
    vector<int> p;
    p.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    
    sort(p.begin(), p.end());

    int sum = 0;
    for (int i = 0; i < K; i++)
    {
        sum += p[i];
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
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 n;
string s;
vector<int> r(4040, 0);
vector<int> g(4040, 0);
vector<int> b(4040, 0);
vector<int> rsum(4040, 0);
vector<int> gsum(4040, 0);
vector<int> bsum(4040, 0);

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

    for(int i = 0; i < n; ++i) {
        if(s.at(i) == 'R') r.at(i)++;
        else if(s.at(i) == 'G') g.at(i)++;
        else b.at(i)++;
    }

    for(int i = 0; i < n; ++i) {
        rsum.at(i+1) += rsum.at(i) + r.at(i);
        gsum.at(i+1) += gsum.at(i) + g.at(i);
        bsum.at(i+1) += bsum.at(i) + b.at(i);
    }

    long long cnt = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            if(s.at(i) != s.at(j)) {
                int dx = j-i;
                if((s.at(i) == 'R' && s.at(j) == 'G') || (s.at(i) == 'G' && s.at(j) == 'R')) {
                    cnt += bsum.at(n)-bsum.at(j);
                    if(j+dx < n) {
                        if(s.at(j+dx) == 'B') cnt--;
                    }
                }else if((s.at(i) == 'R' && s.at(j) == 'B') || (s.at(i) == 'B' && s.at(j) == 'R')) {
                    cnt += gsum.at(n)-gsum.at(j);
                    if(j+dx < n) {
                        if(s.at(j+dx) == 'G') cnt--;
                    }
                }else {
                    cnt += rsum.at(n)-rsum.at(j);
                    if(j+dx < n) {
                        if(s.at(j+dx) == 'R') cnt--;
                    }
                }
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3744
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mi d + 1, r
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MP make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
inline int sgn(double x){return (x > EPS) - (x < -EPS);}

int n;
int c[N];
int num;
void add(int k){
    for(; k <= num; k += k & (-k)) c[k] += 1;
}
int sum(int k){
    int s = 0;
    for(; k; k &= (k - 1)) s += c[k];
    return s;
}
long long k, a[N], x, hx[N];
set<long long>S;
int main(){
  //  IN;
    cin >> n >> k;
    LL ans = 0;
    FF(i, 1, n){
        scanf("%lld", &a[i]);
    }
    FF(i, 1, n) a[i] += a[i - 1];
    FF(i, 1, n){
        a[i] = a[i] - k * i;
        hx[i] = a[i];
    }
    hx[n + 1] = 0;
    sort(hx + 1, hx + 1 + n + 1);
    num = unique(hx + 1, hx + 1 + n + 1) - hx - 1;
    x = lower_bound(hx + 1, hx + 1 + num, 0) - hx;
    add(x);
    FF(i, 1, n){
        x = lower_bound(hx + 1, hx + 1 + num, a[i]) - hx;
        ans += sum(x);
        add(x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int q; cin >> q;
	for (int i = 0; i < q; i ++) {
		long long a, b; cin >> a >> b;
assert(a<=1000000000);
assert(b<=1000000000);
assert(b>=1);
assert(a>0);
		long long root = sqrt(a*b);
		long long ans = root + (a*b-1)/root-1;
        if(a!=b)--ans;
		cout << ans << endl;
	}
}


Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String str1 = sc.nextLine();
		int count = 0;
		for(int i = 0;i<str1.length();i++) {
			if(str.charAt(i)!=str1.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 42196
#include <iostream>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";
 
int main(){
  ll n, count=0;
  cin >> n;
  ll p;
  rep(i, 0, n){
    cin >> p;
    if(p != i+1) count++;
  }
  if(count <= 2) {
    print("YES"); 
  }else print("NO");
  
  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

//sqrt
//-------------------------------------------
template<class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//repetition
//------------------------------------------
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  FOR(i,0,n)
#define REPR(i, n) for(int i = n;i >= 0;i--)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {

    LL val = 1;
    int N; cin>>N;

    for(LL i=1;i<=N;i++){
        val *= i;
        val %= 1000000007;
    }

    cout<<val;

    return 0;
}















































Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int min = INT_MAX
      , max = INT_MIN
      , sum = 0;
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      int d;

      scanf ( "%d", &d );
      min   = MIN( min, d );
      max   = MAX( max, d );
      sum  += d;
    }

    printf ( "%d\n", ( sum - min - max ) / ( n - 2 ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
using pii = pair<int,int>;
char s[maxn];
vector<int>v,son[maxn];
int id[maxn],use[maxn];
int tot = 0;
int GetWay(int st)
{
    int x = ++tot;
    for(auto &u:son[st]){
        int y = GetWay(u);
        son[x].push_back(y);
    }
    return x;
}
int main()
{
   // freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
    int n;
    scanf("%s",s+1);
    bool ok = 0;
    n = strlen(s+1);
    if(s[n]=='1'||s[1]=='0'||s[n-1]=='0') ok = 1;
    for(int i = 1;i <= n/2; ++i) if(s[i]!=s[n-i]) ok = 1;
    //set<int>se;
    for(int i = 1; i < n; ++i) if(s[i]=='1') v.push_back(i);//se.insert(i);

    if(ok) puts("-1");
    else
    {//       int e = 0;
        for(int i = 0;i < v.size(); ++i)
        {
            ++tot;id[v[i]] = tot;
            int Size = v[i]-1;
            for(int j = i-1;j >= 0&&Size; --j)
            {
                Size -= v[j];
                if(Size < 0)
                {
                     Size += v[j];
                     while(Size--){
                        if(use[1]) son[id[v[i]]].push_back(++tot);
                        else son[id[v[i]]].push_back(id[v[1]]),
                            use[1] = 1;
                     }
                     break;
                }
                if(use[v[j]]) son[id[v[i]]].push_back(GetWay(id[v[j]]));
                else son[id[v[i]]].push_back(id[v[j]]),
                     use[v[j]] = 1;
            }
            while(Size>0){ Size --;
                    if(use[1]) son[id[v[i]]].push_back(++tot);
                    else son[id[v[i]]].push_back(id[v[1]]),
                         use[1] = 1;
            }
        }
        son[id[*v.rbegin()]].push_back(++tot);
        for(int i = 1;i <= tot; ++i) for(auto &u:son[i]) printf("%d %d\n",i,u);
    }
    return 0;
}
/*
101111010
*/


Measured memory_bytes: 8184
/*
	AOJ_0110: Alphametic
*/
#include	<iostream>
#include	<string>
#include	<cstdlib>
#include	<algorithm>

using namespace std;

int Alp_calc(string);
string convert_Xtoi(string, int);
string calc_AddofNumString(string, string);

int main(void) {
	string str;
	int result;

	while (1) {
		cin >> str;
		if (cin.eof()) { break; }

		result = Alp_calc(str);
		if (result != -1) { cout << result << endl; }
		else { cout << "NA" << endl; }
	}
	return 0;
}

int Alp_calc(string str) {
	string sect_1, sect_2, solution;

	string::iterator it = str.begin();
	while (*it != '+') {
		sect_1 += *it;
		it++;
	} it++;
	while (*it != '=') {
		sect_2 += *it;
		it++;
	} it++;
	while (it != str.end()) {
		solution += *it;
		it++;
	}
	for (int i = 0; i < 10; i++) {
		string _bf1, _bf2, _bfs, _buff;

		_bf1 = convert_Xtoi(sect_1, i);
		_bf2 = convert_Xtoi(sect_2, i);
		_bfs = convert_Xtoi(solution, i);

		_buff = calc_AddofNumString(_bf1, _bf2);
		if (_buff == _bfs) { return i; }
	}

	return -1;
}

string convert_Xtoi(string str, int n) {
	string::iterator it = str.begin();
	while (it != str.end()) {
		if (*it == 'X') { *it = n + '0'; }
		it++;
	}
	return str;
}

string calc_AddofNumString(string str1, string str2) {
	bool f1 = false, f2 = false, carry = false;
	char bb;
	int s1_i = 0, s2_i = 0;
	const int s1_mx = str1.length(), s2_mx = str2.length();
	string result;

	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());
	while ((s1_i < s1_mx) || (s2_i < s2_mx) || carry == true) {
		if (carry == true) { bb = '1'; carry = false; }
		else { bb = '0'; }
		if (s1_i < s1_mx) { bb += str1.at(s1_i) - '0'; }
		if (s2_i < s2_mx) { bb += str2.at(s2_i) - '0'; }
		if (bb > '9') { bb -= 10; carry = true; }
		result += bb;
		s1_i++; s2_i++;
	}

	reverse(result.begin(), result.end());
	return result;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long long key;
	int num;
} data;

void merge_sort(data x[], int n)
{
	static data y[200001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, M, B[100001];
	long long A[100001], C[100001];
	scanf("%d %d", &N, &M);
	for (i = 0; i < N; i++) scanf("%lld", &(A[i]));
	for (i = 0; i < M; i++) scanf("%d %lld", &(B[i]), &(C[i]));
	
	data X[200001];
	for (i = 0; i < N; i++) {
		X[i].key = A[i];
		X[i].num = 1;
	}
	for (i = 0; i < M; i++) {
		X[N+i].key = C[i];
		X[N+i].num = B[i];
	}
	merge_sort(X, N + M);
	
	int count = N;
	long long sum = 0;
	for (i = N + M - 1; i >= 0; i--) {
		if (count <= X[i].num) {
			sum += X[i].key * count;
			break;
		} else {
			sum += X[i].key * X[i].num;
			count -= X[i].num;
		}
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 8320
N = int(input()) 
A =  [int(x) for x in input().split()]
B =  [[0 for i in range(2)] for j in range(N)]
for i in range(N):
    B[i][0]=A[i]
    B[i][1]=i+1

B.sort()
for i in range(N):
    if i != N-1:
        print(B[i][1], end=" ")
    else:
        print(B[i][1], end="")

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

int main(){

  long long int n;

  while(cin >> n, n){
    int count = 0;
    while(1){
      if(n == 1) break;
      if(n%2 == 0){
	n = n/2;
	count++;
      }
      else if(n%2 == 1){
	n = n*3 + 1;
	count++;
      }
    }

    cout << count << endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void)


{


int a,b,c,x;


scanf("%d %d %d",&a,&b,&c);


if(a>b){


x=a;


a=b;


b=x;


}


if(a>c){


x=a;


a=c;


c=x;


}


if(b>c){


x=b;


b=c;


c=x;


}


printf("%d %d %d\n",a,b,c);


return 0;


}

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

int main(){
  int n,m,c;
  cin>>n>>m>>c;
  int b[m],a[n][m];
  int i,j,keep,ans=0;
  for(i=0;i<m;i++){
    cin>>b[i];
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  for(i=0;i<n;i++){
    keep=c;
    for(j=0;j<m;j++){
      keep+=a[i][j]*b[j];
    }
    if(keep>0)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll A[200010];
ll B[200010];

ll C[200010];
ll D[200010];

int main(){
   ll N,M,K;
   cin >> N >> M >> K;
   rep(i,N){
      cin >> A[i];
      C[i+1] = C[i] + A[i];
   }
   rep(i,M){
      cin >> B[i];
      D[i+1] += D[i] + B[i];
   }

   ll ans = 0;

   rep(i,N+1){
      ll l = 0,r = M+1;
      while(r-l > 1){
         ll mid = (r+l)/2;
         if(C[i] + D[mid] > K) r = mid;
         else l = mid;
      }
      if(C[i] + D[l] <= K) ans = max(ans,i+l);
   }

   cout << ans << endl;
}

Measured memory_bytes: 9884
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
using namespace std;

int main(){
    string S;
    cin >> S;
    int si = S.size();
    for (int i = 0; i < si; i++){
        S = S.substr(0, S.size() - 2);
        int j = 0;
        while (true){
            if (S.at(j) != S.at(j + S.size() / 2)){
                break;
            }
            else{
                if (j == S.size() / 2 - 1){
                    cout << (j+1) * 2 << endl;
                    return 0;
                }
            }
            j++;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 3000

int main(){
  int x[N],y[N],cnt=0,i;
  for(i=0;i<N;i++){
    scanf("%d %d",&x[i],&y[i]);
    if(x[i]==0 && y[i]==0) break;
    cnt++;
  }
  for(i=0;i<cnt;i++){
    if(x[i]<y[i] || x[i]==y[i]){
      printf("%d %d\n",x[i],y[i]);
    }
    else printf("%d %d\n",y[i],x[i]);
  }
  return 0;
}


Measured memory_bytes: 2040
#define _CRT_SECURE_NO_WARNINGS
 
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>
 
using std::endl;
using std::string;
 
#define ll long long int
#define LEP(a, n) for(ll a = 0; a < n; ++a)
#define INF 123456789012345
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std
 
ll N, X, ans = 0;
ll data[123];
 
int main()
{
	IN >> N >> X;
	LEP(a, N)
	{
		IN >> data[a];
	}
 
	std::sort(data, data + N);
 
	LEP(a, N - 1)
	{
		X -= data[a];
		if (X < 0)
		{
			break;
		}
		ans++;
	}
 
	if (X == data[N - 1])ans++;
 
	OUT << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
/*
Contest: NOMURA Programming Competition 2020
Problem: nomura2020 A
Author: tzc_wk
Time: 2020.5.30
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y1010101010101
#define y0			y0101010101010
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int x1=read(),y1=read(),x2=read(),y2=read(),k=read();
signed main(){
	cout<<(x2-x1)*60+(y2-y1)-k<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> k(M), p(M);
  vector<vector<int>> s(M, vector<int>(0));
  for(int i = 0; i < M; i++){
    cin >> k.at(i);
    for(int j = 0; j < k.at(i); j++){
      int x;
      cin >> x;
      x--;
      s.at(i).push_back(x);
    }
  }
  for(int i = 0; i < M; i++){
    cin >> p.at(i);
  }
  int result = 0;
  for(int tmp = 0; tmp < (1<<N); tmp++){
    bitset<10> bit(tmp); // スイッチのon offパターン
    bool flag = true;
    for(int i = 0; i < M; i++){
      int counter = 0;
      for(int j = 0; j < s.at(i).size(); j++){
        if(bit.test(s.at(i).at(j))) counter++;
      }
      if(counter % 2 != p.at(i)){
        flag = false;
        break;
      }
    }
    if(flag) result++;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, const char * argv[]) {
	int n;
	int a, b, c;
	int count = 0;
	cin >> n;
	int p[n];

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

	for(int i=1; i<n-1; i++){
		a = p[i-1];
		b = p[i];
		c = p[i+1];
		if(a > b && b > c){
			count++;
		}
		if(a < b && b < c){
			count++;
		}
	}
	cout << count << endl;

	return 0;
}


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

int main(){
  double N, A;
  cin >> N;
  double Ans=0;
  for(int i=0; i<N; i++){
    cin >> A;
    Ans+=1/A;
  }
  cout << setprecision(10) << 1/Ans << endl;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

const long double eps = 1.0e-6; // 許容される誤差

long double mysqrtl(long double x) {
    long double a = sqrt((double) x); // 近似値
    do {
        a = (a + x / a) / 2.0L;
    } while (fabsl(x - a * a) > eps);
    return a;
}

void solve() {
    long double a, b, c;
    cin >> a >> b >> c;
    long double d = c - a - b;
    if (d >= 0 && 4 * a * b < pow(d, 2)) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    cout<<(x*min(k,n)+y*max(0,n-k))<<endl;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    s = S()
    t = S()

    r = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            r += 1

    return r


print(main())




Measured memory_bytes: 11352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
int n,x,y,z;
ll ans,f[N],g[N];
struct data{
	int x,y,z;
}a[N];
bool operator <(data a,data b){
	return a.x-a.y>b.x-b.y;
}
priority_queue<pair<int,data> > q;
int main(){
	x=read(); y=read(); z=read();
	n=x+y+z;
	for(int i=1;i<=n;i++){
		a[i].x=read(); a[i].y=read(); a[i].z=read();
	}
	sort(&a[1],&a[n+1]);
	//for(int i=1;i<=n;i++)cout<<a[i].x<<" "<<a[i].y<<" "<<a[i].z<<endl;
	for(int i=1;i<=x;i++){q.push(mp(a[i].z-a[i].x,a[i])); f[i]=f[i-1]+a[i].x;}
	for(int i=x+1;i<=n;i++){
		q.push(mp(a[i].z-a[i].x,a[i]));
		f[i]=f[i-1]+a[i].x;
		f[i]-=q.top().second.x; f[i]+=q.top().second.z; q.pop();
	}
	while(!q.empty())q.pop();
	for(int i=n;i>n-y;i--){q.push(mp(a[i].z-a[i].y,a[i])); g[i]=g[i+1]+a[i].y;}
	for(int i=n-y;i;i--){
		q.push(mp(a[i].z-a[i].y,a[i]));
		g[i]=g[i+1]+a[i].y;
		g[i]-=q.top().second.y; g[i]+=q.top().second.z; q.pop();
	}
	for(int i=x;i<=n-y;i++)ans=max(ans,f[i]+g[i+1]);
	//cout<<a[1].x<<" "<<f[1]<<" "<<g[2]<<endl;
	cout<<ans<<endl;	
}

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

int main() {
	int n;
	cin >> n;
	int a[2][n];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	int dp[2][n];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			if (i) {
				if (j) {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
				} else {
					dp[i][j] = dp[i - 1][j] + a[i][j];
				}
			} else {
				if (j) {
					dp[i][j] = dp[i][j - 1] + a[i][j];
				} else {
					dp[i][j] = a[i][j];
				}
			}
		}
	}
	cout << dp[1][n - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//    fl();
	long long a,b,k;
	scanf("%lld%lld%lld",&a,&b,&k);
	long long zero=0;
	if(a>=k)
		printf("%lld %lld\n",a-k,b);
	else if(a+b>=k)
		printf("%lld %lld\n",zero,a+b-k);
	else
		printf("%lld %lld\n",zero,zero);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
typedef long long ll;

int main() {
  int N; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  sort(A.begin(), A.end());
  ll ans = 0;
  ll s = accumulate(A.begin(), A.begin() + N / 2, 0LL);
  ll l = accumulate(A.begin() + N / 2, A.end(), 0LL);
  if (N & 1) {
    ans = 2 * (l - s) - A[N / 2] - A[N / 2 + 1];
    s += A[N / 2], l -= A[N / 2];
    ll tmp = 2 * (l - s) + A[N / 2 - 1] + A[N / 2];
    ans = max(ans, tmp);
  } else {
    ans = 2 * (l - s) + A[N / 2 - 1] - A[N / 2];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
    int n, num[100];
    int i;

    scanf("%d", &n);

    for(i=0;i<n;i++){
        scanf("%d", &num[i]);
    }

    for(i=n-1;i>0;i--){
        printf("%d ", num[i]);
    }
    printf("%d\n", num[0]);
    return 0;
}
    

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

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

using namespace std;
typedef long long ll;

int main() {
   int a, b, c, d;

   cin >> a >> b >> c >> d;
   if (abs(a - c) <= d) cout << "Yes" << endl;
   else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
   else cout << "No" << endl;
   return(0);
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    ans += (a[i] & 1);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3612
N,M,Q = map(int,input().split())
s = [[0 for j in range(501)] for i in range(501)]

for _ in range(M):
    L,R = map(int,input().split())
    s[L][R] += 1

for i in range(1,501):
    for j in range(1,501):
        s[i][j] += s[i-1][j] + s[i][j-1] - s[i-1][j-1]

for _ in range(Q):
    p,q = map(int,input().split())
    print(s[q][q]-s[p-1][q]-s[q][p-1]+s[p-1][p-1])


Measured memory_bytes: 13416
x = input().split()
a = x[0]
b = x[1]
if a == 'H' and b == 'H':
    print('H')
elif a == 'H' and b == 'D':
    print('D')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'D' and b == 'D':
    print('H')

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

int main(){
    int n,m,K;
    cin >> n >> m >> K;
    bool ok = false;
    for(int l=0;l<=m;l++){
        for(int k=0;k<=n;k++){
            if(k*m-2*k*l+n*l==K) ok = true;
        }
    }
    cout << (ok? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int x;
  cin>>x;
  x-=400;
  cout<<8 - x/200<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = (1<<s.size() - 1);
	ll ans = 0;
	for(int bit = 0; bit < n; bit++)
	{
		ll res = 0;
		vector<string> vec;
		string str = "";
		for(int i = 0; i < s.size(); i++)
		{
			str += s[i];
			if(bit & (1<<i)) 
			{
				vec.push_back(str);
				str = "";
			}
			
		}
		if(str.size() > 0)
		{
			vec.push_back(str);
			str = "";
		}
		for(int i = 0; i < vec.size(); i++)
		{
			res += stoll(vec[i]);
		}
		ans += res;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c; cin >>a >>b >>c;
  int ans;
  if (a==b) ans = c;
  else if (b==c) ans = a;
  else ans = b;
  
  cout <<ans <<endl;
  /*
  if (ans) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
  */
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			int[] x = Console.ReadLine().Split().Select(int.Parse).OrderBy(p => p).ToArray();
			int ans = 0;
			if (n < m) {
				int[] distance = new int[m - 1];
				for (int i = 0; i < m - 1; i++) {
					distance[i] = Math.Abs(x[i + 1] - x[i]);
				}
				distance = distance.OrderBy(p => p).ToArray();
				for (int i = 0; i < m - n; i++) {
					ans += distance[i];
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> t(N+1),x(N+1),y(N+1);
  t.at(0) = x.at(0) = y.at(0) = 0;
  for(int i=0;i<N;i++){
    cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
  }
  
  bool can = true;
  for(int i=0;i<N;i++){
    int dt = t.at(i+1) - t.at(i);
    int dist = abs(x.at(i+1) - x.at(i)) + abs(y.at(i+1) - y.at(i));
//    cout << "x" << x.at(i+1) << " : " << x.at(i) << endl;
//    cout << abs(x.at(i+1) - x.at(i)) << " : " << abs(y.at(i+1) - y.at(i)) << endl;
//    cout << dt << " : " << dist << endl;
    if(dt < dist) can = false;
    if(dt % 2 != dist % 2) can = false;
  }
  
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    int n;
    cin >> n;
    auto c = make_v(n, 3, 0);
    for (auto &&i : c) {
        for (auto &&j : i) {
            scanf("%d", &j);
        }
    }
    auto dp = make_v(n+1, 3, 0);
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if(j == k) continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + c[i-1][k]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 11136
fun main(args: Array<String>) {
    val x= readLine()!!.split(" ").map { it.toInt() }
    when{
        x[0]+x[1]>x[2]+x[3] -> println("Left")
        x[0]+x[1]<x[2]+x[3] -> println("Right")
        else                -> println("Balanced")
    }
}

Measured memory_bytes: 37900
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;
long long MOD;

using namespace std;

char str[105];

void solve()
{
    scanf("%s", str);
    int n = strlen(str);

    int i;
    for (i = 0; i < n; i++) {
        if (str[i] != str[n - 1 - i]) {
            printf("No\n"); return;
        }
    }
    int m = (n - 3) / 2;
    for (i = 0; i <= m; i++) {
        if (str[i] != str[m - i]) {
            printf("No\n"); return;
        }
    }
    printf("Yes\n");

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>

using namespace std;

const int MOD = 1000000007;

long long N;
long long dp[61][3];

long long search(int digit = 60, int prevDif = 0){
	if(prevDif < 0) return 0;
	if(digit < 0) return 1;
	if(dp[digit][prevDif] >= 0) return dp[digit][prevDif];
	long long res = 0;
	for(int add=0;add<=2;add++){
		int newDif = min<int>(2, 2 * prevDif + (N>>digit)%2 - add);
		res = (res + search(digit-1, newDif)) % MOD;
	}
	return dp[digit][prevDif] = res;
}

int main(){
	while(cin >> N){
		memset(dp, -1, sizeof(dp));
		cout << search() << endl;
	}
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    ll a, b;
    cin >> a >> b;

    if((a * b) % 2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

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

#define mask (0x7F)
int cnt[mask];

int main(){
  int n, i;
  while(n = getInt()){
    const int n2 = n / 2;
    memset(cnt, 0, sizeof(cnt));

    for(i = 0; i < n; i++){
      int a = getInt();
      if(++cnt[a & mask] > n2){
	printf("%d\n", a);
	for(++i; i < n; i++)
	  getInt();
	goto end;
      }
    }

    puts("NO COLOR");

  end:;
  }
  return 0;
}

Measured memory_bytes: 368