akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 998244353
using namespace std;
using ll = long long;

int main() {
    int N, S; cin >> N >> S;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    ll dp[N + 1][S + 1][3] = {};
    dp[0][0][0] = 1;
    REP(i, 0, N) {
        REP(j, 0, S + 1) {
            REP(k, 0, 3) {
                REP(l, k, 3) {
                    dp[i + 1][j][l] = (dp[i + 1][j][l] + dp[i][j][k]) % MOD;
                    if (j + A[i] < S + 1 && k != 2 && l != 0) dp[i + 1][j + A[i]][l] = (dp[i + 1][j + A[i]][l] + dp[i][j][k]) % MOD;
                }
            }
        }
    }

    cout << dp[N][S][2] << endl;
    return 0;
}

Measured memory_bytes: 211328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin >> S;
}
//=============================
void func() {}

void add(vector<pii> &v, int l, int r){
    v.push_back(make_pair(l,r));
}
int diff(int a, int b)
{
    return min(abs(a - b), abs(b - a));
}
//=============================
void solve()
{
    // S : L or R
    // S[0] == 'R', S[-1] == 'L'
    int N = S.size();
    vector<int> subv;
    int ans[N] = {};
    enum State
    {
        STATE_INIT = 0,
        STATE_GOTR = 1,
        STATE_GOTL = 2,
        STATE_CALC = 3,
    };
    State state = STATE_INIT;
    int rcount,lcount;
    char R='R';
    char L='L';
    int i=0;
    int begin_index = 0;
    vector<pii> lr;
    for( ; i<N ; ++i){
        switch (state)
        {
        case STATE_INIT:
            begin_index = i;
            rcount=lcount=0;
            
            if (S[i]==R){
                state = STATE_GOTR;
                rcount++;
            }
            break;
        case STATE_GOTR:
            if (S[i]==L){
                state = STATE_GOTL;
                lcount++;
            }
            else {
                rcount++;
            }
            break;
        case STATE_GOTL:
            if (S[i]==R){
                add(lr, lcount,rcount);
                lcount=0;
                rcount=1;
                state = STATE_GOTR;
            }
            else {
                lcount++;
            }
            break;
        }
    }
    add(lr,lcount,rcount);
    
    int id = 0;
    for(auto x : lr){
        int f = x.first;
        int s = x.second;
        int n = id+f+s;
        int br = s-1;
        int bl = s;
        for(int i=0; i<f+s; ++i){
            int now = id+i;
            if (diff(i,br)%2 == 0){
                ans[id+br]++;
            }
            else {
                ans[id+bl]++;
            }
        }
        id = n;
    }
    rep(i,N){
        cout<<ans[i]<<(i==N-1 ? "\n" : " ");
    }
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 2296
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();
		
		if(a%2==1 && b%2==1)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	boolean[] pattern;
	boolean[][] osenbei;
	int c, r, max;

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			c = scan.nextInt();
			r = scan.nextInt();
			if (c + r == 0)
				break;
			pattern = new boolean[c];
			osenbei = new boolean[c][r];
			for (int i = 0; i < c; i++) {
				for (int j = 0; j < r; j++)
					osenbei[i][j] = scan.nextInt() == 1? true : false;
			}
			max = 0;
			dfs(0);
			System.out.println(max);
		}
	}

	void dfs(int d) {
		if (d == pattern.length) {
			max = Math.max(max, solve());
			return;
		}
		pattern[d] = false;
		dfs(d + 1);
		pattern[d] = true;
		dfs(d + 1);
		return;
	}

	int solve() {
		int sum = 0;
		for (int i = 0; i < r; i++) {
			int count = 0;
			for (int j = 0; j < c; j++) {
				if (pattern[j]) {
					count += osenbei[j][i]? 1 : 0;
				} else {
					count += !osenbei[j][i]? 1 : 0;
				}
			}
			sum += Math.max(count, pattern.length - count);
		}
		return sum;
	}

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

