akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++) 
#define all(v) v.begin(),v.end()
#define F first
#define S second 
const ll MOD=1e9+7;
template<typename ForwardIterator,typename T>
ForwardIterator first_less_than(ForwardIterator first,ForwardIterator last,T val)
{
	auto it=lower_bound(first,last,val);
	return (it==first?first:it);
}
bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
  
void solve()
{
	ll n;
	cin>>n;
	ll arr[n];
	rep(i,n)
	{
		cin>>arr[i];
	}
	map<ll,ll> m;
	bool temp=false;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j*j<=arr[i];j++)
		{
			if(arr[i]%j==0)
			{
				if(arr[i]!=1 && j==1)
				{
					if(m.find(arr[i])!=m.end())
					{
						temp=true;
						break;
					}
					else
					{
						m[arr[i]]++;
					}
				}
				else if(arr[i]!=1)
				{
					
				ll val=arr[i]/j;
				if(val!=j)
				{
					if(m.find(j)!=m.end() || m.find(val)!=m.end())
					{
						temp=true;
						break;
					}
					else
					{
						m[val]++;
						m[j]++;
					}
				}
				else if(m.find(j)!=m.end())
				{
					temp=true;
					break;
				}
				else
				{
					m[j]++;
				}
			}
			}
		}
	}
	if(temp)
		{
			ll res=arr[0];
			for(int i=1;i<n;i++)
			{
				res=__gcd(res,arr[i]);
				if(res==1)
				{
					break;
				}
			}
			if(res==1)
			{
				cout<<"setwise coprime"<<endl;
			}
			else
			{
				cout<<"not coprime"<<endl;
			}
		}
		else
		{
			cout<<"pairwise coprime"<<endl;
		}
}

int main()
{
//	ios_base::sync_with_stdio(false); 
  //	 cin.tie(NULL);  
	int tt;
	tt=1;
	while(tt--)
	{
		solve();
	}
}


Measured memory_bytes: 73920
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 200005;
const int mod = 1e9+7;

bool vis[maxn],ins[maxn];int n,a[maxn],deg[maxn];int ans=1;
bool onring[maxn];int stk[maxn],top,len[maxn],cnt[maxn];
int fac[maxn],inc[maxn],pw[maxn],ffac[maxn];

int fpm(LL p,int k) {
	LL res=1ll;
	while (k) {
		if (k&1) (res*=p)%=mod;
		(p*=p)%=mod;k>>=1;
	}
	return res;
}
LL comb(int n,int m) {
	return (LL)fac[n]*inc[m]%mod*(LL)inc[n-m]%mod;
}

void dfs(int u)
{
	stk[++top]=u;ins[u]=vis[u]=true;
	if (ins[a[u]]) {
		onring[a[u]]=true;
		for (int j=top;stk[j]!=a[u];j--)
			onring[stk[j]]=true;
	}
	if (!vis[a[u]]) dfs(a[u]);
	top--;ins[u]=false;
}
void dfs2(int u,int dis)
{
	if (onring[u]) len[u]=dis;
	else dfs2(a[u],dis+1);
}
void calc(int u)
{
	vis[u]=true;
	for (int v=a[u];v!=u;v=a[v]) vis[v]=true;
	if (!len[u]) {
		int v=a[u],dis=1;
		while (v!=u&&!len[v]) {v=a[v],++dis;}
		if (v==u) {cnt[dis]++;return ;}
		u=v;
	}
	for (int co=0,i=u,j;!co||i!=u;co++,i=j)
	{
		int dis=1;j=a[i];while (!len[j]) j=a[j],++dis;
		if (dis<len[j]) {puts("0");exit(0);}
		if (dis>len[j]) (ans<<=1)%=mod;
	}
}
int main()
{
	#ifdef Amberframe
		freopen("agc008e.in","r",stdin);
		freopen("agc008e.out","w",stdout);
	#endif
	scanf("%d",&n);fac[0]=inc[0]=ffac[0]=pw[0]=1;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),deg[a[i]]++;

	for (int i=1;i<=n;i++) if (!vis[i]) dfs(i);
	for (int i=1;i<=n;i++) if (onring[i]+1<deg[i]) {puts("0");return 0;}
	for (int i=1;i<=n;i++) if (!deg[i]) dfs2(i,0);
	memset(vis,0,sizeof vis);
	for (int i=1;i<=n;i++) if (onring[i]&&!vis[i]) calc(i);
	
	for (int i=1;i<=n;i++) ffac[i]=(LL)(2*i-1)*ffac[i-1]%mod;
	for (int i=1;i<=n;i++) fac[i]=(LL)fac[i-1]*i%mod;
	inc[n]=fpm(fac[n],mod-2);
	for (int i=n;i>=2;i--) inc[i-1]=(LL)inc[i]*i%mod;
	for (int i=1;i<=n;i++) pw[i]=(LL)pw[i-1]*2ll%mod;
	
	for (int i=1;i<=n;i++)
	if (i&1) {
		int o=cnt[i],res=0,lx=1;
		for (int x=0;x*2<=o;x++,lx=(LL)lx*i%mod)
			res=(res+(LL)comb(o,x*2)*ffac[x]%mod*(LL)lx%mod*(i>1?pw[o-2*x]:1))%mod;
		ans=(LL)ans*res%mod;
	}
	else {
		int o=cnt[i],res=0,lx=1;
		for (int x=0;x*2<=o;x++,lx=(LL)lx*i%mod)
			res=(res+(LL)comb(o,x*2)*ffac[x]%mod*(LL)lx)%mod;
		ans=(LL)ans*res%mod;
	}
	printf("%d",ans<0?ans+mod:ans);
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#define ll long long
using namespace std;

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

  int f = s.length();
  int cntr = 0;
  
  ll ans = 0;
  for (int i = 0; i <= f-1; i++){
    if (s[i] == 'B')
      cntr++;
    else{
      ans = ans + cntr;
    }
  }
  cout << ans << endl;
}

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

