akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

struct SEG {
    buf: Vec<u64>,
    n: usize,
}

impl SEG {
    fn new(size: usize) -> SEG {
        let n = (1..).map(|i| 1 << i).find(|&x| x >= size).unwrap();

        SEG {
            buf: vec![0; 2 * n],
            n: n,
        }
    }

    fn add(&mut self, i: usize, x: u64) {
        let mut i = self.n + i - 1;
        self.buf[i] += x;
        while i > 0 {
            i = (i - 1) / 2;
            self.buf[i] = self.buf[i * 2 + 1] + self.buf[i * 2 + 2];
        }
    }

    fn sum(&self, a: usize, b: usize, k: usize, l: usize, r: usize) -> u64 {
        if r <= a || b <= l {
            return 0;
        }

        if a <= l && r <= b {
            return self.buf[k];
        }

        let vl = self.sum(a, b, k * 2 + 1, l, (l + r) / 2);
        let vr = self.sum(a, b, k * 2 + 2, (l + r) / 2, r);

        vl + vr
    }
}

fn main() {
    let (n, q) = get!(usize, usize);

    let mut seg = SEG::new(n);

    for _ in 0..q {
        let (com, x, y) = get!(usize, usize, usize);

        if com == 0 {
            seg.add(x - 1, y as u64);
        } else {
            println!("{}", seg.sum(x - 1, y, 0, 0, seg.n));
        }
    }
}



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

