akhauriyash/Code-Regression huggingface dataset:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

s = input()[:-1]

if s == "ABC":
    print("ARC")
else:
    print("ABC")

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

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define REP(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
typedef long long int ll;
const int MOD=(int)1e9+7;

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll digitsum(ll a){
    ll x=0;
    while(a>0){
        x+=a%10;
        a/=10;
    }
    return x;
}

int main(){
    ll n,s,ans=MOD;
    cin>>n>>s;
    vector<unsigned long long int> a(n);
    REP(i,n)cin>>a.at(i);
    sort(a.begin(),a.end());
    REP(i,n-s+1){
        ll tmp=abs(a.at(i+s-1)-a.at(i));
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

typedef long long i64;
const int MOD = 924844033;
const int MAXN = 200000 + 15;

int N;
int A[MAXN * 4], B[MAXN * 4], rev[MAXN * 4];
int fact[MAXN], inv[MAXN], siz[MAXN];

vector <int> Adj[MAXN];

template <class T>
inline T modularExp(T base, T exp)
{
	T ret(1);

	while(exp)
	{
		if(exp & 1)
			ret = 1LL * ret * base % MOD ;
		base = 1LL * base * base % MOD ;
		exp = exp >> 1;
	}

	return ret;
}

namespace NumberTheoryTransformation
{

const int PrimitiveRoot = 5;

inline int Get_wn(int i)
{
	return modularExp(PrimitiveRoot, (MOD - 1) / (i << 1));
}

void NTT(int * coef, int n, int f)
{
	for(int i = 0; i < n; i++)
		if(i < rev[i])
			swap(coef[i], coef[rev[i]]);

	for(int i = 1; i < n; i = i << 1)
	{
		int x, y, wn = Get_wn(i);

		for(int j = 0; j < n; j = j + i * 2)
			for(int k = 0, w = 1; k < i; k++, w = 1LL * w * wn % MOD)
				x = coef[j + k], y = 1LL * coef[j + k + i] * w % MOD,
				coef[j + k] = (x + y) % MOD, coef[j + k + i] = (x - y) % MOD;
	}

	if(f == 1)		// Inverted?
		return;
	reverse(coef + 1, coef + n);
	int inverse = modularExp(n, MOD - 2);
	for(int i = 0; i < n; i++)
		coef[i] = 1LL * coef[i] * inverse % MOD;
}

void convolution(int n)
{
	NTT(A, n, 1), NTT(B, n, 1);
	for(int i = 0; i < n; i++)
		A[i] = 1LL * A[i] * B[i] % MOD;
	NTT(A, n, -1);
}

}

void prepare()
{
	fact[0] = 1;
	for(int i = 1; i < MAXN; i++)
		fact[i] = 1LL * fact[i-1] * i % MOD;

	inv[MAXN - 1] = modularExp(fact[MAXN-1], MOD - 2);
	for(int i = MAXN - 1; i > 0; i--)
		inv[i-1] = 1LL * inv[i] * i % MOD;
}

void DFS(int cur)
{
	siz[cur] = 1;

	for(int to : Adj[cur])
	{
		if(siz[to])
			continue;
		DFS(to);

		siz[cur] += siz[to];
		A[siz[to]] --, A[N - siz[to]]--;
	}
}

int main()
{
	int s, l = 0;
	prepare();

	scanf("%d", &N), A[N] = N;

	for(int i = 1; i < N; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		Adj[u].push_back(v), Adj[v].push_back(u);
	}

	DFS(1);

	for(int i = 1; i <= N; i++)
		A[i] = 1LL * A[i] * fact[i] % MOD;
	for(int i = 0; i <= N; i++)
		B[i] = inv[N - i];

	for(s = 1; s <= N * 2; s = s * 2)
		l++;
	for(int i = 0; i < s; i++)
		rev[i] = ((rev[i >> 1] >> 1) | ((i & 1) << (l - 1)));

	NumberTheoryTransformation::convolution(s);
	for(int i = 1; i <= N; i++)
		printf("%lld\n", 1LL * (A[N + i] + MOD) * inv[i] % MOD);
}


Measured memory_bytes: 32768
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int n;
	int m;
	int q;
	int h[];
	int a[];
	int b[];
	int ans[];
	int count;

	public void run() {
		Scanner sc = new Scanner(System.in);

		// 入力値取得
		n = sc.nextInt();
		m = sc.nextInt();
		h = new int[n];
		a = new int[m];
		b = new int[m];
		for(int i=0; i<n; i++) {
			h[i] = sc.nextInt();
		}
		for(int i=0; i<m; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		sc.close();

		// 解答処理
		ans = new int[n];
		Arrays.fill(ans, 1);
		check();
		count = 0;
		for(int i=0; i<n; i++) {
			if(ans[i] == 1) count++;
		}

		System.out.println(count);
	}

	private void check() {
		for(int i=0; i<m; i++) {
			if(h[a[i]-1] < h[b[i]-1]) {
				ans[a[i]-1] = 0;
			} else {
				ans[b[i]-1] = 0;
			}
			if(h[b[i]-1] < h[a[i]-1]) {
				ans[b[i]-1] = 0;
			} else {
				ans[a[i]-1] = 0;	
			}
		}
	}
}


Measured memory_bytes: 61112
#include <stdio.h>

#define N 44

int main(){

  int i,n,F[N];

  scanf("%d",&n);
    F[0] = 1;
    F[1] = 1;
    for(i=2;i<=n;i++){
      F[i] = F[i-2] + F[i-1];
  }

  printf("%d\n",F[n]);

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int main() {
    int H, W, K; cin >> H >> W >> K;
    string s[H]; for (int i = 0; i < H; i++) cin >> s[i];
    int ans = 0;
    for (int s1 = 0; s1 < 1 << H; s1++)
        for (int s2 = 0; s2 < 1 << W; s2++) {
            int sum = 0;
            for (int i = 0; i < H; i++)
                for (int j = 0; j < W; j++)
                    if (s[i][j] == '#' && ((s1 >> i) & (s2 >> j) & 1))
                        sum++;
            if (sum == K) ans++;
        }
    cout << ans << endl;
}


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

int N,M;

int main(){
	while(cin >> N >> M && N>0){
		vector< vector<int> > v(200010);
		for(int i=0;i<M;i++){
			int a,b;
			cin >> a >> b;
			v[a].push_back(b);
		}
		bool judge = false;
		for(int i=0;i<v[1].size();i++){
			int u = v[1][i];
			for(int j=0;j<v[u].size();j++){
				if(v[u][j] == N) judge = true;
			}
		}
		if(judge) cout << "POSSIBLE" << endl;
		else cout << "IMPOSSIBLE" << endl;
		for(int i=1;i<N+1;i++) v[i].clear();
	}
}

Measured memory_bytes: 8576
a :: [Int]
a = [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]

main = do
  n <- (read :: String -> Int) <$> getLine
  print $ a !! (n-1)


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

int n;
char mat[255][255];
// vertical
int v[255][255];
// horizontal
int h[255][255];
// right-down diagonally
int rd[255][255];
// left-down diagonally
int ld[255][255];

int solve(){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            v[i][j] = h[i][j] = rd[i][j] = ld[i][j] = 0;
        }
    }

    if(mat[0][0]=='1')  v[0][0] = h[0][0] = rd[0][0] = ld[0][0] = 1;

    for(int j = 1; j < n; j++){
        if(mat[0][j]=='1'){
            h[0][j] = h[0][j-1]+1;
            v[0][j] = rd[0][j] = ld[0][j] = 1;
        }  
    }

    for(int i = 1; i < n; i++){
        for(int j = 0; j < n; j++){
            if(mat[i][j]=='1'){
                if(j != 0)      h[i][j] = h[i][j-1]+1;    
                else            h[i][j] = 1;
                v[i][j] = v[i-1][j]+1;
                if(j != n-1)    ld[i][j] = ld[i-1][j+1]+1;
                else            ld[i][j] = 1;
                if(j != 0)      rd[i][j] = rd[i-1][j-1]+1;
                else            rd[i][j] = 1;
            }
        }
    }

    int ret = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            ret = max(ret, max(max(max(h[i][j], v[i][j]), rd[i][j]),ld[i][j]));
        }
    }

    return ret;
}

