akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int a[111];
int b[111];
int c[111];
int d[111];
int n;

int R[111];
int B[111];
vector<int> E[111];
int vis[111];
bool match(int x){
    vis[x] = 1;
    for(auto y : E[x]) {
        if (B[y] == -1 || (!vis[B[y]] && match(B[y]))){
            R[x] = y;
            B[y] = x;
            return true;
        }
    }
    return false;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d%d",&c[i],&d[i]);
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if (a[i] < c[j] && b[i] < d[j]){
                E[i].push_back(j);
            }
        }
    }
    fill(R,R+n,-1);
    fill(B,B+n,-1);
    int ans = 0;
    for(int i=0;i<n;i++){
        fill(vis, vis+n, 0);
        if(match(i))ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
import sys

x, n = map(int, input().split())

p = list(map(int, input().split()))
s = set(p)

best_diff = 10000000
best_a = -2
for a in range(-5, 1000):
	if not a in p:
		diff = abs(x - a)
		if diff < best_diff:
			best_diff = diff
			best_a = a

print(best_a)

Measured memory_bytes: 61772
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>

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

using namespace std;
using p = pair<int, int>;
using ll = long long;

vector< vector<int> > memo;

int gcd(int a, int b, int c) {
	int min_num = (a > b) ? b : a;
	if (min_num > c) min_num = c;
	while (min_num != 1) {
		if (a % min_num == 0 && b % min_num == 0 && c % min_num == 0) break;
		min_num--;
	}
	return min_num;
}

int gcd(int a, int b) {
	int m = (a < b) ? a : b;
	while (m != 1) {
		if (a % m == 0 && b % m == 0)break;
		m--;
	}
	return m;
}



int main() {
	int k;
	int a, b;
	cin >> k;
	cin >> a >> b;
	if (b / k > a / k)cout << "OK" << endl;
	else if (a % k == 0 || b % k == 0) cout << "OK" << endl;
	else cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3640
var weeks = require("fs").readFileSync("/dev/stdin","utf8");
var startPercentage = 100;

console.log(calculateDebt(startPercentage, weeks));

function calculateDebt(number, weeks){
  for (var i = 0; i < weeks; i++) {
    number = Math.ceil(number * 1.05);
	}
  
	return number * 1000;
}

Measured memory_bytes: 15272
#![allow(non_snake_case)]

use std::io;
use std::io::prelude::*;

/// num回シャッフルした文字列を返す
/// シャッフル: 文字列の前からnum個を取り出し、後ろに連結する
fn shuffle(s: &String, num: u32) -> String {
    // 文字列を2つ連結し、ループを模す。
    let n = s.len();
    let mut res: String = s.clone();
    res.push_str(s);
    let st: usize = num as usize % n;
    res[st..st+n].to_string()
}

fn main() {
    let sin = io::stdin();
    let mut lines = sin.lock().lines();

    loop {
        let word: String = lines.next().unwrap().unwrap();
        if word == "-" {
            break;
        }
        let num: u32 = lines.next().unwrap().unwrap().parse().unwrap();
        let mut sh = 0;
        for _ in 0..num {
            sh += lines.next().unwrap().unwrap().parse().unwrap();
        }
        let res = shuffle(&word, sh);
        println!("{}", res);
    }
}



Measured memory_bytes: 5024
// https://twitter.com/tanakh/status/1152575899306323968
// https://atcoder.jp/contests/abc134/submissions/6466342

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>
#include <cstdio>

using namespace std;

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

int N;
int A[100001];

void print(std::multiset<int> &s, int x) {
    cout << "s = {";
    for (auto y : s) { cout << y << ", "; }
    cout << "}, x = " << x << endl;
}

int main() {
    std::multiset<int> s;
    scanf("%d", &N);
    rep(i, N) scanf("%d", &A[i]);
    
    rep(i, N) {
        int x = A[i];
        auto it = s.upper_bound(-x);
        if (it == s.end()) {
            s.insert(-x);
        } else {
            s.erase(it);
            s.insert(-x);
        }
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const double PI = 3.14159265358979323846;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	double a = (H * 60.0 + M) / 2.0;
	double b = 6.0*M;
	double d = fabs(a - b);
	//if (d >= 180.0) d -= 180.0;
	double angle = (atan(1) / 45.0) * d;
	double inside = A*A + B*B - 2.0*A*B*cos(angle);
	double r = sqrt(inside); 
	//db(PI);
	cout << fixed << setprecision(20) << r << endl;
}



Measured memory_bytes: 4192
import itertools
import sys
a,b=map(int,input().split())

# 最大公約数（ユークリッドの互除法）
def gcd(A,B):
    while B!=0:
        A,B=B,A%B
    return A

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

print(len(factorization(gcd(a,b)))+1 if a!=1 and b!=1 else 1)
# print(gcd(a,b))
# print(factorization(gcd(a,b)))

Measured memory_bytes: 9380
#include <stdio.h>

int dice[3][2];

void swap1(int a, int b)
{
  int i, temp[2];
  for (i=0; i<2; i++) {
    temp[i] = dice[a][i];
    dice[a][i] = dice[b][i];
  }
  for (i=0; i<2; i++)
    dice[b][i] = temp[i];
}

void swap2(int a)
{
  int i, temp;
  temp = dice[a][0];
  dice[a][0] = dice[a][1];
  dice[a][1] = temp;
}

void dice_init()
{
  int i;
  for (i=0; i<3; i++) {
      dice[i][0] = i+1;
      dice[i][1] = 7-(i+1);
    }
}

int move_dice(char *direction)
{
  char d = direction[0];
  switch (d) {
    case 'N': swap1(0, 1); swap2(1); break;
    case 'E': swap1(0, 2); swap2(0); break;
    case 'W': swap1(0, 2); swap2(2); break;
    case 'S': swap1(0, 1); swap2(0); break;
    case 'R': swap1(1, 2); swap2(2); break;
    case 'L': swap1(1, 2); swap2(1); break;
    default : return -1;
  }
  return dice[0][0];
}

int main(int argc, char const *argv[])
{
  int i, n, sum;
  char direction[6];

  while (scanf("%d", &n), n) {
    dice_init();
    for (sum=1; n--;) {
      scanf("%s", direction);
      sum += move_dice(direction);
    }
    printf("%d\n", sum);
  }
  return 0;
}

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

int main(){
      string s;cin >> s;
      int n = s.length();
      map<char, int> m;
      int ans = 0;
      for(int i = 0;i < n;i++){
            m[s[i]]++;
            if(m[s[i]] == 2)ans--;
            else ans++;
      }
      if(ans == 0)cout << "Yes";
      else cout << "No";
}

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

vector<vector<pair<int,ll> > > g;
vector<ll> cost;
vector<ll>res;

ll bfs(int a,int p,int b){
    //cerr << a << " " << p << " " << b << endl;
    if(a==b){
        for(auto x:g[a]){
            res.push_back(cost[b]*(x.second+bfs(x.first,a,b)));
        }
        return 0;
    }else{
        vector<ll>res2;
        for(auto x:g[a]){
            if(x.first!=p)res2.push_back(cost[b]*(x.second+bfs(x.first,a,b)));
        }
        if(res2.size()==0)return 0;
        sort(res2.begin(),res2.end());
        for(int i=0;i<res2.size()-1;i++){
            res.push_back(res2[i]);
        }
        return res2[res2.size()-1]/cost[b];
    }
}


int main(){
    int n,m;
    cin >> n >> m;
    g.resize(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--;
        b--;
        g[a].push_back(make_pair(b,c));
        g[b].push_back(make_pair(a,c));
    }
    cost.resize(n);
    for(int i=0;i<n;i++){
        cin >> cost[i];
    }
    for(int i=0;i<n;i++){
        bfs(i,-1,i);
    }
    ll ans = 0;
    if(m>=res.size()){
        for(auto x:res){
            ans += x;
        }
    }else{
        sort(res.rbegin(),res.rend());
        for(int i=0;i<m;i++){
            ans += res[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 36072
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
for i in range(n):
  temp = t - h[i]*0.006
  k = abs(a-temp)
  if i == 0:
    ans = i+1
    keep = k
  else:
    if keep>k:
      ans = i+1
      keep = k
print(ans)
      

Measured memory_bytes: 3060
object Main extends App {
	val line = scala.io.StdIn.readLine
	val a = line.split(" ")(0).toList
	val b = line.split(" ")(1).toList
	val c = line.split(" ")(2).toList

	if(a(a.size - 1) == b(0)){
		if(b(b.size - 1) == c(0)){
			println("YES");
		}else{
			println("NO")
		}
	}else{
		println("NO")
	}
}

Measured memory_bytes: 25400
import itertools
n=int(input())
List=[0,0,0,0,0]
for i in range(n):
  s=input()[0]
  if s=="M":
    List[0]+=1
  elif s=="A":
    List[1]+=1
  elif s=="R":
    List[2]+=1
  elif s=="C":
    List[3]+=1
  elif s=="H":
    List[4]+=1
ans=0
for c in itertools.combinations(List,3):
  ans+=c[0]*c[1]*c[2]
print(ans)

Measured memory_bytes: 3064
a,b = gets.split.map(&:to_i)
s = gets.chomp.chars

unless s.first(a).all? {|c| ('0'..'9').include?(c) }
  puts "No"
  exit
end

unless s[a] == '-'
  puts "No"
  exit
end

unless s.last(b).all? {|c| ('0'..'9').include?(c) }
  puts "No"
  exit
end

puts "Yes"


Measured memory_bytes: 14356
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (auto &v : vec)
    cin >> v;

  sort(vec.begin(), vec.end());
  int a = accumulate(vec.begin(), vec.end(), -*vec.rbegin());
  int b = *vec.rbegin();
  cout << (b < a ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(){
  int set_num;
  int data[3] = {0};
  int tmp;
  int i,j;

  scanf("%d",&set_num);

  for(i=0; i<set_num; i++){
    scanf("%d%d%d",&data[0],&data[1],&data[2]);

    //計算の処理
    for(j=0; j<2; j++){
      if(data[j] > data[j+1]){
        tmp = data[j];
        data[j] = data[j+1];
        data[j+1] = tmp;
      }
    }

    if(data[0]*data[0] + data[1]*data[1] == data[2]*data[2]){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
    
  }

  return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=400015;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;


#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);

	
	int n, m;
	cin >> n >> m;
	if(m == n) cout << "Yes";
	else cout << "No\n";


	
 
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(void) {
  int N, V[51];
  scanf("%d", &N);

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

  int sum = 0;
  for(int i = 0; i < N; i++) {
    int C;
    scanf("%d", &C);
    
    int diff = V[i] - C;
    if(diff > 0) {
      sum += diff;
    }
  }

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

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int mod = 1e9 + 7;

int main() {
	int n;
	int a[100000];
	cin >> n;
	REP(i, n) scanf("%d", &a[i]);
	
	int cnt[100000] = {};
	REP(i, n) cnt[a[i]-1]++;
	bool flag = false;
	REP(i, 100000) {
		if (n % 2 == 1 && i == n / 2) continue;
		if (cnt[i] != 0 && cnt[i] != 2) flag = true;
	}
	
	if (flag) puts("0");
	else {
		int ans = 1;
		REP(i, n / 2) ans = ans * 2 % mod;
		cout << ans << endl;
	}
	
	return 0;
}

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

using namespace std;

const int N = 3030;
const int mod = 1e9 + 7;

void add(int &x, int y) {
   x += y;
   if (x >= mod) {
      x -= mod;
   }
}

int n, m;
char s[N];
int go[N];
int f[N][N];

int main() {
   scanf("%d %d %s", &n, &m, s + 1);
   for (int i = 1; i <= n; ++i) {
      go[i] = i;
   }
   for (int i = 0; i < m; ++i) {
      int l, r;
      scanf("%d %d", &l, &r);
      go[l] = max(go[l], r);
   }
   for (int i = 1; i <= n; ++i) {
      go[i] = max(go[i], go[i - 1]);
   }
   f[0][0] = 1;
   for (int i = 1; i <= n; ++i) {
      int ad = 0;
      for (int j = go[i - 1] + 1; j <= go[i]; ++j) {
         ad += (s[j] - '0');
      }
      for (int j = 0; j <= n; ++j) {
         if (!f[i - 1][j]) continue;
         if ((j + ad)) {
            add(f[i][j + ad - 1], f[i - 1][j]);
         }
         if (go[i] - i + 1 - (j + ad)) {
            add(f[i][j + ad], f[i - 1][j]);
         }
      }
   }
   printf("%d\n", f[n][0]);
}


Measured memory_bytes: 33920
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl; 
#define prl cerr<<"called: "<< __LINE__ << endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
  fastio;
  ll a,b,c,d;
  cin >> a >>b >> c >> d;
  ll best = max({a*c,a*d,b*c,b*d});
  if(a<=0 and 0<=b)best = max(best,0LL);
  if(c<=0 and 0<=d)best = max(best,0LL);
  cout << best << endl;
  // math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

int main() {
    std::vector<int> a(3);
    int d;
    std::cin >> a[0] >> a[1] >> a[2] >> d;

    auto max = std::max_element(a.begin(), a.end());

    int ans = 0;
    for (auto it = a.begin(); it != a.end(); it++)
    {
        if(it == max) {
            for (int i = 1; i <= d; i++) {
                *it *= 2;
            }
            ans += *it;
        }
        else
        {
            ans += *it;
        }
    }

    std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N, M, Q;
vv<int> graph;
vector<int> V, D, C;
vv<int> coloring;

int main() {
    cin >> N >> M;
    graph.resize(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    cin >> Q;
    V.resize(Q);
    D.resize(Q);
    C.resize(Q);
    rep(i, Q) {
        cin >> V[i] >> D[i] >> C[i];
        V[i]--;
    }

    coloring = vvec(11, N, -1);
    rep(i, Q) {
        coloring[D[i]][V[i]] = i;
    }

    for (int d = 10; d > 0; --d) {
        rep(v, N) {
            coloring[d - 1][v] = max(coloring[d - 1][v], coloring[d][v]);
            for (int u : graph[v]) {
                coloring[d - 1][v] = max(coloring[d - 1][v], coloring[d][u]);
            }
        }
    }

    rep(v, N) write(coloring[0][v] == -1 ? 0 : C[coloring[0][v]]);
}

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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N, K-Q);

    for(int i=0; i<Q; i++) {
        int n;
        cin >> n;
        A[n-1]++;
    }

    for(int i=0; i<N; i++) {
        if(A[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

VI g[MAX];
int P[MAX];
int n;
int SZ[MAX];

int a, b;
int p;

void dfs(int x, int p, int c)
{
	P[x] = p;
	SZ[x] += c;

	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i];
		if (to == p) continue;

		if (x == a && to == b) continue;
		if (x == b && to == a) continue;

		dfs(to, x, -c);
		SZ[x] += SZ[to];
	}
}

LL solveTree()
{
	dfs(0, -1, 1);

	LL res = 0;
	if (p == 1)
	{
		if (SZ[0] % 2 != 0) return -1;
		int cnt = SZ[0] / 2;

		FOR (i, 0, n)
		{
			SZ[i] = 0;
		}

		SZ[a] -= cnt;
		SZ[b] -= cnt;
		res += abs(cnt);

		dfs(0, -1, 1);
	}

	if (SZ[0] != 0) return -1;
	FOR (i, 1, n)
	{
		res += abs(SZ[i]);
	}
	return res;
}

int D[MAX];

int dfs2(int x, int p, int d)
{
	D[x] = d;
	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i];
		if (to == p) continue;

		if (D[to])
		{
			a = x;
			b = to;
			if ((D[to] ^ d) & 1) return 0;
			return 1;
		}

		int val = dfs2(to, x, d + 1);
		if (val != -1) return val;
	}

	return -1;
}

LL calc(int m)
{
	FOR (i, 0, n)
	{
		SZ[i] = 0;
	}

	SZ[a] = m;
	SZ[b] = -m;

	return solveTree() + abs(m);
}

int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int m;
	scanf("%d%d", &n, &m);
	FOR (i, 0, m)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;

		g[x].PB(y);
		g[y].PB(x);
	}

	if (m == n-1)
	{
		cout<<solveTree()<<endl;
		return 0;
	}

	p = dfs2(0, -1, 1);

	if (p == 1)
	{
		cout<<solveTree()<<endl;
		return 0;
	}

	if (p == 0)
	{
		int l = -n-4, r = n+4;
		while(r - l > 4)
		{
			int m = (r - l) / 3;
			int m1 = l + m;
			int m2 = r - m;

			LL v1 = calc(m1);
			LL v2 = calc(m2);

			if (v1 < v2) r = m2;
			else l = m1;
		}

		LL res = LINF;

		while(l <= r)
		{
			res = min(res, calc(l));
			l++;
		}

		cout<<res<<endl;
		return 0;
	}

	throw -1;
}


Measured memory_bytes: 14720
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

char a[5], b[5];
int main() {
    gets(a);
    gets(b);
    if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

int main()
{  
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   map<int,int> mp;
   for(int i=0;i<n;i++) mp[a[i]]++;
   int ans=0;
   for(auto p: mp){
       int x=p.first;
       int n=p.second;
       if(n<x) ans+=n;
       else ans+=n-x;
   }
   cout<<ans<<endl;

} 

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

int main(){
    int H, W;
    vector<pair<int, int> > d;
    while (true)
    {
        cin >> H >> W;
        if(H==0 && W==0) break;
        else d.push_back(make_pair(H, W));
    }

    for (int i = 0; i < d.size(); i++)
    {
        for (int j = 0; j < d.at(i).first; j++)
        {
            for (int k = 0; k < d.at(i).second; k++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    
    
}


Measured memory_bytes: 3080
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    c=[list(map(int,input().split())) for _ in range(3)]
    a=[[0]*3 for _ in range(3)]
    b=[[0]*3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            a[i][j]=c[i][j]-min(c[i])
            b[j][i]=c[i][j]-min(c[0][j],c[1][j],c[2][j])
    YesNo(a[0]==a[1]==a[2] and b[0]==b[1]==b[2])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef queue<ll> qi;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int a1,b1;
	a1 = c/b;
	b1 = a/d;
	if(c%b)
		a1++;
	if(a%d)
		b1++;
	if(a1<=b1)
		cout<<"Yes\n";
	else
		cout<<"No\n"; 
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

int main(void){
  int n;
  static int v[100000],c0[100010]={},c1[100010]={};

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>v[i];
    if(i%2==0){
      c0[v[i]]++;
    }
    else{
      c1[v[i]]++;
    }
  }

  int f0,f1,s0,s1;
  f0=f1=s0=s1=0;
  for(int i=1;i<=100000;i++){
    if(c0[f0]<c0[i]){
      s0=f0;
      f0=i;
    }
    else if(c0[s0]<c0[i]){
      s0=i;
    }

    if(c1[f1]<c1[i]){
      s1=f1;
      f1=i;
    }
    else if(c1[s1]<c1[i]){
      s1=i;
    }
  }

  if(f0!=f1){
    cout<<n-c0[f0]-c1[f1]<<endl;
  }
  else if(c0[f0]+c1[s1]>c1[f1]+c0[s0]){
    cout<<n-c0[f0]-c1[s1]<<endl;
  }
  else{
    cout<<n-c1[f1]-c0[s0]<<endl;
  }

  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    for (int i = 0; ; ++i) {
        if(!(i&1)){
            c -= b;
            if(c <= 0){
                puts("Yes");
                return 0;
            }
        }else {
            a -= d;
            if(a <= 0){
                puts("No");
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
    //Enter your code here Tanmay:)
    int n=0,a=0,b=0,c=0,count=0;
    string s;
    cin>>a>>b;
    if((a*500)>=b)
        cout<<"Yes";
    else
        cout<<"No";

}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll W, ll a, ll b) {
  cout << max(0LL, abs(a - b) - W) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll W;
	ll b;
	ll a;
	scanf("%lld", &W);
	scanf("%lld", &a);
	scanf("%lld", &b);
	solve(W, a, b);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 1000010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x) {
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int n, k;
int inp[N];

vector < ll > v, tmp, op;

int main(){
  fastScan(n); fastScan(k);
  for(int i = 0; i < n; i++){
    fastScan(inp[i]);
  }
  for(int i = 0; i < n; i++){
    ll hand = inp[i];
    v.pb(hand);
    for(int j = i + 1; j < n; j++){
      hand += inp[j];
      v.pb(hand);
    }
  }
  ll answer = 0, startBit = -1;
  for(int i = 50; i >= 0 && startBit == -1; i--){
      for(int j = 0; j < v.size(); j++){
        if((v[j] & (1ll << i)) > 0){
          op.pb(v[j]);
        }
      }
      if(op.size() >= k){
        startBit = i + 1;
        answer |= (1ll << i);
        break;
      }
      op.clear();
  }
  //cout << startBit << '\n';
  for(int i = startBit; i >= 0; i--){
    int one = 0, zero = 0;
    for(int j = 0; j < op.size(); j++){
      if((op[j] & (1ll << i)) > 0){
        one++;
      } else {
        zero++;
      }
    }
    if(one >= k){
      answer |= (1ll << i);
      for(int j = 0; j < op.size(); j++){
        if((op[j] & (1ll << i)) > 0){
          tmp.pb(op[j]);
        }
      }
      op.clear();
      op = tmp;
      tmp.clear();
    }
  }
  printf("%lld\n", answer);
}


Measured memory_bytes: 7020
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int w = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int[][] map = new int[h][w];
		int n = Integer.parseInt(sc.next());
		

		for(int i=0; i<n; i++) {
		    int x = Integer.parseInt(sc.next());
		    int y = Integer.parseInt(sc.next());
		    int a = Integer.parseInt(sc.next());
		    x--;
		    y--;
		    if(a == 1) {
        		for(int k=0; k<h; k++) {
        		    for(int j=0; j<=x; j++) {
        		        map[k][j] = 1;
        		    }
        		}
		    }else if(a == 2) {
		        for(int k=0; k<h; k++) {
        		    for(int j=x+1; j<w; j++) {
        		        map[k][j] = 1;
        		    }
        		}
		    }else if(a == 3) {
		        for(int k=0; k<=y; k++) {
        		    for(int j=0; j<w; j++) {
        		        map[k][j] = 1;
        		    }
        		}
		    }else {
		        for(int k=y+1; k<h; k++) {
        		    for(int j=0; j<w; j++) {
        		        map[k][j] = 1;
        		    }
        		}
		    }
		}
		
		int count = 0;
        for(int i=0; i<h; i++) {
		    for(int j=0; j<w; j++) {
		        if(map[i][j] == 0) count++;
		    }
		}
		System.out.println(count);
		
		
	}
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807


void kr(int a);

int n,a,b,c,ans,memo[10000],aans[10000];
priority_queue<int> aa;
priority_queue<pair<int,int>> bb;
vector<int> v[10000];

signed main() {
    cin >> n;
    rep(i,n-1) {
        cin >> a >> b;a--,b--;
        memo[a]++;
        memo[b]++;
        v[a].pb(b);
        v[b].pb(a);
    }
    rep(i,n) bb.push(mp(memo[i],i));
    rep(i,n) {
        cin >> c;
        ans += c;
        aa.push(c);
    }
    ans -= aa.top();
    kr(bb.top().se);
    cout << ans << endl;
    rep(i,n-1) cout << aans[i] << " ";
    cout << aans[n-1] << endl;

}
void kr(int a) {
    if (aans[a]) return;
    aans[a] = aa.top();aa.pop();
    rep(i,v[a].size()) kr(v[a][i]);
}

Measured memory_bytes: 1536
while True:
    try:
        a,o,b=input().split()
        a=int(a)
        b=int(b)
    except EOFError:
        break
    if o == "+":
        print(a+b)
    elif o == "-":
        print(a-b)
    elif o == "*":
        print(a*b)
    elif o =="/":
        print(a//b)
    else:
        break



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 2e5 + 7;
const int INF = 1000 * 1000 * 1000;

ii ed[N];
int n, m;
int d[N];
vector <int> g[N]; // numbers of edges!
int ans[N];
bool color[N];
int dist[N];
bool used[N];
void check(int c) {
    priority_queue <ii> q;
    for (int i = 1; i <= n; ++i) {
        dist[i] = INF * INF;
        if (color[i] == c) {
            dist[i] = 0;
            q.push(mp(0ll, i));
        }   
    }   
    memset(used, 0, sizeof used);
    while (q.size()) {
        int u = q.top().s; q.pop();
        if (used[u])
            continue;
        used[u] = 1;
        for (int i : g[u]) {
            int v = ed[i].f^ed[i].s^u;
            int w = ans[i];
            if (dist[u] + w < dist[v]) {
                dist[v] = dist[u] + w;
                q.push(mp(-dist[v], v));
            }   
        }   
    }   
    for (int i = 1; i <= n; ++i) {
        if (color[i] != c) {
            if (d[i] != dist[i]) {
                cout << -1 << endl;
                exit(0);
            }   
        }   
    }   
}   

vector <int> ng[N];
void dfs(int u) {
    used[u] = 1;
    for (int v : ng[u]) {
        if (!used[v]) {
            color[v] = color[u] ^ 1;
            dfs(v);
        }   
    }   
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> d[i];
    }   
    for (int i = 0; i < m; ++i) {
        int u, v; cin >> u >> v;
        ed[i] = mp(u, v);
        g[u].app(i); 
        g[v].app(i);
    }   
    
    for (int i = 0; i < m; ++i)
        ans[i] = INF;

    for (int u = 1; u <= n; ++u) {
        ii mn = mp(INF * INF, INF * INF);
        int e = -1;
        for (int i : g[u]) {
            int v = ed[i].f^ed[i].s^u;
            if (mp(d[v], v) < mn) {
                mn = mp(d[v], v);
                e = i;
            }   
        }
        int v = mn.s;
        ng[u].app(v);
        ng[v].app(u);
        ans[e] = d[u];
    }   

    for (int u = 1; u <= n; ++u)
        if (!used[u])
            dfs(u);

    for (int u = 1; u <= n; ++u)
        for (int v : ng[u]) {
            if (color[u] == color[v]) {
                cout << u << ' ' << v << ' ' << color[u] << endl;
                cout << "LMAO" << endl;
                exit(0);
            }   
        }

    vector <bool> have(2);
    for (int i = 1; i <= n; ++i)
        have[color[i]] = 1;

    if (!have[0] || !have[1]) {
        cout << -1 << endl;
        exit(0);
    }

    for (int t = 0; t < 2; ++t) 
        check(t);

    for (int i = 1; i <= n; ++i) {
        if (color[i]) {
            cout << 'B';
        }   
        else {
            cout << 'W';
        }   
    }   
    cout << endl;

    for (int i = 0; i < m; ++i) {
        cout << ans[i] << endl;
    }   

}


Measured memory_bytes: 31324
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <map>
using namespace std;

#define Int long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl

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


Measured memory_bytes: 768
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N) {
		VI A(N);
		REP(i, N) cin>>A[i];
		ll ans = 0;
		REP(i, N) {
			ans+=A[i]/2;
			if(A[i]%2==1 && i+1<N && A[i+1]) {ans++;A[i+1]--;}
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
function main(input){
  var line1 = parse(input[0]);
  var n = line1[0];
  var x = parse(input[1]);
  var sorted = x.slice(0, x.length).sort((k, l) => k-l);
  var first = sorted[sorted.length/2 - 1];
  var last = sorted[sorted.length/2];
  for (var i = 0; i < n; i++) {
    if (x[i] <= first) {
      console.log(last);
    } else {
      console.log(first);
    }
  }
}
 
function parse(line){
  var ret = [];
  var arr = line.split(' ');
  for (var i = 0; i < arr.length; i++) {
    ret.push(parseInt(arr[i]));
  }
  return ret;
}
 
var
input = '';
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


Measured memory_bytes: 58620
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ld A;
  ld B;
  cin >> A >> B;
  COUT((ll)(A * B));
  return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int n, a ;
  cin >> n >> a ;
  
  if(n%500<=a){
    cout <<"Yes"<<endl ;
  }
  else{
    cout <<"No"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(i%3==0 || i%5==0) continue;
        else sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3636
#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 << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
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<ll>>;

ll H,W;
char field[10][10];

void dfs(ll y,ll x){
   field[y][x] = 'O';
   if(field[y+1][x] == '#') dfs(y+1,x);
   if(field[y][x+1] == '#') dfs(y,x+1);
}

int main(){
   cin >> H >> W;
   ll cnt = 0;
   rep(i,H) rep(j,W){
      cin >> field[i][j];
      if(field[i][j] == '#')cnt++;
   }
   if(cnt != H + W - 1){
      cout << "Impossible" << endl;
   }else{
      dfs(0,0);
      if(field[H-1][W-1] == 'O'){
         cout << "Possible" << endl;
      }else{
         cout << "Impossible" << endl;
      }
   }
}


Measured memory_bytes: 256
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;

use std::collections::BTreeMap;

fn main() {
    input! {
        mut n: usize,
        mut x: usize,
        m: usize,
    }

    let mut map: BTreeMap<usize, usize> = BTreeMap::new();
    let mut cum = vec![0usize; m + 10];

    let mut i = 0;
    let mut ans = 0;
    let mut l = false;

    while i < n {
        if map.contains_key(&x) && !l {
            let j = map.get(&x).unwrap();
            let sum = cum[i] - cum[*j];
            let len = i - j;
            let cnt = (n - i) / len;
            n -= len * cnt;
            ans += sum * cnt;
            l = true;
            if n == i {
                break;
            }
        } else {
            map.insert(x, i);
            cum[i + 1] = cum[i] + x;
        }

        ans += x;
        x = x * x % m;
        i += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<string>
using namespace std;
 
#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))
 
typedef long long ll;

int main(){
	int A,B;
	cin>>A>>B;
	cout<<(A+B)%24<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int i,ans=0;
    string n;
    cin>>n;
    for (i=0;i<n.size();i++)
        ans+=(n[i]=='2');
    cout<<ans<<endl;
}

Measured memory_bytes: 256
while 1:
    s1 = input().split('\"')
    if s1[0] == '.': break
    s2 = input().split('\"')

    jdg = 1
    cnt_d = 0

    if len(s1) != len(s2): print("DIFFERENT")
    else:
        l = len(s1)
        i = 0
        while i < l:
            if s1[i] != s2[i]:
                cnt_d += 1
                if cnt_d == 1 and i % 2 == 1:
                    jdg = 1
                else:
                    jdg = 0
                    break
            i += 1

        if jdg == 1 and cnt_d == 1: print("CLOSE")
        elif jdg == 0 or cnt_d > 1: print("DIFFERENT")
        else: print("IDENTICAL")


Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < n; ++i)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vector<int> a(n);
    int x = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        x ^= a[i];
    }
    for (int y : a) {
        cout << (y^x) << " ";
    }
    cout << endl;
    


    return 0;
}

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

int main(){
  int N;cin>>N;
  vector<int> L;
  for (int i=0;i<N;i++){
    int a;cin>> a;
    L.push_back(a);
  }
  sort(L.begin(),L.end());
  int s=0;
  for (int i=0;i<N-1;i++){
    s+=L[i];
  }
  if (L[N-1]<s){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  return 0;
}

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

int dfs(int v,int N,vector<bool>seen,const Graph G){
    bool all_visited=true;
    rep(i,N){
        if(seen[i]==false){
            all_visited=false;//訪れていないところがあったらfalse
        }
    }
    if(all_visited){
        return 1;
    }//全ての頂点を巡っていれば1を返す
    //まだ全ての頂点を巡っていないとき
    int ret=0;//そこから先で考えられるルート数
    rep(i,N){
        if(G[v][i]==0){
            continue;
        }//経路がなければパス
        if(seen[i]){
            continue;
        }//すでに通った頂点ならパス
        seen[i]=true;//訪れたことにして
        ret+=dfs(i,N,seen,G);//答えにそれより先の答えを追加
        //ここでわたしたvisitedを元に戻す
        seen[i]=false;//もう一度訪れてないことにして続きの処理へ
    }
    return ret;
}

int main(){
    int N,M;cin>>N>>M;
    Graph G(N,vector<int>(N,0));
    rep(i,M){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a][b]=1;
        G[b][a]=1;
    }
    vector<bool>seen(N,false);
    seen[0]=true;
    cout<<dfs(0,N,seen,G)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//#define DEBUG

int main()
{
	int N,A;
	scanf("%d%d",&N,&A);
#ifdef DEBUG
	printf("%d %d\n",N,A);
#endif
	if((N % 500) <=A) printf("Yes\n");
	else              printf("No\n");

	return 0;
}



Measured memory_bytes: 128
n = int(input())
alist = list(map(int, input().split()))
m = int(input())
blist = list(map(int, input().split()))

anslist = set(alist) ^ set(blist)
anslist = set(alist) & set(anslist)
anslist = list(anslist)
anslist.sort()

for ans in anslist:
    print(ans)



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

long long a, b, n;

long long f(long long x) {
    return (a * x) / b - a * (x / b);
}

int main() {
    cin >> a >> b >> n;
    long long lo = 0, hi = n, mid;

    long long ans = 0;

    while (lo <= hi) {
        mid = (lo + hi) / 2;
        if (f(mid) >= ans) {
            lo = mid + 1;
            ans = f(mid);
        } else {
            hi = mid - 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<stdbool.h>

typedef long long ll;
int main(){
    ll N;
    scanf("%lld",&N);
    char S[N];
    scanf("%s",S);
    ll sum=0;
    ll r=0,g=0,b=0;
    for(ll i=0;i<N;i++){
        if(S[i] == 'R') r++;
        else if(S[i] == 'G') g++;
        else b++;
    }
    ll ans = r*g*b;
    for(ll i=0;i<N;i++){
        for(ll range=1;i+range*2<N;range++){
            if(S[i] != S[i+range] && S[i+range] != S[i+range*2]
                    && S[i+range*2] != S[i])
                sum++;
        }
    }
    printf("%lld",ans-sum);
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s; cin >> s;
	if(s == "SSS") cout << 0;
	else if(s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") cout << 1;
	else if(s == "RRS" || s == "SRR") cout << 2;
	else cout << 3;

	return 0;
}

Measured memory_bytes: 3644