akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p = 0;
    cin >> n;
    string s;
    cin >> s;
    vector <ll> s1, s2, s3;
    for(i = 0; i < n; i++){
        if(s[i] == 'R'){
            s1.pb(i);
        }
        else if(s[i] == 'G'){
            s2.pb(i);
        }
        else{
            s3.pb(i);
        }
    }
    for(i = 0; i < s1.size(); i++){
        for(j = 0; j < s2.size(); j++){
            x = s1[i];
            y = s2[j];
            a = min(x,y);
            b = max(x,y);
            if(binary_search(s3.begin(),s3.end(),b-a+b)){
                sum --;
            }
            if((b-a)%2 == 0 && binary_search(s3.begin(),s3.end(),b-(b-a)/2)){
                sum--;
            }
            if(binary_search(s3.begin(),s3.end(),a-(b-a))){
                sum--;
            }
            sum += s3.size();
    }
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 3664
// Dont hack this or I hack ur mama
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#define ll long long 
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define EPS (1e-9)
using namespace std;

////////////// END OF TEMPLATE

const int nmax = 100100;

int x[nmax],y[nmax];
int indices[nmax];
int r[nmax];
int N;
vector < pair < ll, pair < int ,int > > > edges;

int root(int index)
{
	return (r[index] == index) ? index : (r[index] = root(r[index]));
}
void read()
{
	cin >> N;
	for(int i =0 ; i < N; ++i)
	{
		cin >> x[i] >> y[i];
		indices[i] = i;
		r[i] = i;
	}
	sort(indices, indices + N, [](int a, int b){
				return x[a] < x[b];
			});
	for(int i = 0 ; i < N - 1; ++i)
	{
		edges.push_back(make_pair(x[indices[i+1]]-x[indices[i]], make_pair(indices[i+1],indices[i])));
	}
	sort(indices, indices + N, [](int a, int b){
				return y[a] < y[b];
			});
	for(int i = 0 ; i < N - 1; ++i)
	{
		edges.push_back(make_pair(y[indices[i+1]]-y[indices[i]], make_pair(indices[i+1],indices[i])));
	}
	sort(edges.begin(), edges.end());
	ll ans = 0;
	for(int i = 0 ; i < edges.size(); ++i)
	{
		if(root(r[edges[i].second.first]) == root(r[edges[i].second.second]))
			continue;
		ans+=edges[i].first;
		r[root(edges[i].second.first)]  = root(edges[i].second.second);	
	}	
	cout << ans << endl;
}
void solve()
{

}
int main()
{
	std::ios::sync_with_stdio(false);
	read();
	solve();
	return 0;
}


Measured memory_bytes: 8048
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	sort.Ints(arr)
	sum := arr[N-1]
	need := N - 2

	for i := N - 2; need > 0; i-- {
		if need > 1 {
			sum += arr[i] * 2
			need -= 2
		} else {
			sum += arr[i]
			need--
		}
	}
	fmt.Printf("%d\n", sum)
}


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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define frepi(a,b) for(int i=a;i<=b;++i)
// #define int long long
// --------------------------------------------------------------------------------

void test_case(int tc)
{
	int d,t,s;cin>>d>>t>>s;
	double time = (double)(d)/s;
	if(time>t)cout<<"No";
	else cout<<"Yes";
}

int32_t main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif
	
    int tc=1;
    //cin>>tc;
    for(int i=1;i<=tc;++i)test_case(tc);
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main(){

	long long int n;
	long long int sum = 0;
	
	scanf("%lld", &n);
	
	for(int i = 1; i <= n; i++){
		if((i%3 != 0 && i%5 != 0)){
			sum += i;
		}
	}
	
	printf("%lld", sum);
}

Measured memory_bytes: 1708
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = list(input()[:-1].decode())
    for i in range(len(s)):
        if i % 2 == 0:
            if not s[i] in ['R', 'U', 'D']:
                print('No')
                exit()
        else:
            if not s[i] in ['L', 'U', 'D']:
                print('No')
                exit()
    print('Yes')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
typedef long long llint;


