akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll N;
	cin>>N;
	FOR(i,1,10){
		if(N%i==0 && N/i<=9){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1){
		int n,x,ans=0;
		cin>>n>>x;
		if(n+x==0)break;
		rep1(i,n){
			rep1(j,n){
				if(i==j)continue;
				rep1(k,n){
					if(i==k||j==k)continue;
					if(i+j+k==x)ans++;
				}
			}
		}
		cout<<ans/6<<endl;
	}
}


Measured memory_bytes: 3108
import sys
readline = sys.stdin.readline
n, k = map(int, input().split())
A = []
for _ in range(n):
    t, d = map(int, readline().split())
    A.append((d, t))
A.sort(reverse=True)
X = []
Y = []
st = set()
for i in range(k):
    d, t = A[i]
    if t in st:
        X.append(d)
    else:
        Y.append(d)
        st.add(t)
x = sum(X)
y = sum(Y)
v = len(Y)
ans = x + y + v ** 2
for i in range(k, n):
    if not X:
        break
    d, t = A[i]
    if t in st:
        continue
    st.add(t)
    x -= X.pop()
    y += d
    v += 1
    ans = max(ans, x + y + v ** 2)
print(ans)


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

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

int dp[210][210]; 
int main() {
    int k; 
    cin >> k;

    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            if (!dp[i][j]) {
                dp[i][j] = gcd(i, j);
            }

        }
    }
    long long sum = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int x = 1; x <= k; x++) {
                sum += gcd(dp[i][j], x);
            }
        }
    }

    cout << sum << endl; 
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

ll gcd(ll x,ll y){

	if(y==0){ return x;}
  	else{return(gcd(y,x%y));}
}

ll lcm(ll x, ll y){
	return x*y / gcd(x,y);

}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  	ll a,b;  	
  	cin >> a >> b;
  	cout << lcm(a,b) << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int solve(const vector<vector<string>>& w, int K){
  int ret = 0;
  vector<int> cnt(w.size(), 0);

  rep(i,w[0][0].size()){
    rep(j,w.size()){
      rep(k,w[j].size()){
        if(w[j][k][i]=='1') cnt[j]++;
      }
    }
    bool flg = false;
    rep(j,w.size()){
      if(cnt[j] > K) flg = true;
    }

    if(flg){
      ret++;
      rep(j,w.size()){
        cnt[j] = 0;
        rep(k,w[j].size()){
          if(w[j][k][i]=='1') cnt[j] += 1;
        }
      }
    }
    bool flg2 = false;
    rep(j,w.size()){
      if(cnt[j] > K) flg2 = true;
    }
    if(flg2) return 1000000000;
  }
  return ret;
}


int main(){
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> v;
  rep(i,H){
    string s;
    cin >> s;
    v.push_back(s);
  }

  int ret = H*W;

  for(ll S=0; S<(1<<(H-1)); S++){
    vector<vector<string>> w;
    vector<string> tmp;
    tmp.push_back(v[0]);
    int cut = 0;
    REP(i,1,H){
      if((S>>(i-1))&1){
        w.push_back(tmp);
        tmp.clear();
        cut++;
      }
      tmp.push_back(v[i]);
    }
    w.push_back(tmp);

    ret = min(ret, cut + solve(w, K));
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;

}


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

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

using namespace std;

const int MAX = 300001;
bool data[MAX+10];
vector<int> MSPrime;


void make(){
  fill(data,data+MAX,false);
  for(int i = 0; 7*i+6 < MAX; i++){
    data[7*i+1] = true;
    data[7*i+6] = true;
  }

  for(int i = 5; i < MAX; i++)
    if(data[i]) 
      for(int j = 2*i; j < MAX; j+=i) data[j] = false;

  for(int i = 2; i < MAX; i++)
    if(data[i])MSPrime.push_back(i);
}

void solve(int in){
  for(int i = 0; i < MSPrime.size(); i++)
    if(!(in%MSPrime[i])) cout << " " << MSPrime[i];				 
}
int main(){
  make();
  int in;
  while(cin >> in){
    if(in == 1) break;
    
    cout << in << ":";
    solve(in);
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1468
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	private static Map<Long, Long> map = new HashMap<>();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		sc.close();
		System.out.println(solv(h));
	}

	public static long solv(long h) {

		if (h == 1) {
			return 1;
		}
		if (map.containsKey(h)) {
			return map.get(h);
		}
		map.put(h, solv(h / 2L) * 2L + 1L);
		return map.get(h);
	}
}


Measured memory_bytes: 23380
#include<stdio.h>
#define N 1000
 
int n,A[N],B[N],C[N],con,res,min;
 
void swap(int* A,int* B)
{
  int ch;
  ch=*A;
  *A=*B;
  *B=ch;
}
int small(int a,int b)
{
  if(a<b)return a;
  
  else return b;
}
 
int search(int a)
{
  int m;
  for(m=0; m<n; m++){
    if(A[m]==a)return m;
  }
  
}
 
int main()
{
  int i,j,sum=0,k;
 
  scanf("%d",&n);
 
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
    B[i]=A[i];
  }
 
  for(i=n-1; i>0; i--){
    for(j=0; j<i; j++){
      if(B[j]>B[j+1]) swap(&B[j],&B[j+1]);
    }
  }
 
  for(i=0; i<n; i++)C[i]=0;
 
  for(i=0; i<n; i++){
    k=i;
    con=res=0;
    min=(1<<24);
 
    while(C[k]==0){
      C[k]=1;
      con++;
      res+=A[k];
      min=small(min,A[k]);
      k=search(B[k]);
    }
 
    if(con<2)continue;
    sum+=small(res+B[0]*(con+1)+min,res+min*(con-2));
  }
 
  printf("%d\n",sum);
   
  return 0;
  
}




