akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

int ret;
char ct;

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

void change(int depth, vector<string> board) {
	queue<int> q;
	vector<int> v;
	q.push(0);
	bool visit[8][8];
	memset(visit, false, sizeof(visit));
	visit[0][0] = true;
	while (!q.empty()) {
		int now = q.front(); q.pop();

		int y = now / 10;
		int x = now % 10;

		v.push_back(now);

		rep(dir, 4) {
			int nx = x + dx[dir];
			int ny = y + dy[dir];
			if (nx < 0 || nx >= board[0].size() || ny < 0 || ny >= board.size()) {
				continue;
			}
			if (board[y][x] != board[ny][nx]) {
				continue;
			}
			if (visit[ny][nx]) continue;

			visit[ny][nx] = true;

			q.push(ny * 10 + nx);
		}
	}
	if (depth == 0) {
		if (board[0][0] != ct) return;
		ret = max(ret, (int) v.size());
		return;
	}

	for (char c = '1'; c <= '6'; c++) {
		for (int e : v) {
			board[e / 10][e % 10] = c;
		}
		change(depth - 1, board);
	}
}

signed main() {
	while (true) {
		int h, w;
		cin >> h >> w >> ct;

		if (h == 0) break;

		ret = 0;

		vector<string> board;

		rep(y, h) {
			string tmp = "";
			rep(x, w) {
				tmp += nextChar();
			}
			board.push_back(tmp);
		}

		change(5, board);

		cout << ret << endl;
	}

    return 0;
}

Measured memory_bytes: 3152
import sys
readline = sys.stdin.readline

def solve():
    A, B, C = map(int, readline().split())
    K = int(readline())

    count = 0

    while B <= A:
        B *= 2
        count += 1
    
    while C <= B:
        C *= 2
        count += 1
    
    if count > K:
        print('No')
    else:
        print('Yes')

solve()

Measured memory_bytes: 61820
double x[100],y[100],t,u,b,s;n,i,j,k,c;main(m){for(;scanf("%d",&n),i=j=n;printf("%d\n",m)){for(m=1;i--;scanf("%lf,%lf",x+i,y+i));for(i=n;--i;)for(j=i-1;j--;)if((u=acos(hypot(x[j]-x[i],y[j]-y[i])/2))<9)for(s=1,t=atan2(y[j]-y[i],x[j]-x[i]);c=0,s+3;s-=2)for(b=y[i]+sin(t+s*u),k=n;k--;)hypot(x[i]+cos(t+s*u)-x[k],b-y[k])<1.1&&++c>m?m=c:0;}}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	r:=getNextInt(scanner)

	fmt.Fprintln(writer, r*r)
	writer.Flush()
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
  int sx, sy, tx, ty;
  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
  char ans[20000];
  int x = tx - sx;
  int y = ty - sy;
  int i, j;
  for (i = 0; i < y; i++)
    ans[i] = 'U';
  for (j = 0; j < x; j++, i++)
    ans[i] = 'R';
  for (j = 0; j < y; j++, i++)
    ans[i] = 'D';
  for (j = 0; j < x; j++, i++)
    ans[i] = 'L';
  ans[i++] = 'D';
  for (j = 0; j < x + 1; j++, i++)
    ans[i] = 'R';
  for (j = 0; j < y + 1; j++, i++)
    ans[i] = 'U';
  ans[i++] = 'L';
  ans[i++] = 'U';
  for (j = 0; j < x + 1; j++, i++)
    ans[i] = 'L';
  for (j = 0; j < y + 1; j++, i++)
    ans[i] = 'D';
  ans[i] = 'R';

  printf("%s\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_V = 100000;
const int MAX_LOG_V = 17;

vector<int> G[MAX_V];
int root;
int parent[MAX_LOG_V][MAX_V];
int depth[MAX_V];

void dfs(int v,int p,int d)
{
	parent[0][v] = p;
	depth[v] = d;
	for(int i = 0;i < G[v].size();i++)
	{
		if(G[v][i] != p)dfs(G[v][i],v,d+1);
	}
}

void init(int V)
{
	dfs(root,-1,0);
	//cout<<';'<<endl;
	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]];
		}
	}
}

int lca(int u,int 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;
	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];
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0;i<n;i++)
	{
		int k;
		cin >> k;
		for(int j = 0;j<k;j++)
		{
			int x;
			cin >> x;
			G[i].push_back(x);
			G[x].push_back(i);
		}
	}

	init(n);
	int q;
	cin >> q;
	while(q--)
	{
		int l,r;
		cin >> l >> r;
		cout<< lca(l,r)<<endl;
	}
}


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

typedef struct{
	int h;
	int m;
}cktime;