const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
ll dp[MAXN][2];
vector<int> adj[MAXN];

void dfs(int s, int p = 0) {
    dp[s][1] = dp[s][0] = 1;
    for(auto v : adj[s]) {
        if(v == p)
            continue;
        dfs(v, s);
        dp[s][0] = (dp[s][0] * (dp[v][0] + dp[v][1])) % MOD;
        dp[s][1] = (dp[s][1] * dp[v][0]) % MOD;
    }
}

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1);
    cout << (dp[1][0] + dp[1][1]) % MOD << endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<vector<int>> x(N), y(N);
  REP(i, N){
    cin >> A[i];
    x[i].resize(A[i]), y[i].resize(A[i]);
    REP(j, A[i]){
      cin >> x[i][j] >> y[i][j];
      x[i][j]--, y[i][j];
    }
  }
  int ans = 0;
  for(int b = 0; b < (1<<N); b++){
    bool flag = true;
    int cnt = 0;
    for(int i = 0; i < N; i++){
      if((b>>i) & 1){
        cnt++;
        REP(j, A[i]){
          if(((b>>x[i][j]) & 1) != y[i][j]){
            flag = false;
            break;
          }
        }
      }
    }
    if(flag){
      ans = max(ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

import math
import re
import numpy as np
import copy


S = input().split(" ")
X = int(S[0])
N = int(S[1])

#初期値
ans = 0

#空行の場合
if N == 0:
    ans = X

else:
    pn = [int(i) for i in input().split(" ")]

    #距離の最小値の初期値
    min_dist = 1000

    #大きい数字から全探索（超える場合のみ更新）
    for i in range(102):
        if not i in pn:
            dist = abs(X - i)
            if dist < min_dist:
                ans = i
                min_dist = dist

print(ans)



Measured memory_bytes: 27132
#include <iostream>
#include <vector>
#include <set>

int main() {
  unsigned N;
  std::cin >> N;
  std::vector<std::pair<long long, long long>> lr(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> lr[i].first >> lr[i].second;
  }
  std::multiset<long long> left;
  std::multiset<long long> right;
  long long left_add = 0;
  long long right_add = 0;
  long long min = 0;
  left.insert(lr[0].first);
  right.insert(lr[0].first);
  for (unsigned i = 1; i < N; ++i) {
    right_add += lr[i - 1].second - lr[i - 1].first;
    left_add -= lr[i].second - lr[i].first;
    if (*left.rbegin() + left_add > lr[i].first) {
      min += *left.rbegin() + left_add - lr[i].first;
      right.insert(*left.rbegin() + left_add - right_add);
      auto x = left.end();
      --x;
      left.erase(x);
      left.insert(lr[i].first - left_add);
      left.insert(lr[i].first - left_add);
    } else if (*right.begin() + right_add < lr[i].first) {
      min += lr[i].first - (*right.begin() + right_add);
      left.insert(*right.begin() + right_add - left_add);
      right.erase(right.begin());
      right.insert(lr[i].first - right_add);
      right.insert(lr[i].first - right_add);
    } else {
      left.insert(lr[i].first - left_add);
      right.insert(lr[i].first - right_add);
    }
  }
  std::cout << min;
  return 0;
}

Measured memory_bytes: 11136
/***
*  author  :_shamim
*  created : 06.05.2020
*
***/

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--)          
#define MAX            1000000

using namespace std;

ll i,j,temp;
bitset<MAX> prime;

void seive(){
	//0 prime
	//1 not prime

	prime[0] = prime[1] = 1;
	prime[2] = 0;
	for(i=4;i<MAX;i+=2){
		prime[i] = 1;
	}
	for(i=3;i*i<MAX;i+=2){
		if(!prime[i]){
			for(j=i+i;j<MAX;j+=i){
				prime[j] = 1;
			}
		}
	}
}

int main()
{_

	
	
	int x;
	cin>>x;
	seive();

	for(i=x;;i++){
		if(prime[i]==0){
			break;
		}
	}
	cout<<i<<endl;
	//cout<<"The minimum prime number greater than or equal to "<<x<<" is "<<i<<"."<<endl;
	return 0;
}

Measured memory_bytes: 384
import itertools
import collections
n = int(input())
a = list(map(int,input().split()))

b = [0] + a
s = list(itertools.accumulate(b))


c = collections.Counter(s)
cm = c.most_common()
cnt = 0
for v in cm:
    if v[1] > 1:
        cnt += (v[1]*(v[1]-1) // 2)
print(cnt)

Measured memory_bytes: 49936
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n,a,b;
		n=sc.nextInt();
		a=sc.nextInt();
		b=sc.nextInt();
		int x=Math.min(a*n, b);
		System.out.println(x);
	}
}

Measured memory_bytes: 21972
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if i==0 or i==H-1 or j==0 or j==W-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int ans=0,c=0;
    while(n--) {
        int a,b;
        cin>>a>>b;
        if(a==b) {
            c++;
            ans=max(ans,c);
        }
        else {
            c=0;
        } 
    } 
    if(ans>=3) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	char c;
	cin>>c;
	c++;
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main() {
	int N = 0;
	int D = 0;
	int count = 0;
	std::cin >> N;
	std::cin >> D;
	while (N > 0) {
		N = N - (2 * D + 1);
		count++;
	}

	std::cout << count << std::endl;

}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 3e5 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll H, W, A, B, ans, fact[MAXN], inv[MAXN];

ll C(ll r, ll n) {
    if (r < 0 || r > n || n < 0) return 0;
    return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
}

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

    fact[0] = 1;
    for (ll i = 1; i < MAXN; i++) fact[i] = fact[i - 1] * i % MOD;
    for (ll i = 0; i < MAXN; i++) inv[i] = poww(fact[i], MOD - 2, MOD);

    cin >> H >> W >> A >> B;
    ans = C(W - 1, H + W - 2);
    for (ll i = A; i >= 1; i--) {
        ll x = C(i - 1, W - B + i - 1) * (C(B - 1, H - i + B - 1) - (i != A ? 1 : 0) * C(B - 1, H - i + B - 2));
        x = (x % MOD + MOD) % MOD;
        ans = (ans - x + MOD) % MOD;
    }
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 4992
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

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

  if(s+t > t+s) swap(s,t);

  int x = s.size(), y = t.size();

  RREP(i,n+1){
    if(n-x*i >= 0 && (n-x*i)%y==0){
      int j = (n-x*i)/y;
      REP(_,i) cout << s;
      REP(_,j) cout << t;
      cout << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 1684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n,l;cin>>n>>l;
  //caricurate
  ll b=l;ll e=l+n-1;
  if(b*e<=0){cout<<(b+e)*n/2<<endl;return 0;}
  if(e<0){cout<<(b+e)*n/2-e<<endl;return 0;}
  cout<<(b+e)*n/2-b<<endl;
  //output
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0&&i%15!=0)
            sum+=i;
    }
    cout<<sum;
}