Measured memory_bytes: 2108
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
class dice{
public:
	int num[6], tmp;
	void moveS(){
		tmp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = tmp;
	}
	void moveN(){
		tmp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = tmp;
	}
	void moveW(){
		tmp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = tmp;
	}
	void moveE(){
		tmp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = tmp;
	}
};
int main(){
	dice a;
	for (int i = 0; i < 6; i++){
		cin >> a.num[i];
	}
	int n,c,b;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> c >> b;
		if (a.num[2] == b || a.num[3] == b){
			a.moveE();
		}
		while (1){
			a.moveN();
			if (a.num[1] == b)break;
		}
		while (2){
			a.moveE();
			if (a.num[0] == c)break;
		}
		cout << a.num[2] << endl;
	}
	
	return 0;
}



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

using namespace std;
int main(){
    int K, A, B;
    cin >> K;
    cin >> A >> B;
  REP(i,1000){
    if(A <= K*i && K*i <= B){
      cout << "OK" << endl;
      return 0;
    }
    if(B < K*i)break;
  }
  cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
x, y = map(int, input().split())
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
list3 = [2]
list_all = [list1, list2, list3]
for lis in list_all:
  if x in lis:
    if y in lis:
      print("Yes")
    else:
      print("No")
  else:
    continue

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

vector<P> factrize(int m) {
	if (m == 1) return vector<P>(1, { 1,0 });
	vector<P> res;
	for (ll i = 2;i * i <= m;++i) {
		if (m % i) continue;
		res.emplace_back(i, 0);
		while (m % i == 0) {
			m /= i;
			res.rbegin()->second++;
		}
	}
	if (m > 1) res.emplace_back(m, 1);
	return res;
}

const int p = 1000000007;
class Zp {
	ll x;
public:
	Zp(ll X) :x((X + p) % p) { ; }
	Zp() :x(0) { ; }
	Zp &operator=(ll y) { return *this = Zp(y); }
	Zp operator-() const { return Zp(-x); }
	Zp operator+(ll y) const { return Zp(x + y); }
	Zp &operator+=(ll y) { return *this = *this + y; }
	Zp operator-(ll y) const { return Zp(x - y); }
	Zp &operator-=(ll y) { return *this = *this - y; }
	Zp operator*(ll y) const { return Zp(x * y); }
	Zp &operator*=(ll y) { return *this = *this * y; }
	Zp operator/(ll y) const { return *this * Zp(y).inv(); }
	Zp &operator/=(ll y) { return *this = *this / y; }
	Zp operator+(const Zp &r) const { return *this + r.x; }
	Zp &operator+=(const Zp &r) { return *this += r.x; }
	Zp operator-(const Zp &r) const { return *this - r.x; }
	Zp &operator-=(const Zp &r) { return *this -= r.x; }
	Zp operator*(const Zp &r) const { return *this * r.x; }
	Zp &operator*=(const Zp &r) { return *this *= r.x; }
	Zp operator/(const Zp &r) const { return *this / r.x; }
	Zp &operator/=(const Zp &r) { return *this /= r.x; }
	Zp pow(int i) const {
		if (i == 0) return Zp(1);
		if (i % 2) return *this * pow(i - 1);
		Zp tmp = pow(i / 2);
		return tmp * tmp;
	}
	Zp inv() const { return pow(p - 2); }
	ll get() const { return x; }
	bool operator==(ll y) { return x == y; }
	bool operator!=(ll y) { return !(*this == y); }
	friend istream &operator>>(istream &istr, Zp &z) { return istr >> z.x; }
	friend ostream &operator<<(ostream &ostr, const Zp &z) { return ostr << z.x; }
};
class Comb {
	int n;
	vector<Zp> fact, ifact;
public:
	Comb(int N) :n(N), fact(N + 1), ifact(N + 1) {
		fact[0] = 1;
		REP(i, n) fact[i + 1] = fact[i] * (i + 1);
		ifact[n] = fact[n].inv();
		REPR(i, n) ifact[i] = ifact[i + 1] * (i + 1);
	}
	Zp operator()(int k, int r) {
		return fact[k] * ifact[r] * ifact[k - r];
	}
};

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

	int N, M;
	cin >> N >> M;
	vector<P> fact = factrize(M);
	Comb comb(200000);
	Zp res = 1;
	for (auto p : fact) {
		res *= comb(N - 1 + p.second, p.second);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int n; cin >> n;
    vector<int> a(n);
    for(auto &x: a) cin >> x;
    int mn = a[0];
    int ans = 1;
    for(int i = 1; i < n; ++i) {
        if(a[i] < mn) ans++;
        mn = min(mn, a[i]);
    }
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

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

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
typedef pair<int, int> P;

vector<vector<int>> d(22, vector<int>(22, -1));
vector<vector<int>> d2(22, vector<int>(22, -1));

int H, W;

//sからスタートして、gx gyまでの距離を返す
int bfs(vector<vector<char>> &maze, int sx, int sy, int gx, int gy) {
	d[sx][sy] = 0;

	queue<P> que;
	que.push(P(sx, sy));

	while(que.size()) {
		P p = que.front();
		que.pop();

		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];

			if (nx < 0 || nx >= H || ny < 0 || ny >= W || maze[nx][ny] == '#' || d[nx][ny] != -1) continue;
			
          	que.push(P(nx, ny));
			d[nx][ny] = d[p.first][p.second] + 1;
			
		}
	}
	return d[gx][gy];
}

