akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int dp[40];
int main(){
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            for(int k=0;k<=9;k++){
                for(int l=0;l<=9;l++){
                    dp[i+j+k+l]++;
                }
            }
        }
    }
    int n;
    while(cin>>n){
        if(n==0){break;}
        cout<<dp[n]<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)

struct BColor {
	const vector<vector<int>>& g;
	const int n;
	vector<int> color;
	BColor(const vector<vector<int>>& g_) : g(g_), n(g_.size()) { }
	
	bool solve(int v, int c) {
		color.assign(n, 0);
		return dfs(v, c);
	}
	
	bool dfs(int v, int c) {
		color[v] = c;
		for (int i = 0; i < g[v].size(); i++) {
			if (color[g[v][i]] == c) {
				return false;
			}
			else if (color[g[v][i]] == 0 and !dfs(g[v][i], -c)) {
				return false;
			}
		}
		return true;
	}
};

struct warshall_floyd {
	static void solve(vector<vector<ll>>& d) {
		int n = d.size();
		rep(k, n) {
			rep(i, n) {
				rep(j, n) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
};

int main(void)
{
	int n;
	cin >> n;
	vector<vector<int>> G(n);
	vector<vector<ll>> dist(n, vector<ll>(n, 0));
	rep(i, n) {
		string s;
		cin >> s;
		rep(j, n) {
			if (i == j) {
				dist[i][j] = 0;
			}
			else if (s[j] == '1') {
				G[i].push_back(j);
				dist[i][j] = 1;
			}
			else {
				dist[i][j] = 1e7;
			}
		}
	}
	BColor m(G);
	auto p = m.solve(0,1);
	if (!p) {
		cout << -1 << endl;
	}
	else {
		warshall_floyd::solve(dist);
		ll m = 0LL;
		rep(i, n) {
			rep(j, n) { m = max(dist[i][j], m); }
		}
		cout << m + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL h,n;
    cin >> h >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    LL sum = 0;
    REP(i,0,n) sum += a[i];
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int  check (int a,int b, int c)
{
 if(a==5)
{
if(b==7&&c==5)
return 1;
}
else 
return 0;
}
 
int main (void)
{
int a,b,c;
 
scanf("%d",&a); 
scanf("%d",&b);
scanf("%d",&c);
 
if(check(a,b,c)||check(b,c,a)||check(c,a,b))
printf("YES");
else 
printf("NO");
 
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int ans,n,r;
	cin >> n;
	r = (n / 15);
	ans = n * 800 - r * 200;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Language
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] lan = Console.ReadLine().Split(' ');
            string a = lan[0];
            string b = lan[1];
            string c = lan[2];


            string upper1 = a.ToUpper();
            string upper2 = b.ToUpper();
            string upper3 = c.ToUpper();

            char Target1 = upper1[0];
            char Target2 = upper2[0];
            char Target3 = upper3[0];

            Console.Write(Target1);
            Console.Write(Target2);
            Console.WriteLine(Target3);
        }
    }
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;
	string s,p;
	cin >> s;
	cin >> p;

	ll f=0;
	for(i=0;i<sz(s);i++)
		if(s[i]!=p[i])f=1;
	if(f)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}

Measured memory_bytes: 3612
import copy

s = list(map(int,list(input())))
n = len(s)
temp_1 = copy.deepcopy(s)
temp_0 = copy.deepcopy(s)
count_0 = 0
count_1 = 0

if s[0] == 0:
  temp_1[0] = 1
  count_1 = 1
elif s[0] == 1:
  temp_0[0] = 0
  count_0 = 1

for i in range(1,n):
  if temp_1[i-1] == temp_1[i]:
    count_1 = count_1 + 1
    temp_1[i] = not(temp_1[i-1]) 
  
  if temp_0[i-1] == temp_0[i]:
    count_0 = count_0 + 1
    temp_0[i] = not(temp_0[i-1])

print(min(count_0,count_1))

Measured memory_bytes: 55672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    REP(i, N){
        cin >> L[i];
    }
    sort(ALL(L), greater<int>());
    int sum = 0;
    FOR(i, 1, N){
        sum += L[i];
    }
    if(L[0] < sum){
        printf("Yes\n\r");
    }else{
        printf("No\n\r");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	map<string,int>s;
	string str;
	scanf("%d",&n);
	while(n--){
		cin>>str;
		s[str]++;
	}
	printf("AC x %d\n",s["AC"]);
	printf("WA x %d\n",s["WA"]);
	printf("TLE x %d\n",s["TLE"]);
	printf("RE x %d\n",s["RE"]);
	return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e5+5;
const ll mod =   1e9+7;
int l,r,d;
int main()
{  fast cin>>l>>r>>d;

int x=l/d;
int y=r/d;
int ans=y-x;
if(l%d==0)
ans++;
cout<<ans;
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
X = [int(i) for i in input().split()]
X.sort()
if M == 1:
    print(0)
else:
    ls = []
    for x, y in zip(X, X[1:]):
        ls.append(y-x)
    ls.sort(reverse=True)
    if N >= M:
        print(0)
    else:
        num = 0
        for i in range(N-1):
            num += ls[i]
        print(sum(ls)-num)

Measured memory_bytes: 13840
#include <iostream>
#include <algorithm>
using namespace std;
#include <vector>
int main() {
  int size, q;
  cin>>size>>q;
 string s;
 cin>>s;
 int arr[s.size()];
 arr[0]=0;
 for(int i=0, j=1 ; i<s.size()-1 ; i++, j++)
{
  if(s[i+1]-s[i]==2)
  arr[j]=1;
  else arr[j]=0;
  arr[j]+=arr[j-1];
}
int a,b;
for(int i=0 ; i<q; i++)
{cin>>a>>b;
cout<<arr[b-1]-arr[a-1]<<endl;
}
/*
8 3
ACACTACG
3 7
2 3
1 8
*/
}


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

int main(){
	int *V;
	int *C;
	int N,i;
	int a=0;
	scanf("%d",&N);
	V=(int*)malloc(sizeof(int)*N);
	C=(int*)malloc(sizeof(int)*N);
	for(i=0;i<N;i++){
		scanf("%d",&V[i]);
	}
	for(i=0;i<N;i++){
		scanf("%d",&C[i]);
	}
	for(i=0;i<N;i++){
		if(V[i]-C[i]>0)a+=V[i]-C[i];	
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, k;
int s;
int main()
{
    cin >> n >> k;
    vector<int> v(n);
    vector<int> v2(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        s += v[i];
        v2[i] = v[i];
    }
    sort(v2.begin(), v2.end());
    priority_queue<int, vector<int>, greater<int>> que;
    for (int i = 0; i < k - n; i++)
    {
        if (v2[i] < 0)
        {
            s -= v2[i];
        }
    }
    int mx = 0;
    if (n <= k)
    {
        mx = s;
    }
    for (int j = 0; j <= k; j++)
    {
        if (j >= n)
        {
            continue;
        }
        for (int i = 0; i < j; i++)
        {
            int t = 0;
            for (int k = 0; k < j; k++)
            {
                que.push(v[(k - i + n) % n]);
                t += v[(k - i + n) % n];
            }
            for (int i = 0; i < k - j; i++)
            {
                if (que.empty())
                    break;
                if (que.top() < 0)
                {
                    t -= que.top();
                    que.pop();
                }
                else
                {
                    break;
                }
            }
            mx = max(mx, t);
            while (!que.empty())
            {
                que.pop();
            }
        }
    }
    cout << mx << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;
using ll = long long;




struct UnionFind {
    vector<int> par; 

    UnionFind(int N) : par(N) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind tree(N);

    for (int i = 0; i < M; i++) {
        int  x, y;
        cin >> x >> y;
        tree.unite(x - 1, y - 1); 
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (!tree.same(0, i)) {
            tree.unite(0, i);
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3392
# AOJ 0118 Property Distribution 
# Python3 2018.6.23 bal4u
# 隣接する同種ものを集める、Unionセットに帰着

# UNION-FIND library
class UnionSet:
	def __init__(self, nmax):
		self.size = [1]*nmax
		self.id = [i for i in range(nmax+1)]
	def root(self, i):
		while i != self.id[i]:
			self.id[i] = self.id[self.id[i]]
			i = self.id[i]
		return i
	def connected(self, p, q): return self.root(p) == self.root(q)
	def unite(self, p, q):
		i, j = self.root(p), self.root(q)
		if i == j: return
		if self.size[i] < self.size[j]:
			self.id[i] = j
			self.size[j] += self.size[i]
		else:
			self.id[j] = i
			self.size[i] += self.size[j]
# UNION-FIND library

while 1:
	H, W = map(int, input().split())
	if H == 0 and W == 0: break
	tbl = ['']*H
	for r in range(H): tbl[r] = list(input())
	u = UnionSet(H*W)
	for r in range(H):
		for c in range(W):
			if c+1 < W and tbl[r][c] == tbl[r][c+1]: u.unite(r*W+c, r*W+c+1)
			if r+1 < H and tbl[r][c] == tbl[r+1][c]: u.unite(r*W+c, (r+1)*W+c)
	ans = 0
	for k in range(H*W):
		if u.root(k) == k: ans += 1
	print(ans)


Measured memory_bytes: 6272
#include<iostream>
#include<queue>
using namespace std;
const int MAX_H = 1000;
const int MAX_W = 1000;
const int MAX_N = 10;
char map[MAX_H][MAX_W];
bool visit[MAX_N][MAX_H][MAX_W];
int h, w, n;
struct node
{
	int x;
	int y;
	int l;
	int step;
};
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };
int main()
{
	int i, j, k;
	cin >> h >> w >> n;
	node s;
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			cin >> map[i][j];
			if (map[i][j] == 'S')
			{
				s.x = i;
				s.y = j;
				s.l = 0;
				s.step = 0;
			}
			for (k = 0; k < n; k++)
			{
				visit[k][i][j] = false;
			}
		}
	}
	queue<node> que;
	que.push(s);
	int curlevel = 0;
	bool flag = false;
	while (que.size())
	{
		node t = que.front(); que.pop();
		if (t.l < curlevel)continue;
		for (i = 0; i < 4; i++)
		{
			int xx = t.x + dx[i];
			int yy = t.y + dy[i];
			if (xx < 0 || xx >= h || yy < 0 || yy >= w)
			{
				continue;
			}
			if (visit[t.l][xx][yy])continue;
			if (map[xx][yy] == 'X')continue;
			if (map[xx][yy] == '.')
			{
				visit[t.l][xx][yy] = true;
				node n;
				n.x = xx;
				n.y = yy;
				n.l = t.l;
				n.step = t.step + 1;
				que.push(n);
			}
			else
			{
				if (map[xx][yy] > t.l + 1 + '0' || map[xx][yy] < t.l + 1 + '0')
				{
					node n;
					n.x = xx;
					n.y = yy;
					n.l = t.l;
					n.step = t.step + 1;
					que.push(n);
					continue;
				}
				else
				{
					if (map[xx][yy] == n + '0')
					{
						flag = true;
						cout << t.step + 1 << endl;
						break;
					}
					node n;
					n.x = xx;
					n.y = yy;
					n.l = t.l + 1;
					n.step = t.step + 1;
					visit[n.l][xx][yy] = true;
					curlevel++;
					que.push(n);
				}
			}
		}
		if (flag)break;
	}
	return 0;
}


Measured memory_bytes: 12868
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
const int maxn = 2e5 + 10;
ll qmod(ll a,ll n)
{
    ll ans = 1;
    while(n)
    {
        if (n & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}
int N, M, K;

ll fac[maxn], inv[maxn];

ll C(int n,int m)
{
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main()
{
    fac[0] = 1;
    for (int i = 1; i < maxn; ++i)
        fac[i] = fac[i - 1] * i % mod;
    inv[maxn - 1] = qmod(fac[maxn - 1], mod - 2);
    for (int i = maxn - 2; i >= 0; --i)
        inv[i] = inv[i + 1] * (i + 1) % mod;
    read(N), read(M), read(K);
    ll res = 0;
    for (int i = 0; i <= K; ++i)
    {
        res += M * C(N - 1, i) % mod * qmod(M - 1, N - i - 1) % mod;
        res %= mod;
    }
    printf("%lld\n", res);
}


Measured memory_bytes: 6828
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var n = Sarray()[0];
            var ai = Sarray();
            var sum = new long[] { ai[0], ai[0], -1, 1 };
            var cnt = new long[] { 0, 0, Abs(ai[0] + 1), Abs(ai[0] - 1) };
            if (ai[0] == 0)
            {
                sum[0] = 1;
                sum[1] = -1;
                cnt[0] = cnt[1] = 1;
            }
            for (var c = 0; c < 4; ++c)
            {
                for (var i = 1; i < n; ++i)
                {
                    var preSum = sum[c];
                    sum[c] += ai[i];
                    if (sum[c] * preSum < 0) continue;
                    cnt[c] += Abs(preSum + ai[i]) + 1;
                    sum[c] = (0 < preSum) ? -1 : 1;
                }
            }
            WriteLine(cnt.Min());
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 39012
print([((int(s[:2]) == 0 or int(s[:2]) > 12) and (int(s[2:]) == 0 or int(s[2:]) > 12)) * "NA" + (not (int(s[:2]) == 0 or int(s[:2]) > 12) and not (int(s[2:]) == 0 or int(s[2:]) > 12)) * "AMBIGUOUS" + ((int(s[:2]) == 0 or int(s[:2]) > 12) and not (int(s[2:]) == 0 or int(s[2:]) > 12)) * "YYMM" + (not (int(s[:2]) == 0 or int(s[:2]) > 12) and (int(s[2:]) == 0 or int(s[2:]) > 12)) * "MMYY" for s in [input()]][0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAXV = 1e5+5;
const int MAXN = 1e2+2;
const int MAX = 1e9;
int v[MAXN], w[MAXN];
int N, W, pd[MAXV];
int ans;

int main(int argc, char ** argv) {
    scanf("%d%d", &N, &W);
    rep(i, 1, MAXV) pd[i] = MAX+1;
    REP(i, 1, N)
        scanf("%d%d", w+i, v+i);
    REP(i, 1, N)
        PER(j, MAXV-2, v[i])
            pd[j] = min(pd[j], pd[j-v[i]] + w[i]);
    rep(i, 0, MAXV)
        if(pd[i] <= W) ans = i;
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4200
#include<bits/stdc++.h>
#include<cstring>
// #include<queue>
#include<vector>
#include<utility>
using namespace std;
int inf=1e9;
//vector<long long int>adj[10000];

int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];

	for(int i=0;i<n;i++)
	{
		c[i]=0;
		cin>>a[i]>>b[i];
		if(a[i]==b[i])c[i]=1;
	}
	for(int i=0;i<n-2;i++)
	{
		if(c[i]==1 && c[i+1]==1 && c[i+2]==1)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
int main (void){
    char inp;
    const char tei[]="aiueo";
    scanf("%c",&inp);
    if(strchr(tei,inp)==NULL){
        printf("consonant\n");
    }else{
        printf("vowel\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 3.41 + c[j] * 10.9;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int INF=1e10;
int32_t main()
{
    int n, w;
    cin>>n>>w;
    vector<int>dp(1000*n +1, INF);
    dp[0]=0;
    for(int i=0; i<n; ++i)
    {
        int weight, value;
        cin>>weight>>value;
        for(int j=1000*n; j>=value; --j)
        {
            dp[j]=min(dp[j], dp[j-value]+weight);
        }
    }
    int ans=0;
    for(int i=0; i<=1000*n; ++i)
    {
        if(dp[i]<=w)
            ans=max(ans, i);
    }
    cout<<ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b ;
  string str;
  if (a <= b){
  	for(int i = 0; i < b; i++)
    str += to_string(a);
  }
  else
    for (int i = 0; i < a; i++){
    str += to_string(b);
    }
  cout << str << endl;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;
use std::iter::*;

fn main() {
    let mut buffer = String::new();
    stdin().read_line(&mut buffer).unwrap();
    let n = buffer.trim().parse::<i64>().unwrap();
    buffer.clear();
    stdin().read_line(&mut buffer).unwrap();

    let inputs = buffer.split_whitespace().map(|x| x.parse::<i64>().unwrap());
    let v: Vec<i64> = FromIterator::from_iter(inputs);
    let avg = v.iter().sum::<i64>() / n;

    let c1 = v.iter().map(|x| (x - avg) * (x - avg)).sum::<i64>();
    let c2 = v.iter().map(|x| (x - avg - 1) * (x - avg - 1)).sum::<i64>();
    println!("{}", min(c1, c2));
}


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

A.sort()

for x in range(N):
    if A[x]>0:
        break

if x==0:
    x=1

if x==1:
    temp = A[0]
    ans = []
    for i in range(N-2):
        ans.append(str(temp)+" "+str(A[i+1]))
        temp-=A[i+1]
    ans.append(str(A[-1]) +" " + str(temp))
    temp=A[-1]-temp
elif x==N-1:
    temp = A[-1]
    ans = []
    for i in range(N-1):
        ans.append(str(temp)+" "+str(A[N-2-i]))
        temp-=A[N-2-i]
else:
    temp = A[0]
    ans = []
    for i in range(N-x-1):
        ans.append(str(temp)+" "+str(A[N-2-i]))
        temp-=A[N-2-i]
    temp1 = A[-1]
    for i in range(1,x):
        ans.append(str(temp1)+" "+str(A[i]))
        temp1-=A[i]
    ans.append(str(temp1)+" " + str(temp))
    temp = temp1-temp

print(temp)
for a in ans:
    print(a)
    


Measured memory_bytes: 65980
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint gcd( lint m, lint n )
{
	lint a=max(m,n),b=min(m,n);
	if(m==0) return n;if(n==0) return m;
	if(a%b==0) return b;
	return gcd(b,a-b*(a/b));
}
lint lcm( lint m, lint n )
{
	if(m==0) return n;if(n==0) return m;
	return ((m / gcd(m, n)) * n);
}
int main()
{
	lint out=1,a;int n;
	cin>>n;
	rep(i,n){
		cin>>a;out=lcm(out,a);
	}
	cout<<out<<endl;
}


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

int main(void){
	int a,b;

	cin >> a >> b;
	
	if(a==1)
		a=14;
	if(b==1)
		b=14;
	if(a>b)
		cout << "Alice" << endl;
	else if(a<b)
		cout << "Bob" << endl;
	else
		cout << "Draw" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
 
using ll = long long;
using namespace std;

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

int n, a;
pair<int,int> t[N];

int main() {
	scanf ("%d", &n);
	for (int j = 0; j < 2; ++j)
		for (int i = 0; i < n; ++i) {
			scanf ("%d", &a);
			t[j * n + i] = {a, j};
		}
	sort(t, t + n + n);
	int res = 1, bilans = 0;
	for (int i = 0; i < n + n; ++i) {
		int k = t[i].se;
		if (!k) k = -1;
		if (bilans * k >= 0)
			bilans += k;
		else {
			res = (ll) res * abs(bilans) % MOD;
			bilans += k;
		}
	}
	printf ("%d\n", res);
	return 0;
}


Measured memory_bytes: 5344
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>

int main(void) {
	using namespace std;
	/*int N, A,res;
	cin >> N >> A;
	res = N * N - A;
	cout << res << endl;*/

	/*int a, b,c;
	cin >> a >> b;
	c = a * b;
	c = c % 2;
	if (c == 0) {
		cout << "Even" << endl;
	}
	else if(c == 1){
		cout << "Odd" << endl;
	}*/

	/*int A, B, a, b, c;
	cin >> A >> B;
	a = A + B;
	b = A - B;
	c = A * B;
	if (a >= b && a >= c) {
		cout << a << endl;
	}
	else if (b >= a && b >= c) {
		cout << b << endl;
	}
	else if (c >= a && c >= b) {
		cout << c << endl;
	}*/

	/*int K, S,res = 0;
	cin >> K >> S;
	for (int X = 0; X <= K;X++) {
		for (int Y = 0; Y <= K; Y++) {
			for (int Z = 0; Z <= K; Z++) {
				if (X + Y + Z == S) {
					res += 1;
				}

			}
		}
	}
	cout << res << endl;*/

	/*int N,a;
	cin >> N;
	set<int>s;
	for (int i = 0; i < N;i++) {
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;*/

	/*int N, a, res;
	vector<int>vec;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		vec.push_back(a);
	}
	sort(vec.begin(), vec.end());
	res = vec[vec.size() - 1] - vec[0];
	cout << res << endl;*/

	/*int Alice = 0, Bob = 0,a,N;
	deque<int>dec;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		dec.push_back(a);
	}
	sort(dec.rbegin(), dec.rend());
	for (int i = 0; i < N;i++) {
		if (i % 2 == 0) {
			Alice += dec[0];
			dec.pop_front();
		}
		else if (i % 2 == 1) {
			Bob += dec[0];
			dec.pop_front();
		}
	}
	cout << Alice - Bob << endl;*/

	int A, B, C, X,res = 0;
	cin >> A >> B >> C >> X;
	for (int i = 0; i <= A;i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (i * 500 + j * 100 + k * 50 == X) {
					res += 1;
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
int main()
{
    char a[5];
    scanf("%s",&a);
    if(a[0]=='A'&&a[1]=='C'||a[1]=='A'&&a[2]=='C'||a[2]=='A'&&a[3]=='C'||a[3]=='A'&&a[4]=='C')
    printf("Yes");
    else
    printf("No");
} 

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		while (true) {
			if (isPrime(x)) {
				System.out.println(x);
				return;
			}
			x = x + 1;
		}
	}

	public static boolean isPrime(int num) {
		if (num < 2) {
			return false;
		} else if (num == 2) {
			return true;
		} else if (num % 2 == 0) {
			return false;
		}

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2) {
			if (num % i == 0) {
				return false;
			}
		}
		return true;
	}

}


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

using namespace std;

bool ok;
vector<int> ans;
vector<int> a;

void rec(int sum, vector<int>& cnt, vector<int>& v) {
  
  if(sum == 0) {
    ans = v;
    ok = true;
    return;
  }
  
  for(int i=1; i<=13; i++) {
    if(cnt[i] && sum % i == 0) {
      v.push_back(i);
      cnt[i] --;
      rec(sum-i, cnt, v);
      if(ok) return;
      cnt[i] ++;
      v.pop_back();
    }
  }
  
}

int main() {
  int n;
  
  while(cin >> n && n) {
    vector<int> a(n);
    vector<int> cnt(14, 0);
    int sum = 0;
    for(int i=0; i<n; i++) {
      cin >> a[i];
      cnt[a[i]] ++;
      sum += a[i];
    }
    
    vector<int> v;
    ok = false; rec(sum, cnt, v);
    
    if(ok) {
      reverse(ans.begin(), ans.end());
      int const N = ans.size();
      for(int i=0; i<N; i++) {
	if(i) cout << " " << ans[i];
	else cout << ans[i];
      }
      cout << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=(ll)(1e9+7);
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
ll MI(ll a,ll m=Mod) 
{ 
    ll m0=m; 
    ll y=0,x=1; 
    if(m==1) 
      return 0; 
    while(a>1) 
    {  
        ll q=a/m; 
        ll t=m; 
        m=a%m,a=t; 
        t=y;  
        y=x-q*y; 
        x=t; 
    } 
    if(x<0) 
       x+=m0; 
    return x; 
}  
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       ll n,i,k,ans=1;
       cin>>n>>k;
       vector <ll> v(n+1);
       for(i=1;i<=n;i++)
        cin>>v[i];
    //    for(i=1;i<=k;i++)
    //     ans*=v[i],ans%=Mod;
       //cout<<ans<<"\n";  
       for(i=k+1;i<=n;i++)
       { 
           if(v[i]>v[i-k])
            cout<<"Yes\n";
           else
            cout<<"No\n"; 
           /*ll x=ans*MI(v[i-k]);
           x%=Mod;
           x*=v[i];
           x%=Mod;
           //cout<<ans<<" "<<x<<"\n";
           if(x>ans)
            cout<<"Yes\n";
           else
            cout<<"No\n";
           ans*=MI(v[i-k]);
           ans%=Mod;
           ans*=v[i];
           ans%=Mod;  
           //cout<<ans<<'\n';*/
       }  
   }
}

Measured memory_bytes: 4780
#include<stdio.h>

int i,j,k,n;
double x[9],y[9];

int main(){
	scanf("%d",&n);
	while(n--){
		for(i=0;i<4;i++)scanf("%lf%lf",&x[i],&y[i]);
		if((x[1]-x[0])*(y[3]-y[2])==(y[1]-y[0])*(x[3]-x[2]))printf("YES\n");
		else if(x[1]==x[0] && x[3]==x[2])printf("YES\n");
		else if(y[1]==y[0] && y[3]==y[2])printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
for i in range(1, 6):
  if "hi"*i == S:
    print("Yes")
    break
else:
  print("No")
    

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  cout << ((n + 1) / 2 >= k ? "YES" : "NO") << '\n';
}

Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
using namespace std;

int main(void){
    long long a,b;
    int k;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> k;
    rep(i,k) {
        if(i%2 == 0) {
        if(a%2 == 1) a--;
        b += a/2;
        a /= 2;
        } else {
        if(b%2 == 1) b--;
        a += b/2;
        b /= 2;
        }
    }
    cout << a << " " <<  b << endl;
}

Measured memory_bytes: 256
def main():
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*N
    for i in range(1,N):
        dp[i]= min(abs(h[i]-h[j])+dp[j] for j in range(max(0,i-K),i))
    print(dp[-1])
main()

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n,weg;
	cin>>n>>weg;
	vector < pii > v;
	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		v.pb({a,b});
	}
	sort(v.begin(),v.end());
	ll dp[n][weg+1]={};
	for(ll i=1;i<=weg;i++){
		if(i>=v[0].first)dp[0][i] = v[0].second;
	}
	for(ll i=0;i<n;i++) dp[i][0] = 0;
	for(ll i=1;i<n;i++){
		for(ll j=1;j<=weg;j++){
			if(j-v[i].first > 0){
				dp[i][j] = max(dp[i-1][j] , v[i].second + dp[i-1][j-v[i].first]);
			}
			else dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[n-1][weg];
	return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	string ans;
	for(int i=0;i<n;i++)
	{
		ans+=s[i];
		ans+=t[i];

	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long w = sc.nextLong();
		long h = sc.nextLong();
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();
		System.out.println((double) (w * h) / 2.0 + ((x == (double) w / 2.0 && y == (double) h / 2.0) ? " 1" : " 0"));
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
 
int main() { 
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    printf("%c%c%c\n", s1[0]-32, s2[0]-32, s3[0]-32);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int h,w,a,b,c,blank,blankremain;
    scanf("%d %d",&h,&w);
    scanf("%d %d",&a,&b);
    blank=h*w;
    c=w*a+(h-a)*b;
    blankremain=blank-c;
    printf("%d",blankremain);

}


Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> per(n);
	vector<pair<int, int>> route(m);
	int ans = 0;
	ff(i, 0, m) {
		int a, b;
		cin >> a >> b;
		route.at(i).first = a;
		route.at(i).second = b;
	}
	ff(i, 0, n) {
		per.at(i) = i + 1;
	}
	do {
		int go = 0;
		ff(i, 0, n-1) {
			ff(j, 0, m) {
				if (per.at(i) == route.at(j).first ||
					per.at(i) == route.at(j).second) {
					if (per.at(i+1) == route.at(j).first ||
						per.at(i+1) == route.at(j).second) {
						go++;
					}
				}
			}
		}
		if (go == n - 1&&per.at(0)==1) {
			ans++;
		}

	} while (next_permutation(per.begin(), per.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, time = map(int, input().split())
path = [tuple(map(int, input().split())) for _ in range(n)]
mincost = 10 ** 9
for c, t in path:
    if t <= time:
        mincost = min(mincost, c)
if mincost == 10 ** 9:
    print('TLE')
else:
    print(mincost)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
using namespace std;

ostream& operator << (ostream &out, vector<int> &v) { for(auto a:v) out << a<<" "; out<<endl; }

pair<int,pair<int,int> > dp[3005][3005];

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

  int n=s.size();
  int m=t.size();
  //for(int i=0;i<n;i++) s[i][0]=mp(0,-1);
  //for(int j=0;j<m;j++) s[0][j]=mp(0,-1);
  for(int i=0;i<n;i++) for(int j=0;j<m;j++)
  {
    if(s[i]==t[j]) dp[i+1][j+1]= mp(1+dp[i][j].f,mp(i,j));
    if(s[i]!=t[j]){
      if(dp[i][j].f>dp[i+1][j].f)
        dp[i+1][j]=mp(dp[i][j].f,mp(i,j));
      if(dp[i][j].f>dp[i][j+1].f)
        dp[i][j+1]=mp(dp[i][j].f,mp(i,j));
    }
  }
  auto M=mp(0,mp(0,0));

  for(int i=0;i<=n;i++) for(int j=0;j<=m;j++)
  {
    if(dp[i][j].f>M.f)
      M=mp(dp[i][j].f,mp(i,j));
  }
  //cout << M.f<<" " << M.s.f<<" "<<M.s.s<<endl;

  auto curr=M.s;
  string res="";
  while(curr.f!=0 && curr.s!=0)
  {
    auto prev=dp[curr.f][curr.s].s;
    if(prev==mp(curr.f-1,curr.s-1))
      res+=s[curr.f-1];
    curr=prev;
  }
  reverse(all(res));
  cout << res<<endl;
}


Measured memory_bytes: 105984
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<array>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
static const int N=100;
static const int WHITE =0;
static const int GRAY=1;
static const int BLACK=2;
int n,M[N][N];//グラフの隣接行列
int color[N],d[N],f[N],tt;//状態
int nt[N];

int next(int u){
    
    for(int v=nt[u];v<n;v++){
        nt[u]=v+1;
        if(M[u][v])return v;
    }
    return -1;
}


void dfs_visit(int r){
    
    for(int i=0;i<n;i++)nt[i]=0;
    
    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    d[r]=++tt;
    
    while(!S.empty()){
        int u=S.top();
        int v=next(u);
        if(v!=-1){
            if(color[v]==WHITE){
                color[v]=GRAY;
                d[v]=++tt;
                S.push(v);
            }
        }else{
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
    
    
}

void dfs(){
    for(int i=0;i<n;i++){
        color[i]=WHITE;
        nt[i]=0;
    }
    tt=0;
    
    for(int u=0;u<n;u++){
        if(color[u]==WHITE){
           
            dfs_visit(u);
        }
    }
        for(int i=0;i<n;i++){
            cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
        }
}






int main(){

    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=0;
        }
    }
    
    
    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    
    
    
    dfs();
    
    
    
    
    

return 0;
}



Measured memory_bytes: 3140
import math
from collections import Counter

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

def comb2(n):
    return n * (n - 1) // 2

c = Counter(A)
ans = 0
for m in c.values():
    if m >= 2:
        ans +=comb2(m)

for i in range(N):
    print(ans - c[A[i]] + 1)

Measured memory_bytes: 88396
import fractions


def main():
    N = int(input())
    ans = int(input())
    for i in range(N-1):
        T = int(input())
        ans = (ans * T) // fractions.gcd(ans, T)  # 最小公倍数
        ans = int(ans)
    print(ans)


if __name__ == "__main__":
    main()


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

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<int> cnt;
  UnionFind(int n=1) {
    init(n);
  }
  void init(int n=1) {
    par.resize(n); rank.resize(n);
    cnt.resize(n);
    for (int i=0; i<n; i++) par[i]=i, rank[i]=0;
    for (int i=0; i<n; i++) cnt[i]=1;
  }
  int root(int x) {
    if (par[x] == x) return x;
    else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    cnt[y] += cnt[x];
    cnt[x] = cnt[y];
    return true;
  }
  int node_count(int x) {
    return cnt[root(x)];
  }
};

int main()
{
  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  UnionFind uf(n);
  vector<vector<int>> fol(n);
  for (int i=0; i<m; i++){
    int a, b; cin>>a>>b; a--; b--;
    uf.merge(a,b);
    fol[a].push_back(b);
    fol[b].push_back(a);
  }
  vector<vector<int>> blo(n);
  for (int i=0; i<k; i++){
    int c, d; cin>>c>>d; c--; d--;
    blo[c].push_back(d);
    blo[d].push_back(c);
  }
  rep(i, n) {
    int tmp = uf.node_count(i);
    tmp--;
    tmp -= (int)(fol[i].size());
    for (auto v:blo[i]) {
      if (uf.issame(i, v)) tmp--;
    }
    if (i>0) cout << " ";
    cout << tmp;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 13048
MOD = 1e9 + 7
n = int(input())
ans = [[0, 1, 1, 8]]
for i in range(n-1):
    a, b, c, d = ans.pop()
    a = (a * 10 + b + c) % MOD
    b = (b * 9 + d) % MOD
    c = (c * 9 + d) % MOD
    d = (d * 8) % MOD
    ans.append([a, b, c, d])

a, b, c, d = ans.pop()
print(int(a))

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

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


Measured memory_bytes: 3116
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(long long i=(long long)(m);i<(long long)(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

struct S {
    LL x,y,z;
};

void solve() {
    LL n,m,x,y,z;
    cin >> n >> m;
    vector<S> a(n);
    REP(i,0,n) {
        cin >> x >> y >> z;
        a[i].x = x;
        a[i].y = y;
        a[i].z = z;
    }
    LL ans = 0;
    REP(i,0,8) {
        VLL b(n);
        REP(j,0,n) {
            LL tmp = a[j].x * (LL)((i & 1)?1:-1) + a[j].y * (LL)((i & 2)?1:-1) + a[j].z * (LL)((i & 4)?1:-1);
            b[j] = tmp;
        }
        LL cnt = 0;
        sort(all(b));
        reverse(all(b));
        REP(j,0,m) {
            // if (b[j] < 0) break;
            cnt += b[j];
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

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

int main()
{
    string x;
    cin >> x;
    int len = x.size();

    int s = 0,ans = 0;
    for (int i = 0; i < len; i++)
    {
        if(x[i] == 'S')s++;
        else
        {
            if(s > 0)
            {
                s--;
            }
            else
            {
                ans++;
            }
        }
    }
    
    cout << ans + s << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;


int main(){

  int k,x;cin>>k>>x;

  if(k*500>=x)out("Yes");
  else out("No");




  return 0;
}


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

#define REP(i, a, b) for(int i = (a); i < (b); ++i)

int main() 
{
    int N, L;
    cin >> N >> L;
    vector<string> P(N);
    REP(i, 0, N) cin >> P[i];
    sort(P.begin(), P.end());
    REP(i, 0, N) cout << P[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256