Measured memory_bytes: 69612
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []
  /*

  **o**of*
  *o*of***
  o**of**f
  
  */

  const main = (): Print => {
    const r = _io()
    const [K] = r.nn()
    const S = r.s()

    const sl = S.length
    const l = sl + K

    fset(l)
    let res = 0
    let cache25 = 1

    // ###*****
    for (let i = 0; i <= K; i++) {
      let n1 = mul(ncr(l, i), cache25) % mod

      res = (res + n1) % mod
      cache25 = (cache25 * 25) % mod
    }

    return res
  }

  const _io = (i = 0) => {
    const str: string = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }
  const fac: number[] = []
  const finv: number[] = []
  const mod = 10 ** 9 + 7
  const mul = (...a): number =>
    a.reduce(
      (r, c) => ((((r >> 16) * c) % mod) * 65536 + (r & 65535) * c) % mod,
      1
    )
  const inv = (b) => {
    for (var a = mod, u = 0, v = 1, t; b; v = t)
      (t = (a / b) | 0),
        (a -= t * b),
        (u -= t * v),
        (t = a),
        (a = b),
        (b = t),
        (t = u),
        (u = v)
    u %= mod
    return u < 0 ? u + mod : u
  }
  const fset = (n: number) => {
    fac.length = n + 1
    fac[0] = fac[1] = 1
    for (let i = 2; i <= n; ) {
      fac[i] = mul(fac[i - 1], i++)
    }
    finv.length = n + 1
    finv[0] = finv[1] = 1
    finv[n] = inv(fac[n])
    for (let i = n; 2 < i; ) {
      finv[i - 1] = mul(finv[i], i--)
    }
  }
  const ncr = (n: number, r: number) => mul(fac[n], finv[r], finv[n - r])

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 112056
#include <stdio.h>
int main() {
    short int n;
    int A[100], cnt = 0;
    scanf("%hi", &n);
    for (short int i = 0; i < n; i++) scanf("%i", A + i);
    for (short int i = 0; i < n - 2; i++)
        for (short int j = i + 1; j < n - 1; j++)
            for (short int k = j + 1; k < n; k++) {
                if (A[i] == A[j] || A[i] == A[k] || A[j] == A[k]) continue;

                if (A[i] + A[j] > A[k] && A[i] + A[k] > A[j]
                    && A[j] + A[k] > A[i]) cnt++;
            }
    printf("%i", cnt);
}


Measured memory_bytes: 1728
/*
g++ -ggdb -fsanitize=address -std=c++14 C.cpp && ./a.out <<< "20 3
5 10 15"
*/

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename A>
string to_string(A v) { int cnt = 0; string res; for (const auto &x : v) { if (cnt++) res += " "; res += to_string(x); } return "[" + res + "]"; }
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    ll k, n; cin >> k >> n;

    vector<ll> A(n); rep(i, 0, n) cin >> A[i];
    sort(all(A));

    ll maxd = 0;
    rep(i, 0, n) maxd = max( maxd, i == 0 ? (k - A[n - 1] + A[0]) : (A[i] - A[i - 1]) );

    cout << (k - maxd) << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int MAX_N = 300;
static const int MAX_M = 300;

int N, M;
int A[MAX_M][MAX_N];

int sport[MAX_M + 1];

void solve(){
	int min = 300;
	for(int i = 0; i < M; i++){
		fill(sport, sport + M + 1, 0);
		for(int j = 0; j < N; j++){
			for(int k = 0; k < M; k++){
				if(A[j][k] != 0){
					//cout << A[j][k];
					//if(j == N - 1) cout << endl;
					//else cout << " ";
					sport[A[j][k]]++;
					break;
				}
			}
		}
		int max = 0;
		int max_i;
		for(int j = 1; j <= M; j++){
			//cout << sport[j] << endl;
			if(sport[j] > max){
				max = sport[j];
				max_i = j;
			}
		}
		//cout << max << endl;
		for(int j = 0; j < N; j++){
			for(int k = 0; k < M; k++){
				if(A[j][k] == max_i){
					A[j][k] = 0;
					break;
				}
			}
		}
		if(min > max) min = max;
	}
	cout << min << endl;
}

int main(){
	cin >> N >> M;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> A[i][j];
		}
	}
	solve();
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

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

map <ll,int> mp;
pr num[100005];

vector <int> e[100005];
int siz[100005],dep[100005];

void dfs(int x) {
  for(int i=0;i<e[x].size();i++) {
  	int u=e[x][i];
  	dep[u]=dep[x]+1;
  	dfs(u);
  }
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
  	ll x;
  	scanf("%lld",&x);
  	num[i]=pr(x,i);
  	mp[x]=i;
  }
  sort(num+1,num+n+1);
  for(int i=1;i<=n;i++) siz[i]=1;
  for(int i=n;i>1;i--) {
  	int x=num[i].SE;
  	if (siz[x]*2>=n) {
  		puts("-1");
  		return 0;
	  }
	ll v=num[i].FR-(n-2*siz[x]);
	if (!mp.count(v)) {
		puts("-1");
		return 0;
	}
	int p=mp[v];
	e[p].push_back(x);
	siz[p]+=siz[x];
  }
  if (siz[num[1].SE]!=n) {
  	puts("-1");
  	return 0;
  }
  dfs(num[1].SE);
  ll s=0;
  for(int i=1;i<=n;i++) s+=dep[i];
  if (s!=num[1].FR) {
  	puts("-1");
  	return 0;
  }
  for(int i=1;i<=n;i++)
    for(int j=0;j<e[i].size();j++) printf("%d %d\n",i,e[i][j]);
  return 0;
}

Measured memory_bytes: 20156
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>N>>S;
    int temp = 0, ans = 0;
    rep(i,N){
        temp += (S[i] == 'I' ? 1 : -1);
        ans = max(ans, temp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <numeric>
#include <sstream>
#include <iomanip>
using ll = long long;
using namespace std;

int main()
{
    int t = 10;
    int tmp;
    int ans = 0;
    for (int i = 0; i < 5; i++)
    {
        cin >> tmp;
        if (tmp % 10 == 0)
            ans += tmp;
        else
        {
            t = min(t, tmp % 10);
            ans += tmp / 10 * 10 + 10;
        }
    }
    cout << ans - 10 + t << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void next(String s, int index, String p){
        int i;
        for(i = 1; i < p.length(); i++){
            int sub2 = (index+i)%s.length();
            if(s.charAt(sub2) != p.charAt(i))break;
        }
        if(i == p.length()){
            System.out.println("Yes");
            System.exit(0);
        }
    }

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String s, pattern;
        s = scanner.nextLine();
        pattern = scanner.nextLine();

        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == pattern.charAt(0))next(s, i, pattern);
        }
        System.out.println("No");
    }
}



