akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc110/tasks/abc110_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

map<ll, int> enumpr(ll n) {
    map<ll, int> V;

    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            V[i]++;
            n /= i;
        }
    }
    if (n > 1)
        V[n]++;
    return V;
}

ll modpow(ll a, ll n) {
    ll r = 1;
    while (n)
        r = r * ((n % 2) ? a : 1) % MOD, a = a * a % MOD, n >>= 1;
    return r;
}

ll comb(int P_, int Q_) {
    if (P_ < 0 || Q_ < 0 || Q_ > P_)
        return 0;
    ll p = 1, q = 1;
    Q_ = min(Q_, P_ - Q_);
    for (int i = 1; i <= Q_; i++)
        p = p * P_ % MOD, q = q * i % MOD, P_--;

    return p * modpow(q, MOD - 2) % MOD;
}
ll hcomb(int P_, int Q_) {
    return (P_ == 0 && Q_ == 0) ? 1 : comb(P_ + Q_ - 1, Q_);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    map<ll, int> mp = enumpr(m);

    ll ans = 1;
    for (auto x : mp) {
        ans = (ans * comb(x.second + n - 1, n - 1)) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    map<string,int>mymap;
    string ss;
    int mx=0;
    for(i=0; i<n; i++)
    {
        cin>>ss;
        mymap[ss]++;
        mx = max(mx,mymap[ss]);
    }
    for(auto it:mymap)
    {
        if(it.second==mx)
            cout<<it.first<<endl;
    }
    return 0;

}


Measured memory_bytes: 25216
//06
#include<iostream>
#include<map>
#include<algorithm>

using namespace std;

int p[100000];

int find(int x){
  return (x==p[x])?x:(p[x]=find(p[x]));
}

void unite(int a,int b){
  p[find(a)]=find(b);
}

int main(){
  for(int n;cin>>n,n;){
    int o[100000][2],f[100000][2];
    for(int i=0;i<n;i++){
      p[i]=i;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<2;j++){
	cin>>o[i][j]>>f[i][j];
	unite(i,o[i][j]);
      }
    }
    map<int,int> m;
    for(int i=0;i<n;i++){
      for(int j=0;j<2;j++){
	m[find(i)]=max(m[find(i)],f[i][j]);
      }
    }
    map<int,int> mm;
    for(int i=0;i<n;i++){
      for(int j=0;j<2;j++){
	mm[find(i)]+=m[find(i)]==f[i][j];
      }
    }
    int r=1;
    for(map<int,int>::iterator it=mm.begin();it!=mm.end();it++){
      r=r*it->second/2%10007;
    }
    cout<<r<<endl;
  }
  return 0;
}

Measured memory_bytes: 1480
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	string s;
	cin >> s;
	cout << s.substr(0, s.length() - 8) << endl;

	return 0;
}

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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(C-(A-B)<=0){
        cout << 0 << endl;
        exit(0);
    }
    cout << C-(A-B) << endl;
    return 0;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

pn=[2];A=1460
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:
        pn.append(L)
arr=[]
for i in pn:
    if i%5==1:
        arr.append(str(i))

n=ii()

print(" ".join(arr[:n]))

Measured memory_bytes: 63980
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   it.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> //indexed_set;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b,ll m) {ll res=1;a%=m;for(;b;b>>=1){if(b&1)res=res*a%m;a=a*a%m;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll k;
		cin>>k;
		queue<ll>q;
		for(int i=1;i<10;i++){
			q.push(i);
		}
		ll ans;
		for(int i=0;i<k;i++){
			ans=q.front();
			// cout<<i<<" "<<ans<<endl;
			q.pop();
			if(ans%10>0){
				q.push(ans*10+(ans%10)-1);
			}
			q.push(ans*10+(ans%10));
			if(ans%10<9){
				q.push(ans*10+(ans%10)+1);
			}
		}
		cout<<ans<<endl;
	}
}

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