int main(){
    while(cin >> n){
        if(n == 0)  break;

        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                cin >> mat[i][j];
            }
        }

        cout << solve() << endl;
    }


    return 0;
}


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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
/*
think fast
think simple
*/
int n, m, k;
char arr[6][6];
void copy_matrix(string g[])
{
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			arr[i][j] = g[i][j];
}
void color(int x, int y)
{
	for (int i = 0; i < n; i++)
	{
		if (x & (1 << i))
		{
			for (int j = 0; j < m; j++)
				arr[i][j] = '$';
		}
	}
	for (int j = 0; j < m; j++)
	{
		if (y & (1 << j))
		{
			for (int i = 0; i < n; i++)
				arr[i][j] = '$';
		}
	}
}
bool cnt()
{
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (arr[i][j] == '#')
				ans++;
		}
	}
	return ans == k;
}
void mysol()
{
	cin >> n >> m >> k;
	string g[n];
	for (auto &i : g)
		cin >> i;
	int ans = 0;
	for (int i = 0; i < (1 << n); i++)
	{
		for (int j = 0; j < (1 << m); j++)
		{
			copy_matrix(g);
			color(i, j);
			if (cnt())
				ans++;
		}
	}
	cout << ans << endl;

}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


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

int main(){
  ll x,n,p,i,j;
  cin >> x >> n;
  ll ans[101]={0};
  for(i=0;i<n;i++){
    cin >> p;
    ans[p]=1;
  }
  j=max(x,101-x);
  for(i=0;i<=j;i++){
    if(x-i==-1){
      cout << -1;
      break;
    }
    if(ans[x-i]==0){
      cout << x-i;
      break;
    }
    if(ans[x+i]==0){
      cout << x+i;
      break;
    }
    if(x+i==101){
      cout << 101;
      break;
    }
  }
}

