akhauriyash/Code-Regression huggingface dataset:
// 1_1_D
#include <stdio.h>
#include <limits.h>

long max(long, long);
long min(long, long);

int main(){
    long i, n, price, minv = LONG_MAX, maxv = LONG_MIN;
    scanf("%ld", &n);

    for(i = 0; i < n; i++){
        scanf("%ld", &price);
        maxv = max(maxv, price - minv);
        minv = min(minv, price);
    }

    printf("%ld\n", maxv);
    return 0;
}

long max(long a, long b){
    return a > b ? a : b;
}

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

Measured memory_bytes: 596
import math
n = int(input())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

D = [x for i in range(4)]

for i in range(len(D)):
    if i == len(D) -1:
        D[i] = 0
        for j in range(n):
            di = math.fabs(x[j]-y[j])
            if D[i] < di:
                D[i] = di

    else:
        p = 1
        p += i
        di = 0
        d = 0
        for k in range(n):
            d += math.fabs(x[k]-y[k])**p
        di = d**(1/p)
        D[i] = di

for i in range(len(D)):
    print(D[i])

Measured memory_bytes: 7832
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
signed main() {
  int N;
  cin >> N;
  set <string>A;
  for(int i = 0;i < N;i++){
    string g;
    cin >> g;
    A.insert(g);
  }
  
 
  cout << A.size() << endl;
}

Measured memory_bytes: 19188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	string s;
	int sum = 0;

	cin >> s;

	for (int i = 0; i < s.size(); ++i)
	{
		if(s[i]=='1'){
			sum++;
		}
	}

	cout << sum << endl;

	return 0;
}


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

int main() {
    string s;  cin >> s;
    sort(s.begin(), s.end());
    if (s == "abc")  cout << "Yes" << endl;
    else  cout << "No" << endl;
}

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

