akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

int x, y, z, k, res = 0, tmp = 0;
string s;
main(){
    INCANT;
    in(x, y, z, k);
    int a[x], b[y], c[z];
    rep(i, x){
        in(a[i]);
    }
    rep(i, y){
        in(b[i]);
    }
    rep(i, z){
        in(c[i]);
    }
    vector<int> ab, abc;
    rep(i, x){
        rep(j, y){
            ab.pb(a[i] + b[j]);
        }
    }
    sort(all(ab), greater<int>());
    rep(i, min((int)ab.size(), k)){
        rep(j, z){
            abc.pb(ab[i] + c[j]);
        }
    }
    sort(all(abc), greater<int>());
    rep(i, k){
        print(abc[i]);
    }
}


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

namespace ABC088_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = new double[3][];
            var input = "";
            var arrayTemp = new string[3];
            for (int i = 0; i < 3; i++)
            {
                num[i] = new double[3];
                input = Console.ReadLine();
                arrayTemp = input.Split(' ');
                num[i] = arrayTemp.Select(double.Parse).ToArray();
            }

            double a1 = 0;
            double b1 = num[0][0] - a1;
            double a2 = num[1][0] - b1;
            double a3 = num[2][0] - b1;
            double b2 = num[0][1] - a1;
            double b3 = num[0][2] - a1;
            if (num[1][1] == a2 + b2 && num[1][2] == a2 + b3 && num[2][1] == a3 + b2 && num[2][2] == a3 + b3)
            {
                Console.WriteLine("Yes");
                return;
            }

            for (int i = 1; i <= Math.Ceiling(num[0][0] / 2); i++)
            {
                if (num[1][1] == a2 + b2 && num[1][2] == a2 + b3 && num[2][1] == a3 + b2 && num[2][2] == a3 + b3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                a1 = i;
                b1 = num[0][0] - a1;
                a2 = num[1][0] - b1;
                a3 = num[2][0] - b1;
                b2 = num[0][1] - a1;
                b3 = num[0][2] - a2;
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    set <string> st;
    int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() <<endl;
}


Measured memory_bytes: 19084
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    for(int j=0;j<n;j++){
        string a,b;
        cin>>a>>b;
        int numa[100000]={0},numb[100000]={0};
        int flag=0;
        int sum[81]={0};
        if(80<max(a.size(),b.size())){
            puts("overflow");
            goto exit;
        }
        for(int i=a.size()-1,k=0;0<=i;i--,k++)numa[k]=a[i]-'0';
        for(int i=b.size()-1,k=0;0<=i;i--,k++)numb[k]=b[i]-'0';
        for(int i=0;i<max(a.size(),b.size());i++){
            sum[i]+=(numa[i]+numb[i]);
            sum[i+1]=sum[i]/10,sum[i]=sum[i]%10;
            if(sum[80]!=0){
                puts("overflow");
                goto exit;
            }
        }
        for(int i=80;0<=i;i--){
            if(flag==1||sum[i]!=0)flag=1;
            if(flag==1)printf("%d",sum[i]);
        }
        if(flag==0)printf("0");
        puts("");
exit:
;
    }
    return 0;
}

Measured memory_bytes: 2024
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	prices := make([]int, n)
	
	sum := 0;
	high := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&prices[i])
		sum += prices[i]
		if prices[i] > high {
			high = prices[i]
		}
	}
	sum -= high / 2
	fmt.Println(sum)
}

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

#define REP(A, H) for(int A = 0; A < H; A++)
#define RREP(A, B, H, W) for(int A = 0; A < H; A++) for (int B = 0; B < W; B++)
#define MAX(A, B) (A = std::max(A, B))
#define MIN(A, B) (A = std::min(A, B))

typedef long long ll;

struct POINT {
  int x; int y;
  POINT(int x, int y) : x(x), y(y) {}
};

POINT operator +(const POINT& a, const POINT& b) {
  return POINT(a.x + b.x, a.y + b.y);
}

POINT operator -(const POINT& a, const POINT& b) {
  return POINT(a.x - b.x, a.y - b.y);
}

/* std::cout << ;*/
/* std::cout << << std::endl; */

int a[50];

int main(void) {
  std::string s;
  std::cin >> s;  

  REP(i, 50) a[i] = 0;
  REP(i, 4) a[s[i] - 'A']++;

  int tcnt = 0;
  REP(i, 50) if (a[i] == 2) tcnt++;

  if (tcnt == 2)
    std::cout << "Yes" << std::endl;
  else 
    std::cout << "No" << std::endl;

  return 0;
}

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 100013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N, Q;
ll M;
int dsu[MAXN];
vpi guys;
ll cc = 0;