int main(){
  char s[100],p[100];
  int i,j,slen,plen;
  int f=0;

  scanf("%s%s",s,p);

  slen=strlen(s);
  plen=strlen(p);
  
  for(i=0; i<slen; ++i){
    if(s[i]==p[0]){
      for(j=0; j<plen; ++j){
	if(s[i+j-slen]==p[j]){
	  if(j==plen-1){
	    f=1;
	  }
	}else
	if(s[i+j]==p[j]){
	  if(j==plen-1){
	    f=1;
	  }
	}else{
	  break;
	}
      }
    }
  }

  if(f){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  

  return 0;
}



Measured memory_bytes: 2608
#include <iostream>

using namespace std;

int main(){
    int k, flg, out;
    cin >> k;
    flg = k / 2;
    if(k % 2 != 0){
        out = (flg + 1) * flg;
    }else{
        out = flg * flg;
    }
    cout << out << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        while(true) {
        	String str = sc.next();
        	int sum = 0;

        	if(str.equals("0")) {
        		break;
        	}

        	for(int i = 0; i < str.length(); i++) {
        		sum += Integer.parseInt(str.substring(i, i+1));
        	}

        	System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26576
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    string s;
    cin >> s;
    s = "#" + s;
    if (s[3] == s[4] && s[5] == s[6]){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = list(input())

# why are these variables named "dp"?
dp1 = [10**6] * K
dp2 = [0] * K

i = 0
dp_ind = 0
while i < N:
    if S[i] == "o":
        dp1[dp_ind] = i
        dp_ind += 1
        if dp_ind == K:
            break
        i += C + 1
        continue
    i += 1

i = N - 1
dp_ind = K - 1
while i >= 0:
    if S[i] == "o":
        dp2[dp_ind] = i
        dp_ind -= 1
        if dp_ind == -1:
            break
        i -= C + 1
        continue
    i -= 1
for a, b in zip(dp1, dp2):
    if a == b:
        print(a+1)


Measured memory_bytes: 64880
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, a, b;

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n >> a >> b;
	if((b - a) % 2 == 0) cout << "Alice";
	else cout << "Borys\n";
	
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(raw_input())
    b = map(int, raw_input().split())
    m = n * n
    a = [0] * m
    for i, x in enumerate(b):
        a[x-1] = i + 1
    j = 0
    for i in xrange(m):
        if a[i] > 0:
            x = a[i]
            for k in xrange(x - 1):
                while a[j] != 0:
                    if j >= i:
                        print "No"
                        return
                    j += 1
                a[j] = -x
    j = m - 1
    for i in xrange(m - 1, -1, -1):
        if a[i] > 0:
            x = a[i]
            for k in xrange(n - x):
                while a[j] != 0:
                    if j <= i:
                        print "No"
                        quit()
                        return
                    j -= 1
                a[j] = -x
    print "Yes"
    for x in a:
        print x if x > 0 else -x,
    print
main()


Measured memory_bytes: 11524
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a, b, c;
	cin>>a>>b>>c;
	if(a==b||b==c||c==a){
		if(a==b&&b==c)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int a;
    cin >> a;
    string s;
    cin >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
s = input()
l1 = []
for x in s:
    l1.append(x)
l2 = l1[:]
l2.reverse()
hugs = 0
for count in range(int(len(l1)/2)):
    if l1[count] == l2[count]:
        continue
    else:
        hugs += 1
print(hugs)

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

namespace Atc_0027
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            int N = int.Parse(str);

            Console.WriteLine(N * N * N);

        }
    }
}


Measured memory_bytes: 27332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
#define rep2(i, ns, ne) for (int i = ns; i <= ne; ++i)

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << ((a + b) * h / 2) << endl;
  getchar();
}

Measured memory_bytes: 3636
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
    # 確かめるのはnの平方根までで大丈夫
        if not is_prime[i]:  # すでにfalseなら次のiへ
            continue
            """
            bool(not False)はTrueになる
            """
        for j in range(i * 2, n + 1, i):
        # iずつ大きくなる(つまりiの倍数をみる)
            is_prime[j] = False
            # i自身を除くiの倍数を全てFalseにする
    return [i for i in range(n + 1) if is_prime[i]]
     # Trueのものだけ列挙して返す


N = int(input())
hoge = primes(10**6)
for i in range(len(hoge)):
    if hoge[i] >= N:
        print(hoge[i])
        exit()


Measured memory_bytes: 14000
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans = float("inf")
for i in range(N - K + 1):
    left, right = X[i], X[i + K - 1]
    dist = right - left
    ans = min(ans, abs(left) + dist, abs(right) + dist)
print(ans)


Measured memory_bytes: 14392
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
//#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

struct UnionFind {
    vector<int> par;
    vector<int> si;
    UnionFind(int N) : par(N), si(N) {
        for(int i = 0; i < N; ++i) par[i] = i;
        for(int i = 0; i < N; ++i) si[i] = 1;
    }

    int root(int x) {
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        si[ry] += si[rx];
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return si[root(x)];
    }
};
const int MAX_N = 1001;
const int MAX_H = 10001;
int dp[MAX_N][MAX_H];
int main() {
    int H, N;
    cin >> H >> N;
    int A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];
    rep(i, N + 1) {
        rep(j, H + 1){
            dp[i][j] = ((j == 0) ? 0 : INF);
        }
    }
    rep(i, N) {
        for(int j = 1; j <= H; ++j) {
            dp[i + 1][j] = min(B[i] * ((j - 1) / A[i] + 1), dp[i][j]);
            if(j - A[i] >= 0) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][j - A[i]] + B[i]);
            }
        }
    }

    cout << dp[N][H] << endl;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	const int mod = 1e9 + 7;
	int n, m; cin >> n >> m;
	vector<vector<int>> C(n + 1, vector<int>(n + 1, 0));
	for (int i = 0; i <= n; i++) for (int j = 0; j <= i; j++) {
		if (j == 0 || j == i) C[i][j] = 1;
		else C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
	}
	string s; cin >> s;
	vector<int> cnt(n, 0);
	for (int i = 0; i < n; i++) cnt[i] = (i == 0 ? 0 : cnt[i - 1]) + (s[i] == '1');
	vector<pair<int, int>> q(m);
	for (int i = 0; i < m; i++) {
		cin >> q[i].first >> q[i].second;
		q[i].first--; q[i].second--;
	}
	sort(q.begin(), q.end(), [&](const pair<int, int>& l, const pair<int, int>& r) {
		if (l.first == r.first) return l.second > r.second;
		return l.first < r.first;
	});
	for (int i = 1; i < m; ) {
		if (q[i].second <= q[i - 1].second) {
			m--;
			for (int j = i; j < m; j++) q[j] = q[j + 1];
		} else i++;
	}
	q.resize(m + 1);
	for (int i = m; i > 0; i--) q[i] = q[i - 1];
	vector<vector<int>> f(m + 1, vector<int>(n + 1, 0));
	auto getcount = [&](int l, int r) {
		if (l == 0) return cnt[r];
		return cnt[r] - cnt[l - 1];
	};
	vector<int> pw2(n + 1, 1);
	for (int i = 1; i <= n; i++) pw2[i] = pw2[i - 1] * 2 % mod;
	vector<int> seg(m + 1, 0);
	vector<int> tot(m + 1, 0);
	for (int i = 1; i <= m; i++) {
		if (i != m && q[i].second >= q[i + 1].first) seg[i] = q[i + 1].first - q[i].first;
		else seg[i] = q[i].second - q[i].first + 1;
		if (i != 1 && q[i].first <= q[i - 1].second) tot[i] = tot[i - 1] + getcount(q[i - 1].second + 1, q[i].second);
		else tot[i] = getcount(q[i].first, q[i].second);
	}
	long long ans = 1;
	f[0][0] = 1;
	for (int i = 1; i <= m; i++) {
		int t = tot[i];
		int jmn = t - (q[i].second - q[i].first + 1 - seg[i]);
		for (int j = max(0, jmn); j <= t; j++) {
			for (int k = 0; k <= seg[i] && k <= j; k++) {
				f[i][j] = ((long long)f[i][j] + (long long)f[i - 1][j - k] * C[seg[i]][k]) % mod;
			}
		}
		if (i == m || q[i].second < q[i + 1].first) {
			ans = ans * f[i][t] % mod;
			for (int j = 0; j <= n; j++) f[i][j] = 0;
			f[i][0] = 1;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  ll n, m;
  bool prime = true;
  cin >> n;

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

  ll ans = 0;
  for (ll i=2; i*i <= n; i++){
    if (n % i != 0) continue;

    prime = false;
    ll expo = 0;
    while (n % i == 0){
      n /= i;
      expo ++;
    }
    ll j = 1;
    while ( expo >= j*(j+1)/2 ) j++;
    ans += j-1;
  }
  if (n!=1) ans += 1;
  if (prime) ans = 1;
  cout << ans << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) - '0' != i % 2) ans++;
  }
  cout << min(ans, (int) s.size() - ans) << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