Measured memory_bytes: 3632
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var ab = int.Parse(Console.ReadLine().Replace(" ",""));
        var sqrt = Math.Sqrt(ab);
        var answer = sqrt == (int) sqrt ? "Yes" : "No";
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27476
using System;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private int[] H;
        private void Scan()
        {
            Scanner sc = new Scanner();
            N = sc.NextInt();
            H = sc.IntArray();
        }



        public void Solve()
        {
            Scan();
            int cnt = 0;
            while (true)
            {
                bool flag = true;
                int l;
                for (l = 0; l < N; l++)
                {
                    if (H[l] > 0)
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag) break;
                int min = int.MaxValue;
                int r;
                for (r = l; r < N; r++)
                {
                    if (H[r] == 0)
                    {
                        break;
                    }
                    min = Math.Min(min, H[r]);
                }
                cnt += min;
                for (int i = l; i < r; i++)
                {
                    H[i] -= min;
                }
            }

            Console.WriteLine(cnt);
        }

        static void Main(string[] args) => new Program().Solve();
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		string s, t;
		cin >> s >> t;
		int n = sz(s), len;
		int m = sz(t);
		vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (s[i - 1] == t[j - 1]) dp[i][j] = 1 + dp[i - 1][j - 1];
				else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
		len = dp[n][m];
		vector<char> ans;
		while (len) {
			if (s[n - 1] == t[m - 1]) ans.pb(s[n - 1]), n--, m--, len--;
			else if (dp[n][m] == dp[n - 1][m]) n--;
			else m--;
		}
		reverse(all(ans));
		for (auto i : ans) cout << i;
		cout << '\n';
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string word[n];
    bool check = true;
    set<string> s;
    for(int i=0;i<n;++i)
    {
        cin>>word[i];
        if(i!= 0 && word[i].front() != word[i-1].back())
            check = false;
        if(s.find(word[i]) != s.end())check = false;
        s.insert(word[i]);
    }
    if(check)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<ll> l(2*n);
  rep(i,2*n) cin>>l[i];
  sort(l.begin(),l.end());
  ll ans=0;
  rep(i,n) ans+=l[2*i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
hoge=[]
for i in range(n):
  huga=list(map(int,input().split()))
  hoge.append(huga)
  
hoge.sort()

ans=0

mise=0

while 1:
  if(m==0):
    break
  
  if(hoge[mise][1]==0):
    mise+=1
  if(hoge[mise][1]>0):
    hoge[mise][1]-=1
    ans+=hoge[mise][0]
    m-=1
    
print(ans)

Measured memory_bytes: 27888
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,a,b);
  OUT(max((a-1)*(b-1), 0LL))BR;
  
  return 0;
}


