akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int max = 0;
    if(k>a){
        k -= a;
        max += a;
    }
    else if(k<=a){
        max += k;
        k = 0;
    }
    if(k > b){
        k -= b;
    }
    else if(k <= b){
        k = 0;
    }
    if(k>0){
        max -= k;
    }
    cout << max;
}

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

int main() {
   ll n, x;
   cin >> n;
   vector<ll>v;
   for (ll i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
   }
   ll ans = 0;

   for (ll i = 0; i < n - 1; i++) {
    if(v[i] > v[i+1]) {
        ans += v[i] - v[i+1];
    }
   }
   ans += v[n-1];
   cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3620
def main():
    n,m = map(int,input().split())

    if n == 1 and m == 1:
        print(1)
    elif n == 1 and m > 1:
        print(m-2)
    elif n > 1 and m == 1:
        print(n-2)
    else:
        print((n-2) * (m-2))

if __name__ == "__main__":
        main()


Measured memory_bytes: 2940
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-5,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  ll N,K;
  cin >> N >> K ;
  vl a(N);
  rep(i,N) cin >> a[i] ;
  ll X = 0;
  bool g = false; // X<K 確定 : 1, それまで同じ : 0
  RREP(i,50,0){
    if((1LL<<i)>K) continue;
    if(!g && ((K>>i)&1)==0) continue;
    int cnt = 0;
    rep(j,N) if((a[j]>>i)&1) cnt++;
    if(cnt<N-cnt) X ^= (1LL<<i);
    else g = true;
    dump(i,cnt,g);
  }
  dump(X);
  ll ans = 0;
  rep(i,N) ans += (a[i]^X);
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    Int N;
    vector<vector<Int>> Y;

    bool check(Int bit) {
        for (int i = 0; i < N; ++i) {
            if (!(bit >> i & 1)) continue; // lier musi

            for (int j = 0; j < N; ++j) {
                if (Y[i][j] == 1) {
                    if (!(bit >> j & 1)) return false;
                } else if (Y[i][j] == 0) {
                    if (bit >> j & 1) return false;
                }
            }
        }

        return true;
    }

    void solve() {
        cin >> N;
        Y.resize(N, vector<Int>(N, -1)); // -1 : no infor, 0 : false, 1 : true
        for (int i = 0; i < N; ++i) {
            Int a;
            cin >> a;
            for (int j = 0; j < a; ++j) {
                Int x, y;
                cin >> x >> y;
                x--;
                Y[i][x] = y;
            }
        }

        Int ans = 0;
        for (Int bit = 0; bit < 1 << N; ++bit) {
            if (check(bit)) {
                Int cnt = __pop_count((unsigned) bit);
                chmax(ans, cnt);
            }
        }
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstdint>
#include <utility>
#include <algorithm>
#include <vector>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  int cur = 0;
  for (size_t i = 0; i < n; ++i) {
    if (cur+1 == a[i]) {
      ++cur;
    }
  }
  if (cur == 0) return puts("-1"), 0;
  printf("%zu\n", n-cur);
}


Measured memory_bytes: 1024
using namespace std;

#include<bits/stdc++.h>

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define All(v) v.begin(),v.end()
#define sortA(a) sort(a, a+n)
#define sortArr(a, i, n) sort(a+i, a+n)
#define SortArr(a, i, n) sort(a+i, a+n+1)
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second
#define concatenate(a, b) std::copy(b.begin(), b.end(), std::back_inserter(a));
#define fcout(x) cout << fixed << setprecision(x)
#define ifcout(x, a, b) if(x) cout << a << '\n'; else cout << b << '\n'
// #define concatenate(a, b) a.insert(b.end(), b.begin(), b.end());
// std::move(b.begin(), b.end(), std::back_inserter(a)); "Undefined behaviour if a actually is b (which is OK if you know that can never happen - but worth being aware of in general purpose code)"
#define makeUnique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define inRange(x, a, b) (a <= x && x < b)

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printMap(m) for(auto it = m.begin(); it!=m.end(); it++) (it==m.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

ll f(ll y) {
	
	if (y <= 1) return y;
	
	return f(y-1) + f(y-2);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	if (n == m)
		cout << "Yes\n";
	else
		cout <<"No\n";
	
	
	return 0;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N;
	cin >> N;
	vector<int> S;
	int sum = 0;

	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		sum = sum + a;
		S.push_back(a);
	}
	sort(S.begin(), S.end());
	cout << sum - S[S.size()-1]/2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            std::deque<int> deq;
            for (int i=0;i<n;i++) {
                cin>>a;
                deq.emplace_back(a);
            }
            std::map<int, int> map;
            int count=0;
            while (1) {
                map.clear();
                count++;
                for (int i=0;i<n;i++) {
                    map[deq[i]]++;
                }
                int tmp=0;
                for (int i=0;i<n;i++) {
                    if (deq[i]==map[deq[i]]) {
                        tmp++;
                    } else {
                        deq[i]=map[deq[i]];
                    }
                }
                if (tmp==n) {
                    cout<<count-1<<endl;
                    for (int i=0;i<n;i++) {
                        cout<<deq[i];
                        if (i!=n-1) {
                            cout<<" ";
                        } else {
                            cout<<endl;
                        }
                    }
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 3108
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a_list = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for a in a_list:
    tmp = 0
    for i in range(m):
        tmp += a[i]*b[i]
    else:
        if tmp + c > 0:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (b != 100) {
		if (a == 0) cout << b;
		if (a == 1) cout << b * 100;
		if (a == 2) cout << b * 10000;
	}
	else {
		if (a == 0) cout << b+1;
		if (a == 1) cout << b * 100+100;
		if (a == 2) cout << b * 10000+10000;
	}
}


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

int main()
{
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if(M1 != M2 && D2 == 1) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
 * Problem     : AOJ0013
 * Title       : Switching Railroad Cars
 * Author      : mizo0203
 * Copyright   : Your copyright free
 * Description : スタック
 */

#include <stdio.h>
#include <stack>
using namespace std;

int cn; // car number or 0
stack<int> st;

bool input() {

  if (scanf("%d", &cn) == EOF)
    return false;

  return true;
}

int main() {

  while (input()) {
    if (cn) st.push(cn);
    else {
      printf("%d\n", st.top());
      st.pop();
    }
  }

  return 0;
}

Measured memory_bytes: 0
num = 0
b = "+"
while True:
  a = input()
  if b == "+":
    num += a
  elif b == "-":
    num -= a
  elif b == "*":
    num *= a
  elif b == "/":
    num /= a
  b = raw_input()
  if b == "=":
    print num
    break

Measured memory_bytes: 4208
import itertools
import math

n = int(input())
fac = math.factorial(n-1)

ll = [i for i in range(0, n)]
con = list(itertools.combinations(ll, 2))
cnt = len(con)

ls = []
for i in range(n):
    x, y = map(int, input().split())
    ls.append([x, y])

ans = []
for i, j in con:
    ans.append(((ls[i][0] - ls[j][0])**2 + (ls[i][1]-ls[j][1])**2)**0.5)

print(sum(ans)/(n/2))


Measured memory_bytes: 3188
N = int(input())
H = [int(x) for x in input().split()]
# print(N,H)
result = "Yes"
top = 0
for i in range(len(H)):
    if (H[i] < top-1 ):
        result = "No"
        break
    top = max(top, H[i])

print(result)

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

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

        String input;
        int hit = 0;
        int blow = 0;

        while((input = br.readLine()) != null){
            String[] a = input.split(" ");
            String[] b = br.readLine().split(" ");

            hi:
            for(int i = 0; i < 4; i++){
                if(a[i].equals(b[i])){
                    hit++;
                    a[i] = "";
                    b[i] = "";
                }
            }

            bl:
            for(int i = 0; i < 4; i++){
                if(a[i].equals("")){
                    continue bl;
                }

                for(int j = 0; j < 4; j++){
                    if(a[i].equals(b[j])){
                        blow++;
                    }
                }
            }

            System.out.printf("%d %d%n", hit, blow);
            hit = 0;
            blow = 0;
        }
    }
}


Measured memory_bytes: 24780
""" AtCoder """

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

count = 0

while True:
    for i in range(N):
        if A[i] % 2 == 1:
            print(count)
            exit()
    A = list(map(lambda x: x//2, A))
    count += 1


Measured memory_bytes: 3060
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
for i in range(10**n):
  if len(str(i))==n and all(str(i)[s-1]==str(c) for s,c in sc):
    print(i)
    break
else:
  print(-1)

Measured memory_bytes: 9128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.printf("%d %d %.5f\n", a / b, a % b, (double)a / b);
	}
}



Measured memory_bytes: 26356
#include <stdio.h>
#include <math.h>

int main(){
	int a,b,c,n,i,r;
	double l1,l2,l3;

	while(1){
		scanf("%d %d %d",&a,&b,&c);
		if(a == 0 && b == 0 && c == 0){
			break;
		}
		l1 = sqrt(pow(a*1.0,2)+pow(b*1.0,2));
		l2 = sqrt(pow(b*1.0,2)+pow(c*1.0,2));
		l3 = sqrt(pow(c*1.0,2)+pow(a*1.0,2));

		scanf("%d",&n);

		for(i = 0;i < n;i++){
			scanf("%d",&r);
			if(l1 < r*2.0){
				printf("OK\n");
			}else if(l2 < r*2.0){
				printf("OK\n");
			}else if(l3 < r*2.0){
				printf("OK\n");
			}else{
				printf("NA\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 584
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
template<typename T>
pair<T,int>diameter_dfs(vector<vector<pair<int,T> > >&G,int u,int p)
{
	pair<T,int>ans(0,u);
	for(pair<int,T>&e:G[u])
	{
		if(e.first!=p)
		{
			pair<T,int>q=diameter_dfs(G,e.first,u);
			q.first+=e.second;
			ans=max(ans,q);
		}
	}
	return ans;
}
template<typename T>
T diameter(vector<vector<pair<int,T> > >&G)
{
	pair<T,int>p=diameter_dfs(G,0,-1);
	pair<T,int>q=diameter_dfs(G,p.second,-1);
	return q.first;
}
int n;
main()
{
	cin>>n;
	vector<vector<pair<int,int> > >G(n);
	for(int i=0;i<n-1;i++)
	{
		int s,t,w;cin>>s>>t>>w;
		G[s].push_back(make_pair(t,w));
		G[t].push_back(make_pair(s,w));
	}
	cout<<diameter(G)<<endl;
}


Measured memory_bytes: 15860
#pragma comment(linker,"/STACK:1024000000,1024000000")
//std::ios::sync_with_stdio(false)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#define INF 0X3F3F3F3F
#define MOD 2147493647
#define egs 1e-30
#define LL long long
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define FF(i,a,b) for(int i=a; i<=b; i++)
#define RR(i,a,b) for(int i=a; i>=b; i--)
#define FC(i,a,b) for(int i=a; i<b; i++)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define PRR(x,y) printf("%d %d\n",x,y)
#define CL(a,x) memset(a,x,sizeof(a))
#define MID int mid=((l+r)>>1)
#define lson x<<1,l,mid
#define rson x<<1|1,mid+1,r
#define root int x,int l,int r
#define F(x) ((x)/3+((x)%3==1?0:tb))
#define G(x) ((x)<tb?(x)*3+1:((x)-tb)*3+2)
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define MAIN 1000010
#define MAXN 1010
using namespace std;
int movex[4]= {1,-1,0,0};
int movey[4]= {0,0,1,-1};
int main()
{
    int h,w;
    while(cin>>h>>w)
    {
        string str[60];
        for(int i=0; i<h; i++) cin>>str[i];
        bool judge=true;
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
            {
                if(str[i][j]=='#')
                {
                    bool flag=false;
                    for(int k=0; k<4; k++)
                    {
                        int nxtx=i+movex[k],nxty=j+movey[k];
                        if(nxtx>=0&&nxtx<h&&nxty>=0&&nxty<w)
                        {
                            if(str[nxtx][nxty]=='#')
                            {
                                flag=true;
                                break;
                            }
                        }
                    }
                    if(!flag)
                    {
                        judge=false;
                        break;
                    }
                }
            }
        if(judge) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    double rr;
    int n;
    cin >> rr >> n;
    if(rr==0) return 0;
    vector<int> t(42,0);
    int l,r,hh;
    rep(i,n){
      cin >> l >> r >> hh;
      l+=21,r+=21;
      repp(j,l,r){
        t[j]=max(t[j],hh);
      }
    }
    double ans=IINF;
    double x,y;
    repp(i,20-rr+1,20+rr){
      x=abs(i-20);
      y=min(t[i],t[i+1]);
      // cout << i-20 SP y SP y-sqrt(rr*rr-x*x)+rr << endl;
      ans=min(ans,y-sqrt(rr*rr-x*x)+rr);
    }
    cout << fixed << setprecision(10) << ans << endl;
  }
  return 0;
}



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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    set<string> used;
    used.insert(s);
    for(int i = 1; i < n; i++){
        string t;   cin >> t;
        if(used.count(t) || s[s.length()-1] != t[0]){
            cout << "No" << endl;
            return 0;
        }
        used.insert(t);
        s = t;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int n;

  std::cin >> n;

  std::string s[55], t;

  for (int i = 0; i < n; i ++) {
    std::cin >> s[i];

    std::sort(ALL(s[i]), std::greater<char>());
  }

  for (char c = 'a'; c <= 'z'; c ++) {
    int lm = INF;

    for (int i = 0; i < n; i ++) {
      int l = 0;

      for ( ; ! s[i].empty() && s[i].back() == c; l ++)
        s[i].pop_back();

      lm = std::min(l, lm);
    }

    t += std::string(lm, c);
  }

  std::cout << t << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        int c=scanner.nextInt();
        if(a<b && b<c && a<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26356
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N[3], K;
ll A[3][1010];
//---------------------------------------------------------------------------------------------------
inline ll get(int a, int b, int c) { return A[0][a] + A[1][b] + A[2][c]; }
int check(ll x) {
	int cnt = 0;
	rep(a, 0, N[0]) rep(b, 0, N[1]) rep(c, 0, N[2]) {
		if (get(a, b, c) < x) break;
		cnt++;
		if (K <= cnt) return 1;
	}
	return 0;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	rep(i, 0, 3) cin >> N[i];
	cin >> K;
	rep(i, 0, 3) rep(j, 0, N[i]) cin >> A[i][j];
	rep(i, 0, 3) sort(A[i], A[i] + N[i], greater<ll>());

	ll ok = 0, ng = infl;
	while (ok + 1 != ng) {
		ll md = (ng + ok) / 2;
		if (check(md)) ok = md;
		else ng = md;
	}

	vector<ll> ans;
	rep(a, 0, N[0]) rep(b, 0, N[1]) rep(c, 0, N[2]) {
		if (get(a, b, c) < ok) break;
		ans.push_back(get(a, b, c));
	}
	while (ans.size() < K) ans.push_back(ok);

	sort(all(ans), greater<ll>());
	rep(i, 0, K) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 132444
# include "iostream"
# include "algorithm"
# include "cstdio"
# include "vector"

using namespace std;

const int maxm=1e5+10;

int N,Mod,head[maxm],tot;
int Father[maxm],Step;
long long DP[maxm],DP2[maxm];
vector<long long> Num[maxm],Left[maxm],Right[maxm];

struct edge{
	int To;
	int Next;
	# define To(x) Edge[x].To
	# define Next(x) Edge[x].Next
}Edge[maxm<<1];

inline void Add_Edge(int From,int To){Edge[++tot]=(edge){To,head[From]};head[From]=tot;return;}
inline void Insert_Edge(int x,int y){Add_Edge(x,y),Add_Edge(y,x);return;}

void Dfs(int now){
	DP[now]=1;
	for(int i=head[now];i;i=Next(i)){
		if(To(i)==Father[now]) continue;
		long long Number;
		Father[To(i)]=now;
		Dfs(To(i));
		Number=(1+DP[To(i)])%Mod;
		Number=(Number+Mod)%Mod;
		DP[now]=DP[now]*Number%Mod;
		Num[now].push_back(Number);
	}
	return;
}

inline void Work(int now){
	register int i;
	register long long Result;
	sort(Num[now].begin(),Num[now].end());
	Result=1;
	Left[now].push_back(1);
	for(i=0;i<Num[now].size();i++){
		Result=(Result*Num[now][i])%Mod;
		Left[now].push_back(Result);
	}
	Result=1;
	Right[now].push_back(1);
	for(i=Num[now].size()-1;i>=0;i--){
		Result=(Result*Num[now][i])%Mod;
		Right[now].push_back(Result);
	}
	return;
}

void Dfs2(int now){
	if(now==1){
		DP2[now]=DP[now];
		Work(now);
	}else{
		long long Now,Number;
		Number=(DP[now]+1)%Mod;
		Number=(Number+Mod)%Mod;
		Step=(lower_bound(Num[Father[now]].begin(),Num[Father[now]].end(),Number)-Num[Father[now]].begin());
		Now=(Left[Father[now]][Step]*Right[Father[now]][Num[Father[now]].size()-Step-1])%Mod;
		Number=(Now+1)%Mod;
		Number=(Number+Mod)%Mod;
		Num[now].push_back(Number);
		DP2[now]=Number*DP[now]%Mod;
		Work(now);
	}
	for(int i=head[now];i;i=Next(i)){
		if(To(i)==Father[now]) continue;
		Dfs2(To(i));
	}
	return;
}

int main(){
	register int i;
	int x,y;
	long long Result;
	scanf("%d%d",&N,&Mod);
	for(i=1;i<N;i++){
		scanf("%d%d",&x,&y);
		Insert_Edge(x,y);
	}
	Dfs(1);
	Dfs2(1);
	for(i=1;i<=N;i++){
		printf("%lld\n",DP2[i]);
	}
	return 0;
}

Measured memory_bytes: 32256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;


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

if((s[1]!=s[0]&&s[1]!=s[3])||s[1]!=s[2])
    cout<<"No"<<endl;
else
    cout<<"Yes"<<endl;
 return 0;
}


Measured memory_bytes: 3600
K, N = map(int, input().split())
mod = 998244353
def inved(a):
  x, y, u, v, k, l = 1, 0, 0, 1, a, mod
  while l != 0:
    x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
    k, l = l, k % l
  return x % mod

X = [0 for i in range(2*K-1)]
frac = [1]
for i in range(N + K):
  frac.append(((i+1)*frac[i])%mod)
invf = []
for i in range(N + K + 1):
  invf.append(inved(frac[i]))
for k in range(2, K+2):
  S = 0
  sign = 1
  l = k // 2
  for m in range(min(l+1, N//2+1)):
    prod = (sign * (frac[l]*frac[N+K-2*m-1])) % mod
    prod *= (invf[m]*invf[l-m]) % mod
    prod %= mod
    prod *= (invf[N-2*m] * invf[K-1]) % mod
    prod %= mod
    S += prod
    S %= mod
    sign *= -1
  X[k-2], X[2*K-k] = S, S
for i in range(2*K-1):
  print(X[i])

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using	namespace	std;
#define ll long long
#define	llu	unsigned	long	long
#define	ld	double
#define	llu	unsigned	long	long
#define	rep(i,x,y)		for(ll	i=x;i<y;++i)
#define	For(i,x,y)		for(ll	i=x;i<=y;++i)
#define	FOr(i,x,y)		for(ll	i=(ll)(x);i>=(ll)(y);--i)
#define	pi	acos(-1)	
#define	mk	make_pair
#define	pa	pair<ll,ll>
#define	lf	else	if
#define	IL	inline
#define	max(x,y)				((x)<(y)?(y):(x))
#define	min(x,y)				((x)<(y)?(x):(y))
#define	sqr(x)						((x)*(x))
#define	Mul(x,y)				((x)=1LL*(x)*(y)%mod)
#define	Add(x,y)				((x)=((x)+(y))%mod)
#define	Max(x,y)				((x)=((x)<(y)?(y):(x)))
#define	Min(x,y)				((x)=((x)>(y)?(y):(x)))
#define	E(x)					return	writeln(x),0
#define	LL						(long	long)
#define	p(x)					prllf("~%lld~\n",LL(x))
#define	pp(x,y)					prllf("~~%lld	%lld~~\n",LL(x),LL(y))
#define	ppp(x,y,z)				prllf("~~~%lld	%lld	%lld~~~\n",LL(x),LL(y),LL(z))
#define	pppp(a,b,c,d)			prllf("~~~%lld	%lld	%lld	%lld\n",LL(a),LL(b),LL(c),LL(d))
#define	f_in(x)					freopen(x".in","r",stdin)
#define	f_out(x)				freopen(x".out","w",stdout)
#define	open(x)					f_in(x),f_out(x)
#define	fi	first
#define	se	second
#define	GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef	complex<double>	E;
namespace	SHENZHEBEI{
#ifdef	LOCAL
				struct	_{_(){freopen("cf.in","r",stdin);}}_;
#endif	
#define	NEG	1
				inline	char	gc(){	return	getchar();	}
#if	NEG
				inline	ll	read(){				ll	x=0,fa=1;	char	ch=gc();			for	(;!isdigit(ch);ch=gc())	if	(ch=='-')	fa=-1;		for	(;isdigit(ch);ch=gc())		x=x*10-48+ch;			return	x*fa;	}
				inline	void	write(ll	x){				if	(x<0)	putchar('-'),x=-x;		if	(x>=10)			write(x/10);				putchar(x%10+'0');		}
#else
				inline	ll	read(){				ll	x=0;	char	ch=gc();			for	(;!isdigit(ch);ch=gc());				for	(;isdigit(ch);ch=gc())		x=x*10-48+ch;			return	x;			}
				inline	void	write(ll	x){				if	(x>=10)			write(x/10);				putchar(x%10+'0');		}
#endif
	void	writeln(ll	x){write(x);puts("");}
}using	namespace	SHENZHEBEI;
const ll mod=1e9+7,N=1000010;
ll f[N],ans=0,n,fac[N],inv[N],chos[N],before;
ll ppow(ll x,ll k){ll ans=1;for(;k;k>>=1,Mul(x,x))if(k&1)Mul(ans,x);return ans;}
ll C(ll n,ll k){return (n>=k)?(fac[n]*inv[k]%mod*inv[n-k]%mod):0ll;}
int main(){
	n=read();
	fac[0]=1;For(i,1,n)fac[i]=fac[i-1]*i%mod;
	inv[n]=ppow(fac[n],mod-2);FOr(i,n,1)inv[i-1]=inv[i]*i%mod;
	For(i,0,n)	f[i]=C(n-i-2,i)*fac[n-i-1]%mod*fac[i]%mod;
	For(i,0,n)	Add(f[i],-f[i+1]);
	For(i,0,n)	Add(ans,(n-i-1)*f[i]);
	writeln((ans+mod)%mod);
}
/*
ooooo
oo**o**
simga
n/p>=i*i
n/(i*i)>=p
sigma(i=1..sqrt(n),i是质数)	min(n/i*i,sqrt(n))

去掉3个合法-> 
OO**OO
*/

Measured memory_bytes: 25344
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

a, b = input_nums()

a_rate = 0.08
b_rate = 0.1

al = int(a / a_rate)
ar = int((a+1) / a_rate)
bl = int(b / b_rate)
br = int((b+1) / b_rate)

ans = 0
if bl <= al and al < br:
    ans = al
elif al <= bl and bl < ar:
    ans = bl
else:
    ans = -1

if not ans == -1 and int(ans*0.08) < a:
    ans += 1
    if int(ans*0.1) > b:
        ans = -1
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M,K;
    cin >> N >> M >> K;
    vector<int> l(M),r(M),c(M);
    vector<vector<P>> G(N);
    for(int i=0; i<M; i++){
        cin >> l[i] >> r[i] >> c[i];
        l[i]--;r[i]--;
        G[l[i]].emplace_back(r[i],c[i]);
        G[r[i]].emplace_back(l[i],c[i]);
    }
    priority_queue<P,vector<P>,greater<P>> que;
    vector<int> dist(N,inf);
    for(int i=0; i<K; i++){
        int a;
        cin >> a;
        a--;
        dist[a] = 0;
        que.emplace(0,a);
    }
    while(que.size()){
        int v = que.top().second;
        int cost = que.top().first;
        que.pop();
        if(cost > dist[v]) continue;
        for(auto nv: G[v]){
            if(nv.second + cost < dist[nv.first]){
                dist[nv.first] = nv.second + cost;
                que.emplace(dist[nv.first],nv.first); 
            }
        }
    }
    // for(int i=0; i<N; i++){
    //     cout << dist[i] << enld;
    // }
    int ans = 0;
    for(int i=0; i<N; i++){
        chmax(ans,dist[i]);
        for(auto nv: G[i]){
            int v = nv.first;
            int t = (dist[v]+dist[i]+nv.second+1)/2;
            chmax(ans,t);
        }
    }
    cout << ans << enld;
    return 0;
}



Measured memory_bytes: 7152
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll mod = 1000000007LL;

// aのb乗を求める.
ll modpow(ll a, ll b) {
	if (a > mod) a %= mod;
	if (b == 0LL) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b & 1LL)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

// aの逆元を求める.
ll inverse(ll a) {
	return modpow(a, mod - 2);
}

// kの階乗を計算する.(sgnを0以外に設定すると逆元を返す)
ll fact(ll k, int sgn = 0) {
	static vector<ll> fac(2, 1LL);
	static vector<ll> inv(2, 1LL);
	static vector<ll> finv(2, 1LL);
	static ll nx = 2LL;
	while (nx <= k) {
		fac.push_back(fac[nx - 1] * nx % mod);
		inv.push_back(mod - inv[mod % nx] * (mod / nx) % mod);
		finv.push_back(finv[nx - 1] * inv[nx] % mod);
		++nx;
	}
	if (sgn == 0)
		return fac[k];
	return finv[k];
}

// aCbを計算する.
ll comb(ll a, ll b) {
	if (b < 0 || b > a) return 0;
	return fact(a) * fact(b, 1) % mod * fact(a - b, 1) % mod;
}

int main() {
	ll n, a, b, c;
	cin >> n >> a >> b >> c;
	ll A = a * inverse(a + b), B = b * inverse(a + b);
	ll res = 0;
	for (ll x = 0; x < n; ++x) {
		ll tmp1 = comb(n + x - 1LL, x);
		ll tmp2 = n + x;
		ll tmp3 = modpow(A, x) * modpow(B, n) % mod;
		ll tmp4 = modpow(B, x) * modpow(A, n) % mod;
		ll tmp = tmp1 * ((tmp3 + tmp4) % mod) % mod * tmp2 % mod;
		res += tmp;
		res %= mod;
	}
	res *= 100 * inverse(100 - c) % mod;
	res %= mod;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6620
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main () {
cin >> a >> b;
	if (a<b) {
		if (a == 1) {
			cout << "Alice" << endl;
		} else {
			cout << "Bob" << endl;
		}
}
	else if (a == b) {
		cout << "Draw" << endl;
	}
	else {
		if (b == 1) {
			cout << "Bob" << endl;
		} else {
			cout << "Alice" << endl;
		}
	}
}



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

int main() {
    int ans[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << ans[K-1] << endl;
}

Measured memory_bytes: 256
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

x,y = map(int,input().split())

if (x in a) and (y in a):
    print("Yes")
elif (x in b) and (y in b):
    print("Yes")
elif (x in c) and (y in c):
    print("Yes") 
else:
    print("No")


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

double dist(vector<int> p1, vector<int> p2){
    int dx = p1[0] - p2[0];
    int dy = p1[1] - p2[1];
    return pow( dx*dx + dy*dy ,0.5);
}

int main(){

    int N; cin>>N;
    vector<vector<int>> Map(N, vector<int>(2));
    for(int n=0; n<N; n++) cin>>Map[n][0]>>Map[n][1];

    // 順列全探索
    vector<int> ptn(N); for(int n=0; n<N; n++) ptn[n]=n;
    double all_dist = 0;
    int cnt=0;
    do{
        double cnt_dist =0;
        for(int i=1; i<N; i++) cnt_dist += dist(Map[ptn[i-1]], Map[ptn[i]]);
        all_dist += cnt_dist;
        cnt++;
    } while(next_permutation(ptn.begin(), ptn.end()));

    cout <<fixed<<setprecision(10)<<(all_dist/cnt)<< endl;
}

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

char b;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> b;
  if(b == 'A'){
    cout << 'T' <<endl;
  }
  if(b == 'T'){
    cout << 'A' <<endl;
  }
  if(b == 'C'){
    cout << 'G' <<endl;
  }
  if(b == 'G'){
    cout << 'C' <<endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 305;
int n, a[N][N], b[N][N];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) fw (j, 0, n) cin >> a[i][j];
	int ans = 0;
	memset(b, 63, sizeof b);
	fw (i, 0, n) fw (j, 0, n) if (i != j) {
		bool haveMid = 0;
		fw (k, 0, n) if (k != i && k != j) if (a[i][k] + a[k][j] == a[i][j]) haveMid = 1;
		if (!haveMid) ans += a[i][j], b[i][j] = a[i][j];
	}
	fw (i, 0, n) b[i][i] = 0;
	fw (k, 0, n) fw (i, 0, n) fw (j, 0, n) b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
	fw (i, 0, n) fw (j, 0, n) if (a[i][j] != b[i][j]) {
		cout << "-1";
		return 0;
	}
	cout << ans / 2;
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        int b=scan.nextInt();
        if(a<b) System.out.println("a < b");
        else if(a>b) System.out.println("a > b");
        else System.out.println("a == b");
    }
}


Measured memory_bytes: 26200
#include <iostream>
#include <algorithm>

using namespace std;

bool check(int a[12], int b[12], int n)
{
	bool f = true;
	
	for(int i = 0; i < n; i++){
		if(a[i] != b[i]){
			f = false;
			break;
		}
	}
	
	return f;
}

int main()
{
	int n;
	
	while(cin>>n && n){
		int a[12], b[10000], c[12], t=0, s;
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		fill(c, c+n, -1);
		while(1){
			fill(b, b+10000, 0);
			for(int i = 0; i < n; i++){
				b[a[i]]++;
			}
			s = 1;
			for(int i = 1; i <= n; i++){
				s = max(b[s], b[i]);
			}
			if(check(a, c, n)){
				break;
			}
			
			for(int i = 0; i < n; i++){
				c[i] = a[i];
				a[i] = b[a[i]];
			}
			t++;
		}
		
		cout << (t-1) << endl;
		cout << a[0];
		for(int i = 1; i < n; i++){
			cout << " " << a[i];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

namespace {
	const int mo = 998244353;
	inline int add(int x, int y) { x += y; return x >= mo ? x - mo : x; }
	inline int sub(int x, int y) { x -= y; return x < 0 ? x + mo : x; } 
	inline int mul(int x, int y) { return (lo) x * y % mo; }
	inline int power(int a, int k = mo - 2) {
		int ans = 1;
		for (; k; k >>= 1, a = mul(a, a))
			if (k & 1) ans = mul(ans, a);
		return ans;
	}
}
const int N = 3e6 + 233;
int n, m;
int fac[N], ifac[N];

inline int C(int n, int m) {
	if (n < m) return 0;
	else if (m == 0 || m == n) return 1;
	else return mul(fac[n], mul(ifac[m], ifac[n - m]));
}

inline void prepare(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++) fac[i] = mul(fac[i - 1], i);
	ifac[n] = power(fac[n]);
	for (int i = n - 1; i >= 0; i--) ifac[i] = mul(ifac[i + 1], i + 1);
}

int main(void) {
	read(n); read(m);
	prepare(3e6);
	int ans = 0;
	for (int d = 0; d <= min(m, n); d++) {
		if ((3 * m - d) % 2 == 0) {
			auto F = [] (int k, int n) {
				return C(k / 2 + n - 1, n - 1);
			};
			ans = add(ans, mul(C(n, d), F(3 * m - d, n)));
			ans = sub(ans, mul(C(n, d), mul(n, F(m - d, n))));
			ans = add(ans, mul(C(n, d), mul(n - d, F(m - d, n - 1))));
		}
	}
	cout << ans << "\n";
}



Measured memory_bytes: 23680
#include <iostream>

using namespace std;
int main()
{
	int a,b,c,k;
	int cou = 0;
	cin>>a>>b>>c>>k;
	if(k <= a)
		cou  = k;
	else if(k<=a+b)
		cou = a;
	else
		cou = a - (k - a - b);
	cout<<cou;
	return 0;
} 

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

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

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

using namespace std;

int main()
{
    int Z;           //入力待ち
    int j, k;        //for文用
    string to = ","; //デバッグ用
    int e_count = 0; //演算回数を数える
    int count = 0;   //よくあるカウント
    //----------

    int a;
    cin >> a; //500の枚数
    int b;
    cin >> b;
    int c;
    cin >> c;

    int x;
    cin >> x;

    //Xは50の倍数
    REP(i, a + 1) //500を使う枚数を定める
    {

        REP(ii, b + 1) //100を使う回数を定める
        {

            REP(iii, c + 1) //50を使う枚数によって，xをつくれたらカウント
            {
                //cout << i << to << ii << to << iii << endl;

                if (i * 500 + ii * 100 + iii * 50 == x)
                {
                    //cout << "O" << endl;
                    count++;
                }
            }
        }
    }

    cout << count << endl;

    //-----------
    cin >> Z;
    return 0;
}

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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const ll INF =  0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

int n, m, z;
vector<int> v(MAX);
vector<int> a(MAX);
vector<ll> d(MAX, 0), f(MAX, 0) , da(MAX, 0) , db(MAX, 0);

void update(int l, int r, int a, int d){
	// printf("%d %d %d %d\n", l, r, a, d);
	if(l > r)
		return;
	f[l] += a;
	f[r+1] -= a;
	da[l] -= 1ll*l*d;
	da[r+1] += 1ll*l*d;
	db[l] += d;
	db[r+1] -= d;
}

void compute(){
	d[1] = f[1] + 1ll*db[1] + da[1];
	for(int i = 2 ; i <= m ; i++){
		f[i] = f[i-1] + f[i];
		da[i] = da[i-1] + da[i];
		db[i] = db[i-1] + db[i];
		d[i] = f[i] + 1ll*i*db[i] + da[i]; 
	}
}

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  
  scanf("%d %d", &n, &m);

  for(int i = 1 ; i <= n ; i++){
  	scanf("%d" , &z);
  	v[i] = z;
  }

  for(int i = 2 ; i <= n ; i++){
  	int x = v[i-1];
  	int y = v[i];

  	if(y > x){
  		int d = y - x;
  		update(x, x, d, 0);
  		update(x+1, y, d, -1);
  		update(y+1, m, d, 0);
  		update(1, x-1, d, 0);
  	}
  	else{
  		int d = (m - x) + (y - 1) + 1;
  		update(x, x, d, 0);
  		update(x+1, m, d, -1);
  		update(1, y, d - m + x , -1);
  		update(y + 1, x-1, d, 0);
  	}
  }

  	compute();
  	ll ans = LLONG_MAX;

  	for(int i = 1 ; i <= m ; i++)
  		ans = min(ans, d[i]);

  	printf("%lld", ans);
  

  return 0;
}  




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

using namespace std;

int main()
{int a;
cin>>a;
double x=0;
int y[100];
for(int i=0;i<a;i++)
{cin>>y[i];x+=y[i];}
x=x/a;
double n=ceil(x);
x=floor(x);
int sum=0;int u=0;
for(int i=0;i<a;i++)
{
    if(y[i]!=n)
    {u+=pow(y[i]-n,2);
        
    }
}
for(int i=0;i<a;i++)
{
    if(y[i]!=x)
    {sum+=pow(y[i]-x,2);
        
    }
}cout<<min(sum,u);
cout<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int N = 1e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    init();
    int a,b;cin>>a>>b;
    string s;cin>>s;
    bool flg = false;
    for(int i = 0;i < a;i++) {
        if(!isdigit(s[i])) {
            flg = true;
        }
    }
    if(s[a] != '-') flg = true;
    for(int i = a+1;i <= a+b;i++) {
        if(!isdigit(s[i])) {
            flg = true;
        }
    }
    if(!flg) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

/*............................*/

#define uint uint64_t
#define mx 100001
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define mp make_pair
#define pb push_back
#define inf INT_MAX
#define pi acos(-1)
#define eps 1e-8
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define input(ara, n)          \
   for (int i = 0; i < n; i++) \
   scanf("%d", &ara[i])
#define inputl(ara, n)                   \
   for (long long int i = 0; i < n; i++) \
   scanf("%lld", &ara[i])
#define pf(a) printf("%d\n", a);
#define pfl(a) printf("%lld\n", a);
#define pfi(a) printf("%d ", a);
#define pfll(a) printf("%lld ", a);
#define sc(a) scanf("%d", &a)
#define scc(a, b) scanf("%d %d", &a, &b)
#define sccdbl(a, b) scanf("%lf %lf", &a, &b)
#define sccc(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scccdbl(a, b, c) scanf("%lf %lf %lf", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define sccl(a, b) scanf("%lld %lld", &a, &b)
#define scccl(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
using namespace std;
int main()
{
   // int t;
   // sc(t);
   // while (t--)
   // {

   // }
   int n,count=0;
   sc(n);
   int ara[n],ar[n];
   for(int i=0;i<n;i++){
      sc(ara[i]);
   }
   for(int i=0;i<n;i++){
      sc(ar[i]);
   }
   int d[n];
   for(int i=0;i<n;i++){
      d[i]=ara[i]-ar[i];
   }
   sort(d,d+n);
   for(int i=n-1;i>=0;i--){
      if(count+d[i]<count){
         break;
      }
      else{
         count+=d[i];
      }
   } 
   pf(count);
   return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>

int main(void){
	int i;
	char s[4], a[4];

	for(i=0; i<3; i++){
		scanf("%s", s);
		a[i] = s[i];
	}
	a[i] = '\0';

	printf("%s\n", a);

	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include <algorithm>

using ll = long long;
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; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
	int n, a, b;
	scanf("%d", &n);
	scanf("%d", &a);
	scanf("%d", &b);
	printf("%d\n", std::min(n*a, b));
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N;
int dp[100001];

int main(){
    cin>>N;

    repn(i,N){
        int x6=6, x9=9;
        dp[i]=1+dp[i-1];
        while(i-x6>=0){
            dp[i]=min(dp[i],1+dp[i-x6]);
            x6*=6;
        }
        while(i-x9>=0){
            dp[i]=min(dp[i],1+dp[i-x9]);
            x9*=9;
        }
    }

    cout<<dp[N]<<endl;
}

Measured memory_bytes: 640