akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#define M 800008
#define N 200002
int A[N],B[M],C[M],F[N],S,T,a[N],b[M],c[M],e[N],h[N],l,n,q[N],r,t;bool D[N],d[M];
inline void add(int u,int v){b[++t]=a[u],c[a[u]=t]=v,d[t]=true,b[++t]=a[v],c[a[v]=t]=u;}
inline bool bfs()
{
	memset(h+1,-1,T<<2),*h=l=0,*q=S,r=1;
	while(l<r)for(int u=q[l++],i=a[u];i;i=b[i])if(d[i]&&h[c[i]]<0)h[q[r++]=c[i]]=h[u]+1;
	return h[T]>=0;
}
bool dfs(int u)
{
	if(u==T)return true;
	for(int&i=e[u];i;i=b[i])if(d[i]&&h[c[i]]==h[u]+1&&dfs(c[i]))return d[i]=false,d[i^1]=true;
	return false; 
}
void ans(int u)
{
	D[u]=true;
	for(int&i=A[u];i;i=B[i])if(!D[C[i]])t++,F[C[i]]=u,ans(C[i]);
}
int main()
{
	scanf("%d",&n),T=n<<1;
	for(int i=t=1,u,v;i<n;i++)for(scanf("%d",&u);u--;)scanf("%d",&v),add(n+i,v);
	for(int i=2;i<=n;i++)add(i,T);
	for(int i=1;i<n;i++)add(S,n+i);
	for(t=0;bfs();)for(memcpy(e,a,T+1<<2);dfs(S);t++);
	if(t!=n-1)return 0*puts("-1");
	for(int i=2;i<=n;i++)while(a[i]=b[a[i]])if(d[a[i]])e[c[a[i]]-n]=i;
	for(int i=t=1;i<n;i++)while(a[n+i]=b[a[n+i]])if(d[a[n+i]])B[++t]=A[c[a[n+i]]],C[A[c[a[n+i]]]=t]=e[i];
	if(t=0,ans(1),t!=n-1)return 0*puts("-1");
	else for(int i=1;i<n;i++)printf("%d %d\n",F[e[i]],e[i]);
	return 0;
}

Measured memory_bytes: 20352
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    char S[10000]={},T[10000]={};
    cin >> S >> T;
    int lens = strlen(S);
    int lent = strlen(T);
    
    int ans=INF;
    for(int i=0;i <= lens-lent;i++){
        int count=0;
        for(int j=i;j-i < lent;j++){
            if(S[j] != T[j-i]) count++;
        }
        if(ans > count) ans = count;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

ll llabs(ll a, ll b){
  if(a>=b) return a-b;
  else return b-a;
}

ll llmax(ll a, ll b){
  if(a>=b) return a;
  else return b;
}

ll llmin(ll a, ll b){
  if(a<=b) return a;
  else return b;
}


// 降順P番目までは確実に採用される
// 絶対に問題セットに採用されない問題：ジャッジ全員が点数を入れても降順P番目に点数が入らない場合
// そのとき、他の問題への投票は、降順P番目未満の問題
// V問を選ぶ：昇順V-1問目までの場合は、他の問題に投票する場合を考えなくてはいけない　→　不要？？？？
// 初期で降順P番目の問題の点数と比較する必要がありそう

// ジャッジにより最大+m点が加算される
// 降順P番目の問題に加点されてしまうのは、V>Pのとき

// 入れたい問題には、全員が点をいれればいい
// i番目の問題を入れるとする
// それ以外の点数の振り方は、降順でP-1番目までの問題＞入れたい問題よりも昇順で早い問題
// 困るとき：(p-1)+i < v のとき(予定よりも多くの問題に点を入れなければいけないとき)

signed main(){
  ll a,b; cin>>a>>b;
  ll ans;
  ll z = 0;
  if(a==1&&b==1) ans = 1;
  else if(a==1||b==1) ans = llmax(z,llmax(a,b)-2);
  else ans = (a-2)*(b-2);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long x;
   cin>>x;
   long long bj=100;
   long long total=0;
   while(bj<x)
   {
   bj=bj*1.01*1.0;
   total++;
   }
   cout<<total;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  double n;
  cin>>n;
  
  double l=n/3;
  double ans;
  
  ans = l*l*l;
  
  cout << fixed << setprecision(8) << ans << endl;
}

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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0; i<n; i++){
		if(s.substr(i, int(s.size())-i)==t.substr(0, int(t.size())-i)){
			cout<<n+n-(int(s.size())-i)<<endl;
			return;
		}
	}
	cout<<n*2<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int n;
