akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
  int N, M;
  char s[100][10] = {};//青いカード
  char t[100][10] = {};//赤いカード
  int i, j, k;
  int max = -1000;
  int count;
  int flag;

  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%s", &s[i][0]);
  }
  scanf("%d", &M);
  for(i = 0; i < M; i++){
    scanf("%s", &t[i][0]);
  }

  for(i = 0; i < N; i++){
    //高橋くんが言う文字列をs[i][]にする
    count = 0;
    for(j = 0; j < N; j++){
      //s[i][]とs[j][]が一致してるか確認
      flag = 1;
      for(k = 0; k < 10; k++){
        if(s[i][k] != s[j][k]){
          flag = 0;
          break;
        }
      }
      //ここでflag == 1ならば，s[i][]とs[j][]は一致
      if(flag == 1){
        count++;
      }
    }
    for(j = 0; j < M; j++){
      //s[i][]とt[j][]が一致してるか確認
      flag = 1;
      for(k = 0; k < 10; k++){
        if(s[i][k] != t[j][k]){
          flag = 0;
          break;
        }
      }
      //ここでflag == 1ならば，s[i][]とt[j][]は一致
      if(flag == 1){
        count--;
      }
    }
    if(count > max){
      max = count;
    }
  }

  for(i = 0; i < M; i++){
    //高橋くんが言う文字列をt[i][]にする
    count = 0;
    for(j = 0; j < N; j++){
      //t[i][]とs[j][]が一致してるか確認
      flag = 1;
      for(k = 0; k < 10; k++){
        if(t[i][k] != s[j][k]){
          flag = 0;
          break;
        }
      }
      //ここでflag == 1ならば，t[i][]とs[j][]は一致
      if(flag == 1){
        count++;
      }
    }
    for(j = 0; j < M; j++){
      //t[i][]とt[j][]が一致してるか確認
      flag = 1;
      for(k = 0; k < 10; k++){
        if(t[i][k] != t[j][k]){
          flag = 0;
          break;
        }
      }
      //ここでflag == 1ならば，t[i][]とt[j][]は一致
      if(flag == 1){
        count--;
      }
    }
    if(count > max){
      max = count;
    }
  }

  if(max < 0){
    max = 0;
  }

  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define inf 2000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;		
			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			ll n,k;
			cin>>n;

			if(n%2==0)
			{
				cout<<-1<<endl;
				return 0;
			}
			ll x=0;
			ll count=0;
			while(count<=1e6)
			{
				x=(x*10+7)%n;
				
				if(x==0)
				{
					cout<<count+1<<endl;
					return 0;
				}
				count+=1;
			}
			cout<<-1;
			
			
		
			return 0;
		 }	




Measured memory_bytes: 3656
S = input()
out = "Yes"
for i, char in enumerate(S):
    if (i + 1) % 2 == 0 and char != "L" and char != "U" and char != "D":
        out = "No"
        break
    elif (i + 1) % 2 == 1 and char != "R" and char != "U" and char != "D":
        out = "No"
        break
print(out)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int solve(string const & s, int k) {
    int n = s.length();
    auto dp = vectors(n + 1, n + 1, k + 1, int());
    REP (l, n) {
        REP (i, k + 1) {
            dp[l][l + 1][i] = 1;
        }
    }
    REP3 (len, 2, n + 1) {
        REP (l, n - len + 1) {
            int r = l + len;
            REP (i, k + 1) {
                int & it = dp[l][r][i];
                if (s[l] == s[r - 1]) {
                    chmax(it, dp[l + 1][r - 1][i] + 2);
                }
                if (i - 1 >= 0) {
                    chmax(it, dp[l + 1][r - 1][i - 1] + 2);
                }
                chmax(it, dp[l + 1][r][i]);
                chmax(it, dp[l][r - 1][i]);
                if (i - 1 >= 0) {
                    chmax(it, dp[l][r][i - 1]);
                }
            }
        }
    }
    return dp[0][n][k];
}

int main() {
    string s; cin >> s;
    int k; cin >> k;
    cout << solve(s, k) << endl;
    return 0;
}


Measured memory_bytes: 110336
use std::io::Read;

const GETA: usize = 4000;