Measured memory_bytes: 256
import math
n,d=map(int,input().split())
xl=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        fx=xl[i]
        tx=xl[j]
        t=0
        for k in range(d): 
            t+=(fx[k]-tx[k])**2
        ts=math.sqrt(t)
        if ts==float(ts//1):
            ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t



int main(){
    ll N; cin >> N;
    vector<ll> A(N), B(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];

    vector<vector<ll>> DP((1<<N)+1, vector<ll>(55, INF)); DP[0][0] = 0;
    for(int i = 0; i < (1<<N) ; i++){
        bitset<20> b = i;
        ll c = b.count();


        ll p = 0;
        for(int j = N-1; j >= 0; j--){
            if(b[j] == 1) {p++; continue;}
            for(int k = 0; k <= 50; k++){
                if(DP[i][k] == INF) continue;
                bitset<20> b2 = 0; b2[j] = 1;
                ll n;
                if( abs(c-j)%2 == 0) n = A[j];
                else n = B[j];
                if(n >= k) {
                    DP[(b|b2).to_ullong()][n] = min(DP[i][k] + abs(c-(j+p)), DP[(b|b2).to_ullong()][n]);
                }
            }
        }
    }
    ll ans = INF;
    for(int i = 0; i <= 50; i++) ans = min(ans, DP[(1<<N)-1][i]);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;



}

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

int main(){
	
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			int ans = i * j;
			cout << i << "x" << j << "=" << ans << "\n"; 
		}
	}
	
    return 0;
}

Measured memory_bytes: 1112
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }
const int MAX=510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

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


//n!
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
}
 
// 繰り返し二乗法 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
 
//nCr O(r) nがでかくても安心
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    //a=n!/(n-r)!=n~n-r+1までの総積->O(r)
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    //b=inv(r!)
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
 