ll cum[200002]; 
int main() {
	cin >> n;
	rep(i, n) {
		int A;
		cin >> A;
		if (i==0) cum[i] = A;
		else cum[i] = cum[i-1] + A;
	}
	ll mi = cum[n-1];
	rep(i, n) {
		ll now = abs(cum[i]-(cum[n-1]-cum[i]));
		mi = min(mi, now);
	}
	cout << mi << endl;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
class P{
    static long div(long x,long d){//その数字までにその桁が1だったものの数%2
        //if(d==1)return x/2;
        //else{
            return ((x/(d*2))*d+(x%(d*2)>=d?x%(d*2)-d+1:0));
        //}
    }
    static void Main(){
        var x=Console.ReadLine().Split().Select(long.Parse).ToArray();
        long ans=0;
        for(long i=1;i<=x[1];i*=2){
            ans+=i* ((div(x[1],i)-div(x[0]-1,i))%2);
        }
        Console.WriteLine(ans);
    }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;
  vll a(3*n);
  REP(i, 3*n)
    cin >> a[i];

  sort(a.begin(), a.end());
  ll ans = 0;
  REP(i, n){
    ans += a[3*n-2*(i+1)];
  }

  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define v  vector<int>
#define pb  push_back

int gcd(int a, int b)
{ return (b==0 ? a: gcd(b,a%b));}

int a;
int main()
{
    cin>>a;
    cout<<(a*2)/gcd(a,2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    cin >> n;
    vector<pp> a(n);
    rep(i,n){
        int f;
        cin >> f;
        a[i].first=f;
        a[i].second=i+1;
    }
    sort(all(a));
    rep(i,n){
        cout << a.at(i).second << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
#include <stdio.h>
int main()
{
    int a, b, c, cnt;
    scanf("%d %d %d", &a, &b, &c);
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
        {
            cnt++;
        }
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 2108
#include <cstdio>
#define max(a,b) ((a)>(b)?(a):(b))
int main(){
    long long a,b,c,d;scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    printf("%lld\n",max(a*c,max(a*d,max(b*c,b*d))));
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> a(n);
  for(int i=0;i<n;i++){
  	cin >> a[i];
  }
  int ac=0,wa=0,tle=0,re=0;
  for(int i=0;i<n;i++){
    if(a[i]=="AC")ac++;
    if(a[i]=="WA")wa++;
    if(a[i]=="TLE")tle++;
    if(a[i]=="RE")re++;
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}



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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    vector<ll> cnv;
    
    REP(i, n) {
        if(s[i] == 'A') {
            cnv.push_back(0);
        } else if (s[i] == 'B') {
            if((i < n-1) && s[i+1] == 'C') {
                i++;
                cnv.push_back(1);
            } else {
                cnv.push_back(-1);
            }
        } else {
            cnv.push_back(-1);
        }
    }

    ll ans = 0;
    ll front = 0;
    REP(i, cnv.size()) {
        //cout << cnv[i] << endl;
        if(cnv[i] == 0) {
            front++;
        } else if(cnv[i] == 1) {
            ans += front;
        } else {
            front = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2680
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;

int main (){
	int a;
	cin >> a;
	if(a>=1000){
		cout << "ABD" <<endl;
	}
	else {
		cout << "ABC" <<endl;
	}

	return 0;
}


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

int main() {
  string S;
  cin >> S;
  string T;
  cin >> T;
  if (S.size() < T.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  vector<string> candidates;
  for (int i = 0; i <= (int)S.size() - (int)T.size(); ++i) {
    string tmp = S;
    bool isValid = true;
    for (int j = 0; j < (int)T.size(); ++j) {
      if (tmp[j + i] != '?' && tmp[j + i] != T[j]) {
	isValid = false;
	break;
      }
      tmp[j + i] = T[j];
    }
    if (isValid) {
      replace(tmp.begin(), tmp.end(), '?', 'a');
      candidates.push_back(tmp);
    }
  }
  if (candidates.size() == 0) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  sort(candidates.begin(), candidates.end());
  cout << candidates[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,i=0;
	cin>>a>>b;
	if(b<10){
		c=a*10+b;
	}else if(b<100){
		c=a*100+b;
	}else{
		c=a*1000+b;
	}
	while(1){
		i++;
		if(i*i==c){
			cout<<"Yes";
			return 0;
		}
		if(i*i>100100){
			break;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


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

	return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i <= (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll n, x;
    while (cin >> n >> x)
    {
        ll cnt = 0;
        if (n == 0 && x == 0)
        {
            break;
        }
        repi(i, n, 1)
        {
            repi(j, n, i + 1)
            {
                repi(k, n, j + 1)
                {
                    if (i == j || j == k || i == k)
                    {
                        continue;
                    }
                    if (i + j + k == x)
                    {
                        // cout << i << " " << j << " " << k << endl;
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int main()
{
  char S[10];
  int r,i;
  int x = 0;
  
  scanf("%s",S);
  
  for(i = 0;i <= 10;i++){
    if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
      x++;
    else{
      if(x > r)
        r = x;
      x = 0;
    }
  }
  
  printf("%d",r);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
  ll n,d,cnt=0;
  cin>>n>>d;

  double arr[n];

  for(int i=0;i<n;i++)
  {
      ll x,y,k;
      double r;
      cin>>x>>y;
      k=x*x+y*y;
      r=sqrt(k);
      arr[i]=r;
  }

  for(int i=0;i<n;i++)
  {
      if(arr[i]<=d)
        cnt++;
  }
  cout<<cnt<<endl;
 return 0;
}


Measured memory_bytes: 5236
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,ans=0; cin>>n;
    vector<ll> p(n,0),pos(n+1,0);
    rep(i,n){
        cin>>p[i];
        pos[p[i]]=i;
    }
    set<ll> me;
    me.insert(pos[n]);
    me.insert(-1);
    me.insert(n);
    for(ll i=n-1;i>=1;i--){
        int l,r;
        r=*me.lower_bound(pos[i]);
        l=*(--me.lower_bound(r));
        if(r!=n){
            ans+=i*(pos[i]-l)*(*me.lower_bound(r+1)-r);
        }
        if(l!=-1){
            ans+=i*(r-pos[i])*(l-*(--me.lower_bound(l)));
        }
        me.insert(pos[i]);
    }
    cout<<ans<<endl;
}

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

int main() {
   int x, a, b;
   cin >> x >> a >> b;

   x -= a;
   while (x-b >= 0) {
       x -= b;
   }

   cout << x << endl;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	string s;

	cin >> s;

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

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

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;

int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>aa[i];
    z=0;
    x=1;
    while(true){
        x=aa[x];
        if(ba[x]==1){
            C -1 E;
            break;
        }
        ba[x]=1;
        z++;
        if(x==2){
            C z E;
            break;
        }
    }
    
}

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

#define MAX_N 100010

string s;

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>s;
    int N=s.size();
    bool can;
    rep(i,1,N){
        can=true;
        rep(j,0,N/2-i){
            if(s[j]!=s[N/2-i+j])can=false;
        }
        if(can){
            cout<<N-i*2<<endl;
            return 0;
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = new int[] { 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 };
            var index = int.Parse(Console.ReadLine());
            Console.WriteLine(nums[index - 1]);
        }
    }
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

using Graph = vector<vector<int>>;

vector<bool> seen;
void dfs(const Graph& g, int v) {
    seen[v] = true;

    for (auto next : g[v]) {
        if (seen[next])continue;
        dfs(g, next);
    }
}

void Main() {
    int n, m;
    cin >> n >> m;

    Graph g(n);

    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        --x; --y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    int ans = 0;
    seen.assign(n, false);
    rep(i, n) {
        if (seen[i] == false) {
            ++ans;
            dfs(g, i);
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 10368
///http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_B
#include <bits/stdc++.h>
using namespace std;

int main(){

    int n,i=0;

    while(1){

        cin >> n;
        i++;
        if(n == 0) break;
        printf("Case %d: %d\n",i, n);

    }

    return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,N) for(long long int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;

double a, mi = -1, ma = -1;

int main(){
	while (cin>>a){
		if (mi + ma < 0){
			mi = a;
			ma = a;
		}
		else{
			mi = min(mi, a);
			ma = max(ma, a);
		}
	}
	cout << ma - mi;

}

Measured memory_bytes: 1272
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	char c;

	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}



	return 0;
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		int[] A = new int[n];
		
		String[] str = br.readLine().split(" ");
		
		for(int i = 0; i < n; i++){
			A[i] = Integer.parseInt(str[i]);
		}
		
		
		for(int i = 0; i < n; i++){
			System.out.print(A[i]);
			
			if(i + 1 == n){
				System.out.print("\n");
			} else {
				System.out.print(" ");
			}
		}
		
		for(int i = 1; i < n; i++){
			int v = A[i];
			int j = i - 1;
			
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			
			for(int k = 0; k < n; k++){
				System.out.print(A[k]);
				
				if(k + 1 == n){
					System.out.print("\n");
				} else {
					System.out.print(" ");
				}
			}
		}
	}

}

Measured memory_bytes: 32824
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  template<class Z> ModInt(Z x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool) *this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t) v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  template<class Z> M pow(Z n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  template<class Z> friend M operator*(Z l, M r) { return M(l) *= r; }
  template<class Z> friend M operator/(Z l, M r) { return M(l) /= r; }
  template<class Z> friend M operator+(Z l, M r) { return M(l) += r; }
  template<class Z> friend M operator-(Z l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  template<class Z> friend bool operator==(Z l, M r) { return M(l) == r; }
  template<class Z> friend bool operator!=(Z l, M r) { return !(l == r); }
};
using Mint = ModInt<998244353>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  int s = accumulate(begin(a), end(a), 0);
  Mint res = Mint(3).pow(n);
  {
    V<Mint> dp(s + 1);
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
      V<Mint> ndp(s + 1);
      for (int x = 0; x <= s; ++x) {
        ndp[x] += 2 * dp[x];
        if (x + a[i] <= s) ndp[x + a[i]] += dp[x];
      }
      swap(dp, ndp);
    }
    for (int x = s + 1 >> 1; x <= s; ++x) {
      res -= 3 * dp[x];
    }
  }
  if (~s & 1) {
    V<Mint> dp(s + 1);
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
      auto ndp = dp;
      for (int x = 0; x +a[i] <= s; ++x) {
        ndp[x + a[i]] += dp[x];
      }
      swap(dp, ndp);
    }
    res += 3 * dp[s >> 1];
  }
  cout << res << '\n';
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

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

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    vi B(A);

    bool pairwise = true; 

    vb used(1000010, false);

    REP(i, N)
    {
        for(int j = 2; j * j <= A[i]; j++)
        {
            if(A[i] % j != 0) continue;
            if(used[j])
            {
                pairwise = false;
                break;
            }
            else 
            {
                used[j] = true;
                while(A[i] % j == 0) A[i] /= j;
            }
        }
        if(A[i] != 1)
        {
            if(used[A[i]]) pairwise = false;
            else used[A[i]] = true;
        }
        if(!pairwise) break;
    }

    if(pairwise) 
    {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int x = B[0];
    REP(i, N-1) x = gcd(x, B[i+1]);
    if(x == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 11344
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int r, g;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> r >> g;
    cout << 2 * g - r << endl;
}


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

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

int main() {
    string s, t; cin >> s >> t;
    int cnt = 0;
    rep(i, 3){
        if(s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
NIL = -1


class Node:
    parent = NIL
    left = NIL
    right = NIL


def getDepth(u):
    d = 0
    while T[u].parent != NIL:
        u = T[u].parent
        d += 1
    return d


def getChildren(u):
    c = T[u].left
    result = []
    while c != NIL:
        result.append(c)
        c = T[c].right
    return result


n = int(input())
T = [0] * n
for i in range(n):
    T[i] = Node()

for i in range(n):
    tmp = list(map(int, input().split()))
    id = tmp.pop(0)
    k = tmp.pop(0)
    c = tmp
    if k != 0:
        for j in range(len(c)):
            T[c[j]].parent = id
        T[id].left = c[0]
        for j in range(len(c) - 1):
            T[c[j]].right = c[j + 1]

for i in range(n):
    d = getDepth(i)
    c = getChildren(i)
    if d == 0:
        t = 'root'
    elif c == []:
        t = 'leaf'
    else:
        t = 'internal node'
    print('node ', i, ': ', 'parent = ', T[i].parent, ', depth = ', d, ', ', t, ', ', c, sep='')

Measured memory_bytes: 30864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a,b;
  char op;
  cin >> a >> op >> b;

  if (op=='+') {
  cout << a+b << endl;
    return 0;
  }
  
  cout << a-b << endl;
      
}

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

int main(){
    int N;
    int tmp=0, tmpA=0, tmpB=0, tmpBA=0, ans;
    char S[20000][20];
    cin >> N;
    for(int i=0; i<N; i++){
	cin >> S[i];	    
    }
    for(int i=0; i<N; i++){	
	for(int j=0; j<11; j++){
	    if(S[i][j+1]=='\0'){
		if(S[i][j]=='A')
		    tmpA++;
		if(S[i][0]=='B')
		    tmpB++;

		if(S[i][j]=='A'&&S[i][0]=='B')
		    tmpBA++;
		break;
	    }
	    if(S[i][j]=='A' && S[i][j+1]=='B')
		tmp++;
	}
    }

    ans = min(tmpA, tmpB);
    if(ans==N || (tmpBA==tmpA && tmpBA==tmpB) && ans>=1)
	ans--;
    

    
    cout<<ans+tmp<<endl;

    
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ret = n;
    for (int i = 1; i < n; ++i) {
        if (s[i] != s[i - 1]) {
            int temp = max(i, n - i);
            chmin(ret, temp);
        }
    }
    cout << ret << "\n";
    return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

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


ll sums(ll i,ll n){
	ll m=n/i;
	return m*(m+1)/2;
}

int main() {
	ll n;cin>>n;
	ll ans=0;
	reps(i,n){
		ans+=i*sums(i,n);
	}
	cout<<ans;
}

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

string t = "MARCH";
int cnt[5];

int main()
{
    string s;
    int n;
    cin >> n;
    while (n--)
    {
        cin >> s;
        int pos = t.find(s[0]);
        if (~pos) cnt[pos]++;
    }
    long long ans = 0;
    for (int i = 0; i < 5; i++)
        for (int j = i + 1; j < 5; j++)
            for (int k = j + 1; k < 5; k++)
                ans += 1LL * cnt[i] * cnt[j] * cnt[k];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	vector<int> num;
	for (int i = 0; i < 6; ++i) {
		int n;
		cin >> n;
		num.push_back(n);
	}
	sort(num.begin(), num.end());
	int count = 0;
	for (int i = 1; i <= 4; ++i) {
		vector<int> ws(num.size());
		auto it = copy_if(num.begin(), num.end(), ws.begin(), [i](int n) {
			return n == i;
		});
		ws.resize(distance(ws.begin(), it));
		if ((int)ws.size() == 2) count++;
	}
	if (count == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    int N;

    public void solve() {
        N = nextInt();

        while(N > 0) {
            if (N % 10 == 9) {
                out.println("Yes");
                return;
            }
            N /= 10;
        }
        out.println("No");
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

typedef long long ll;
const ll mod = 1000000007LL;

vector<int> adj[100002];
ll ans = 1;

int n, k; ///input
ll colors[100002];
///DFS
ll dfs(int u, int p) {

    int t = 2, c = 0;

    if(p == -1) t = 1;

    for(auto v : adj[u]) {

        if(v != p) {
            colors[v] = (k - t) - c++;

            dfs(v, u);
        }

    }

    return ans;

}


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

    cin >> n >> k;

    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;

        u--, v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    colors[0] = k;
    dfs(0, -1);

    ll ans = 1LL;

    for(int i = 0; i < n; i++) {
        ans *= colors[i] % mod;
        ans %= mod;
    }

    cout << ans << endl;
}

/**
*/

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=200005;
ll num[maxn],a[maxn],ans;
int n,r[maxn],f[maxn],k,ky;
inline int read(){
	int x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar());
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x;
}
inline void update(int x,int y){ for(;x<=ky;x+=x&-x) f[x]+=y;}
inline int query(int x){ int an=0; for(;x;x-=x&-x) an+=f[x]; return an;}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) a[i]=read()-k;
	for(int i=1;i<=n;i++){
	    a[i]+=a[i-1],num[i]=a[i];
	    if(a[i]>=0) ans++;
	}
	sort(num+1,num+n+1);
	ky=unique(num+1,num+n+1)-num-1;
	for(int i=1;i<=n;i++) r[i]=lower_bound(num+1,num+ky+1,a[i])-num;
	for(int i=1;i<=n;i++) ans+=(ll)query(r[i]),update(r[i],1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int mp[8][8];

int main() {
	rep(i, 8) {
		rep(j, 8) {
			mp[i][j] = 1;
		}
	}
	for (int i = 0; i < 8; i += 2) {
		for(int j = 1; j < 8; j += 2) {
			mp[i][j] = 0;
		}
	}
	int q; cin >> q;
	rep(aa, q) {
		int a, b, c, d; cin >> a >> b >> c >> d; a--; b--; c--; d--;
		int ans = 0;
		Rep1(i, a, c) {
			Rep1(j, b, d) {
				ans += mp[i][j];
			}
		}
		cout << ans << endl;
	}
	//stop
	return 0;
}


Measured memory_bytes: 3132
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
mod = 10 ** 9 + 7

dp = [[0] * (m + 1) for _ in range(n + 1)]

for i, ei in enumerate(s, 1):
    for j, ej in enumerate(t, 1):
        if ei == ej:
            dp[i][j] = dp[i-1][j] + dp[i][j-1] + 1
        else:
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]

        dp[i][j] %= mod

ans = dp[n][m] + 1
ans %= mod
print(ans)


Measured memory_bytes: 73052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S[3];
    rep(i,3) cin >> S[i];
    cout << "A" << S[1][0] << "C" << endl;
}

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

using namespace std;

typedef long long ll;

const int MOD = 1000000007;

int n, m;
int a[121];
ll dp[100021];
ll s[100021];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int i = 0; i <= a[1]; ++i)
        dp[i] = 1;
    s[0] = 1;
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j <= m; ++j)
            s[j] = s[j - 1] + dp[j] % MOD;
        for (int j = m; j >= 0; --j)
            dp[j] = (dp[j] + s[j - 1] - s[j - min(a[i], j)] + dp[j - min(a[i], j)] + MOD) % MOD;
    }
    printf("%d\n", dp[m] % MOD);
    return 0;
}


Measured memory_bytes: 1664
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1e15+7;
const ll mod = 1e9 + 7;
const int MAX_N = 1e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<int>> kake(vector<vector<int>> &tim1,vector<vector<int>> &tim2) {
	vector<vector<int>> res = vector<vector<int>>(tim1.size(),vector<int>(tim1[0].size(),0));
	REP (i,tim1.size()) {
		REP (j,tim1[0].size()) {
			REP (k,tim2[0].size()) {
				res[i][k] += tim1[i][j] * tim2[j][k];
				res[i][k] %= mod;
			}
		}
	}
	return res;
}

signed main() {
	int h,w;
	cin >> h >> w;
	int dis[h][w];
	int bd[h][w];
	REP (i,h) {
		REP (j,w) {
			dis[i][j] = INF;
			char x;
			cin >> x;
			if (x == '#') {
				bd[i][j] = 1;
				dis[i][j] = 0;
			} else {
				bd[i][j] = 0;
			}
		}
	}
	REP (i,h) {
		FOR (j,1,w) {
			dis[i][j] = min(dis[i][j],dis[i][j-1]+1);
		}
		FOR (j,1,w) {
			dis[i][w-j-1] = min(dis[i][w-j-1],dis[i][w-j]+1);
		}
	}
	REP (j,w) {
		FOR (i,1,h) {
			dis[i][j] = min(dis[i][j],dis[i-1][j]+1);
		}
		FOR (i,1,h) {
			dis[h-i-1][j] = min(dis[h-i-1][j],dis[h-i][j]+1);
		}
	}
	int ans = -INF;
	REP (i,h) {
		REP (j,w) {
			ans = max(ans,dis[i][j]);
		}
	}
	cout << ans << endl;
}

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

int main(){
    int64_t N, A, sum = 0, bit = 1;

    cin >> N;
    vector<int64_t> array(60);
    for(int i = 0; i < 60; i++){
        array[i] = 0;
    }
    for(int i=0; i < N; i++){
        cin >> A;
        int place = 0;
        while (A != 0){
            if(A % 2 == 1)array[place]++;
            place++;
            A = A >> 1;
        }
    }
    for(int i = 0; i < 60; i++){
        int num = array[i] * (N - array[i]) % 1000000007;
        sum += num * bit;
        sum %= 1000000007;
        bit = bit << 1;
        bit %= 1000000007;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=5005,mod=1e9+7;
int vis[N],zz[N],p[N],bj[N];
ll dp[N][N],sum,fac[N],ans;
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read();
	For(i,1,n)p[i]=max(read(),(ll)0);
	For(i,1,n){
		mem(vis);
		for(int j=i;;j=p[j]){
			if(bj[j])break;
			if(vis[j]){
				if(j==i){
					bj[j]=1; sum++;
				} break;
			}
			vis[j]=1;
			if(!p[j]){
				zz[j]++; break;
			}
		}
	}
	vector<int> v;
	For(i,1,n)if(zz[i])v.pb(zz[i]);
	int m=v.size(); v.pb(0);
	dp[0][0]=1;
	For(i,0,m){
		For(j,0,i){
			dp[i][j]%=mod;
			dp[i+1][j+1]+=dp[i][j]*v[i];
			dp[i+1][j]+=dp[i][j]*(n-1);
		}
	}
	For(i,fac[0]=1,m){
		fac[i]=fac[i-1]*i%mod;
		ans=(ans+fac[i-1]*dp[m][i])%mod;
	}
	if(m)ans=(ans-m*dp[m-1][0]%mod+mod)%mod;
	//cout<<ans<<" "<<sum<<" "<<m<<" "<<dp[m][1]<<" "<<endl;
	ans=(dp[m][0]*(n-sum)-ans+mod)%mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 120388
use std::cmp::{max, min};

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn main() {
    let (n, k): (i64, i64) = {
        let t = reads();
        (t[0], t[1])
    };

    let mut ret = 0;
    for a in k + 1..n + 1 {
        let t = (n + 1) / a;
        let r = (n + 1) - t * a;

        ret += t * (a - k) + max(0, r - k);

        // println!("{} {}", a, t * (a - k) + max(0, r - k));
    }

    if k == 0 {
        ret -= n;
    }

    println!("{}", ret);
}


Measured memory_bytes: 4352