akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

void dfs1(int v, int &k, mat &G, vec &level){
    level[v] = -2;
    for(int to : G[v]){
        if(level[to] == -1) dfs1(to, k, G, level);
    }
    level[v] = k++;
}

void dfs2(int v, mat &G, vector<bool> &used, vec &res){
    used[v] = true;
    res.push_back(v);
    for(int to : G[v]) if(!used[to]) dfs2(to, G, used, res);
}

void scc(mat &G, mat &res){
    int n = G.size();
    mat G_rev(n, vec(0));
    rep(u, n) rep(v, (int)G[u].size()) G_rev[G[u][v]].push_back(u);
    vec level(n, -1), ord(n);
    vector<bool> used(n, false);
    int k(0);
    rep(i, n) if(level[i] == -1) dfs1(i, k, G, level);
    rep(i, n) ord[level[i]] = i;
    Rrep(i, n) {
        if(!used[ord[i]]) {
            vec temp(0);
            dfs2(ord[i], G_rev, used, temp);
            res.push_back(temp);
        }
    }
}

int main() {
    cin>>N>>M;
    mat G(N, vec(0));
    vec num_in(N, 0);
    rep(i,M){
        int a, b;
        scanf("%d%d", &a, &b);
        G[a].push_back(b);
    }
    mat scc_list(0);
    scc(G, scc_list);
    printf("%d\n", (int)scc_list.size());
    for(vec v : scc_list){
        int n = v.size();
        printf("%d ", n);
        rep(i, n) printf("%lld%c", v[i], " \n"[i == n - 1]);
    }
}


Measured memory_bytes: 87076
#include "stdio.h"