int main()
{
    int n;
    vector <string> s;
    vector <int> t;
    string tmp_s;
    int tmp_t;
    
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> tmp_s >> tmp_t;
        s.push_back(tmp_s);
        t.push_back(tmp_t);
    }
    
    string x;
    cin >> x;

    int cnt=0;
    
    for(int i=0; i<n; i++){
        if(s[i] == x){
            for(int j=i+1; j<n; j++){
                cnt += t[j];
            }
            break;
        }
    }
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	
	void doIt() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for(int i = 0; i < K; i++) {
			int d = sc.nextInt();
			for(int j = 0; j < d; j++) {
				set.add(sc.nextInt());
			}
		}
		System.out.println(N - set.size());
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 46128
#include <stdio.h>
#define SIZE 2001

char resultTable[SIZE];
int n,q,elems[20];

void calc(int sum,int index){
	if(index == n){
		if(sum >= 1 && sum <= 2000){
			resultTable[sum] = 'y';
		}
	}else{
		calc(sum+elems[index],index+1);
		calc(sum,index+1);
	}
}

int main(){

	for(int i = 0;i < SIZE; i++) resultTable[i] = 'n';

	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%d",&elems[i]);
	calc(0,0);

	scanf("%d",&q);

	int tmp;
	for(int i = 0; i < q; i++){
		scanf("%d",&tmp);
		if(resultTable[tmp] == 'y'){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
}



Measured memory_bytes: 2700
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    char c;
    cin>>c;
    if(c=='A') cout<<'T';
    else if(c=='C') cout<<'G';
    else if(c=='T') cout<<'A';
    else cout<<'C';
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	int l[100005],r[100005];
	int ans=0;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		cin>>l[i]>>r[i];
	int a=0,b=n;
	for(int i=1;i<=m;i++)
	{
		if(a<l[i])
		   a=l[i];
		if(b>r[i])
		   b=r[i];
	}
	ans=b-a+1;
	if(ans<0)
	   cout<<"0"<<endl;
	else if(ans>n)
	   cout<<n<<endl;
	else
	   cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
using namespace std;
using ll =long long;
int main() {
	ll N, K;
	cin >> N>> K;
	ll x;
	int i=2;
N= N % K;
	while (i) {
		if (N - K < 0) {
			i--;
		}
		x = N;
		N = labs(N - K);
	}
	x <= N ?cout<<x:cout<<N;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long 
#define int long long //
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define LN outchar('\n')
#define endl '\n'
using namespace std;

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}
template <typename T, typename TT> inline void inpos(T &n, TT &m) { inpos(n); inpos(m);}
template <typename T, typename TT ,typename TTT> inline void inpos(T &n, TT &m, TTT &o) { inpos(n,m); inpos(o);}
template <typename T, typename TT ,typename TTT, typename TTTT> inline void inpos(T &n, TT &m, TTT &o , TTTT &p) { inpos(n,m); inpos(o,p);}

const int nax = 1e5+5;
int color[nax][2];
const int mod = 1e9 + 7;

vector <vector <int> > graph;



/* 0 Is Black */
void dfs (int node , int p ) {
	
	int whiteChild = 1 ; int allChild = 1;
	for (auto elem : graph[node] ) {
		if (elem == p) {continue;}
		dfs (elem , node);
		allChild *= ((color[elem][0] + color[elem][1])%mod); allChild%=mod; 
		whiteChild *= (color[elem][1]);  whiteChild %=mod;
	}

	
	color[node][0] = whiteChild;
	color[node][1] = allChild;
}


int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;
	int u, v;
	graph.resize(n);
	for (int i = 0; i<n-1; i++) {
		cin >> u >> v;
		u--; v--;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	dfs(0, -1);
	cout << (color[0][0] + color[0][1])%mod << endl;

	
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int h,w;
vector<string> grid;

int dp[1001][1001] = {0};

const int MOD = 1000000007;
void add(int &a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

int main(){
    cin >> h >> w;
    grid.resize(h);

    rep(i,h) cin >> grid[i];
    

    dp[0][0] = 1;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if((i+1) < h && grid[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
            if((j+1) < w && grid[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);
        }
    }

    dunk(dp[h-1][w-1]);
}

Measured memory_bytes: 5248
D = int(input())

cs = [int(i) for i in input().split()]

last = {n: 0 for n in range(1, 27)}
ans = []
for day in range(1, D+1):
    ss = [int(i) for i in input().split()]
    max_score = 0
    max_i = 1
    for i, s in enumerate(ss, 1):
        human = day-last[i]
        s_human = s + cs[i-1] * human
        if s_human > max_score:
            max_score = s_human
            max_i = i
    ans.append(max_i)
    last[max_i] = day
for a in ans:
    print(a)

Measured memory_bytes: 9224
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  string S;
  cin >>S;
  int count=1;
  int counting=0;
  rep(i,N-1) {
    if(S.at(i)==S.at(i+1)) {
      count++;
    }
if (S.at(i)!=S.at(i+1)) {
     counting++;
  count=1;
}
  }
  
      
  
  cout<<counting+1<<endl;
}
    
      


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
int64_t INF = 10010010010;
// int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;
// int64_t INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    vi colar(9);
    rep(i,n){
        ll col = a.at(i)/400;
        if(a.at(i)/400>=8) col = 8;
        colar.at(col)++;
    }
    ll maxn=0,minn=0;
    rep(i,8) if(colar.at(i)>0) minn++,maxn++;
    if(colar.at(8)>0) maxn += colar.at(8);
    if(minn==0) minn = 1;
    cout << minn << " " << maxn << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	for(;;){
		int hist[3] = {0};
		int input[5];
		for(int i=0; i<5; ++i){
			scanf("%d", &input[i]);
			--input[i];
			if(input[i] == -1)
				break;
			hist[input[i]]++;
		}
		if(input[0] == -1)
			break;
		
		for(int i=0; i<5; ++i){
			bool weak = !!hist[(input[i]+1)%3];
			bool strong = !!hist[(input[i]+2)%3];
			printf("%d\n", weak ? (strong ? 3 : 1) : (strong ? 2 : 3));
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(){
	int S;
	int s, m, h;
	scanf("%d", &S);
	s = S%60;
	S /= 60;
	m = S%60;
	S /= 60;
	h = S;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println((H * W) - (h * W) - (w * H) + (h * w));
    }
}

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

int main(void) {
    int h, w;
    while (1) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i == 0 || i == h-1 || j == 0 || j == w-1) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
    string w; cin >> w;
    int n = 'z' - 'a';
    vector<int> count(n);
    for(int i = 0; i < w.size(); ++i) ++count[w[i] - 'a'];

    string ans = "Yes";
    REP(i, n) {
        if (count[i] % 2 != 0) ans = "No";
    }

    cout << ans << endl;

    return 0;
}

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

int H, W;
char field[20][20];
bool visited[20][20];

struct Loc {
    int y;
    int x;
    int step;
};

// 四方向への移動ベクトル
const int dy[4] = {1, 0, -1, 0};
const int dx[4] = {0, 1, 0, -1};

int count_steps_by_BFS (int sy, int sx, int gy, int gx) {
    Loc start_loc = {sy, sx, 0};
    queue<Loc> search_queue;
    search_queue.push(start_loc);
    memset(visited, false, sizeof(visited));
    visited[sy][sx] = true;

    while(!search_queue.empty()) {
        // キューから探索対象のセルを取り出す
        Loc loc = search_queue.front();
        search_queue.pop();

        int y = loc.y;
        int x = loc.x;
        int step = loc.step;
        //cout << y << ' ' << x << " (" << step << ")" << endl; // **** debug ****

        if (y == gy && x == gx) return step; // ゴールに到達

        // 四方向の探索を予約
        for (int dir = 0; dir < 4; dir++) {
            int next_y = y + dy[dir];
            int next_x = x + dx[dir];

            if (next_y < 0 || next_y >= H || next_x < 0 || next_x >= W) continue; // 場外
            if (field[next_y][next_x] == '#') continue; // 壁
            if (visited[next_y][next_x]) continue; // 探索済み
            Loc next_loc = {next_y, next_x, step + 1};
            search_queue.push(next_loc);
            visited[next_y][next_x] = true;
        }
    }

	return -1; // ゴールできなかった場合
}

int main(){
    cin >> H >> W;

    string S;
    for (int i=0; i<H; i++) {
    	cin >> S;
    	for (int j=0; j<W; j++) {
    		field[i][j] = S[j];
    	}
    }

    int ans = 0;

    for (int i=0; i<H; i++) {
    	for (int j=0; j<W; j++) {
    		if (field[i][j] == '#') continue;
    		for (int k=0; k<H; k++) {
    			for (int l=0; l<W; l++) {
    				if (field[k][l] == '#') continue;
    				int steps = count_steps_by_BFS(i, j, k, l);
    				if (ans < steps) {
    					ans = steps;
    				}
    			}
    		}
    	}
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define mod 1000000007

int n,x,y,c[N],w[N];
vector<pair<int,int> > q[N];
vector<int> v[N];
map<int,int> h;
long long e[N],ans;

void solve(int x){
	ans=ans*(++h[0])%mod*e[++h[c[x]]]%mod;c[x]=0;
	for (int i=0;i<(int)v[x].size();i++)
		if (c[v[x][i]]) solve(v[x][i]);
}


int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();x=read();y=read();
	for (int i=1;i<=n;i++){
		c[i]=read();w[i]=read();
		q[c[i]].push_back(make_pair(w[i],i));
	}
	for (int i=1;i<=n;i++)
		if (q[i].size()){
			sort(q[i].begin(),q[i].end());
			q[0].push_back(q[i][0]);
			for (int j=1;j<(int)q[i].size();j++)
				if (q[i][0].first+q[i][j].first<=x)
				v[q[i][0].second].push_back(q[i][j].second),
				v[q[i][j].second].push_back(q[i][0].second);
		}
	sort(q[0].begin(),q[0].end());
	for (int i=1;i<=n;i++)
		if (c[i]!=c[q[0][0].second]){
			if (w[i]+q[0][0].first<=y)
			v[i].push_back(q[0][0].second),
			v[q[0][0].second].push_back(i);
		}
		else {
			if (q[0].size()>=2&&w[i]+q[0][1].first<=y)
			v[i].push_back(q[0][1].second),
			v[q[0][1].second].push_back(i);
		}
	ans=e[1]=1;
	for (int i=2;i<=n;i++)
		e[i]=(-(mod/i)*e[mod%i]%mod+mod)%mod;
	for (int i=1;i<=n;i++)
		if (c[i]) solve(i),h.clear();
	printf("%lld\n",ans);return 0;
}

Measured memory_bytes: 78360
n,l = map(int,input().split())

aji = []
for i in range(1,n+1):
    aji.append(l + i - 1)
if 0 in aji:
    print(sum(aji))
elif aji[0] > 0:
    print(sum(aji) - aji[0])
else:
    print(sum(aji) - aji[-1])

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

int main() {
  int q,w,e,r;
  cin>>q>>w>>e>>r;
  if(q+w<e+r){
cout<<"Right"<<endl;
  }
else if(q+w==e+r){
cout<<"Balanced"<<endl;
}
else if(q+w>e+r){
cout<<"Left"<<endl;
}
}
    

  



Measured memory_bytes: 256
def main():
    n,s = map(int,input().split())
    A = list(map(int,input().split()))
    dp = [[0 for j in range(s+1)] for i in range(n+1)]

    mod = 998244353

    ans = 0

    dp[0][0] = 1

    for i in range(n):
        dp[i+1][0] = dp[i][0]+1
        for j in range(1,s+1):
            if j-A[i] >= 0:
                dp[i+1][j] += dp[i][j-A[i]]
            dp[i+1][j] = (dp[i][j]+dp[i+1][j])%mod

        ans = (ans+dp[i+1][-1])%mod
    
    print(ans%mod)
if __name__ == "__main__":
    main()


Measured memory_bytes: 120028
IDENTIFICATION  DIVISION.
        PROGRAM-ID.      christmas.
        ENVIRONMENT    DIVISION.
        DATA           DIVISION.
        WORKING-STORAGE SECTION.
        77  NUM         PIC 9(2).
        PROCEDURE       DIVISION.
        MAIN.
        ACCEPT  NUM     FROM CONSOLE.
        IF NUM = 25 THEN
            DISPLAY "Christmas"  UPON CONSOLE
        ELSE IF NUM = 24 THEN
            DISPLAY  "Christmas Eve" UPON CONSOLE
        ELSE IF NUM = 23 THEN
            DISPLAY  "Christmas Eve Eve" UPON CONSOLE
        ELSE IF NUM = 22 THEN
            DISPLAY  "Christmas Eve Eve Eve" UPON CONSOLE  
        END-IF 
        END-IF
        END-IF.
        STOP RUN.

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5;
const int mod = 1e9 + 7;
int n, a[100][100], b[100][100];
ll k, ans;
int res[100][100];
void solve() {
	for (int i = 1; i <= n; ++i) res[i][i] = 1;
	while (k) {
		if (k & 1) {
			for (int i = 1; i <= n; ++i)
				for (int j = 1; j <= n; ++j) 	
					b[i][j] = 0;
			for (int i = 1; i <= n; ++i)
				for (int j = 1; j <= n; ++j)
					for (int k = 1; k <= n; ++k)
						(b[i][j] += (ll)res[i][k] * a[k][j] % mod) %= mod;
			for (int i = 1; i <= n; ++i)
				for (int j = 1; j <= n; ++j) 	
					res[i][j] = b[i][j];
		}
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j) 	
				b[i][j] = 0;
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				for (int k = 1; k <= n; ++k)
					(b[i][j] += (ll)a[i][k] * a[k][j] % mod) %= mod;
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j) 	
				a[i][j] = b[i][j];
		k >>= 1;
	}
}
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			cin >> a[i][j];
	solve();
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			(ans += res[i][j]) %= mod;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
using namespace std;

typedef complex<double> P;
struct L : public vector<P>{
    L(const P &a, const P &b){
        push_back(a), push_back(b);
    }
};
const double EPS = 1e-8;

namespace std {
  bool operator < (const P& a, const P& b) {
    return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
  }
}

double cross(const P &a, const P &b){
    return imag(conj(a)*b);
}

double dot(const P &a, const P &b){
    return real(conj(a)*b);
}

int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > 0) return +1;
    if(cross(b,c) < 0) return -1;
    if(dot(b,c) < 0) return +2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

P crosspoint(const L &l, const L &m) {
    double A = cross(l[1] - l[0], m[1] - m[0]);
    double B = cross(l[1] - l[0], l[1] - m[0]);
    if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
    return m[0] + B / A * (m[1] - m[0]);
}

bool intersectHalfLS(const L &l, const L &s){
    bool flag1 = (cross(l[1]-l[0], s[0]-l[0])*cross(l[1]-l[0], s[1]-l[0]) < EPS);
    bool flag2 = (norm(crosspoint(l, s) - s[1]) <EPS);
    return flag1 && !flag2;
}

#define curr(G, i) G[i%n]
#define next(G, i) G[(i+1)%n]

double area(vector<P> &G){
    int n = G.size();

    double S = 0;
    for (int i=0;i<n;i++){
        P p = curr(G, i);
        P q = next(G, i);
        S += (1.0/2)*cross(p, q);
    }

    return S;
}

double convexCut(vector<P> &G, P &p1, P &p2){
    int n= G.size();
    L l(p1, p2);
    vector<P> leftG;

    bool flag = true;
    for (int i=0;i<n;i++){
        if(ccw(p1, p2, G[i]) == 1){
            flag = false;
        }
    }

    if (flag) return 0;

    //??????
    for (int i=0;i<n;i++){
        if(ccw(p1, p2, curr(G,i))!= -1){
            leftG.push_back(curr(G,i));
            if(ccw(p1, p2, next(G,i)) == -1 ){
                L s(curr(G, i), next(G, i));
                leftG.push_back(crosspoint(l, s));
            }
        }else{
            if(ccw(p1, p2, next(G,i)) != -1 ){
                L s(curr(G, i), next(G, i));
                leftG.push_back(crosspoint(l, s));
            }
        }
    }
    /*
    for (int x=0;x<leftG.size();x++){
        cout << leftG[x] << " ";
    }
    cout << endl;
    */
    return area(leftG);
}

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

    vector<P> G;
    P p, q;
    for (int i=0;i<n;i++){
        cin >> p.real() >> p.imag();
        G.push_back(p);
    }

    cin >> Q;
    for (int i=0;i<Q;i++){
        cin >> p.real() >> p.imag() >> q.real() >> q.imag();
        printf("%.7f\n", convexCut(G, p, q));
    }

    return 0;
}

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

int main(){
    ll n; cin >> n;

    if(n % 2 == 1){
        // odd
        cout << 0 << endl;
    }else{
        // even
        ll d = 10;
        ll ans = 0;
        while(n >= d){
            ans += n/d;
            d*=5;
        }
        cout << ans << endl;

    }

    return 0;
}

Measured memory_bytes: 256
#encoding utf-8

n = int(input())
words = [0]*n
for i in range(n):
    words[i] = str(input())

state = 1

for i in range(n-1):
    # print(list(words[i])[-1],list(words[i+1])[0])
    if list(words[i])[-1] == list(words[i+1])[0]:
        state = 1
    else:
        state = 0
        break

if len(list(set(words))) < n:
    state = 0

if state == 1:
    print("Yes")
else:
    print("No")

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++)cin>>a[i];

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

  cout<<ans/2<<endl;
}


