akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

template<class T, class U> T lexical_cast(const U& from)
{ T to; stringstream ss; ss << from; ss >> to; return to; }

int get(int n, int index) {
    char buf[16];
    sprintf(buf, "%05d", n);
    string s = lexical_cast<string>(buf);
    return s[4 - index] - '0';
}

const char bit[10] = {
    0b01111001,
    0b01110101,
    0b01101101,
    0b01011101,
    0b00111101,
    0b01111010,
    0b01110110,
    0b01101110,
    0b01011110,
    0b00111110
};

char board[5];

int main() {
    bool first = true;
    for(int num; cin >> num; ) {
        if(first == false) putchar('\n');
        else first = false;

        for(int i = 0; i < 5; i++) {
            board[i] = bit[get(num, i)];
        }
        for(int row = 0; row < 7; row++) {
            for(int i = 4; i >= 0; i--) {
                putchar((board[i] & (1 << row)) ? '*' : ' ');
            }
            putchar('\n');
            if(row == 1) puts("=====");
        }
    }
}

Measured memory_bytes: 1240
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 22;
char dn[dm], * di = dn;
char C[10];
int keta = 0;
inline void putint(int X) {
	keta = 0;
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
inline void putmae() {
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint();
	int n = 1 << N;
	int dp1[1 << 18], dp2[1 << 18];
	rep(i, n) {
		dp1[i] = getint();
		dp2[i] = 0;
	}

	rep(k, N) {
		int d = 1 << k;
		int m = ~d;
		for (int i = n - 1; i >= 0; ) {
			if (i >> k & 1) {
				int j = i & m;
				int k = min(dp1[i], dp1[j]);
				dp1[i] = max(dp1[i], dp1[j]);
				dp2[i] = max(dp2[i], k);
				dp2[i] = max(dp2[i], dp2[j]);
				i--;
			}
			else i -= d;
		}
	}

	int saidai = 0;
	rep1(i, n - 1) {
		if (saidai < dp1[i] + dp2[i]) {
			saidai = dp1[i] + dp2[i];
			putint(saidai);
		}
		else putmae();
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 9216
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [2, 4, 6, 9, 11]

if d2 == 1 and m2 == m1 + 1:
    if d1 == 28 and m1 == 2:
        print(1)
    elif d1 == 30:
        for i in range(len(b)):
            if m1 == b[i]:
                print(1)
        for i in range(len(a)):
            if m1 == a[i]:
                print(0)
    elif d1 == 31:
        for i in range(len(a)):
            if m1 == a[i]:
                print(1)
        for i in range(len(b)):
            if m1 == b[i]:
                print(0)
    else:
        print(0)
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	int x;
	cin>>x;
	cout<<10-x/200;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  long ans = 0;
  if (N % 10 == 2) ans++;
  if ((N % 100) / 10 == 2) ans++;
  if ((N % 1000) / 100 == 2) ans++;
  if ((N % 10000) / 1000 == 2) ans++;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  cin >> N;
  map<int,int> mp;
  rep(i,N){
    int a; cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for(auto itr : mp){
    if(itr.first>itr.second) ans += itr.second;
    else if(itr.first<itr.second) ans += itr.second-itr.first;
  }
  
  COUT(ans);
  return 0;

}

Measured memory_bytes: 9508
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;
constexpr int NIL = -1;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

void dfs(vector<vi> &G, vi &color, int r, int c) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while (!S.empty()) {
    auto u = S.top();
    S.pop();
    REP(i, G[u].size()) {
      auto v = G[u][i];
      if (color[v] == NIL) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

int main() {
  int n, m, s, t;
  cin >> n >> m;
  vector<vi> G(n, vi());
  vi color(n, NIL);
  REP(i, m) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  int id = 1;
  REP(i, n) if (color[i] == NIL) dfs(G, color, i, id++);
  cin >> m;
  REP(i, m) {
    cin >> s >> t;
    cout << (color[s] == color[t] ? "yes" : "no") << endl;
  }
}


Measured memory_bytes: 8688
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
int n;
int x[102],cnt=0;
//最大公約数
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
int main(){
    int h,w;cin>>h>>w;
    char a[h][w];
    int hl[h],wl[w];
    rep(i,h)rep(j,w)cin>>a[i][j];
    int ok=1;
    rep(i,h){
        ok=1;
        rep(j,w){
            if(a[i][j]=='.')continue;
            else {hl[i]=1;ok=0;break;}
        }
        if(ok)hl[i]=0;
    }
    rep(i,w){
        ok=1;
        rep(j,h){
            if(a[j][i]=='.')continue;
            else {wl[i]=1;ok=0;break;}
        }
        if(ok)wl[i]=0;
    }

    rep(i,h){
        if(hl[i]){
            rep(j,w){
                if(wl[j])cout<<a[i][j];
            }
        }
        else continue;
        cout<<endl;
    }
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int i,j,h,w;
	char a,pic[111][111]={};
	FOR(i,0,110)FOR(j,0,110)pic[i][j]='#';
	cin>>h>>w;
	FOR(i,1,h+1)FOR(j,1,w+1)cin>>pic[i][j];
	FOR(i,0,h+2){
		FOR(j,0,w+2){
			cout<<pic[i][j];
		}
		cout<<endl;
	}

    return 0;
}


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

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,c=0,ok=1;
    cin>>n;map<string ,ll>m;char a;
    while(n--){++c;
        string s;
        cin>>s;
        if(m[s]){
            ok=0;
        }
        if(c>=2&&s[0]!=a){
            ok=0;
        }
        m[s]=1;a=s[s.size()-1];
    }
    if(ok)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    int n;
    vector<LL> a;
    Solver(LL n):n(n),a(n){};

    void solve(){
        for(int i=0; i<n; ++i){
            cin >> a[i];
        }
        for(int i=1; i<n; ++i){
            a[i] += a[i-1];
        }
        map<LL,LL> m;
        for(int i=0; i<n; ++i){
            m[a[i]]++;
        }
        m[0]++;
        DBG(m)
        LL ans = 0;
        for(auto x : m){
            ans += (x.second-1)*x.second/2;
        }
        cout <<ans <<"\n";
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0;
    std::cin >> n;
    Problem::Solver sol(n);
    sol.solve();
    Problem::Writer::write();
    return 0;
}



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

constexpr int64_t mod = 1'000'000'007;

int main(){    
    int n, k;
    cin >> n >> k;
    static int64_t dp[50+1][50+1][50*50+1];
    dp[1][0][0] = 1;
    dp[1][1][2] = 1;
    for(int i=2;i<=n;i++){
        for(int j=0;j<=i;j++){
            for(int c=0;c<=k;c++){
                dp[i][j][c] = 0;
                if(c-2*j >= 0)
                    dp[i][j][c] = (dp[i][j][c] + (2*j+1)*dp[i-1][j][c-2*j]) % mod;
                if(j+1 <= 50 && c-2*j >= 0)
                    dp[i][j][c] = (dp[i][j][c] + (j+1)*(j+1)*dp[i-1][j+1][c-2*j]) % mod;
                if(j-1 >= 0 && c-2*j >= 0)
                    dp[i][j][c] = (dp[i][j][c] + dp[i-1][j-1][c-2*j]) % mod;
            }
        }
    }

    cout << dp[n][0][k] << endl;
    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int ans = 0;
    rep(i, N - 1) {
        if (a[i] == a[i + 1]) {
            ans++;
            i++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<ll> s(n+1);
	s[0]=0;
	rep(i,n){
		s[i+1]=s[i]+a[i];
	}
	sort(s.begin(),s.end());
	ll ans=0,sum=1,b=s[0];
	for(int i=1;i<=n;++i){
		if(s[i]==b) sum++;
		else{
			ans+=sum*(sum-1)/2;
			b=s[i];
			sum=1;
		}
	}
	ans+=sum*(sum-1)/2;
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;

using namespace std;

int main(void)
{
	int H, W;
	int h, w;

	cin >> H >> W;
	cin >> h >> w;

	cout << H * W - (h*W + w*H - h*w) << endl;

	return 0;
}

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

ll M,rd,rr,cd,cr;

int main(){
  cin >> M >> rd >> rr >> cd >> cr;

  M -= (100LL*cd+rd-1)/rd + (100LL*cr+rr-1)/rr;
  if(M<0LL)cout << -1 << endl;
  else cout << M << endl;
}

Measured memory_bytes: 1160
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := getInt(), getInt()

	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<string.h>
using namespace std;

int main(){
	char s[200020];
	cin>>s;

	long long int ar[26]={0},l = strlen(s);
	for(int i=0;i<l;i++) ar[s[i]-'a']++;
	long long int ans = l*(l-1)/2;
	for(int i=0;i<26;i++){
		ans -= ar[i]*(ar[i]-1)/2;
	}
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    string s, t;
    cin >> s >> t;

    int slen = s.length();
    int tlen = t.length();

    int dp[slen + 1][tlen + 1];
    REP(i, slen + 1) REP(j, tlen + 1) dp[i][j] = 0;
    FOR(i, 0, slen) {
        FOR(j, 0, tlen) {
            if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
            else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
        }
    }

    string ans = "";
    int alen = dp[slen][tlen];
    int itr = 0;
    int i = slen;
    int j = tlen;
    while (i > 0 && j > 0 && ans.length() < alen) {
        if (dp[i][j] == dp[i - 1][j]) --i;
        else if (dp[i][j] == dp[i][j - 1]) --j;
        else {
            ans = s[i - 1] + ans;
            --i;
            --j;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35456
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int[][] c = new int[3][3];
    int[] r = new int[3];
    boolean flag = true;

    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        c[i][j] = scan.nextInt();
      }
    }

    outside:for(int i = 0; i < 3; i++){
      int a = 101;
      for(int j = 0; j < 3; j++){
        a = Math.min(c[i][j], a);
      }
      if(i == 0){
        for(int j = 0; j < 3; j++){
          r[j] = c[i][j] - a;
        }
      }
      if(i > 0){
        for(int j = 0; j < 3; j++){
          if(r[j] != c[i][j]-a){
            flag = false;
            System.out.println("No");
            break outside;
          }
        }
      }
    }

    if(flag == true){System.out.println("Yes");}
  }
}


Measured memory_bytes: 23124
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int N,K;
	cin >> N>>K;
	int ansMax = (N - 1) * (N - 2) / 2;//☆ウニ☆
	if (K > ansMax) {
		cout << -1 << endl;
		return;
	}
	//ウニのために辺がN-1個ある。
	//ウニはansMax個最短距離が2
	int ter = ansMax - K;
	int M = N - 1 + ter;
	cout << M << endl;
	for (int i = 1; i < N; ++i) {
		cout << i << " " << N << endl;
	}
	int cnt = 0;
	for (int i = 1; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			if (cnt >= ter) {
				return;
			}
			cout << i << " " << j << endl;
			++cnt;
		}
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>

#include <utility>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < n; ++i)
#define rep(i, n) rep_init(i, 0, n)

constexpr int INF = numeric_limits<int>::max();

template<typename T>
constexpr T gcd(T a, T b)
{
	if (a < b) swap(a, b);

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

void Main()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << (C % gcd(A, B) == 0 ? "YES" : "NO") << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

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

using i64 = long long int;

int main(){
    int n;
    cin >> n;
    map<int, int> problems;
    for(int i=0;i<n;++i){
        int d;
        cin >> d;
        problems[d]++;
    }

    int m;
    cin >> m;
    bool ok = true;
    for(int i=0;i<m;++i){
        int t;
        cin >> t;
        problems[t]--;
        if(problems[t] < 0)ok = false;
    }

    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,a,x,y;
    cin>>n;
    for(i=sqrt(n);i>=1;i--){
        if(n%i==0){
            k=i+(n/i);
            cout<<k-2<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3680
#include <stdio.h>
int main(){
    int n;
    int a[110];
    int t;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;i>=0;i--){
        printf("%d",a[i]);
        if(i!=0) printf(" ");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
from math import *
n=int(input())
a=list(map(int,input().split()))
a.sort()
opr=0
for i in range(n-1,-1,-1):
	if(a[i]%2==0):
		k=bin(a[i])[2:]
		for j in range(len(k)-1,-1,-1):
			if(k[j]=='0'):
				opr+=1
			else:
				break
print(opr)


Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  int sum=0;
  vector<int>A(M);
  for (int i=0; i<M; i++){
    cin >> A[i];
    sum += A[i];
  }
  int ans = N-sum;
  if (ans < 0) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($A,$B) =  explode(" ",trim(fgets(STDIN)));

if ($A<= 5) {
  $B=0;
}
else if ($A<=12) {
  $B=$B/2;
}
printf("%d\n",$B);


Measured memory_bytes: 4728
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();
		sc.close();
		System.out.println(a == b ? Math.max(a, b) * 2 : Math.max(a, b) * 2 - 1);
	}
}

Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, z, w, tab[2005], res, i, rloc, closest;

int ab(int a, int b) {
	if (a > b) return a - b;
	return b - a;
}

int main() {
scanf("%d %d %d", &n, &z, &w);
for (i=0;i<n;i++) scanf("%d", &tab[i]);
res = ab(tab[n-1], w);
closest = n - 1;
for (i=n-2;i>=0;i--) {
	rloc = ab(tab[i], tab[n-1]);
	if (closest != n-1) rloc = min(rloc, ab(tab[closest], tab[n-1]));
	res = max(res, rloc);
	if (closest == n - 1 || ab(tab[i], tab[n-1]) < ab(tab[closest], tab[n-1])) closest = i;
}
printf("%d\n", res);
return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;
    cout << N + N * N + N * N * N << endl;

}


Measured memory_bytes: 3652
n, k = map(int, input().split())
cum = [0, 1]
dp = [0, 1]

lr = [list(map(int, input().split())) for _ in range(k)]    
mod = 998244353
# i: 目標のマス
def check(i):
    res = 0
    for l, r in lr:
        if i - l < 1:
            continue
        res += cum[i-l] - cum[max(i-r-1,0)]
        res %= mod
    return res


for i in range(2,n+1):
    dp.append(check(i))
    cum.append((cum[-1]+dp[-1])%mod)

print(dp[-1])

Measured memory_bytes: 94168
package main

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

func main() {
	N := readint()
	M := readint()
	aced := make(map[int]bool, N+1)
	pcnt := make([]int, N+1)
	for i := 0; i < M; i++ {
		p := readint()
		s := readstr()
		// 既に正答済の問いなら以降の同問回答は見ない
		if aced[p] {
			continue
		}
		// 今回の回答が正答だった
		if s == "AC" {
			aced[p] = true
			continue
		}
		// ああ、今回もダメだったよ
		pcnt[p]++
	}
	// 正答数とペナルティ数をカウント
	ac, pc := 0, 0
	for i := 1; i <= N; i++ {
		if aced[i] {
			ac++
			pc += pcnt[i]
		}
	}
	fmt.Println(ac, pc)
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int Mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"Yes"<<nl
#define no cout<<"No"<<nl

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void solve()
{
    int n,x,y,cnt=0;
    bool f=0;

    cin>>n;

    for(int i=0; i<n; i++)
    {
        cin>>x>>y;
        if(x==y)
            cnt++;
        else
            cnt=0;
        if(cnt==3)
            f=1;
    }

    if(f==1)
        yes;
    else
        no;

}

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


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

int n,m,wei[11][11],hasil[11],total;
priority_queue<pair<int,int> >pq;
bool bol[11];

int main(){
	cin>>n>>m;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			cin>>wei[i][j];
		}
	}
	for(int i=0;i<=9;i++){
		if(i==1)continue;
		for(int j=0;j<=9;j++){
			bol[j]=0;
		}
		pq.push({0,i});
		while(!pq.empty()){
			int nowx,noww;
			noww=pq.top().first;
			nowx=pq.top().second;
			if(nowx==1){
				hasil[i]=-noww;
				while(!pq.empty())pq.pop();
			}
			else if(bol[nowx]){
				pq.pop();
				continue;
			}
			else{
				bol[nowx]=1;
				for(int j=0;j<=9;j++){
					if(i==j)continue;
					pq.push({noww-wei[nowx][j],j});
				}
			}
			if(!pq.empty())pq.pop();
		}
	}
	total=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int x;
			cin>>x;
			total+=hasil[x];
		}
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
/*そーなのかー
　　　＿
　 '´　　 ヽ
 ./ ﾉﾉ））)）〉
〈《.! ﾟ ヮﾟﾉ》
　⊂!::V::!つ
　 く::::::::〉
　　 し'ﾉ*/
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(a%b==0){
  cout << a/b << endl;
  }
  else{
  cout << a/b+1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 5001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id,id1,id2,id3,id4,lvl;
L A[Mx],P[Mx];
vector<L>V;
void solve(){
	for(L i=1;i<=n;i++){
		sum=0;
		c=0;
		V.clear();
		c1=-inf;
		id=P[i];
		while(true){
			sum+=A[id];
			c++;
			c1=max(c1,sum);
			V.push_back(c1);
			if(id==i)break;
			id=P[id];
		}
		c1=-inf;
		if(k>=c){
			if(sum>0){
				d=k/c;
				c1=(d*sum);
				d1=k%c;
				if(d1)c1=max(c1+V[d1-1],c1);
				if(d){
					d--;
					c2=(d*sum)+V[c-1];
					c1=max(c1,c2);	
				}			

			}else{
				c1=V[c-1];
			}
		}else{
			c1=V[k-1];
		}
		mx=max(c1,mx);
	}
	printf("%lld\n", mx);
}
int main()
{
    scanf("%lld%lld",&n,&k);
    for(L i=1;i<=n;i++)scanf("%lld",&P[i]);
    for(L i=1;i<=n;i++)scanf("%lld",&A[i]);
    solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3928
from math import sqrt,ceil,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())


# for _ in range(ii()):

n=ii()
a=li()
i=0
ans=1000
while(i<n-1):

    while(i<n-1 and a[i]>=a[i+1]):
        i+=1
    if(i==n-1):
        break
    j=i
    i+=1
    while(i<n and a[i]>=a[i-1]):
        i+=1
    x1=ans//a[j]
    ans%=a[j]
    ans+=(x1*a[i-1])
print(ans)
    
    
    
    
    
    
    
    
    
    
    


Measured memory_bytes: 62188
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int H,N;
    int A[114514];
    cin >> H >> N;
    REP(i,N){
        cin >> A[i];
        H-=A[i];
    }
    if(H<=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}



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

int main() {
	string s;
	string ans;
	int now = -1;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			ans.push_back(s[i]);
			now++;
		}
		if (s[i] == '1') {
			ans.push_back(s[i]);
			now++;
		}
		if (s[i] == 'B'&& !(ans.empty())) {
			ans.erase(now,1);
			now--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# abc 115 C
# input
n, k = map(int, input().split())
a = []
o = 10000000000
for i in range(n):
    a.append(int(input()))
a.sort()

# calc
for i in range(n-k+1):
    t = a[i+k-1]-a[i]
    if o > t:
        o = t
# output
print(o)


Measured memory_bytes: 7384
n = int(input())
s = []
for i in range(n):
    tmp = int(input())
    s.append(tmp)
s = sorted(s)
max_s = sum(s)
if max_s % 10 != 0:
    print(max_s)
else:
    for j in range(n):
        if s[j] % 10 != 0:
            print(max_s - s[j])
            break
        elif j == n-1:
            print(0)

Measured memory_bytes: 3060
/*https://atcoder.jp/contests/agc002/tasks/agc002_a*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	long long a, b;
	cin >> a >> b;
	if (a > 0 && b < 0)
		swap(a, b);
	if (a < 0 && b < 0)
	{
		a = abs(a - b);
		if ((a + 1) % 2 == 0)
			cout << "Positive";
		else
			cout << "Negative";
	}
	else  if (a < 0 && b > 0)
		cout << "Zero";
	// else if (a == 0 || b == 0)
	// 	cout << "0";
	else
		cout << "Positive";
}

Measured memory_bytes: 3584
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int m;
    cin >> m;
    ll ans = 0LL;
    ll sum = 0LL;
    rep(i, m) {
        int d;
        ll c;
        cin >> d >> c;
        sum += d * c;
        ans += c;
    }
    --ans;

    ans += sum/9LL;
    if(!(sum%9LL)) {
        ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int n, k;
		n = scan.nextInt();
		k = scan.nextInt();
		
		System.out.print((int)(k * Math.pow(k-1, n-1)));
		
	}
}

Measured memory_bytes: 23124
#include<iostream>
    #include<vector>
    #include<string>
    #include<algorithm>
    #include<cmath>
    #include<random>
     
    //使い方がよくわからない
    #include<stack>
    #include<queue>
    #include<bitset>
    #include<sstream>
     
    #define rep(i,n) for(int i=0;i<(n);i++) 
    #define rep1(i,n) for(int i=1;i<(n);i++)
    #define co(x) cout << x << endl
    #define cosp(x) cout << x << " "
     
    using namespace std;
    using ll = long long;
    #define INF 998244353 
     
    int main(int argc, const char *argv[]){
        ll n;
        cin >> n;
        vector<ll> d(n);
        vector<ll> v(n,0);
        rep(i,n){cin >> d[i];}
        if(d[0]>0){co(0); return 0;}
        rep(i,n){v[d[i]]++;}
        if(v[0]>1){co(0); return 0;}
        ll ans = 1;
        rep1(i,n){
            rep(j,v[i]){
                ans*=(v[i-1]%INF);
                ans = ans%INF;
            }
        }
        co(ans);
        return 0;
    }

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

int main() {
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		int count=0;
		int no=i;
		while(no>0)
		{
			int d=no%10;
			count=count+1;
			no=no/10;
		}
		if(count%2!=0)
		sum=sum+1;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {	
	int t=1;
	//cin >> t;
	while (t--) {
	   
	   int n;
       cin>>n;
       long long w;
       cin>>w;
       long long*val=new long long[n];
        long long*we=new long long[n];
       
       long long ans=0;
       for(int i=0;i<n;i++)
       {
       	 cin>>we[i];
       	 cin>>val[i];
       	 ans+=val[i];
	   }
	   
	   long long dp[101][100001];
	   for(int i=1;i<100001;i++)
	   {
	   	dp[0][i]=INT_MAX;
	   }
	   for(int i=0;i<n;i++)
	   {
	   	dp[i][0]=0;
	   }
	   for(int i=1;i<=n;i++)
	   {
	   	for(int j=1;j<100001;j++)
	   	{
	   		if(val[i-1]<=j)
	   		{
	   			dp[i][j]=min(we[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
			}
			else
			dp[i][j]=dp[i-1][j];
		}
	}
		for(int i=ans;i>=0;i--)
		{
			if(dp[n][i]<=w)
			{
			     cout<<i;
				break; 
			}
		}
	   
	    
      }
	} 
	
	
	

Measured memory_bytes: 82528
A, B, C, D = map(int, input().split())

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)

lcm_cd = lcm(C, D)



b_mul_c = B // C
b_mul_d = B // D
b_mul_cd = B // lcm_cd

a_mul_c = (A - 1) // C
a_mul_d = (A - 1) // D
a_mul_cd = (A - 1) // lcm_cd

num_b = B - (b_mul_c + b_mul_d - b_mul_cd)
num_a = (A - 1) - (a_mul_c + a_mul_d - a_mul_cd)

print(num_b - num_a)

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = (1<<21)+1;

/* ...o(^-^)o... */

const lint mod = MOD;
class mint{
    public:
        long long x;

    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend istream& operator>>(istream& is, mint& m){
        long long x; is >> x; m = x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};

mint a[25][25];
mint dp[MAX];

int main(){
    int n; cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];
    int M = (1<<n);
    rep(i, M){
        if(i == 0){
            dp[i] = 1; continue;
        }
        rep(j, n){
            if(i&(1<<j)) dp[i] += dp[i^(1<<j)] * a[bit_c(i)-1][j];
        }
    }
    out(dp[M-1]);
}

Measured memory_bytes: 16640
#include<stdio.h>
int main(){
  int x,y,i,temp;

  scanf("%d%d",&x,&y);

  if(x<y){
    temp=y;
    y=x;
    x=temp;
  }
  while(1){
    temp=x%y;
    x=y;
    if(temp==0)break;
    y=temp;
  }
  printf("%d\n",x);
  return 0;
}



Measured memory_bytes: 2756
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

char s[100001];
char t[100001];
int next[100001][26];
int main() {
	scanf("%s", s);
	scanf("%s", t);
	int N;
	for (int i = 0;; i++) {
		if (s[i] == 0) {
			N = i;
			break;
		}
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < N; j++) {
			next[j][i] = -1;
		}
	}
	for (int i = 0; i < N; i++) {
		if (next[N - 1][s[i] - 'a'] == -1) {
			next[N - 1][s[i] - 'a'] = i;
		}
	}
	for (int i = N - 2; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			if (s[i + 1] != 'a' + j) {
				next[i][j] = next[i + 1][j];
			}
			else {
				next[i][j] = i + 1;
			}
		}
	}
	long long cnt = 0;
	int p = -1;
	for (int i = 0;; i++) {
		if (t[i] == 0) {
			printf("%lld", cnt*N + p + 1);
			break;
		}
		if (i == 0) {
			if (s[i] == t[i]) {
				p = 0;
			}
			else {
				p = next[0][t[i] - 'a'];
				if (p == -1) {
					printf("-1");
					break;
				}
			}
		}
		else {
			if (p >= next[p][t[i] - 'a']) {
				cnt++;
			}
			p = next[p][t[i] - 'a'];
			if (p == -1) {
				printf("-1");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s; cin >> s;
  int cnt = 0;
  string cf = "CODEFESTIVAL2016";
  for (int i = 0; i < 16; i++) if (cf[i] != s[i]) cnt++;
  printf("%d\n", cnt);
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

n = gets.chomp.to_i

result = []

C = ('a'..'z').map.with_index {|c, i| [i, c] }.to_h

loop do
  b = (n - 1) % 26

  result << C.fetch(b)

  n = (n - 1) / 26

  break if n.zero?
end

result.reverse!

puts result.join('')


Measured memory_bytes: 14340
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
q,h,s,d = readInts()
n = I()
#4*q, 2*h, s, d - 2
Q = 4*q;H = 2*h
print(min(d * (n//2) + n%2 * min(Q,H,s), min(Q,H,s)*n))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int64_t N, Q, a, b, p, x;
vector<vector<int64_t>> Tree(200001);
vector<int64_t> X(2000001, 0);

void dfs(int64_t prev, int64_t cur, int64_t cnt)
{
  X.at(cur) += cnt;
  for (int i = 0; i < Tree.at(cur).size(); i++)
  {
    if (Tree.at(cur).at(i) == prev)
      continue;
    else
      dfs(cur, Tree.at(cur).at(i), X.at(cur));
  }
}

int main()
{
  cin >> N >> Q;
  for (int64_t i = 0; i < N - 1; i++)
  {
    cin >> a >> b;
    Tree.at(a).push_back(b);
    Tree.at(b).push_back(a);
  }
  for (int64_t i = 0; i < Q; i++)
  {
    cin >> p >> x;
    X.at(p) += x;
  }
  dfs(0, 1, 0);
  for (int64_t i = 1; i <= N; i++)
  {
    cout << X.at(i);
    if (i != N)
      cout << ' ';
    else
      cout << endl;
  }
}


Measured memory_bytes: 41472
#include <cstdio>

int main(){
    int n;
    int card[52]={0};

    scanf(" %d", &n);
    for(int i=0; i<n; ++i){
        char c;
        int a;
        scanf(" %c %d", &c, &a);

        if(c=='S') card[a-1]=1;
        else if(c=='H') card[a-1+13]=1;
        else if(c=='C') card[a-1+26]=1;
        else if(c=='D') card[a-1+39]=1;
    }

    for(int i=0; i<52; ++i){
        if(card[i]==0){
            if(i<13) printf("S ");
            else if(i<26) printf("H ");
            else if(i<39) printf("C ");
            else if(i<52) printf("D ");

            printf("%d\n", i%13+1);
        }
    }

    return 0;
}



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

public static class Program {
    public static void Main() {
        int n=int.Parse(Console.ReadLine());
        int a=0,b=0,c=0;
        foreach(int x in Console.ReadLine().Split().Select(int.Parse)){
            if(x==1)a++;
            if(x==2)b++;
            if(x==3)c++;
        }
        double[,,]dp=new double[n+1,n+1,n+1];
        for(int k=0;k<=n;k++){
            for(int j=0;j+k<=n;j++){
                for(int i=0;i+j+k<=n;i++){
                    if(i==0&&j==0&&k==0)continue;
                    double e=0;
                    if(0<i)e+=dp[i-1,j,k]*i/n;
                    if(0<j)e+=dp[i+1,j-1,k]*j/n;
                    if(0<k)e+=dp[i,j+1,k-1]*k/n;
                    dp[i,j,k]=(1+e)/(1-(double)(n-i-j-k)/n);
                }
            }
        }
        Console.WriteLine(dp[a,b,c]);
    }
}



Measured memory_bytes: 224096
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int change;
        int numA = sc.nextInt();
        int numB = sc.nextInt();
        int numC = sc.nextInt();
        /*numA<numB<numCとなるようにnumの中身を入れ替えていく*/
        if(numA>numB){          //A<Bに並べ替え
            change = numA;
            numA = numB;
            numB = change;
        }
        if(numB>numC){          //B<Cになるよう入れ替え
            change = numB;
            numB = numC;
            numC = change;
        }
        if(numA>numB){          //A<B<Cとなる
            change = numA;
            numA = numB;
            numB = change;
        }
        System.out.println(numA+" "+numB+" "+numC); //A B Cと出力
    }
}


Measured memory_bytes: 26432
//
// Created by 加藤英祐 on 2020/04/14.
//
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N-1; ++i) {
        int a;
        cin >> a;
        A.at(a-1)++;
    }

    for (int i = 0; i < N; ++i) {
        cout << A.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int A[N],B[N];

int main(){
    int t = 1;
   // cin >> t;
    while (t--) {
        int n, m ,ms;
        scanf("%d%d%d", &n, &m, &ms);
 
        for(int A_i = 0; A_i < n; A_i++){
            scanf("%d",&A[A_i]);
        }
        for(int B_i = 0; B_i < m; B_i++){
           scanf("%d",&B[B_i]);
        }

        long long sum = 0;
        int x = 0, y = 0;

        while (x < n && sum + A[x] <= ms) {
            sum += A[x++];
        }

        int ans = x;

        while (y < m && x >= 0) {
            sum += B[y++];
            while (sum > ms && x > 0) {
                sum -= A[--x];
            }

            if (sum <= ms && ans < x + y) {
                ans = x + y;
            }
        }

        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 5384