int main() {
	cin >> H >> W;
	vector<vector<char>> maze(H, vector<char>(W));

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> maze[i][j];
		}
	}
	vector<int> ans;

	for (int sx = 0; sx < H; sx++) {
		for (int sy = 0; sy < W; sy++) {
			for (int gx = 0; gx < H; gx++) {
				for (int gy = 0; gy < W; gy++) {
					if (maze[sx][sy] == '#') continue;
					
					ans.push_back(bfs(maze, sx ,sy, gx, gy));
					d = d2;
				}
			}
		}
	}
	
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());

	cout << ans[0] << endl;
}

Measured memory_bytes: 1404
n = int(input())
A = [[int(i) for i in input().split()] for i in range(n)]
B = [[int(i) for i in input().split()] for i in range(n)]
A.sort(reverse=True)
B.sort(key=lambda x: x[1])

count = 0
for i in range(n):
    for j in range(len(B)):
        if A[i][0] < B[j][0] and A[i][1] < B[j][1]:
            count += 1
            B.pop(j)
            break
        
print(count)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;

namespace ABC125 {
  class ProblemB {
    static void Main(string[] args) {
      int n = Input.num;
      int[] v = Input.nums;
      int[] c = Input.nums;

      int[] diff = new int[n];
      for (int i = 0; i < n; i++) {
        diff[i] = v[i] - c[i];
      }
      int ans = 0;
      for (int i = 0; i < n; i++) {
        if (diff[i] > 0) ans += diff[i];
      }
      System.Console.WriteLine(ans);
    }
  }
  public class Input {
    public static string str => System.Console.ReadLine();
    public static string[] strs => str.Split(' ');
    public static char[] charArr => str.ToCharArray();
    public static int num => int.Parse(str);
    public static int[] nums => Array.ConvertAll(strs, int.Parse);
    public static long numL => long.Parse(str);
    public static long[] numLs => Array.ConvertAll(strs, long.Parse);
  }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
const int N = 305;
const int mod = 1e9 + 7; 
using namespace std;

int n, m, f[N][N][N], ans; 
struct node { int l, r, x; } p[N]; 
vector<int> vec[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

bool check(int pos, int p1, int p2)
{
	bool flag = 1;
	for(int l, x, i = 0; i < vec[pos].size() && flag; i++)
	{
		l = p[vec[pos][i]].l, x = p[vec[pos][i]].x;
		if(x == 1 && p1 >= l) flag = 0; 
		if(x == 2 && (p1 < l || p2 >= l)) flag = 0;
		if(x == 3 && p2 < l) flag = 0; 
	}
	return flag; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> ();
	for(int i = 1; i <= m; i++) p[i].l = read <int> (), p[i].r = read <int> (), p[i].x = read <int> (); 
	for(int i = 1; i <= m; i++) vec[p[i].r].push_back(i);
	f[0][0][0] = 1; 
	for(int i = 0; i < n; i++)
	{
		if(check(i + 1, 0, 0)) f[i + 1][0][0] = f[i][0][0]; 
		if(check(i + 1, i, 0)) f[i + 1][i][0] = f[i][0][0]; 
		for(int j = 1; j < i; j++)
			for(int k = 0; k < j; k++)
				if(f[i][j][k])
				{
					if(check(i + 1, j, k)) f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % mod; 
					if(check(i + 1, i, k)) f[i + 1][i][k] = (f[i + 1][i][k] + f[i][j][k]) % mod; 
					if(check(i + 1, i, j)) f[i + 1][i][j] = (f[i + 1][i][j] + f[i][j][k]) % mod; 
				}
	}
	for(int i = 0; i < n; i++)
		for(int j = 0; j < i; j++) ans = (1ll * f[n][i][j] * 6 + ans) % mod;
	ans = (1ll * f[n][0][0] * 3 + ans) % mod; 
	printf("%lld\n", ans); 
	return 0; 
}


Measured memory_bytes: 57856
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct data{
    int a, k, t;
    bool operator< (const data other) const{
        return a+k < other.a+other.k;
    }
};

int main(){
    int n, m, L, d, a, k, t;
    cin >> n >> m >> L;
    vector<data> day[5];
    while(m-- > 0){
        cin >> d >> a >> k >> t;
        day[d].push_back(data({a,k,t}));
    }
    for(int i = 0; i < 5; i++)  sort(day[i].begin(), day[i].end());
    vector<vector<vector<int>>> dp(5, vector<vector<int>>(n+1, vector<int>(n+1, 0)));
    for(int i = 0; i < 5; i++){
        for(int j = 0; j < day[i].size(); j++){
            for(int cnt = n; cnt >= 1; cnt--){
                for(int l = day[i][j].a-1; l >= 0; l--){
                    dp[i][cnt][day[i][j].a+day[i][j].k-1] 
                    = max(dp[i][cnt][day[i][j].a+day[i][j].k-1], dp[i][cnt-1][l]+day[i][j].t);
                }
            }
        }
    }
    vector<vector<int>> dp2(5, vector<int>(n+1, 0));
    for(int i = 0; i < 5; i++){
        for(int j = 0; j < n+1; j++){
            for(int k = 0; k < n+1; k++){
                dp2[i][j] = max(dp2[i][j], dp[i][j][k]);
            }
            if(j)   dp2[i][j] = max(dp2[i][j], dp2[i][j-1]);
        }
    }
    int ans = 0;
    for(int i = 1; i < 9*9*9*9*9; i++){
        int cp = i, tmp = 0, takes = 0;
        for(int j = 0; j < 5; j++){
            int take = min(cp%9, n);
            takes += take;
            cp /= 9;
            tmp += dp2[j][take];
        }
        if(takes <= L)  ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3192
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_map<string, int> m;
  string s;  
  for (int i = 0; i < N; i++) {
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }
  size_t ans = 0;
  for (auto p : m) {
    auto x = static_cast<size_t>(p.second);
    ans += x * (x - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10660
n = int(input())
red = []
blue = []
used_r = [False for _ in range(n)]
used_b = [False for _ in range(n)]
for i in range(n):
    tmp, tmp2 =  map(int, input().split())
    red.append((tmp,tmp2))
for i in range(n):
    tmp, tmp2 =  map(int, input().split())
    blue.append((tmp,tmp2))
red = sorted(red, key=lambda x: -1*x[1])
blue = sorted(blue)
cnt = 0
for j in range(n):
    for i in range(n):
        if red[i][0] < blue[j][0] and red[i][1] < blue[j][1]:
            if used_r[i] or used_b[j]:
                continue
            else:
                cnt += 1
                used_r[i] = True
                used_b[j] = True
                break
print(cnt)


Measured memory_bytes: 3064
A,B=map(int,input().split())
mod = 2018
flag =0
for i in range(A,B):
  x = i % 2019
  for j in range(i+1,B+1):
    j = j % 2019
    mod = min(mod, (x*j)%2019)
    if mod == 0:
      flag = 1
      break
  if flag:
    break

print(mod)

Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
int main()
{
          char c[4];
          int i,count=0;
          scanf("%s",c);
          for(i=0;i<=2;i++)
         {
                     if(c[i]=='1')
                                  count++;
         }
         printf("%d",count);
         return 0;
}

Measured memory_bytes: 128
H = int(input())
if H==1:
  print(1)
elif 2 <= H and H <= 3:
  print(3)
elif 4 <= H and H <= 7:
  print(7)
else:
  for i in range (1,43):
    if 2**(i-1)<=H and H <2**(i):
      print(2**(i)-1)
    else:
      pass


Measured memory_bytes: 2940
import java.util.Scanner;

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

		int kosu=sc.nextInt();
		int ave=0;
		int kst=0;
		int kag=0;
		int sum=0;
		int wa=0;
		int[] aa=new int[kosu];
		for(int i=0; i<kosu; i++) {
			aa[i]=sc.nextInt();
			sum+=aa[i];
		}

		if(sum%kosu==0) {
			ave=sum/kosu;
		}
		else {
			kst=sum/kosu;
			kag=(sum+kosu-1)/kosu;
			if(kag*kosu-sum>=sum-kst*kosu) {
				ave=kst;
			}
			else {
				ave=kag;
			}
		}

		for(int i=0; i<kosu; i++) {
			wa+=(aa[i]-ave)*(aa[i]-ave);
		}
		System.out.println(wa);
	}
}

Measured memory_bytes: 23764
L, R = gets.chomp.split(" ").map(&:to_i)
l = L % 2019
r = R % 2019
if L + (2019 - l) <= R 
    puts 0
else
    ans = nil
    (l..r-1).each do |i|
        (i+1..r).each do |j|
            val = (i * j) % 2019
            ans = ans.nil? ? val : [val, ans].min
        end
    end
    puts ans
end

Measured memory_bytes: 1788
S = int(input())
h=0
m=0
s=0

for i in range(S//3600):
    h=h+1
S=S-h*3600
for i in range(S//60):
    m=m+1
S=S-m*60
for i in range(S):
    s=s+1
    
print(h,m,s,sep = ':')



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

int main(){
    int n;
    cin>>n;
    long long t[n],g,l;
    for(int i=0;i<n;i++){
        cin>>t[i];
        if(!i) g=t[i],l=t[i];
        else {
            g=__gcd(l,t[i]);
            l*=t[i]/g;
        }
    }
    cout<<l;


}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] SS = s.toCharArray();
    SS[5] =' ';
    SS[13] = ' ';

    System.out.println(String.valueOf(SS));  
    }
}


Measured memory_bytes: 35580
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;

public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        Console.WriteLine(string.Join(string.Empty,Reader.ReadLine().Split(' ').Select(a=>a[0])));
    }


    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


AtCoder Beginner Contest


";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;


int main()
{	
	  ll ans=0;
	  ll n;
	  cin>>n;
	  ll a[n];
	  for(ll i=0;i<n;i++)
	  {
	  	cin>>a[i];
	  }
	  ll last=mod,c=0;

	  for(ll i=0;i<n;i++)
	  {	
	  	if(a[i]<=last)
	  	{
	  		c++;
	  		last=a[i];
	  	}
	  	else
	  	{
	  		last=a[i];
	  		ans=max(ans,c);
	  		c=1;
	  	}
	  

	  }
	  ans=max(ans,c);
	  cout<<ans-1<<endl;


	   


}
    
 
    
    


Measured memory_bytes: 1024
fn solve() {
    let n: usize = read();
    println!("{}", (1000 - n % 1000) % 1000);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2236
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;


int main() {
	int a, b, c;
	auto count = 3;
	cin >> a >> b >> c;
	if (b == a)count--;
	if (a == c)count--;
	if (b == c)count--;
	cout << max(1, count) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll ;
typedef long double ld ;
typedef vector< ll > vi ;
typedef pair<ll, ll > ii ;
#define pb push_back
#define mp make_pair
#define EPS 1e-8
#define se second
#define fi first
#define mod 1000000007
map<ll,ll>dp[100] ;
ll n ,k;
ll w[101],v[101] ;
ll solve(ll i , ll tot)
{
    if(i == n)
    {
        if(tot > k)
            return -1e18 ;
        return 0 ;
    }
    if(dp[i].find(tot) != dp[i].end())
        return dp[i][tot] ;
    ll res = 0 ;
    res = solve(i+1 , tot + w[i] ) + v[i] ;
    res = max(solve(i+1 , tot ),res) ;
    return dp[i][tot] = res ;
}
int main()
{
    cin>>n>>k;
    for(int i = 0 ; i < n ; i ++ )
    {
        cin >> w[i] >> v[i] ;
    }
    cout << solve(0,0);
}


Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N;
    vector<int> T;
    int tmp1;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp1;
        T.emplace_back(tmp1);
    }

    int sum = accumulate(T.begin(), T.end(), 0);
    int min = 10000000;

    cin >> M;
    vector<int> P;
    vector<int> X;
    int tmp2;
    for (int i = 0; i < M; i++)
    {
        cin >> tmp1 >> tmp2;
        P.emplace_back(tmp1);
        X.emplace_back(tmp2);
    }

    int ans;
    for (int i = 0; i < M; i++)
    {
        ans = sum - T[P[i] - 1] + X[i];
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#include<algorithm>
#define Max (int)105
#define MAX2 (int)1e5+5
#define MOD ((int)1e9+7)
using namespace std;



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

	int max = 0,tmp = 0;
	for(i=0;i<n;i++){
		if(a[i]>=max){
			max = a[i];
			tmp++;
		}
	}

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










/*
Atcoder Dp G-Longest Path iterative solution

vector<int>vec[Max];
queue<int>q;

int dp[Max];
int vis[Max];

void init(){
	int i;
	for(i=0;i<Max;i++){
		dp[i] = 0;
		vis[i] = 0;
	}
}

int getMax(int a,int b){
	return (a<b)?b:a;
}

void solve(int x){
	int i,u;
	q.push(x);

	while(!q.empty()){
		u = q.front();
		q.pop();

		if(vis[u])
			continue;
		vis[u] = 1;
		
		for(i=0;i<vec[u].size();i++){
			dp[vec[u][i]] = getMax(dp[vec[u][i]],dp[u]+1);
			q.push(vec[u][i]);
		}
	}

}

int main(){
	int n,m,incoming[Max],x,y,i;
	for(i=0;i<Max;i++)
		incoming[i] = 0;
	
	init();

	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		vec[y].push_back(x);
		incoming[x]++;
	}
	
	for(i=1;i<=n;i++)
		solve(i);
	
	int max = 0;
	for(i=0;i<Max;i++)
		max = getMax(max,dp[i]);
	
	printf("%d\n",max);
	return 0;
}
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> X(M),Y(M);
  for (int i=0; i < M; i++) {
    cin >> X[i] >> Y[i];
  }
  for (int i=0; i < N; i++) {
    int z = 0;
    for (int j=0; j < M; j++) {
      if (X[j] == i + 1) z++;
      if (Y[j] == i + 1) z++;
    }
    cout << z << endl;
  }
}
    

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var dt = DateTime.Parse(Console.ReadLine());

            if (dt <= DateTime.Parse("2019/04/30"))
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }
        }
    }
}


Measured memory_bytes: 13660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
      int x,n;
      cin>>x>>n;
      int a[n];
      set<int>q;
      for(int i=0;i<n;i++)
          {cin>>a[i];
            q.insert(a[i]);
          }
     if(n==0)
      cout<<x<<endl;
     else
     {

    int i=0;
    while(1)
    {
        if(q.find(x-i)==q.end())
        {
            cout<<x-i<<endl;
            break;

        }
        else if(q.find(x+i)==q.end())
        {
            cout<<x+i<<endl;
            break;
        }
         i++;
    }
     }

}



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

int main() {
	int N,K,s=0;
	cin >> N >> K;
	vector<int> l(N);

	rep(i,N)
		cin >> l.at(i);
	sort(l.begin(), l.end(), greater<int>());

	rep(i,K)
		s += l.at(i);
	cout << s << endl;
}

Measured memory_bytes: 256
import sys

# S = input()
# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():

    A1 = list(map(int, input().split()))
    A2 = list(map(int, input().split()))
    A3 = list(map(int, input().split()))

    As = [A1, A2, A3]

    N = int(input())
    idxs = list()

    for i in range(N):
        b = int(input())
        for j, A in enumerate(As):
            if b in A:
                idx = A.index(b)
                idxs.append((j, idx))

    answer = 'No'

    # check rows
    for i in range(3):
        if (i, 0) in idxs and (i, 1) in idxs and (i, 2) in idxs:
            answer = 'Yes'

    # check columns
    for i in range(3):
        if (0, i) in idxs and (1, i) in idxs and (2, i) in idxs:
            answer = 'Yes'

    if (0, 0) in idxs and (1, 1) in idxs and (2, 2) in idxs:
        answer = 'Yes'

    if (0, 2) in idxs and (1, 1) in idxs and (2, 0) in idxs:
        answer = 'Yes'

    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,x,y;
	cin>>a>>b>>c>>x;
	if (a==1){
		cout<<abs(x-c);
		return 0;
	}
	for (int i=0;i<a-1;i++){
		y=x;
		cin>>x;
	}
	cout<<max(abs(x-y),abs(x-c));
	return 0;
}

Measured memory_bytes: 256
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1173&lang=jp
*/

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

bool solve(string str, int s, int t){
    // cout << s << " " << t << endl;
    int cntm = 0, cntk = 0;
    int findm = -1, findk = -1;
    int levelm = 0, levelk = 0;
    for(int i=s;i<t;i++){
        if(findm >= 0){
            if(str[i] == '(') levelm++;
            else if(str[i] == ')'){
                levelm--;
                if(levelm == 0){
                    if(!solve(str, findm + 1, i)) return false;
                    findm = -1;
                }
            }else if(str[i] == '['){
                levelk++;
            }else if(str[i] == ']'){
                levelk--;
                if(levelk < 0) return false;
            }
        }else if(findk >= 0){
            if(str[i] == '[') levelk++;
            else if(str[i] == ']'){
                levelk--;
                if(levelk == 0){
                    if(!solve(str, findk + 1, i)) return false;
                    findk = -1;
                }
            }else if(str[i] == '('){
                levelm++;
            }else if(str[i] == ')'){
                levelm--;
                if(levelm < 0) return false;
            }
        }else{
            if(str[i] == '('){
                // find corresponding )
                findm = i;
                levelm++;
            }else if(str[i] == '['){
                // find corresponding ]
                findk = i;
                levelk++;
            }else if(str[i] == ')'){
                return false;
            }else if(str[i] == ']'){
                return false;
            }
        }
    }
    if(levelm != 0 || levelk != 0){
        return false;
    }
    return true;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    vector<string> strs;
    while(1){
        string s; getline(cin, s);
        if(s == ".") break;
        strs.push_back(s);
    }
    for(string str: strs){
        bool ok = solve(str, 0, str.size());
        if(ok) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll N;
    cin >> N;
    const auto &res = prime_factorize(N); //(素因数, 数)
    ll ans = 0;
    for (auto p: res){
        ll count=2;
        ll residue = p.second - 1;
        while (residue>=0){
            ++ans;
            residue -= count;
            ++count;
        }
    }
    cout << ans << endl;
}

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

int main() {
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	int a, b, n;
	cin >> a >> b >> n;
	if (b == 1) {
		cout << 0 << endl;
		return;
	}
	int x = min(b - 1, n);
	int ans = (a * x) / b;
	int flag = x / b;
	ans -= (a * flag);
	cout << ans << endl;
}
int32_t main() {
	BOLT;
	solve();
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define popb pop_back()
#define lb lower_bound
#define mp make_pair
#define le length()
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
typedef unordered_map<ll,ll> ull;
typedef unordered_map<ll,int> uli;
typedef unordered_map<int,int> uii;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0,lim-1);
  return uid(rang);
}
ll mpow(ll base, ll exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
 
const int mod = 1000000009;
const int N = 3e5, M = N;
//=======================
 
vi g[N];
int a[N];
vector<ll> f(500069,1);
void compute_factorial(){
  for(int i =2;i<500068;i++){
    f[i] = (i*f[i-1])%mod;
  }
}

void rec(string a, vector<char> b,vector<bool> added,unordered_set<string>& m ,vector<string>& ans){
  //cout<<b.size()<<'\n';
  if(b.size() == a.length()){
    string ss;
    for(auto it:b)ss+=it;
    if(m.find(ss) == m.end())ans.pb(ss),m.insert(ss);
  }
  for(int i =0;i<a.le;i++){
    if(!added[i]){
      b.pb(a[i]);
      added[i]  = true;
      rec(a,b,added, m,ans);
      b.popb;
      added[i] = false;
    }
  }
}

ll gcd(ll a, ll b) 
{ 
    // Everything divides 0  
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    // base case 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
}



void solve(){
  ll n,x,t;
  cin>>n>>x>>t;
  if(n%x!=0){
    n/=x;
    n++;
  }
  else{
    n/=x;
  }
  cout<<n*t<<'\n';

  


 
 }
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    #ifndef ONLINE_JUDGE
          freopen("input.txt", "r", stdin);
          freopen("output.txt", "w", stdout);
    #endif
          int t;
          t = 1;
          //cin>>t;
          int tt = t;
   while(t--)solve();
 
    return 0;
}
 


Measured memory_bytes: 14272
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
    string A, B, C;
    cin >> A >> B >> C;
    if (A.back() == B.front() && B.back() == C.front()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string s;
	cin>>s;
	fy(26){
		char a='a'+y;
	fx(s.size()){
		if(s.at(x)==a){x=s.size()+5;}
		if(x==s.size()-1){ce(a) return 0;}
	}
	
	}
	ce("None")
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int n,m,q,ans=0;
vector<int> a(0);
vector<int> b(0);
vector<int> c(0);
vector<int> d(0);
vector<int> suretu(11,0);

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int A,B,C,D;
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>A>>B>>C>>D;
        a.pb(A);b.pb(B);c.pb(C);d.pb(D);
    }
    int ans=0;
    for(int i=1;i<=m;i++){
        for(int i2=i;i2<=m;i2++){
            for(int i3=i2;i3<=m;i3++){
                for(int i4=i3;i4<=m;i4++){
                    for(int i5=i4;i5<=m;i5++){
                        for(int i6=i5;i6<=m;i6++){
                            for(int i7=i6;i7<=m;i7++){
                                for(int i8=i7;i8<=m;i8++){
                                    for(int i9=i8;i9<=m;i9++){
                                        for(int i10=i9;i10<=m;i10++){
                                            int tmp=0;
                                            vector<int> vec={i,i2,i3,i4,i5,i6,i7,i8,i9,i10};
                                            for(int j=0;j<q;j++){
                                                if(vec[b[j]-1]-vec[a[j]-1]==c[j])tmp+=d[j];
                                            }
                                            ans=max(ans,tmp);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	N := readInt()
	A := readIntArray(N)

	l := lcm(A...)
	B := make([]*big.Int, N)
	for i := range A {
		B[i] = big.NewInt(0).Div(l, big.NewInt(int64(A[i])))
	}
	result := big.NewInt(0)
	d := 1000000007
	for i := range B {
		result = result.Add(result, B[i])
		//result += B[i] % d
		//result %= d
	}
	fmt.Println(big.NewInt(0).Mod(result, big.NewInt(int64(d))))
}

func lcm(ns ...int) *big.Int {
	l := big.NewInt(int64(ns[0]))
	for i := range ns {
		if i == 0 {
			continue
		}

		if l.Cmp(big.NewInt(int64(ns[i]))) == 0 {
			continue
		}

		g := big.NewInt(0).GCD(nil, nil, l, big.NewInt(int64(ns[i])))
		//g := gcd(l, big.NewInt(int64(ns[i])))
		l = big.NewInt(0).Div(big.NewInt(0).Mul(l, big.NewInt(int64(ns[i]))), g)
	}

	return l
}

//func gcd(m, n *big.Int) *big.Int {
//	if m.Cmp(n) == -1 {
//		m, n = n, m
//	}
//	for big.NewInt(0).Mod(m, n).Cmp(big.NewInt(0)) != 0 {
//		m, n = n, big.NewInt(0).Mod(m, n)
//	}
//	return n
//}


Measured memory_bytes: 264576
package main

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

func solve() {
	n := getInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		k := getInt()
		m[k]++
	}

	ans := 0
	for k, v := range m {
		switch {
		case k > v:
			ans += v
		default:
			ans += (v - k)
		}
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


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

using namespace std;

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort(ALL(c))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

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

  string s;
  cin >> s;
  IN(K);
  int N = s.size();

  string v[N];
  vector<string> ans;
  REP(i, N) {
    v[i] = s.substr(i, N);
  }
  sort(v, v+N);
  REP(i, N) REP(j, min(K, (int)v[i].size()))
      ans.push_back(v[i].substr(0, j+1));

  SORT(ans); unique(ALL(ans));
  OUT(ans[K-1]);


  return 0;
}


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

int main(){
	string s,t;
	cin>>s>>t;
  	for(int i=0;i<3;++i)if(s[i]!=t[2-i]){cout<<"NO"<<endl;return 0;}
  	cout<<"YES"<<endl;
  	return 0;
}

Measured memory_bytes: 256