fn calc(a: &[char], b: &[char]) -> Vec<bool> {
    let mut res = vec![true; 2 * GETA];
    for (i, res) in res.iter_mut().enumerate() {
        let l = std::cmp::max(i, GETA);
        let r = std::cmp::min(i + b.len(), GETA + a.len());
        if l >= r {
            continue;
        }
        if i >= GETA {
            *res = a[(i - GETA)..]
                .iter()
                .zip(b.iter())
                .all(|(a, b)| *a == *b || *a == '?' || *b == '?');
        } else {
            *res = a.iter()
                .zip(b[(GETA - i)..].iter())
                .all(|(a, b)| *a == *b || *a == '?' || *b == '?');
        }
    }
    res
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let a: Vec<char> = it.next().unwrap().chars().collect();
    let b: Vec<char> = it.next().unwrap().chars().collect();
    let c: Vec<char> = it.next().unwrap().chars().collect();
    let ab = calc(&a, &b);
    let ac = calc(&a, &c);
    let bc = calc(&b, &c);
    let mut ans = 6000;
    for (i, _) in ab.iter().enumerate().filter(|p| *p.1) {
        for (j, _) in ac.iter().enumerate().filter(|p| *p.1) {
            if *bc.get(j - i + GETA).unwrap_or(&false) {
                use std::cmp::*;
                let l = min(GETA, min(i, j));
                let r = max(GETA + a.len(), max(i + b.len(), j + c.len()));
                ans = min(r - l, ans);
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>

int n,i;
char mozi[6];
int me;

int main(){

int sum,
	saikoro1,
	saikoro2,
	saikoro3;
	
while(1){
	scanf("%d",&n);
	if(n==0)break;

	saikoro1 = 1;
	saikoro2 = 2;
	saikoro3 = 3;
	sum = saikoro1;
	for(i=0;i<n;i++){
		scanf("%s",mozi);
		if(strcmp("North",mozi)==0){
			me = 7 - saikoro1;
			saikoro1 = saikoro2;
			saikoro2 = me;
		}
		if(strcmp("East",mozi)==0){
			me = 7-saikoro3;
			saikoro3 = saikoro1;
			saikoro1 = me;
		}
		if(strcmp("West",mozi)==0){
			me = 7-saikoro1;
			saikoro1 = saikoro3;
			saikoro3 = me;
		}
		if(strcmp("South",mozi)==0){
			me = 7-saikoro2;
			saikoro2 = saikoro1;
			saikoro1 = me;
		}
		if(strcmp("Right",mozi)==0){
			me = 7-saikoro2;
			saikoro2 = saikoro3;
			saikoro3 = me;
		}
		if(strcmp("Left",mozi)==0){
			me = 7 - saikoro3;
			saikoro3 = saikoro2;
			saikoro2 = me;
		}
		sum +=saikoro1;
	}
	printf("%d\n",sum);
}
return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);

typedef pair<int, int> p;

int dp[101][101][401];

int main(){
  int n, max_w;
  scanf("%d %d", &n, &max_w);

  vector<p> v(n + 1);
  v[0] = make_pair(0, 0);
  int a, b, d;
  FOR (i, 1, n  + 1) {
    scanf("%d %d", &a, &b);
    if (i == 1) d = a - 1;
    v[i] = make_pair(a - d, b);
  }

  REP (i, n + 1) {
    REP (j, n + 1) {
      REP (k, n * 4 + 1) {
        dp[i][j][k] = 0;
      }
    }
  }

  FOR (i, 1, n + 1) {
    FOR (j, 1, n + 1) {
      FOR (k, 1, n * 4) {
        if (0 <= k - v[i].first && k <= (LL)max_w - (LL)j * (LL)d) {
          dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - v[i].first] + v[i].second);
        }
        else dp[i][j][k] = max({dp[i - 1][j][k], dp[i][j - 1][k], dp[i][j][k - 1]});
      }
    }
  }

  cout << dp[n][n][n * 4 - 1] << endl;
}


Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1e3 + 10;
vector<ll> graph[MAXN];
ll level[MAXN];
bool visit[MAXN];
ll par[MAXN];
vector<ll> ans_v;
map<pair<ll,ll>,ll> check;

void solve(){
    ll n,m; cin>>n>>m;

    FOR(i,1,m){
        ll u,v; cin>>u>>v;
        graph[u].push_back(v);
        check[{u,v}] = i;
    }

    ll ans = 1e10;

    FOR(i,1,n){

        FOR(i,1,n) level[i] = 0,par[i] = 0;
        ll s = i;

        queue<ll> q;
        ll las = -1;

        q.push(s);
        level[i] = 1;
        ll ans_ = 1e10;
        while(!q.empty()){
            ll u = q.front(); q.pop();

            for(ll v:graph[u]){
                if(v == s){
                    ans_ = min(ans_,level[u]);
                    las = u;
                    goto xx;
                }
                if(level[v] == 0){
                    par[v] = u; 
                    q.push(v);
                    level[v] = level[u] + 1;
                }
            }
        }

        xx:
        if(ans_ < ans){
            ans_v.clear();
            ll node = las;
            ans_v.push_back(las);
            while(las != s){
                las = par[las];

                ans_v.push_back(las);
            }
            ans = ans_;
        }
    }

    if(ans >= 1e9){
        cout<<-1<<endl;
        return;
    }
    cout<<ans_v.size()<<endl;

    reverse(all(ans_v));
    for(ll i=0;i<ans_v.size();i++){
        cout<<ans_v[i]<<endl;
    }

}
 
signed main(){
 
   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

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

		double x1,x2,y1,y2;

		x1 = sc.nextDouble();
		y1 = sc.nextDouble();
		x2 = sc.nextDouble();
		y2 = sc.nextDouble();

		double kyori =Math.pow(Math.abs(x1 - x2),2) + Math.pow(Math.abs(y1 - y2),2);

		System.out.print(Math.sqrt(kyori));

		sc.close();

	}

}


Measured memory_bytes: 27964
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vector<pii> R(N);
  rep(i, 0, N) {
    int x, l;
    cin >> x >> l;
    R[i] = {x + l, x - l};
  }
  sort(all(R));
  int ans = 0;
  int r = -INF;
  rep(i, 0, N) {
    if (r <= R[i].second) {
      r = R[i].first;
      ans++;
    }
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 1920
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(18);

	ll n, k;
	ll d;
	ll a;
	cin >> n >> k;

	vector<bool> t(n);
	ll ans = 0;

	rep(i, k)
	{
		cin >> d;
		rep(j, d)
		{
			cin >> a;
			t[a - 1] = true;
		}
	}

	rep(i, n)
	{
		if (!t[i])
			ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    A = [list(map(int,input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    # print(A)
    # print(B)
    # N, M = map(int, input().split())
    # A = list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            for b in B:
                if A[i][j] == b:
                    A[i][j] = 0
    # print(A)
    bingo1 = (A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0) or (A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0) or (A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0)
    bingo2 = (A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0) or (A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0) or (A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0)
    bingo3 = (A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0) or (A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0)
    # print(bingo1)
    print("Yes" if (bingo1 or bingo2 or bingo3) else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for a in range(0, min(A + 1, X // 500 + 1)):
    for b in range(0, min(B + 1, (X - a*500)//100 + 1)):
        if ((X - a*500 - b*100) % 50) == 0 and ((X - a*500 - b*100) // 50) <= C:
            count += 1

print(count)


Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (n, d) = readLine()!!.split(' ').map { it.toInt() }
    var ans = 0
    repeat(n) {
        val (x, y) = readLine()!!.split(' ').map { it.toDouble() }
        if ( Math.sqrt(x*x + y*y) <= d.toDouble() ) ans++
    }
    println(ans)

}


Measured memory_bytes: 63096
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	string S;
	cin >> S;
	if (S.size() < 4 || S.substr(0, 4) != "YAKI") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

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

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int count=0;
  for(int i=a;i<=b;i++)
  {
    if(i%c==0)
      count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3680
import java.util.Scanner;

class BinaryIndexTree {
    final int n;
    final long[] bit;
    public BinaryIndexTree(int n) {
        this.n = n;
        int size = Integer.highestOneBit(n) << 1;
        bit = new long[size + 1];
    }
    long sum(int i) {
        long s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    void add (int i, long x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
}
public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        char[] chars = new char[n + 1];
        BinaryIndexTree[] binaryIndexTrees = new BinaryIndexTree[26];
        for (int i = 0; i < 26; ++i) {
            binaryIndexTrees[i] = new BinaryIndexTree(n);
        }
        for (int i = 0; i < n; ++i) {
            int current = s.charAt(i) - 'a';
            chars[i + 1] = s.charAt(i);
            binaryIndexTrees[current].add(i + 1, 1);
        }
        int query = scanner.nextInt();
        for (int i = 0; i < query; ++i) {
            int type = scanner.nextInt();

            if (type == 1) {
                int a = scanner.nextInt();
                int newChar = scanner.next().charAt(0) - 'a';
                int oldChar = chars[a] - 'a';
                binaryIndexTrees[oldChar].add(a, -1);
                binaryIndexTrees[newChar].add(a, 1);
                chars[a] = (char)(newChar + 'a');
            } else if (type == 2) {
                int l = scanner.nextInt();
                int r = scanner.nextInt();
                int diff = 0;
                for (int j = 0; j < 26; ++j) {
                    long rSum = binaryIndexTrees[j].sum(r);
                    long lSum = binaryIndexTrees[j].sum(l - 1);
                    if (rSum > lSum) {
                        ++diff;
                    }
                }
                System.out.println(diff);
            }
        }
    }
}


Measured memory_bytes: 223124
s=str(input())
s=list(s)
for i in range(0,len(s)):
  if i%2==0:
    if s[i]!="R" and s[i]!="U" and s[i]!="D":
      print("No")
      break
  else:
    if s[i]!="L" and s[i]!="U" and s[i]!="D":
      print("No")
      break
else:
  print("Yes")


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

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

	int i;
	int result;
	int a_score = 0;
	int b_score = 0;
	char a_card[100];
	char b_card[100];
	for (i = 0; i < n; i++)
	{
		scanf("%s %s", a_card, b_card);

		result = strcmp(a_card, b_card);
		if (result == 0)
		{
			a_score += 1;
			b_score += 1;
		}
		if (result > 0)
		{
			a_score += 3;
		}
		if (result < 0)
		{
			b_score += 3;
		}
	}
	printf("%d %d\n", a_score, b_score);

	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int n, m;
    long long int a[300010], b[300010];
    map<long long int, long long int> mp;

    cin >> n;

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

    cin >> m;

    for (int i = 0; i < m; i++) cin >> b[i];

    sort(b,b+m);

    for (int i = 0; i < m; i++) {
        if (mp[b[i]] == 0) {
            cout << "NO" << endl;
            return (0);
        }
        else {
            mp[b[i]] = mp[b[i]]-1;
        }
    }

    cout << "YES" << endl;

}


Measured memory_bytes: 17280
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <iostream>
#include <cstring>
#include <cstdio>


#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define f(n) for (ll i = 0; i < n; i++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vi nums(n);
	f(n) cin >> nums[i];
	int x = 0;
	for (int i = 1; i < n - 1; i++)
	{
		if (min(nums[i - 1], min(nums[i], nums[i + 1])) != nums[i] && max(nums[i - 1], max(nums[i], nums[i + 1])) != nums[i]) x++;
	}
	cout << x << '\n';
}


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

int n, a[300000], s[300000], q, x, y, c;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]), s[i] = a[i];
  sort(s, s+n);
  for (int i = 0; i < n; i++) if (s[i] != a[i]) c++;
  scanf("%d", &q);
  if (c == 0) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &x, &y);
    x--; y--;
    if (s[x] != a[x]) c--;
    if (s[y] != a[y]) c--;
    swap(a[x], a[y]);
    if (s[x] != a[x]) c++;
    if (s[y] != a[y]) c++;
    if (c == 0) {
      printf("%d\n", i+1);
      return 0;
    }
  }
  printf("-1\n");
}



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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
    int k,n;
    cin>>k>>n;
    int arr[n];
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }

    int ans = inf;
    for(int i = 0;i<n;i++){
        if(i==0||i==n-1){
            if(i==0){
                ans = min(ans, k - (k - arr[n-1] + arr[i]));
                ans = min(ans, k - arr[i+1] + arr[i]);
            }else{
                ans = min(ans, k - arr[i] + arr[i-1]);
                ans = min(ans, arr[n-1] - arr[0]);
            }
        }else{
            ans = min(ans, k - arr[i] + arr[i-1]);
            ans = min(ans, k - arr[i+1] + arr[i]);
        }
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N, K;
    cin >> N >> K;
    int height, j = 0;
    Fp(i, 0, N){
        cin >> height;
        if(height >= K) j++;
    }
    cout << j << endl;
}


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

int main(void) {
	int A, B;
	scanf("%d%d", &A, &B);
	int ans = 0;
	for (int i = 0; i < 2; i++) {
		if (A >= B) {
			ans += A;
			A--;
		} else {
			ans += B;
			B--;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3820
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  ll n;
  cin >> n;
  vector<ll> h(n);
  rep(i, n) {
    cin >> h[i];
  }
  map<ll, ll> l, r;
  rep(i, n) {
    l[i-h[i]]++;
    r[i+h[i]]++;
  }
  ll ans = 0;
  for (auto p : l) {
    ans += p.second * r[p.first];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 39004
#include <iostream>
#include <cmath>
#include <functional>
#include <algorithm>
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
 
using namespace std;
 
int main() {
    int N, H, a[100000], b[100000];
    cin >> N >> H;
    REP(i, N) cin >> a[i] >> b[i];
 
    int a_max = *max_element(a, a + N);
    sort(b, b + N, greater<int>());
 
    int ans = 0, i = 0;
    while (H > 0) {
        if (b[i] > a_max) {
            H -= b[i];
            ans++;
        }
        else break;
        i++;
    }
    if (H <= 0) {
        cout << ans << endl;
        return 0;
    }
    ans += ceil((double)H / a_max);
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
*P, = map(int, input().split())

N += 1
data = [0]*(N+1)
def add(k, x):
    while k <= N:
        data[k] += x
        k += k & -k

def get(k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s

N0 = 2**(N-1).bit_length()
def lower_bound(x):
    w = i = 0
    k = N0
    while k:
        if i+k <= N and w + data[i+k] <= x:
            w += data[i+k]
            i += k
        k >>= 1
    return i+1

E = [(v, i) for i, v in enumerate(P)]
E.sort(reverse=1)

add(1, 1)
add(N+1, 1)

ans = 0
for v, i in E:
    k = get(i+2)
    l1 = lower_bound(k-2)
    l0 = lower_bound(k-1)
    r0 = lower_bound(k)
    r1 = lower_bound(k+1)
    if l0 > 1:
        ans += (l0-l1) * (r0 - (i+2)) * v
    if r0 < N+2:
        ans += (r1-r0) * (i+2 - l0) * v
    add(i+2, 1)
print(ans)

Measured memory_bytes: 62956
N = int(input())
T = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for i in range(N)]
dp[0] = T[0]
for i in range(1,N):
  for j in [0,1,2]:
    dp[i][j] = max([dp[i-1][j1]+T[i][j] for j1 in [0,1,2] if j1 != j])
print(max(dp[N-1]))

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<int> L( N );
	for( auto& v: L ) { cin >> v; }

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

	int result = 0;
	for( int i = 0; i < N-2; ++i ) {
		int a = L[i];
		int b = 0;
		int c = 0;

		for( int j = i+1; j < N-1; ++j ) {
			b = L[j];

			for( int k = j+1; k < N; ++k ) {
				c = L[k];

				if( c >= a+b ) { break; }

				result += 1;
			}
		}
	}

	cout << result << endl;
	return 0;
}


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

int main()
{
    int i,j,m,n;
    int a[13];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    int p=0;
    int sum=1;
    for(i=0;i<n;i++)
    {
        if(a[i]%2==0) p=2;
        else p=1;
        sum*=p;
    }
    cout<<pow(3,n)-sum<<endl;
    return 0;
}

Measured memory_bytes: 640
import collections
n, k = map(int, input().split())
d = collections.defaultdict(int)
b = map(int, input().split())
for e in b:
    d[e] += 1
ret = 0
a = sorted([v for v in d.values()], reverse = True)
while len(a) > k:
    ret  += a.pop()
print(ret)

Measured memory_bytes: 41504
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;

int main(){
  ll n;cin >> n;
  map<ll,ll> l;
  rep(i,n){
    ll num;cin >> num;
    l[num]++;
  }
  vector<ll> v;
  for(auto p : l ){
    v.push_back(p.first);
  }
  ll ans = 0;
  for(ll i=0;i<(ll)v.size()-2;++i){
    for(ll j=i+1;j<(ll)v.size()-1;++j){
      for(ll k=j+1;k<(ll)v.size();++k){
        if( v.at(i)+v.at(j) > v.at(k) ){
          ans += l[v.at(i)]*l[v.at(j)]*l[v.at(k)];
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{  ios::sync_with_stdio(false);
   cin.tie(0);  
   int n,k;
   cin>>n>>k;
   vector<int>v(n);
   for(int i=0;i<n;i++) cin>>v[i];
    int dp[n];
    for(int i=1;i<n;i++) dp[i]=INT_MAX;
    dp[0]=0;
     for(int i=1;i<n;i++){
         for(int j=1; (i-j)>=0 && j<=k ;j++){
            dp[i]=min(dp[i],abs(v[i]-v[i-j])+dp[i-j]);
         }
     }
     cout<<dp[n-1];
     return 0;
}


Measured memory_bytes: 3940
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
      int Count5=0;
      int Count7=0;

             //配列の宣言
       int array[] = new int[5];
      for(int i=0;i<3;i++){
        array[i]=sc.nextInt();
        if (array[i]==5){
          Count5++;
        }else if (array[i]==7){
          Count7++;
        }
      }

		// 出力
      if (Count5==2&&Count7==1){
		System.out.println("YES");
      }else{
		System.out.println("NO");
      }
   }
}

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

int main(){
    unsigned long N, Q;
    cin >> N >> Q;
    vector<unsigned long> A(N), S(N), X, a;
    for(auto& i : A)cin >> i;
    partial_sum(A.rbegin(), A.rend(), S.begin());
    for(unsigned long i{(N + 1) / 2}, s{0}; i--; s += A[N - i * 2 - 1])a.push_back(S[i] + s);
    for(unsigned long i{(N + 1) / 2}; --i;)X.push_back(A[N - i - 1] + A[N - i * 2 - 1]);
    for(unsigned long i{0}, x; i < Q; ++i){
        cin >> x;
        cout << a[lower_bound(begin(X), end(X), x * 2) - begin(X)] << endl;
    }
    return 0;
}

Measured memory_bytes: 4216
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
using i64 = int64_t;
int all = 7;
int bit(char c) {
    switch (c) {
        case 'R':
        return 1;
        case 'G':
        return 2;
        case 'B':
        return 4;
    }
    return 0;
}
const i64 mod = 998244353;
string s;
i64 n;
vector<int> cs;
int main() {
    cin >> n >> s;
    cs.assign(3 * n, 0);
    for (int i = 0; i < 3 * n; ++i) cs[i] = bit(s[i]);
    i64 ans = 1;
    vector<i64> cnt(8);
    for (int c : cs) {
        int co = all & ~c;
        if (cnt[co] > 0) {
            (ans *= cnt[co]) %= mod;
            cnt[co]--;
        } else {
            bool f = false;
            for (int d = 1; d < 8; d <<= 1) {
                if (d != c && cnt[d] > 0) {
                    (ans *= cnt[d]) %= mod;
                    cnt[c | d]++;
                    cnt[d]--;
                    f = true;
                }
            }
            if (!f) {
                cnt[c]++;
            }
        }
    }
    for (i64 x = 1; x <= n; ++x) (ans *= x) %= mod;
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define nl '\n'
#define tez ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

signed main()
{
	tez
	char c;
	cin >> c;
	if(c=='A')cout<<'T';
	if(c=='T')cout<<'A';
	if(c=='C')cout<<'G';
	if(c=='G')cout<<'C';
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    /*
    1 2
    1 3
    1 4
    2 3
    2 4
    3 4
    */
    vector<int> p = { 0, 1, 2, 3 };
    vector<vector<bool>> links(4, vector<bool>(4, false));

    for (size_t i = 0; i < 3; i++) {
        int a, b;
        cin >> a >> b;
        links[a - 1][b - 1] = true;
        links[b - 1][a - 1] = true;
    }

    bool allok = false;
    do {
        bool ok = true;
        for (size_t i = 0; i < p.size() - 1; i++) {
            if (!links[p[i]][p[i + 1]]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            allok = true;
        }
    } while (next_permutation(p.begin(), p.end()));

    cout << (allok ? "YES" : "NO")
         << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, k) = get!(i64, i64);
    let mut ans = 0;
    if k == 0 {
        println!("{}", n * n);
        return;
    }
    for i in 1..n + 1 {
        if i < k {
            continue;
        }
        let a = (n / i) * (i - k);
        let mut b = (n % i) - (k - 1);
        if b < 0 {
            b = 0;
        }
        //eprintln!("a: {}, b: {}", a, b);
        ans += a + b;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
z[4000],*a=z,*b=z+2000,m,i,j;main(n){for(;!scanf("%d",&n)|n;m=!printf("%d\n",m))for(i=++n;i--;j=a,a=b,b=j)for(j=n;j--;)m=fmax(m,b[j]=n+~i&&getchar()>45?1+fmin(fmin(b[j+1],a[j+1]),a[j]):0);}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] ABC = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long sum = 0;
           for(int j = 1; j < 1000; j++)
            {
                sum = ABC[0] * j;
                if (sum % ABC[1] == ABC[2])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


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

int main()
{
  int n;
  char s1[100] = "", s2[100] = "";
  cin >> n;
  if (n % 2)
  {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < n / 2; i++)
  {
    cin >> s1[i];
  }
  for (int i = 0; i < n / 2; i++)
  {
    cin >> s2[i];
  }
  if (strcmp(s1, s2))
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ld r;
    cin>>r;
    cout<<fixed<<setprecision(12)<<(2*3.14159265358979323846*r);



    return 0;
}

Measured memory_bytes: 3808
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    for a in A:
        if a%2==0 and not (a%3==0 or a%5==0):
            print("DENIED")
            return
    print("APPROVED")
if __name__ == '__main__':
    main()

Measured memory_bytes: 6668
from collections import Counter

n = int(input())
list_A = list(map(int, input().split()))
L, R = [], []

for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

A = Counter(L)
A = sorted(A.items(), key=lambda x:x[1], reverse=True)
A.append((-1, 0))

B = Counter(R)
B = sorted(B.items(), key=lambda x:x[1], reverse=True)
B.append((-1, 0))

if A[0][0] != B[0][0]:
    print(n - A[0][1] - B[0][1])
else:
    print(min(n - A[1][1] - B[0][1], n - A[0][1] - B[1][1]))


Measured memory_bytes: 25980
#include <bits/stdc++.h>
using namespace std;
#define pi 3.141592654
#define EPS 1e-9
#define forr(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a; i<=b;i++)
#define clr(x, val) memset(x, val, sizeof(x))
set<char> st;
int cnt[26];
int main(){


    int n;
    cin >> n;
    signed int arr[n];
    forr(i,0,n)
    {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    int s = arr[0];
    int e= arr[n-1];
    int sum=0,mini=INT_MAX;
    for(int i=s; i<=e; i++)
    {
       sum=0;
        for(int j=0; j<n; j++)
        {
            sum += ((arr[j]-i)*(arr[j]-i));
        }
        mini = min(mini,sum);
    }

    cout << mini ;
    return 0;

}


Measured memory_bytes: 256
n = int(input())
lis = [0]*(n+1)
for i in range(2,n+1):
    j = 1
    while i*j <= n:
        lis[i*j] += 1
        j += 1
ans = 0
for i in range(2,n+1):
    ans += (lis[i]+1)*i
print(ans+1)

Measured memory_bytes: 145616
#include<iostream>
using namespace std;
int main()
{
    int  x,y;
    cin>>x>>y;
    long long  sum=0;
    for(int i=y+1; i<=x; i++)
    {
        sum=sum+(i-y)*(x/i);
        if(x%i-y>=0)
            sum=sum+1+x%i-y;
    }
    if(y==0)
        sum=sum-x;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
# E - Count Median
def main():
    N, *AB = map(int, open(0).read().split())
    A, B = AB[::2], AB[1::2]
    A.sort(), B.sort()
    mid = N // 2
    if N % 2:
        print(B[mid] - A[mid] + 1)
    else:
        print((B[mid] + B[mid - 1]) - (A[mid] + A[mid - 1]) + 1)


if __name__ == "__main__":
    main()


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

struct node
{
	int nKey;
	struct node* pNext, *pPrev;
};

typedef struct node Node;

Node* pNul;

void Init()
{
	pNul = (Node*)malloc(sizeof(Node));
	pNul->pNext = pNul;
	pNul->pPrev = pNul;
}

void insert(int key)
{
	Node* pCur = (Node*)malloc(sizeof(Node));
	pCur->nKey = key;
	pCur->pNext = pNul->pNext;
	pCur->pNext->pPrev = pCur;
	pCur->pPrev = pNul;
	pNul->pNext = pCur;
}

Node* listSearch(int key)
{
	Node* pCur = pNul->pNext;
	while (pCur->nKey != key && pCur != pNul)
	{
		pCur = pCur->pNext;
	}
	return pCur;
}

void printList()
{
	Node* pCur = pNul->pNext;
	int nIndex = 0;
	while (pCur != pNul)
	{
		if (0 != nIndex)
		{
			printf(" ");
		}
		printf("%d", pCur->nKey);
		++nIndex;
		pCur = pCur->pNext;
	}
	printf("\n");
}

void deleteNode(Node* p)
{
	if (p == pNul)
	{
		return;
	}
	p->pNext->pPrev = p->pPrev;
	p->pPrev->pNext = p->pNext;
	p->pNext = p;
	p->pPrev = p;
	free(p);
}

void deleteFirst()
{
	deleteNode(pNul->pNext);
}

void deleteLast()
{
	deleteNode(pNul->pPrev);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

int main()
{
	char cod[20];
	int nkey, n;
	scanf("%d", &n);
	Init();
	for (int i = 0; i < n; ++i)
	{
		scanf("%s", cod);
		if ('i' == cod[0])
		{
			scanf("%d", &nkey);
			insert(nkey);
		}
		else if (6 < strlen(cod))
		{
			if ('L' == cod[6])
			{
				deleteLast();
			}
			else if ('F' == cod[6])
			{
				deleteFirst();
			}
		}
		else
		{
			scanf("%d", &nkey);
			deleteKey(nkey);
		}
	}
	printList();
	return 0;
}


Measured memory_bytes: 32996
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
  i_str = str(i)
  i_sum = 0
  for j in i_str:
    i_sum += int(j)
  if A <= i_sum and i_sum <= B:
    ans += i
print(ans)

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

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

	for (int a = 1; a <= 3500; ++a) for (int b = 1; b <= 3500; ++b) {
		long long ts = 1LL * N * a * b;
		long long ms = 4LL * a * b - N * a - N * b;
		if (ms <= 0) continue;
		if (ts % ms) continue;
		ts /= ms;
		cout << a << ' ' << b << ' ' << ts << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
  
using namespace std;
  
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


int main(){
	
	int a,b;
	while(cin>>a>>b){
		const int N = 111;
		int sum[N]={0};
		
		sum[a]++; sum[b]++;
		
		while(cin>>a>>b){
			if(a==0)break;
			sum[a]++; sum[b]++;
		}
		
		bool ok = true;
		if(sum[1]%2!=1)ok=false;
		if(sum[2]%2!=1)ok=false;
		
		reps(i,3,N){
			if(sum[i]==0 || sum[i]%2==0){
			}else ok=false;
		}
		
		if(ok)puts("OK");
		else puts("NG");
	}
}

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

int main(void){
    string s;
    cin >> s;
    int cnt = 0;
    if (s[0] == '1') cnt++;
    if (s[1] == '1') cnt++;
    if (s[2] == '1') cnt++;

    cout << cnt << endl;


}

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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  for(int i = 0; i<k; i++){
    if(c>=a && a>=b) b*=2;
    else c*=2;
  }
  if(a<b && b<c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    dic={'A':'T','T':'A','G':'C','C':'G'}
    b=STR()
    print(dic[b])
if __name__ == '__main__':
    do()

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

using namespace std;

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

  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;
  uint64_t count = max(0, a[0] - x);
  a[0] = min(a[0], x);
  for (int i = 1; i < n; ++i) {
    int64_t diff = a[i] + a[i-1] - x;
    if (0 < diff) {
      count += diff;
      a[i] -= diff;
    }
  }
  cout << count << "\n";
}


Measured memory_bytes: 640
import java.util.Scanner;

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

		int roll = 0;
		if(dice2.top == dice1.south || dice2.top == dice1.north || dice2.top == dice1.bottom) {
			while(dice2.top != dice1.top && roll <= 4) {
				dice1.goNorth();
				roll++;
			}
			roll = 0;
			while(dice2.bottom != dice1.bottom && roll <= 4) {
				dice1.goNorth();
				roll++;
			}
		} else if(dice2.top == dice1.west || dice2.top == dice1.east) {
			roll = 0;
			while(dice2.top != dice1.top && roll <= 4) {
				dice1.goEast();
				roll++;
			}
			roll = 0;
			while(dice2.bottom != dice1.bottom && roll <= 4) {
				dice1.goEast();
				roll++;
			}
		}

		if(dice2.south == dice1.east || dice2.south == dice1.west || dice2.south == dice1.north ) {
			roll = 0;
			while(dice2.south != dice1.south && roll <= 4) {
				dice1.spin();
				roll++;
			}
			roll = 0;
			while(dice2.north != dice1.north && roll <= 4) {
				dice1.spin();
				roll++;
			}
		}

		if(dice2.top == dice1.top && dice2.south == dice1.south && dice2.east == dice1.east && dice2.west == dice1.west && dice2.north == dice1.north && dice2.bottom == dice1.bottom) {
			System.out.println("Yes");
		}  else {
			System.out.println("No");
		}




	}

	//dice?????£?????????
	int top;
	int south;
	int east;
	int west;
	int north;
	int bottom;


	//?????????????????????
	public Main(Scanner sc) {
		this.top = sc.nextInt();
		this.south = sc.nextInt();
		this.east = sc.nextInt();
		this.west = sc.nextInt();
		this.north = sc.nextInt();
		this.bottom = sc.nextInt();
	}


	//??¢?????????????????? ?????£??????????????\????????????
	//N??´?????¢??????
	public void goNorth() {
		int t = this.top;
		int s = this.south;
		int n = this.north;
		int b = this.bottom;

		this.top = s;
		this.south = b;
		this.north = t;
		this.bottom = n;
	}

	//S??´?????¢??????
	public void goSouth() {
		int t = this.top;
		int s = this.south;
		int n = this.north;
		int b = this.bottom;

		this.top = n;
		this.south = t;
		this.north = b;
		this.bottom = s;
	}

	//E??´?????¢??????
	public void goEast() {
		int t = this.top;
		int e = this.east;
		int w = this.west;
		int b = this.bottom;

		this.top = w;
		this.east = t;
		this.west = b;
		this.bottom = e;
	}

	//W??´?????¢??????
	public void goWest() {
		int t = this.top;
		int e = this.east;
		int w = this.west;
		int b = this.bottom;

		this.top = e;
		this.east = b;
		this.west = t;
		this.bottom = w;
	}

	//dice????????¢??????
	public void spin() {
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;


		this.south = w;
		this.east = s;
		this.west = n;
		this.north = e;

	}

}

Measured memory_bytes: 26328
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        nw: usize,
        a: [[usize; 2]; n],
    };

    let mut dp = vec![vec![0; nw+1]; n+1 ];

    for i in 0..n {
        for w in 0..nw+1 {

            if (w as i64)- (a[i][0] as i64) >= 0 {
                dp[i+1][w] = max(dp[i+1][w], dp[i][w-a[i][0]] + a[i][1]);
            } 

            dp[i+1][w] = max(dp[i+1][w], dp[i][w]);
        }
    }
    println!("{}", dp[n][nw]);
}


Measured memory_bytes: 106748