akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

#define MAX 25

struct Node{
    int parent;
    int left;
    int right;
};

Node node[MAX];
int ans[MAX];
void init(){
	for (int i = 0; i < MAX; i++) {
		node[i].parent = -1;
		node[i].left = -1;
		node[i].right = -1;
	}
}

//先行順巡回 
void preParse(int n) {
    if(n == -1) return;
    printf(" %d",n);
    preParse(node[n].left);
    preParse(node[n].right);
}

//中間順巡回
void inParse(int n) {
    if(n == -1) return;
    inParse(node[n].left);
    printf(" %d", n);
    inParse(node[n].right);
}

//後行順巡回
void postParse(int n) {
    if(n == -1) return;
    postParse(node[n].left);
    postParse(node[n].right);
    printf(" %d", n);
}

int main() {
	init();
    int m;
    scanf ("%d" ,&m);
    int id;
    int l, r;
    int root;

    for (int i = 0; i < m; i++) {
        scanf("%d %d %d", &id, &l , &r);
        node[id].left = l;
        node[id].right = r;

        if(l != -1) node[l].parent = id;
        if(r != -1) node[r].parent = id;
    }
    
    for (int i = 0; i < m; i++) {
        if(node[i].parent == -1) root = i;
    }

    //先行順巡回で表示
    printf("Preorder\n");
    preParse(root);
    printf("\n");

    //中間順巡回で表示
    printf("Inorder\n");
    inParse(root);
    printf("\n");

    //後行順巡回で表示
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}


Measured memory_bytes: 2700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
struct query
{
    ll l, r, id;
};
struct BIT
{

    const int N = 1e6;
    std::vector<ll> b;

    BIT()
    {
        b.assign(N,0);
    }

    void update(ll id, ll val)
    {
        while(id < N)
        {
            b[id] += val;
            id += (id & (-id));
        }

    }
    ll query(ll id)
    {
        ll ans = 0;
        while(id>0)
        {
            ans += b[id];
            id -= (id & (-id));
        }
        return ans;
    }
};
bool cmp(query &a, query &b)
{
    return a.r < b.r;
}
void solve()
{
    ll n, q, x, l, r;
    BIT bb;
    cin >> n >> q;
    std::vector<ll> v(n + 1), res(q + 1);
    map<ll, ll> last;
    for(int i = 1; i <= n; i++) cin >> v[i];
    std::vector<query> qq(q);

    for(int i = 0; i < q; i++)
    {
        cin >> qq[i].l >> qq[i].r;
        qq[i].id=i;
    }
    sort(qq.begin(), qq.end(), cmp);
    for(int i = 1, j = 0; i <= n; i++)
    {
        if(last[v[i]])
        {
            bb.update(last[v[i]] + 1, -1);
        }
        bb.update(i+1, 1);
        last[v[i]] = i;
        while(j < q and qq[j].r == i)
        {
            res[qq[j].id] = bb.query(qq[j].r+1) - bb.query(qq[j].l);
            j++;
        }

    }
    for(int i = 0; i < q; i++)
        cout << res[i] << endl;

}



int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    // cin >> t;
    for(int i = 0; i < t; i++)
    {
        solve();
    }

}

Measured memory_bytes: 62472
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int a[100010];
int main(void)
{
    int T,t,x,y,n,m,k,s=0,f=0;
    char c[10];
    scanf("%d %d",&m,&n);
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++)
    {
        scanf("%d %s",&x,c);
        if(c[0]=='W'&&a[x]!=-1)
        a[x]++;
        if(c[0]=='A'&&a[x]!=-1)
        {
            s+=a[x];
            f++;
            a[x]=-1;
        }
    }
    printf("%d %d\n",f,s);
    return 0;
}









Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
}


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

const int VMAX=3*100000;
const int CMAX=1000000;
const int INF=INT_MAX/2;
int d[VMAX];
int N,M;
vector<vector<pair<int, int> > > C(CMAX);

struct edge {int to, cost;};
typedef pair<int, int> P; // firstは最短距離, secondは頂点の番号