int main(){
	int a, b;
	cktime t[101], i[101];
	int nowN=0, nowM=0;
	
	scanf(" %d", &a);
	for(int k=0; k<a; ++k) scanf(" %d %d", &t[k].h, &t[k].m);
	t[a].h=25;
	scanf(" %d", &b);
	for(int k=0; k<b; ++k) scanf(" %d %d", &i[k].h, &i[k].m);
	i[b].h=25;
	
	bool flag=false;
	while(nowN<a || nowM<b){
		cktime p;
		if(flag) printf(" ");
		
		if(t[nowN].h < i[nowM].h) p=t[nowN++];
		else if(t[nowN].h > i[nowM].h) p=i[nowM++];
		else{
			if(t[nowN].m < i[nowM].m) p=t[nowN++];
			else if(t[nowN].m > i[nowM].m) p=i[nowM++];
			else{
				p=t[nowN];
				nowN++;
				nowM++;	
			}
		}	
		
		printf("%d:", p.h);
		if(p.m<10) printf("0");
		printf("%d", p.m);
		flag=true;
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <math.h>

int main(void) 
{
  int a,b,h,m;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  double scaler = 2 * M_PI;
  double angle_h = (double)(h*60+m)/720 * scaler;
  double angle_m = (double)m/60 * scaler;
  double angle = fabs(angle_h - angle_m) ;
  angle = (360 - angle < angle) ? 360 - angle : angle;
  double distance = sqrt(a*a+b*b-2*a*b*cos(angle));
  printf("%.15lf\n",distance);
  return 0;
}

Measured memory_bytes: 2564
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,q,d[100000],d2[100000],A,B,c,L,ans;
vector<ll> s,t;
int main(void){
    cin>>a>>b>>q;
    for(int i=0;i<a;i++){
        cin>>c;
        s.push_back(c);
    }
    for(int i=0;i<b;i++){
        cin>>c;
        t.push_back(c);
    }
    for(int i=0;i<s.size();i++){
        L=lower_bound(t.begin(),t.end(),s[i])-t.begin();
        A=abs(s[i]-t[L]);
        B=abs(t[max(0LL,L-1)]-s[i]);
        d[i]=min(A,B);
    }
    for(int i=0;i<t.size();i++){
        L=lower_bound(s.begin(),s.end(),t[i])-s.begin();
        A=abs(t[i]-s[L]);
        B=abs(s[max(0LL,L-1)]-t[i]);
        d2[i]=min(A,B);
    }
    while(q--){
        cin>>c;
        L=lower_bound(s.begin(),s.end(),c)-s.begin();
        A=abs(c-s[min((ll)s.size()-1,L)])+d[min((ll)s.size()-1,L)];
        B=abs(s[max(0LL,L-1)]-c)+d[max(0LL,L-1)];
        ans=min(A,B);
        L=lower_bound(t.begin(),t.end(),c)-t.begin();
        A=abs(c-t[min((ll)t.size()-1,L)])+d2[min((ll)t.size()-1,L)];
        B=abs(t[max(0LL,L-1)]-c)+d2[max(0LL,L-1)];
        ans=min(ans,min(A,B));
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 4596
#include <iostream>
#include <string>
using namespace std;
int main(){
    int k,n;
    string s;
    cin >> n >> s >> k;
    for(auto it=s.begin(); it!=s.end(); it++){
        cout << ((*it==s[k-1])? *it : '*');
    }
    cout << endl;
}

Measured memory_bytes: 256
import math
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

D1 = 0
d2 = 0
d3 = 0
dm =[]
for i in range(n):
    D1 += abs(x[i]-y[i])
    d2 += (abs(x[i]-y[i]))**2
    d3 += (abs(x[i]-y[i]))**3
    m = abs(x[i]-y[i])
    dm.append(m)
    
D2 = math.sqrt(d2)
D3 = d3 ** (1/3)
Dm = max(dm) 

print(f'{D1:.06f}')
print(f'{D2:.06f}')
print(f'{D3:.06f}')
print(f'{Dm:.06f}')


Measured memory_bytes: 5708
#include<stdio.h>
int main(void){
  int l,i,j;
  scanf("%d",&l);
  int v[l],c[l],sa,sum=0;
  for(i=0;i<l;i++){
    scanf("%d",&v[i]);
  }
  for(i=0;i<l;i++){
    scanf("%d",&c[i]);
    sa=v[i]-c[i];
    if(sa>0){
      sum+=sa;
    }
  }
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 128
from collections import deque
n =  int(input())

mylist = deque()


for i in range(n):
    a = input()
    if a == "deleteFirst":
        mylist.popleft()
    elif a == "deleteLast":
        mylist.pop()
    else:
        a,key = a.split()
        if a == "insert":
            mylist.appendleft(key)
        else:
            try:
                mylist.remove(key)
            except:
                pass

print(' '.join(mylist))



Measured memory_bytes: 69736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

ll c[maxn],p[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)cin>>c[i];
  p[0] = 1;
  for(int i=1;i<=n;i++)p[i] = p[i-1] * 2 % mod;
  ll ret = 0;
  sort(c+1,c +n+1, greater<int>());
  for(int i=1;i<=n;i++){
    ll tmp = p[n-i]*p[n-i]%mod * p[i]%mod;
    tmp = tmp * c[i]%mod;
    tmp = (p[i-1] + (i-2>=0?(i-1)*p[i-2]%mod:0))%mod*tmp%mod;
    ret = (ret+tmp)%mod;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <stack>

using namespace std;


int main(){

	int w, h;

	while(1){
		cin >> h >> w;
		if(h==0 && w==0) break;

		int obi = w*w + h*h;
		int ans[2] = {150, 150};
		int ans_obi;
		int temp;

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

				temp = i*i + j*j;
				ans_obi = ans[0]*ans[0] + ans[1]*ans[1];

				if(obi < temp && temp < ans_obi){
					ans[0] = i;
					ans[1] = j;
				}
				if(obi == temp){
					if(i>h && temp < ans_obi){
						ans[0] = i;
						ans[1] = j;
					}
				}
				if(temp == ans_obi){
					if(i<ans[0] && temp > obi){
						ans[0] = i;
						ans[1] = j;
					}
				}

			}
		}

		cout << ans[0] << ' ' << ans[1] << endl;


	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void){
    int x, y, a;
    scanf("%d", &x);
    scanf("%d", &y);
    
    while(1){
        a = x % y;
        if(a == 0){
            break;
        }
        x = y;
        y = a;
    }
    printf("%d\n", y);
    
    return 0;
}


Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int X;
		int Y;
		int Z;
		int temp;
		Scanner sc = new Scanner(System.in);
		X = sc.nextInt();
		Y = sc.nextInt();
		Z = sc.nextInt();
		temp = X;
		X = Y;
		Y = temp;
		temp=X;
		X=Z;
		Z=temp;
		System.out.println(X+" "+Y+" "+Z);
		sc.close();
	}
}


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

int main(){
    ll n,c,k,ans = 0;
    cin >> n >> c >> k;
    vector<ll> t(n);
    for(int i = 0;i < n;i ++){
        cin >> t[i];
    }
    sort(t.begin(),t.end());
    for(int i = 0;i < n;i ++){
        if(i==n-1){ans ++;break;}
        int j=i+1,cnt=1;
        while(t[j]-t[i]<=k&&cnt<c){
            j ++;
            cnt ++;
        }
        ans ++;
        i = j-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
S = input()

#print(int(S[5:7]))
if int(S[0:4]) < 2019:
    print('Heisei')

elif int(S[5:7]) < 4:
    print('Heisei')

elif int(S[5:7]) == 4 and int(S[8:10]) <= 30:
    print('Heisei')
else:
    print('TBD')

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve(void){
    int n, x;
    cin >> n >> x;
    if(x <= 1 || n*2 - 1 <= x){
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
    if(n == 2){
        int cnt = 1;
        while(cnt <= 3){
            cout << cnt << endl;
            cnt++;
        }
        return;
    }
    vector<int> ans(n*2 - 1);
    vector<bool> done(n*2 - 1);
    if(x == 2){
        ans[n-2] = x+1;
        ans[n-1] = x;
        ans[n] = x-1;
        ans[n+1] = x+2;
        REP(i, x-1, x+3){
            done[i] = true;
        }
    }else{
        ans[n-2] = x-1;
        ans[n-1] = x;
        ans[n] = x+1;
        ans[n+1] = x-2;
        REP(i, x-2, x+2){
            done[i] = true;
        }
    }
    int now = 1;
    rep(i, n*2 - 1){
        if(ans[i] > 0){
            continue;
        }
        while(done[now]){
            now++;
        }
        ans[i] = now;
        done[now] = true;
    }
    rep(i, n*2 - 1){
        cout << ans[i] << endl;
    }
    return;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
const int MN = 1e5+100;
int t[MN];
vector<int> v[MN];
int n,k;
int ans = 0;
bool used[MN];
int f(int x) {
    int ma = 0;
    used[x] = 1;
    for(int y: v[x])  {
        if(!used[y]) {
            int q = f(y);
            if(x != 1 && q == k) {
                ++ans;
            }
            else {
                ma = max(ma, q);
            }
        }
    }
    return ma+1;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k;
    for(int i = 1; i <= n; ++i) {
        cin>>t[i];
        if(i > 1) {
            v[t[i]].push_back(i);
        }
    }
    if(t[1] != 1) {
        t[1] = 1;
        ++ans;
    }
    f(1);
    cout<<ans<<'\n';
}


Measured memory_bytes: 10880
import math

class UnionFind(): # 0インデックス
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        '''
        xとyは-=1して使う
        '''
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

if __name__ == "__main__":
    N, M = map(int, input().split()) # N人、M個の関係
    union_find = UnionFind(N)
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        union_find.union(A, B)

    answer = 0
    for i in range(N):
        answer = max(answer, union_find.size(i))

    print(answer)
   

Measured memory_bytes: 77948
using System;

namespace question1
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run()
        {
            var line = Console.ReadLine();

            var x = int.Parse(line.Split(' ')[0]);
            var y = int.Parse(line.Split(' ')[1]);

            Console.WriteLine($"{x + y / 2}");
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int n,k,a,p;
int main(void){
	cin>>n>>k;
	k--;n--;
	for(int i=0;i<n;i++)cin>>a;
//	for(int i=0;i<n;i++){cin>>a;if(a==1)p=i;}
//	if(n==k){cout<<1;return 0;}
	int ans=n/k+(n%k==0?0:1);
	cout<<ans;
	return 0;
} 

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							     \
			cout.tie(0);
#define sz(arr) ll(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }
ll kCn(ll k, ll n, ll f[]) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

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

int n, m, q;
vector<int> a(1001);
vector <item> arr(1001);
ll ans = 0;

void dfs(int cur, int idx) {
	if (idx > n) {
		ll total = 0;
		for (int i = 0; i < q; ++i) {
			int ai = arr[i].a;
			int bi = arr[i].b;
			int ci = arr[i].c;
			if (a[bi] - a[ai] == ci) {
				total += arr[i].d;
			}
		}
		ans = max(ans, total);
		return;
	}
	for (int i = cur; i <= m; ++i) {
		a[idx] = i;
		dfs(i, idx + 1);
	}
}

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;

	cin >> n >> m >> q;

	for (int i = 0; i < q; ++i) {
		cin >> arr[i].a;
		cin >> arr[i].b;
		cin >> arr[i].c;
		cin >> arr[i].d;
	}

	dfs(1, 1);
	cout << ans;
	


	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<int,int> P;
ll match[10] = {0,2,5,5,4,5,6,3,7,6};
string big(string s,string t){
    string res = "";
    rep(i,s.length()){
        if (s[i]-'0' > t[i]-'0'){
            res = s;
            break;
        }
        else if (s[i]-'0' < t[i]-'0'){
            res = t;
            break;
        }
    }
    if (res == "") res = s;
    return res;
}
int main(){
    ll n,m,a;
    cin >> n >> m;
    ll num[9] = {0};
    rep(i,m){
        cin >> a;
        chmax(num[match[a]],a);
    }
    string s[20005];
    string c;
    ll l;
    s[0] = "";
    rep(i,n){
        l = s[i].length()+1;
        if (i != 0 && s[i] == "") continue;
        rep(j,2,8){
            if (num[j] != 0){
                if (i == 0 || num[j] < s[i][0]-'0'){
                    c = s[i]+(char)(num[j]+'0');
                }
                else c = (char)(num[j]+'0')+s[i];
                //PRINT(i+j << " " << c << " " << s[i+j]);
                if (l > s[i+j].length()) s[i+j] = c;
                else if(l == s[i+j].length()) s[i+j] = big(s[i+j],c);
            }
        }
    }
    PRINT(s[n]);
}

Measured memory_bytes: 34816
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		boolean[] isAc = new boolean[N+1];
		Arrays.fill(isAc, false);
		int[] was = new int[N+1];
		Arrays.fill(was, 0);
		int ac = 0;
		int wa = 0;

		for (int i = 0; i < M; i++) {
			int p = sc.nextInt();
			String s = sc.next();
			if (isAc[p]) continue;
			if (s.equals("WA")) was[p]++;
			else {
				ac++;
				isAc[p] = true;
				wa += was[p];
			}
		}
		System.out.println(ac+" "+wa);
	}
}

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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j : {i + 1, i + 2}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}

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

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

using namespace std;

int main() {
  int n;
  cin>>n;
  string name;
  cin>>name;
  int l=name.size();
  int cnt = 0;
  REP(hoge,n){
    string b;
    cin>>b;
    int m=b.size();
    bool okok = false;
    REP(i,m)REP(j,m){
      if(!j)continue;
      bool ok=true;
      REP(k,l){
        int p=i+k*j;
        if(p >= m || b[p] != name[k]) {
          ok=false;
          break;
        }
      }
      if (ok)okok=true;
    }
    if(okok)++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;

int ctoi(char c) {
	return c - '0';
}


int main()
{
	long long int a, b, c;

	cin >> a >> b >> c;

	if(c >= (a - b))
		cout << c - (a - b) << endl;
	else
		cout << 0 << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>

#include <cstdio>

#define N 100005

using namespace std;



typedef long long ll;

ll n, x, m, sum, ans, c[N], s[N];

int main()
{

    ll i;

    cin >> n >> x >> m;

    for (i = 1; i <= n; i++, x = x * x % m) {

        if (!c[x]) c[x] = i, s[x] = sum;

        else break;

        sum += x;

    }

    if (i > n) {cout << sum << endl; return 0;}

    ll t = (n - c[x] + 1) / (i - c[x]);

    ans = s[x] + (sum - s[x]) * t;

    n = (n - c[x] + 1) % (i - c[x]);

    for (i = 1; i <= n; i++, x = x * x % m) {

        ans += x;

    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  int N = 0,x = 0,ans = 0;
  cin >> N >> x;
  vector<int>A(N);
  rep(i,N){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  rep(i,N){
    x -= A[i];
    ans++;
    if(x < 0){
      cout << ans - 1;
      return 0;
    }
  }
  if(x != 0){
    cout << N - 1;
  }
  else{
    cout << N;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))

//辺の情報を個別に持つタイプ
int n;
int oya[30];
int ko1[30],ko2[30];

int f(int v,int mode){
	if(mode==0)printf(" %d",v);
	if(ko1[v]!=-1)f(ko1[v],mode);
	if(mode==1)printf(" %d",v);
	if(ko2[v]!=-1)f(ko2[v],mode);
	if(mode==2)printf(" %d",v);
}

int cnt[30];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)oya[i]=-1;
	for(int i=0;i<n;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		ko1[x]=y;
		ko2[x]=z;
		oya[y]=x;
		oya[z]=x;
		cnt[y]++;
		cnt[z]++;
	}
	int root;
	for(int i=0;i<n;i++)if(cnt[i]==0)root=i;
	puts("Preorder");
	f(root,0);
	puts("");
	puts("Inorder");
	f(root,1);
	puts("");
	puts("Postorder");
	f(root,2);
	puts("");
}




Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
	char a[3], b[3];
	std::cin >> a >> b;
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) std::cout << "YES"; else std::cout << "NO";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, a[100005];
int main() {
	cin>>n;
	for(int i=0; i<n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	cout<<a[n/2] - a[n/2-1];
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void) {
  char s[3];
  int r = 700;
  int i;
  for(i = 0; i < 3; i++) {
    scanf("%c", &s[i]);
    if(s[i] == 'o') r += 100;
  }
  printf("%d\n", r);
  return 0;
}

Measured memory_bytes: 128
//13
#include<iostream>
#include<cstdlib>
#include<algorithm>

using namespace std;

int x,y,z;
int v[4];
int e[51],a[51];
bool p[51][50001];
double mem[51][50001];

double dfs(int s,int m){
  if(s>=y){
    return m;
  }else if(p[s][m]){
    return mem[s][m];
  }else{
    double sm=0;
    for(int i=0;i<x;i++){
      int c=s+v[i];
      int cm=m;
      if(c<y){
	if(e[c]==1){
	  c+=a[c];
	}else if(e[c]==2){
	  cm+=a[c];
	}else if(e[c]==3){
	  if(cm>a[c]){
	    cm-=a[c];
	  }else{
	    cm=0;
	  }
	}
      }
      sm+=dfs(c,cm);
    }
    p[s][m]=true;
    return mem[s][m]=sm*1./x;
  }
}

int main(){
  while(cin>>x>>y>>z,x|y|z){
    for(int i=0;i<x;i++){
      cin>>v[i];
    }
    fill(e,e+51,0);
    for(int i=0;i<z;i++){
      int n;
      cin>>n;
      cin>>e[n]>>a[n];
    }
    fill(p[0],p[51],false);
    cout<<(int)dfs(0,0)<<endl;
  }
  return 0;
}

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

int binarySearch(int a[], int n, int key)
{
    int lo = 0;
    int hi = n - 1;

    while (lo <= hi)
    {
        int mid = lo + (hi - lo) / 2;
        if (key > a[mid])
        {
            lo = mid + 1;
        }
        else if (key < a[mid])
        {
            hi = mid - 1;
        }
        else
        {
            return mid;
        }
    }
    return -1;
}


int threeSum(int a[], int n, int s)
{
    int b[n * n];
    int c[n * n];
    int d[n * n];
    int k = 0;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            b[k] = s - (a[i] + a[j]);
            c[k] = a[i];
            d[k++] = a[j];
        }
    }
    for (int i = 0; i < k; i++)
    {
        int t = binarySearch(a, n, b[i]);
        if (t != -1)
        {    
            count++;
        }
        
    }
    return count;
}

int main()
{
    int k, s;
    cin >> k >> s;
    int list[k + 1];
    for (int i = 0; i < k + 1; i++)
    {
        list[i] = i;
    }
    cout << threeSum(list, k+1, s) << endl;
    return 0;
}


Measured memory_bytes: 73600
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  int n;
  cin >> n >> s;
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  n/=2;
  if(n==0){
    cout << "No" << endl;
    return 0;
  }
  if(s.substr(0,n)==s.substr(n,n))cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
  string S,R,U;
  int A,B;
  cin>>S>>R>>A>>B>>U;
  if(S==U){
    cout<<A-1<<" "<<B<<endl;
  }
  else{
    cout<<A<<" "<<B-1<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
using namespace std;
 
long long dataset[300005]={0};
 
int main()
{
    int number;
    cin>>number;
 
    for(int i=0;i<number;i++)
        cin>>dataset[i];
 
    ll result=0;
    for(ll i=0,p=1;i<61;i++,p*=2ll)
    {
        long long zeros=0,ones=0;
 
        for(ll j=0;j<number;j++)
        {
            if(dataset[j]%2ll==1)
                ones++;
            else
                zeros++;
            dataset[j]/=2ll;
        }
        result+=((ones*zeros)%MOD*(p%MOD))%MOD;
      result%=MOD;
 
    }
    cout<<result<<endl;
}


Measured memory_bytes: 5936
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

L = []
cnt = 0

ab = abs(a-b)
ac = abs(a-c)
ad = abs(a-d)
ae = abs(a-e)
bc = abs(b-c)
bd = abs(b-d)
be = abs(b-e)
cd = abs(c-d)
ce = abs(c-e)
de = abs(d-e)

L.append(ab)
L.append(ac)
L.append(ad)
L.append(ae)
L.append(bc)
L.append(bd)
L.append(be)
L.append(cd)
L.append(ce)
L.append(de)

for l in L:
    if l > k:
        print(':(')
        break
    else:
        cnt += 1
        if cnt == 5:
            print('Yay!')





Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using ll = long long;
const ll MOD=1e9+7;
const long long INF = 1LL<<60;

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

    int answer = -1;
    for(int i = 1;i<=100000;i++){
        if(int(i*0.08)==a && int(i*0.1)==b){
            answer = i;
            break;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#include<climits>
#include<sstream>
using namespace std;
#define maxn 10010
struct Node{
    int x,y,val,pre;
};
Node g[100010];
int gh[maxn],du[maxn];
int n,m;
stack<int> s;

int main(){

    int i,j;
    cin>>n>>m;
    memset(gh,-1,sizeof gh);
    memset(du,0,sizeof du);
    for(i=0;i<m;i++){
        cin>>g[i].x>>g[i].y;
        g[i].pre=gh[g[i].x];
        gh[g[i].x]=i;

        du[g[i].y]++;
    }
    for(i=0;i<n;i++)
        if(du[i]==0)
            s.push(i);
    int cnt=0;
    while(!s.empty()){
        int t=s.top();
        s.pop();
        cnt++;
        j=gh[t];
        while(j!=-1){
            int yy=g[j].y;
            du[yy]--;
            if(!du[yy]) s.push(yy);
            j=g[j].pre;
        }
    }
    if(cnt==n)
        cout<<0<<endl;
    else
        cout<<1<<endl;
    return 0;
}



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

long long n;
long long ans = 1e16;
int main(){
	scanf("%lld",&n);
	long long t = sqrt(n) + 1;
	for(long long i = t;i;i--){
		if(n % i == 0){
			ans = i + n / i - 2;
			break;
		}
	}
	printf("%lld",ans);
	return 0;
}
		

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;

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

    Map map = new HashMap();
    map.put("Sunny", "Cloudy");
    map.put("Cloudy", "Rainy");
    map.put("Rainy", "Sunny");
    
 	String s = sc.next();

    String result = (String) map.get(s);

    System.out.println(result);
  }
}



Measured memory_bytes: 26928
#include <bits/stdc++.h>
#define il inline
const int N=1e5+5;

int n,a[N];

il bool cmp(int x,int y){return x>y;}

int main()
{
	scanf("%d",&n); int i,j;
	for (i=1; i<=n; i++) scanf("%d",a+i);
	std::sort(a+1,a+n+1,cmp);
	
	for (i=1; i<=n; i++) if (i+1>a[i+1])
	{
		for (j=0; a[i+j+1]==i; j++);
		if ((j&1)||(a[i]-i&1)) puts("First");
		else puts("Second");
		break;
    }
	
	return 0;
}

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

int main(void) {
	string s;
	cin >> s;
	int cnt = 0, max = 0;
	bool f = 0;
	for (int i = 0; i < 3; i++) {
		if (f == 1)cnt++;
		else cnt = 0;
		if (s[i] == 'R')f = 1;
		else f = 0;
		if (cnt > max)max = cnt;
	}
	if (f == 1)cnt++;
	else cnt = 0;
	if (cnt > max)max = cnt;
	cout << max;
	return 0;
}

Measured memory_bytes: 3592
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toLong)
    val abList = Array(m.toInt()) {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        Pair(a - 1, b - 1)
    }.toMutableList().apply { this.removeAt(0) }.reversed()

    val cost = mutableListOf<Long>().apply { this.add(n * (n - 1) / 2) }
    val union = UnionFind(n.toInt())

    for ((a, b) in abList) {
        if (union.root(a) == union.root(b)) {
            cost.add(cost.last())
        } else {
            cost.add(cost.last() - union.size(a) * union.size(b))
        }
        union.union(a, b)
    }
    cost.reversed().forEach(::println)
}

class UnionFind(num: Int) {
    val parent = IntArray(num) { it }
    val rank = IntArray(num) { 1 }

    fun union(u: Int, v: Int): Int {
        var ru = root(u)
        var rv = root(v)
        if (ru == rv)
            return ru
        if (rank[rv] < rank[ru]) {
            val temp = rv
            rv = ru
            ru = temp
        }
        parent[ru] = rv
        rank[rv] += rank[ru]
        rank[ru] = -1
        return rv
    }

    fun root(u: Int): Int {
        var tu = u
        while (parent[tu] != tu)
            tu = parent[tu]
        return tu
    }

    fun size(u: Int): Int {
        return rank[this.root(u)]
    }
}

Measured memory_bytes: 81376
#include <cstdio>
#include <algorithm>
#include <cstring>
#define INF 1<<30
using namespace std;
int n,cnt[30][100],m;
char s[100];
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%s",s);
		for (int j=0;j<strlen(s);j++)
			cnt[s[j]-'a'+1][i]++;
	}
	for (int i=1;i<=26;i++) {
		m=INF;
		for (int j=1;j<=n;j++)
			m=min(m,cnt[i][j]);
		for (int j=1;j<=m;j++)
			printf("%c",i+'a'-1);
	}
	printf("\n");
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
long long INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
    int h,w,d,q;
    scanf("%d %d %d",&h,&w,&d);
    vector<pair<int,int>> vp(h*w+1);
    FOR(i,1,h+1){
        FOR(j,1,w+1){
            int a;
            scanf("%d",&a);
            vp[a] = make_pair(i,j);
        }
    }

    scanf("%d",&q);
    vector<ll> vl(h*w+1);
    FOR(i,1,d+1) vl[i] = 0;
    FOR(i,d+1,h*w+1) vl[i] = vl[i-d] + abs(vp[i].first-vp[i-d].first) + abs(vp[i].second-vp[i-d].second);
    
    vector<ll> answer(q);
    REP(i,q){
        int l,r;
        scanf("%d %d",&l,&r);
        answer[i] = vl[r] - vl[l];
    }
    REP(i,q) printf("%lld\n",answer[i]);
    return 0;
}


Measured memory_bytes: 3328
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
s = [["#"] + i + ["#"] for i in s]
s = [["#" for i in range(w+2)]] + s + [["#" for i in range(w+2)]]
for i in range(h+2):
  print("".join(s[i]))

Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,K,k; cin >> N >> K;
  k=K;
  int count=1;
  while(true){
    if(k>N){
      break;
    }
    k*=K;
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        String[] S = s.split("");
        String[] T = t.split("");
        
        int count = 0;
        
        for(int i = 0; i < S.length; i++) {
            if(S[i].equals(T[i])) {
                count++;
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 23764
def main():
    s = input().rstrip()
    t = input().rstrip()

    s_len = len(s)
    t_len = len(t)
    if s_len+1 == t_len and s == t[:s_len]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 8956
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<cstring>
using namespace std;

int BIT[100005];
int sum(int a) {
	int k = 0;
	while (a > 0) {
		k += BIT[a];
		a -= a&(-a);
	}
	return k;
}
void add(int a,int b) {
	while (a <= 100005) {
		BIT[a] += b;
		a += a&(-a);
	}
}
signed main() {
	int a, b; cin >> a >> b;
	for (int c = 0; c < b; c++) {
		int d, e, f; scanf("%d%d%d", &d, &e, &f);
		if (d) {
			cout << sum(f) - sum(e - 1) << endl;
		}
		else {
			add(e, f);
		}
	}
}

Measured memory_bytes: 3536
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,x[100],y[100],h[100];
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>h[i];
	for(int cx=0;cx<=100;cx++)
	{
		for(int cy=0;cy<=100;cy++)
		{
			int j=0;
			for(;h[j]==0;j++);
			int H=h[j]+abs(cx-x[j])+abs(cy-y[j]);
			int f=0;
			for(int i=0;i<n;i++)
			{
				if(h[i]!=max(H-abs(cx-x[i])-abs(cy-y[i]),0))
				{
					f=1;
					break;
				}
			}
			if(f==0)
			{
				cout<<cx<<" "<<cy<<" "<<H<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
// r#"3 3"# => r#"2"#,

// r#"2 2"# => r#"0"#,

r#"999999 999999"# => r#"151840682"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        s: String,
    }

    if s == "SUN" {
        7
    } else if s == "MON" {
        6
    } else if s == "TUE" {
        5
    } else if s == "WED" {
        4
    } else if s == "THU" {
        3
    } else if s == "FRI" {
        2
    } else {
        1
    }.to_string()
}

Measured memory_bytes: 4352
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         String input = infile.readLine();
         long K = Long.parseLong(infile.readLine());
         int N = input.length();
         char[] arr = input.toCharArray();
         int left = 0;
         int right = 0;
         long res = 0L;
         while(right < N)
         {
            while(right < N && arr[left] == arr[right])
               right++;
            int boof = right-left;
            res += boof/2;
            left = right;
         }
         if(arr[0] != arr[N-1])
            System.out.println(K*res);
         else
         {
            long res2 = 0L;
            int count = 0;
            for(int i=0; i < N; i++)
            {
               if(arr[i] == arr[0])
                  count++;
               else
               {
                  int upper = N;
                  while(arr[upper-1] == arr[0])
                     upper--;
                  int l = i;
                  int r = i;
                  while(r < upper)
                  {
                     while(r < upper && arr[l] == arr[r])
                        r++;
                     int boof = r-l;
                     res2 += boof/2;
                     l = r;
                  }
                  break;
               }
            }
            if(count == N)
            {
               System.out.println(K*N/2);
               return;
            }
            res = count/2;
            int count2 = 0;
            for(int i=N-1; i >= 0; i--)
            {
               if(arr[i] == arr[0])
                  count2++;
               else
                  break;
            }
            res += count2/2;
            res += K*(res2);
            res += ((long)count+count2)/2*(K-1);
            System.out.println(res);
         }
      }
   }

Measured memory_bytes: 22996
#include <stdio.h>
#include<string.h>


int main()
{
    char  s[1000],t[1000];
    int slen, tlen;
    int minmin=1000;
    scanf("%s", s);
    scanf("%s", t);
    slen = strlen(s);
    tlen = strlen(t);
    for (int i = 0; i <= slen - tlen;i++){
        int cnt = 0;
        for (int j = 0; j < tlen;j++){
            if(s[i+j]!=t[j]){
                cnt++;
            }
        }
        if(minmin>cnt){
            minmin = cnt;
        }
    }
    printf("%d\n", minmin);
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String n = in.readLine();
    System.out.println("ABC" + n);
  }
}

Measured memory_bytes: 36116
N,K=(int(i) for i in input().split())
poss = [0]*(N+1)
# ~ for i in range(N): poss.append([])
for _ in range(K):
	x = int(input())
	for y in (int(j) for j in input().split()):
		poss[y]+=1
ans = 0
for i in range(1, N+1):
	if poss[i]==0:
		ans+=1
print(ans)


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxs = 3005;
const int INF = 1e9 + 7;

int s;
ll ans;
ll fac[maxs], ifac[maxs];

inline ll qpow(ll x, ll y){
	ll ret = 1;
	for(; y; y >>= 1){
		if(y & 1)
			(ret *= x) %= INF;
		(x *= x) %= INF;
	} 
	return ret;
}

inline ll C(int x, int y){ return fac[x] * ifac[y] % INF * ifac[x - y] % INF; }

int main(){
	scanf("%d", &s); s -= 3;
	fac[0] = 1;
	FOR(i, 1, maxs)
		fac[i] = fac[i - 1] * i % INF;
	ifac[maxs - 1] = qpow(fac[maxs - 1], INF - 2);
	for(int i = maxs - 2; i >= 0; --i)
		ifac[i] = ifac[i + 1] * (i + 1) % INF; 
	for(int n = 1; s >= 0; s -= 3, ++n)
		(ans += C(s + n - 1, n - 1)) %= INF;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <cstdlib>
using namespace std;

const int maxn = 1e5+1;
vector<int> e[maxn];
set<pair<int, int> > visE;
set<int> vis;

void dfs(int u, int fa = -1) {
  vis.insert(u);
  int degu = 0;
  for(auto v : e[u]) {
    if(fa == v) continue;
    if(vis.find(v) == vis.end()) {
      dfs(v, u);
    }
    auto ituv = visE.find(make_pair(u, v));
    auto itvu = visE.find(make_pair(v, u));
    if(ituv != visE.end()) {
      degu++;
    }
    if(ituv == visE.end() && itvu == visE.end()) {
      visE.insert(make_pair(v, u));
    }
  }
  if(fa != -1) {
    if(degu % 2 == 0) {
      visE.insert(make_pair(fa, u));
    }
    else {
      visE.insert(make_pair(u, fa));
    }
  }
}

int main() {
  int N, M, x, y;
  cin>>N>>M;
  for(int i = 0; i < M; i++) {
    cin>>x>>y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1);
  if(M % 2 == 1) {
    cout<<"-1"<<endl;
  } else {
    for(auto pr: visE) {
      cout<<pr.first<<" "<<pr.second<<endl;
    }
  }
  return 0;
}


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

using namespace std;
using ll = long long;

int n, m;
vector<vector<int>> hen;
vector<bool> seen;
vector<int> top;

void dfs(int v) {
    if(seen[v]) return;
    seen[v] = true;
    for(auto i : hen[v]) {
        dfs(i);
    }
    top.push_back(v);
}

int main()
{
    cin >> n >> m;
    hen.resize(n);
    seen.resize(n);
    for(int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        hen[a].push_back(b);
    }
    for(int i = 0; i < n; i++)dfs(i);
    reverse(top.begin(), top.end());
    for(auto i : top)cout << i << endl;
}


Measured memory_bytes: 3648
def main():
	N = int(input())
	A = [0]*N
	MOD = 998244353
	summation = 0

	for i in range(N):
		A[i] = int(input())
		summation += A[i]

	# dp[i][j] represents sum of red is j at i position
	dp = [[0 for _ in range(summation+1)] for _ in range(N)]
	dp[0][0] = 2 # green or blue
	dp[0][A[0]] = 1 # red

	for i in range(1, N):
		for j in range(len(dp[i])):
			dp[i][j] += dp[i-1][j] * 2 % MOD # don't use A[i] for red, i.e. use green or blue
			dp[i][j] += dp[i-1][j-A[i]] % MOD if 0 <= j - A[i] <= len(dp[i]) else 0 # use i red

	# total
	ans = (3 ** N) % MOD
	ceil = summation // 2
	if summation % 2 != 0:
		ceil += 1
	ans -= sum([dp[N-1][r] for r in range(ceil, summation+1)])*3
	ans %= MOD

	if summation %2 == 0:
		# case r = g = S/2
		dp  =[[0 for _ in range(summation//2+1)] for _ in range(N)]
		dp[0][0] = 1 # only blue
		dp[0][A[0]] = 1
		for i in range(1, N):
			for j in range(len(dp[i])):
				dp[i][j] += dp[i-1][j] % MOD
				dp[i][j] += dp[i-1][j-A[i]] % MOD if 0 <= j-A[i] <= len(dp[i]) else 0
		ans += dp[N-1][summation//2]*3
		ans %= MOD

	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 382648
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let m = get!(usize);
    let mut xs = vec![0; m];
    for _ in 0..n {
    	let mut k = get!();
        for _ in 0..k {
        	let x = get!(usize);
            xs[x-1] += 1;
        }
    }
    let ans = xs
    	.iter()
        .filter(|x| **x == n)
        .count();
        
	println!("{}", ans);
}

Measured memory_bytes: 4352