int get(int u)
{
	return (u == dsu[u] ? u : dsu[u] = get(dsu[u]));
}
void merge(int u, int v)
{
	dsu[get(u)] = get(v);
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(12);
	cerr << fixed << setprecision(4);
	cin >> N >> M >> Q;
	FOR(i, 0, N)
	{
		dsu[i] = i;
	}
	FOR(i, 0, Q)
	{
		int u, v, c;
		cin >> u >> v >> c; if (u > v) swap(u, v);
		if (c == 0)
		{
			merge(u, v);
		}
		else
		{
			if (M == N - 1)
			{
				cout << "No\n";
				return 0;
			}
			guys.PB({u, v});
		}
	}
	for (pii p : guys)
	{
		if (get(p.fi) == get(p.se))
		{
			cout << "No\n";
			return 0;
		}
	}
	FOR(i, 0, N)
	{
		if (get(i) == i) cc++;
	}
	if (M > N + cc * (cc - 3) / 2)
	{
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	//N-k from with in cc's + (k choose 2) = N+k(k-3)/2 is max # of edges.
	//otherwise you try merging the shit.
	//consider removing edges.
	//a -> b
	return 0;
}


Measured memory_bytes: 1784
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
//↓Union-Find Tree
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
//↑Union-Find Tree
int main(){
	int N;
	cin>>N;
	vpint A,B;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.eb(a, 0);
	}
	for(int i=0;i<N;i++){
		int b;
		cin>>b;
		B.eb(b, i);
	}
	sort(B.begin(), B.end());
	for(int i=0;i<N;i++){
		int idx=B[i].second;
		A[idx].second=i;
	}
	sort(A.begin(), A.end());

	for(int i=0;i<N;i++){
		if(A[i].first>B[i].first){
			cout<<"No"<<endl;
			return 0;
		}
	}
	UnionFind U(SIZE);
	for(int i=0;i<N;i++){
		U.unionSet(i, A[i].second);
	}
	if(U.size(0)!=N){
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=0;i<N-1;i++){
		if(A[i+1].first<=B[i].first){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

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

mod = 10**9+7

def choose(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod # modの世界では逆元はpow(x,mod-2)をかけることと同じ

ans = []
for i in range(1,k+1):
    comb_div = choose(k-1, i-1) # k個の青いボールをiグループに分ける分け方。(1,2)と(2,1)は後で赤いボールに混ぜるときに違う並べ方になるので違うものとみなす
    comb_loc = choose(n-k+1, i) * comb_div % mod # 
    ans.append(comb_loc)
    
print(*ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N = 1e5+3;
vector <pair <int,int> > adj[N];
int deg[N];
bool used[N];
int size[N], dir[N];
int n, m;
pair<int, int> edge[N];

void dfs(int u)
{
	used[u] = true;
	size[u] = deg[u];
	for(auto i:adj[u])
	{
		if(!used[i.fi])
		{
			dfs(i.fi);
			if(size[i.fi] % 2 == 1)
			{
				dir[i.se]^=1;
			}
			size[u] += size[i.fi];
		}
	}
}


int main()
{
	int res = 1;
	cin >> n >> m;
	for(int i=1;i<=m;i++)
	{
		int x, y;
		cin >> x >> y;
		deg[x]^=1;
		adj[x].push_back({y, i});
		adj[y].push_back({x, i});
		edge[i]={x,y};
	}
	
	if(m % 2 == 1)
		return cout <<-1, 0;
	dfs(1);
	for(int i=1;i<=m;i++)
	{
		if(dir[i] == 0)
			cout << edge[i].fi << ' ' << edge[i].se << '\n';	
		else
			cout << edge[i].se << ' ' << edge[i].fi << '\n';
					
	}
	
}

Measured memory_bytes: 13568
#include<stdio.h>
int main()
{
    int ara[4],i,x,j;
    for(i=0;i<3;i++)
    {
        scanf("%d",&ara[i]);
    }
    for(i=1;i<3;i++)
    {
        x=ara[i];
        j=i-1;
        while(j>=0&&ara[j]>x)
        {
            ara[j+1]=ara[j];
            j--;
        }
        ara[j+1]=x;
    }
    printf("%d %d %d\n",ara[0],ara[1],ara[2]);
    return 0;
}



Measured memory_bytes: 2036
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

S = input()
N = len(S)

def bit(S, j):
    # Sの右からj bit目(0-indexed)
    return (S>>j)&1

ans = 0
for i in range(1<<(N-1)):
    k = 0
    tmp = []
    for j in range(N-1):
        if bit(i, j) == 1:
            tmp.append(S[k:j+1])
            k = j + 1
    tmp.append(S[k:])

    for t in tmp:
        ans += int(t)

print(ans)



Measured memory_bytes: 73464
#include <iostream>
#include <set>

int main()
{
	std::set< std::pair<int, int> > set;
	int up[100010] = { 0 }, down[100010] = { 0 };
	int ss[100010], ts[100010], cs[100010];
	
	int max = 0;
	
	int n, c;
	
	std::cin >> n >> c;
	for (int i = 0; i < n; ++i)
	{
		std::cin >> ss[i] >> ts[i] >> cs[i];
		
		set.insert(std::make_pair(ts[i], cs[i]));/*
		if (set.count(std::make_pair(ss, cs)))
		{
			--down[ss];
			--up[ss];
		}
		
		++up[ss];
		++down[ts];*/
	}
	
	for (int i = 0; i < n; ++i)
	{
		if (set.count(std::make_pair(ss[i], cs[i])))
		{
			--down[ss[i]];
			--up[ss[i]];
		}
		
		++up[ss[i]];
		++down[ts[i]];
	}
	
	int count = 0;
	
	for (int i = 0; i <= 100000; ++i)
	{
		count += up[i];
		max = std::max(max, count);
		count -= down[i];
	}
	
	std::cout << max;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int N;
    cin >> N;
    vector<int> d(N);

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

    sort(d.begin(), d.end(), greater<int>());

    int before = 0;
    int count = 0;
    for (int i = 0; i < N; i++) {
        // cout << before << " " << count << " " << i << "\n";
        if (before != d[i]) {
            count++;
        }
        before = d[i];
    }
    cout << count;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include <map>
#include <set>

using namespace std;

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 100000000

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

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

void print_op(int op){
    if(op==1){
        cout << '+';
    }
    else{
        cout << '-';
    }
}

int main(void){
	int n, a, b, c, d;
    cin >> n;
    d = n % 10;
    n = n / 10;
    c = n % 10;
    n = n / 10;
    b = n % 10;
    n = n / 10;
    a = n % 10;

    int op1[] = {1,1,1,1,-1,-1,-1,-1};
    int op2[] = {1,1,-1,-1,1,1,-1,-1};
    int op3[] = {1,-1,1,-1,1,-1,1,-1};

    REP(i, 8){
        if(a + op1[i]*b + op2[i]*c + op3[i]*d == 7){
            cout << a;
            print_op(op1[i]);
            cout << b;
            print_op(op2[i]);
            cout << c;
            print_op(op3[i]);
            cout << d << "=7\n";

            return 0;
        }
    }
}


Measured memory_bytes: 256
/*　　　＿
　 '´　　 ヽ
 ./ ﾉﾉ））)）〉＜そーなのかー
〈《.! ﾟ ヮﾟﾉ》
　⊂!::V::!つ
　 く::::::::〉
　　 し'ﾉ*/
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,m;
  cin >> n >> m;
  if(n>=10){
  cout << m << endl;
  }
  else{
  cout << m+(10-n)*100 << endl;
  }
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0103&lang=jp
"""
import sys



class Baseball():
    def __init__(self):
        self.score = 0
        self.out_count = 0
        self.base = [0, 0, 0]

    def event(self, e):
        if e == 'HIT':
            self.base.insert(0, 1)
            home = self.base.pop()
            if home:
                self.score += 1
        elif e == 'HOMERUN':
            self.score += self.base.count(1)
            self.score += 1
            self.base = [0, 0, 0]
        elif e == 'OUT':
            self.out_count += 1


def main(args):
    num = int(input().strip())
    for _ in range(num):
        b = Baseball()
        while b.out_count < 3:
            b.event(input().strip())
        print(b.score)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();
        int[] H = new int[N];
        for (int i = 0 ; i< N ; i++) {
            H[i] = sc.nextInt();
        }
        int index = 0;
        double minDiff = 10000;
        for (int i = 0 ; i < N ; i++) {
            double diff = Math.abs(T - 0.006 * H[i] - A);
            if (diff < minDiff) {
                minDiff = diff;
                index = i;
            }
        }
        System.out.println(index + 1);
    }

}

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

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

  int ans = 1050;

  for (int i = 0; i < s.size() - t.size() + 1; i++) {
    int tmp = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s[i + j] != t[j]) tmp++;
    }
    if (tmp < ans) ans = tmp;
  }
  cout << ans << endl;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int INF = TEN(9);

int solve(int h, string &s, string &t) {
	vector<vi> dp(h + 1, vi(h + 1, INF));
	vector<vi> cost(h + 1, vi(h + 1));

	for (int i = 0; i <= h; ++i) {
		for (int j = 0; j <= h; ++j) {
			if (i == 0 || j == 0) {
				int c = 0;
				rep(k, h) {
					if (k >= i && k >= j) {
						c += (s[k-i] == t[k-j]);
					}
				}
				cost[i][j] = c;
			} else {
				cost[i][j] = cost[i-1][j-1] - (s[h-i] == t[h-j]);
			}
		}
	}

	dp[0][0] = 0;
	for (int i = 0; i <= h; ++i) {
		for (int j = 0; j <= h; ++j) {
			if (i < h) {
				dp[i+1][j] = min(dp[i+1][j], dp[i][j] + cost[i][j]);
			}
			if (j < h) {
				dp[i][j+1] = min(dp[i][j+1], dp[i][j] + cost[i][j]);
			}
		}
	}
	return dp[h][h];
}

int main() {
	int h, w; cin >> h >> w;
	vector<string> vec(h);
	rep(i, h) cin >> vec[i];

	int ans = 0;
	rep(j, w-1) {
		string s1, s2;
		rep(i, h) {
			s1.pb(vec[i][j]);
			s2.pb(vec[i][j+1]);
		}
		int c = solve(h, s1, s2);
		ans += c;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1200
n,m=map(int,input().split())
L=[]
d=set(".")
for i in range(n):
  s=input()
  if set(list(s))!=d:
    L.append(list(s))
l=[list(a) for a in  zip(*L) if set(a)!=set(".")]
for a in zip(*l):
  print("".join(a))

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, A;

int main() {
  INCANT;
  cin >> N >> A;
  string ans = A>=N%500?"Yes":"No";
  cout << ans << "\n";
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  bool bo=true;
  for(int i=0;i<N;i++){
    int j;
    cin>>j;
    if(j%2==0 && j%3!=0 && j%5!=0){
      bo=false;
      break;
    }
  }
  if(bo)
    cout<<"APPROVED"<<endl;
  else
    cout<<"DENIED"<<endl;
}

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

int jougen(int a,int b){
 while(a*a<b){
  a++; 
 }
 a-=1;
  
 return a;
}

int main(void){
 int x=1;
 int tmp=0;
 int ans=1;
 int s;
 bool flag=true;
 bool flag2=true;
 bool flag3=true;
 bool flag4=true;
 cin>>x; 
 if(x<=4){
   if(x<=2){
     x=2;
   }else if(x==3){
    x=3;
   }else{
    x=5;
   }
 }else{
  do{
   if(flag3){
    tmp=jougen(0,x);
   }else{
    tmp=jougen(tmp,x);
   }
   for(int i=2;i<=tmp;i++){
    //if(x==100003){//DEBUG
    //   cout<<i<<"a";//DEBUG
    //}//DEBUG
    s=x%i;
    if(s==0){
     if(i==2){
      flag2=false;
     }
     ans*=s;
     
     break;
    }
    ans*=s;
   }
   if(ans>0){
    flag=false;
    break;
   } 
   if(!flag2){
    x++;
    flag2=true;
   }else{
    x+=2;
   }
    
   ans=1;
    flag3=false;
   }while(flag);
 }
   
 cout<<x;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
using namespace std;
char S[200020];
int A[20000],N;
struct Node{
	char c;
	int Pre,Ne;
}C[200200];
bool Work(){
	for (int pos=1;pos!=N+1;pos=C[pos].Ne)
		if (C[pos].c>='a'&&C[pos].c<='z'){
		int n1=C[pos].Ne,n2=C[n1].Ne;
		if (C[n1].c=='-'&&C[n2].c>='a'&&C[n2].c<='z'){
			int x=C[pos].c,y=C[n2].c;
			if (!A[x]) swap(x,y),swap(C[pos].c,C[n2].c);
			if ((A[x]>0&&A[y]>0)||(A[x]<=0&&A[y]<=0)){
				cout<<"No"<<endl; exit(0);
			}
			A[x]--;
			int st=C[pos].Pre,en=C[n2].Ne;
			if (C[st].Pre==0) return 0;
			C[st].c=C[pos].c; C[st].Ne=C[en].Ne; 
		}
	}
	return 1;
}
int main(){
	cin>>(S+1);
	N=strlen(S+1);
	int num=0;
	for (int i=1;i<=N;i++) if (S[i]>='a'&&S[i]<='z') num++;
	for (int i=1;i<=N;i++)
		C[i].c=S[i],C[i].Pre=i-1,C[i].Ne=i+1;
	for (int i=1;i<=num;i++){
		char x; cin>>x; scanf("%d",&A[x]);
	}
	while (Work());
	for (int i='a';i<='z';i++) if (A[i]){
		cout<<"No"<<endl; return 0;
	}
	cout<<"Yes"<<endl; return 0;
}


Measured memory_bytes: 3204
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
q = list(map(int, input().split()))
q.sort()
r = list(map(int, input().split()))
print(sum(sorted(p[-x:] + q[-y:] + r)[-x-y:]))



Measured memory_bytes: 23328
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int a;
    cin>>a;
    cout<<a*a<<endl;
    return 0;

}


Measured memory_bytes: 256
t[99],h[99];main(i,s,N,T,L){for(scanf("%d%d%d%d",&N,&T,&L,&L),i=0;i<N;i++)scanf("%d%d",t+i,h+i);for(i=s=0;;i=(i+1)%N)if(t[i]){t[i]--;if(++T>L)break;if(++s==9)s=0;}else if(h[i]){h[i]--;if(T<++s)break;t[i]=s;T-=s;s=0;}else break;printf("%d\n",i+1);exit(0);}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MAX_ANS 123456789

signed main(){
    int n, m, x;
    cin >> n >> m >> x;
    vi c(n);
    vector<vi> a(n, vi(m));
    bool isOK = false;
    int ans = MAX_ANS;

    rep(i, n){
        cin >> c[i];
        rep(j, m){
            cin >> a[i][j];
        }
    }

    /* どの本を取るかビット全探索 */
    for(int bits = 0; bits < (1<<n); bits++){
        bool can_do = true;
        vi tmp_a(m);
        int tmp = 0;
        for(int i = 0; i < n; i++){
            if((bits>>i) & 1){
                /* cout << i << "冊目 ";  */
                rep(j, m) tmp_a[j] += a[i][j];
                tmp += c[i];
            }
        }
        rep(i, m){
            if(tmp_a[i] < x) can_do = false;
        }

        if(can_do){
            isOK = true;
            ans = min(ans, tmp);
        }
    }

    if(ans == MAX_ANS){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

}

Measured memory_bytes: 3612
while True:
    things = {}
    count = input()
    if count == 0: break
    for i in range(count):
        fuga = raw_input().split()
        things[fuga[0]] = int(fuga[1])
    for i in range(input()):
        fuga = raw_input().split()
        money =0
        for j in range(int(fuga[1])):
            hoge = things[fuga[j+2]] if fuga[j+2] in things else 0
            money+= hoge
        things[fuga[0]] = things[fuga[0]] if money > things[fuga[0]] else money
    print things[raw_input()]

Measured memory_bytes: 4252
A, B, C = map(int, input().split())

K = int(input())

flg = False

for i_a in range(K+1):
    for i_b in range(K+1):
        for i_c in range(K+1):
            if(i_a + i_b + i_c <= K):
                score_a = A
                score_b = B
                score_c = C
                for n_a in range(i_a):
                    score_a *= 2
                for n_b in range(i_b):
                    score_b *= 2
                for n_c in range(i_c):
                    score_c *= 2
                if((score_b > score_a) and (score_c > score_b)):
                    flg = True
            
            if(flg):
                break
        if(flg):
            break
    if(flg):
        break

if(flg):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9200
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[i]=format(a[i],'030b')
l=[0 for i in range(30)]
for i in range(n):
  for j in range(30):
    if a[i][j]=='1':
      l[j]+=1
for j in range(30):
  l[j]=l[j]%2
 
if 1 in l:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 14212
#include <stdio.h>

int main(void)
{
  /*
    int n;
  int *a;

  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", a++);

  for (int i = 0; i < n; i++)
    a--;

  for (int i = 0; i < n; i++) {
    if (*a++ % 2 == 0) {
      if (*a % 3 != 0 && *a % 5 != 0)
	printf("DENIED\n"); break;
    }
  }
  printf("APPROVED\n");

  return 0;
  */

  
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);

  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i]%3 != 0 && a[i]%5 != 0) {
	printf("DENIED\n"); break;
      }
    }
      if (i == n-1) 
	printf("APPROVED\n");
  }


  return 0;
}


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

int main() {
    ll n, a, b, tmp;
    cin >> n >> a >> b;
    ll cost = 0;

    vector<ll> v;
    rep(i, n) {
        cin >> tmp;
        v.push_back(tmp);
    }
    for(int i = 1; i < n; i++) {
        ll tcost = (v[i] - v[i - 1]) * a;
        if(tcost < b) {
            cost += tcost;
        } else {
            cost += b;
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)


int main()
{
    int n;cin>>n;
    map<int, int> mp;
    for(int i = 0; i<n; i++){
        int d;cin>>d;
        mp[d]++;
    }
    cout << mp.size()<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N;
int Q;
vi c,t,x,d;
vi box;

int main(){
    cin >> N;
    c.resize(N);
    box.assign(N,0);
    rep(i,N) cin >> c[i];
    cin >> Q;
    t.resize(Q);
    x.resize(Q);
    d.resize(Q);
    rep(i,Q){
        cin >> t[i] >> x[i] >> d[i];
        x[i]--;
    }

    rep(i,Q){
        if(t[i] == 1){
            int &nokori = box[x[i]];
            nokori += d[i];
            if(nokori > c[x[i]]){
                cout << x[i]+1 << endl;
                return 0;
            }
        }else if(t[i] == 2){
            int &nokori = box[x[i]];
            nokori -= d[i];
            if(nokori < 0){
                cout << x[i]+1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}



Measured memory_bytes: 3896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

vector<int> d, f, color;
vector<vector<int>> A;
int cnt = 0;

int next(int i) {
    for (auto j : A[i]) {
        if (color[j] == 0) {
            d[j] = cnt;
            color[j] = 1;
            return j;
        }
    }
    f[i] = cnt;
    color[i] = 2;
    return -1;
}

void dfs(int u) {
    cnt += 1;
    stack<int> S;
    S.push(u);
    d[u] = cnt;
    color[u] = 1;
    while (!S.empty()) {
        cnt += 1;
        int i = S.top();
        int j = next(i);
        if (j != -1) S.push(j);
        else S.pop();
    }
}

int main() {
    int n;
    cin >> n;
    A = vector<vector<int>>(n, vector<int>(0));
    d = vector<int>(n, 0);
    f = vector<int>(n, 0);
    color = vector<int>(n, 0);
    rep(i, n) {
        int u, k;
        cin >> u >> k;
        rep(j, k) {
            int tmp;
            cin >> tmp;
            A[i].push_back(--tmp);
        }
    }
    rep(i, n) {
        if (color[i] == 0) dfs(i);
    }
    rep(i, n) {
        printf("%d %d %d\n", i + 1, d[i], f[i]);
    }
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    deque<char> q;
    for (char c : s) q.push_back(c);

    bool flip = false;
    int Q;
    cin >> Q;
    rep(qi, Q){
        int ty;
        cin >> ty;
        if(ty == 1){
            flip =!flip;
        }else{
            int f; char c;
            cin >> f >> c;
            if(flip) f = 3-f;
            if(f == 1){
                q.push_front(c);
            }else{
                q.push_back(c);
            };
        }
    }
    if(flip) reverse(q.begin(), q.end());
    string ans;
    for(char c : q) ans += c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
a, b = map(int, input().split())
def xor(p):
    if p % 4 == 0:
        return p
    elif p % 4 == 1:
        return 1
    elif p % 4 == 2:
        return p + 1
    elif p % 4 == 3:
        return 0
print(xor(a - 1) ^ xor(b))

Measured memory_bytes: 2940
while True:
  N = int(raw_input())
  if N==0: break
  dic = {}
  for _ in xrange(N):
    L,P,A,B,C,D,E,F,S,M = raw_input().split()
    cost = int(P)
    time = int(A)+int(B)+int(C)+int(D)+int(E)+(int(D)+int(E))*(int(M)-1)
    profit = int(F) * int(S) * int(M)
    if float((profit-cost))/float(time) not in dic:
      dic[float((profit-cost))/float(time)] = []
    dic[float((profit-cost))/float(time)].append(L)
  for k,v in sorted(dic.items(), reverse=True):
    for name in sorted(v):
      print name
  print "#"

Measured memory_bytes: 6332
n = gets.to_i
w = gets.split.map(&:to_i)
s = Array.new(n)
sum1 = w.inject(:+)
sum2 = 0
(0...n).each do |i|
    sum1 -= w[i]
    sum2 += w[i]
    s[i] = (sum1 - sum2).abs
end
puts s.min

Measured memory_bytes: 1788
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	while (1) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		vector<pair<string, int>>v(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i].first;
			for (int j = 0; j < n - 1; j++) {
				int num;
				cin >> num;
				if (num == 0) v[i].second += 100;
				if (num == 1) v[i].second -= 1;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = n - 1; j >= i + 1; j--) {
				if (v[j].second > v[j - 1].second) swap(v[j], v[j - 1]);
			}
		}
		for (int i = 0; i < n; i++) {
			cout << v[i].first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3136
#include <cstdio>
#define MOD 1000000007
typedef long long ll;
inline ll quick_pow(ll a, int n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
ll fact[2000005], inv[2000005];
inline ll calc(int n, int m)
{
	return fact[n + m] * inv[n] % MOD * inv[m] % MOD;
}
inline ll calc(int x1, int x2, int y1, int y2)
{
	return calc(x2 + 1, y2 + 1) - calc(x1, y2 + 1) - calc(x2 + 1, y1) + calc(x1, y1);
}
inline void init()
{
	const int mx = 2e6;
	fact[0] = 1;
	for (int i = 1; i <= mx; i++)
		fact[i] = fact[i - 1] * i % MOD;
	inv[mx] = quick_pow(fact[mx], MOD - 2);
	for (int i = mx; i; i--)
		inv[i - 1] = inv[i] * i % MOD;
}
int main()
{
	// freopen("AGC018-E.in", "r", stdin);
	init();
	int x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;
	scanf("%d%d%d%d%d%d", &x1, &x2, &x3, &x4, &x5, &x6);
	scanf("%d%d%d%d%d%d", &y1, &y2, &y3, &y4, &y5, &y6);
	ll ans = 0;
	for (int i = x3; i <= x4; i++)
	{
		(ans -= (i + y3) * calc(i - x2, i - x1, y3 - y2 - 1, y3 - y1 - 1) % MOD * calc(x5 - i, x6 - i, y5 - y3, y6 - y3)) %= MOD;
		(ans += (i + y4 + 1) * calc(i - x2, i - x1, y4 - y2, y4 - y1) % MOD * calc(x5 - i, x6 - i, y5 - y4 - 1, y6 - y4 - 1)) %= MOD;
	}
	for (int i = y3; i <= y4; i++)
	{
		(ans -= (i + x3) * calc(x3 - x2 - 1, x3 - x1 - 1, i - y2, i - y1) % MOD * calc(x5 - x3, x6 - x3, y5 - i, y6 - i)) %= MOD;
		(ans += (i + x4 + 1) * calc(x4 - x2, x4 - x1, i - y2, i - y1) % MOD * calc(x5 - x4 - 1, x6 - x4 - 1, y5 - i, y6 - i)) %= MOD;
	}
	printf("%lld\n", (ans + MOD) % MOD);
	return 0;
}


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

int main(){
    long long n, a, b, sum1, sum2;
    cin>>n>>a>>b;
    if((n<2 && a!=b) || a>b){
        cout<<'0';
    }else if(n==1 && a==b){
        cout<<'1';
    }else{
        sum1 = a*(n-1) + b;
        sum2 = a + (n-1)*b;
        cout<<sum2-sum1+1;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 251

main()
{
  int A[MAX], H, i;

  scanf("%d", &H);
  for(i=1; i<=H; i++)
    {
      scanf("%d", &A[i]);
    }

  for(i=1; i<=H; i++)
    {
      printf("node %d: key = %d, ", i, A[i]);
      if(i==1)
	{
	  printf("left key = %d, right key = %d, ", A[2*i], A[2*i+1]);
	}
      else
	{
	  printf("parent key = %d, ", A[i/2]);
	  if(2*i <= H)
	    {
	      printf("left key = %d, ", A[2*i]);
	    }
	  if(2*i + 1 <= H)
	    {
	      printf("right key = %d, ", A[2*i+1]);
	    }
	}
      printf("\n");
    }

  return 0;
}

Measured memory_bytes: 600
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

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

def factorize(x):
    ret = []
    i = 2
    while i * i <= x:
        while x % i == 0:
            x //= i
            ret.append(i)
        i += 1
    if x > 1:
        ret.append(x)
    return ret

def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    return gcd(y, x % y)

A, B = map(int, input().split())
C = gcd(A, B)
print(len(set(factorize(C))) + 1)




Measured memory_bytes: 38512
#include <vector>
#include <iostream>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n, k; cin >> n >> k;
	vector<int> a(n); for (int i = 0; i <= n - 1; i++) cin >> a[i];

	vector<bool> dp(k + 1, false);
	dp[a[0]] = true;

	for (int i = a[0] + 1; i <= k; i++) {
		for (auto j : a) {
			if (i >= j and dp[i - j] == false) {dp[i] = true; break;}
		}
	}

	cout << (dp[k] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n, match[10][10];

int solve(int x, int y)
{
    if (x == n - 1 && y == n - 1)
        return 1;
    int nx = x, ny = y + 1;
    if (ny == n)
        nx++, ny = 0;
    if (match[x][y] != 0)
        return solve(nx, ny);
    int xwin = 0, xlose = 0, ywin = 0, ylose = 0;
    rep(i, n)
    {
        if (match[x][i] == 1)
            xwin++;
        if (match[x][i] == -1)
            xlose++;
    }
    rep(i, n)
    {
        if (match[y][i] == 1)
            ywin++;
        if (match[y][i] == -1)
            ylose++;
    }
    int res = 0;
    if (xwin < n / 2 && ylose < n / 2)
    {
        match[x][y] = 1, match[y][x] = -1;
        res += solve(nx, ny);
        match[x][y] = match[y][x] = 0;
    }
    if (xlose < n / 2 && ywin < n / 2)
    {
        match[x][y] = -1, match[y][x] = 1;
        res += solve(nx, ny);
        match[x][y] = match[y][x] = 0;
    }
    return res;
}

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

    while (cin >> n, n)
    {
        rep(i, n) rep(j, n) match[i][j] = 0;
        rep(i, n) match[i][i] = 2;
        int m;
        cin >> m;
        rep(i, m)
        {
            int x, y;
            cin >> x >> y;
            x--, y--;
            match[x][y] = 1;
            match[y][x] = -1;
        }
        bool ok = true;
        rep(i, n)
        {
            int win = 0, lose = 0;
            rep(j, n)
            {
                if (match[i][j] == 1)
                    win++;
                if (match[i][j] == -1)
                    lose++;
            }
            if (win > n / 2 || lose > n / 2)
                ok = false;
        }
        cout << (ok ? solve(0, 0) : 0) << endl;
    }
}


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

int main() {
  int n,W; cin>>n>>W;
  vector<int> v(n),w(n);
  rep(i, n) cin>>v[i]>>w[i];

  vector<vector<int>> dp(n+1, vector<int>(W+1));
  rep(i, n) {
    rep(j, W+1) {
      if (j-w[i]>=0) dp[i+1][j]=max(dp[i][j], dp[i+1][j-w[i]]+v[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout<<dp[n][W]<<endl;
}



Measured memory_bytes: 6796
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        p: [(i64, i64); n],
    }
    let mut p = p;
    p.sort_by_key(|p| p.0 + p.1);
    let mut ans = p.iter().fold(0, |s, p| s + p.0);
    for (i, p) in p.iter().rev().enumerate() {
        if i & 1 == 1 {
            ans -= p.0 + p.1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 8444
# coding: utf-8
# Your code here!
import collections

N = int(input())

blue_card = []
red_card = []
ans = 0
for i in range(N):
    blue_card.append(input())

M = int(input())

for i in range(M):
    red_card.append(input())
    
blue = collections.Counter(blue_card)
red = collections.Counter(red_card)

for i in blue.items():
    k,v = i[0],i[1]
    ans = max(ans,v-red.get(k,0))
        
print(ans)

Measured memory_bytes: 3316
n = int(input())
s = input()
res = 0
pos = []
for i in range(10):
    pos.append([])

for i in range(len(s)):
    c = int(s[i])
    pos[c].append(i)
import bisect
# 0010
# print(format(10, '04d'))
res = 0
for num in range(0, 1000):
    numstr = format(num, '03d')
    iscan = True
    curpos = -2
    for i in range(3):
        curpos += 1
        val = int(numstr[i])
        ind = bisect.bisect_left(pos[val], curpos)
        if ind == len(pos[val]):
            iscan = False
            break
        curpos = pos[val][ind]

    if iscan:
        res += 1
print(res)


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

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -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;
}

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

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


int main(void){
    vector<int> a(3);

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

    int ans = 1e9;
    do{
        int tmp = 0;
        for(int i = 0; i < 3; i++){
            if(i == 0)continue;
            tmp += abs(a[i] - a[i - 1]);
        }
        ans = min(ans, tmp);
    } while(next_permutation(a.begin(), a.end()));

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

  int r,g,b;
  cin>>r>>g>>b;
  
  int N=r*100+g*10+b;
  cin>>N;
  
  if(N%4==0){
  
    cout<<"YES"<<endl;
  }
  else{
  
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

char s[101][101];
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int h, w; cin >> h >> w;
	f(i, 1, h)scanf("%s", s[i] + 1);
	f(i, 1, h) {
		bool ok = 1;
		f(j, 1, w)if (s[i][j] == '#')ok = 0;
		if (ok)f(j, 1, w)s[i][j] = 'X';
	}
	f(i, 1, w) {
		bool ok = 1;
		f(j, 1, h)if (s[j][i] == '#')ok = 0;
		if (ok)f(j, 1, h)s[j][i] = 'X';
	}
	f(i, 1, h) {
		bool e = 0;
		f(j, 1, w)if (s[i][j] != 'X')cout << s[i][j],e=1;if(e) cout << '\n';
	}
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const long long mod = 1000000007;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


void solve(long long N, long long K){
    vector<i64> table(K + 1);
    i64 ans = 0;
    for(i64 i = K; i >= 1; --i){
        i64 s = modpow(K / i, N, mod);
        for(i64 j = 2 * i; j <= K; j += i){
            s = (s - table[j] + mod) % mod;
        }
        ans = (ans + i * s % mod) % mod;
        table[i] = s;
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 4072
def func(x, y)
  mod = 1000000007
  return 1 if  y == 0
  return x % mod if y == 1
  return func(x, y / 2) ** 2 % mod if y % 2 == 0
  return func(x, (y - 1) / 2) ** 2 * x % mod
end

m, n = gets.split(' ').map(&:to_i)
puts func(m,n)



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

int main(){
    string s; cin >> s;
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] == s[i+1]){
            cout << i + 1 << " " << i+1 + 1 << endl;
            return 0;
        }
    }
    for(int i = 0; i < s.size() - 2; i++){
        if(s[i] == s[i+2]){
            cout << i + 1 << " " << i+2 + 1 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3716
def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	A.sort()
	cnt = []
	c = 0
	a = 0
	for i in range(len(A)):
		if i == 0:
			a = A[i]
			c += 1
		else:
			if A[i] == a:
				c += 1
			elif A[i] != a:
				cnt.append(c)
				c = 1
				a = A[i]
	else:
		cnt.append(c)

	cnt = list(map(lambda ct: (2 - (ct % 2)), cnt))
	evens = cnt.count(2)
	if evens % 2 == 0:
		print(len(cnt))
	else:
		print(len(cnt) - 1)

main()

Measured memory_bytes: 20516