Measured memory_bytes: 640
import io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val map = mu.HashMap.empty[Long, Long]

  val Array(n, m) = in.readLine.split(" ").map(_.toInt)

  in.readLine.split(" ").map(_.toLong).foreach { a =>
    map(a) = map.getOrElse(a, 0L) + 1
  }

  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toLong))
    .foreach { e =>
      val v = e(0)
      val k = e(1)
      map(k) = map.getOrElse(k, 0L) + v
    }

  val entries = map.iterator.toArray.sortBy(_._1)(Ordering[Long].reverse)

  def rec(acc: Long, cnt: Long, i:Int): Long = {
    val k = entries(i)._1
    val v = entries(i)._2
    if(cnt + v >= n) acc + k * (n - cnt)
    else rec(acc + (k * v), cnt + v, i + 1)
  }

  val ans = rec(0, 0, 0)
  println(ans)
}

Measured memory_bytes: 142192
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define true 1
#define false 0
typedef long long ll;
typedef unsigned char Uchar; 

int main(void){

int i = 0,j = 0;
ll a[200002];
  int n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
   scanf("%lld",&a[i]); 
  }
    
  int step = 0;
  ll sub = 0;
  ll sum = 0;
  
  for(i=0;i<n-1;i++){
    if(a[i] > a[i+1]){
     sub = a[i] - a[i+1];
      //printf("%lld[%lld - %lld]\n",sub,a[i],a[i+1]);
      sum += sub;
      a[i+1] += sub;
    }else{
   //   printf("%d\n",i);
    }
  }
    
  printf("%lld",sum);
  