int main(void) {
  /* code */
  int h,n;
  scanf("%d %d", &h, &n);
  /*int a[100001]={0};
  for (int i = 0; i < n; i++) {
    scanf("%d",&a[i]);
    
  } */
  int a;
  for (int j = 0; j < n; j++) {
    a = 0;
    scanf("%d\n", &a);
    h -= a;
      /* code */
  }
  if(h <= 0){
    printf("%s\n","Yes");
  }else{
    printf("%s\n","No" );
  }
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool vis[300];
vector<int> v[300];
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		string a,b;
		cin>>a>>b;
		for(int i=0;i<a.size();i++)vis[a[i]]=1;
		for(int i=0;i<b.size();i++)if(vis[b[i]]==0){cout<<-1;return 0;}
		for(int i=0;i<a.size();i++)v[a[i]].push_back(i+1);
		int pos=0,giri=0;
		for(int i=0;i<b.size();i++){
      char c=b[i];
      int d=upper_bound(v[c].begin(),v[c].end(),pos)-v[c].begin();
      if(d==v[c].size()){
        giri++;
        pos=v[c][0];
      }else{
        pos=v[c][d];
      }
		}
		cout<<giri*a.size()+pos;
		return 0;
}


Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int x,y;
  cin>>s>>x>>y;
  int f=0,F=0;
  vector<int> xi,yi;
  
  for(int i=0;i<s.size();i++){
    while(f==0&&s[i]=='F'){
      i++,F++;
      if(i==s.size())break;
    }
    if(i==s.size())break;
    if(s[i]=='T'){
      f++;
    }else{
      int cnt=0;
      while(s[i]=='F'){
	i++;
	cnt++;
	if(i==s.size())break;
      } i--;
      if(f%2)yi.push_back(cnt);
      else xi.push_back(cnt);
    }
  }
  
  //cout<<F<<endl;
  
  int xdp[2][20000]={},ydp[2][20000]={};
  xdp[0][10000+F]=1,ydp[0][10000]=1;
  for(int i=0;i<xi.size();i++){
    //cout<<xi[i]<<endl;
    for(int j=0;j<20000;j++){
      if(xdp[i%2][j]) xdp[(i+1)%2][j+xi[i]]=1;
      if(xdp[i%2][j]) xdp[(i+1)%2][j-xi[i]]=1;
    }
    for(int j=0;j<20000;j++)xdp[i%2][j]=0;
  }
  
  //cout<<endl;
  
  for(int i=0;i<yi.size();i++){
    //cout<<yi[i]<<endl;
    for(int j=0;j<20000;j++){
      if( ydp[i%2][j]) ydp[(i+1)%2][j+yi[i]]=1;
      if( ydp[i%2][j]) ydp[(i+1)%2][j-yi[i]]=1;
    }
    for(int j=0;j<20000;j++)ydp[i%2][j]=0;
  }
  if(xdp[xi.size()%2][10000+x]==1&&ydp[yi.size()%2][10000+y]==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s;
    cin>>s;
    int n=s.length();
    int a=0,b=0;
    rep(i,n){
        if(s[i]=='0') a++;
        else b++;
    }
    cout<<2*min(a,b)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    vector<int> a(n);
    For(i, n){
        Cin(char, c);
        a[i] = (c == 'I' ? 1 : -1);
    }
    Cusum(int, n, a, sa);
    DeSort(sa);
    Cout(sa[0]);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[float]", u: "List[str]"):
    sum = 0.0
    for i in range(N):
        if u[i] == "JPY":
            sum += x[i]
        else:
            sum += x[i] * 380000
    print(sum)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [float()] * (N)  # type: "List[float]" 
    u = [str()] * (N)  # type: "List[str]" 
    for i in range(N):
        x[i] = float(next(tokens))
        u[i] = next(tokens)
    solve(N, x, u)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std; 
int main(){
	char a[3];
	cin>>a;
	string b="abc",c;
	c="ABC";
	int x;
	for (int i=0 ; i<3 ; i++){
	for (int j=0 ;j<3; j++){
		if(a[i]==b[j] || a[i]==c[j]){
			b[j]='0';
			c[j]='0';
			x+=1;
		}
	}}
	if(x==3){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n, k, s;
  cin >> n >> k >> s;
  int cnt = 1;
  for(int i = 1; i <= n; i ++ ){
    if(i <= k)
      cout << s << " ";
    else
      cout << (s == (int)1e9 ? 1 : (int)1e9) << " ";
  }
  return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

//?????????????????°
const int MAX_V = 100000;
//??????????????°?????????????????????(log(MAX_V))
const int MAX_LOG_V = 17;
//??¨?????£??\???????????¨???
vector<int> G[MAX_V];
//?????????????????????
int root = 0;

//??????2^k????????£?????°??????????????????(???????????????????????´???,-1)
int parent[MAX_LOG_V][MAX_V];
//??????????????±???
int depth[MAX_V];

//?????¨v?????¨????????????p?????±???d
void lca_dfs(int v, int p, int d){
    parent[0][v]=p;
    depth[v]=d;
    rep(i,G[v].size()){
        if(G[v][i]!=p){ //?????§???????????°???
            lca_dfs(G[v][i], v, d+1);
        }
    }
}

//?????????
void lca_init(int V){
    //parent[0]??¨depth????????????
    lca_dfs(root, -1, 0);
    //parent????????????
    for(int k=0; k+1<MAX_LOG_V; ++k){
        for(int v=0; v<V; ++v){
            if(parent[k][v] < 0) parent[k+1][v]=-1;
            else parent[k+1][v] = parent[k][parent[k][v]];
        }
    }
}

//u??¨v???LCA????±???????
int lca(int u, int v){
    //u??¨v?????±??????????????????????????§????????????
    if(depth[u] > depth[v]) swap(u,v);
    for(int k=0; k<MAX_LOG_V; ++k){
        if((depth[v]-depth[u])>>k & 1) v = parent[k][v];
    }
    if(u==v) return u;
    //????????¢?´¢??§LCA????±???????
    for(int k=MAX_LOG_V-1; k>=0; --k){
        if(parent[k][u] != parent[k][v]){
            u=parent[k][u];
            v=parent[k][v];
        }
    }
    return parent[0][u];
}

const int INF=12345678;
int d[MAX_V];

int main()
{
    int n;
    scanf(" %d", &n);
    vector<int> p(n);
    for(int i=1; i<n; ++i)
    {
        scanf(" %d", &p[i]);
        --p[i];

        G[p[i]].pb(i);
    }

    lca_init(n);

    vector<int> vis;
    fill(d,d+MAX_V,INF);
    d[0]=0;
    queue<int> que;
    que.push(0);
    vis.pb(0);
    while(!que.empty())
    {
        int v=que.front();
        que.pop();
        rep(i,G[v].size())
        {
            int nx=G[v][i];
            if(d[nx]>d[v]+1)
            {
                d[nx]=d[v]+1;
                que.push(nx);
                vis.pb(nx);
            }
        }
    }

    ll ans=0;
    rep(i,vis.size()-1)
    {
        // printf("%d %d\n", vis[i],vis[i+1]);
        ans += d[vis[i]]+d[vis[i+1]]-2*d[lca(vis[i],vis[i+1])];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 24436
#include <iostream>
#include <string>
using namespace std;
struct po{int J,O,I;};
string mp[1001];
int h,w,n;
po memo[1002][1002];

void make_memo() {
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(j != 0)memo[i][j] = memo[i][j-1];
      if(mp[i][j] == 'J') memo[i][j].J++;
      else if(mp[i][j] == 'O') memo[i][j].O++;
      else if(mp[i][j] == 'I') memo[i][j].I++;
    }
}

po com(int a,int b,int c,int d){
  po res;
  res.J = res.O = res.I = 0;
  for(int i=a;i<=c;i++) {
    res.J += memo[i][d].J;
    res.O += memo[i][d].O;
    res.I += memo[i][d].I;
    if(b== 0) continue;
    res.J -=memo[i][b-1].J;
    res.O -=memo[i][b-1].O;
    res.I -=memo[i][b-1].I;
  }
  return res;
}

int main() {
  cin >> h >>w >> n;
  for(int i=0;i<h;i++) cin >> mp[i];
  make_memo();
  for(int q=0;q<n;q++){
    int a,b,c,d;
    cin >> a >> b >> c>>d;
    a--,b--,c--,d--;
    po ans = com(a,b,c,d);
    cout << ans.J <<" "<<ans.O<<" "<<ans.I<<endl;
  }

  return 0;
}

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

namespace ConsoleApp14
{
    class Class10
    {
        static void Main()
        {
            int ans=int.MaxValue;
            long[] LR = Console.ReadLine().Split().Select(long.Parse).ToArray();
            for(long i = LR[0]; i <= LR[1]; i++)
            {
                for(long j = i + 1; j <= LR[1]; j++)
                {
                    ans =(int) Math.Min((i * j)%2019, ans);
                    if (ans == 0)
                    {
                        Console.WriteLine(ans);
                        return;
                    }
                }
            }
            Console.WriteLine(ans);
        }
        

    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(void)
{
	int n,h[101],i,j,x[100],k,flg,y,z;
	while(1){
		scanf("%d",&n);
		if(n==0)	break;
		for(i=0;i<n+1;i++){
			scanf("%d",&h[i]);
		}
		for(i=0;i<n+1;i++){
			k=0;
			for(j=0;j<n+1;j++){
				if(i!=j){
					x[k]=h[j];
					k++;
				}
			}
			flg=1;
			y=x[1]-x[0];
			for(k=1;k<n-1;k++){
				z=x[k+1]-x[k];
				if(y!=z){
					flg=0;
					break;
				}
			}
			if(flg==1)	break;
		}
		printf("%d\n",h[i]);
	}
	return 0;
}


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

int main() {
    string s; cin >> s;
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else if (s[0] == s[2] && s[1] != s[2] && s[1] == s[3]) cout << "Yes" << endl;
    else if (s[1] == s[2] && s[0] != s[2] && s[0] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {

  int n; cin >> n;

  n %= 10;
  if(n==0 || n==1 || n==6 || n==8){
    cout << "pon" << endl;
  } 
  else if(n==3){
    cout << "bon" << endl;

  }
  else{
    cout << "hon" << endl;
  }



  return 0;
}


Measured memory_bytes: 3624
#include <iostream>

int main()
{
    using namespace std;
    //----------------
    
    int a;
    cin >> a;
    if( a == 3 || a == 5 || a== 7 )
    { cout << "YES"; }
    else
    { cout  << "NO"; }
    
    //----------------
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

main()
{
  int N,i,k;
  long min=0;
  long *A;
  scanf("%d",&N);
  A = (long*)malloc(sizeof N);
  for(i=0; i<N; i++)
    scanf("%ld",&A[i]);
  for(i=0; i<N-1; i++)
    for(k=i+1; k<N; k++)
      if(min < abs(A[i]-A[k]))
        min = abs(A[i]-A[k]);
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 128
function Main(input) {
	var inputdata = input.split(/\s/);
    var A = parseInt(inputdata[0]);
    var B = parseInt(inputdata[1]);
    console.log( Math.max(A+B,A-B,A*B) );
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//div game
#include <stdio.h>
#include <math.h>

int main(void){
    unsigned long int n;

    scanf("%lu",&n);

    unsigned int i=2;
    unsigned long int cnt = 0;

 /*   if(n%i==0) {
        unsigned long int div = i;
        for(unsigned int j = 1;n%(int)pow(div,j)==0;j++){
            n/= pow(div,j);
            cnt ++;
        }
        while(n%div == 0) n/=div;
    }
    */

    for(i = 2;i<sqrt(n);i+=1){
        if(n%i==0) {
            unsigned long int div = i;
            for(unsigned int j = 1;n%(int)pow(div,j)==0;j++){
                n/= pow(div,j);
                cnt ++;
            }
            while(n%div == 0) n/=div;
        }
    }
    if(n>sqrt(n)) cnt ++;
    printf("%lu",cnt);

    return 0;
}


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

int main(void)
{
  double y, v, t;
  double N;
  
  while(cin >> v) {
    t = v / 9.8;
    y = 4.9 * t * t;
    
    N =  y / 5 + 1 + 0.5;

    printf("%.0f\n", N);
  }
  return 0;
}

Measured memory_bytes: 0
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import numpy as np


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def main():
    # write codes here
    [N, M] = LI()

    if N != 1 and M == 0:
        print(str(10 ** (N - 1)))

    elif N == 1 and M == 0:
        print("0")

    else:

        SCset = set([tuple(LI()) for i in range(M)])
        SClist = list(SCset)

        Mactual = len(SCset)

        Ss = Counter([SClist[i][0] for i in range(Mactual)])

        Ss_np = np.array(list(Ss.values()))

        SCdict = {SClist[i][0]: SClist[i][1] for i in range(Mactual)}

        if np.sum(Ss_np > 1) > 0:
            print("-1")

        elif N > 1 and 1 in Ss.keys() and SCdict[1] == 0:
            print("-1")

        else:
            if 1 not in SCdict.keys():
                SCdict[1] = 1
            print(str(sum([SCdict[key] * 10 ** (N - key) for key in SCdict.keys()])))


# Main
if __name__ == "__main__":
    main()


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true){
        c -= b;
        if (c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;++i)
#define in(v,n) v.push_back(n)
using namespace std;
int n,p1,p2,q,t,a[101],x;
main(){
  vector<int>v;
  cin>>n;
  r(i,n)cin>>a[i];
  sort(a,a+n);
  r(i,n)if(!a[i])p1++;
   else if(a[i]==1)p2++;
  if(p1%2&&p2){
    r(i,n){
      if(a[i]>1)in(v,a[i]);
    }
    r(i,n)if(!a[i])if(t++)in(v,0);
    in(v,1);t=0;in(v,0);
    r(i,n)if(a[i]==1)if(t++)in(v,1);
    if(p1!=1)p1++;
  }
  else if(p1%2&&!p2){
    r(i,n){
      if(a[i]>1&&!q)q=a[i];
      else if(a[i]>1&&q)in(v,a[i]);
    }
    r(i,n)if(!a[i])if(t++)in(v,0);
    if(q)in(v,q);
    in(v,0);if(p1!=1)p1++;
  }
  else{
    r(i,n)if(a[i]>1)in(v,a[i]);
    r(i,n)if(!a[i])in(v,0);
    r(i,n)if(a[i]==1)in(v,1);
  }
  for(int i=v.size()-1;i>=0;i--){
    if(v[i]<2)continue;
    if(i!=v.size()-1&&v[i+1]==0&&p1%2||i!=0&&v[i-1]==0)continue;
    if(i>0&&v[i]==3&&v[i-1]==2)swap(v[i],v[i-1]);
    break;
  }
  r(i,v.size())cout<<v[i]<<endl;
}

Measured memory_bytes: 3124
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  long n, m;
  cin >> n >> m;

  // vector<long> k(n);
  // vector<vector<long>> a(n, vector<long>());

  long count = 0;

  vector<long> m_count(m,0);

  for (int i = 0; i < n; ++i) {
    int k = 0;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int b = 0 ;
      cin >> b;
      // a[i].push_back(b);
      m_count[b-1]++;
    }
  }


  for (int i = 0; i < m; ++i) {
    if (m_count[i]==n){
      count++;
    }
  }


  cout << count;


  // cout << "w:" << w << "  h:" << h << endl;


}




















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
double e[202020], ecum[202020];

int main(){
    
    // 1. 入力情報.
    int N, K;
    scanf("%d %d", &N, &K);
    rep(i, N){
        double p;
        scanf("%lf", &p);
        e[i] = (p + 1.0) / 2.0; // i番目のサイコロの期待値.
    }
    
    // 2. 累積和.
    rep(i, N) ecum[i + 1] = ecum[i] + e[i];
    
    // 3. 出る目の合計の期待値の最大値は？
    double ans = 0.0;
    rep(i, N - K + 1) ans = max(ans, ecum[i + K] - ecum[i]);
    
    // 4. 出力.
    printf("%.12lf\n", ans);
    return 0;
    
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  in a,b;
  in v,w;
  in t;
  cin>>a>>v;
  cin>>b>>w;
  cin>>t;
  if(w>=v){
    cout<<"NO"<<endl;
    return 0;
  }
    
  in nan = max(w-v,v-w);
  in d = max(a-b,b-a);
  if(d<=t*nan)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num=1e9+7;
int main(){
    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << (double)(w*h)/2 << " " ;
    if(x*2==w&&y*2==h)cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
#define for_(i,a,b) for(ll i=a;i<ll(b);i++)
#define forr_(i,a,b) for(ll i=a;i>=ll(b);i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
using namespace std;

int k, s, ans;
int main() {
	cin >> k >> s;
	rep(x, k+1){
		rep(y, k+1){
			int z = s - x - y;
			if(0 <= z && z <= k) ans++;
		}
	}
	cout << ans << endl;
    return 0;
}


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

int main(){
  string str;
  cin >> str;
  int price = 700;
  for(int i = 0; i < 3; i++){
    char a = str.at(i);
    if(a == 'o') price += 100;
  }
  cout << price << endl;
}
  

Measured memory_bytes: 3592
#include <stdio.h>
int tanri(int src, int year, double riritu, int tesuu)
{
  int i,risi=0;
  for(i=0; i<year; i++){
    risi += (int)(src * riritu);
    src -= tesuu;
  }
  return src + risi;
}
int fukuri(int src, int year, double riritu, int tesuu)
{
  int i;
  for(i=0; i<year; i++){
    src += (int)(src * riritu);
    src -= tesuu;
  }
  return src;
}
int main()
{
  int m,i;
  scanf("%d",&m);
  for(i=0; i<m; i++){
    int src, year,n,j,max = 0;
    scanf("%d\n%d\n%d",&src,&year,&n);
    for(j=0; j<n; j++){
      int k, tesuu,ret;
      double riritu;
      scanf("%d %lf %d",&k,&riritu,&tesuu);
      if(k == 0){
        ret = tanri(src,year,riritu,tesuu);
      }else{
        ret = fukuri(src,year,riritu,tesuu);
      }
      if(max < ret){
        max = ret;
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 628
#include <stdio.h>
int main(){
  int S[100000],T[50000],n,q,i,j,count=0,left,right,mid;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    left=0;
    right=n;  
    while(left < right){
      mid=(left + right)/2;
      if(T[i] == S[mid]){
	count++;
	break;
      }
      else if(T[i] < S[mid]) right = mid;
      else left = mid + 1;
    }
  }
  printf("%d\n",count);
  
  return 0;
}

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

int main(){
int a;
cin>>a;
string s;
cin>>s;
for(int i=0;i<s.size();i++){
while(s[i]==s[i+1]){
s.erase(s.begin()+i);
}
}
cout<<s.size()<<'\n';
}


Measured memory_bytes: 512
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A.exe A.cpp 
Execute: ./A
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	string s; 
	cin >> s; 
	
	if(s.back() == 's') {
		s += "es";
	} else {
		s += "s";
	}
	
	cout << s << endl; 
	
	return 0; 
} 


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


typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int,pair<int,ll> > pii;
typedef vector<int> vi;

#define f first
#define s second
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define forn(i, n) for(register int i=0; i<(n); i++)
#define Forn(i, n) for(register int i=1; i<=(n); i++)
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)

inline int in()
{
    char c=getchar();
    int neg=1, x=0;
    while(!isdigit(c)) (c=='-')?neg=-1, c=getchar():c=getchar();
    while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48), c=getchar();
    return neg*x;
}
inline int ex_gcd(int a, int b, int&x, int&y, int mod=1e9+7)
{
    if(!a)
    {
        x=0, y=1;
        return b;
    }
    int d=ex_gcd(b%a, a, y, x);
    x=(x-1LL*b/a*y%mod)%mod;
    return d;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=1e5+5;

int N, ptr, sz[MAX];
ll len[MAX], dp[MAX];
map<ll,int> rev;
pi ret[MAX];
pair<ll,int> dat[MAX];

inline void die()
{
    puts("-1");
    exit(0);
}

signed main()
{
    N=in();
    Forn(i, N)
    {
        scanf("%lld", &len[i]);
        rev[len[i]]=i;
        dat[i]=mp(len[i], i);
        sz[i]=1;
    }
    sort(dat+1, dat+1+N);
    
    for(int i=N; i>1; i--)
    {
        int now=dat[i].s;
        ll want=dat[i].f-N+2*sz[now];
        if(want<0) die();
        if(!rev.count(want)) die();
        int par=rev[want];
        sz[par]+=sz[now];
        dp[par]+=dp[now]+sz[now];
        ret[ptr++]=mp(min(par, now), max(par, now));
    }
    int now=dat[1].s;
    if(dp[now]!=dat[1].f) die();
    sort(ret, ret+ptr);
    forn(i, ptr)
        printf("%d %d\n", ret[i].f, ret[i].s);
    return 0;
}

Measured memory_bytes: 12800
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws ParseException {
    try (Scanner sc = new Scanner(System.in);) {
      int targetCounter = Integer.parseInt(sc.nextLine());

      BigDecimal sum = BigDecimal.ZERO;
      for (int i = 0; i < targetCounter; i++) {
        String target = sc.nextLine();
        String[] money = target.split(" ");
        if ("JPY".equals(money[1])) {
          BigDecimal yenPrice = new BigDecimal(money[0]);
          sum = sum.add(yenPrice);
        } else {
          BigDecimal bitPrice = new BigDecimal("380000");
          bitPrice = bitPrice.multiply(new BigDecimal(money[0]));
          sum = sum.add(bitPrice);
        }
      }
      System.out.println(sum);
    }
  }
}

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

string s;
int cnt[30];
signed main(){
	cin>>s;
	rep(i,s.size()){
		cnt[s[i]-'a']++;
	}
	int ans=s.size()*(s.size()-1)/2+1;
	rep(i,26){
		ans-=cnt[i]*(cnt[i]-1)/2;
	}
	cout<<ans<<endl;
}


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

int const MAX = 100005;
long long a[MAX];
long long b[MAX * 2];


int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= m * 2; i++) {
		b[i] = 0;
	}
	for (int i = 1; i <= n - 1; i++) {
		if (a[i] < a[i + 1]) {
			b[a[i] + 1]--;
			b[a[i + 1]]++;
			b[a[i + 1]] += a[i + 1] - a[i] - 1;
			b[a[i + 1] + 1] -= a[i + 1] - a[i] - 1;
		}
		else {
			b[a[i] + 1]--;
			b[a[i + 1] + m]++;
			b[a[i + 1] + m] += a[i + 1] + m - a[i] - 1;
			b[a[i + 1] + m + 1] -= a[i + 1] + m - a[i] - 1;
		}
	}
	for (int i = 2; i <= m * 2; i++) {
		b[i] += b[i - 1];
	}
	for (int i = 1; i <= m; i++) {
		b[i] += b[i + m];
	}
	long long cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] < a[i + 1]) {
			cnt += a[i + 1] - a[i];
		}
		else {
			cnt += a[i + 1];
		}
	}
	long long ans = cnt;
	for (int i = 1; i < m; i++) {
		cnt += b[i];
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

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

int main() {
    int a, b, c, ans;
    cin >> a >> b >> c;
    if (a == b) ans = c;
    else if (a == c) ans = b;
    else ans = a;
    cout << ans << endl;
    return 0;
}

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

int main()
{
  cin >> n;
  cout << n / 3600 << ":" << (n - n / 3600 * 3600) / 60 << ":" << (n - n/3600 * 3600- (n - n/3600 * 3600)/60 * 60 )<< endl;
  return 0;
}
 
 

Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int set[10002];
int find(int);
int main(){
	int n,q;
	cin>>n>>q;
	for(int i=0;i<=n;i++)
		set[i]=i;
	int qu,x,y;
	for(int i=0;i<q;i++){
		cin>>qu>>x>>y;
		if(qu){
			if(find(x)==find(y))
				cout<<1<<endl;
			else cout<<0<<endl;
		}else{
			set[find(x)]=find(y);
		}
	}
	return 0;
}
int find(int x){
	return x==set[x]?x:set[x]=find(set[x]);
}



Measured memory_bytes: 3228
import sys

input = sys.stdin.readline

def main():
    ans = float('inf')
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n):
        tmp = 0
        while a[i]%2 == 0:
            a[i] //= 2
            tmp += 1
        ans = min(ans, tmp)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
  int n,m;
  scanf("%d %d\n",&n, &m);

  std::vector<std::vector<ll> > a;
  a.resize(m);
  for( int i=0; i<m; i++ ){
    a[i].resize(3);
  }

  std::vector<std::vector<ll> > b(n);
  for (int i = 0; i < m; i++) {
    scanf("%llu %llu\n ",&a[i][0],&a[i][1]);
  }
  std::vector<std::vector<ll> > c(n);

  for (int j = 0; j < m; j++) {
        b[a[j][0]-1].push_back(a[j][1]);
        c[a[j][0]-1].push_back(j);
  }

  std::map<ll ,int> mp;
  for (size_t i = 0; i < n; i++) {
    std::map<int ,int> mp;
    for (size_t j = 0; j < b[i].size(); j++) {
      mp[b[i][j]]=c[i][j];
    }


    std::sort(b[i].begin(),b[i].end());
    for (size_t j = 0; j < b[i].size(); j++) {
      a[mp[b[i][j]]][2]=a[mp[b[i][j]]][0]*1000000+j+1;
    }
  }

  for (size_t i = 0; i < m; i++) {
    printf("%012llu\n",a[i][2]);
  }
  return 0;
}


Measured memory_bytes: 17948
def gai(a,b,c,d):
    S = a*d - b*c
    return(S)
while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp  = map(float,input().split(","))
        A1,A2,B1,B2,C1,C2,D1,D2 = x1,y1,x2,y2,x3,y3,xp,yp
        
        if gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) < 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) < 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) < 0:
            print("NO")
        elif gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) > 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) > 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) > 0:
            print("NO")
        else:
            x1,y1,x2,y2,x3,y3,xp,yp = A1,A2,B1,B2,D1,D2,C1,C2
            if gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) < 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) < 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) < 0:
                print("NO")
            elif gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) > 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) > 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) > 0:
                print("NO")
            else:
                x1,y1,x2,y2,x3,y3,xp,yp = A1,A2,D1,D2,C1,C2,B1,B2
                if gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) < 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) < 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) < 0:
                    print("NO")
                elif gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) > 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) > 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) > 0:
                    print("NO")
                else:
                    x1,y1,x2,y2,x3,y3,xp,yp = D1,D2,B1,B2,C1,C2,A1,A2
                    if gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) < 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) < 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) < 0:
                        print("NO")
                    elif gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) > 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) > 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) > 0:
                        print("NO")
                    else:
                        print("YES")

            
    except EOFError:
        break

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define sz(x) (int)x.size()
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i;
    cin>>n;
    ll a[n],b[n];
    REP(i,0,n-1) cin>>a[i]>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    if(n&1) {
        n--;
        if(a[n/2]>b[n/2]) cout<<0;
        else cout<<b[n/2]-a[n/2]+1;
    }
    else {
        n--;
        long double ma,mb;
        ma=(a[n/2]+a[n/2+1])/2.0;
        mb=(b[n/2]+b[n/2+1])/2.0;
        if(ma>mb) cout<<0;
        cout<<ll(2*(mb-ma)+1);
    }
	return 0;
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    ll A,B,N;
    cin>>A>>B>>N;
    ll n;
    if(N>=B-1)n=B-1;
    else{n=N;}
    ll ans=n*A/B;
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// O(N^.5)
/// --- primeFactors {{{ ///
#include <map>
map< ll, int > primeFactors(ll n) {
  map< ll, int > res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) n /= i, res[i]++;
  }
  if(n != 1) res[n] = 1;
  return res;
}
/// }}}--- ///


