akhauriyash/Code-Regression huggingface dataset:
// by adiforluls
#pragma GCC optimize ("-O2")
#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 FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{ 
  int n,k; cin>>n>>k;
  vector<int> a(n);
  rep(i,0,n) cin>>a[i];
  vector<bool> dp(k+1,0);
  rep(i,0,k+1)
  {
    for(auto j:a)
    {
      if(i>=j and !dp[i-j])
      {
        dp[i]=true;
      }
    }
  }
  cout<<(dp[k]?"First":"Second");
} 
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	float xa, ya, xb, yb, xc, yc, xd, yd;
	
	while(cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd){
		if(((yb-ya)==0.0&&(xd-xc)==0.0)||((xb-xa)==0.0&&(yd-yc)==0.0)){
			cout << "YES" << endl;
		} else if((xb-xa)==0.0&&(xd-xc)==0.0){
			cout << "NO" << endl;
		} else if(((yb-ya)/(xb-xa))*((yd-yc)/(xd-xc)) == -1.0){
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
n=int(input())
c=[list(map(int, input().split())) for i in range(n)]

for i in range(n):
    c[i].append(c[i][0]+c[i][1])

c.sort(key=lambda x:x[2],reverse=True)

ans1=0
ans2=0

for i in range(n):
    if i%2==0:
        ans1+=c[i][0]
    else:
        ans2+=c[i][1]

print(ans1-ans2)

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> c(10, vector<int>(10, 0));
    for (int i = 1; i <= N; i++) {
        string s = to_string(i);
        int l = s.size();
        int a = s[0] - '0', b = s[l - 1] - '0';
        c[a][b]++;
    }
    ll ans = 0;
    rep(i, 10) {
        rep(j, 10) {
            ans += c[i][j] * c[j][i];
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

double a, b, x;

int main() {
	scanf("%lf %lf %lf", &a, &b, &x);
    
    double tmp;
    if (a * a * b / 2.0 > x) tmp = 90 - atan(2 * x / (a * pow(b, 2))) * 180 / acos(-1.0);
    else tmp = 90 - atan(pow(a, 3) / 2 / (pow(a, 2) * b - x)) * 180 / acos(-1.0);
	printf("%.10lf\n", tmp);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, k := io.NextInt(), io.NextInt()
	cnt := make([]int, k+1)
	for x := k; x >= 1; x-- {
		cnt[x] = ModPow(k/x, n, mod)
		for y := 2 * x; y <= k; y += x {
			cnt[x] += mod - cnt[y]
			cnt[x] %= mod
		}
	}
	ans := 0
	for x := 1; x <= k; x++ {
		ans += x * cnt[x]
		ans %= mod
	}
	io.Println(ans)
}

const mod = 1e9 + 7

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

// ModMul returns a*b with mod
func ModMul(a, b, mod int) int {
	a, b = a%mod, b%mod
	if b == 0 {
		return 0
	}
	if a*b/b == a {
		return a * b % mod
	}
	panic("overflow")
}

// ModPow returns base^n with mod
func ModPow(base, n, mod int) int {
	ans := 1
	for ; n > 0; n >>= 1 {
		if n&1 == 1 {
			ans = ModMul(ans, base, mod)
		}
		base = ModMul(base, base, mod)
	}
	return ans
}


Measured memory_bytes: 2604
n,x = list(map(int, input().split()))
a=list(map(int, input().split()))
ans = 0
if(a[0]>x):
    ans+=a[0]-x
    a[0]=x
for i in range(n-1):
    if(a[i]+a[i+1]>x):
        ans += a[i]+a[i+1]-x
        a[i+1] = x - a[i]
print(ans)

Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	int swap,ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		//cout<<a[i]<<endl;
	}
	//for(int i=0;i<n;i++) cout<<a[i]<<endl;
	for(int i=0;i<n-1;i++){
		//cout<<a[i]<<endl;
		if(a[i]<a[i+1]) ans=1;
		else if(a[i]>a[i+1]){
			ans=0;
			break;
		}
		//cout<<a[i]<<' '<<a[i+1]<<endl;
	}
	//cout<<ans<<endl;
	if(ans==1){
		cout<<"YES";
		return 0;
	}
	ans=0;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			swap=a[j];
			a[j]=a[i];
			a[i]=swap;
			for(int k=1;k<n;k++){
				if(a[k]>a[k-1]) {
					ans=1;
				}
				else{
					ans=0;
					break;
				}
			}
			if(ans==1){
				cout<<"YES";
				return 0;
			}
			a[i]=a[j];
			a[j]=swap;
		}
	}
	cout<<"NO";
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<int> trans(int n,int k){
    vector<int> ret;
    while(n){
        n--;
        ret.push_back(n%k);
        n /= k;
    }
    return ret;

}
signed main(){
    int n;cin >> n;
    auto hoge = trans(n,26);
    string ret;
    for(auto e:hoge)ret  = (char)('a'+e) + ret;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>




int main(){

	int n, i;
	int *buf;


	scanf( "%d", &n );

	buf = (int*)malloc( n*sizeof(int) );
	if(buf==NULL) return 0;

	for( i=0; i<n; i++ ){
		scanf( "%d", &buf[i] );
	}

	for( i=(n-1); i>=0; i--){
		printf( "%d", buf[i] );

		if( i != 0 ) printf( " " ); 
	}

	free(buf);

	printf( "\n" );

	return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator it
using namespace std;
int n,k,sta,x1,x2,b1,b2,res[100010];
map<int,int>mp;
vector<int>g;
typedef struct node
{
    int a,t,id,ans;
};
node query[100010];
bool cmp(node aa,node bb)
{
    if(aa.t==bb.t)
        return aa.a<bb.a;
    return aa.t<bb.t;
}
void update(int t1,int t2)
{
    int d=t2-t1;
    if(sta==0)
    {
        if(d<=b1)
        {
            b1-=d;
            b2-=d;
        }
        else if(d>=b2)
        b1=b2=x1=x2=0;
        else
        {
            x1=x1+d-b1;
            b1=0;
            b2-=d;
        }
    }
    else
    {
        if(d<=n-b2)
        {
            b1+=d;
            b2+=d;
        }
        else if(d>=n-b1)
        {
            x1=x2=0;
            b1=b2=n;
        }
        else
        {
            b2=n;
            x2=n-d-b1+x1;
            b1+=d;
        }
    }
    if(mp[t2])
        sta^=1;
}
int main()
{
    scanf("%d",&n);
    x1=b1=0;
    x2=b2=n;
    scanf("%d",&k);
    ff(i,1,k)
    {
        int now;
        scanf("%d",&now);
        g.push_back(now);
        mp[now]=1;
    }
    int q;
    scanf("%d",&q);
    ff(i,1,q)
    {
        scanf("%d%d",&query[i].t,&query[i].a);
        g.push_back(query[i].t);
        query[i].id=i;
    }
    sort(g.begin(),g.end());
    g.erase(unique(g.begin(),g.end()),g.end());
    sort(query+1,query+1+q,cmp);
    int pos=1;
    for(int i=0;i<g.size();i++)
    {
        if(i==0)
        update(0,g[i]);
        else update(g[i-1],g[i]);
        for(;pos<=q;pos++)
        {
            if(query[pos].t!=g[i])
            break;
            if(query[pos].a<=x1)
                query[pos].ans=b1;
            else if(query[pos].a>=x2)
                query[pos].ans=b2;
            else
                query[pos].ans=b1+query[pos].a-x1;
        }
    }
    ff(i,1,q)
    res[query[i].id]=query[i].ans;
    ff(i,1,q)
    printf("%d\n",res[i]);
    return 0;
}



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

int main() {
    int n, x;
    while (cin >> n >> x) {
        if (n == 0 && x == 0) return 0;
        int ans = 0;
        for (int i = 1; i <= n; i++)
            for (int j = i + 1; j <= n; j++)
                for (int k = j + 1; k <= n; k++)
                    if (i + j + k == x) ans++;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3116
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			long N = scan.nextLong();
			int count = 0;
			Set<Long>set = new TreeSet<Long>();
			outside:while(true) {
				
				
				for(Long a:enum_div(N)) {
					//System.out.print(a);
					//System.out.print(" ");
					}
				
				//System.out.println();
				//Collections.sort(as,Collections.reverseOrder());
				int ok = 0;
				for(Long i:enum_div(N)) {
					if(primefact(i).size()==1&&!set.contains(i)) {
					
					//System.out.println(i);
					//System.out.println(i);
					set.add(i);
					ok=1;
					N = N/i;
					//System.out.println(N);
					count++;
					break;
					//System.out.println(N);
				}
				
					
					
			}
				if(N==1||N==0) {
					break outside;
				}
				
				
			 //System.out.println();
			 
			 if(ok==0)break;
			}
			
			System.out.println(count);
			
			
			
			
			
			
			
			
			
			
			
			
			
		}
		
		
	}
	
	
	
	private static ArrayList<Long> enum_div(long n){//数字１〜ｎまでの約数を全部Allaylistに詰め込むメソッド
		ArrayList<Long> ret = new ArrayList<Long>();
		for(long i = 1;i*i<=n;i++) {
			if(n%i==0) {
				ret.add(i);
				if(i*i!=n){
					ret.add(n/i);
				}
			}
		}
		
		//ただここまでだと格納した約数はソートされてない
		
		Collections.sort(ret);//int型、Sting型くらいの格納した奴ならコレクションクラスのソートが使える。
		//ソートしてからcollections.reverseつかえば降順にもできる
		return ret;
		
		
		
	}
	
	
	/*for(Integer key:A.keySet()) {
	System.out.println(key);//素数
	System.out.println(A.get(key));//素数の指数
	}みたいな感じで表示できる*/	
	private static Map<Long,Long> primefact(long n){//入力ｎの素数とその指数をmapに格納
		Map<Long,Long> map = new TreeMap<Long,Long>();
		for(long i = 2;i*i<=n;i++) {
			if(n%i!=0) {
				continue;
			}
			long ex = 0;//素因数分解した素数たちの指数
			
			while (n % i == 0) {//iでわれる限りやる
				++ex;
				n /= i;
				}		
			map.put(i, ex);//(素数、その素数の指数)
		}
		if(n!=1) {//もし最後に素数が残ったら入れておく
			map.put(n, (long)1);
		}
		return map;
	}
		

}


Measured memory_bytes: 38484
#include"bits/stdc++.h"
using namespace std;

int main(){
	int A, B, K;
	cin >> A >> B >> K;
	int dA[50] = {0};
	int dB[50] = {0};
	int gcd[50] = {0};
	int k = 0;
	int l = 0;
	int m = 0;
	//number store
	for(int i = 1; i <= A; i++){
		if(A%i == 0){
			dA[k] = i;
			k++;
		}
	}
	for(int i = 1; i <= B; i++){
		if(B%i == 0){
			dB[l] = i;
			l++;
		}
	}
	//check
	for(int i = 0; i < k + 1; i++){
		for(int j = 0; j < l + 1; j++){
			if(dA[i] == dB[j]){
				gcd[m] = dA[i];
				m++;
			}
		}
	}
	//sort
	int tmp = 0;
	for (int i = 0; i < 50; ++i) {
		for (int j = i+1; j < 50; ++j) {
			if (gcd[i] < gcd[j]) {
				tmp =  gcd[i];
				gcd[i] = gcd[j];
				gcd[j] = tmp;
			}
		}
	}


	//output
	cout << gcd[K -1] << endl;
	//for(int i = 0; i < 50; i++){
	//	cout << dA[i] << endl;
	//	cout << dB[i] << endl;
	//}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,X; cin>>N>>X;
    vint a(N);
    REP(i,N) cin>>a[i];
    sort(ALL(a));

    int sum=0;
    REP(i,N) sum+=a[i];

    if(sum<X) cout<<N-1<<endl;
    else if(sum==X) cout<<N<<endl;
    else{
        int ans=0;
        REP(i,N){
            if(X>=a[i]){
                X-=a[i];
                ans++;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int LLI;
int main()
{
	int n;
	LLI a, b, x, diff, sum = 0 ;
	cin >> n >> x;
	cin >> a >> b;
	if( a + b > x )
	{
		diff = a + b - x;
		if( diff <= b )
	    	b -= diff;
	    else
	    	b = 0;
		sum += diff;
	}
	a = b;
	for(int i = 2; i < n; i++)
	{
	    cin >> b;
	    if( a + b > x )
		{
			diff = a + b - x;
			if( diff <= b )
		    	b -= diff;
		    else
		    	b = 0;
			sum += diff;
		}
		a = b;
	}
	cout << sum;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 204,M = 1e5+5;
const int mod=1e9+7;
int a[N],n,X;
int f[N][M];

int main()
{
	cin >> n >> X;
	for(int i=1;i<=n;i++)cin >> a[i];
	sort(a+1,a+n+1);
	f[n+1][X]=1; 
	for(int i=n;i;i--){
		for(int j=1;j<=X;j++){
			f[i][j%a[i]] += f[i+1][j]; f[i][j%a[i]]%=mod;
			f[i][j] += (long long)f[i+1][j]*(i-1)%mod; f[i][j]%=mod;
		}
	}
	int ans = 0;
	for(int j=1;j<=X;j++){
		ans = ans + (long long)j * f[1][j] %mod;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
int main() {
    int n; cin >> n;
    mint  ans = 1;
    rep(i, n) {
        ans *= (i+1);
    }
    cout << ans.x;
}


Measured memory_bytes: 256
Q = 10**9+7
def main():
    N = int( input())
    A = list( map( int, input().split()))
    S = sum(A)%Q
    T = sum( [a*a for a in A])%Q
    print((S*S%Q-T)*pow(2,Q-2,Q)%Q)
if __name__ == '__main__':
    main()

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    int A, B; cin >>A>>B;
    
    if (1 <= A && A <= 9 && 1 <= B && B <= 9)
        cout << A*B << endl;
    else
        cout << -1 << endl;
}


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

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define REPe(i, n) for(int i = 0; i <= (int)(n); ++i)
#define REPi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REPei(i, a, b) for(int i = int(a); i <= int(b); ++i)

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int time[110] = {0};

    REPi(i, a, b)time[i] += 1;
    REPi(i, c, d)time[i] += 1;

    int cnt = 0;

    REPi(i, 0, 100) if(time[i] == 2) cnt++;

    cout << cnt << '\n';

}



Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
#define re real()
#define im imag()

typedef complex<double> P;
typedef pair<P,P> line; //sX+tY
double EPS=1e-10;
double dot(P a,P b){return (conj(a)*b).real();}
double cros(P a,P b){return (conj(a)*b).imag();}
P proj(P a,P to){
  return dot(a,to)/norm(to)*to;
}
int ccw(P a,P b,P c){
  b-=a; c-=a;
  if(cros(b,c) > EPS) return +1;//ccw
  if(cros(b,c) < EPS) return -1;//cw
  if(dot(b,c) < EPS) return +2; //c-a-b
  if(dot(b,c) > EPS) return -2; //a-b-c or a-c-b
  return 0;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int i,j,k;
  P a,b,c,p;
  double are,aim,bre,bim,cre,cim,pre,pim;
  while(cin>>are>>aim>>bre>>bim>>cre>>cim>>pre>>pim){
    a=P(are,aim); b=P(bre,bim); c=P(cre,cim); p=P(pre,pim);
    if(ccw(a,b,p)==ccw(b,c,p) && ccw(b,c,p)==ccw(c,a,p))
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
# import
import itertools

# input
S = input()
SS = []
CC = []

# LRの間でスライスして文字列に追加
p_cut = 0

for i in range(len(S) -1) : 
    if i == len(S) -2: 
        SS.append(S[p_cut:i+2])
    
    elif S[i] == "L" and S[i+1] == "R" : 
        SS.append(S[p_cut:i+1])
        p_cut = i+1
        
# CCの作成
CC = [[0 for _ in range(len(SS[i]))] for i in range(len(SS))]

# other_setting
for i in range(len(SS)) : 
    cnt_R = 0
    cnt_L = 0

    for j in range(len(SS[i])) : 
        if SS[i][j] == "R" : 
            cnt_R += 1
        else : 
            point_R = j-1
            point_L = j
            break
        
    cnt_L = len(SS[i]) -cnt_R
    # print(i, cnt_R, cnt_L)
    
    if cnt_R % 2 == 0 and cnt_L % 2 == 0 : 
        CC[i][point_R] = int((cnt_R+cnt_L)/2)
        CC[i][point_L] = int((cnt_R+cnt_L)/2)
    elif cnt_R % 2 == 0 and cnt_L % 2 == 1 : 
        CC[i][point_R] = int(cnt_R/2 + cnt_L - ((cnt_L + 1)/2))
        CC[i][point_L] = int(cnt_R/2 + ((cnt_L + 1)/2))
    elif cnt_R % 2 == 1 and cnt_L % 2 == 0 : 
        CC[i][point_R] = int(cnt_L/2 + ((cnt_R + 1)/2))
        CC[i][point_L] = int(cnt_L/2 + cnt_R - ((cnt_R + 1)/2))
    elif cnt_R % 2 == 1 and cnt_L % 2 == 1 : 
        CC[i][point_R] = int((cnt_R+cnt_L)/2)
        CC[i][point_L] = int((cnt_R+cnt_L)/2)

# # confirm
# print(SS)
# print(CC)

# output
print(*list(itertools.chain.from_iterable(CC)))

Measured memory_bytes: 14672
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n][n] = {0};
    rep(i, n)
    {
        rep(j, n)
        {
            int temp;
            cin>>temp;
            if(temp==-1) temp=INT_MAX;
            a[i][j]=temp;
        }
    }
    int mincost[n];
    bool used[n];
    rep(i, n)
    {
        mincost[i] = INT_MAX;
        used[i] = false;
    }
    //solve by prim
    mincost[0] = 0;
    int res = 0;
    while (true)
    {
        int v = -1;
        rep(i, n)
        {
            if (used[i] == false && (v == -1 || mincost[i] < mincost[v]))
                v = i;
        }
        if (v == -1)
            break;
        used[v] = true;
        res += mincost[v];
        rep(i, n)
        {
            mincost[i] = min(mincost[i], a[v][i]);
        }
    }cout<<res<<endl;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        return fact[n]*ifact[n-k];
    }
};

vector<ll> prime;

void setPrime(ll x) {
    for (ll i=2; i<=x; i++) {
        bool ok = true;
        for (ll e: prime) {
            if (i%e==0) {
                ok = false;
                break;
            }
            if (e*e>i) {
                break;
            }
        }
        if (ok) prime.push_back(i);
    }
}


 

int main(){
    int n;
    cin >> n;
    vector<mint> num(1005, mint(1));
    setPrime(n);
    for (int i=1; i<=n; i++) {
        int now = i;
        for (int p: prime) {
            while (now%p==0) {
                now /= p;
                num[p]+=1;
            }
            if (now ==1) break;
        }
    }
    mint ans = 1;
    for (mint e: num) {
        ans *= e;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <cmath>
#include <string.h>

using namespace std;

int main(int argc, char* argv[]) {
  vector<int> rets;
  while (true) {
    int w, h;
    cin >> w >> h;

    if (w == 0 && h == 0)
      break;

    map<pair<int, int>, vector<pair<int, int> > > m;
    for (int i = 0; i < h; ++i) {
      int horizon[w - 1];
      for (int j = 0; j < w - 1; ++j)
        cin >> horizon[j];

      int vertical[w];
      if (i < h - 1) {
        for (int j = 0; j < w; ++j)
          cin >> vertical[j];
      }

      for (int j = 0; j < w; ++j) {
        pair<int, int> cur = make_pair(i, j);
        int cur_x = j;
        int cur_y = i;

        // check right
        int next_y = cur_y;
        int next_x = cur_x + 1;
        pair<int, int> next = make_pair(next_y, next_x);
        if (next_x < w) {
          if (horizon[cur_x] == 0) {
            m[cur].push_back(next);
            m[next].push_back(cur);
          }
        }

        // check bottom
        next_y = cur_y + 1;
        next_x = cur_x;
        next = make_pair(next_y, next_x);
        if (next_y < h) {
          if (vertical[cur_x] == 0) {
            m[cur].push_back(next);
            m[next].push_back(cur);
          }
        }
      }
    }

    int d[h][w];
    memset(d, -1, sizeof(int) * h * w);
    d[0][0] = 0;

    queue<pair<int, int> > q;
    q.push(make_pair(0, 0));
    while (!q.empty()) {
      pair<int, int> cur = q.front();
      q.pop();
      int cur_x = cur.second;
      int cur_y = cur.first;
      for (int i = 0; i < m[cur].size(); ++i) {
        pair<int, int> next = m[cur][i];
        int next_x = next.second;
        int next_y = next.first;
        if (d[next_y][next_x] == -1) {
          d[next_y][next_x] = d[cur_y][cur_x] + 1;
          q.push(next);
        }
      }
    }

    if (d[h - 1][w - 1] == -1)
      rets.push_back(0);
    else
      rets.push_back(d[h - 1][w - 1] + 1);
  }

  for (int i = 0; i < rets.size(); ++i)
    cout << rets[i] << endl;

  return 0;
}


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

enum State { ParsingAs, ParsingB, ParsingC, NotParsing };

int main() {
  string S;
  cin >> S;

  State state = NotParsing;
  int nAs = 0;
  int nBCs = 0;
  long long total = 0;

  for (int i = 0; i < S.size() - 1; i++) {

    if(S[i] == 'A') nAs += 1;
    else if(S[i] == 'B' && S[i + 1] == 'C') { total += nAs; i += 1; }
    else nAs = 0;




  //   switch(state) {
  //   case NotParsing: {
  //     if(S[i] == 'A') {
  //       state = ParsingAs;
  //       nAs = 1;
  //     }
  //   } break;

  //   case ParsingAs: {
  //     switch(S[i]) {
  //     case 'A': {
  //       nAs += 1;
  //     } break;
  //     case 'B': {
  //       state = ParsingB;
  //     } break;
  //     default: {
  //       state = NotParsing;
  //       nAs = 0;
  //       nBCs = 0;
  //     }
  //     }
  //   } break;

  //   case ParsingB: {
  //     switch(S[i]) {
  //     case 'A': {
  //       state = ParsingAs;
  //       nAs = 1;
  //     } break;
  //     case 'C': {
  //       state = ParsingC;
  //       nBCs += 1;
  //     } break;
  //     default: {
  //       state = NotParsing;
  //       nAs = 0;
  //       nBCs = 0;
  //     }
  //     }
  //   } break;

  //   case ParsingC: {
  //     switch(S[i]) {
  //     case 'A': {
  //       state = ParsingAs;
  //       total += nAs * nBCs;
  //       nAs += 1;
  //       nBCs = 0;
  //     } break;
  //     case 'B': {
  //       state = ParsingB;
  //     } break;
  //     default: {
  //       state = NotParsing;
  //       total += nAs * nBCs;
  //       nAs = 0;
  //       nBCs = 0;
  //     }
  //     }
  //   } break;
  //   }
  // }

  // if(state == ParsingC || state == ParsingB) total += nAs * nBCs;
  }
  cout << total << endl;
}


Measured memory_bytes: 832
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
int n;
map<ll,ll>t;
ll a[200010],ans;
int main()
{
	t[0]++;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]+=a[i-1];
		ans+=t[a[i]];
		t[a[i]]++;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define RREPS(i,n) RFOR(i,1,n+1)
#define ALL(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using ll = long long;
#define int ll

bool Fcomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.F < secondElof.F;}
bool Scomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.S < secondElof.S;}

//**********

signed main(void) {
    
    int n=0;
    vector<int> x;

    scanf("%lld",&n);
    REP(i,n){
        int a;
        scanf("%lld",&a);
        x.pb(a);
    }
    vector<int> y = x;
    sort(ALL(y));
    int med_l = y[n/2-1];
    int med_h = y[n/2];

    REP(i,n){
        int ans;
        if(x[i]>med_l) ans = med_l;
        else ans = med_h;
        printf("%lld\n",ans);
    }
    
    return 0;
    
}




Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;
  ll a[n], b[n];

  ll rec = 1e11, ans;

  REP(i, n){
    cin >> a[i] >> b[i];
    if(b[i] < rec){
      rec = b[i];
      ans = a[i] + b[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#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 main(){
    int N,M;
    cin >> N >> M;
    vector<ll> x(N),y(N),z(N);

    rep(i,N){
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = -LINF;
    for(int mask=0;mask<(1<<3);mask++){
        // 0 : + , 1 : -
        int d[3]={1,1,1};
        rep(i,3) if(mask & (1<<i)) d[i] = -1;
        vector<ll> t(N);
        rep(i,N){
            ll sum = 0;
            sum += x[i] * d[0];
            sum += y[i] * d[1];
            sum += z[i] * d[2];
            t[i] = sum;
        }
        sort(all(t));
        reverse(all(t));
        ll c = 0;
        rep(i,M){
            c += t[i];
        }
        ans = max(ans,c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
queue = []
for i in range(n):
    name, time = input().split()
    time = int(time)
    queue.append([name, time])
ans = []
cnt = 0
while queue !=  []:
    queue[0][1] = queue[0][1] - q
    if queue[0][1] > 0:
        cnt += q
        queue.append(queue.pop(0))
    else:
        cnt += q + queue[0][1]
        ans.append([queue[0][0], cnt])
        queue.pop(0)
for i in ans:
    print(' '.join(map(str, i)))


Measured memory_bytes: 14476
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int Y = sc.nextInt();

        sc.close();

        int sum = 0;
        // 10000yen
        int C = 0;

        for(int A = 0; A <= N; A++) { // 1000yen
            for(int B = 0; B <= N; B++) {
                C = N - A - B;
                sum = 10000 * C + 5000 * B + 1000 * A;
                if(sum == Y && A >= 0 && B >= 0 && C >= 0) {
                    System.out.println(C + " " + B + " " + A);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<vector>

using namespace std;

#define long long long
#define ft(i, a, b) for (int i = (long)a ; i <= (long)b ; i++)
#define fd(i, a, b) for (int i = (long)a ; i >= (long)b ; i--)

const int MAXN = 1e5 + 5;
const long oo = 1e15;

long n , k;
long a[MAXN] , dp[MAXN];

long choose(int i , int j) {
    return abs(a[i] - a[j]);
}

void Solve() {
    ft(i , 2 , n) {
        dp[i] = oo;
        fd(j , i - 1 , max(i - k , 1LL)) {
            dp[i] = min(dp[j] + choose(i , j) , dp[i]);
            //if (i == n) cout << "THIS IS DEBUG " << j << " " << dp[j] << " " << i << " " << dp[i] << "\n";
        }
    }    
    cout << dp[n];
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
}

void Input() {
    cin >> n >> k;
    ft(i , 1 , n) cin >> a[i];
}

int main() {
    FastInput();
    Input();
    Solve();
}

Measured memory_bytes: 5140
#include<stdio.h>

const int MAX = 200;

int main() {
  int N;
  int red[100][2];
  int blue[100][2];
  int tmp[2];
  int tmpn;
  int cnt = 0;
  int cnty = 0;

  scanf("%d", &N);

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

    for (int j = i; j > 0; j--) {
      if (red[j][0] < red[j - 1][0]) {
        tmp[0] = red[j][0];
        tmp[1] = red[j][1];
        red[j][0] = red[j - 1][0];
        red[j][1] = red[j - 1][1];
        red[j - 1][0] = tmp[0];
        red[j - 1][1] = tmp[1];
      }
    }
  }

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

    for (int j = i; j > 0; j--) {
      if (blue[j][0] < blue[j - 1][0]) {
        tmp[0] = blue[j][0];
        tmp[1] = blue[j][1];
        blue[j][0] = blue[j - 1][0];
        blue[j][1] = blue[j - 1][1];
        blue[j - 1][0] = tmp[0];
        blue[j - 1][1] = tmp[1];
      }
    }
  }


  bool f = false;
  for (int i = 0; i < N; i++) {
    tmp[0] = -1;
    tmp[1] = -1;
    f = false;
    for (int j = 0; j < N; j++) {
      if (blue[i][0] > red[j][0] && blue[i][1] > red[j][1]) {
        f = true;
        if (tmp[1] < red[j][1]) {
          tmp[0] = red[j][0];
          tmp[1] = red[j][1];
          tmpn = j;
        }
      }
    }
    if (f) {
      cnt += 1;
      red[tmpn][0] = MAX;
      red[tmpn][1] = MAX;
    }
  }


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

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<sstream>
#include<stdio.h>
#include <functional>
#include<set>

using namespace std;

int main()
{
	int n,q;
	cin >> n >> q;
	vector<int> a(n);
	for ( int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<int> ans(q);
	for (int i = 0; i < q; i++)
	{
		int l, r;
		cin >> l >> r;
		int x,y;
		x= lower_bound(a.begin(), a.end(), l)-a.begin();
		y = upper_bound(a.begin(), a.end(), r)-a.begin();
		y--;
		ans[i] = y - x+1;
	}
	for (int i = 0; i < q; i++)
	{
		cout << ans[i] << endl;
	}

}


Measured memory_bytes: 3596
use std::io;
use std::collections::HashMap;


/// https://beta.atcoder.jp/contests/arc082/tasks/arc082_a
fn main() {
    let _ = read_one::<usize>();
    let an = read::<isize>();
    let mut hm = HashMap::new();
    let am = an.clone().iter().map(|i| i - 1).collect::<Vec<_>>();
    let ap = an.clone().iter().map(|i| i + 1).collect::<Vec<_>>();

    for a in an {
        *hm.entry(a).or_insert(0) += 1;
    }

    for a in am {
        *hm.entry(a).or_insert(0) += 1;
    }

    for a in ap {
        *hm.entry(a).or_insert(0) += 1;
    }

    let mut v = hm.iter().collect::<Vec<_>>();
    v.sort_by_key(|&(_, v)| -v);

    println!("{:?}", v[0].1);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 14588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int l[10][40000],r[10][40000];

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  set<tuple<int,int,int>> se;
  rep(i,n){
    if(i-1>=0)rep(j,10)l[j][i]=l[j][i-1];
    l[s[i]-'0'][i]++;
  }
  rep(i,n){
    rep(j,10)r[j][n-1-i]=r[j][n-i];
    r[s[n-1-i]-'0'][n-1-i]++;
  }
  for(int i=1;i<=n-2;i++){
    rep(j,10)rep(k,10){
      if(l[j][i-1]*r[k][i+1]>0){
        tuple<int,int,int> t=make_tuple(j,(int)(s[i]-'0'),k);
        se.insert(t);
      }
    }
  }
  cout << se.size() << endl;
return 0;}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const int MAXN = 2e5;
const int INF = 1e9 + 2;
const ld pi = acos(-1);
const ll MOD = 1e9 + 7;
const ll POW = 1e9 + 9;

ll a, b;

int main() {

    faster();

    cin >> a >> b;

    if(a < 0 && b < 0){
        if((b - a + 1) % 2 == 1){
            cout << "Negative";
        }
        else{
            cout << "Positive";
        }
    }
    else if(a <= 0 && 0 <= b){
        cout << "Zero";
    }
    else{
        cout << "Positive";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a-b <= c){
            System.out.println(c-a+b);
        }else{
            System.out.println(0);
        }
        
    }
}

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

int main() {

    for(int i = 1; i <= 3000; i++){
        int x, y;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x < y) cout << x << " " << y << endl;
        else cout << y << " " << x << endl;
        
    }
}


Measured memory_bytes: 2984
local read = io.read
local n = read("n")
local a = {}
for i = 1, n do
	a[i] = read("n")
end

local has_shined = {}
local function push_switch(light_num, push_times)
	if light_num == 2 then
		return push_times
	elseif has_shined[light_num] then
		return -1
	else
		has_shined[light_num] = true
		push_times = push_times + 1
		return push_switch(a[light_num], push_times)
	end
end

print(push_switch(1, 0))


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

main()
{
  int x, y, s;
  while( cin >> x >> y >> s, x + y + s ) {
    int mx = 0;
    for(int i=1; i<s-1; i++) {
      for(int j=i; j<s; j++) {
	if( i * (100+x) / 100 + j * (100+x) / 100 == s ) {
	  mx = max(mx, i * (100+y) / 100 + j * (100+y) / 100); 
	}
      }
    }

    cout << mx << endl;
  }
}

Measured memory_bytes: 3080
n = int(input())
b = [4, 7]
p = [0]

while 1:
	pt = []
	for i in range(len(p)):
		for j in range(2):
			if p[i]+b[j] < n:
				pt.append(p[i]+b[j])
			elif p[i]+b[j] == n:
				print("Yes")
				exit(0)
	if len(pt) == 0:
		print("No")
		exit(0)
	else:
		p = pt




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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    int a, b; cin >> a >> b;
    priority_queue<int> pq;
    REPI(i, a){
        int x; cin >> x;
        pq.push(x);
    }

    int ans = 0;
    REPI(i, b){
        ans += pq.top();
        pq.pop();
    }cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N, K = 0;
    scanf("%ld %ld", &N, &K);
    if(N % 2 == 0){
        if(N / 2 >= K){
            printf("YES\n");
        }else {
            printf("NO\n");
        }
    }else {
        if(N / 2 + 1 >= K){
            printf("YES\n");
        }else {
            printf("NO\n");
        }
    }
}

Measured memory_bytes: 128
/*
これを入れて実行
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 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;
}

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

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


int main(void){
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	cout << min(a, b) + min(c, d) << endl;
}



Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

A = []

A.append(a * x + b * y)

if x > y:
    A.append(2 * c * y + (x - y) * a)
    A.append(2 * c * x)
else:
    A.append(2 * c * x + (y - x) * b)
    A.append(2 * c * y)

print(min(A))

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

int main(){
  string s,u;
  int a = 0;
  cin >> s;
  u = s;
  reverse(s.begin(), s.end());
  for(int i=0; i<s.size()/2; i++){
    if(s[i]!=u[i]){a++;}
  }
  cout << a << endl;
}

Measured memory_bytes: 256
N,L = map(int,input().split())
sum = 0

if L>=0:
    for i in range(N):
        sum += i+L
    print(sum-L)
elif L<0 and N+L>0:
    for i in range(N):
        sum += i+L 
    print(sum)
else:
    for i in range(N-1):
        sum += i+L 
    print(sum)

Measured memory_bytes: 3064