return 0;
}

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

const ll mod=1000000007;

int main() {
  char a;
  cin >> a;
  if(a>='a')cout<<'a'<<endl;
  else cout<<'A'<<endl;
}

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

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    if (abs(a - b) % 2 == 0) cout << abs(a - b) / 2 << endl;
    else {
        long long tmp = a + abs(b - a - 1) / 2;
        long long tmp2 = (n - b + 1) + abs(b - a - 1) / 2;
        cout << min(tmp, tmp2) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using vl = vector<long long>;
using P = pair<long long,long long>;

ll ab(ll x){
	if(x < 0)x *= -1;
	return x;
}

int main(){
	ll n; cin >> n;
	vl w(n); rep(i,n)cin >> w[i];
	ll ans = 100000;
	rep(t,n){
		ll sum1=0,sum2=0;
		rep(i,t)sum1 += w[i];
		for(int i = t;i<n;i++)sum2 += w[i];
		ans = min(ans,ab(sum1-sum2));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
const int MAXN = 1e5+1;
int main()
{
	int N, C, K, i, j, x, ans;
	int D[MAXN];
	scanf("%d%d%d", &N, &C, &K);
	for(i=1; i<=N; ++i)
		scanf("%d", D+i);
	std::sort(D+1, D+N+1);
	i = x = ans = 0;
	D[0] = -K;
	for(j=1; j<=N; ++j)
		if(x>=C || D[j]-D[i]>K)
			++ans, x=1, i=j;
		else ++x;
	printf("%d\n", ans);
}

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

int main() {
    int N;
    cin >> N;
    
    vector<int> a(N+1);
    rep(i,N+1) {
        cin >> a[i];
    }
    
    vector<long int> d_max(N+1), d_min(N+1), max(N+1);
    bool tf = true;
    
    reverse(a.begin(), a.end());
    
    rep(i,N+1) {
        if(i == 0) {
            d_min[i] = a[0];
            d_max[i] = a[0];
        }
        else {
            d_min[i] = (d_min[i-1] + 1) / 2 + a[i];
            d_max[i] = d_max[i-1] + a[i];
        }
    }
    
    if(d_min[N] > 1)
        tf = false;
    
    reverse(d_max.begin(), d_max.end());
    reverse(a.begin(), a.end());
    
    //if(a[N] < 1)
        //tf = false;
    
    rep(i,N+1) {
        if(i == 0)
            max[i] = 1;
        else {
            max[i] = min((max[i-1] - a[i-1]) * 2, d_max[i]);
            //if(max[i] < max[i-1] - a[i-1])
                //tf = false;
        }
    }
    
    long int sum = 0;
    if(tf) {
        rep(i,N+1) {
            sum += max[i];
        }
    }
    else
        sum = -1;
    
    cout << sum << endl;
    
    return 0;
}


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

// Loops
#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 _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(std::vector<long long> A) {
  ll ret = 0;
  rep(i,3) ret += A[i];
  if(ret>21) cout << "bust" << endl;
  else cout << "win" << endl;
}

int main() {
  std::vector<long long> A(3);
  for (int i = 0; i < 3; i++) {
    scanf("%lld", &A[i]);
  }
  solve(std::move(A));
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
	int n, k, m;
	cin >> n >> k;
	m = max(n - k + 1, k - 1);
	vector<ll> fact(n + 2), ifact(n + 2), inv(n + 2);
	fact[0] = fact[1] = ifact[0] = ifact[1] = inv[1] = 1;
	for (int i = 2; i <= m; ++i) {
		fact[i] = fact[i - 1] * i%mod;
		inv[i] = (mod - mod / i)*inv[mod%i] % mod;
		ifact[i] = ifact[i - 1] * inv[i] % mod;
	}
	for (int i = 1; i <= k; ++i) {
		if (n - k + 1 - i >= 0)
			cout << (fact[n - k + 1] * (ifact[n - k + 1 - i] * ifact[i] % mod) % mod)
			* (fact[k - 1] * (ifact[k - i] * ifact[i - 1] % mod) % mod) % mod << endl;
		else cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
ninzuu = int(input())
a_list = list(map(int, input().split()))
min_zahyou = min(a_list)
max_zahyou = max(a_list)
ans = 0

for i in range(min_zahyou, max_zahyou+1):
  tmp_sum = 0
  for j in a_list:
    tmp_sum += (j-i)**2
  if ans == 0 or ans > tmp_sum:
    ans = tmp_sum

print(ans)

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

int main(void) {
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N -1);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
		ans += B[i];
	}
	for (int i = 0; i < N - 1; i++) {
		cin >> C[i];
	}

	for (int i = 0; i < N - 1; i++) {
		if (A[i + 1] == A[i] + 1) {
			ans += C[A[i] - 1];
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <map>
#include <regex>
#include <sstream>
#include <utility>
#include <list>
#include <unordered_set>
#include <unordered_map>
#define endl	'\n'
#define MOD 1000000

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
int dx[] = { 0,1,0,-1 };
int dy[] = { -1,0,1,0 };
int dz[] = { 0,0,0,0,1,-1 };
const int INF = 1000000000;



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin >> n;
	map<string, int> mp;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		sort(s.begin(), s.end());
		mp[s] += 1;
	}

	ll ans = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ll num = (*it).second;
		ans += (num * (num - 1)) >> 1;
	}

	cout << ans;
}


Measured memory_bytes: 11264
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
//#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

const int N = 1e6 + 10;

int main(){
	string str;
	cin>>str;
	int res = 0,cnt = 0;
	repi(i,0,str.size() - 1){
		if(str[i] == 'R'){
			cnt++;
			if(cnt > res)
				res = cnt; 
		}
		else
			cnt = 0;
	} 
	cout<<res<<endl;
	return 0;
} 

Measured memory_bytes: 3636
#include<stdio.h>
int main() {
  int num, num2;
  
  scanf("%d %d", &num, &num2);
  if(num < num2) printf("a < b\n");
  else if(num > num2) printf("a > b\n");
  else printf("a == b\n");

  return 0;
} 

Measured memory_bytes: 1008
ABCD = input()

for i in range(1 << 3):
    exp = ABCD[0]
    for j in range(3):
        if i >> j & 1:
            exp += '+'
        else:
            exp += '-'
        exp += ABCD[j + 1]
    if eval(exp) == 7:
        print(exp + '=7')
        break


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll a, b, c;
  cin >> a >> b >> c;

  if(b - a == c - b) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A, B = [], []

for i in range(n):
    A.append(input())

for i in range(m):
    B.append(input())

def is_contain(i, b_pos):
    containing = True
    for k in range(1, m):
        if A[i+k][b_pos:(b_pos+len(B))] != B[k]:
            containing = False
    return containing

if n < m or len(A) < len(B):
    print("No")
    exit()

for i in range(n - m + 1):
    lineA = A[i]
    lineB = B[0]
    lineB_pos = lineA.find(lineB)
    if lineB_pos >= 0:
        if is_contain(i, lineB_pos):
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;
using Graph = vector<vector<int>>;

void DFS(Graph &tree, vector<bool> &seen, vector<int> &dist, int node)
{
    seen[node] = true;
    for (auto &&subnode : tree[node])
    {
        if (seen[subnode])
            continue;
        dist[subnode] = dist[node] + 1;
        DFS(tree, seen, dist, subnode);
    }
}

int main()
{
    int n, u, v;
    cin >> n >> u >> v;

    Graph tree(n + 1);

    for (int i = 1; i <= n; i++)
    {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<bool> useen(n + 1, false);
    vector<int> udist(n + 1, 0);
    vector<bool> vseen(n + 1, false);
    vector<int> vdist(n + 1, 0);
    DFS(tree, useen, udist, u);
    DFS(tree, vseen, vdist, v);

    int reachablefurthestnode = 0;
    int max_vdist = 0;
    for (int i = 1; i <= n; i++)
    {
        if (udist[i] < vdist[i])
        {
            if (max_vdist < vdist[i])
            {
                max_vdist = vdist[i];
                reachablefurthestnode = i;
            }
        }
    }

    int ans = vdist[reachablefurthestnode] - 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12928
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

int main(){
	int N, M;
	cin>>N>>M;
	vector<Int> A(N);
	REP(i,N)cin>>A[i];
	sort(ALL(A));
	vector<pair<Int,Int> > v;
	REP(i,M){
		Int B,C;
		cin>>B>>C;
		v.push_back({C,B});
	}
	sort(ALL(v));
	reverse(ALL(v));
	Int ans = 0;
	int i = 0;
	for(auto &&p:v){
		if(i == N)break;
		for(int t = 0;t < p.second and i < N;t++,i++){
			if(p.first >= A[i])ans += p.first;
			else break;
		}
	}
	if(i<N){
		for(int j = i;j < N;j++)ans += A[j];
	}
	cout<<ans<<endl;
}


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

int main() {
    int k; cin >> k;
    queue<ll> q;
    for (int i = 1; i <= 9; i++) q.push(i);

    ll x;
    while (k--) {
        x = q.front(); q.pop();
        if (x % 10 != 0) q.push(10 * x + x % 10 - 1);
        q.push(x * 10 + x % 10);
        if (x % 10 != 9) q.push(10 * x + x % 10 + 1);
    }
    cout << x << endl;
}

Measured memory_bytes: 1792
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

queue<int> dat[3];

int main(){
    FOR(i,3){
        while(!dat[i].empty()) dat[i].pop();
        //
        char s[105]; scanf("%s", s);
        for(int j=0; s[j]; j++) dat[i].push(s[j]-'a');
    }
    // do
    int pos = 0;
    while(!dat[pos].empty()){
        int ret = dat[pos].front(); dat[pos].pop();
        pos = ret;
    }
    // print
    printf("%c\n", 'A' + pos);
    return 0;
}


Measured memory_bytes: 256