ll inv_mod(ll n){
    // フェルマーの小定理
    return pow_mod(n,mod-2);
}

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

    COMinit();

    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(ALL(a));
    ll ans=0,mi=0,pl=0;
    //pl
    for(int i=k-1;i<n;i++){
        ll num=a[i];
        ll le=i;
        ll res=COM(le,k-1)*num%mod;
        if(res<0) res+=mod;
        pl=(pl+res)%mod;
    }
    
    reverse(ALL(a));

    for(int i=k-1;i<n;i++){
        ll num=a[i];
        ll le=i;
        ll res=COM(le,k-1)*num%mod;
        if(res<0) res+=mod;
        mi=(mi+res)%mod;
    }

    ans=pl-mi;
    if(ans<0) ans+=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 13056
//                             In The Name Of Allah                                           
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define ll long long
//#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 450, OO = 1e9 + 7, K = 3e5 + 100, T = 5, M = 1e9 + 7, P = 6151, SQ = 450, lg = 20;
typedef pair <int, int> pii;
vector <pii> v[N];
int n, m;
bool mark[N];

inline bool get(int i, int j) {
	queue <pii> q;
	q.push({i, m + 1}), q.push({j, m + 1});
	memset(mark, 0, sizeof(mark));
	mark[i] = mark[j] = true;
	while((int)q.size()) {
		pii pq = q.front();
		q.pop();
		int x = pq.ff, tm = pq.ss;
		for(auto u : v[x]) {
			if(u.ss >= tm)
				break;
			if(mark[u.ff])
				return false;
			mark[u.ff] = true;
			q.push(u);
		}
	}
	return true;
}

int32_t main() {
	use_fast;
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		v[x].pb({y, i});
		v[y].pb({x, i});
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) 
		for(int j = i + 1; j <= n; j++)
			ans += get(i, j);
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 5900
package main

import "fmt"