vector<edge> G[VMAX];

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+VMAX, INF);
  d[s]=0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second; // 頂点の番号
    if (d[v] < p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

const int MAX_V=100000;

int par[MAX_V]; //　親
int rnk[MAX_V]; // rank, 木の深さ

// V要素で初期化
void init(){
  for(int i=0;i<MAX_V;i++){
    par[i]=i;
    rnk[i]=0;
  }
}

// 木の根を求める
int find(int x){
  if (par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

// ｘとｙの属する集合を併合
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

// ｘとｙが同じ集合に属するかどうか
bool same(int x, int y){
  return find(x) == find(y);
}


int main(){
  fill(d,d+VMAX,INF);
  scanf("%d%d",&N,&M);
  rep(i,M){
    int p,q,c; scanf("%d%d%d",&p,&q,&c); p--,q--,c--;
    C[c].push_back(make_pair(p,q));
  }
  int ind=N;
  init();
  rep(i,CMAX) if(!C[i].empty()){
    set<int> st;
    rep(j,C[i].size()){
      unite(C[i][j].first,C[i][j].second);
      st.insert(C[i][j].first);
      st.insert(C[i][j].second);
    }
    map<int,int> mp;
    for(auto s:st){
      int p=find(s),q=mp[p];
      if(q==0){
        mp[p]=q=ind;
        ind++;
      }
      G[s].push_back({q,1});
      G[q].push_back({s,1});
    }
    for(auto s:st){
      par[s]=s;
      rnk[s]=0;
    }
  }
  dijkstra(0);
  if(d[N-1]==INF) printf("-1\n");
  else printf("%d\n",d[N-1]/2);
  return 0;
}


Measured memory_bytes: 51324
using System;
class Program
{
	static void Main(string[] args)
	{
      string s = Console.ReadLine();
      string t = Console.ReadLine();
      string matched = "No";
      int len = s.Length;
      
      for(int i = 0; i < len; i++)
      {
        string rotated = s.Substring(len - 1) + s.Substring(0, len - 1);
        if(rotated == t)
        {
          matched = "Yes";
          break;
        }
        s = rotated;
      }

      Console.WriteLine(matched);
      
    }
}

Measured memory_bytes: 11092
use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn solve() -> i32 {
    let n: i32 = read();
    n - (n / 2)
}

fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
	println!("{}", solve());
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int a;
	while (cin>>a)
	{
		int ans =0;
		for (int i = 0; i < 10; ++i)
		{
			for (int j = 0; j < 10; ++j)
			{
				for (int k = 0; k < 10; ++k)
				{
					for (int l = 0; l < 10; ++l)
					{
						if (i+j+k+l==a)
						{
							ans++;
						}
					}
				}
			}
		}
		printf("%d\n",ans );
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;

const int MOD = (int)1e9 + 7;
int N;
vector<vi> G;
vector<vi> dp;

void input_init(void) {
	cin >> N;
	G.resize(N + 1);
	for (int i = 1; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dp.resize(N + 1, vi(2, 0));
}

void rec(int u, int v = -1) {
	dp[u][0] = dp[u][1] = 1;
	for (int i = 0; i < (int)G[u].size(); ++i) {
		int nxt = G[u][i];
		if (nxt == v)
			continue;
		rec(nxt, u);
		dp[u][0] = (int)((ll)1 * dp[u][0] * (dp[nxt][0] + dp[nxt][1]) % MOD);
		dp[u][1] = (int)((ll)1 * dp[u][1] * dp[nxt][0] % MOD);
	}
}

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

	input_init();
	rec(1);
	int ans = (dp[1][0] + dp[1][1]) % MOD;

	cout << ans << '\n';
	return 0;
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";



int main() {
 int n;
 cin>>n;
 vll x(n),y(n);
 ll ysum=0;
 ll xsum=0;
 rep(i,n){
     cin>>x[i]>>y[i];
     ysum+=y[i];
     xsum+=x[i];
 }
 ysum/=n;
 xsum/=n;
 ll prpr=0,prma=0,mapr=0,mama=0;
 rep(i,n){
     y[i]-=ysum;
     x[i]-=xsum;
     if(x[i]+y[i]>prpr) prpr=x[i]+y[i];
     if(-x[i]+y[i]>mapr) mapr=-x[i]+y[i];
     if(x[i]-y[i]>prma) prma=x[i]-y[i];
     if(-x[i]-y[i]>mama) mama=-x[i]-y[i];

 }
 
 cout<<max(mapr+prma,prpr+mama);
 
}


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

int main(void){
    string s;
    int k;
    cin>>k;
    cin>>s;
    if(s.size()<=k){
        cout<<s;
    }else{
        rep(i,k)cout<<s.at(i);
        cout<<"...";
    }
    return 0;
}

Measured memory_bytes: 3628
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int n; cin >> n;
  set<int> st;
  rep(i,n){
    int d;  cin >> d;
    st.insert(d);
  }
  cout << st.size();
  return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

struct node {
    int a, b, c, d;
};

int n, m, q;
vector<node> v;
int res = 0;

void solve(int idx, int num, vector<int> a) {
    if(num >= m + 1) {
        return;
    }
    if(idx == n) {
        if(a.size() == n && num <= m + 1) {
            int cur = 0;
            for(int i=0;i<q;i++) {
                if(a[v[i].b-1] - a[v[i].a-1] == v[i].c) cur += v[i].d;
            }
            res = max(res, cur);
        }
        return;
    }
    vector<int> next(a);
    if(a.size() < n) {
        next.push_back(num);
        solve(idx + 1, num , next);
        if(num <= m + 1) solve(idx + 1, num + 1, next);
    }
    solve(idx, num + 1, a);
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    cin >> n >> m >> q;
    v.resize(q);
    for(int i=0;i<q;i++) {
        cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;
    }
    solve(0, 1, vector<int>());
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3668
#define ll long long
#include<cstdio>
using namespace std;
const int maxn=200500;
int a[maxn],num[maxn],b[maxn],c[maxn],far[maxn];
int main(){
	int n,z=0;
	scanf("%d",&n);
	far[n+1]=n;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if (a[i]==0) num[i]++; else {
			b[++z]=a[i];
			c[z]=i;
		}
	}
	b[++z]=0;
	c[z]=n;
	ll ans=0;
	for (int i=1;i<=z;i++){
		ll sum=0,xorsum=0;
		for (int j=0;j<=20;j++){
			if (i+j>z) break;		
			sum+=b[i+j];
			xorsum^=b[i+j];
			if (sum==xorsum) {
				if (i+j+1<=z) far[c[i]]=c[i+j+1]-1;else far[c[i]]=c[i+j];
			}
		}
	}
	for (int i=n;i>0;i--)
	if (a[i]==0) far[i]=far[i+1];
	for (int i=1;i<=n;i++)
	ans+=far[i]-i+1;
	printf("%lld ",ans);
}
/*21
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144
 524288 0*/

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl cnt = 0;
    repi(i, n, m + 1){
        string s = to_string(i);
        string t = s;
        reverse(all(t));
        cnt += (s == t);
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;
public class Main { public static void main (String...args) {
	Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long a = sc.nextLong(); long b = sc.nextLong();
    System.out.println((n/(a+b))*a + Math.min(a,n%(a+b)));}
}

Measured memory_bytes: 21844
require 'set'

def main
    k = gets.to_i
    s = gets.chomp

    if s.size <= k
        puts s
    else
        puts s[0,k] + '...'
    end
end

main

## イディオムなど
# until s.empty? do
#
## 配列のインデックス
# s[0,6] # 0番目から6文字
# s[0..6] # 0番目から6番目まで
# s[5..-1] # 5番目から最後まで
#
## 全探索
# [0, 1].repeated_permutation(n) do |combination| # 2^n の全探索
# array.combination(i) do |selected| # array から要素が i 個である部分列を全部抽出

Measured memory_bytes: 14472
/*! path: /home/ts3min/work/tspro/src/contest/atcoder/msol2020/a.ts */!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";(function(e){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.main=void 0;const o=r(n(2)),u=n(3);function i(e){const t=u.getNextInt(e)();console.log(function(e){return 8-((e-400)/200|0)}(t))}if(t.main=i,n.c[n.s]===e){i(o.default.readFileSync("/dev/stdin","utf8"))}}).call(this,n(1)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){e.exports=require("fs")},function(e,t,n){"use strict";function*r(e){const t=e.split(/\s+/);for(const e of t)yield e}Object.defineProperty(t,"__esModule",{value:!0}),t.getNextBigInt=t.getNextInt=t.getNext=t.getIteratorWithParser=t.getIterator=void 0,t.getIterator=r,t.getIteratorWithParser=function*(e,t){const n=e.split(/\s+/);for(const e of n)yield t(e)},t.getNext=function(e){const t=r(e);return()=>t.next().value},t.getNextInt=function(e){const t=r(e);return()=>parseInt(t.next().value)},t.getNextBigInt=function(e){const t=r(e);return()=>BigInt(t.next().value)}}]);
//# sourceMappingURL=submit.js.map

Measured memory_bytes: 29776
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>

#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
double start_moment = 0;
double get_runtime() { return 1.0*clock()/CLOCKS_PER_SEC; }
void reset_timer() { start_moment = get_runtime(); }
double timer_time() { return get_runtime() - start_moment; }
void runtime(){cout<<fixed<<setprecision(5)<<get_runtime()<<'\n';}
 
typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}

const ll mod=1000000007;
int n;
ll res,sum;

int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
//    freopen("OUTPUT.txt", "w", stdout);
    
    cin>>n;
    cin>>sum;
    for(int i=1;i<n;i++)
    {
        ll cur;
        cin>>cur;
        res=(res+cur*sum)%mod;
        sum=(sum+cur)%mod;
    }
    cout<<res;
    
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  if(s=="SUN") cout << "7" << endl;
  else if(s=="MON") cout << "6" << endl;
  else if(s=="TUE") cout << "5" << endl;
  else if(s=="WED") cout << "4" << endl;
  else if(s=="THU") cout << "3" << endl;
  else if(s=="FRI") cout << "2" << endl;
  else if(s=="SAT") cout << "1" << endl;
  return 0;
}


Measured memory_bytes: 3600
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		String t = sc.next();
		
		// 計算
		String result = "No";
		for(int i = 0; i < s.length(); i++){
		    String now = s.substring(i, s.length()) + s.substring(0, i);
		    if(now.equals(t)) result = "Yes";
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 22996
n=int(input())
l=input()
a=l.count('R')
b=l.count('G')
c=l.count('B')
d=a*b*c
i=0
count=0
lis=list(l)
while i<=n-3:
    j=i+1
    while i+2*(j-i)<=n-1:
        if lis[i]!=lis[j] and lis[j]!=lis[i+2*(j-i)] and lis[i]!=lis[i+2*(j-i)]:
            count+=1
            j+=1
        else:
            j+=1
    i+=1
print(d-count)


Measured memory_bytes: 68084
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    for i in range(min(k, 50)):
        b = [0] * (n + 1)
        for j in range(n):
            l = max(0, j - a[j])
            r = min(n - 1, j + a[j])
            b[l] += 1
            b[r + 1] -= 1
        for m in range(n):
            b[m + 1] += b[m]
        a = b[:-1]
    print(*a)
if __name__ == '__main__':
    main()

Measured memory_bytes: 187040
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int x_offset[8] = {-1, 0, 1,-1, 1,-1, 0, 1};
const int y_offset[8] = {-1,-1,-1, 0, 0, 1, 1, 1};
int main()
{
  int H, W;
  cin >> H >> W;
  vector <string> S(H);
  vector <string> ans(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
    ans[i] = S[i];
  }

  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      if (ans[h][w]=='#') continue;
      int boms = 0;
      for (int i = 0; i < 8; i++) {
        int x = w + x_offset[i];
        int y = h + y_offset[i];
        if (x < 0) continue;
        if (y < 0) continue;
        if (x >= W) continue;
        if (y >= H) continue;
        if (S[y][x]=='#') boms++;
      }
      ans[h][w] = (char)boms + '0';
    }
  }
  for (int h = 0; h < H; h++) {
    cout << ans[h] << endl;
  }
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];

  sort(a.begin(), a.end());
  cout << (a[0] + a[1] == a[2] ? "Yes" : "No") << endl;



  
  return 0;
}

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

char F[102][102];

void DFS(int H,int W,char a){
  if(F[H][W]!=a){
    return;
  }
  F[H][W]='0';

  DFS(H-1,W,a);
  DFS(H,W+1,a);
  DFS(H+1,W,a);
  DFS(H,W-1,a);
}

int main(){
  while(1){
  int N,M;
  cin>>N>>M;
  if(N==0&&M==0){
    break;
  }
  for(int h=1;h<=N;h++){
    for(int w=1;w<=M;w++){
      cin>>F[h][w];
    }
  }

  int cnt=0;
  for(int h=1;h<=N;h++){
    for(int w=1;w<=M;w++){
      if(F[h][w]=='@'){
        cnt++;
        DFS(h,w,'@');
      }else if(F[h][w]=='#'){
        cnt++;
        DFS(h,w,'#');
      }else if(F[h][w]=='*'){
          cnt++;
          DFS(h,w,'*');
      }
    }
  }
  cout<<cnt<<endl;
}
  return 0;
}



Measured memory_bytes: 3380
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

using namespace std;
int64_t calc(int64_t N) {
    int divN = (((N+1) / 2) % 2);
    if(N % 2 == 1) {
        return divN;
    } else {
        return N ^ divN;
    }
}

int main() {
    int64_t A, B;
    cin >> A >> B;
    if(A == 0) {
        cout << calc(B) << endl;
        return 0;
    }

    cout << (calc(A-1) ^ calc(B)) << endl;

    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

ll f(ll b, ll n) {
  if (n < b) return n;
  else return (n % b) + f(b, n/b);
}

int main() {
  ll n, s; cin >> n >> s;
  if (s == n) {
    cout << n+1 << endl;
    return 0;
  } else if (n < s) {
    cout << -1 << endl;
    return 0;
  }
  bool is_exist = false;
  ll b;
  for (b=2; b*b<=n; b++) {
    if (s == f(b, n)) {
      cout << b << endl;
      is_exist = true; break;
    }
  }
  if (!is_exist) {
    ll ans = -1;
    for (ll p=1; p*p<=n; p++) {
      if ((n-s)%p == 0) {
        b = (n-s) / p + 1;
        if (s == f(b, n)) {
          if (ans == -1) ans = b;
          else ans = min(ans, b);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

typedef long long ll;

const int inf = 100000;

int main() {
    ll ans = 0;
    string S;
    cin >> S;
    string before = "";
    string t = "";
    for (int i = 0; i < S.size(); i++) {
        if (i == 0) {
            ans++;
            before += S[i];
            continue;
        }
        t += S[i];
        if (t == before) {
            t += S[i];
        } else {
            ans++;
            before = t;
            t = "";
        }
    }
    if (t == before) {
        ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
class Dice:
    def __init__(self):
        self.front = '1'
        self.back = '6'
        self.top = '5'
        self.bottom = '2'
        self. right = '3'
        self.left = '4'
    def turnRight(self):
        temp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = temp
        return self.top
    def turnLeft(self):
        temp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = temp
        return self.top
    def turnFront(self):
        temp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = temp
        return self.top
    def turnBack(self):
        temp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = temp
        return self.top

mydice = Dice()
mydice.top, mydice.front, mydice.right, mydice.left, mydice.back, mydice.bottom = input().split()
orders = input()

for order in orders:
    if order == 'E':
        mydice.turnRight()
    elif order == 'W':
        mydice.turnLeft()
    elif order == 'S':
        mydice.turnFront()
    elif order == 'N':
        mydice.turnBack()
    else:
        print('Input error')
        break
print(mydice.top)
    

Measured memory_bytes: 7592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=3;i++)
	{
		if(i*a*b%2==1)
		{
			printf("Yes");
		    break;
		}
	    else
	    {
	    	printf("No");
	    	break;
	    }
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        
        int[] a = new int[n];
        int[] b = new int[n];
        
        for(int i=0;i<n;i++)
        {
            a[i] = scan.nextInt();
        }
        
        for(int i=0;i<n;i++)
        {
            b[i] = Counthalf(a[i]);
        }
        
        System.out.println(ArrayMin(b));
    }
    
    static int Counthalf(int a){
        int count = 0;
        while(a>1)
        {
            if(a%2==1)
            {
                return count;
            }
            else
            {
                a /= 2;
                count++;
            }
        }
        return count;
    }
    
    static int ArrayMin(int[] a){
        int min = 1000000000;
        for(int i=0;i<a.length;i++)
        {
            if(a[i]<min)
            {
                min = a[i];
            }
        }
        return min;
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N, K;
  cin >> N >> K;

  int ans = 0;
  while (N > 0){
    N /= K;
    ans ++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <functional>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

using namespace std;

const ll MOD = 1000000007;
typedef pair<ll, ll> P;
int V;

struct edge
{
	int to;
	ll yc;
	ll sc;
};

vector< vector<edge> >G;

const ll INF = pow(10, 14);

int n, m, s, t;
//! sから各点への円でのコスト
ll yC[100005];
//! tから各点へのスヌークでのコスト
ll sC[100005];

void dijkstraYen()
{
	std::priority_queue<P, vector<P>, std::greater<P>> que;
	fill(yC, yC + n, INF);
	yC[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		ll v = p.second;
		if (yC[v] < p.first)continue;
		REP(i, G[v].size())
		{
			edge e = G[v][i];
			if (yC[e.to] > yC[v] + e.yc)
			{
				yC[e.to] = yC[v] + e.yc;
				que.push(P(yC[e.to], e.to));
			}
		}
	}
}
void dijkstraSnk()
{
	std::priority_queue<P, vector<P>, std::greater<P>> que;
	fill(sC, sC + n, INF);
	sC[t] = 0;
	que.push(P(0, t));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		ll v = p.second;
		if (sC[v] < p.first)continue;
		REP(i, G[v].size())
		{
			edge e = G[v][i];
			if (sC[e.to] > sC[v] + e.sc)
			{
				sC[e.to] = sC[v] + e.sc;
				que.push(P(sC[e.to], e.to));
			}
		}
	}
}

int main()
{
	cin >> n >> m >> s >> t;
	s--; t--;
	G.resize(n);
	REP(i, m)
	{
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		edge tov, tou;
		tou.yc = tov.yc = a;
		tou.sc = tov.sc = b;
		tou.to = u;
		tov.to = v;
		G[u].push_back(tov);
		G[v].push_back(tou);
	}

	dijkstraYen();
	dijkstraSnk();

	ll yen = pow(10, 15);

	vector<P> route(n);
	REP(i, n)
	{
		route[i] = P(yC[i] + sC[i], i);
	}
	sort(route.begin(), route.end(), [](P a, P b) {return a.first < b.first; });

	int index = 0;
	REP(i, n)
	{
		if (route[index].second < i)
		{
			FOR(j, n, index)
			{
				if (route[j].second >= i)
				{
					index = j;
					break;
				}
			}
		}
		cout << yen - route[index].first << endl;
	}
	return 0;
}

Measured memory_bytes: 13824
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

N,K=map(int, sys.stdin.readline().split())
if K==1:
    print 0
    quit()
A=map(int, sys.stdin.readline().split())
A=map(lambda a: (a-1)%K, A)

S=[0]
for a in A:
    S.append( (S[-1]+a)%K )   #累積和

d=dict()    #要素：要素の数を持つ

ans=0
for i in range(N+1):
    x=S[i]%K
    if i==0:
        d[x]=1
    else:
        if x in d:
            if 2<=K:    #K=1の時は自分の値も見てはいけない
                ans+=d[x]   #自分より前に同じ出現した、自分と同じ要素の数を答えに追加
            d[x]+=1
        else:
            d[x]=1      
        if 0<=i-K+1:
            x_head=S[i-K+1]%K  #長さK-1の範囲で配列Sを見るため、１つ進んだら一番先頭の要素を辞書から削除する
            d[x_head]-=1

print ans
       

Measured memory_bytes: 80428
n = int(input())
abc_list = [list(map(int, input().split())) for i in range(n)]
dp = [[0] * 3 for i in range(n)]
dp[0] = [abc_list[0][0], abc_list[0][1], abc_list[0][2]]

for i in range(1, n):
    dp[i][0] = abc_list[i][0] + max(dp[i - 1][1], dp[i - 1][2])
    dp[i][1] = abc_list[i][1] + max(dp[i - 1][0], dp[i - 1][2])
    dp[i][2] = abc_list[i][2] + max(dp[i - 1][0], dp[i - 1][1])

print(max(dp[n - 1]))

Measured memory_bytes: 74456
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;
    int ans,acount,count;
    acount = 0;

    for(int i = 1;i < n+1;i ++){
        int j = i;

        count = 0;
        while(j % 2 == 0){
            count ++;
            j /= 2;
        }

        if(acount <= count){
            acount = count;
            ans = i;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
a=int(input())
x=a//100
y=a%100
c=False
d=False
if 1<= x<=12:
    c=True
if 1<= y<=12:
    d=True
if c==True and d==True:
    print("AMBIGUOUS")
if c==True and d==False:
    print("MMYY")
if c==False and d==True:
    print("YYMM")
if c==False and d==False:
    print("NA")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m>>l;
    r=l;
    for(i=0;i<10;i++)
    {
        r=n*r-m;
        cout<<r<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3532
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b && b < c) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>

int main() {
	char s[99];
	int i, x = 1;
	scanf("%s", s);
	for (i = 0; s[i] != '\0'; i++);
	for (int j = 0; j < i / 2; j++) {
		if (s[j] != s[i - j - 1]) {
			x = 0;
		}
	}
	for (int j = 0; j < (i - 3) / 2; j++) {
		if (s[j] != s[(i - 3) / 2 - j]) {
			x = 0;
		}
	}
	for (int j = (i + 1) / 2; j < i - 1; j++) {
		if (s[j] != s[i - 1 - j]) {
			x = 0;
		}
	}
	if (x == 0) {
		printf("No");
	}
	else {
		printf("Yes");
	}
}

Measured memory_bytes: 128
N, M = map(int, input().split())
H = list(map(int, input().split()))
g = [1] * N
ab = [list(map(int, input().split())) for i in range(M)]
for a, b in ab:
    if H[a-1] < H[b-1]:
        g[a-1] = 0
    elif H[a-1] > H[b-1]:
        g[b-1] = 0
    else:
        g[a-1] = g[b-1] = 0
print(sum(g))

Measured memory_bytes: 31884
import sys
n=int(input())
x=list(map(int,input().split()))

if n==1:
    print('0')
    sys.exit()

if x.count(x[0])==n:
    print('0')
    sys.exit()

a=sum(x)/len(x)
d=[]
for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c)

print(min(d))


Measured memory_bytes: 9168
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   cin >> n;
   cout << n * (1 + n % 2) << endl;
   return 0;
}


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

int main() {
	int N, i, tmp = 0;
	cin >> N;
	for (i = 0; i < N; ++i) {
		string S;
		cin >> S;
		if (S == "A") ++tmp;
		else {
			if (!tmp) break;
			--tmp;
		}
	}
	if (N != i || tmp) cout << "NO";
	else cout << "YES";
	cout << endl;
}


Measured memory_bytes: 3164
a = sorted(list(map(int, input().split())))
count = 0


def plusOne(x, y):
    return x+1, y+1


def plusTwo(x):
    return x+2


while True:
    if a[0] == a[1] == a[2]:
        break
    elif a[1] == a[2]:
        a[0] = plusTwo(a[0])
    else:
        a[0], a[1] = plusOne(a[0], a[1])

    a.sort()
    count += 1

print(count)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){

    int n, k;
    int ans = 0;

    cin >> n >> k;

    for (int i = 0; i < n; i++){
        int h;
        cin >> h;
        if(h >= k){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1<<30
const int mod = 1e9+7;

int main(){
    ll h,w; cin >> h >> w;
    vvl a(h,vl(w)), b(h,vl(w)), c(h,vl(w));
    rep(i,h) rep(j,w) cin >> a[i][j];
    rep(i,h) rep(j,w) cin >> b[i][j];
    vector<vvl> v(h+1,(vvl(w+1,vl(6481,0))));
    v[1][0][0] = 1; v[0][1][0] = 1;
    rep(i,h){
        rep(j,w) c[i][j] = abs(a[i][j]-b[i][j]);
    }
    rep(i,h){
        rep(j,w){
            rep(k,6401){
                if(v[i+1][j][k]==1){
                    if(k-c[i][j]>=0) v[i+1][j+1][k-c[i][j]]=1;
                    else v[i+1][j+1][c[i][j]-k]=1;
                    if(k+c[i][j]<=6400)v[i+1][j+1][k+c[i][j]]=1;
                }
                if(v[i][j+1][k]==1){
                    if(k-c[i][j]>=0) v[i+1][j+1][k-c[i][j]]=1;
                    else v[i+1][j+1][c[i][j]-k]=1;
                    if(k+c[i][j]<=6400) v[i+1][j+1][k+c[i][j]]=1;
                }
            }
        }
    }
    rep(k,6401){
        if(v[h][w][k]==1){
            cout << k << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 337024
from collections import Counter
n = int(input())
X = list(map(int, input().split()))
A = Counter(X[::2]).most_common()
B = Counter(X[1::2]).most_common()
A.append((0,0))
B.append((0,0))
if A[0][0]!=B[0][0]:
  print(n-A[0][1]-B[0][1])
else:
  print(min(n-A[0][1]-B[1][1], n-A[1][1]-B[0][1]))

Measured memory_bytes: 25212
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=1e17+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,d,x;cin>>n>>d>>x;
	int ans=x;
	while(n--){
		int a;cin>>a;
		ans+=(a+d-1)/a;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}
int n, W;
int w[101];
ll  v[101];
ll dp[101][100001];

int main()
{
    cin >> n >> W;
    rep(i,n) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i < n; i++) {
        for(int j = 0; j <= W; j++) {
            if (j < w[i]) {
                dp[i+1][j] = dp[i][j];
            } else {
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }

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



Measured memory_bytes: 78464
#include <cstdio>

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

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

signed main() {
  int N = rint();
  int M = rint();
  int Q = rint();
  int S[N][N];
  dotimes(R, N)
    dotimes(L, N)
      S[R][L] = 0;
  dotimes(i, M) {
    int L = rint() - 1;
    int R = rint() - 1;
    S[R][L]++;
  }
  dotimes(R, N)
    dotimes(i, R) {
      int L = R - i;
      S[R][L-1] += S[R][L];
    }
  dotimes(i, Q) {
    int p = rint() - 1;
    int q = rint() - 1;
    int r = 0;
    for (int R = p; R <= q; R++)
      r += S[R][p];
    wint(r);
  }
  return 0;
}


Measured memory_bytes: 2816
n, m = map(int, input().split())
cnt = [1 for _ in range(m)]
for _ in range(n):
  a = list(map(int, input().split()))
  a.pop(0)
  for i in range(m):
    if i+1 not in a:
      cnt[i] = 0;
print(cnt.count(1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const int sqrtN = 512;
const int logN = 32;
const ll LINF=1e18;
const ld PI=abs(acos(-1));

struct LowestCommonAncestor{
	vector<vector<int>> g, parent;
	vector<int> depth;
	bool built = false;
	int N;
	
	LowestCommonAncestor(int n) : N(n) {
		g.resize(N);
		parent.resize(logN, vector<int>(N));
		depth.resize(N);
	}
	
	void add_edge(int u, int v){
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	void dfs(int v, int par = -1, int d = 0){
		parent[0][v] = par;
		depth[v] = d;
		
		for(auto e:g[v]){
			if(e == par) continue;
			dfs(e, v, d + 1);
		}
	}
	
	void build(){
		dfs(0);
		REP(k, 0, logN - 1){
			REP(i, 0, N){
				if(parent[k][i] < 0) parent[k + 1][i] = -1;
				else parent[k + 1][i] = parent[k][parent[k][i]];
			}
		}
	}
	
	int get(int u, int v){
		if(!built) build(); built = true;
		if(depth[u] > depth[v]) swap(u, v);
		
		REP(k, 0, logN) if(((depth[v] - depth[u]) >> k) & 1) v = parent[k][v];	
		if(u == v) return u;
		
		RREP(k, logN - 1, 0){
			if(parent[k][u] == parent[k][v]) continue;
			u = parent[k][u];
			v = parent[k][v];			
		}
		
		return parent[0][u];
	}
};

int main(){
	int n; cin >> n;
	LowestCommonAncestor lca(n);
	REP(i, 0, n){
		int k; cin >> k;
		REP(j, 0, k){
			int a; cin >> a;
			lca.add_edge(i, a);
		}
	}
	int q; cin >> q;
	REP(i, 0, q){
		int a, b; cin >> a >> b;
		
		cout << lca.get(a, b) << endl;
	}
	
	return 0;
}



Measured memory_bytes: 24056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;

int main(){
	string s,t;
	cin>>s>>t;
	vector<vector<pair<int,pair<int,int>>>> dp((int)s.length()+1, vector<pair<int,pair<int,int>>>((int)t.length()+1));
	//dp[0][0] = {0,{0,0}};
	for(int i = 0; i <= s.length(); i++){
		for(int j = 0; j <= t.length(); j++){
			if(s[i] == t[j] && i < s.length() && j < t.length()){
				dp[i+1][j+1].first = max(dp[i+1][j+1].first, dp[i][j].first + 1);
				dp[i+1][j+1].second = {i,j};
			}
			if(j < t.length())
			dp[i][j+1].first = max(dp[i][j+1].first, dp[i][j].first);

			if(i < s.length())
			dp[i+1][j].first = max(dp[i+1][j].first, dp[i][j].first);
		}
	}
	/*int len = 0;
	for(int i = 0; i <= s.length(); i++){
		len = max(dp[i][t.length()].first,len);
	}
	for(int i = 0; i <= t.length(); i++){
		len = max(dp[s.length()][i].first,len);
	}
	cout<<len<<endl;
	
	for(int i = 0; i <= s.length(); i++){
		for(int j = 0; j <= t.length(); j++){

			cout<<dp[i][j].first;
		}
		cout<<endl;
	}*/
	int i = s.length(), j = t.length();
	string answer = "";
	while(i > 0){
		if(i == 0)
			break;
		
		if(dp[i][j].first == dp[i][j-1].first){
			j--;
		}
		else if(dp[i][j].first == dp[i-1][j].first){
			i--;
		}
		else{
			if(dp[i][j].second.first == INF){
				cout<<i<<j;
				break;
			}
			answer += s[dp[i][j].second.first];
			i = i-1;
			j = j-1;

		}
	}
	reverse(answer.begin(), answer.end());
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 105984
fun main(args: Array<String>) {
    val color = readLine()!!.split(" ").map(String::toString)
    val size = readLine()!!.split(" ").map(String::toInt).toMutableList()
    val select = readLine()!!.toString()

    if (select == color[0]) size[0] = size[0] -1 else size[1] = size[1] -1
    println("${size[0]} ${size[1]}")
}

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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n, k;
  cin >> n >> k;

  int a[n + 1];
  for (int i = 1; i <= n; i++)
    cin >> a[i];

  vec<ll> S;
  for (int i = 1; i <= n; i++) {
    ll sum = 0;
    for (int j = i; j <= n; j++) {
      sum += a[j];
      S.pb (sum);
    }
  }
  ll sum = 0;
  for (int b = 40; b >= 0; b--) {
    static vec<ll> T;
    T.clear();
    for (int i = 0; i < sz(S); i++)
      if ((S[i] & (1ll<<b)))
        T.pb (S[i]);
    if (sz(T) >= k) {
      sum += (1ll<<b);
      S = T;
    }
  }
  cout << sum;



  return 0;
}






// Coded by Z..

Measured memory_bytes: 6548