Measured memory_bytes: 3616
#include <cstdio>
long long x[100001],p[100001],ans,n,s;
int main(){
	scanf("%d%d",&n,&s);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&p[i]);
	int i=1,j=n;
	while(i<=j){
		if(s<=x[i]){
			printf("%lld",x[j]-s+ans);
			return 0;
		}else if(s>=x[j]){
			printf("%lld",ans+s-x[i]);
			return 0;
		}
		if(p[i]>=p[j]){
			ans+=x[j]-x[i];
			while(i<j && p[i]>=p[j])p[i]+=p[j--];
		}else{
			ans+=x[j]-x[i];
			while(i<j && p[i]<p[j])p[j]+=p[i++];
		}
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int (i) = 0; i < (n); i++)
#define REP(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

int g[300][300], h[300][300];

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

	int n, m, d;
	cin >> n >> m >> d;
	Fill(g, false);
	Fill(h, false);
	int res = 0;

	rep(i, n) {
		string s;
		cin >> s;
		rep(j, m) {
			if(s[j] == '.') g[i][j] = 1;
			else g[i][j] = 0;
		}
	}

	rep(i, m) {
		rep(j, n) {
			h[i][j] = g[j][i];
		}
	}

	rep(i, n) {
		rep(j, m) {
			bool f = 1;
			rep(k, d) {
				if(!g[i][j + k]) f = 0;
			}
			if(f) res++;
		}
	}

	rep(i, m) {
		rep(j, n) {
			bool f = 1;
			rep(k, d) {
				if(!h[i][j + k]) f = 0;
			}
			if(f) res++;
		}
	}
	cout << res << endl;
	return 0;
}



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