int main() {
    ll a,b;
    std::cin >> a>>b;
    if(a >= 10 || b>= 10){
        std::cout << -1 << std::endl;
    }else{
        std::cout << a*b << std::endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n,k,a,b,a1,ans;
	cin>>n>>k;
	if(n>k){
		a=n%k;
		b=n/k;
		a1=(b+1)*k-n;
		ans=min(a,a1);
	}
	else
	{
		a=k-n;
		ans=min(a,n);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int abc[] = new int[3];
        for(int i=0;i<3;i++){
            abc[i]=sc.nextInt();
        }

        int bai = sc.nextInt();
        int last=1;
        for(int i=1;i<=bai;i++) {
            last = last * 2;
        }
        int max=0;

        for(int i=0;i<3;i++){
            max=Math.max(max,abc[i]);
        }
        int lastmax=max*last;
        int ans=abc[0]+abc[1]+abc[2]-max+lastmax;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import java.io.*;
import java.util.Arrays;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Deque<Integer> stack = new ArrayDeque<Integer>();
		String[] str = (br.readLine()).split(" ");
		int count = 0;
		for (int i = 0 ; i<n ; i++ ) {
			stack.addLast(Integer.parseInt(str[i]));
		}
		int q = Integer.parseInt(br.readLine());
		String[] st = (br.readLine()).split(" ");
		int[] num = new int[q];
		for (int i = 0; i<q ; i++ ) {
			num[i] = Integer.parseInt(st[i]);
		}

		Arrays.sort(num);

		int a;
		try{

			for (int i = 0; i<q ; i++ ) {
				while((a = stack.pollFirst()) < num[i]);
				if (num[i] == a) {
					count++;	
				}else{

					stack.addFirst(a);
					continue;
				}
			}
		}catch (NullPointerException e){

		}

		System.out.println(count);
	}

}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

constexpr int MAX_N = 7;
constexpr int MAX_M = 60;
constexpr int MAX_L = 7;

int N, M, L;

map<char, int> c;
int kind[MAX_L];
int num[MAX_L];
int hand[MAX_L];

long long memo[MAX_N * MAX_M + 1][MAX_L + 1];
long long combination(int n, int k) {
	if(k == 0 || n == k) return 1;
	auto &res = memo[n][k];
	if(res) return res;
	return res = combination(n - 1, k - 1) + combination(n - 1, k);
}

bool match() {
	vector<int> value(c.size());
	vector<int> card(hand, hand + L);

	do {
		fill(begin(value), end(value), -1);
		for(int i = 0; i < L; ++i) {
			if(kind[i] == -1) continue;

			if(value[kind[i]] == -1) {
				if(card[i] <= num[i]) goto fail;
				value[kind[i]] = card[i] - num[i];
			}
			else {
				if(value[kind[i]] != card[i] - num[i]) goto fail;
			}
		}
		return true;

	fail:;
	} while(next_permutation(begin(card), end(card)));

	return false;
}

long long calc() {
	if(!match()) return 0;

	long long res = 1;
	map<int, int> cnt;
	for(int i = 0; i < L; ++i) {
		++cnt[hand[i]];
	}

	for(const auto &e : cnt) {
		res *= combination(N, e.second);
	}

	int select = 1;
	for(int i = 1; i < L; ++i) {
		if(hand[i - 1] + 1 <  hand[i]) ++select;
	}

	res *= combination(M - (hand[L - 1] - select), select);
	return res;
}

long long dfs(int idx, int len) {
	if(idx == L) return calc();

	long long res = 0;
	for(int i = 0; i < 3; ++i) {
		if(i == 0 && len == N) continue;
		if(hand[0] + M <= hand[idx - 1] + i) break;
		hand[idx] = hand[idx - 1] + i;
		res += dfs(idx + 1, (i ? 1 : len + 1));
	}
	return res;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	//cout.precision(10);
	cout.precision(9);

	while(cin >> N >> M >> L && N) {
		c.clear();

		for(int i = 0; i < L; ++i) {
			string pattern;
			cin >> pattern;

			if(pattern == "*") {
				kind[i] = -1;
			}
			else {
				if(!c.count(pattern[0])) c.insert({pattern[0], c.size()});
				kind[i] = c[pattern[0]];
				num[i] = pattern.size() - 1;
			}
		}

		dump(c);
		hand[0] = 1;
		const auto ans = (long double)dfs(1, 1) / combination(N * M, L);
		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

long long a,b,c,d,e,f,kpk,tmp1,tmp2,kali1,kali2,x,y;
double ans1,ans2;


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	while(cin>>a>>b>>c>>d>>e>>f){
		tmp1=b; tmp2=c;
		if(a==0 || d==0){
			kpk=1;
		}else
			kpk=a*d/__gcd(a,d);
		if(a==0){
			kali1=1;
		}else
			kali1=kpk/a;
		if(d==0){
			kali2=1;
		}else
			kali2=kpk/d;
		b*=kali1;
		c*=kali1;
		e*=kali2;
		f*=kali2;
		x=b-e;
		y=c-f;
		if(x==0){
			ans2==0;
		}else
			ans2=y*1.0/x;
		if(a==0){
			ans1==0;
		}else
			ans1=(tmp2-(tmp1*ans2))*1.0/a;
		cout<<fixed<<showpoint<<setprecision(3);
		cout<<ans1<<' '<<ans2<<'\n';
	}
	
	
return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define int ll
#define pb push_back
#define lb lower_bound

void pre() {
}

void solve() {
//    int n;
//    cin >> n;
//    vi a(n);
//    for (auto &i:a)cin >> i;
    string s;
    cin>>s;
    if(s.length()%2){
        cout<<"No";
        return;
    }
    for (int i = 0; i < s.length()-1; i+=2) {
        if(s[i]!='h' || s[i+1]!='i'){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}

signed main() {
    pre();
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	map<int,int>my;
	for(int i=0;i<n;++i)
	{
		int x;
		cin>>x;
		my[x]++;
	}
	int m;
	cin>>m;
	bool ans=true;
	for(int i=0;i<m;++i)
	{
		int y;
		cin>>y;
		if(my[y]==0)
		{
			ans=false;
		}
		else
		{
			my[y]--;
		}
	}
	if(ans)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
}

Measured memory_bytes: 9600
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

bool is_triangle(int blocks[100000],int W){

  bool is_first = true;
  for(int x=0;x<W;x++){
    if(blocks[x] == 0) continue;
    if(blocks[x] != 0){
      if(is_first){
	if(blocks[x] != 1) return false;
	is_first = false;
      }

      int target = -1;
      for(int dx=x+1;dx<W;dx++){
	if(blocks[dx] != 0){
	  target = dx;
	  break;
	}
      }

      if(target == -1) continue;
      if(blocks[x] + 1 != blocks[target]) return false;
    }
  }

  return true;
}

int main(){
  int W;
  while(~scanf("%d",&W)){
    if(W == 0) break;
    int blocks[100000];
    memset(blocks,0,sizeof(blocks));
    for(int x=0;x<W;x++){
      int block;
      scanf("%d",&block);
      blocks[x] = block;
    }

    int res = -1;
    bool isok = true;
    int nextW = W;
    for(int round = 0; round <= 10000;round++){
      if(is_triangle(blocks,nextW)){
	res = round;
	break;
      }

      int width = 0;
      for(int x=0;x<nextW;x++){
	if(blocks[x] > 0){
	  blocks[x]--;
	  width++;
	}
      }

      blocks[nextW++] = width;
    }

    printf("%d\n",res);
  }
}

Measured memory_bytes: 1588
fun main(args: Array<String>) {
    // Your code here!
    val (a,b,c) = readLine()!!.split(" ").map{it.toLong()}
    var msg = "No"
    val d = c-a-b
    
    
    if(d > 0 && 4*a*b < d*d){
        msg = "Yes"
    }
    println(msg)
}

Measured memory_bytes: 37868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n , m;
  cin >> n >> m;
  vector<int> hai_b(m,0);
  for(int i=0;i<n;i++){
    int k;
    cin >>k;
    vector<int> hai_a(k);
    for(int j=0;j<k;j++){
      cin >> hai_a.at(j);
      hai_b.at(hai_a.at(j)-1)++;
    }
  }
  int cnt=0;
  for(int i=0;i<m;i++){
    if(hai_b.at(i)==n){
      cnt++;
    }
  }
  cout << cnt <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
using namespace std;
int main() {
	int x, a;
	cin >> x >> a;
	if (x < a)cout << 0 << endl;
	else cout << 10 << endl;
}

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

int main(){
    int N;
    cin >> N;
    int a[1000];
    int count=0;
    for(int i=1; i<=N; i++){
        cin >>a[i];
        if(a[i]==a[i-1]){
            a[i]=-6;
            count++;
        }
    }

cout << count << endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000;

using ll = long long;

int N, K;
ll a[MAX_N];
ll S[MAX_N+1], zS[MAX_N+1];

int main()
{
  scanf( "%d%d", &N, &K );
  rep( i, N )
    scanf( "%lld", a+i );
  S[0] = 0;
  zS[0] = 0;
  rep( i, N )
  {
    S[i+1] = S[i]+a[i];

    zS[i+1] = zS[i]+std::max( 0ll, a[i] );
  }

  ll ans = 0;
  rep( i, N-K+1 )
    ans = std::max( ans, std::max( 0ll, S[i+K]-S[i] )+zS[i]-zS[0]+zS[N]-zS[i+K] );

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

  return 0;
}

Measured memory_bytes: 2560
X, Y, A, B, C = map(int, input().split())
p = [int(n) for n in input().split()]
q = [int(n) for n in input().split()]
r = [int(n) for n in input().split()]
p.sort(reverse=True)
q.sort(reverse=True)
px = p[0: X]
qx = q[0: Y]
t = px + qx + r
t.sort(reverse=True)
print(sum(t[0: X + Y]))

Measured memory_bytes: 23200
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, inp;
  set<int> s;
  cin >> n;
  rep(i, n){
    cin >> inp;
    s.insert(inp);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;

int n,m;
vector<int> adj[100001];

int dfn[100001],dn=0;

vector<pii> ans;
int dfs(int cur,int p) {
    dfn[cur] = ++dn;
    
    vector<int> va;
    for(auto &it:adj[cur]) if(it!=p) {
        if(dfn[it]) {
            if(dfn[it] > dfn[cur]) va.push_back(it);
        } else {
            int v=dfs(it,cur);
            if(v) va.push_back(it);
        }
    }

    for(int i=0;i+1<(int)va.size();i+=2) {
        ans.push_back({cur,va[i]});
        ans.push_back({cur,va[i+1]});
    }
    if(p) {
        if(va.size()%2) {
            ans.push_back({cur,va.back()});
            ans.push_back({cur,p});
            return 0;
        } else return 1;
    } else {
        return va.size()%2;
    }
}

int main() {
    scanf("%d%d",&n,&m);
    for(int i=0,u,v;i<m;i++) {
        scanf("%d%d",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    for(int i=1;i<=n;i++) if(!dfn[i]) {
        if(dfs(i,0)) {
            puts("-1");
            return 0;
        }
    }
    for(auto &v:ans) printf("%d %d\n",v.first, v.second);
    return 0;
}


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

char table[] = "abcdefghijklmnopqrstuvwxyz.?! ";

int main(void)
{
    char in[201];
    char out[201];
    int in_p;
    int out_p;
    
    while (scanf("%s", in) != EOF){
        in_p = out_p = 0;
        while (in[in_p] != '\0'){
            if (in[in_p] < '1' || '6' < in[in_p] || 
                in[in_p + 1] < '1' || '5' < in[in_p + 1]){
                
                strcpy(out, "NA");
                out_p = 2;
                break;
            }
            
            out[out_p] = table[(in[in_p] - '1') * 5 + in[in_p + 1] - '1'];
            in_p += 2;
            out_p++;
        }
        out[out_p] = '\0';
        
        printf("%s\n", out);
    }
    return (0);
}

Measured memory_bytes: 0
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            int n = Integer.parseInt(br.readLine());
            int[] A = new int[(n+1)/2];
            Arrays.fill(A,0);
            String st = br.readLine();
            String[] s = st.split(" ",0);
            BigInteger answer=BigInteger.ONE;
            int error = 0;
            for(int i = 0; i<n;i++){
                int a = Integer.parseInt(s[i]);
                if((n%2==1&&a%2==1)||(n%2==0&&a%2==0)){
                    error++;
                    break;
                }
                A[a/2]++;
                if(A[a/2]>2 || (A[0]>1&&n%2==1)){
                    error++;
                    break;
                }
            }
            BigInteger k =BigInteger.ZERO;
            if(error==0){
                for(int i = 0;i<n/2;i++){
                answer = answer.multiply(new BigInteger(String.valueOf(2)));
                }
                k = answer.remainder(new BigInteger("1000000007"));
            }
            System.out.println(k);
        }catch(Exception ex){
            System.exit(0);
        }
    }
}

Measured memory_bytes: 62804
#include <stdio.h>

const long long mod = 1000000007;

long long inv[100100], fact[100100], ifact[100100];

int main()
{
	inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
	for (int i = 2; i < 100100; i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i - 1] * i % mod;
		ifact[i] = ifact[i - 1] * inv[i] % mod;
	}

	int a, b, c;
	scanf("%*d %d %d %d", &a, &b, &c);

	long long ans = 0;
	if (b % 2 == 0){
		b /= 2;
		for (int i = 0; i <= a && i <= c; i++){
			for (int j = 0; i + 3 * j <= c; j++){
				int g = a + b + j, l = c - i - 3 * j;
				long long hey = fact[g] * ifact[i] % mod * ifact[a-i] % mod * ifact[b] % mod * ifact[j] % mod;
				long long com = b ? fact[l + b - 1] * ifact[l] % mod * ifact[b - 1] % mod : (l == 0);
				ans = (ans + hey * com) % mod;
			}
		}
	}
	printf("%lld\n", ans);

	return 0;
}


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

int main(){
    int n = 3, f = 0, s = 0;
    while(n--){
        int x;
        cin >> x;
        if(x==5) f++;
        else if(x==7) s++;
    }
    cout << (f==2 && s==1 ? "YES":"NO") << endl;
}


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

int main() {
	string s;
	while(getline(cin, s)){
		for(int i = 0; i < s.size(); ++i){
			if('a' <= s[i] && s[i] <= 'z'){
				s[i] = toupper(s[i]);
			}
		}
		cout << s << endl;
	}
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n, m; scanf("%d%d", &n, &m);
	printf("%d", (n*(n-1)+m*(m-1))>>1);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
h,w,kazu = map(int, input().split())

masu = []

for i in range(h):
    masu.append(list(input()))
    
count = 0

import copy

for i in range(2**h):
    for j in range(2**w):
        
        m = copy.deepcopy(masu)
        blacknum = 0
        
        for k in range(h):
            for l in range(w):
                if i>>k&1 == 0 and j>>l&1 == 0 and m[k][l] == "#":
                    blacknum = blacknum + 1
                
                    
        if blacknum == kazu:
            count = count+1
            # print(i,j)
            
print(count)

Measured memory_bytes: 77372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
typedef pair<ll,pii> ipii;
#define MOD 998244353 
#define mod(a) ((a)%MOD)
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define dbg(x) cout<<#x<<" = "<<x<<"\n"
#define dbg2(x,y) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<"\n"
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<" , "<<#z<<" = "<<z<<"\n"
#define INF (1LL<<60)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define endl '\n'
ll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}
ll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}

int dp[3001][3001];
int main(){
      string s,t;
      cin>>s>>t;

      for(int i=0;i<s.length();i++){
      	for(ll j=0; j<t.length(); j++){
      		  if(i==0){
      		  	 if(j!=0)
      		  	    dp[i][j]=dp[i][j-1];
      		  	 if(s[i]==t[j]) dp[i][j]=1;
      		     continue;
      		  }
      		  if(j==0){
                  dp[i][j]=dp[i-1][j];
                  if(s[i]==t[j]) dp[i][j]=1;
                  continue;
      		  }
      	       if(s[i]==t[j]){
      	       	   dp[i][j]=1+dp[i-1][j-1];
      	       }
      	       else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      	}
    }
    string ans="";  
    ll i=s.length()-1,j=t.length()-1;
    while(1){
    	 if(i<0||j<0) break;
    	 if(i==0){
    	    	if(dp[i][j]==1) ans.pb(s[i]);
    	    	break;
    	 }
    	 if(j==0){
    	 	  if(dp[i][j]==1) ans.pb(t[j]);
    	 	  break;
    	 }
    	 if(s[i]==t[j]){
    	 	ans.pb(s[i]);
    	 	i--;j--;
    	 	continue;
    	 }
    	 else{
             if(dp[i-1][j]>dp[i][j-1]) i--;
             else j--;
    	 }

    }
    reverse(all(ans));
    cout<<ans<<endl;  
} 



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

	int a,b,c,min,max,middle;
	scanf("%d %d %d",&a,&b,&c);


	if(a<b && a<c){
		min=a;
		if(b<c){
			middle=b;
			max=c;
		}else{
			middle=c;
			max=b;
		}
	}else if(b<a && b<c){
		min=b;
		if(a<c){
			middle=a;
			max=c;
		}else{
			middle=c;
			max=a;
		}
	}else{
		min=c;
		if(a<b){
			middle=a;
			max=b;
		}else{
			middle=b;
			max=a;
		}
	}
	printf("%d %d %d\n",min,middle,max);
	return 0;
}

Measured memory_bytes: 1796
from operator import itemgetter
from math import log,ceil

def main():
    N = int(input())
    P = list(map(int,input().split()))
    mini = P[0]
    cnt = 0
    for p in P:
        if p <= mini:
            cnt += 1
        mini = min(p,mini)
    print(cnt)
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 24872
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,cnt,i,j,k,len,kk;
	char s[11],mm[100][21],copy[11],cat[100][21];
	scanf("%s",s);
	scanf("%d",&n);
	cnt=0;
	for(i=0;i<n;i++) {
		scanf("%s",mm[i]);
		strcpy(cat[i],mm[i]);
	}
	for(i=0;i<n;i++) strcat(mm[i],cat[i]);
	len=strlen(s);
	for(i=0;i<n;i++) {
		k=0;
		for(j=0;j<20;j++) {
//			printf("mm=%c s==%c\n",mm[i][j],s[k]);
			if(mm[i][j]==s[k]) {
				copy[k]=s[k];
				k++;
				if(len==k) break;
			}
		}
		copy[k]='\0';
	//	printf("%s\n",copy);
		if(strcmp(s,copy)==0) cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}
		

Measured memory_bytes: 1052
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int sum=0;
    rep(i,s.size()){
        if(s[i]!=t[i])sum++;
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  long long int K;
  cin>>S>>K;
  for(long long int i=0;i<K;i++){
    if ((int)(S[i]-'0')!=1){
      cout<<S[i]<<endl;
      return 0;
    }
  }
  cout<<1<<endl;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  int K; cin >> K;
  int D, E;
  if (K % 2 == 0){
    D = K / 2;
    cout << D*D << endl;
  }
  else {
    D = K / 2;
    E = D + 1;
    cout << D * E << endl;
  }
}

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

int main()
{
    string s,t,ans="";
    cin>>s>>t;
    for(int i=0;i<t.length()-1;i++)
    {
        ans+=t[i];
    }
    if(ans==s)
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 7;
int main(){
    int n, m;
    cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0;
        return 0;
    }
    ll ans = 1;
    ll ans2 = 1;
    for(int i = 1; i <= n; i++){
        ans = (ans%INF * i%INF)%INF;
    }
    for(int i = 1; i <= m; i++){
        ans2 = (ans2%INF * i%INF)%INF;
    }
    if(n==m){
        cout << (((ans%INF * ans2%INF)%INF) * 2)%INF;
    }
    else{
        cout << (ans%INF * ans2%INF)%INF;
    }
}

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

int main() {
  int K;
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;
  cout << vec.at(K-1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  bool a=false,b=false;
  char tmp;
  for(int i=0;i<3;i++){
    cin>>tmp;
    if(tmp=='A')a=true;
    else b=true;
  }
  if(a&&b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

// 計算量 : O(n)
int main() {
  int n;
  cin >> n;

  // (d[1] + d[2] + ... + d[n])**2 = sigma(d[i]**2) + 2 * sigma(d[i] * d[j])
  //
  // 2 * sigma(d[i] * d[j]) = (d[1] + d[2] + ... + d[n])**2 - sigma(d[i]**2)
  // sigma(d[i] * d[j]) = ((d[1] + d[2] + ... + d[n])**2 - sigma(d[i]**2)) * (1/2)
  //
  int a = 0;
  int b = 0;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    a += d;
    b += d*d;
  }

  int ans = ((a*a) - b) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3512
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


int main(){
	for(int n;cin>>n;){
		int sum = 1;
		rep(i,n+1)sum+=i;
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 1136
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << s.substr(0, s.size() - 8);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a,b,c;
  int num=3;
  cin >> a;
  cin >> b;
  if(a==b)
    num--;
  cin >> c;
  if(a==c)
    num--;
  else if(b==c)
    num--;
  cout << num;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
G = [[1, 3, 5, 7, 8, 10, 12],
     [4, 6, 9, 11],
     [2]]
flag = 0
for i in range(3):
    for j in G[i]:
        if x == j:
            for k in G[i]:
                if y == k:
                    print('Yes')
                    flag = 1
if flag == 0:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, m, n, t, r, k, w, l, ans, i, j;
string S, T;
vl A, B;
map<ll, ll> insuu;
void insuubunkai(ll n) {
    ll a = n;
    for(ll i = 2; i * i <= a; i++) {
        if(a % i == 0) {
            while(a % i == 0) {
                insuu[i]++;
                a = a / i;
            }
        }
    }

    if(a != 1)
        insuu[a]++;
}
void solve() {
    insuubunkai(n);
    for(auto ite = insuu.begin(); ite != insuu.end(); ite++) {
        x = (*ite).se;
        ans += (sqrtl(x * 8 + 1) - 1) / 2;
    }

    cout << ans << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    solve();
}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> d(n), c(m);
    for (auto &&i : d) scanf("%d", &i);
    for (auto &&j : c) scanf("%d", &j);
    auto dp = make_v(m+1, n+1, INF<int>);
    dp[0][0] = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j <= n; ++j) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if(j != n) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]+d[j]*c[i]);
        }
    }
    cout << dp[m][n] << "\n";

    return 0;
}



Measured memory_bytes: 6012
#include<bits/stdc++.h>
#define int long long 

using namespace std ;

int n; 
int arr[300001];
int hell = 1e9 + 7;

int mod_multiplacation(vector<int>sample){
        int res = 1 ; 
        for(int& i: sample) i = i%hell;
        for(int i: sample){
                (res *= i)%=hell;
        }
        return res ;
}

int32_t main(){
        ios_base::sync_with_stdio(0); cin.tie(0);

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

        int ans = 0;
        int ze,on;

        for(int bits = 0; bits < 61 ; bits++ ){
                ze = on = 0 ;
                for(int i = 0 ; i < n ; i++ ){
                        if(arr[i]%2 == 0) on++;
                        else ze++;
                        arr[i] /= 2 ;
                }
                (ans += mod_multiplacation({on,ze,(1ll<<bits)}))%=hell;
        }

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

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string w;
    cin >> w;
    vector<ll> count(27, 0);
    for(char c : w){
        count.at(c - 'a')++;
    }
    for(ll v : count){
        if(v % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())

A = list(map(int, input().split()))

dis = True
count = 0
for i in range(0, N-1):
    if A[i] > A[i+1]:
        count += 1
        dis = False
        if count == 1:
            tmp1 = i
        elif count == 2:
            tmp2 = i+1

if dis == False and count > 1:
    tmp = A[tmp1]
    A[tmp1] = A[tmp2]
    A[tmp2] = tmp

    count = 0
    for i in range(0, N-1):
        if A[i] > A[i + 1]:
            count += 1
            dis = False
            if count == 1:
                tmp1 = i
            elif count == 2:
                tmp2 = i + 1
    if count == 0:
        dis = True

if dis == True:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
ll n;
int main()
{
    n=read();
    cout<<n*(n-1)/2<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
ll n,m,cnt;
ll x[1000010],y[100010],c[100010],sub[1010][2010],suw[1010][2010];
char ss;
ll ans;
ll ffw(int a1,int b1,int a2,int b2)
{
	if(a1>a1 || b1>b2)return 0;
	return suw[a2][b2]-suw[a1-1][b2]-suw[a2][b1-1]+suw[a1-1][b1-1];
}
ll ffb(int a1,int b1,int a2,int b2)
{
	if(a1>a1 || b1>b2)return 0;
	return sub[a2][b2]-sub[a1-1][b2]-sub[a2][b1-1]+sub[a1-1][b1-1];
}
int main()
{
	ll i,s,a,b,j,k;
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld %c",&a,&b,&ss);
		k=a/m;
		//cout<<" "<<k<<endl;
		a-=k*m;b-=k*m;
		if(a<0)a+=m,b+=m;
		if(a>=m)a-=m,b+=m;
		b%=2*m;if(b<0)b+=2*m;
		x[i]=a;y[i]=b;c[i]=(ss=='W');
		if(c[i]==1)sub[x[i]+1][y[i]+1]++;
		else suw[x[i]+1][y[i]+1]++;
		//cout<<" "<<a<<" "<<b<<" "<<c[i]<<endl;
	}
	for(i=1;i<=m;i++)
		for(s=1;s<=2*m;s++)
		{
			sub[i][s]+=sub[i-1][s]+sub[i][s-1]-sub[i-1][s-1];
			suw[i][s]+=suw[i-1][s]+suw[i][s-1]-suw[i-1][s-1];
			//cout<<" "<<i<<" "<<s<<" "<<sub[i][s]<<" "<<suw[i][s]<<endl;
		}
	for(i=1;i<=m;i++)
		for(s=m;s<=2*m;s++)
		{
			a=ffw(1,s-m+1,i,s)+ffw(i+1,s+1,m,2*m)+ffw(i+1,1,m,s-m);
			b=ffb(1,1,i,s-m)+ffb(1,s+1,i,2*m)+ffb(i+1,s-m+1,m,s);
			ans=max(ans,a+b);
			
			a=ffb(1,s-m+1,i,s)+ffb(i+1,s+1,m,2*m)+ffb(i+1,1,m,s-m);
			b=ffw(1,1,i,s-m)+ffw(1,s+1,i,2*m)+ffw(i+1,s-m+1,m,s);
			ans=max(ans,a+b);
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 35072
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		double d = nd();
		double t = nd();
		double s = nd();

		if (d / s <= t) {
			out(Y);
		} else {
			out(N);
		}

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int w;
	int d;

	XY(int h, int w, int d) {
		this.h = h;
		this.w = w;
		this.d = d;
	}
}


Measured memory_bytes: 37332
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>

int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

  
    ll t;
    t=1;
    // cin>>t;
    while(t--){
       ll x,k,d;
      cin>>x>>k>>d;
      x=abs(x);
      
      ll p = x/d;

      ll moves = (k>p?k-p:0);
      if(moves==0){cout<<x-k*d;exit(0);}

      moves%=2;
      ll ans1 = min(abs(x-p*d+moves*d),abs(x-p*d-moves*d));
      moves=k-p-1;
      moves%=2;
      ll ans2 = min(abs(x-(p+1)*d+moves*d),abs(x-(p+1)*d-moves*d));

      cout<<min(ans1,ans2);

    }



  






return 0;
}     



Measured memory_bytes: 3648
n,k=map(int,input().split())
l=[0 for i in range(n)]
for i in range(k):
    t=int(input())
    ar=list(map(int,input().split()))
    for j in range(t):
        l[ar[j]-1]+=1
val=0
for i in range(n):
    if(l[i]==0):
        val=val+1
print(val)

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

int main() {
  string s;
  cin >> s;
  bool ans = true;
  
  for (int i = 0;i < s.size();i++){
    if (i%2 == 0){
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
        ans = false;
        break;
      }
    }
    else{
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
        ans = false;
        break;
      }
    }
  }
  
  if (ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 20005
#define inf 998244353
struct edge{
    int t,v,f,nxt;
}e[M];
int head[M],tot=1;
void add(int st,int t,int v,int f) {
    e[++tot].nxt=head[st],e[tot].t=t,e[tot].v=v,e[tot].f=f,head[st]=tot;
    e[++tot].nxt=head[t],e[tot].t=st,e[tot].v=-v,e[tot].f=0,head[t]=tot;
}
int n,s,t;
ll ans;
int d[M],vis[M],pre[M],F,L;
ll dis[M];
bool spfa() {
    int tp=0;
    for(int i=1;i<=t;i++) vis[i]=0,dis[i]=-1e18;
    F=L=0;
    d[++L]=s,dis[s]=0;
    do{
	int p=d[++F];
	vis[p]=0;
	for(int i=head[p];i;i=e[i].nxt)
	    {
		int to=e[i].t;
		if(!e[i].f) continue ;
		if(dis[to]<dis[p]+e[i].v)
		    {
			if(to==t) tp=1;
			dis[to]=dis[p]+e[i].v,pre[to]=i^1;
			if(!vis[to]) d[++L]=to,vis[to]=1;
		    }
	    }
    }while(F<L);
    if(!tp) return 0;
    int p=t,Mf=inf;
    while(p!=s)
	{
	    Mf=min(Mf,e[pre[p]^1].f);
	    p=e[pre[p]].t;
	}
    p=t;
    while(p!=s)
	{
	    e[pre[p]^1].f-=Mf;
	    e[pre[p]].f+=Mf;
	    ans+=1ll*e[pre[p]^1].v*Mf;
	    p=e[pre[p]].t;
	}
    return 1;
}
void work() {
    while(spfa()) ;
    cout<<ans<<'\n';
}
int main()
{
    cin>>n;
    s=n*2+9,t=s+1;
    for(int i=1,x,y,c;i<=n;i++)
	{
	    cin>>x>>y>>c;
	    add(s,i,0,c);
	    add(i,n*2+1,x+y,inf);
	    add(i,n*2+2,x-y,inf);
	    add(i,n*2+3,-x+y,inf);
	    add(i,n*2+4,-x-y,inf);
	}
    for(int i=1,x,y,c;i<=n;i++)
	{
	    cin>>x>>y>>c;
	    add(i+n,t,0,c);
	    add(n*2+5,i+n,x+y,inf);
	    add(n*2+6,i+n,x-y,inf);
	    add(n*2+7,i+n,-x+y,inf);
	    add(n*2+8,i+n,-x-y,inf);
	}
    add(n*2+1,n*2+8,0,inf);
    add(n*2+2,n*2+7,0,inf);
    add(n*2+3,n*2+6,0,inf);
    add(n*2+4,n*2+5,0,inf);
    work();
    return 0;
}

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

vector<int> g[201];
int V;

int bipartite_matching()
{
    int res=0;
    vector<int> match(V, -1);
    for(int v=0; v<V; ++v) if (match[v]<0) {
        vector<bool> used(V);

        function<bool(int)> dfs=[&](int x) {
            used[x]=true;
            for(int u: g[x]) {
                int w=match[u];
                if (w<0 || (!used[w] && dfs(w))) {
                    match[x]=u;
                    match[u]=x;
                    return true;
                }
            }
            return false;
        };

        if (dfs(v)) ++res;
    }
    return res;
}

int main()
{
    int N; cin>>N;
    V=2*N;
    vector<int> a(N), b(N), c(N), d(N);
    for(int i=0; i<N; ++i) cin>>a[i]>>b[i];
    for(int i=0; i<N; ++i) cin>>c[i]>>d[i];

    for(int i=0; i<N; ++i) for(int j=0; j<N; ++j) if (a[i]<c[j] && b[i]<d[j]) {
        g[i+N].push_back(j);
        g[j].push_back(i+N);
    }
    cout<<bipartite_matching()<<endl;
}


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

int main() {
    int64_t n, b, cnt = 0, as = 0, bs = 0;
    cin >> n;
    vector<int64_t> a(n);
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        as += a[i];
    }
    for (auto i = 0; i < n; i++) {
        cin >> b;
        bs += b;
        if (a[i] < b) cnt += ((b - a[i]) + 1) / 2;
    }
    // cout << as << " " << bs << " " << cnt << endl;
    if (bs - as >= cnt) cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3672
from collections import deque
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
UV = [[]for _ in range(n)]
for _ in range(m):
    u, v = list(map(lambda x: int(x)-1, input().split()))
    UV[u].append(v)
s, t = list(map(lambda x: int(x)-1, input().split()))

NV = 3*n
edges = [[]for _ in range(NV)]


def to_v(i, j):
    return 3*i+j


for i in range(n):
    for i2 in UV[i]:
        for j in range(3):
            edges[to_v(i, j)].append(to_v(i2, (j+1) % 3))

init_v = to_v(s, 0)
INF = 10**18
dist = [INF]*NV
dist[init_v] = 0
next_v = deque([init_v])
while next_v:
    v = next_v.popleft()
    for v2 in edges[v]:
        if dist[v2] <= dist[v]+1:
            continue
        dist[v2] = dist[v]+1
        next_v.append(v2)

print(dist[to_v(t, 0)]//3 if dist[to_v(t, 0)] != INF else -1)


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

int main()
 {
   int N,t,i;
   cin>>N;
   if(N%10==3)
{
  cout<<"bon";
}
else if(N%10==0 || N%10==1 || N%10==6 || N%10==8)
  cout<<"pon";
else
cout<<"hon";
return 0;
 }


Measured memory_bytes: 3628
# input
S = input()

alphabet = ['a', 'b', 'c', 'd','e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'None']

for i in range(len(alphabet)):
    if alphabet[i] in S:
        continue
    else:
        print(alphabet[i])
        break



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

vector<int> P;

int root(int a){
    if(a == P[a]) return a;
    else return P[a] = root(P[a]);
}

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

    int n, m;
    cin >> n >> m;
    P.resize(n);
    REP(i, n) P[i] = i;
    
    vector<int> G(n);
    REP(i, n){
        int g;
        cin >> g;
        G[i] = g - 1;
    }

    REP(i, m){
        int x, y;
        cin >> x >> y;
        x--; y--;
        int t1, t2;
        t1 = root(x);
        t2 = root(y);
        if(t1 == t2) continue;
        if(t1 > t2) swap(t1, t2);
        P[t1] = t2;
    }

    int cnt = 0;
    REP(i, n){
        if(root(i) == root(G[i])){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

i = 0
ans = 0
for a in A:
  right, right2 = i, i
  while right+1 < N and A[right] <= A[right+1]: right += 1
  while right2+1 < N and A[right2] >= A[right2+1]: right2 += 1
  i = max(right, right2) + 1
  ans += 1
  if i >= N: break
print(ans)

Measured memory_bytes: 14252
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s; cin >> s;
    s[k - 1] = tolower(s[k - 1]);
    cout << s << '\n';
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t H,W,h,w;
    cin >> H >> W >>h >> w;
    cout << (H-h) * (W -w) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

bool isPalindrome(string S) {
  int L = S.size();
  for (int i = 0; i < L / 2; i++) {
    if (S[i] != S[L - i - 1]) {
      return false;
    }
  }
  return true;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;

  int N = S.size();

  if (!isPalindrome(S)) {
    cout << "No" << endl;
    return 0;
  }
  if (!isPalindrome(S.substr(0, N / 2))) {
    cout << "No" << endl;
    return 0;
  }
  if (!isPalindrome(S.substr(((N + 3) / 2) - 1, N))) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256