Measured memory_bytes: 26364
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
const int N=2005;
int ans[N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, x, y;
     cin >> n >> x >> y;
    // --x; --y;
    for(int i=1; i<=n; i++) {
        for(int j=i+1; j<=n; j++) {
            int d=0;
            if(i<=x) d+=x-i;
            if(j>=y) d+=j-y;
            int tx=max(i,x), ty=min(j,y);
            d+=min(ty-tx, y-x+1-(ty-tx));
            ans[d]++;
        }
    }
    REP(i,n-1) cout << ans[i+1] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i = (a);i <= (b);++i)
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;

int main()
{

	string s,t;
	cin>>s>>t;
	int n = s.size();
	int m = t.size();
	int ans = 1e9;
	for(int i = 0;i < n-m+1;++i){
		string tmp = s.substr(i,m);
		int cnt = 0;
		for(int j = 0;j < m;++j){
			if(tmp[j]!=t[j])cnt++;
		}
		ans = min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3596
from math import ceil 
s=input()
n=len(s)
ans=[0]*n
r=0
l=0
for i in range(n-1):
    if s[i]=="R":
        r+=1
    if s[i+1]=="L":
        ans[i]+=ceil(r/2)
        ans[i+1]+=r//2
        r=0
    if s[n-i-1]=="L":
        l+=1
    if s[n-i-2]=="R":
        ans[n-i-1]+=ceil(l/2)
        ans[n-i-2]+=l//2
        l=0
print(" ".join(map(str,ans)))

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

int main()
{
    ll i,j,k,n,q,t=1,c=0;
    ll a,b;
    cin>>a>>b;
    if(abs(a-b)>1)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
}


Measured memory_bytes: 256
<?php
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
//   print_r($c);
  
  $j1 = $c[0][1]-$c[0][0];
  $j2 = $c[0][2]-$c[0][0];
  
  $i1 = $c[1][0]-$c[0][0];
  $i2 = $c[2][0]-$c[0][0];
  
  for($i=1; $i<3; $i++){
      if($j1 != $c[$i][1]-$c[$i][0]){
          echo "No";
          exit;
      }
      if($j2 != $c[$i][2]-$c[$i][0]){
          echo "No";
          exit;
      }
      if($i1 != $c[1][$i]-$c[0][$i]){
          echo "No";
          exit;
      }
      if($i2 != $c[2][$i]-$c[0][$i]){
          echo "No";
          exit;
      }
  }
  echo "Yes";

Measured memory_bytes: 4728
N=int(input())
if N==0:
  print(0)
  exit()
if N>0:
  S=bin(N)[2:]
  S=list(S[::-1])
  S=list(map(int,S))
  S+=[0]*1000
  i=0
  while True:
    S[i+1]+=S[i]//2
    S[i]=S[i]%2
    if i%2==1:
      S[i+1]=S[i+1]+S[i]
    i+=1
    if i==len(S)-1:
      break
  S=list(map(str,S))
  S=list(reversed(S))
  S="".join(S)
  print(int(S))
else:
  N=abs(N)
  S=bin(N)[2:]
  S=list(S[::-1])
  S=list(map(int,S))
  S+=[0]*1000
  i=0
  while True:
    S[i+1]+=S[i]//2
    S[i]=S[i]%2
    if i%2==0:
      S[i+1]=S[i+1]+S[i]
    i+=1
    if i==len(S)-1:
      break
  S=list(map(str,S))
  S=list(reversed(S))
  S="".join(S)
  print(int(S))

Measured memory_bytes: 9080
node1234= [0, 0, 0, 0]
for i in range(3):
    ai , bi = list(map(int, input().split()))
    # print('path is ', ai, bi)
    node1234[ai-1] +=1
    node1234[bi-1] +=1
# print(node1234)
odd = 0
for ele in node1234:
    if ele/2 == 1:
        odd+=1
# print(node)
# print(odd)
if odd == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<algorithm>
#define f first
#define s second
#define pb push_back
using namespace std;
int const INF=0x3f3f3f3f;
int const maxn=200005;
typedef long long ll;
typedef pair<int,int>P;
int mv[2][2]={{1,0},{0,1}};
map<int,ll>mmp;
int a[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		mmp[a[i]]++;
	}
	ll res=0;
	ll m=mmp.size();
	for(auto it:mmp){
		res+=it.s*(it.s-1)/2;
	}
	for(int i=0;i<n;i++){
		printf("%lld\n",res-(mmp[a[i]]-1));
	}
}


Measured memory_bytes: 10240
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long w = sc.nextLong();
        if (h == 1 || w == 1) {
            System.out.println("1");
        } else if ((h * w) % 2 == 0) {
            System.out.println(h * w / 2);
        } else if (h % 2 == 1 && h % 2 == 1) {
            System.out.println((h / 2 + 1) * (w / 2 + 1) + (h / 2) * (w / 2));
        }
    }
}