func main() {
	var N, M, C int
	fmt.Scan(&N, &M, &C)

	B := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&B[i])
	}

	var sum, ans int
	var A []int
	for i := 0; i < N; i++ {
		sum = C
		A = make([]int, M)

		for j := 0; j < M; j++ {
			fmt.Scan(&A[j])
		}

		for k := 0; k < M; k++ {
			sum += A[k] * B[k]
		}

		if sum > 0 {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node ori[10000];

int getheight(int );
void result(int );

int main()
{
  int n,i,id,left,right;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    ori[i].p=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
    ori[id].l=left;
    ori[id].r=right;
    if(left!=NIL && right!=NIL){
      ori[left].p=id;
      ori[right].p=id;
    }
    else if(left!=NIL && right==NIL){
      ori[left].p=id;
    }

    else if(left==NIL && right!=NIL){
      ori[right].p=id;
    }
  }
    
    for(i=0;i<n;i++) result(i);
  
    return 0;
}

int getheight(int i)
{
  int s=0,t=0;

  if(ori[i].l==NIL && ori[i].r==NIL) return 0;

  if(ori[i].l!=NIL){
    s=getheight(ori[i].l)+1;
  }

   if(ori[i].r!=NIL){
    t=getheight(ori[i].r)+1;
  }

   if(s>t)return s;

   else return t;
}

void result(int i)
{
  int count,height=0,depth=0,degree=0;
   printf("node %d: parent = %d, ",i,ori[i].p);
    if(ori[i].p==NIL){
      printf("sibling = -1, ");
    }

    else if(ori[ori[i].p].l==i){
      printf("sibling = %d, ",ori[ori[i].p].r);
    }

    else {
      printf("sibling = %d, ",ori[ori[i].p].l);
    }

    printf("degree = ");

    if(ori[i].l!=NIL && ori[i].r!=NIL){
      printf("2, ");
    }
      
      else if(ori[i].l==NIL && ori[i].r==NIL){
	printf("0, ");
      }

      else printf("1, ");

      count=i;

      while(ori[count].p!=NIL){
	depth++;
	count=ori[count].p;
      }

      printf("depth = %d, ",depth);
      depth=0;

      printf("height = ");
      height=getheight(i);

      printf("%d,",height);

      if(ori[i].p==NIL){
	printf(" root\n");
      }
      else if(ori[i].l==NIL && ori[i].r==NIL){
	printf(" leaf\n");
      }
      else {
	printf(" internal node\n");
      }
}





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

int main() {
  string n;
  cin >> n;
  ll sum = 0;
  rep(i, n.size()) {
    int n1 = n[i] - '0';
    sum += n1;
  }
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3720
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#include<unordered_map>
#define io ios::sync_with_stdio(false)
#define inf 0x3f3f3f3f
#define ll long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const double PI = 3.1415926536;

using namespace std;



int main()
{
	io;
	ll n, a, b;
	cin >> n >> a >> b;
	ll t = a + b;
	ll ans = n / t;
	n -= ans*t;
	ans *= a;
	ans += n >= a ? a : n;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())
#define MP(a,b) make_pair(a,b)
#define FORE(a,b) for(auto &&a:b)

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int main(void){
	int W,H,x,y,r; cin>>W>>H>>x>>y>>r;
	bool f=true;
	if(x-r<0) f=false;
	if(x+r>W) f=false;
	if(y-r<0) f=false;
	if(y+r>H) f=false;
	if(f) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  cout << "ABC" << N << 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;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N, M;
    cin >> N >> M;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<pair<ll, ll>> C(M);
    rep(i, M) {
        ll b, c;
        cin >> b >> c;
        C[i] = make_pair(c, b);
    }

    sort(A.begin(), A.end());
    sort(C.begin(), C.end(), greater<pair<ll, ll>>());

    int idx_A = 0;
    rep(i, M) {
        rep(j, C[i].second) {
            if (C[i].first <= A[idx_A] || idx_A == N)
                break;
            else {
                A[idx_A] = C[i].first;
                ++idx_A;
            }
        }
        if (C[i].first <= A[idx_A] || idx_A == N) break;
    }

    ll ans = 0;
    rep(i, N) ans += A[i];

    cout << ans << endl;
}

Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
signed main() {
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  vector<int> X(N);
  REP(i, N) cin >> X[i];
  sort(X.begin(), X.end());
  vector<int> same(M, 0);
  for(int i = 0; i < N; ) {
    int c = 0;
    int j;
    for(j = i + 1; j < N && X[i] == X[j]; ++j) {
    }
    c = j - i;
    same[X[i] % M] += c / 2;
    // DEBUG(X[i]); DEBUG(c);
    i += c;
  }
  vector<int> mod(M, 0);
  REP(i, N) {
    mod[X[i] % M]++;
  }
  int ans = 0;
  REP(i, M) {
    int j = (M - i) % M;
    if(i > j) break;
    // cerr << "i=" << i << " j=" << j << " mod[" << i <<"]=" << mod[i] << " mod[" << j << "]=" << mod[j] << " same[" << i << "]=" << same[i] << " same[" << j << "]=" << same[j] << endl;
    if(i == j) {
      ans += mod[i] / 2;
    }
    else {
      int use = min(mod[i], mod[j]);
      // DEBUG(use);
      ans += use;
      ans += min(same[i], (mod[i] - use) / 2);
      ans += min(same[j], (mod[j] - use) / 2);
    }
    // DEBUG(ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;
using ll = long long int;

int main(){
    ll N, D;
    cin >> N >> D;

    vector<vector<ll>> X(N, vector<ll>(D));

    for(ll i = 0; i < N; ++i){
        for(ll j = 0; j < D; ++j){
            cin >> X[i][j];
        }
    }

    ll c = 0;
    for(ll i = 0; i < N; ++i){
        for(ll j = i+1; j < N; ++j){
            ll sum = 0;
            for(ll k = 0; k < D; ++k){
                auto diff = X[i][k] - X[j][k];
                sum += diff * diff;
            }
            for(ll l = 1; l * l <= sum; ++l){
                if(l * l == sum) c++;
            }
        }
    }
    cout << c << endl;
}


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

int main(){
  int a, i;
  cin >> a;
  for(i=9; i>=1; i--){
    if (a%i == 0){
      if (a/i > 0 && a/i <= 9){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String text = br.readLine();
		StringBuilder sb = new StringBuilder("");

		for(int i = 0; i < text.length(); i++) {
			sb.append("x");
		}
		System.out.println(sb);

	}
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}

inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}

ll modpow(ll a, ll n){
    ll ret = 1ll;
    while(n > 0){
        if(n&1)(ret *= a)%=mo;
        (a *= a)%= mo;
        n>>=1;
    }
    return ret;
}
ll comb(ll N_, ll C_) {
	const int NUM_=200050;
	static ll com[NUM_+1],inv[NUM_+1];
	if (com[0]==0) {
        inv[1] = 1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
        for(int i=1;i<=NUM_;++i){
            if(i == 1) com[i] = N_;
            else {
                com[i] = ((com[i-1] * (N_ - i + 1))%mo * inv[i])%mo;
                (com[i] += mo)%=mo;
            }
        }
	}
	if(C_<0 || C_>N_) return 0;
	return com[C_]%mo;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    
    int n,a,b;
    cin>>n>>a>>b;
    
    ll sum = modpow(2,n);
    sum--;
    
    
    ll cb= comb(n,b);
    ll ca= comb(n,a);
    
    sum = (sum + mo - cb )%mo;
    sum = (sum + mo - ca)%mo;
    cout << sum << endl;
    return 0;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main ()
{
    int a,b,c;
    cin >> a >>   b >> c;
    if((a==b && a!=c) || (a==c && a!=b) || (c==b && a!=b) )
    cout << "Yes" << endl;
    else cout << "No"<< endl;
}


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

s = []
t = []
for i in range(N):
    a,b = input().split()
    s.append(a)
    t.append(int(b))
x = input()

f = False
ans = 0
for i in range(N):
    if f:
        ans += t[i]
    else:
        if x == s[i]:
            f = True

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <map>
using namespace std;
int main(void){
	int n,q;
	while(cin>>n>>q,n||q){
		map<int,string> eras;
		map<string,int> exist_year;
		int miny=-1;
		for(int i=0,eb,wy;i<n;++i){
			string nengo;
			cin>>nengo>>eb>>wy;
			eras[wy-eb]=nengo;
			if(exist_year.find(nengo)==exist_year.end()) exist_year[nengo]=wy;
			else if(exist_year[nengo]<wy) exist_year[nengo]=wy;
			if(miny==-1 || miny > wy-eb) miny=wy-eb;
		}
		for(int i=0,y;i<q;++i){
			cin>>y;
			if(miny>=y) cout<<"Unknown"<<endl;
			else{
				for(map<int,string>::reverse_iterator it=eras.rbegin();it!=eras.rend();++it){
					if(it->first < y){
						if(y<=exist_year[it->second]) cout<<it->second<<" "<<y-it->first<<endl;
						else cout<<"Unknown"<<endl;
						break;
					}
				}
			}
		}
	}
	return 0;
}

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

int main()
{
  int a, s, d;
  cin >> a >> s >> d;
  if(a==7&&s==5&&d==5 || s==7&&a==5&&d==5 || a==5&&s==5&&d==7)
    cout << "YES" << endl;
    else
      cout << "NO" << endl;
}  


Measured memory_bytes: 256
N = int(input())
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)
for i in range(1, N + 1):
    t[i], x[i], y[i] = map(int, input().split())

"""
t = [0, 3, 6]
x = [0, 1, 1]
y = [0, 2, 1]
"""

for i in range(N):
    dt = t[i + 1] - t[i]
    dx = abs(x[i + 1] - x[i])
    dy = abs(y[i + 1] - y[i])

    # 移動距離が実現可能か
    if (dx + dy) > dt:
        print("No")
        exit()

    # 目的地に到達した後、残り時間が偶数か
    if (dt - (dx + dy)) % 2 != 0:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 17432
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

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

int main(){
	int n;
	while(cin>>n){
		int ans=0;
		rer(i,1,n){
			if(is_prime(i) && is_prime(n+1-i)) ans++;
		}
		o(ans);
	}
}

Measured memory_bytes: 1160
#include<map>
#include<queue>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=14,M=797171,T=2e5+10;
template<class o>void qr(o&x) {
	char c=gc;int f=1;x=0;
	while(!isdigit(c)){if(c=='-')f=-1;c=gc;}
	while(isdigit(c))x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o>void qw(o x) {
	if(x/10)qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o>void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x);puts("");
}

int trie[M][3],ed[M],p[M],n,cnt=1,tot,f[N]; 
char s[T]; bool v[M];

void insert(int x) {
	int p=1;
	for(int i=1;i<=n;i++) {
		int c=x%3; x/=3;
		if(!trie[p][c]) trie[p][c]=++cnt;
		p=trie[p][c];
	}
	ed[p]=++tot;
}

void lazy(int x) {
	if(v[x]) {
		v[x]=0;
		int &y=trie[x][1],&z=trie[x][2];
		swap(y,z); 
		v[trie[x][0]]^=1; v[y]^=1; v[z]^=1;
	}
}

void add(int x) {
	if(ed[x]) return ;
	lazy(x);
	int a=trie[x][0],b=trie[x][1],c=trie[x][2];
	trie[x][0]=c; trie[x][1]=a; trie[x][2]=b;
	add(c);
}

void dfs(int x,int y,int d) {//½Úµã±àºÅ,ÕæÊµÖµ,Éî¶È 
	if(ed[x]) {p[ed[x]]=y; return ;} lazy(x);
	for(int i=0;i<=2;i++) dfs(trie[x][i],y+i*f[d],d+1);
}

int main() {	
	qr(n); scanf("%s",s+1);
	f[0]=1; for(int i=1;i<=n;i++) f[i]=f[i-1]*3;
	for(int i=0;i<f[n];i++) insert(i);
	for(int i=1;s[i];i++) 
		if(s[i]=='S') v[1]^=1;
		else add(1);
	dfs(1,0,0);	for(int i=1;i<=tot;i++) pr1(p[i]);
	return 0;
}



Measured memory_bytes: 15192
#include <iostream>

using namespace std;

int v[35];

int main()
{
    int m,n,a,f;
    cin>>n>>m;
    for(int i=0; i<n; i++){
        cin>>a;
        for(int j=0; j<a; j++){
            cin>>f;
            v[f]++;
        }
    }
    int ttl=0;
    for(int i=0; i<35; i++){
        if(v[i]==n)
            ttl++;
    }
    cout<<ttl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  string s[N]; rep(i, N) cin >> s[i];
  int M; cin >> M;
  string t[M]; rep(i, M) cin >> t[i];

  int result = 0;
  rep (i, N) {
    int diff = 0;
    rep(j, N) if(s[j]==s[i]) diff++;
    rep(j, M) if(t[j]==s[i]) diff--;
    result = max(result, diff);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
w=[input() for i in range(n)]
m=w[0][-1]
for i in range(1,n):
  if w.count(w[i])==1 and m==w[i][0]:
    m=w[i][-1]
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 9156
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int ans1, ans2, ans3, ans;
	scanf("%d %d %d", &a, &b, &c);
	ans1 = a + b;
	ans2 = a - b;
	ans3 = a * b;
	if(ans1 > ans2) {
		ans = ans1;
	} else {
		ans = ans2;
	}
	if(ans3 > ans) {
		ans = ans3;
	}
	printf("%d\n", ans);
}



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

using namespace std;
using nagai = long long;
#define sz(x) int((x).size())
const int mod=1e6+3;
int su(int a,int b){
	 if((a+=b)>=mod)a-=mod;
	 return a;
}
int mu(int a,int b){
	 return (nagai)a*b%mod;
}
int pw(int a,int b,int c=1){
	 for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
	 return c;
}

int dv(int a,int b){
	return mu(a,pw(b,mod-2));
}

int q;
const int N=2*mod+5;
int pref[N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	pref[0]=1;
	for(int i=0;i+1<N;++i){
		if(i%mod==0)
			pref[i+1]=pref[i];
		else
			pref[i+1]=mu(pref[i],i%mod);
	}
	cin>>q;
	while(q--){
		int x,d,n;
		cin>>x>>d>>n;
		if(d==0){
			cout<<pw(x,n)<<'\n';
			continue;
		}
		if(x==0||n>=mod){
			cout<<0<<'\n';
			continue;
		}
		int k=dv(mod-x,d);
		if(k<n){
			cout<<0<<'\n';
			continue;
		}
		x=dv(x,d);
		cout<<mu(pw(d,n),dv(pref[x+n],pref[x]))<<'\n';
	}
	return 0;
}



Measured memory_bytes: 8704
N=int(input())
A=list(map(int,input().split()))
A.sort()
M=N
for k in range(N-1):
    if A[k]==A[k+1] and A[k]!=0:
        for j in range(M-1,k+1,-1):
            if A[j]==A[j-1] and A[j]!=0:
                A[j]=0
                A[k]=0
                M=j
                break
count=0
dcount=0
for k in range(len(A)):
    if A[k]!=0:
        count+=1
for k in range(len(A)-1):
    if A[k]==A[k+1] and A[k]!=0:
        dcount+=2
print(count-dcount)

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

int main(){
  string s;
  cin >> s;
  int n= s.length();
  int count=0;
  if(n%2==1){
    count++;
  }
  else{
    for(int i=0;i<n;i++){
      if(i%2==0 && s.at(i)!='h'){
        count++;
      }
      else if(i%2==1 && s.at(i)!='i'){
        count++;
      }
    }
  }
  if(count==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

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

  int zero = 0;
  int one = 0;
  for (int i=0; i<S.size(); i++) {
	if (S[i] == '0') {
	  zero += 1;
	} else {
	  one += 1;
	}
  }

  if (zero < one) {
	cout << 2 * zero << endl;
  } else {
	cout << 2 * one << endl;
  }
  
  return 0;
}

Measured memory_bytes: 512