int main(void){
	int n, k, tmp, len = 0;
	vector<int> l;
	cin >> n >> k;
	for (int i = 0; i < n; ++i){
		cin >> tmp;
		l.push_back(tmp);
	}
	sort(l.begin(), l.end(), greater<int>());
	for (int i = 0; i < k; ++i){
		len += l[i];
	}
	cout << len << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD 1000000007

int main(void)
{
  string str;
  cin >> str;

  if(str == "a" || str == "i" || str == "u" || str == "e" || str == "o")
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
///
// File:  1346.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 26 02:53:16 2017
//

#include <cstdint>
#include <iostream>
#include <stack>
#include <string>

using namespace std;

uint32_t mult_first(string exp)
{
  stack<int32_t> stack;

  stack.push(exp[0] - '0');
  uint32_t index = 1;
  while (index < exp.size()) {
    uint32_t val = exp[index + 1] - '0';
    if (exp[index] == '+') {
      stack.push(val);
    } else {
      uint32_t val1 = stack.top();
      stack.pop();
      stack.push(val * val1);
    }
    index += 2;
  }

  uint32_t result = 0;
  while (!stack.empty()) {
    result += stack.top();
    stack.pop();
  }
  return result;
}

uint32_t left_to_right(string exp)
{
  uint32_t result = exp[0] - '0';

  uint32_t index = 1;
  while (index < exp.size()) {
    uint32_t val = exp[index + 1] - '0';
    if (exp[index] == '+') {
      result += val;
    } else {
      result *= val;
    }
    index += 2;
  }
  return result;
}

int32_t main()
{
  string exp;
  cin >> exp;

  uint32_t result1 = mult_first(exp);
  uint32_t result2 = left_to_right(exp);

  uint32_t n;
  cin >> n;
  if (result1 == n && result2 == n) {
    cout << "U" << endl;
  } else if (result1 == n) {
    cout << "M" << endl;
  } else if (result2 == n) {
    cout << "L" << endl;
  } else {
    cout << "I" << endl;
  }
  return 0;
}

Measured memory_bytes: 3204
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            money = i * 500 + j * 100 + k * 50
            if money == x:
                count += 1

print(count)


Measured memory_bytes: 3064
n = int(input())
m = 0
a = n // 3
b = n // 5
c = n // 15
for i in range(1,n+1):
    m = m+i
for j in range(1,a+1):
    m = m-(3*j)
for k in range(1,b+1):
    m = m-(5*k)
for l in range(1,c+1):
    m = m+(15*l)
print(m)

Measured memory_bytes: 64696
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=int(input())
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    a=list(map(int,sys.stdin.readline().split(' ')))
    ams=1

    if 0 in a:
        print(0)
        continue
        
    for x in a:
        ams*=x
        if ams> 1000000000000000000:
            ams=-1
            break

    print(ams)
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

template <typename CLASS1, typename CLASS2>
bool operator==(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2){
  return hoge1.value == hoge2.value;
};

template <typename CLASS1, typename CLASS2>
bool operator<(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2){
  return hoge1.value < hoge2.value;
};

template <typename CLASS1, typename CLASS2>
bool operator>(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2){
  return hoge1.value > hoge2.value;
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  bool even_flag = true;
  REP(i, N){
    ll a;
    cin >> a;
    if(a%2==1) even_flag = false;
  }

  if(!even_flag) cout << "first\n";
  else           cout << "second\n";

  return 0;
}

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

using namespace std;

int main() {
	const Int MOD = 1e9 + 7;
	int N, M;
	cin >> N >> M;
	vector<int> S(N + 1), T(M + 1);
	for (int i = 1; i <= N; ++i) { cin >> S[i]; }
	for (int i = 1; i <= M; ++i) { cin >> T[i]; }

	vector<vector<Int>> dp(N + 1, vector<Int>(M + 1, 0));
	vector<vector<Int>> d(N + 1, vector<Int>(M + 1, 0));
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= M; ++j) {
			if (i == 0 || j == 0) {
				d[i][j] = 1;
				continue;
			}
			if (S[i] == T[j]) { dp[i][j] = d[i - 1][j - 1]; }
			d[i][j] = (d[i][j-1] + d[i-1][j] - d[i-1][j-1] + dp[i][j] + MOD) % MOD;
		}
	}
	cout << d[N][M] % MOD << endl;

	return 0;
}


Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int K, T;
  cin >> K >> T;
  vector<ll> a(T);
  REP(i, T) cin >> a[i];
  sort(a.begin(), a.end());
  ll mn = 1e15;
  vector<ll> ruiseki(T);
  ruiseki[0] = a[0];
  for (int i = 1; i < T; i++) {
    ruiseki[i] = ruiseki[i - 1] + a[i];
  }
  REP(i, T) {
    ll b = ruiseki[i], c = ruiseki[T - 1] - ruiseki[i];
    mn = min(mn, abs(b - c));
  }
  cout << max((ll)0, mn - 1) << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    int ANS=0;
    rep(i,N){
        cin>>A[i];
        while(A[i]%2==0){
            ANS++;
            A[i]=A[i]/2;
        }
    }

    cout<<ANS<<endl;


    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
n,m,q=map(int,input().split())
g=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    #a-=1
    #b-=1
    g[a][b]+=1
    
for i in range(n):
    for j in range(n+1):
        g[i+1][j]+=g[i][j]
for i in range(n+1):
    for j in range(n):
        g[i][j+1]+=g[i][j]
for i in range(q):
    a,b=map(int,input().split())
    a-=1
    print(g[b][b]+g[a][a]-g[a][b]-g[b][a])
#print(g)