llint n;
llint a[300005];
void solve(){
  cin >> n;
  for(int i=0;i<3*n;i++){
    cin >> a[i];
  }
  sort(a,a+3*n);
  reverse(a,a+3*n);
  llint ans=0;
  for(int i=0;i<n;i++){
    ans+=a[2*i+1];
  }
  cout << ans << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  deque<int> b;

  for (int i=0; i<n; i++) {
    if (i%2==0) {
      b.push_front(a[i]);
    } else {
      b.push_back(a[i]);
    }
  }

  if (n%2==0) {
    for (int i=0; i<n; i++) {
      if (i==0) cout << b[n-i-1];
      else cout << " " << b[n-i-1];
    }
  } else {
    for (int i=0; i<n; i++) {
      if (i==0) cout << b[i];
      else cout << " " << b[i];
    }
  }
  cout << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
typedef long long llong;

int score[100010];
int N;
int H[100010];



int main() {

	cin >> N;

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

	score[0] = 0;
	score[1] = abs(H[1] - H[0]);
	for (int i = 2; i < N; i++) {
		score[i] = min(score[i-1]+abs(H[i] - H[i - 1]), score[i-2]+abs(H[i] - H[i - 2]));
	}
	cout << score[N - 1] << endl;


	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define ALL(x) begin(x), end(x)
using namespace std;

int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> a(n); REP (i, n) scanf("%d", &a[i]);
    // solve
    int argmin_a = min_element(ALL(a)) - a.begin();
    int argmax_a = max_element(ALL(a)) - a.begin();
    vector<pair<int, int> > result;
    if (abs(a[argmin_a]) <= abs(a[argmax_a])) {
        REP (i, n) if (i != argmax_a) result.emplace_back(argmax_a, i);
        REP (i, n - 1) result.emplace_back(i, i + 1);
    } else {
        REP (i, n) if (i != argmin_a) result.emplace_back(argmin_a, i);
        REP_R (i, n - 1) result.emplace_back(i + 1, i);
    }
    // output
    printf("%d\n", int(result.size()));
    for (auto op : result) {
        int x, y; tie(x, y) = op;
        printf("%d %d\n", x + 1, y + 1);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int tax(int p,int x){
	return p*(100+x)/100;
}

int main(){
	int x,y,s;
	int i,j,k,l,m,n;
	int ans;
	int p1,p2;
	while(1){
		scanf("%d %d %d",&x,&y,&s);
		if(x==0&&y==0&&s==0)break;
		//printf("%d %d %d\n",x,y,s);
		ans=0;
		for(i=1; i<s; i++){
			for(j=1; j<s; j++){
				p1=i;
				p2=j;
				if(tax(p1,x)+tax(p2,x)==s){
					if(tax(p1,y)+tax(p2,y)>ans){
						ans=tax(p1,y)+tax(p2,y);
					}
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 600
//
// Created by yamunaku on 2020/03/22.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    string s;
    cin >> s;
    int n = s.size();
    string t = s;
    reverse(all(t));
    if(s != t){
        CNO;
        return 0;
    }
    string s1 = s.substr(0, n / 2), s2 = s.substr(n / 2 + 1, n / 2);
    string t1 = s1, t2 = s2;
    reverse(all(t1)), reverse(all(t2));
    if(s1 == t1 && s2 == t2) CYES;
    else
        CNO;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

int main() {
	ll K, N; cin >> K >> N;
	ll ans = K, m = 0;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		int j = (i + 1) % N;
		ll x = a[j] - a[i];
		if (x < 0) { x += K; }
		chmax(m, x);
	}
	cout << ans - m << endl;
	return 0;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,k,ans;cin>>n>>k;
    if(k==1)ans=0;
    else{
        ans=n-k;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
#define oset tree<int, null_type,greater<int>, rb_tree_tag,tree_order_statistics_node_update>

bool isprime(int n)
{
    bool fl = false;
    for(int i=2; i*i<=n; i++){
        if(n%i == 0){
            fl = true;
            break;
        }
    }
    return fl;
}

int main()
{
    int n;
    cin >> n;
    while(isprime(n)){
        n++;
    }
    cout << n;

    return 0;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 20:59:02 2019
//
package main

import (
	"bufio"
	"fmt"
	"os"
)

type route struct {
	to, weight int
}

type graph [][]route

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var depths []int

func dfs(n int, g graph, weight int) {
	depths[n] = weight
	for i := range g[n] {
		to, w := g[n][i].to, g[n][i].weight
		if depths[to] == -1 && w > 0 {
			dfs(to, g, weight+w)
		}
	}
}

func main() {
	var N, Q, K int
	fmt.Sscan(nextLine(), &N)

	g := make(graph, N)

	for i := 0; i < N-1; i++ {
		var a, b, c int
		fmt.Sscan(nextLine(), &a, &b, &c)
		g[a-1] = append(g[a-1], route{to: b - 1, weight: c})
		g[b-1] = append(g[b-1], route{to: a - 1, weight: c})
	}

	fmt.Sscan(nextLine(), &Q, &K)

	depths = make([]int, len(g))
	for i := range depths {
		depths[i] = -1
	}
	dfs(K-1, g, 0)

	for i := 0; i < Q; i++ {
		var x, y int
		fmt.Sscan(nextLine(), &x, &y)
		fmt.Println(depths[x-1] + depths[y-1])
	}
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a + b > c + d){
    cout << "Left" << endl;
  }else if(a + b == c + d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, x;
  int counter = 0;

  while(1){
	scanf("%d %d", &n, &x);
	if(n == 0 && x == 0){break;}
	for(int i = 1; i <= n; i++){
	  for(int j = 1; j <= n; j++){
		for(int k = 1; k <= n; k++){
		  if((i + j + k) == x && i < j && j < k){
counter += 1;
		  }
		}
	  }
	}
	printf("%d\n", counter);
	counter = 0;
  }
  return 0;
}


Measured memory_bytes: 2052
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long Int;

Int n, k, sum, res;
Int a[108000];

int main(){
	while(true){
		cin >> n >> k;
		if(n == 0 && k == 0)break;
		
		for(int i = 0;i < n;i++){
			cin >> a[i];
		}

		sum = 0;
		for(int i = 0;i < k;i++){
			sum += a[i];
		}
		res = sum;

	for(int i = k;i < n;i++){
		sum -= a[i-k];
		sum += a[i];
		res = max(res, sum);
	}
	cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3772
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    ll h, w;

    cin >> h >> w;

    if(h % 3 == 0 || w % 3 == 0){
        cout << 0 << endl;
        return 0;
    }

    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }

    ll ans = INF;
    ll total = h * w;
    ll rest = total;
    ll a = 0;
    ll b = 0;
    ll c = 0;

    for(int i = 1; i <= w; i++){
        rest -= h;
        a += h;
        if((w - i) % 2 == 0){
            b = rest / 2;
            c = rest / 2;
        } else {
            b = h * ((w - 1) / 2);
            c = h * (((w - 1) / 2) + 1);
        }
        ll maxi = max({a, b, c});
        ll mini = min({a, b, c});
        ans = min(ans, maxi - mini);
    }

    a = 0;

    for(int i = 1; i <= h; i++){
        rest -= w;
        a += w;
        if((h - i) % 2 == 0){
            b = rest / 2;
            c = rest / 2;
        } else {
            b = w * ((h - 1) / 2);
            c = w * (((h - 1) / 2) + 1);
        }
        ll maxi = max({a, b, c});
        ll mini = min({a, b, c});
        ans = min(ans, maxi - mini);
    }

    // cout << ans << endl;

    rest = total;
    a = 0;
    b = 0;
    c = 0;
    for(int i = 1; i <= w; i++){
        rest -= h;
        a += h;
        if(h % 2 == 0){
            b = rest / 2;
            c = rest / 2;
        } else {
            b = (w - i) * (h / 2);
            c = (w - i) * (h / 2 + 1);
        }
        // cout << a << " " << b << " " << c << endl;
        ll maxi = max({a, b, c});
        ll mini = min({a, b, c});
        ans = min(ans, maxi - mini);
    }

    rest = total;
    a = 0;
    b = 0;
    c = 0;
    for(int i = 1; i <= h; i++){
        rest -= w;
        a += w;
        if(w % 2 == 0){
            b = rest / 2;
            c = rest / 2;
        } else {
            b = (h - i) * (w / 2);
            b = (h - i) * (w / 2 + 1);
        }
        ll maxi = max({a, b, c});
        ll mini = min({a, b, c});
        ans = min(ans, maxi - mini);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import heapq
n = int(input())
A = list(map(int, input().split()))
heapq.heapify(A)

cnt = 1
prev = heapq.heappop(A)
while A:
    x = heapq.heappop(A)
    if prev > x:
        heapq.heappush(A, prev)
        prev = x
        continue
    if 2*prev < x:
        cnt = 1
    else:
        cnt += 1
    prev += x

print(cnt)


Measured memory_bytes: 14320
import java.lang.Math.min

fun main(args: Array<String>) {

    val (d, g) = readLine()!!.split(' ').map(String::toInt)
    val scores = (1..d).map{
        val (p, c) = readLine()!!.split(' ').map(String::toInt)
        listOf(100 * it, p, c)
    }
    var ans = Int.MAX_VALUE
    loop@ for(bit in 0 until (1 shl d)){
        var score = 0
        var num = 0
        for(i in 0 until d){
            if(bit and (1 shl i) != 0){
                score += scores[i][0] * scores[i][1] + scores[i][2]
                num += scores[i][1]
            }
        }

        if(score >= g) {
            ans = min(ans, num)
            continue@loop
        }
        for(i in d-1 downTo 0){
            if(bit and (1 shl i) != 0) continue
            for(j in 0 until scores[i][1]){
                if(score >= g){
                    ans = min(ans, num)
                    continue@loop
                }
                score += scores[i][0]
                num++
            }
        }


    }

//    print(calcF1(g, scores.reversed(), 0))
    print(ans)
}

fun calcF1(goal: Int, probs: List<List<Int>>, acc: Int): Int?{
    val len = probs.size
    fun inI(i : Int, goal: Int, bit: Int, acc: Int): Int?{
        if(goal < 0) return acc
        if(i !in probs.indices) {
            val ps = probs.mapIndexedNotNull{index, list ->  if(1 and (bit shr index) == 1) null else list}
            return calcF2(goal, ps, acc)
        }
        val iscore = probs[i].let { it[0] * it[1] + it[2]}
        return min(inI(i+1, goal - iscore, bit + (1 shl i), acc + probs[i][1]) ?: Int.MAX_VALUE, inI(i+1, goal, bit, acc) ?: Int.MAX_VALUE)
    }
    return inI(0, goal, 0, acc)
}

fun calcF2(goal: Int, probs: List<List<Int>>, acc: Int): Int?{
    if(goal <= 0) return acc
    if(probs.isEmpty()) return null

    val current = probs.first()
    val rest = probs.subList(1, probs.size)

    return (0..current[1]).mapNotNull {i ->
        val score = current[0] * i + if(i == current[1]) current[2] else 0
        calcF2(goal - score, rest, acc + i)
    }.min()
}

Measured memory_bytes: 37240
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, M; cin >> N >> M;
	vector<int>X(N); rep(i, 0, N) { cin >> X[i]; }
	vector<int>v(1e5 + 10);
	map<int, map<int, int>>mp;
	rep(i, 0, N) {
		v[X[i] % M]++;
		mp[X[i] % M][X[i]]++;
	}
	int ans = 0;
	rep(i, 0, M) {
		int j = (M - i) % M;
		if (i == j) {
			ans += v[i] / 2;
			v[i] -= v[i] / 2 * 2;
		}
		else {
			int z= min(v[i], v[j]);
			ans += z;
			v[i] -= z;
			v[j] -= z;
		}
	}
	rep(i, 0, v.size()) {
		int s = v[i] / 2;
		if (s) {
			auto m = mp[i];
			for (auto p : m) {
				int q = p.second / 2;
				int t = min(q, s);
				s -= t;
				ans += t;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17408
package main

import (
  "fmt"
  "sort"
  "strings"
)

func main() {
  var n, l int 
  fmt.Scan(&n, &l)
  s := make([]string, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&s[i])
  }
  sort.Sort(sort.StringSlice(s))
  fmt.Println(strings.Join(s, ""))
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <set>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <iomanip>
#include <utility>

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int n, k;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("river.in", "r", stdin);
	//freopen("river.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i * 4 <= n; i++)
		if ((n - 4 * i) % 7 == 0)
		{
			cout << "Yes";
			return 0;
		}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+50;
int a[maxn], b[maxn], c[maxn];
int n;
int main(){ 
	while(cin >> n){
		for(int i = 0; i < n; i++)cin >> a[i];
		for(int i = 0; i < n; i++)cin >> b[i];
		for(int i = 0; i < n; i++)cin >> c[i];
		sort(a, a+n);
		sort(c, c+n);
		ll ans = 0;
		for(int i = 0; i < n; i++){
			ll l = lower_bound(a, a+n, b[i]) - a;
			ll r = n - (upper_bound(c, c+n, b[i]) - c);
			ans += l*r;
		}
		cout << ans << endl;
	}
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

ll a,b,c;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
    cout << 0 << endl;
  else
    cout << min(a * b,min(b * c,a * c));
}

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

using namespace std;

static const int N = 100;
static const int INF = (1 << 21);

int main() {
    int n;
    int p[N + 1];
    int m[N + 1][N + 1];

    cin >> n;

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

    for (int i = 0; i <= n; i++) m[i][i] = 0;
    for (int l = 2; l <= n; l++) {
        for (int i = 1; i <= n - l + 1; i++) {
            int j = i + l - 1;
            m[i][j] = INF;
            for (int k = i; k <= j; k++) {
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i -1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;
    return 0;
}



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

struct UnionFind{
  int n;
  vector<int> r, p;
  UnionFind() {}
  UnionFind(int sz): n(sz), r(sz, 1), p(sz, 0){ iota(p.begin(), p.end(), 0); }
  int find(int x) {
    return (x == p[x] ? x : p[x] = find(p[x]));
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y){
    x = find(x); y = find(y);
    if ( x == y ) return;
    if ( r[x] < r[y] ) swap(x, y);
    r[x] += r[y];
    p[y] = x;
  }
};

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

  UnionFind uf(n);
  for ( int i = 0; i < m; i++ ) {
    int s, t;
    cin >> s >> t;
    uf.unite(s, t);
  }

  int q;
  cin >> q;
  for ( int i = 0; i < q; i++ ) {
    int s, t;
    cin >> s >> t;
    if ( uf.same(s, t) ) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  
  return 0;
}



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

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

    vector<pair<int,int>> v[m];

    int s, t, e;
    while(scanf("%d %d %d", &s, &t, &e), s+t+e){
        v[--t].push_back({--s,e});
    }

    int l;
    scanf("%d", &l);

    for(int i = 0; i < l; i++){
        vector<int> sal(n), b(m);
        for(int i = 0; i < m; i++)  scanf("%d", b.begin()+i);
        for(int i = 0; i < m; i++){
            for(int j = 0; j < v[i].size(); j++){
                sal[v[i][j].first] += v[i][j].second * b[i];
            }
        }
        for(int i = 0; i < n; i++)  printf("%d%c", sal[i], " \n"[i == n-1]);
    }

    return 0;
}


Measured memory_bytes: 4308
#include <iostream>
using namespace std;
int main()
{
	int n,m,ans;
	char IOI[1000001];
	while(cin>>n,n){
		//cin>>m>>IOI;
		scanf("%d %s",&m,IOI);
		int i,k;
		ans = 0;
		n = 2*n+1;
		k=0;
		// 4__ IOIOIOIOI
		for(;;){
			for(i=0; i<n/2; i++){
				if( IOI[i+k]!=(i&1?'O':'I') ||
					 IOI[i+k]!=IOI[k+n-i-1] )
					break;
			}
			if( i==n/2 && IOI[k+n/2]==((n/2)%2?'O':'I')){
				//printf("k_%d IOI[%d]=%c\n",k,k+n/2,IOI[k+n/2]);
				ans++;
				k += n;
				for(; k<m; k+=2){
					if( IOI[k]=='O' && IOI[k+1]=='I' ){
						ans++;
						//printf("k__%d\n",k);
					}
					else break;
				}
			}else{
				for(k++; k<m && IOI[k]=='O'; k++);
			}
			//printf("next_k_%d\n",k);
			if( k+n>m )break;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1896
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  vector<int> l(n); REP(i, n) cin >> l[i];
  sort(ALL(l));
  long long ans = 0;
  REP(i, n) FOR(j, i + 1, n) {
    int lhs = l[j] - l[i], rhs = l[i] + l[j];
    ans += lower_bound(ALL(l), rhs) - l.begin() - max(int(upper_bound(ALL(l), lhs) - l.begin()), j + 1);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define ll long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const ll MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	int n;
	cin >> n;
	string str = to_string(n);
	if (str[0] == '7' || str[1] == '7' || str[2] == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if(S[0] == S[1] && S[1] == S[2] || S[1] == S[2] && S[2] == S[3]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	
	ll n;
	cin >> n;
	ll a[n];
	double sum = 0;
	
	rep(i,0,n){
		cin >> a[i];
		
		sum += (double)1/a[i];
	}
	
	cout << 1/sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#include <sstream>
#define REP(i,x) for(int i=0; i<(x); i++)
typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    int n,m;
    cin >> n >> m;
    ll x[n],y[n],z[n];
    ll selector[8][3] = {{1,1,1},{1,1,-1},{1,-1,1},{-1,1,1},{1,-1,-1},{-1,1,-1},{-1,-1,1},{-1,-1,-1}};
    REP(i,n){
        cin>> x[i] >> y[i] >> z[i];
    }
    ll copy[8][n];
    for(int i=0; i<8; i++){
        REP(j,n){
            copy[i][j] = (x[j]*selector[i][0])+(y[j]*selector[i][1])+(z[j]*selector[i][2]);
        }
        sort(copy[i],copy[i]+n,greater<ll>());
    }
    ll out = 0;
    REP(i,8){
        ll orx = 0;
        REP(j,m){
            orx += copy[i][j];
        }
        out = max(out,orx);
    }

    cout << out << endl;
    
    return 0;
}


Measured memory_bytes: 384
H,W = gets.split.map(&:to_i)
Ss = H.times.map{ gets.chomp.chars}

def mine(h,w)
    sum = 0
    # 上下をチェック
    (h-1..h+1).each do |hi|
        next if hi < 0 || H <= hi
        # 左右をチェック
        (w-1..w+1).each do |wi|
            next if wi < 0 || W <= wi
            sum += 1 if Ss[hi][wi] == '#'
        end
    end
    return sum
end

H.times do |h|
    W.times do |w|
        print Ss[h][w] == '#' ? '#' : mine(h,w)
    end
    print "\n"
end


Measured memory_bytes: 3836
#include <stdio.h>
#define inf (int)(2e9)

int only_plus(int x){
	if(x >= 0){
		return x;
	}
	else{
		return inf;
	}
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int x, y;
	scanf("%d%d", &x, &y);
	printf("%d\n", min(min(only_plus(y - x), only_plus(1 + y + x)), min(only_plus(1 - y - x), only_plus(2 - y + x))));
	return 0;
}

Measured memory_bytes: 128
from collections import  Counter
n,m,q=map(int,input().split())
h=[[0]*(n) for _ in range(n)]
for i in range(m):
    l,r=map(int,input().split())
    l-=1
    r-=1
    h[n-1-l][r]+=1
ans=0
for i in range(n):
    for j in range(n-1):
        h[i][j+1] += h[i][j]
 
for j in range(n):
    for i in range(n-1):
        h[i+1][j] += h[i][j]

for i in range(q):
    x,y=map(int,input().split())
    x-=1
    y-=1
    print(h[n-1-x][y])

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

ll N;
int c[200010];
int cnt[200010];
int son[200010];
ll ans[200010];
vector<int> G[200010];

void dfs(int v, int p){
    son[v] = 1;
    for(auto u : G[v]){
        if(u == p) continue;
        ll memo = cnt[c[v]];
        dfs(u, v);
        ll m = son[u] - (cnt[c[v]] - memo);
        ans[c[v]] -= m * (m - 1) / 2 + m;
        son[v] += son[u];
        cnt[c[v]] = memo + son[u];
    }
    cnt[c[v]]++;
}

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> c[i];
        ans[i] = N * (N - 1) / 2 + N;
    }
    for(int i = 1; i < N; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(1, 0);
    for(int i = 1; i <= N; i++){
        ll m = son[1] - cnt[i];
        ans[i] -= m * (m - 1) / 2 + m;
    }
    for(int i = 1; i <= N; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 37148
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using P = pair<long long, long long>;

long long n;
vector<P> v, l, r;

long long solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i].se >> v[i].fi;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  sort(v.begin(), v.end());
  l.assign(n, {0, 0});
  r.assign(n, {0, 0});
  for(int i = 0; i < n; ++i) {
    l[i].se = v[0].fi;
    if(i == 0)
      l[i].fi = v[0].se;
    else
      l[i].fi = max(l[i - 1].fi, v[i].se);
  }
  for(int i = n - 1; i >= 0; --i) {
    r[i].se = v[i].fi;
    if(i == n - 1)
      r[i].fi = v[i].se;
    else
      r[i].fi = max(r[i + 1].fi, v[i].se);
  }
  long long ans = 0;
  for(int i = 0; i < n; ++i) {
    long long now = v[i].fi - v[i].se + 1;
    now += max(0LL, v[0].fi - max(l[i].fi, r[i].fi) + 1);
    ans = max(ans, now);
  }
  for(int i = 0; i < n - 1; ++i) {
    long long now = 0;
    now = max(0LL, l[i].se - l[i].fi + 1);
    now += max(0LL, r[i + 1].se - r[i + 1].fi + 1);
    ans = max(ans, now);
  }
  return ans;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];
    for (int i = 0; i < n; ++i) {
        if (i > 0 && h[i - 1] > h[i]) {
            cout << "No" << endl;
            return 0;
        }
        if (i == 0 || h[i - 1] < h[i]) --h[i];
    }
    // for (int i = 0; i < n; ++i) cerr << h[i] << ' ';
    // cerr << endl;
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
		
		while(sc.hasNextInt()){
			int n = sc.nextInt();
			int q = sc.nextInt();
			if(n == 0 && q == 0){
				break;
			}
			else{
				calc(n,q);
			}
		}
	}
	public void calc(int n, int q){
		int[] dates = new int[101];
		for(int i = 0; i < n; i++){
			int m = sc.nextInt();
			for(int j = 0; j < m; j++){
				int date = sc.nextInt();
				dates[date] = dates[date] + 1;
			}
		}
		
		int maxDate = 0;
		for(int i = 1; i < 101; i++){
			if(dates[maxDate] < dates[i]) maxDate = i;
		}
		if(dates[maxDate] < q) maxDate = 0;
		System.out.println(maxDate);
	}
	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 60756
data=list(input())
if eval(data[0]+"+"+data[1]+"+"+data[2]+"+"+data[3])==7:
    print(data[0]+"+"+data[1]+"+"+data[2]+"+"+data[3]+"=7")
elif eval(data[0]+"+"+data[1]+"+"+data[2]+"-"+data[3])==7:
    print(data[0]+"+"+data[1]+"+"+data[2]+"-"+data[3]+"=7")
elif eval(data[0]+"+"+data[1]+"-"+data[2]+"-"+data[3])==7:
    print(data[0]+"+"+data[1]+"-"+data[2]+"-"+data[3]+"=7")
elif eval(data[0]+"+"+data[1]+"-"+data[2]+"+"+data[3])==7:
    print(data[0]+"+"+data[1]+"-"+data[2]+"+"+data[3]+"=7")
elif eval(data[0]+"-"+data[1]+"+"+data[2]+"+"+data[3])==7:
    print(data[0]+"-"+data[1]+"+"+data[2]+"+"+data[3]+"=7")
elif eval(data[0]+"-"+data[1]+"+"+data[2]+"-"+data[3])==7:
    print(data[0]+"-"+data[1]+"+"+data[2]+"-"+data[3]+"=7")
elif eval(data[0]+"-"+data[1]+"-"+data[2]+"-"+data[3])==7:
    print(data[0]+"-"+data[1]+"-"+data[2]+"-"+data[3]+"=7")
elif eval(data[0]+"-"+data[1]+"-"+data[2]+"+"+data[3])==7:
    print(data[0]+"-"+data[1]+"-"+data[2]+"+"+data[3]+"=7")
else:
    pass

Measured memory_bytes: 62320
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool dp[2][2][40010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int x, y;
    cin >> x >> y;
    int n = S.length();
    rep(i, n) {
        if(S[i] == 'F') {
            x--; 
        }
        if(S[i] == 'T' || i + 1 == n){
            S = S.substr(i + 1);
            break;
        }
    }
    // cout << S << endl;
    vector<int> v;
    n = S.length();
    bool isturn = true;
    int len = 0;
    rep(i, n) {
        if (S[i] == 'F') len++;
        if (S[i] == 'T' || i + 1 == n) {
            v.push_back(len);
            len = 0;
        }
    }
    // rep(i, v.size()) cout << v[i] << " ";
    // cout << endl;
    dp[0][0][20000] = dp[1][0][20000] = true;
    rep(i, v.size()) {
        REP(j, -16000, 16000) dp[1][(i + 1) % 2][20000 + j] = dp[0][(i + 1) % 2][20000 + j] = false;
        REP(j, -8000, 8000) {
            if (i % 2 == 0) {
                dp[0][(i + 1) % 2][20000 + j] |= dp[0][i % 2][20000 + j];
                dp[1][(i + 1) % 2][20000 + j + v[i]] |= dp[1][i % 2][20000 + j];
                dp[1][(i + 1) % 2][20000 + j - v[i]] |= dp[1][i % 2][20000 + j];
            } else {
                dp[1][(i + 1) % 2][20000 + j] |= dp[1][i % 2][20000 + j];
                dp[0][(i + 1) % 2][20000 + j + v[i]] |= dp[0][i % 2][20000 + j];
                dp[0][(i + 1) % 2][20000 + j - v[i]] |= dp[0][i % 2][20000 + j];
            }
        }
    }
    //cout << x << " " << y << endl;
    //REP(i, -10, 10) cout << i << " " << dp[1][v.size()][10000 + i] << endl;
    if(dp[0][v.size() % 2][20000 + x] && dp[1][v.size() % 2][20000 + y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 512
N,W=map(int,input().split())
dp=[[0]*(W+1) for _ in range(N+1)]
for i in range(1,N+1):
	w,v=map(int,input().split())
	for j in range(1,W+1):
		if j-w>=0:
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
		else:
			dp[i][j]=dp[i-1][j]
print(dp[N][W])

Measured memory_bytes: 119916
#include <iostream>
#include <algorithm>

long long a, b, c;

int main() {
	std::cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		std::cout << 0 << std::endl;
		return 0;
	}

	std::cout << std::min({ a * b, b * c, c * a }) << std::endl;

	return 0;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

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

    ll n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(sum([abs(a[i] - b[i]) for i in range(n)]))
print(pow(sum([abs(a[i] - b[i]) **2 for i in range(n)]), 1/2))
print(pow(sum([abs(a[i] - b[i]) **3 for i in range(n)]), 1/3))
print(max([abs(a[i] - b[i]) for i in range(n)]))



Measured memory_bytes: 5700
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int N=2e5+5;
struct edge
{
    int u,v,w;
    bool operator<(const edge&o)const
    {
        return w<o.w;
    }
}e[N];
int n,m,a[N],f[N];
ll sum[N],p[N];
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) f[i]=i,sum[i]=a[i];
    for(int i=1;i<=m;i++) scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
    sort(e+1,e+1+m);
    for(int i=1;i<=m;i++)
    {
        int fu=getf(e[i].u),fv=getf(e[i].v);
        if(fu!=fv)
        {
            f[fu]=fv;
            sum[fv]+=sum[fu];
            p[fv]+=p[fu];
        }
        p[fv]++;
        if(e[i].w<=sum[fv]) p[fv]=0;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        if(getf(i)==i) ans+=p[i];
    printf("%d\n",ans);
}


Measured memory_bytes: 6016
#include<stdio.h>                                                                                                             
int main(void){
    int i;
    char odd[50];
    char even[50];
    char output[100];
        scanf("%s %s",odd,even);
    for(i=0;i<=50;i++){
            output[2*i]=odd[i];
            output[2*i+1]=even[i];
    }   
    printf("%s\n",output);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;


struct Segmenttree{
    int n;
    vector<long long> node;

    Segmenttree(vector<long long> v){
        n = (int)(v.size());
        node.resize(2*n);
        for(int i=0;i<n;i++) node[i+n] = v[i];
        for(int i=n-1;i>=0;i--) node[i] = node[i<<1] + node[i<<1|1];
    }
    //i番目の要素にxを足す
    void update(int i,long long x){
        i += n;
        node[i] += x;
        while(i>1){
            i >>= 1;
            node[i] = node[i<<1] + node[i<<1|1];
        }
    }
    //[l,r)の要素の和を求める
    long long query(int l,int r){
        if(r>n) r=n;
        if(l>n) return 0;
        if(l>=r) return 0;
        long long res = 0;
        l += n; r += n;
        while(l<r){
            if(l&1) res += node[l++];
            if(r&1) res += node[--r];
            l >>= 1; r >>= 1;
        }
        return res;
    }
    //i番目の要素にアクセス
    long long getval(int i){
        return node[i+n];
    }
};

struct qq{
    int t;
    ll a,b;
};

int main(){
    int q;
    cin >> q;
    vector<qq> query(q);
    vector<P> pp;
    rep(i,q){
        int t;
        cin >> t;
        if(t==1){
            int a,b;
            cin >> a >> b;
            query[i] = qq{t,a,b};
            pp.push_back(P(a,i));
        }else{
            query[i] = qq{t,-1,-1};
        }
    }
    sort(pp.begin(),pp.end());
    map<P,int> mp;
    rep(i,pp.size()){
        mp[pp[i]] = i;
    }

    Segmenttree seg(vector<ll>((int)(pp.size()),0));
    set<int> st;

    int idx = 0;
    int sz = 0;
    ll bb = 0;
    rep(i,q){
        if(query[i].t==1){
            P pq = P(query[i].a,i);
            int id = mp[pq];
            seg.update(id,query[i].a);
            bb += query[i].b;
            ++sz;
            st.insert(id);
            if(idx<id&&sz%2==1){
                idx = *(++st.find(idx));
            }
            if(id<idx&&sz%2==0){
                idx = *(--st.find(idx));
            }
        }else{
            ll res = 0;
            if(sz%2==0){
                res += seg.query(idx+1,(int)(pp.size())+1);
                res -= seg.query(0,idx+1);
            }
            else{
                res += seg.query(idx+1,(int)(pp.size())+1);
                res -= seg.query(0,idx);
            }
            cout << seg.node[seg.n+idx] << " " << res+bb << endl;
        }
    }
    return 0;    
}

Measured memory_bytes: 34468
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
int n;
bool ok[10001];
int main()
{
	for(int i=0;i<=9;++i)ok[i*111]=ok[i*1111]=1;
	cin>>n;
	if(ok[n] || ok[n/10] || ok[n%1000])puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char f(char a, char b) {
    if (a == b) {
        return 'H';
    }
    return 'D';
}

int main() {

    char a, b;
    cin >> a >> b;

    char result = f(a, b);
    cout << result << endl;

    return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,num1=0,num2=0;
    cin >> n;
    string s;
    cin >> s;
    ll size = s.size();
    rep(i,size){
        if(s[i]=='R') num1++;
        else num2++;
    }
    if(num1 > num2) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a, b;
	cin >> a >> b;
	int ans = 0;
	REP(i, n) {
		int c = i + 1;
		int cnt = 0;
		while (c > 0) {
			cnt += c % 10;
			c /= 10;
		}
		if (cnt <= b&&cnt >= a)ans+=i+1;

	}
	cout << ans << endl;

}


Measured memory_bytes: 256