Measured memory_bytes: 35856
import java.util.*;
 
class Restaurant implements Comparable<Restaurant> {
	String direc;
	int num;
	int i;
	
	public Restaurant(String direc, int num, int i) {
		this.direc = direc;
		this.num = num;
		this.i = i;
	}
 
	public int compareTo(Restaurant other) {
		int ans = direc.compareTo(other.direc);
		if (ans != 0)
			return ans;
		return Integer.compare(other.num, num);
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Restaurant> list = new ArrayList<Restaurant>();
		int n = sc.nextInt();
		for (int i=1; i<=n; i++) {
          
			String direc = sc.next();
			int num = sc.nextInt();
			list.add(new Restaurant(direc, num, i));
          
		}
		Collections.sort(list);
		for (Restaurant restaulant : list) {
			System.out.println(restaulant.i);
		}
	}
}


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

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	if (n == 1) {
		if (a == b)cout << 1 << endl;
		else cout << 0 << endl;
	}
	else {
		if (a > b)cout << 0 << endl;
		else if (a == b)cout << 1 << endl;
		else cout << (n - 2)*(b - a) + 1 << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+9;
int arr[maxn];
int n;
int aa,bb;
bool sol(int a){
    int ans=0;
    for(int i=0;i<n&&ans<=a;i++){
        if((ll)a*(ll)bb>=(ll)arr[i]){
            continue;
        }
        int tmp=arr[i]-bb*a;
        int tt=aa-bb;
        ans+=tmp/tt+((tmp%tt)>0);
    }
    return ans<=a;
}
int main(){
    //freopen("in","r",stdin);
    ios::sync_with_stdio(0);
    cin>>n;
    cin>>aa>>bb;
    int l=1,r=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        r=max(r,arr[i]);
    }
    r=r/bb+((r%bb)>0);
    if(sol(1)){
        cout<<1<<endl;
        return 0;
    }
    while(r-l>1){
        //cout<<l<<' '<<r<<endl;
        int mid=l+((r-l)>>1);
        //cout<<mid<<endl;
        if(sol(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    cout<<r<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const ll inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

ll L;
vector<ll> a, x;
ll len(ll l, ll r) {
    ll s = x[l], t = x[r];
    if (r < l) return L - abs(s - t);
    return abs(s - t);
}
P search(ll th, ll s) {
    ll n = a.size();
    ll l = 0, r = n;
    while (r - l > 1) {
        ll m = (l + r)/2;
        if ( len(s, (s+m)%n) >= th ) {
            r = m;
        }
        else {
            l = m;
        }
    }
    if (r == n) return P(s, L);
    return P((s+r)%n, len(s, (s+r)%n));
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n; cin >> n;
    a.assign(n, 0); cin >> a;
    x.assign(n, 0); REP(i, n-1) x[i+1] = x[i] + a[i];
    L = 0; REP(i, n) L += a[i];
    ll l = 0, r = L;
    while (r - l > 1) {
        ll m = (l + r)/2;
        bool f = false;
        REP(i, n) {
            ll sd = 0;
            ll pos, d;
            P p = search(m, i); tie(pos, d) = p; sd += d;
            p = search(m, pos); tie(pos, d) = p; sd += d;
            p = search(m, pos); tie(pos, d) = p; sd += d;
            sd += len(pos, i);
            if (sd == L) {
                f = true;
                break;
            }
        }
        if (f) {
            l = m;
        }
        else {
            r = m;
        }
    }
    cout << l << endl;
}

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

using namespace std;
typedef long long ll;

int N, C;
int D[30][30];
int cnt[3][30];

int main() {
	cin >> N >> C;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			int a;
			cin >> a;
			a--;
			cnt[(i + j) % 3][a]++;
		}
	}

	ll ans = 1145141919810893;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				if (i == j || j == k || k == i)continue;
				ll totalcost = 0;
				for (int l = 0; l < 3; l++) {
					for (int m = 0; m < 30; m++) {
						if (l % 3 == 0)totalcost += cnt[0][m] * D[m][i];
						else if (l % 3 == 1)totalcost += cnt[1][m] * D[m][j];
						else totalcost += cnt[2][m] * D[m][k];
					}
				}
				ans = min(ans, totalcost);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  
  vector<int> change(0);
  vector<int> memo(n, 0);

  for (int i = 0; i < n - 1; i++){
    if (s[i] == 'R' && s[i + 1] == 'L'){
      change.push_back(i);
    }
  }

  int l = 0, r = 0;;
  while(r < change.size()){
    while (s[l] == 'R' && l < s.size()){
      memo[l] = change[r];
      l++;
    }
    if (l == s.size())
      break;
    while (s[l] == 'L' && l < s.size()){
      memo[l] = change[r];
      l++;
    }
    r++;
  }

  vector<int> ret(n, 0);
  for (int i = 0; i < n; i++){
    if (abs(i - memo[i]) % 2 == 0)
      ret[memo[i]]++;
    else
      ret[memo[i] + 1]++;
  }
  for (int i = 0; i < n; i++){
    cout << ret[i] << " ";
  }
  cout << endl;

  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 1664
def main():

    s = str(input())
    x, y = map(int, input().split())

    n = len(s)

    dir = 1
    dx = []
    dy = []
    cnt = 0
    for i in range(n):
        if s[i] == 'F':
            cnt += 1
        else:
            if dir == 1:
                dx.append(cnt)
                cnt = 0
                dir = -1
            else:
                dy.append(cnt)
                cnt = 0
                dir = 1
    else:
        if dir == 1:
            dx.append(cnt)
        else:
            dy.append(cnt)
    #print(dx)
    #print(dy)
    D = 8000*2+1

    import numpy as np
    dpx = [0]*(len(dx)+1)
    dpy = [0]*(len(dy)+1)
    dpx[0] = np.zeros(D, np.bool)
    dpy[0] = np.zeros(D, np.bool)
    dpx[0][8000] = 1
    dpy[0][8000] = 1
    for i, d in enumerate(dx):
        if i == 0:
            b = np.zeros(D, np.bool)
            b[d:] |= dpx[i][:D-d]
            dpx[i+1] = b
        else:
            b = np.zeros(D, np.bool)
            b[d:] |= dpx[i][:D-d]
            b[:D-d] |= dpx[i][d:]
            dpx[i+1] = b

    for i, d in enumerate(dy):
        b = np.zeros(D, np.bool)
        b[d:] |= dpy[i][:D-d]
        b[:D-d] |= dpy[i][d:]
        dpy[i+1] = b

    if dpx[-1][8000+x] == 1 and dpy[-1][8000+y] == 1:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
  int n, mx = 0;
  map<int, int> m;
  while (cin >> n) ++m[n];
  for (auto i : m) mx = max(mx, i.second);
  for (auto i : m) {
    if (i.second == mx) cout << i.first << endl;
  }
}

Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.IO;

namespace Heaps
{
    class Priority_Queue
    {
        class PriorityQueue
        {
            List<int> buffer;

            public PriorityQueue() { buffer = new List<int>(); }

            static void PushHeap(List<int> array, int elem)
            {
                var n = array.Count;
                array.Add(elem);

                while (n != 0)
                {
                    var i = (n - 1) / 2;
                    if (array[n] > array[i])
                    {
                        var tmp = array[n];
                        array[n] = array[i];
                        array[i] = tmp;
                    }
                    n = i;
                }
            }

            static void PopHeap(List<int> array)
            {
                var n = array.Count - 1;
                array[0] = array[n];
                array.RemoveAt(array.Count - 1);

                for (int i = 0, j; (j = 2 * i + 1) < n;)
                {
                    if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) < 0))
                        j++;
                    if (array[i] < array[j])
                    {
                        var tmp = array[j];
                        array[j] = array[i];
                        array[i] = tmp;
                    }
                    i = j;
                }
            }

            public void Push(int elem)
            {
                PushHeap(buffer, elem);
            }

            public int Pop()
            {
                var top = buffer[0];
                PopHeap(buffer);
                return top;
            }

        }

        static void Main(string[] args)
        {
            var pq = new PriorityQueue();

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string line;
            while ((line = Console.ReadLine()) != "end")
                switch (line[0])
                {
                    case 'i':
                        pq.Push(int.Parse(line.Substring(7)));
                        break;
                    case 'e':
                        Console.WriteLine(pq.Pop());
                        break;
                }
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 20088
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = a
cnt = 0
for i in range(n):
    for j in range(n):
        if i < j:
            if a[i] > a[j]:
                cnt += 1

tmp = 0
for i in a:
    for j in b:
        if i > j:
            tmp += 1

ans = cnt*k + ((k-1)*k*tmp)//2
print(ans%(10**9+7))

Measured memory_bytes: 3188
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int a, b, c, x;
    cin >> a >> b >> c >> x;

    Int ans = 0;
    for (Int A = 0; A <= a; A++) {
        for (Int B = 0; B <= b; B++) {
            for (Int C = 0; C <= c; C++) {
                if (A * 500 + B * 100 + C * 50 == x) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
alst = list(map(int, input().split()))
num = n - 1
ans_lst = [abs(i) for i in range(-num, num + 1, 2)]
alst.sort()
ans_lst.sort()
if alst != ans_lst:
    print(0)
else:
    MOD = 10 ** 9 + 7
    ans = pow(2, n // 2, MOD)
    print(ans)

Measured memory_bytes: 91072
#include <bits/stdc++.h>
using namespace std;
map<char,int> mp;
string a;
int ans;
int main()
{
	cin>>a;
	mp['-']=-1,mp['+']=1;
	for(int i=0;i<4;i++)
	{
		ans+=mp[a[i]];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
int main(){
  int i, j, n, x;
  long long sum=0;
  cin >> n >> x;
  int a[n];
  for(i=0; i<n; i++)
    cin >> a[i];
  if(a[0]>x){
    sum+=(a[0]-x);
    a[0]=x;
  }
  for(i=0; i<n-1; i++)
    if(a[i]+a[i+1]>x){
      sum+=(a[i]+a[i+1]-x);
      a[i+1]=x-a[i];
    }
  cout << sum;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i,l,r) for(int i=l;i<=r;i++)
signed main()
{  // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;

    int k=a+b;

    if(k%2!=0)
    {
    	cout<<"IMPOSSIBLE"<<endl;
    }
    else
    {
    	cout<<k/2<<endl;
    }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;


int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans=n;
    int cnt = 0;
    rep(i,n){
        if(s[i]=='E') cnt++;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='E') cnt--;
        ans = min(ans,cnt);
        if(s[i]=='W') cnt++;
     }
     cout << ans << endl;
}

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


int main() {
  int N, D;
  cin >> N >> D;
  ll X[N][D];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      ll d = 0;
      for (int k = 0; k < D; k++) {
        d += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      ll t = sqrt(d);
      if (t * t == d) {
        cnt++;
      }
    }
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
int n,m; 
int main(){
	cin>>n>>m;
	if(m>=n) printf("%d\n",n);
	else printf("%d",n-1);

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	string s;
	cin >> s;
	s[5] = s[13] = ' ';
	cout << s << endl;
	return 0;
}


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

bool prime(int x)
{
	if(x <= 1){
		return false;
	}
	if(x == 2){
		return true;
	}
	
	int i = 2;
	while(i * i <= x){
		if(x % i == 0){
			return false;
		}
		i++;
	}
	return true;
}

int main(void)
{
	int n;
	scanf("%d", &n);
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x;
		scanf("%d", &x);
		if(prime(x)){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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 (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

using namespace std;
using ll = long long;

const ll kInf = 1e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
   int a, b;
   cin >> a >> b;
   ll c = a + b;
   if (c%2) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
   } else {
      cout << c / 2 << endl;
   }
   return 0;
}


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

using namespace std;

struct node {
  int key;
  node *lp,*rp;

  node(){}
  node(int z):key(z),lp(NULL),rp(NULL){}

} *root;

void insert(node* z){
  node *x=root,*y=NULL;

  while(x){
    y = x;
    x = (z->key < x->key) ? x->lp : x->rp;
  }

  if(!y)root = z;
  else (z->key < y->key ? y->lp : y->rp) = z;
}

bool find(node *t, int v){
  if(!t)return false;
  if(t->key == v)return true;
  return find((v < t->key)?t->lp:t->rp,v);
}

vector<int> preorder, inorder;

int dfs(node *t = root){
  preorder.push_back(t->key);
  if(t->lp)dfs(t->lp);
  inorder.push_back(t->key);
  if(t->rp)dfs(t->rp);
}

int main(void) {

  root = NULL;

  int n,v;
  string s;
  cin >> n;

  for(int i=0,m=0;i<n;i++){
    cin >> s;
    if(s=="insert"){
      cin >> v;
      insert(new node(v));
      m++;
    } else if(s=="find"){
      cin >> v;
      cout << (find(root,v)?"yes":"no") << endl;
    } else {
      dfs();
      for(int j=0;j<m;j++)cout << " " << inorder[j];
      cout << endl;
      for(int j=0;j<m;j++)cout << " " << preorder[j];
      cout << endl;

      preorder.clear();
      inorder.clear();
    }
  }

  return 0;
}

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

#define int long long

using namespace std;

const int mod = 1e9 + 7;

int32_t main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int d;
    cin >> d;
    int n = s.size();
    vector<vector<int>> dp(n + 1, vector<int>(d, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            for (int k = 0; k < 10; ++k) {
                dp[i + 1][(j + k) % d] += dp[i][j];
                dp[i + 1][(j + k) % d] %= mod;
            }
        }
    }
    int ans = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < s[i] - '0'; j++) {
            ans += dp[n - i - 1][(2 * d - sum - j % d) % d];
            ans %= mod;
        }
        sum += s[i] - '0';
        sum %= d;
    }
    if (sum == 0) {
        ans++;
        ans %= mod;
    }
    ans += mod - 1;
    ans %= mod;
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


// 最大流を求める(Dinic法)
typedef vector<int> vi;
class Flow{
	public:
		int N;	// 頂点数
		vector<vi> F, C, edge;	// F:残余グラフ C:初期容量 edge:隣接する頂点

		vi itr, lv;	// itr:調べ終わったかどうか  lv:Sからの距離

		// コンストラクタ n:頂点数
		Flow(int n): N(n), F(n,vi(n)), C(n,vi(n)), edge(n) {}

		// f->tにコストcの辺を追加する(同じf->tに対して何度も追加することも可能)
		void addEdge(int f, int t, int c){
			F[f][t] = C[f][t] = c;
			edge[f].push_back(t);
			edge[t].push_back(f);
		}

		// sからの最短距離を求める。これを実行するとDFSでは最短経路の中から探索する
		int bfs(int S, int T){
			lv.assign(N, 0);
			queue<int> q;
			q.push(S);
			lv[S] = 1;
			while( !q.empty() ){
				int n = q.front(); q.pop();
				for(auto v: edge[n]) if( !lv[v] && F[n][v] ){
					lv[v] = lv[n] + 1;
					q.push(v);
				}
			}
			return lv[T];
		}

		// 増加パスをDFSで探す
		int dfs(int n, int c, int T){
			if( n == T ) return c;
			for(;itr[n] < edge[n].size(); ++itr[n]){
				int v = edge[n][itr[n]];
				if( F[n][v] && lv[v] > lv[n] ){
					int f = dfs(v, min(c, F[n][v]), T);
					F[n][v] -= f;
					F[v][n] += f;
					if(f) return f;
				}
			}
			return 0;
		}

		// 流す。最大流を求める(現在の状態からいくら流れたかが返ってくる)
		int maxFlow(int S, int T){
			if( S == T ) return INF;
			int f, ret = 0;
			while( bfs(S,T) ){
				itr.assign(N,0);
				while( f = dfs(S, INF, T) ) ret += f;
			}
			return ret;
		}

		// 辺に流れている流量を取得する
		int flow(int f, int t){ return C[f][t] - F[f][t]; }

		// 隣接する辺の流量の合計を取得する。n=S,T以外の場合は、出た値を1/2倍したものがその点の流量
		int flow(int n){
			int ret=0;
			for(int v: edge[n]) ret += abs( flow(n,v) );
			return ret;
		}

		// グラフを初期値に戻す
		void reset(){ rep(i,N) rep(j,N) F[i][j] = C[i][j]; }
};

int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;
	int a[105], b[105];
	Flow fl(209);

	cin >> N;
	rep(i,N) cin >> a[i] >> b[i];
	rep(i,N){
		int c, d;
		cin >> c >> d;
		rep(j,N) if( a[j] < c && b[j] < d ){
			fl.addEdge( j, 100+i, 1 );
		}
	}

	int S = 205;
	int T = 206;
	rep(i,N) fl.addEdge(S, i, 1);
	rep(i,N) fl.addEdge(100+i, T, 1);

	ans = fl.maxFlow(S, T);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
    double W, H, x, y;

    scanf("%lf %lf %lf %lf", &W, &H, &x, &y);

    printf("%lf ", W*H/2.0);

    if(x == W/2 && y == H/2)
        printf("1\n");
    else
        printf("0\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

struct Point2D {
  double x,y;

  Point2D operator-(Point2D &p);
  friend istream &operator>>(istream &is, Point2D &t);
  friend double cross(Point2D &a, Point2D &b);
};

Point2D Point2D::operator-(Point2D &p) {
  Point2D t;
  t.x = x - p.x;
  t.y = y - p.y;
  return t;
}

istream &operator>>(istream &is, Point2D &t) {
  is >> t.x >> t.y;
  return is;
}

double cross(Point2D &a, Point2D &b) {
  return a.x * b.y - a.y * b.x;
}

int judge(double t) {
  if(t>0.0) return 1;
  else if(t<0.0) return -1;
  else return 0;
}

int main() {
  vector<Point2D> t(3);
  Point2D p;
  
  while(cin >> t[0] >> t[1] >> t[2] >> p) {
    int key = 0;
        
    for(int i = 0; i < 3; i++) {
      Point2D m = t[i] - t[( i + 1 ) % 3];
      Point2D n = t[i] - p;
      key += judge(cross(m, n));
    }
    cout << ((abs(key) == 3) ? "YES" : "NO") << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1224
N, M = map(int, input().split())
ablist = [tuple(map(int, input().split())) for _ in range(M)]
city_list = [0] * N

for a, b in ablist:
    city_list[a - 1] += 1
    city_list[b - 1] += 1

for city in city_list:
    print(city)


Measured memory_bytes: 2940
N,K = list(map(int,input().strip().split()))
P = list(map(int,input().strip().split()))
def find(P,K):
    temp = 0
    MAX = 0
    for i in range(K):
        temp += (P[i]+1)/2
    MAX = max(MAX,temp)
    for i in range(K,len(P)):
        temp -= (P[i-K]+1)/2
        temp += (P[i]+1)/2
        MAX = max(MAX,temp)
    return MAX
print(find(P,K))

Measured memory_bytes: 25060
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define FF first.first
#define FS first.second
#define S second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e16;
 
ll n, q=1, m, e[4], a[N], b[N], c[N], o[4], k, t, x, y, z, u[4], h, mx, mn, ans, Ans;
pair<ll,ll> p[N];
string s[N];
vector<int> v[N];
 
main(){ios_base::sync_with_stdio(false), cin.tie(0);
   	
	cin>>n>>e[1]>>e[2]>>e[3];
	
	for (int i=1; i<=n; i++)
		cin>>s[i];
		
	for (int i=1; i<=n; i++){
		
		x=s[i][0]-'A'+1;
		y=s[i][1]-'A'+1;
		
		if(e[x]>e[y])swap(x, y);
		
		if(e[x]==e[y] && e[x]==1 && i<n && ((s[i+1][0]-'A'+1)==6-x-y || (s[i+1][1]-'A'+1)==6-x-y)){
			if((s[i+1][0]-'A'+1)==6-x-y){
				k=(s[i+1][1]-'A'+1);
				e[k]++;
				e[(x^y^k)]--;
				a[i]=k;
			}
			if((s[i+1][1]-'A'+1)==6-x-y){
				k=(s[i+1][0]-'A'+1);
				e[k]++;
				e[(x^y^k)]--;
				a[i]=k;
			}
		}
		if(!a[i]){
			e[x]++;
			e[y]--;
			
			a[i]=x;
		}
		if(e[y]<0){
			cout<<"No"; return 0;
		}
	}
	
	cout<<"Yes"<<endl;
	for (int i=1; i<=n; i++){
		cout<<char('A'+a[i]-1)<<endl;
	}
}

Measured memory_bytes: 59080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <list>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  string str;
  cin >> str;
  int len = str.length();
  cout << str[0] << len-2 << str[len-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,i,j,k,sum=0;int c=0;
	vector<int> p;
	cin>>n;
	for(i=2;i<=(int)(sqrt(n));i++)
	{
		c=0;
		while(n%i==0)
		{
			c++;
			n/=i;
		}
		if(c!=0)
			p.push_back(c);
	}
	if(n>1)
		sum=1;
	for(i=0;i<p.size();i++)
	{
		for(j=1;;j++)
		{
			k=j*(j+1)/2;
			if(k>p[i])
				break;
		}
		sum+=j-1;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 3756
n, m = map(int, input().split())
a = list(map(int, input().split()))
t = []
for i in range(n):
  t.append((a[i], 1))

for i in range(m):
  b, c = map(int, input().split())
  t.append((c, b))

t.sort(reverse=True)
ans = 0
for c, b in t:
  for k in range(b):
    if n == 0:
      break
    ans += c
    n -= 1

print(ans)


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

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

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  map<string, priority_queue<int>> S;
  map<int, int> P;
  string s;
  int p;
  REP(i, N) {
    cin >> s >> p;
    if (S.find(s) == S.end()) {
      priority_queue<int> _p;
      _p.push(p);
      S.insert(make_pair(s, _p));
    } else {
      S.at(s).push(p);
    }
    P.insert(make_pair(p, i));
  }

  for (auto it : S) {
    while (!it.second.empty()) {
      cout << P.at(it.second.top()) + 1 << endl;
      it.second.pop();
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    double x[n];
    string u[n];
    rep(i,n)cin >> x[i] >> u[i];
    double sum = 0;
    rep(i,n){
        if(u[i]=="JPY")sum+=x[i];
        if(u[i]=="BTC")sum+=x[i]*380000;
    }
    
    cout << sum;
    
	return 0;
}

Measured memory_bytes: 3684
t[24][3]={
{1,2,3},{1,3,5},{1,5,4},{1,4,2},
{2,1,4},{2,4,6},{2,6,3},{2,3,1},
{3,1,2},{3,2,6},{3,6,5},{3,5,1},
{4,1,5},{4,5,6},{4,6,2},{4,2,1},
{5,1,3},{5,3,6},{5,6,4},{5,4,1},
{6,2,4},{6,4,5},{6,5,3},{6,3,2}
},i,f,x[7],y[7];
main(){
for(i=1;i<7;scanf("%d",x+i++));
for(i=1;i<7;scanf("%d",y+i++));
for(i=0;i<24;i++)
    if(x[1]==y[t[i][0]]&&
       x[2]==y[t[i][1]]&&
       x[3]==y[t[i][2]]&&
       x[4]==y[7-t[i][2]]&&
       x[5]==y[7-t[i][1]]&&
       x[6]==y[7-t[i][0]])
       f=1;
    printf("%s\n",f==1?"Yes":"No");
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
#define int long long
#define dl long double
#define ff first
#define ss second
#define pb push_back
#define inf 1000000007
#define MAXN 2019
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int,int> pii;
const int M = 1e9+7;

int dp[MAXN][MAXN];

int mod(int a,int m){
	int r = a%m;
	if(r<0)r+=m;
	return r;
}

int32_t main(){
	fastio;
	int n,m;
	cin>>n>>m;
	vector<int> s(n+2),t(m+2);
	for(int i=1;i<=n;i++)cin>>s[i];
	for(int i=1;i<=m;i++)cin>>t[i];
	
	for(int i=0;i<MAXN;i++){
		dp[0][i]=0;
		dp[i][0]=0;
	}
	

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dp[i][j] = mod(dp[i][j-1]+dp[i-1][j],M);
			dp[i][j] = mod(dp[i][j]-dp[i-1][j-1],M);
			if(s[i]==t[j]){
				dp[i][j]=mod(dp[i][j]+1+dp[i-1][j-1],M);
			}
			
		}
	}   	

	cout<<dp[n][m]+1<<endl;
}

Measured memory_bytes: 31872