akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
const double PI=3.14159265358979323846;
 
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {

	int k, n;
	cin >> k >> n;

	int dis[n];
	rep(i, n) {
		cin >> dis[i];
	}

	int max = 0;
	rep(i, n - 1) {
		int diff = dis[i + 1] - dis[i];
		if (max < diff) max = diff;
	}
	int diff = (k - dis[n - 1]) + dis[0];
	if (max < diff) max = diff;

	int ans = k - max;


	cout << ans << endl;
}



Measured memory_bytes: 1024
a = [0]*55556
N = int(input())
for i in range(2,55556):
    for j in range(2*i,55556,i):
        a[j] += 1
A = []
for i in range(2,55556):
    if a[i]==0 and i%5==1:
        A.append(str(i))
print(' '.join(A[:N]))

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

bool valid(string S){
  int n=S.size();
  rep(i,n-3+1){
    if(S.substr(i,3)=="AGC")return false;
  }
  return true;
}

bool check(string S){
  int n=S.size();
  rep(i,n-1){
    string tmp=S;
    swap(tmp[i],tmp[i+1]);
    if(!valid(tmp))return false;
  }
  return valid(S);
}

ll n;
string s="AGCT";
ll dp[101][4][4][4];

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

  cin>>n;

  rep(a,4)rep(b,4)rep(c,4){
    string tmp;
    tmp+=s[a]; tmp+=s[b]; tmp+=s[c];
    if(check(tmp))dp[3][a][b][c]=1;
  }

  repl(i,3,n)rep(a,4)rep(b,4)rep(c,4){
    rep(d,4){
      string tmp;
      tmp+=s[a]; tmp+=s[b]; tmp+=s[c]; tmp+=s[d];
      if(check(tmp))(dp[i+1][b][c][d]+=dp[i][a][b][c])%=mod;
    }
  }
  ll res=0;
  rep(a,4)rep(b,4)rep(c,4)(res+=dp[n][a][b][c])%=mod;
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main() {

	string s;
	cin >> s;
	bool OK = true;
	for (int i = 0; i < s.length(); i++)
	{
		if ((i + 1) % 2 != 0) {
			if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
				OK = false;
				break;
			}
			
		}
		else {
			if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
				OK = false;
				break;
			}
		}
		
	}

	if (OK) cout << "Yes";
	else cout << "No";

	
}



Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



def main():
    A, B, C, D = map(int, input().split())

    alice = [A <= t < B for t in range(100)]
    bob   = [C <= t < D for t in range(100)]

    cnt = 0
    for t in range(100):
        if alice[t] and bob[t]:
            cnt += 1

    print(cnt)

if __name__ == "__main__": main()


Measured memory_bytes: 4080
#include<stdio.h>
#include<algorithm>
#define reg register
#define ri reg int
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define nrep(i, x, y) for(ri i = x; i >= y; --i)
#define DEBUG 1
#define ll long long
#define max(i, j) (i) > (j) ? (i) : (j)
#define min(i, j) (i) < (j) ? (i) : (j)
struct IO {
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
	char buf[MAXSIZE], *p1, *p2;
	char pbuf[MAXSIZE], *pp;
	#if DEBUG
	#else
		IO() : p1(buf), p2(buf), pp(pbuf) {}
		~IO() {
			fwrite(pbuf, 1, pp - pbuf, stdout);
		}
	#endif
	inline char gc() {
		#if DEBUG
    		return getchar();
		#endif
    	if(p1 == p2)
			p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    	return p1 == p2 ? ' ' : *p1++;
	}
	inline bool blank(char ch) {
    	return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
	}
	template <class T>
	inline void read(T &x) {
    	register double tmp = 1;
    	register bool sign = 0;
    	x = 0;
    	register char ch = gc();
    	for(; !isdigit(ch); ch = gc())
    		if(ch == '-') sign = 1;
    	for(; isdigit(ch); ch = gc())
			x = x * 10 + (ch - '0');
    	if(ch == '.')
			for(ch = gc(); isdigit(ch); ch = gc())
        		tmp /= 10.0, x += tmp * (ch - '0');
    	if(sign) x = -x;
	}
	inline void read(char *s) {
		register char ch = gc();
		for(; blank(ch); ch = gc());
		for(; !blank(ch); ch = gc())
			*s++ = ch;
    	*s = 0;
	}
	inline void read(char &c) {
    	for(c = gc(); blank(c); c = gc());
	}
	inline void push(const char &c) {
		#if DEBUG
    		putchar(c);
		#else
    		if(pp - pbuf == MAXSIZE) {
				fwrite(pbuf, 1, MAXSIZE, stdout);
				pp = pbuf;
			}
    		*pp++ = c;
		#endif
	}
	template <class T>
	inline void write(T x) {
    	if(x < 0) {
			x = -x;
			push('-');
		}
    	static T sta[35];
    	T top = 0;
    	do {
			sta[top++] = x % 10;
			x /= 10;
    	}while(x);
    	while(top)
			push(sta[--top] + '0');
	}
	template <class T>
	inline void write(T x, char lastChar) {
    	write(x);
		push(lastChar);
	}
} io;
int l[110], n, ans;
int main() {
	io.read(n);
	rep(i, 1, n) io.read(l[i]);
	std::sort(l + 1, l + n + 1);
	rep(i, 1, n) rep(j, i + 1, n) rep(k, j + 1, n) if(l[i] + l[j] > l[k] && l[i] != l[j] && l[i] != l[k] && l[j] != l[k]) ++ans;
	io.write(ans);
}

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