int main(void){
char a[10],b[10];
  scanf("%s %s",&a,&b);
  if((strcmp(a,"H")==0)&&(strcmp(b,"H")==0)){printf("H");}
  if((strcmp(a,"H")==0)&&(strcmp(b,"D")==0)){printf("D");}
  if((strcmp(a,"D")==0)&&(strcmp(b,"H")==0)){printf("D");}
  if((strcmp(a,"D")==0)&&(strcmp(b,"D")==0)){printf("H");}
return 0;
}

Measured memory_bytes: 128
def main():
  ## IMPORT MODULE
  #import sys
  from decimal import Decimal

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    a, b = 198, 1.10

  else:
    ##INPUT 
    #n = input()
    a, b = map(str, input().split())

  ## SUBMITION CODES HERE
  print(int(int(a)*Decimal(b)))
    
main()

Measured memory_bytes: 10004
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
#include <list>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef vector<int> vi;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	if(a + b >= c) cout << b + c << endl;
	else cout << a + b + b + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
void compareNum(int a,int b,int c);
using namespace std;
int main(int argc, const char * argv[]) {
    int a,b,c;
    cin >> a >> b >> c;
    compareNum(a, b, c);
    return 0;
}
void compareNum(int a,int b,int c){
    if (a < b && b <c) {
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b,h,m,h1,m1;
	cin>>a>>b>>h>>m;
	m1=m*360/60;
	h1=h*360/12+0.5*m;
	cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos(abs(m1-h1)/360*2*3.1415926535));
	return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

int get_int4(int *a1, int *a2, int *a3, int *a4) {
  scanf("%d %d %d %d", a1, a2, a3, a4);
  return 0;
}

#define NUM_MAX 500000

struct arrpos {
    int pos;
    int label;
};

int asc_by_pos(const void *a1, const void *a2) {
    struct arrpos *pa1 = (struct arrpos*)a1;
    struct arrpos *pa2 = (struct arrpos*)a2;
    return pa1->pos - pa2->pos;
}

int asc(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

struct point2d {
    int x;
    int y;
};

struct range {
    int start;
    int end;
};

int lower_bound(struct arrpos *xs, int size, int key) {
    int low = -1;
    int high = size;
    while(low + 1 < high) {
        int mid = (low + high) / 2;
        if(xs[mid].pos >= key) {
            high = mid;
        } else {
            low = mid;
        }
    }
    return high;
}


int upper_bound(struct arrpos *xs, int size, int key) {
    int low = -1;
    int high = size;
    while(low + 1 < high) {
        int mid = (low + high) / 2;
        if(xs[mid].pos <= key) {
            low = mid;
        } else {
            high = mid;
        }
    }
    return low;
}


int main(void) {
    int num = get_int();
    struct arrpos xs[NUM_MAX]; 
    struct arrpos ys[NUM_MAX];
    int i, j;
    for(i = 0; i < num; i++) {
        int x, y;
        get_int2(&x, &y);
        xs[i] = (struct arrpos){x, i};
        ys[i] = (struct arrpos){y, i};
    }

    qsort(xs, num, sizeof(struct arrpos), asc_by_pos);
    qsort(ys, num, sizeof(struct arrpos), asc_by_pos);
    int queries = get_int();

    for(i = 0; i < queries; i++) {
        static char map[NUM_MAX+1];
        memset(map, 0, NUM_MAX+1);
        static int ans[NUM_MAX];
        int aidx = 0;
        struct point2d start, end;
        get_int4(&start.x, &end.x, &start.y, &end.y);
        struct range rx = {
            lower_bound(xs, num, start.x),
            upper_bound(xs, num, end.x)
        };
        // register
        for(j = rx.start; j <= rx.end; j++) {
            map[xs[j].label]++;
        }

        struct range ry = {
            lower_bound(ys, num, start.y),
            upper_bound(ys, num, end.y)
        };
        for(j = ry.start; j <= ry.end; j++) {
            if(map[ys[j].label]) ans[aidx++] = ys[j].label;
        }
        qsort(ans, aidx, sizeof(int), asc);
        for(j = 0; j < aidx; j++) {
            printf("%d\n", ans[j]);
        }
        putchar('\n');
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<string> b(n);
  for (int i = 0; i < n; i++)
    cin >> b.at(i);
  
  int m;
  cin >> m;
  vector<string> r(m);
  for (int i = 0; i < m; i++)
    cin >> r.at(i);
  
  int bestVal = 0;
  for (int i = 0; i < n; i++) {
    string str = b.at(i);
    int val = 0;
    for (int j = 0; j < n; j++) {
      if (b.at(j) == str)
        val++;
    }
    for  (int j = 0; j < m; j++) {
      if (r.at(j) == str)
        val--;
    }
    bestVal = max(bestVal, val);
  }
  cout << bestVal << endl;
  
  return 0;
}

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

using namespace std;

int main()
{
	string s, t, r;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	cin >> r;

	if (r == s) {
		cout << a - 1 << ' ' << b << endl;
	}
	else if (r == t) {
		cout << a << ' ' << b - 1 << endl;
	}
	else {
		cout << a << ' ' << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n  = int(input())
ls = list(map(int, input().split()))
ls_plus1  = list(map(lambda x: x + 1, ls))
ls_minus1 = list(map(lambda x: x - 1, ls))
dic = {}
for a in ls_minus1 + ls + ls_plus1:
    dic[a] = dic.get(a, 0) + 1
print(max(dic.values()))
    

Measured memory_bytes: 26596
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

const int MAX = 300000;

using S = int;
S op(S a, S b) { return max(a, b); }
S e() { return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k; cin >> n >> k;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  segtree<S, op, e> rmq(MAX+5);
  rmq.set(a[0], 1);

  vector<int> dp1(n,0);
  dp1[0] = 1;
  FOR(i,1,n){
    dp1[i] = rmq.prod(max(a[i]-k,0), min(a[i]+k,MAX)+1)+1;
    rmq.set(a[i], dp1[i]);
  }

  int ans = 0;
  REP(i,n){
    chmax(ans, dp1[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9824
#E問題
#UnionFind(normal)
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
        
"""
Class呼び出しの際には,UnionFind(Number)とする.関数の引数にはUnite(x,y)やisSameGroup(x,y)とする.
"""
    
if __name__ == "__main__":
  
    N,M = map(int,input().split())
    uf = UnionFind(N+1)
    for i in range(M):
        X,Y,Z = map(int,input().split())
        if not uf.isSameGroup(X,Y):
            uf.Unite(X,Y)
    ans=0
    for j in uf.root[1:N+1]:
        if j < 0:
            ans+=1
    print(ans)
            

Measured memory_bytes: 8516
#include<stdio.h>
#define MAX 500000
#define INFTY 1000000001
int  H[MAX];

int merge(int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right -mid;
  int L[n1],R[n2];
  int i;
  static int sum=0;
  for(i=0;i<n1;i++)L[i]=H[left+i];
  for(i=0;i<n2;i++)R[i]=H[mid+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  int j=0,k;
  for(k=left;k<right;k++){
    if(L[i]<=R[j])H[k]=L[i++];
    else H[k]=R[j++];
    sum++;
  }
  return sum;
}

int mergesort(int left,int right){
  int a;
  if (left+1<right){
    int mid=(left+right)/2;
    mergesort(left,mid);
    mergesort(mid,right);
    a=merge(left,mid,right);
  }
  return a;
}



int main(){
  int i,n,cnt;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&H[i]);
  cnt=mergesort(0,i);
  for(i=0;i<n;i++){
    if(i!=n-1)printf("%d ",H[i]);
    else printf("%d\n",H[i]);
  }
  printf("%d\n",cnt);
  return 0;
  
}



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

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

	int x_l, x_r;
	x_l = x/100;
	x_r = x%100;

	if(x_r <= x_l*5){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
    int a,b;
    cin>>a>>b;
    int sum=0;
    for(int i=0;i<2;i++){
    if(a>b){
        sum+=a;
        a--;
    }else{
        sum+=b;
        b--;
    }
    }
    cout<<sum<<endl;

    return 0;
}

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

int main(void){
    int n;
    cin>>n;
    vector<int> a(n+2);
    ll sum = 0;
    int pre = 0;
    rep1(i,n){
        cin>>a[i];
        sum += abs(pre-a[i]);
        pre = a[i];
    }
    sum += abs(a[n]);
    rep1(i,n){
        cout<<sum - (abs(a[i-1]-a[i])+abs(a[i]-a[i+1])) + abs(a[i+1]-a[i-1])<<endl;
    }
    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String w = scanner.next().toUpperCase();
        String s = scanner.next();
        int count = 0;
        while (!s.equals("END_OF_TEXT")) {
            s = s.toUpperCase();
            if (s.equals(w)) count++;
            s = scanner.next();
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26256
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    S = list(input().strip())
    T = list(input().strip())
    tt = 0
    for i in range(len(S)-len(T)+1):
        t = 0
        for j in range(len(T)):
            if S[i+j] == T[j]:
                t += 1
        tt = max(tt, t)
    print(len(T)-tt)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 64928
#-----UnionFind-----(0-indexed)
import sys;sys.setrecursionlimit(10**9)
class UnionFind:
  def __init__(self,n):
    self.n=[-1]*n
    self.r=[0]*n
    self.siz=n
  def find_root(self,x):
    if self.n[x]<0:
      return x
    else:
      self.n[x]=self.find_root(self.n[x])
      return self.n[x]
  def unite(self,x,y):
    x=self.find_root(x)
    y=self.find_root(y)
    if x==y:return
    elif self.r[x]>self.r[y]:
      self.n[x]+=self.n[y]
      self.n[y]=x
    else:
      self.n[y]+=self.n[x]
      self.n[x]=y
      if self.r[x]==self.r[y]:
        self.r[y]+=1
    self.siz-=1
  def root_same(self,x,y):
    return self.find_root(x)==self.find_root(y)
  def count(self,x):
    return -self.n[self.find_root(x)]
  def size(self):
    return self.siz

n,m=map(int,input().split())
p=list(map(int,input().split()))
u=UnionFind(n)
for _ in range(m):
  x,y=map(int,input().split())
  u.unite(x-1,y-1)
ans=0
for i in range(n):
  if u.root_same(i,p[i]-1):ans+=1
print(ans)

Measured memory_bytes: 13812
T = ["dream", "dreamer","erase", "eraser", ""]
S = input()
L = len(S)
ans = "YES"
while L >= 7:
    if S[-7:] == "dreamer":
        L -= 7
        S = S[:-7]
    elif S[-6:] == "eraser":
        L -= 6
        S = S[:-6]
    elif S[-5:] == "erase" or S[-5:] == "dream":
        L -= 5
        S = S[:-5]
    else:
        ans = "NO"
        break
if S in T:
    print(ans)
else:
    print("NO") 


Measured memory_bytes: 3188
#include<cstdio>

int main(){
    double r; //??????
    double p = 3.141592653589; //??
    scanf("%lf", &r);
    double S = p*r*r; //????????¢???
    double L = 2*p*r; //?????¨?????????
    printf("%f %f\n", S, L);
    
    return 0;
}

Measured memory_bytes: 1076
import sys
from collections import defaultdict
input = sys.stdin.readline
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    B = sorted(A)
    d = defaultdict( int)
    for i in range(N):
        d[B[i]] = i
    odd = 0
    for i in range(N):
        if (i+1)%2 == d[A[i]]%2 and d[A[i]]%2 == 1:
            odd += 1
    print(odd)
    
if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
  int N;
  int tmp;
  int sum = 0;
  vector<int> d;

  cin >> N;
  for(int i=0;i<N;i++){
    cin >> tmp;
    d.push_back(tmp);
  }

  for(int i=0;i<d.size()-1;i++){
    for(int j=i+1;j<d.size();j++){
      sum += d[i] * d[j];
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
ab = [[] for _ in range(N)]
for i in range(N-1) :
  a, b = map(int, input().split())
  ab[a-1].append((b-1, i))
  ab[b-1].append((a-1, i))
M = int(input())
uv = [[int(i) for i in input().split()] for _ in range(M)]

dp = [0] * M
def dfs(cur, pre, t, i) :
  if cur == t : return True
  for nex, j in ab[cur] :
    if nex == pre : continue
    if dfs(nex, cur, t, i) :
      dp[i] |= 1<<j
      return True
  return False

for i, (u, v) in enumerate(uv) :
  dfs(u-1, -1, v-1, i)

ret = 1<<(N-1)
for i in range(1, 1<<M) :
  sgn = 1
  s = 0
  for j in range(M) :
    if i & (1<<j) :
      s |= dp[j]
      sgn *= -1
  ret += sgn * (1<<(N-1-bin(s).count('1')))

print(ret)

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

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

int main()
{
    string s;
    cin >> s;
    int n = 0;
    rep(i, s.size()) {
        n += ctoi(s[i]);
    }
    if (n % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long tnum;

#define loop(i, num) for(int i = 0; i < num; i++)

tnum* tnumAlloc(int num);
tnum getNumStdin();
tnum* getNumsStdin(int);
char* getCharsStdin(int maxlength);
string getStringStdin();
void printlnNums(int count, tnum* nums);
void printlnNum(tnum num);
void printString(string str);

#define min(a,b) (a <= b ? a : b)
#define max(a,b) (a >= n ? a : b)

/*void sort(T* start, T* end) (in <algorithm>)
example:
	int a[5] = {2, 1, 3, 5, 4};
	sort(a, a + 5);
	-> a: {1, 2, 3, 4, 5}
*/


int main() {
	tnum t;
	tnum p, c, pp = 0, cp = 0;
    int flag = 0;

    string s1 = getStringStdin();
    string s2 = getStringStdin();

    if(s2.length() == s1.length() + 1){
        loop(i, s1.length()) {
            if(s1[i] != s2[i]){
                flag = 1;
                break;
            }
	    }
        if(!flag){
            printf("Yes");
        }
        else{
            printf("No");
        }
    }
    else{
        printf("No");
    }

	return 0;
}



//have to be free()
tnum* tnumAlloc(int num) {
	return (tnum*)calloc(num,sizeof(tnum));
}

tnum getNumStdin() {
	tnum ret;
	scanf("%lld", &ret);

	return ret;
}

//have to be free()
tnum* getNumsStdin(int num) {
	tnum* buf;
	tnum* tmp;
	buf = tnumAlloc(num);
	for (int i = 0; i < num; i++) {
		scanf("%lld", &buf[i]);
	}

	return buf;
}

//have to be free()
char* getCharsStdin(int maxlength) {
	char* ret = (char*)malloc(maxlength+1);
	scanf("%s", ret);

	return ret;
}

//have to be free()
string getStringStdin() {
	string ret;
	cin >> ret;
	return ret;
}

void printlnNum(tnum num) {
	printf("%lld\n", num);
}

// can be used for debugging
void printlnNums(int count, tnum *nums) {
	loop(i, count) {
		printf("%lld", nums[i]);
		if (i != count - 1) printf(" ");
	}
	printf("\n");
}

void printString(string str) {
	cout << str;
}

Measured memory_bytes: 3728
function main(input){
    var tmp = input.split(/\r\n|\r|\n/);
    var S = tmp[0];
    var T = tmp[1];


    if(S.length<T.length){
        console.log("UNRESTORABLE");
        return;
    }
    for(var i=S.length - T.length; i>=0; i--) {
        var flag = 0;
        var sub = S.substr(i, T.length);
        for(var j=0; j<T.length; j++){
            if(sub.charAt(j) === T.charAt(j) || sub.charAt(j) === "?"){

            }
            else{
                flag = 1;
                break;
            }
        }

        if(flag === 0){
            var res = S.substring(0, i) + T + S.substring(i+T.length);
            res = res.replace(/\?/g, "a");
            console.log(res);
            return;
        }
    }

    console.log("UNRESTORABLE");


}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <stdio.h>

int main()
{
	int x,y,a;
		
	while(1)
	{	
		scanf("%d %d",&x,&y);
		
		if(x == 0 && y == 0){
			break;
		}
		
		if(x > y)
		{
			a = 0;
			a = x;
			x = y;
			y = a;
		}
		printf("%d %d\n",x,y);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
ll a[1000005];
ll sum[1000005];
void init(){
	for(int i = 1;i <= 1000000;i++){
		if(i % 3 != 0 && i % 5 != 0){
			a[i] = i;
		}else{
			a[i] = 0;
		}
		sum[i] = sum[i - 1] + a[i];
	}
}
int n;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	init();
	cin >> n;
	cout << sum[n] << endl;
	return 0;
}

Measured memory_bytes: 18820
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 4*1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int n,t,a[110000];
signed main(){
  cin>>n>>t;rep(i,n)cin>>a[i];set<int> st;
  int mm = INF, value = 0;
  rep(i,n){
    chmin(mm, a[i]);
    chmax(value, a[i]-mm);
  }
  int ans = 0;
  rep(i,n){
    if(st.count(a[i]-value))ans++;
    st.insert(a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 5760
a=input()
b=input()
if (a=="1" and b=="2")or(a=="2" and b=="1"):
	print("3")
if (a=="1" and b=="3")or(a=="3" and b=="1"):
	print("2")
if (a=="3" and b=="2")or(a=="2" and b=="3"):
	print("1")

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b,c, x;
	string s;
	cin >> a >>b >>c;
	if(a==b) x=c;
	else if(b==c) x=a;
	else x=b;
	cout << x <<"\n";
	return 0;

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

	int n;
	int s;
	int[] ans;

	int memo[][];

	int rep(int masked, int answer) {
		if (memo[masked][answer] != -1) {
			return memo[masked][answer];
		}

		int count = 0;
		for (int i = 0; i < n; i++) {
			if ((ans[i] & masked) == answer) {
				count++;
			}
		}
		if (count < 2) {
			memo[masked][answer] = 0;
			return 0;
		}

		int min = 100;

		for (int i = 0; i < s; i++) {
			int shi =  1<<i;
			
			if((masked &shi) != 0){
				continue;
			}
			int z = shi;
			min = Math.min(
					min,
					Math.max(rep(masked | z, answer),
							rep(masked | z, answer | z)));
		}
		memo[masked][answer] = min+1;
		return min+1;
	}

	void run() {
		memo = new int[1 << 11][1 << 11];
		for (;;) {
			s = sc.nextInt();
			n = sc.nextInt();
			if (s + n == 0) {
				break;
			}
			ans = new int[n];

			for (int i = 0; i < n; i++) {
				ans[i] = sc.nextInt(2);
			}

			for (int i = 0; i < 1 << 11; i++) {
				Arrays.fill(memo[i], -1);
			}
			int m = rep(0, 0);

			System.out.println(m);
		}
	}

	public static void main(String[] a) {
		Main aa = new Main();
		aa.run();
	}

}

Measured memory_bytes: 29000
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>


using namespace std;

int main()
{
    long long x;
    cin>>x;
    
    int g1,g2;

    g1=x/500;
    x=x%500;
    g2=x/5;

    cout<<g1*1000+g2*5;

}






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

const int mod = 1000000007;
//const int mod = 998244353;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;
    vector<ll> a(4), b(3);
    a[0] = q*8; a[1] = h*4; a[2] = s*2; a[3] = d;
    b[0] = q*4; b[1] = h*2; b[2] = s;
    if(n%2 == 0){
        cout << n/2*min(a[0], min(a[1], min(a[2], a[3]))) << endl;
    }
    else{
        n--;
        cout << n/2*min(a[0], min(a[1], min(a[2], a[3]))) + min(b[0], min(b[1], b[2])) << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>
#include <math.h>

int main(){
	int n,a,d[4][14]={0};
	char c;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		getchar();
		scanf("%c %d",&c,&a);
		//printf(" c%c a%d\n",c,a);
		if(c=='S') d[0][a]=1;
		else if(c=='H') d[1][a]=1;
		else if(c=='C') d[2][a]=1;
		else if(c=='D') d[3][a]=1;
 	}
	for(int i=0;i<4;i++){
		for(int j=1;j<=13;j++){
			if(d[i][j]==0){
				if(i==0) c='S';
				else if(i==1) c='H';
				else if(i==2) c='C';
				else if(i==3) c='D';
				printf("%c %d\n",c,j);
			}
		}
	}
	return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll a, b;

ll ans;

int main(void) {
  // Here your code !
  scanf("%lld %lld", &a, &b);

  if (abs(a - b) % 2 == 1) {
    printf("IMPOSSIBLE\n");
    return 0;
  }

  ans = min(a, b) + (abs(a - b) / 2);

  printf("%lld\n", ans);

  return 0;
}


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

int main()
{
  int N;
  int A, B, C;
  int topi[105];
  cin >> N >> A >> B >> C;
  Rep(i,N) cin >> topi[i];
  sort( topi, topi + N, greater<int>() );
  int sum = C;
  int maxv = C / A;
  Rep(i,N) {
    sum += topi[i];
    maxv = max(maxv,sum / (A + (i + 1) * B));
  }
  cout << maxv << endl;
  return 0;
}

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

using Weight = ll;
struct Edge {
	int src, dst; Weight weight;
	char id;
	Edge() {}
	Edge(int s, int d, Weight w, char id) : src(s), dst(d), weight(w), id(id) {}
};
using Edges = vector<Edge>;

struct UnionFind {
	vector<int> par;
	int cnt;
	UnionFind(int size_) : par(size_, -1), cnt(size_) {}
	void unite(int x, int y) {
		if((x = find(x)) != (y = find(y))) {
			if(par[y] < par[x]) swap(x, y);
			par[x] += par[y]; par[y] = x; cnt--;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	int size(int x) { return -par[find(x)]; }
	int size() { return cnt; }
};

bool operator < (const Edge &e, const Edge &f) {
	if(e.weight != f.weight) return e.weight < f.weight;
	return e.id > f.id;
}
pair<Weight, Edges> kruskal(int N, Edges es) {
	UnionFind uf(N);
	sort(es.begin(), es.end());
	Weight total = 0; Edges T;
	for(auto &e : es) if(!uf.same(e.src, e.dst)) {
		T.push_back(e); total += e.weight; uf.unite(e.src, e.dst);
	}
	return make_pair(total, T);
}

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

	int N, M, K;
	while(cin >> N >> M >> K, N) {
		Edges es;
		UnionFind uf(N);
		for(int i = 0; i < M; i++) {
			int u, v, w;
			char l;
			cin >> u >> v >> w >> l;
			u--, v--;
			es.push_back(Edge(u, v, w, l));
			uf.unite(u, v);
		}

		if(uf.size(0) != N) {
			cout << -1 << endl;
			continue;
		}

		const ll INF = 1LL << 30;
		ll ng = -INF, ok = INF;
		while(abs(ng - ok) > 1) {
			ll mid = (ng + ok) / 2;
			for(int i = 0; i < M; i++) {
				if(es[i].id == 'A') es[i].weight += mid;
			}

			auto res = kruskal(N, es);
			int sum = 0;
			for(auto e : res.second) {
				if(e.id == 'A') sum++;
			}
			if(sum <= K) ok = mid;
			else ng = mid;

			for(int i = 0; i < M; i++) {
				if(es[i].id == 'A') es[i].weight -= mid;
			}
		}

		for(int i = 0; i < M; i++) {
			if(es[i].id == 'A') es[i].weight += ok;
		}
		auto resR = kruskal(N, es);
		for(int i = 0; i < M; i++) {
			if(es[i].id == 'A') es[i].weight--;
		}
		auto resL = kruskal(N, es);

		int sumR = 0, sumL = 0;
		for(auto e : resR.second) {
			if(e.id == 'A') sumR++;
		}
		for(auto e : resL.second) {
			if(e.id == 'A') sumL++;
		}
		if(sumR <= K && K <= sumL) {
			cout << resR.first - ok * K << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
}

Measured memory_bytes: 3172
import itertools

N,M,X = map(int,input().split())
C = [list(map(int,input().split())) for n in range(N)]
cost = 10**9

for com in itertools.chain(*(itertools.combinations(C,r) for r in range(1,N+1))):
    c,*a = map(sum,zip(*com))
    if c<cost and X<=min(a):
        cost = c

if cost==10**9:
  print(-1)
else:
  print(cost)

Measured memory_bytes: 9208
a = int(input())
b = int(input())
c = int(input())
x = int(input())

res = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        res += 1

print(res)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  i64 a, b, c;
  cin >> a;

  char d;
  cin >> d;
  b = d - '0';
  cin >> d;
  cin >> d;
  c = (d - '0') * 10;
  cin >> d;
  c += d - '0';

  a = a * b + a * c / 100;
  cout << a;
}
#endif


Measured memory_bytes: 3648
/*
NAME:
 ___   _      _   ___  
/ __| /_\    /_\ |   \ 
\__ \/ _ \  / _ \| |) |
|___/_/ \_\/_/ \_\___/ 
 
lang: 
  ___   _      _   
 / __)_| |_  _| |_ 
( (__(_   _)(_   _)
 \___) |_|    |_|  
 
*/
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
 
using namespace std;
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
 
typedef long long ll;
typedef long l;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<l> vl;
typedef vector<ll> vll;
 
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
 
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
 
void solve(){
	int n,m;
	cin>>n>>m;
	if(n==m) cout<<"Yes\n";
	else cout<<"No\n";
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
 
	solve();
 
	return 0;
} 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int selectionSort(int A[],int N)
{
	int minj,sw=0;
	for(int i = 0;i < N;i++)
	{
		minj = i;
		for(int j = i;j < N;j++)
		{
			if(A[j]<A[minj])
			{
				minj = j;
			}		
		}
		swap(A[i],A[minj]);
		if(i!=minj)
			sw++;
	}
	return sw;
}
int main()
{
	int A[100], N, sw=0;
	cin >> N;
	for(int i = 0;i < N;i++) cin >> A[i];
	sw = selectionSort(A,N);
	for(int i = 0;i < N;i++)
	{
		if(i)
			cout << " ";
		cout << A[i]; 
	} 
	cout << endl;
	cout << sw << endl;
	return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a;
  cin >> a;
  for (int i = 1; i <= 9; i++) {
    if (a % i == 0 && a / i <= 9) {
      cout << "Yes" << '\n';
      return 0;
    }
  }          
  cout << "No" << '\n';
  return 0;
}



Measured memory_bytes: 256