int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ll n, p;
  cin >> n >> p;
  auto pf = primeFactors(p);
  ll ans = 1;
  for(auto x: pf) {
    ll y, z;
    tie(y, z) = x;
    ll t = (z / n);
    for(ll i = 0; i < t; i++) ans *= y;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
N, M = map(int, input().split())
P = [list(input().split()) for i in range(M)]

AC = {}
WA = {}

for i in range(M):
    if P[i][0] in AC:  # すでにAC済みの場合
        continue
    if P[i][1] == "AC":  # はじめてのAC
        AC[P[i][0]] = True
        continue
    if not P[i][0] in WA:  # はじめてのWA
        WA[P[i][0]] = 1
    else:  # WA2回目以降
        WA[P[i][0]] += 1

WAsum = 0
for i in AC.keys():
    if i in WA:
        WAsum += WA[i]

print(len(AC), WAsum)


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

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

int main() {
	int X;
	cin>>X;
	int res = 360/(gcd(360, X));
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3632
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int n, m;
bool mat[57][57];
bool visited[57];
int a[57], b[57];

void dfs(int v){
  visited[v] = true;
  REP(i, n) {
    if(!mat[v][i]) continue;
    if(visited[i]) continue;
    dfs(i);
  }
}

int
main(void){  
  ios_base::sync_with_stdio(false);

  cin >> n >> m;
  ll ans = 0LL;
  REP(i, m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    mat[a[i]][b[i]] = mat[b[i]][a[i]] = true;
  }
  REP(i, m){
    //cout << "i: " << i << " ans: " << ans << endl;
    //橋候補を取り除く
    mat[a[i]][b[i]] = mat[b[i]][a[i]] = false;
    REP(j, n) visited[j] = false;
    //探索してみる
    dfs(0);
    bool bridge = false;
    REP(j, n) if(!visited[j]) bridge = true;
    if(bridge) ans++;
    //元に戻す
    mat[a[i]][b[i]] = mat[b[i]][a[i]] = true;    
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	ll n, a, b;
	cin >> n >> a >> b;
	cout << max((ll)0, (n - 1) * b + a - (n - 1) * a - b + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n;
	int input = 0;

	int ansmin = 0;
	int ansmax = 0;
	long long anssum = 0;

	// ??´??°????????°n??\???
	cin >> n;

	// n?????\?????°?????????
	for (int cnt = 0; cnt < n; cnt++)
	{
		// ??\???
		cin >> input;

		// ??\????????????????°????????????§?????±???????????´??°
		if (cnt == 0)
		{
			ansmin = input;
			ansmax = input;
		}

		// ????°??????´??????????°??????´??°
		if (input < ansmin)
		{
			ansmin = input;
		}
		else if (input > ansmax)
		{ // ?????§?????´???????????§?????´??°
			ansmax = input;
		}

		// ???????¨????
		anssum += input;
	}

	// ????????????(?????????????°????????????§??????????¨?)
	cout << ansmin << " " << ansmax << " " << anssum << endl;

	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

int main(){
    string s;
    cin >> s;
    deque<char> qu;
    for(int i=0;i<s.length();i++){
    if(s[i]=='B'&&qu.size()) qu.pop_back();
    else if(s[i]!='B') qu.push_back(s[i]);
    }
    while(qu.size()){
        char u;
        u=qu.front();
        qu.pop_front();
        cout << u;
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
const ll LINF=4000000000000000010;
int main(){
	int x,y;cin>>x>>y;
	cout<<x+y/2<<endl;
}	


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long absv(long long a){
	if(a<0) return -a;
	else return a;
}
int main(){
     long long a,b;
     cin>>a>>b;
     if(a<b) cout<<min(a,absv(a-b));
     else cout<<min(a-a/b*b,absv(a-((a/b+1)*b)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acos(-1);

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

    int N, M;
    cin >> N >> M;
    vector<bool> isused(N);
    for (int i = 0; i < M; ++i) {
        if (!isused[N - 2 * i - 1] && !isused[2 * i + 1] && 4 * i + 2 != N) {
            cout << i + 1 << " " << N - i << '\n';
            isused[N - 2 * i - 1] = isused[2 * i + 1] = true;
        } else {
            cout << i + 1 << " " << N - i - 1 << '\n';
            isused[N - 2 * i - 2] = isused[2 * i + 2] = true;
        }
    }

    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;
  
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    while(true){
      String input = sc.next();
      int output = 0;
      if(input.equals("0")){
        break;
      }
      for(int i = 0; i < input.length(); i++){
        char c = input.charAt(i);
        output += Character.getNumericValue(c);
      }
      System.out.println(output);
    }
  }
}


Measured memory_bytes: 26292
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <climits>

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

#define int long long

using namespace std;



signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    string S;

    cin >> S;
    bool even = S.length() % 2 == 0;
    bool same = S[0] == S[S.length()-1];

    if (even ^ same) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
	long long s,x2,y2,x3,y3,u,v;
	scanf("%lld",&s);
	u=(long long)sqrt((double)s);
	if(u*u==s){
	printf("0 0 %lld 0 0 %lld",u,u);		
	}
	else{
		v=(u+1)*(u+1)-s;
		printf("0 0 %lld 1 %lld %lld",u+1,v,u+1);		
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n, ma, mb, a, b, c, i, j;
	cin >> n >> ma >> mb;
	int x[41], y[41];
	int check = MOD;
	for (i = 0; i < n; i++) {
		cin >> a >> b >> c;
		x[i] = a * mb - b * ma; y[i] = c;
		if (x[i] == 0) {
			check = min(check, y[i]);
		}
	}
	int dp[8001];
	for (i = 0; i < 8001; i++)dp[i] = MOD;
	dp[4000]=0;
	for (i = 0; i < n; i++) {
		if (x[i] < 0) {
			for (j = 0; j < 8001; j++) {
				if (j == 4000) {
					dp[j + x[i]] = min(dp[j + x[i]], y[i]);
				}
				else if (j + x[i] >= 0 && j + x[i] <= 8000 && dp[j] != MOD) {
					if (dp[j + x[i]] != 0) {
						dp[j + x[i]] = min(dp[j + x[i]], dp[j] + y[i]);
					}
					else if(dp[j+x[i]]==0){
						dp[j + x[i]] = dp[j] + y[i];
					}
				}
			}
		}
		else if (x[i] >= 0) {
			for (j = 8000; j >= 0; j--) {
				if (j == 4000) {
					dp[j + x[i]] = min(dp[j + x[i]], y[i]);
				}
				else if (j + x[i] >= 0 && j + x[i] <= 8000 && dp[j] != MOD) {
					if (dp[j + x[i]] != 0) {
						dp[j + x[i]] = min(dp[j + x[i]], dp[j] + y[i]);
					}
					else if(dp[j+x[i]]==0){
						dp[j + x[i]] = dp[j] + y[i];
					}
				}
			}
		}
	}
	if (dp[4000] == 0 )cout << -1 << endl;
	else cout << min(check,dp[4000]) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  string s;
  cin>>s;
  if(s=="ABC") cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int N, L;
	cin >> N >> L;
	
	int tot = (L+(L+N-1))*N  / 2;
	int max = L + N - 1;
	int min = L;
	if((min <= 0) && (0 <= max))
		cout << tot << endl;
	else if(min > 0)
		cout << (tot - min) << endl;
	else if(max < 0)
		cout << (tot - max) << endl;	
	
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N, K = list(map(int, input().split()))
V = list(map(int, input().split()))

max_num = 0
V_left = [0,V[0]]
V_right = [0,V[N - 1]]
V_left_m = [[] for i in range(N + 1)]
V_right_m = [[] for i in range(N + 1)]
for i in range(N - 1):
    V_left.append(V_left[-1] + V[i + 1])
    V_right.append(V_right[-1] + V[N - 2 - i])

for i in range(1, N+1):
    if i == 0:
        minus_l = []
        minus_r = []
    else:
        minus_l = copy.deepcopy(V_left_m[i - 1])
        minus_r = copy.deepcopy(V_right_m[i - 1])
    if V[i - 1] < 0:
        minus_l.append(V[i - 1])
    V_left_m[i] = minus_l
    if V[N  - i] < 0:
        minus_r.append(V[N - i])
    V_right_m[i] = minus_r

for k in range(1, min(N, K) + 1):
    for i in range(0, k + 1):
        point = V_left[i] + V_right[k - i]
        minus = V_left_m[i] + V_right_m[k - i]
        minus = list(minus)
        minus = sorted(minus)
        point -= sum(minus[0:K - k])
        #print(i, k - i, point, minus, minus[0:K - k], K - k)
        if point > max_num:
            max_num = point
           # print(point, i, k-i,minus, minus[0:K-k], K-k)

print(max_num)


Measured memory_bytes: 40688