int main(){
  int n,i;
  char s[101];
  char t[101];
  char r[201];
  
  scanf("%d", &n);
  scanf("%s %s", &s, &t);
  
  for(i=0;i<n;i++)
  {
    r[i*2] = s[i];
    r[i*2+1] = t[i];
  }
  
  r[2*n] = s[n];
  
  printf("%s",r);
  
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	long[] s, t;
	void Solve()
	{
		var I = G;
		int A = I[0], B = I[1], Q = I[2];
		s = MakeArray(A, _ => FL);
		t = MakeArray(B, _ => FL);
		foreach (var q in MakeArray(Q, _ => FL))
		{
			var m = long.MaxValue;
			var a2 = GetBesides(q, s);
			var b2 = GetBesides(q, t);
			foreach (var a in a2) foreach (var b in b2) m = Min(m, Min(Abs(q - a), Abs(q - b)) + Abs(a - b));
			WriteLine(m);
		}
	}
	long[] GetBesides(long x, long[] s)
	{
		var j = FirstBinary(0, s.Length, i => s[i] >= x);
		if (j <= 0) return new[] { s[0] };
		else if (j >= s.Length) return new[] { s[s.Length - 1] };
		return new[] { s[j - 1], s[j] };
	}
	public static int FirstBinary(int min, int max, Predicate<int> pred)
	{
		while (min < max)
		{
			var mid = (min + max) / 2;
			if (pred(mid)) max = mid;
			else min = mid + 1;
		}
		return min;
	}
}


Measured memory_bytes: 18604
n,m = map(int,input().split())
swi = []
for i in range(m):
    lis = list(map(int,input().split()))
    swi.append(lis[1:])
p = list(map(int,input().split()))
cnt = 0

for bit in range(2**n):
    lis = []
    for i in range(n):
        if ((bit >> i) & 1):
            lis.append(i+1)
            
    for j in range(m):
        if len(set(swi[j]) & set(lis)) % 2 == p[j]:
            ans = True
        else:
            ans = False
            break
    if ans:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (n, a, b) = readLongList()

    var ans = n / (a + b) * a

    ans += if (n % (a + b) > a) a
    else n % (a + b)

    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

int main() {
  int n, m;
  cin >> n >> m;

  vector<pair<int, int>> sc;
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    sc.emplace_back(s, c);
  }

  sort(sc.begin(), sc.end());

  bool left_zero = false;

  vector<int> ans(n, -1);
  for (int i = 0; i < m; ++i) {
    int s = sc[i].first;
    if (s > n) {
      cout << -1 << endl;
      return 0;
    }
    if (s == 1 && sc[i].second == 0)
      left_zero = true;

    if (ans[s - 1] == -1)
      ans[s - 1] = sc[i].second;
    else {
      if (ans[s - 1] != sc[i].second) {
        cout << -1 << endl;
        return 0;
      }
    }
  }

  if (n != 1 && left_zero) {
    cout << -1 << endl;
    return 0;
  }

  if (n != 1 && ans[0] == -1)
    ans[0] = 1;

  for (int i = 0; i < n; ++i)
    if (ans[i] == -1)
      ans[i] = 0;

  int tmp = ans[0];
  for (int i = 1; i < n; ++i)
    tmp *= 10, tmp += ans[i];

  cout << tmp << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> d(n);
  for(int i=0;i<n;i++){
    cin >> d.at(i);
  }
  int m;
  cin >> m;
  vector<ll> t(m);
  for(int i=0;i<m;i++){
    cin >> t.at(i);
  }
  if(n<m)
  cout << "NO" << endl;
  else{
    sort(d.begin(),d.end());
    sort(t.begin(),t.end());
    int k=0;
    for(int i=0;i<m;i++){
      for(int j=k;j<n;j++){
        if(t.at(i)==d.at(j)){
          k=j+1;
          break;
        }
        else if(j==n-1){
          cout << "NO" << endl;
          return 0;
        }
      }
    }
    cout << "YES" << endl;
  }
}