Measured memory_bytes: 57688
import scala.math.round
 
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val H = sc.nextLong()
  val W = sc.nextLong()
 
  if (H == 1L || W == 1L) {
    println(1)
  } else {
    println((H * W + 1) / 2)
  }
  
}

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

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

    vector<int> a(N);
    vector<int> aCount(N + 1, 0);
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        aCount[a[i]] += 1;
    }

    vector<int> b(N);
    vector<int> bCount(N + 1, 0);
    for(int i = 0; i < N; ++i){
        cin >> b[i];
        bCount[b[i]] += 1;
    }

    bool isPossible = true;
    for(int elem = 1; elem <= N; ++elem){
        if(aCount[elem] + bCount[elem] > N){
            isPossible = false;
        }
    }

    if(isPossible){
        set<pair<int, int>> countVal;
        for(int elem = 1; elem <= N; ++elem){
            if(bCount[elem] > 0){
                countVal.insert({aCount[elem] + bCount[elem], elem});
            }
        }

        for(int i = 0; i < N; ++i){
            if(bCount[a[i]] > 0){
                countVal.erase({aCount[a[i]] + bCount[a[i]], a[i]});
                aCount[a[i]] -= 1;
                countVal.insert({aCount[a[i]] + bCount[a[i]], a[i]});
            }

            if(a[i] == countVal.rbegin()->second){
                auto it = prev(prev(countVal.end()));
                b[i] = it->second;
                countVal.erase(it);
                bCount[b[i]] -= 1;
                if(bCount[b[i]] > 0){
                    countVal.insert({aCount[b[i]] + bCount[b[i]], b[i]});
                }
            }else{
                b[i] = countVal.rbegin()->second;
                countVal.erase(prev(countVal.end()));
                bCount[b[i]] -= 1;
                if(bCount[b[i]] > 0){
                    countVal.insert({aCount[b[i]] + bCount[b[i]], b[i]});
                }
            }
        }

        cout << "Yes\n";
        for(int i = 0; i < N; ++i){
            cout << b[i] << " ";
        }
    }else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 15476
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n;
    cin >> n;
    int a[n];
    fff(i,n)
    cin >> a[i];
    
    int c=0,an=0;
    fff(i,n-1) {
        if(a[i+1]<=a[i])
        c++;
        else {
            if(an<c)
            an=c;
            c=0;
        }
    }
    if(an<c)
            an=c;
    // if(an>0)
    // cout << an+1;
    // else
    cout << an;
    
	return 0;
    
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    string s;
    int i,sz,p,q;
    while(cin>>s)
    {
        p=0;
        q=0;
        for(i=0;i<s.size();i++)
        {
            if(s[i]=='C')
            {
                p=1;
            }
            if(p==1&&s[i]=='F')
            {
                q=1;
            }

        }
        if(p==1&&q==1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;

    }
     return 0;

}


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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 50000; i++) {
        if ((int)floor((double)i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 3624
#pragma GCC optimize ("Ofast")
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define print(x) cout << (x) << '\n'

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(__null);

  string s; cin >> s;
  if (s.find("C") != string::npos && s.find("F") != string::npos && (int) s.find("C") < (int) s.rfind("F")) print("Yes");
  else print("No");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void main_sub(void);
int main(int argc, char* argv[]) {
    cout << std::fixed << std::setprecision(10);
    main_sub();
    return 0;
}
// int を int64_t にする
// g++ に -DUSE_STRICT_INT をつけるか、
// 下のコメントアウトを外すと無効化
// #define USE_STRICT_INT
using i64 = int64_t;
#ifndef USE_STRICT_INT
#define int i64
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = (1 << 30);
constexpr i64 INFL = (1LL << 62);
constexpr i64 MOD = 1000000007;

//
// O(N)で前処理をし、O(1)で二項係数(mod)を求める
//
// ref: http://drken1215.hatenablog.com/entry/2018/06/08/210000
// verify: https://atcoder.jp/contests/abc145/tasks/abc145_d
struct Comb {
    using i64 = int64_t;
    const i64 mod;
    std::vector<i64> fact;     // a!
    std::vector<i64> factinv;  // (a!)^-1
    std::vector<i64> inv;      // mod. p における 1,2,...,n の逆元
    Comb(int maximum, i64 m)
        : mod(m), fact(maximum, 0), factinv(maximum, 0), inv(maximum, 0) {
        // テーブルを作る前処理
        fact[0] = factinv[0] = 1;
        fact[1] = factinv[1] = 1;
        inv[1] = 1;
        for (i64 i = 2; i < maximum; ++i) {
            fact[i] = fact[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            factinv[i] = factinv[i - 1] * inv[i] % mod;
        }
    }
    i64 nCk(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fact[n] * (factinv[k] * factinv[n - k] % mod) % mod;
    }
};

void main_sub(void) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    int ans{0};

    Comb c(1000000, MOD);
    rep(i, n) {
        int now = c.nCk(i, k - 1) % MOD;
        ans += (now * a[n - 1 - i]) % MOD;
        ans %= MOD;
        ans -= (now * a[i]) % MOD;
        ans %= MOD;
    }
    cout << -ans << endl;

    return;
}

Measured memory_bytes: 24448
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll D;
    cin>>D;
    vll c(27);
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    vector<vll> s(D+1,vll(27));
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
    ll score=0;
    vi last_day(27,0);
    for(int i=1;i<=D;i++){
        ll max_del_sc=0;int idx=0;
        for(int k=1;k<=26;k++){
            ll del_sc=s[i][k];
            for(int j=1;j<=26;j++){
                if(j==k)continue;
                del_sc-=c[j]*(i-last_day[j]);
            }
            if(k==1){
                idx=1;max_del_sc=del_sc;
            }else{
                if(del_sc>max_del_sc){
                    idx=k;max_del_sc=del_sc;
                }
            }
        }
        last_day[idx]=i;
        cout<<idx<<endl;
    }

}


Measured memory_bytes: 3720
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    char c;
    cin >> c;
    c++;
    cout << c;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	string s;
	int ans=999;
	cin >> s;
	for (int i = 0;i < s.length()-2;i++) {
		int num = (s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		ans = min(ans, abs(753 - num));
		
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))

typedef long long LL;
typedef pair<LL, LL> PLL;

LL cb[57][75];

LL c(LL n, LL k) {
	if (k > (n / 2)) { k = n - k; }
	if (k<0 || k>n) {
		return 0;
	}
	if (k < 1) {
		return 1;
	}
	if (n == k) {
		return 1;
	}
	LL& ret = cb[n][k];
	if (ret != -1) {
		return ret;
	}
	return ret = (c(n - 1, k) + c(n - 1, k - 1));
}

LL fac(LL n) {
	LL ret = 1;
	if (n == 0) { return 0; }
	while (n >= 1) {ret *= n; n--;}
	return ret;
}

bool isAllSame(vector<LL>& v,LL st, LL fin) {
	return v[st] == v[fin - 1];
}

int main(void)
{
	memset(cb, -1, sizeof(cb));
	LL n, a, b;
	sci(n), sci(a), sci(b);
	vector<LL> v(n,0),prefix(n,0);
	for (int i = 0; i < n; i++) sci(v[i]); 
	sort(v.begin(), v.end(), std::greater<LL>());
	prefix[0] = v[0];
	for (int i = 1; i < n; i++) prefix[i] = prefix[i - 1] + v[i];
	//for (int i = 0; i < v.size(); i++) {printf("%lld ", v[i]);}
	double avg = (double)prefix[a - 1] / a; printf("%lf\n", avg);
	LL ans = 0;
	LL pick = v[0], uni = 0, cnt = 1, samenumcnt = 0;
	map<LL, LL> mp;
	for (int i = 0; i < a; i++) {mp[v[i]]++;}

	for (int i = 0; i < v.size(); i++) {
		if (isAllSame(v, i, a)) {
			uni += 1; 
			if(i<a){
				samenumcnt += 1;
			}
		}
	}
	if (samenumcnt == a) {
		for (int i = a; i <= b; i++) {
			ans += c(uni, i);
		}
	}
	else {	
		ans += c(uni, samenumcnt); 
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
V[]={1e3,500,100,50,10,5,1};char*R="NEDMYWJ";v,n,s=1e3;main(c){for(;c=getchar()+1;s=v)n=c-11?(v=V[strchr(R,c)-R],n+v-s*2*(s<v)):!printf("%d\n",n,v=*V);}

Measured memory_bytes: 0
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main() {
	int R;
	cin >> R;
	if (R < 1200)puts("ABC");
	else if (R < 2800)puts("ARC");
	else puts("AGC");

	return(0);
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

Q,H,S,D=get_i
N=gets.to_i
q1=min(H,Q*2)
q2=min(S,q1*2)
q3=min(D,q2*2)
puts N/2*q3+(N%2)*q2

Measured memory_bytes: 1788
use POSIX qw(floor ceil);

my $n = <>; chomp $n;
my $ans1 = floor($n / (1.08));
my $ans2 = ceil($n / (1.08));

if (floor($ans1 * 1.08) == $n) {
    print $ans1;
}
elsif (floor($ans2 * 1.08) == $n) {
    print $ans2;
}
else {
    print ':(';
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, ans;
int main() {
	cin >> n;
	vector<ll> s(n);
	REP(i, n)cin >> s[i];
	sort(ALL(s));
	REP(i, n) {
		FOR(j, i + 1, n) {
			auto a = lower_bound(ALL(s), s[i] + s[j]);
			ll b = n - j - 1;
			ll c = n - (a - s.begin());
			ll d = b - c;
			//cout << i << " " << j << " " << *a  << " " << b << " " << d<< endl;
			ans += max(0ll, d);
		}
	}
	cout << ans << endl;
}


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

using namespace std;

int main(){
  string ss[3] = { string("Sunny"), string("Cloudy"), string("Rainy") };
  string s;
  cin >> s;

  if( s == ss[0] ){
    std::cout << ss[1] << '\n';
  }else if( s == ss[1] ){
    std::cout << ss[2] << '\n';
  }else{
    std::cout << ss[0] << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={0, 1, 0, -1};
int dy[]={-1, 0, 1, 0};

/* sample
int array[3][5] = {
    {  1,  2,  3,  4,  5, },
    {  2,  4,  6,  8, 10, },
    {  3,  6,  9, 12, 15, },
};
*/

int n,h[405][405],num[405][405];
int ss[][7] = {
	{ 0,0,0,0,0,0,0, },
	{ 0,0,3,5,2,4,0, },
	{ 0,4,0,1,6,0,3, },
	{ 0,2,6,0,0,1,5, },
	{ 0,5,1,0,0,6,2, },
	{ 0,3,0,6,1,0,4, },
	{ 0,0,4,2,5,3,0, },
};

int main(){
	while(true){
		cin >> n;
    	if(n == 0)break;
    	for(int i = 0;i < 400;i++){
      		for(int j = 0;j < 400;j++){
        		h[i][j] = 0;
        		num[i][j] = -1;
      		}
    	}
		for(int ii = 0;ii < n;ii++){
			int t,f;
			cin >> t >> f;
			int s = ss[t][f];
			int side[] = {f,s,7-f,7-s};
			int nmax = -1,rot = -1;
			int x = 200,y = 200;
			bool flag = false;
			for(int k = 0;k < 4;k++){
				if(side[k] >= 4 && side[k] > nmax && h[x][y] > h[x+dx[k]][y+dy[k]]){
					rot = k;
					nmax = side[k];
					flag = true;
				}
			}
			while(flag == true){
				flag = false;
				x = x + dx[rot]; y = y + dy[rot];
				if(rot == 0){
					int f_tmp = f;
					f = t;
					t = 7 - f_tmp;
				}else if(rot == 1){
					int s_tmp = s;
					s = t;
					t = 7 - s_tmp;
				}else if(rot == 2){
					int t_tmp = t;
					t = f;
					f = 7 - t_tmp;
				}else{
					int t_tmp = t;
					t = s;
					s = 7 - t_tmp;
				}
				nmax = -1; 
				rot = -1;
				side[0] = f; side[1] = s; side[2] = 7-f; side[3] = 7-s;
				for(int k = 0;k < 4;k++){
					if(side[k] >= 4 && side[k] > nmax && h[x][y] > h[x+dx[k]][y+dy[k]]){
						rot = k;
						nmax = side[k];
						flag = true;
					}
				}
			}
			h[x][y]++;
			num[x][y] = t;
		}
		int ans[7];
		for(int i = 1;i <= 6;i++) ans[i] = 0;
		for(int i = 0;i < 400;i++){
			for(int j = 0;j < 400;j++){
				if(num[i][j] >= 1) ans[num[i][j]]++;

			}
		}
		cout << ans[1];
		for(int i = 2;i <= 6;i++){
			cout << " " << ans[i];
		}
		cout << endl;
  	}
}


Measured memory_bytes: 4372
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll N;
map<int, ll> dp[200000];
vector<int> G[200000];
int c[200000];
ll cnt_ch[200000];
bool used[200000];
ll ans[200000];

int dfs(int v){
    int idx = v;
    cnt_ch[v] = 1;
    dp[idx][c[v]] = cnt_ch[v];
    used[v] = true;
    for(int to : G[v]){
        if(!used[to]){
            int idx_to = dfs(to);
            cnt_ch[v] += cnt_ch[to];
            // for(auto i : dp[idx_to]) cout << i.first << '-' << i.second << ' ';
            // cout << endl;
            if(dp[idx_to].count(c[v]) != 0){
                ll cnt = dp[idx_to][c[v]];
                ll dif = cnt_ch[to]-cnt;
                ans[c[v]] -= (dif*(dif+1))/2;
            }else{
                ans[c[v]] -= (cnt_ch[to]*(cnt_ch[to]+1))/2;
            }
            if(dp[idx].size() < dp[idx_to].size()) swap(idx, idx_to);
            for(auto i : dp[idx_to]){
                int col = i.first; ll cnt = i.second;
                if(col == c[v]){
                    
                }else if(dp[idx].count(col) == 0){
                    dp[idx][col] = cnt;
                }else{
                    dp[idx][col] += cnt;
                }
            }
        }
    }
    dp[idx][c[v]] = cnt_ch[v];
    return idx;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> c[i];
        c[i]--;
    }
    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll all = (N*(N+1))/2;
    for(int i = 0; i < N; i++){
        ans[i] = all;
    }
    int idx = dfs(0);
    for(int i = 0; i < N; i++){
        if(i != c[0]){
            if(dp[idx].count(i) != 0){
                ll dif = N-dp[idx][i];
                ans[i] -= (dif*(dif+1))/2;
            }else{
                ans[i] = 0;
            }
        }
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 88956
from itertools import permutations

N, M, R = map(int, input().split())
T = list(map(int, input().split()))
grid = [[float('inf')] * N for _ in range(N)]

for i in range(N):
    grid[i][i] = 0
for i in range(M):
    A, B, C = map(int, input().split())
    A -= 1; B -= 1
    if grid[A][B] > C:
        grid[A][B] = C
        grid[B][A] = C

for k in range(N):
    for i in range(N):
        for j in range(N):
            grid[i][j] = min(grid[i][j], grid[i][k] + grid[k][j])

ans = float('inf')
for path in permutations(T):
    cnt = 0
    for i in range(R - 1):
        s = path[i] - 1
        g = path[i + 1] - 1
        cnt += grid[s][g]
    ans = min(ans, cnt)

print(ans)


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

void solve(long long A, long long B){
    vector<int> factors;
    ll a = __gcd(A, B);
    bitset<1000001> bs;
    vector<ll> primes;
    bs.set();
    bs[0] = 0;
    bs[1] = 0;
    for (ll i = 2; i <= 1e6; i++) {
      if (bs[i]) {
	  primes.push_back(i);
          for (ll j = i * i; j <= 1e6; j += i) {
	      bs[j] = 0;
          }
      }
    }
    ll res = 1;
    for (auto prime : primes) {
	if (a % prime == 0) res++;
	while (a % prime == 0) a /= prime;
    }
    if (a != 1) res++;
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int INF=1e9;
int main(void){
    int d, g;
    cin>>d>>g;
    g/=100;
    vector<pair<int, int> > v(d);
    rep(i, d) {
        int a, b;
        cin>>a>>b;
        b/=100;
        v[i]=make_pair(a, b);
    }
    int ans=INF;
    /*bit全探索*/
    for(int i=0;i<(1<<d);i++){
        int tmp=0;
        int num=0;
        int firstzero=0;
        for(int j=0;j<d;j++){
            if((i>>j)&1){
                tmp+=((j+1)*v[j].first+v[j].second);
                num+=v[j].first; 
            }
            else {
                firstzero=j;
            }
        }
        if(tmp>g) ans=min(ans, num);
        else {
            int k=0;
            int flag=0;
            while(tmp<g){
                if(k>=v[firstzero].first) {
                    flag=1;
                    break;
                }
                tmp+=firstzero+1;
                num++;
                k++;
            }
            if(flag==0) ans=min(ans, num);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    string s;
    cin >> s;
    for (char c : s) {
        if (c == ',') c = ' ';
        cout << c;
    }
    cout << endl;
}


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

N, M = MAP()
PY = [LIST() for _ in range(M)]
PY_ = deepcopy(PY)
PY_.sort(key = lambda x: (x[0],x[1]))

tmp = 0
i = 0
lis = []
dic = {}
for p, y in PY_:
	if p == tmp:
		i += 1
	else: 
		lis.append([])
		tmp = p
		i = 1
	dic[str(p)+"_"+str(y)] = str(p).zfill(6)+str(i).zfill(6)

for p, y in PY:
	print(dic[str(p)+"_"+str(y)])

Measured memory_bytes: 69268
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInteger s = (read :: String -> Integer) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [a, b, x] <- map strToInteger . words <$> getLine
    -- 出力
    putStrLn . show $ b `div` x - (a-1) `div` x


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int numberOfDigets(int x) {
    int res = 0;
    if (x == 0) return 1;
    while (x) {
        res++;
        x /= 10;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int d = numberOfDigets(i);
        if (d&1) ans++;        
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; string s;
	cin >>n>>s;
	if(n%2){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[n/2+i]) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}



Measured memory_bytes: 256
k=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

from collections import deque

q=deque([1,2,3,4,5,6,7,8,9])
ansl=[]
s=1
while len(str(s))<=10:
    s=q.popleft()
    ansl.append(s)
    sl=list(str(s))
    last_digit=int(sl[-1])
    for digit in range(max(0,last_digit-1),min(last_digit+1,9)+1):
        newval=int(str(s)+str(digit))
        #ansl.append(int(str(s)+str(digit)))
        q.append(newval)
print(ansl[k-1])


Measured memory_bytes: 26588