Measured memory_bytes: 6364
#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 inf        1000000000000000000
#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 t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll a[n];
		for(ll i=0;i<n;i++){
			cin>>a[i];
		}
		string s;
		cin>>s;
		vi v;
		bool flag=false;
		for(ll i=n-1;i>=0;i--){
			ll val = a[i];
			for(ll j=0;j<v.size();j++){
				val = min(val , val^v[j]);
			}
			if(val!=0){
				if(s[i]=='1'){
					cout<<1;
					flag=true;
					break;
				}
				v.pb(val);
			}
		}
		if(!flag) cout<<0;
		cout<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 3624
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	string s;
	cin >> s;
	int q;
	cin >> q;
	bool tt=false;
	int cnt=0;
	for(int i=0;i<q;i++){
		int t;
		cin >> t;
		if(t==1){
			if(tt)tt=false;
			else tt=true;
		}else{
			int f;
			cin >> f;
			char p;
			cin >> p;
			if(f==1){
				if(!tt)s.insert(s.begin(),p);
				else s+=p;
			}else{
				if(!tt)s+=p;
				else s.insert(s.begin(),p);
			}
		}	
	}
	if(tt){
		reverse(s.begin(),s.end());
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3904
#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
#define ONLINE_JUDGE
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
inline void solve() {
    int n, x, t; cin >> n >> x >> t;
    cout << (int)ceil((double)n / x)*t << endl;
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3724
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;
#define maxN 100001
vii G(maxN, vi());

int memo[maxN];

int longestPath(int i){
    int ans = 0;
    if(memo[i] >= 0) return memo[i];
    int childLen = G[i].size();
    if(childLen){
        for(int j=0; j<childLen; j++){
            ans = max(ans, 1 + longestPath(G[i][j]));
        }
    }
    memo[i] = ans;
    return ans;
}

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, 0, M){
        int x, y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }
    rep(i, 0, maxN) memo[i] = -1;
    int ans = 0;
    rep(i, 0, N) ans = max(ans, longestPath(i));
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 8192
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 401

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
int N;
int A[SIZE];
long long dp[SIZE][SIZE];
long long pref[SIZE];
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen(fi, "r", stdin);
    #endif */
    //freopen("route.in","r",stdin);
    //freopen("route.out","w",stdout);
    //cin.ignore();
    //cin.clear();
    boost;
    //cin.tie(0);
    //cout<<"Case "<<tt<<": ";
    int N;
    cin>>N;
    for(int i=1;i<=N;i++){
      cin>>A[i];
      pref[i] = pref[i-1] + A[i];
    }
    for(int i=0;i<SIZE;i++){
      for(int j=0;j<SIZE;j++){
        dp[i][j] = LLONG_MAX;
      }
    }
    for(int i=1;i<=N;i++){
      dp[i][i] = 0;
    }
    for(int i=2;i<=N;i++){
      for(int j=1;j<=N-i+1;j++){
        int srt = j;
        int end = srt+i-1;
        for(int k=srt;k<end;k++){
          dp[srt][end] = min(dp[srt][end],dp[srt][k]+dp[k+1][end]+pref[end]-pref[srt-1]);
        }
      }
    }
    /*for(int i=1;i<=N;i++){
      for(int j=i;j<=N;j++){
        cout<<dp[i][j]<<" ";
      }
      cout<<endl;
    }*/
    cout<<dp[1][N]<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> m(h);
	REP(i,h) cin >> m[i];
	int sx, sy;
	REP(i,h) REP(j,w) if(m[i][j] == '%') {sx = i, sy = j;}

	VVI d(h,VI(w));
	d[sx][sy] = 1;
	queue<P> que;
	que.push(make_pair(sx, sy));
	while (!que.empty()){
		P p = que.front();
		que.pop();
		int i = p.first, j = p.second;
		int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
		REP(k,4){
			int ii = i + dx[k], jj = j + dy[k];
			if (ii < 0 || jj < 0 || ii >= h || jj >= w) continue;
			if (m[ii][jj] == '#' || d[ii][jj] > 0) continue;
			d[ii][jj] = d[i][j] + 1;
			que.push(make_pair(ii, jj));
		}
	}
	int p, s;
	s = 1e9;
	REP(i,h) REP(j,w){
		if (m[i][j] == '@') p = d[i][j];
		if (m[i][j] == '$') s = min(s, d[i][j]);
	}
	cout << (p < s ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3304
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int[] xs;

bool input() {
    xs = readln.chomp.split(" ").map!(to!int).array;
    return xs[0] != -1;
}

void solve() {
    auto used = new bool[11];
    foreach (x; xs) {
        if (x == 0) continue;
        used[ x - 1 ] = true;
    }
    auto F = xs.dup;

    bool check() {
        //writeln(F);
        int M = F[9];
        int s = F[0 .. 3].reduce!"a + b" % M;
        auto dirs = [ [ 0, 1, 2 ],
                      [ 3, 4, 5 ],
                      [ 6, 7, 8 ],
                      [ 0, 4, 8 ],
                      [ 2, 4, 6 ],
                      [ 0, 3, 6 ],
                      [ 1, 4, 7 ],
                      [ 2, 5, 8 ] ];
        foreach (dir; dirs) {
            int sum = 0;
            foreach (index; dir) {
                sum += F[index];
            }
            if (sum % M != s) return false;
        }
        return true;
    }

    int ans = 0;
    void dfs(int index) {
        if (index == 10) {
            ans += check();
            return;
        }
        if (F[index] == 0) {
            foreach (int i; 0 .. 10) {
                if (used[i]) continue;
                used[i] = true;
                F[index] = i + 1;
                dfs(index + 1);
                F[index] = 0;
                used[i] = false;
            }
        } else {
            dfs(index + 1);
        }
    }
    dfs(0);
    writeln(ans);
}

void main() {
    while (input) solve;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int X, t; cin >> X >> t;
    int d = X - t;
    cout << (d > 0 ? d : 0) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>

const int N = 100; 
const int B = 10; 

char s[N + 5]; 
int n, k; 
int dp[B + 5][5][N + 5]; 

int main() {

    dp[0][0][0] = 1;
    s[0] = '0';
    scanf("%s", s + 1); 
    scanf("%d", &k); n = strlen(s + 1); 
    for (int i = 1, j = n; i < j; i ++, j --)
        std::swap(s[i], s[j]); 

    if (n == 1 && s[n] == '0') {
        printf("%s\n", k == 0 ? "1" : "0");
        return 0;
    }
    
    for (int i = 1; i < n; i ++) {
        for (int j = 0; j < B; j ++) 
            for (int x = (j > 0); x <= k; x ++) {
                for (int y = 0; y < B; y ++)
                    dp[j][x][i] += dp[y][x - (j > 0)][i - 1];
            }
    }

    for (int j = 0; j < s[n] - '0'; j ++) 
        for (int x = (j > 0); x <= k; x ++) {
            for (int y = 0; y < B; y ++)
                dp[j][x][n] += dp[y][x - (j > 0)][n - 1];
        }
    
    for (int bb = n - 1, cc = 1; bb >= 0 && cc <= k; bb --) {
        //for (int j = 0; j < s[bb] - '0'; j ++) 
        for (int y = 0; y < s[bb] - '0'; y ++)
            dp[s[n] - '0'][k][n] += dp[y][k - cc][bb];
        if (s[bb] - '0')
            cc ++; 
        if (bb == 0) dp[s[n] - '0'][k][n] += dp[0][k - cc][bb];
    }

    int ans = 0;
    for (int i = 0; i <= s[n] - '0'; i ++) 
        ans += dp[i][k][n];

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

    return 0; 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template<class T>
T gcd(T n,T m){
    if(n>m) return gcd(m,n);
    else if(n==0) return m;
    else return gcd(m-n*(m/n),n);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll a,b;
    in>>a>>b;
    cout<<a*b/gcd(a,b)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
//inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}

int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}


int a[N],f[N],s[N];
int main(){
    //srand(time(NULL)+clock());
    int ca=0,T,k,i,j,m=0,n,K;
    scanf("%d",&n);
    rep(i,0,n)scanf("%d",&a[i]);
    f[1]=1;
    rep(i,2,n+1)f[i]=(mod-mod/i*(ll)f[mod%i]%mod)%mod;
    rep(i,1,n+1)s[i]=(s[i-1]+f[i])%mod;
    ll w=1;
    rep(i,2,n+1)w=w*i%mod;
    ll ans=0;
    rep(i,0,n){
        ll v=(s[i+1]+s[n-i]-f[1])%mod;
        ans+=v*a[i]%mod;
    }
    ans%=mod;
    if(ans<0)ans+=mod;
    ans=ans*w%mod;
    printf("%d\n",ans);
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,sum=0,sum1=0,i;
    for (i=1;i<=3;i++)
    {
        cin>>a;
        if (a==5) sum++;
        else if (a==7) sum1++;
    }
    if (sum==2&&sum1==1) cout<<"YES";
    else cout<<"NO";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=100005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
vi gr[N];
int vis[N];
int dis[N];
void dfs(int u){
	vis[u]=1;
	int mx=0;
	for(int i=0;i<gr[u].size();i++){
		int v=gr[u][i];
		if(!vis[v]) dfs(v);
		mx=max(mx,dis[v]);
	}
	dis[u]=1+mx;
}
int main(){
	fast
	int n,m,x,y;
	cin>>n>>m;
	FOR0(m){
		cin>>x>>y;
		gr[x].pb(y);
	}
	mem(vis,0);mem(dis,0);
	FORQ(1,n){
		if(!vis[i]) dfs(i);
	}
	int mx=0;
//	FORQ(1,n) cout<<dis[i]<<" ";cout<<endl;
	FORQ(1,n) mx=max(mx,dis[i]);
	cout<<mx-1; 
}



Measured memory_bytes: 9216
if ARGV[0]=="LOCAL_DEV"
  define_method("debug") do |var|
    p var
  end
else
  define_method("debug") do |var|
  end
end

#https://atcoder.jp/contests/abc051/tasks/abc051_c
ax,ay,bx,by=STDIN.gets.strip.split.map(&:to_i)
ans=[]
(by-ay).times do
  ans<<'U'
end
(bx-ax).times do
  ans<<'R'
end
(by-ay).times do
  ans<<'D'
end
(bx-ax).times do
  ans<<'L'
end
ans<<'L'
(by-ay+1).times do
  ans<<'U'
end
(bx-ax+1).times do
  ans<<'R'
end
ans<<'D'
ans<<'R'
(by-ay+1).times do
  ans<<'D'
end
(bx-ax+1).times do
  ans<<'L'
end
ans<<'U'
ans.each do |a|
  print a
end
puts ''


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

bool is_leap_year(int y);
int  get_leap_years(int list[], int begin, int end);

int main(void)
{
    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない

    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので

    while (true) {
        int year_begin, year_end;

        //読み込み
        scanf("%d %d", &year_begin, &year_end);

        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }

        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }

        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (int i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }

    }
}

int get_leap_years(int list[], int begin, int end)
{
    int cnt = 0;
    int year;
    for (year = begin; year <= end; year++) {
        if (is_leap_year(year)) {
            list[cnt] = year;
            cnt++;
        }
    }

    return cnt;
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true;
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

Measured memory_bytes: 1048
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		int K=sc.nextInt();
		int sum=0;
		
		for(int i=0;i<A;i++) {
			if(K>0) {
				sum+=1;
				K-=1;
			}
		}
		for(int i=0;i<B;i++) {
			if(K>0) {
				K-=1;
			}
		}
		for(int i=0;i<C;i++) {
			if(K>0) {
				sum-=1;
				K-=1;
			}
		}
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 35932
def makearray()
  $n = gets.to_i
  $a = []
  $b = []
  for k in 0..$n-1
    $b[k] = []
    for l in 0..$n+1
      $b[k][l] = 0
    end
  end
  for i in 0..$n-1
    $a[i] = gets.split(' ').map(&:to_i)
    if $a[i][1] > 0
      for j in 2..$a[i][1]+1
        c = $a[i][j] - 1
        $b[i][c] = 1
      end
    end
  end
end

def dfs(i)
  if $b[i][$n] == 0
    $b[i][$n] = $t
  end
  $t += 1
  for j in 0..$n-1
    if $b[i][j] == 1 && $b[j][$n] == 0
      dfs(j)
    end
  end
  $b[i][$n+1] = $t
  $t += 1
end

makearray()
$t = 1
for i in 0..$n-1
  if $b[i][$n] == 0
    dfs(i)
  end
end
for i in 0..$n-1
  print i+1
  print ' '
  print $b[i][$n]
  print ' '
  puts $b[i][$n+1]
end

Measured memory_bytes: 7100
#include <stdio.h>
#include <iostream>

using namespace std;

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

long a(int N) {
    if (N == 0) return 1;
    else return 2 * a(N - 1) + 3;
}

long p(int N) {
    if (N == 0) return 1;
    else return 2 * p(N - 1) + 1;
}

long f(int N, long X) {
    if (N == 0) {
        if (X <= 0) return 0;
        else return 1;
    } else if (X <= a(N - 1) + 1) {
        return f(N - 1, X - 1);
    } else {
        return p(N - 1) + 1 + f(N - 1, X - 1 - a(N - 1) - 1);
    }
}

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

    long X;
    cin >> X;

    cout << f(N, X) << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000



int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    string S; cin >> S;
    int sum[100010] = {};
    REP(i, 1, S.length() - 1) {
        if (S[i] == 'C' && S[i - 1] == 'A') sum[i + 1]++;
    }
    rep(i, S.length()) sum[i + 1] += sum[i];
    //rep(i, S.length()) cout << sum[i] << endl;
    rep(i, Q) {
        int l, r; cin >> l >> r;
        cout << sum[r] - sum[l] << endl;
    }

    return 0;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	#endif
	int n,a,b;
	cin>>n>>a>>b;
	vector<ll> h(n);
	for(int i=0;i<n;i++)cin>>h[i];
	ll md,lo=0,hi=1e9;
	while(lo < hi){
		md = (lo + hi)/2;

		ll cur=0;
		for(int i=0;i<n;i++){
			if(md * b >= h[i])continue;
			ll dif = a-b;
			ll sum = h[i] - md * b;
			ll x = (sum + dif - 1)/dif;
			cur += x;
		}
		// if(md == 2)cout << cur << endl;
		// cout << cur << ' ' << md << endl;
		if(cur <= md){
			hi = md;
		}else{
			lo = md+1;
		}

	}
	cout << hi << endl;
}

Measured memory_bytes: 1024
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 101
int par[MAX_N];
int rank[MAX_N];

typedef struct {
    int p1;
    int p2;
    int weight;
} graph;

void init(int n) {
    for (int i = 0; i <= n; i++) {
        par[i] = i;
        rank[i] = 0;
    }
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
        return;
    }
    if (rank[x] < rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
    }
}

int same(int x, int y) { return find(x) == find(y); }

int comp(const void* c1, const void* c2);

int main() {
    int n, m, count, slim;
    graph edge[4950];

    while (1) {
        scanf("%d %d", &n, &m);
        if (n == 0) break;

        for (int i = 0; i < m; i++) {
            scanf("%d %d %d", &edge[i].p1, &edge[i].p2, &edge[i].weight);
        }

        qsort(edge, m, sizeof(graph), comp);
        slim = -1;
        for (int i = 0; i < m; i++) {
            int w = 0;
            init(n);
            unite(edge[i].p1, edge[i].p2);
            count = 1;
            for (int j = i + 1; j < m; j++) {
                if (!same(edge[j].p1, edge[j].p2)) {
                    unite(edge[j].p1, edge[j].p2);
                    count++;
                    w = edge[j].weight - edge[i].weight;
                }
            }
            if (count == n - 1) slim = slim == -1 ? w : (slim > w ? w : slim);
        }
        printf("%d\n", slim);
    }
    return 0;
}

int comp(const void* c1, const void* c2) { return (*(graph*)c1).weight - (*(graph*)c2).weight; }

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    rep(i, n)
    {
        ll x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll y = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        if (!x || !y)
        {
            continue;
        }

        ans += (x * y);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll N,K;
    cin>>N>>K;
    v A(N);
    v p,m;
    bool zero;
    rep(i,0,N){
        cin>>A[i];
        if(A[i] >= 0)p.push_back(A[i]);
        else m.push_back(-A[i]);
    }

    sort(all(p));
    sort(all(m));
    ll ans = 1;
    if(K == N){
        rep(i,0,p.size()){
            ans *= p[i];
            ans%=MOD;
        }
        rep(i,0,m.size()){
            ans *= m[i];
            ans %= MOD;
        }
        if(m.size()%2 == 1){
            ans *= -1;
            ans += MOD;
            ans %=MOD;
        }
    }
    else if(p.size() == 0){
        if(K%2 == 0){
            rep(i,0,K){
                ans *= m[m.size()-1-i];
                ans %= MOD;
            }
        }
        else{
            rep(i,0,K){
                ans *= m[i];
                ans%=MOD;
            }
            ans *= -1;
            ans += MOD;
            ans%=MOD;
        }
    }
    else{
        ll i = p.size()-1;
        if(p.empty())i = -1;
        ll j = m.size()-1;
        if(m.empty())j = -1;
        while(K > 0){
            if(K%2 == 1){
                ans *= p[i];
                i--;
                K--;
            }
            else if(i >= 1 && j >= 1){
                K-=2;
                if(p[i] * p[i-1] > m[j] * m[j-1]){
                    ans *= p[i];
                    ans %= MOD;
                    ans *= p[i-1];
                    ans %= MOD;
                    i-=2;
                }
                else{
                    ans *= m[j];
                    ans %= MOD;
                    ans *= m[j-1];
                    ans %= MOD;
                    j-=2;
                }
            }
            else if(i < 1){
                K-=2;
                ans *= m[j];
                ans %= MOD;
                ans *= m[j-1];
                ans %= MOD;
                j-=2;
            }
            else if(j < 1){
                K-=2;
                ans *= p[i];
                ans %= MOD;
                ans *= p[i-1];
                ans %= MOD;
                i-=2;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6840
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = min(a, b) + min(c, d);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>

using ll = long long;

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

    std::vector<char> str;
    for (int i = 0; i < S.length(); i++) {
        char c = S[i];
        if (c == 'B') {
            if (!str.empty())str.erase(str.end() - 1);
        }
        else {
            str.emplace_back(c);
        }
    }

    for (int i = 0; i < str.size(); i++) {
        std::cout << str[i];
    }
    std::cout << std::endl;
    return 0;
}

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

int main() {
   int N;
   cin >> N;
   int S , H , J , I ;
   S = N / 1000;
   N = N % 1000;
   H = N / 100;
   N = N % 100;
   J = N / 10;
   N = N % 10;
   I = N;
   if(S == H && H == J){
   		cout << "Yes" << endl;
   }else if(H == J && J == I){
   		cout << "Yes" << endl;
   }else{
   		cout << "No" << endl;
   }
}


Measured memory_bytes: 3580
#include<stdio.h>
int main()
{
  int A[100];
  int N;
  int i,j,tmp,minj;
  int cnt=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i=0;i<N-1;i++)
    {
      minj=i;
      for(j=i;j<N;j++)
	{
	  if(A[j]<A[minj])
	  minj=j;
	}
      tmp=A[i];
      A[i]=A[minj];
      A[minj]=tmp;
      if(A[i]!=A[minj])cnt++;
    }
	  

  for(i=0;i<N;i++)
    {
      printf("%d",A[i]);
      if(i!=N-1) printf(" ");
    }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 604
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx")

#include <bits/stdc++.h>

using namespace std;

#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 1e6 + 10;

int cnt[maxn];

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int res = 0;
        int d = 1;
        while (d * d <= a[i]) {
            if (a[i] % d == 0) {
                res += cnt[d];
                if (d != a[i] / d) {
                    res += cnt[a[i] / d];
                }
            }
            d++;
        }
        if (n - res == n - 1) {
            ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 7880
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 998244353;
const int maxn = 3e5+10;
const int N = 1e5+10;
const int E = 2e5+10;  
ll n;

int main(){
	cin>>n;
	ll sum = 0;
	F(i,1,n){
		if(i%3!=0&&i%5!=0) sum+=i;
	}
	cout<<sum<<endl;
}

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

using namespace std;

int main()
{
	string name; int a, b;

	for (int i = 0; i < 9; i++)
	{
		cin >> name >> a >> b;

		cout << name << ' ' << a + b << ' ' << a * 200 + b * 300 << endl;
	}

	return 0;
}

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


int main(){
  long long N;
  cin >> N;
  vector<pair<long long,long long>> V(2010);
  for(int i = 1; i<= N; i++){
    long long A;
    cin >> A;
    V[i] = make_pair((-1)*A, i);
  }
  
  sort(V.begin(), V.end());
  
  vector<vector<long long>> dp(2010, vector<long long> (2010, 0));
  
  for(int  x = 0; x<=N; x++){
    for(int y = 0; x+y<=N; y++){
      if(x==0&&y==0){
        continue;
      }
      else if(x == 0){
        dp[x][y] = dp[x][y-1]+(-1)*V[x+y-1].first*(abs(V[x+y-1].second-N+y-1));   
      }
      else if(y == 0){
        dp[x][y] = dp[x-1][y]+(-1)*V[x+y-1].first*(abs(V[x+y-1].second-x));      
      }
      else{
        dp[x][y] = max(dp[x-1][y]+(-1)*V[x+y-1].first*(abs(V[x+y-1].second-x)), dp[x][y-1]+(-1)*V[x+y-1].first*(abs(V[x+y-1].second-N+y-1))); 
      }
    }
  }
  
  /*
  for(int x = 0; x<=N; x++){
    for(int y = 0; x+y<=N; y++){
      cout << dp[x][y] << " ";
    }
    cout << endl;
  }
  
  rep(i,N){
    cout << V[i].first << " " << V[i].second << endl;
  }
  */
  
  long long ans = 0;
  for(long long x = 0; x<=N; x++){
    ans =  max(ans, dp[x][N-x]);
  }
  cout << ans << endl;
  
    
}

      
  
  




Measured memory_bytes: 34932
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=1e4+4;
const int MAX_D=1e2+2;
const int MOD=1000000007;

string K;
int D;
ll dp[MAX_N][MAX_D];
ll ans;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>K>>D;
	reverse(K.begin(),K.end());
	K[0]++;
	for(int i=0;i<(int)K.size()-1;i++) if(K[i]-'0'>9) K[i]-=10, K[i+1]++;
	if(K.back()-'0'>9) K.back()-=10, K.push_back('1');
	dp[0][0]=1;
	for(int i=0;i<(int)K.size();i++) for(int j=0;j<D;j++) for(int d=0;d<=9;d++)
		dp[i+1][(j+d)%D]=(dp[i+1][(j+d)%D]+dp[i][j])%MOD;
	for(int i=K.size()-1,d=0;i>=0;i--) for(int j=0;j<K[i]-'0';j++,d++)
		ans=(ans+dp[i][(D-(d%D))%D])%MOD;
	cout<<(ans-1+MOD)%MOD<<'\n';
	return 0;
}



Measured memory_bytes: 8192
import collections

N = int(input())
S = [list(input()) for _ in range(N)]
S2 = ['0' for _ in range(N)]
for i in range(N):
    S[i].sort()
    S2[i] = ' '.join(S[i])

c = collections.Counter(S2)
ans = 0
for i in c.values():
    if i==1:continue
    ans += (i-1)*(i)//2
    
    
print(ans)




Measured memory_bytes: 41716
using System;

namespace A___Round_Up_the_Mean
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = double.Parse(input[0]);
            var b = double.Parse(input[1]);
            var x = Math.Ceiling((a + b) / 2);
            Console.WriteLine(x);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){

  int W,H,x,y,r;

  cin >>W>>H>>x>>y>>r;

  if(x+r>W||y+r>H||x-r<0||y-r<0){

  cout <<"No"<< endl;

  }

  else{

    cout <<"Yes"<< endl;
  }
  return 0;

}

Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int main()
{
    int k,l,la,lb,ans,stat,poi;
    char a[205],b[205];
    scanf("%s",a);//getchar();
    while(a[0]!='.' || a[1]!='\0')
    {
        scanf("%s",b);//getchar();
        ans=stat=k=l=poi=0;
        la=strlen(a);lb=strlen(b);
        while(1)
        {
            if(a[k]=='"' && b[l]=='"')
            {
                if(stat)stat=0;
                else stat=1;
            }
            if(a[k]==b[l])
            {
                k++;l++;
                if(k==la || l==lb)
                {
                    if(k!=la || l!=lb)ans=2;
                    break;
                }
            }
            else
            {
                while(a[k]!='"' && k<la)k++;
                while(b[l]!='"' && l<lb)l++;
                if(stat)
                {
                    if(poi)
                    {
                        ans=2;
                        break;
                    }
                    else
                    {
                        poi++;
                        ans=1;
                    }
                }
                else
                {
                    ans=2;
                    break;
                }
            }
        }
        if(ans==0)printf("IDENTICAL\n");
        if(ans==1)printf("CLOSE\n");
        if(ans==2)printf("DIFFERENT\n",ans);
        scanf("%s",a);
    }
    return 0;
}



Measured memory_bytes: 3156
use std::io::*;
use std::str::FromStr;

fn main() {
    let a: usize = read();
    let b: usize = read();
    println!("{}", 6 - a - b);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352