akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
void File(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define ll long long
ll n,m,ans;
int main(){
	//File();
	scanf("%lld%lld",&n,&m);
	if(n==1 && m==1)cout<<1<<endl;
	else if(n==1 || m==1){
		if(n==1)cout<<m-2<<endl;
		else cout<<n-2<<endl;
	}
	else if(n<=2 || m<=2)cout<<0<<endl;
	else cout<<(n-2)*(m-2)<<endl;
	return 0;
}


Measured memory_bytes: 256
//問題URL
//

//解き方メモ
//
    
#include<iostream>
using namespace std;

int main(){
  int n;
  int tmp;
  int dsum;
  
  cin >> n;

  tmp = n;
  dsum = 0;
  for (int i = 0; tmp > 0; i++) {
    dsum += tmp%10;
    tmp /= 10;
  }

  if (n%dsum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;    
  }
  
  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  
  string S;
  cin >> S;

  int A = 0, B = 0;

  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '0') A++;
    else B++;
  }

  cout << min(A, B) * 2 << endl;
}

Measured memory_bytes: 512
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
void Solve() {
	int a, b, c;
	cin >> a >> b >> c;
	int m = min(a + b + 1, c);
	cout << (m + b) << endl;
}
int main() {
	Solve();
	return 0;
}



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

using namespace std;

const int MAXN = 100005;

vector<int> graph[MAXN];
int dp[MAXN], grad[MAXN];
bool viz[MAXN];

int dfs(int nod){
    viz[nod] = 1;
    for(int i = 0; i < int(graph[nod].size()); ++i){
        dp[graph[nod][i]] = max(dp[graph[nod][i]], dp[nod] + 1);
        grad[graph[nod][i]]--;
        if(grad[graph[nod][i]] == 0)
            dfs(graph[nod][i]);
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= m; ++i){
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        grad[y]++;
    }
    for(int i = 1; i <= n; ++i){
        if(!viz[i] && grad[i] == 0)
            dfs(i);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        ans = max(ans, dp[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 11264
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace AOJ2
{
    class Program
    {
        static void Main()
        {
            var result = Enumerable.Range(1, 30).Except(Read().ToArray()).ToArray();
            Console.WriteLine(result[0] + Environment.NewLine + result[1]);
        }

        private static IEnumerable<int> Read()
        {
            for (int i = 0; i < 28; i++)
            {
                yield return int.Parse(Console.ReadLine());
            }
        }
    }
}

Measured memory_bytes: 6404
num = int(input())
strs = input()
allRs = 0
notAlignedRs = 0
for i in range(num):
    if strs[i] == 'R':
        allRs += 1
for i in range(allRs):
    if strs[i] == 'W':
        notAlignedRs += 1
print(notAlignedRs)

Measured memory_bytes: 9460
#include <iostream>
#include <tuple>
#include <vector>
#include <array>

int calc(int pos, int N, int X, int M, std::array<int, 10> &A, std::vector<std::tuple<int, int, int, int>> const &constraints)
{
    if (pos == N)
    {
        int score = 0;
        for (auto const &constraint : constraints)
        {
            int a = std::get<0>(constraint) - 1;
            int b = std::get<1>(constraint) - 1;
            int c = std::get<2>(constraint);
            if (A[b] - A[a] == c)
            {
                score += std::get<3>(constraint);
            }
        }
        return score;
    }
    int max = 0;
    for (int i = X; i <= M; i++)
    {
        A[pos] = i;
        max = std::max(max, calc(pos + 1, N, i, M, A, constraints));
    }
    return max;
}

int main()
{
    int N, M, Q;
    std::cin >> N >> M >> Q;
    std::vector<std::tuple<int, int, int, int>> constraints(Q);
    for (int i = 0; i < Q; i++)
    {
        std::cin >> std::get<0>(constraints[i]);
        std::cin >> std::get<1>(constraints[i]);
        std::cin >> std::get<2>(constraints[i]);
        std::cin >> std::get<3>(constraints[i]);
    }

    std::array<int, 10> A;
    std::cout << calc(0, N, 1, M, A, constraints) << std::endl;
}

Measured memory_bytes: 3636
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
p=s.count("p")
print(len(s)//2-p)

Measured memory_bytes: 77508
#include <stdio.h>
                 
                int main(){
                  int a,b;
                  if(scanf("%d",&a)==1&&scanf("%d",&b)==1){
                    int tmp;
                    int A=a+b,B=a-b,C=a*b;
                    if(A>=B&&A>=C) tmp = A;
                    if(B>=A&&B>=C) tmp = B;
                    if(C>=A&&C>=B) tmp = C;
                    printf("%d",tmp);
                  }
                  else  {
            printf("Failed to read integer.\n");
        }
                  return 0;
                  }

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main()
{
    char x[10];
    scanf("%s",&x);
    if (x[2]==x[3] && x[4]==x[5]){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1612
#include<iostream>
#include<algorithm>
using namespace std;
int main(void) {
  int a[3];
  int c=0;
  cin>>a[0]>>a[1]>>a[2];
  sort(a, a+3);
  while(a[0]!=a[1] or a[1]!=a[2]) {
    if(a[1]==a[2]) {
      a[0]+=2;
    } else {
      a[0]++;
      a[1]++;
    }
    c++;
    sort(a, a+3);
  }
  cout<<c<<endl;
  return 0;
}


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

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

int main(){
    ll n,ans=0; cin>>n;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    if(n%2==0){
        vector<ll> sum(n/2+1,0);
        ll cur=0;
        rep(i,n/2){
            sum[i+1]=sum[i]+a[2*i]-a[2*i+1];
            ans+=a[2*i+1];
            cur=max(cur,sum[i+1]);
        }
        cout<<ans+cur<<endl;
    }
    else{
        vector<ll> sum(n/2+1,0);
        ans+=a.back();
        rep(i,n/2){
            sum[i+1]=sum[i]+a[2*i+1]-a[2*i];
            ans+=a[2*i];
        }
        ll cur=-INF;
        set<ll> s;
        rep(i,n/2+1){
            s.insert(sum[i]);
            ll k=*begin(s);
            cur=max(cur,sum[i]-k-a[2*i]);
        }
        cout<<ans+cur<<endl;
    }
}


Measured memory_bytes: 10264
Q = int(input())
L, R = [], []
F = [False for _ in range(10 ** 5 + 1)]
C = [0 for _ in range(10 ** 5 + 2)]

for _ in range(Q):
	l, r = map(int, input().split())
	L.append(l)
	R.append(r)
	
for i in range(2, 10 ** 5 + 1):
	if not F[i]:
		for j in range(2 * i, 10 ** 5 + 1, i):
			F[j] = True

for i in range(3, 10 ** 5 + 1, 2):
	if F[i] == False and F[(i + 1) // 2] == False:
		C[i] += 1
		
for i in range(1, 10 ** 5 + 1):
	C[i] += C[i - 1]
	
	
for i in range(Q):
	print(C[R[i]] - C[L[i] - 1])

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

using namespace std;

typedef long long ll;

const ll inf = 1LL << 60 ;


int main(){
 ll N,W; cin >> N >> W;
  
  vector<ll> w(N,0); vector<ll> v(N,0);
 for(ll i = 0; i < N; i++){ cin >> w[i] >> v[i];}
  //重量、価値はN種類
  
  ll dp[110][100100];
  for(ll i = 0; i < 110; i++){
    for(ll j = 0; j < 100100; j++){ dp[i][j] = inf;}}
  
  dp[0][0] = 0;
  
  for(ll i = 0; i < N; i++){
    for(ll sum_v = 0; sum_v <= 100100; sum_v++){
      dp[i + 1][sum_v] = min( dp[i + 1][sum_v] , dp[i][sum_v]);
      if( sum_v >= v[i]){
        dp[i+1][ sum_v] = min( dp[i+1][sum_v] , dp[i][sum_v - v[i]] + w[i]);}}}
    
    ll res = 0;
    
    for(ll sum_v = 0; sum_v < 100100; sum_v++){
      if( dp[N][sum_v] <= W){ res = sum_v;}}
    
    cout << res << endl;
    return 0;}
                            
      

Measured memory_bytes: 86400
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		out.println((inint()+1)/2);
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

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

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public double indouble() {
		return in.nextDouble();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  char H[S.size()];

  for(int i=0; i<S.size(); ++i){
    H[i] = S[i] + N;
    if(H[i] > 90) H[i] -= 26;
    cout << H[i];
  }
return 0;
}

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

int main() {
  int K,A,B;
  cin >> K >> A >> B;

  if ( ((B-A) >= (K-1)) || (A%K > B%K) || (A%K == 0)) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
}



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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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


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

    ll n;
    cin>>n;
    ll ar[n];
    ll prefix[n];
    for(ll i=0;i<n;i++){
        cin>>ar[i];
        if(i==0)
            prefix[i]=ar[i];
        else
            prefix[i]=ar[i]+prefix[i-1];
    }

    ll ans=0;
    ll mod=1e9 + 7;


    for(ll i=0;i<n;i++){
        ll sum=prefix[n-1]-prefix[i];
        sum=sum%mod;
        ans+=(sum*ar[i]);
        ans=ans%mod;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 6776
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  vector<int> data(n, 0);
  for(int i = 0; i < n; ++i) {
    cin >> data[i];
  }
  
  vector<int> lmax(n, 0);
  vector<int> rmax(n, 0);
  for(int i = 1; i < n; ++i) {
    lmax[i] = max(lmax[i - 1], data[i - 1]);
  }
  
  for(int i = n - 2; i >= 0; --i) {
    rmax[i] = max(rmax[i + 1], data[i + 1]);
  }
  
  for(int i = 0; i < n; ++i) {
    cout << max(lmax[i], rmax[i]) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3968
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int H=nextInt();
		int W=nextInt();
		String[][] b = new String[H+2][W+2];
		Arrays.fill(b[0], ".");
		Arrays.fill(b[b.length-1], ".");
		for(int i=0;i<H;i++){
			b[i+1]=toStringArray("."+nextString()+".");
		}
		int x=1;
		int y=1;
		String ans = "Possible";
		//4方向の場合はx[i+around[n]][k+around[n+1]]n<4,8方向はn<8でループ
		int[] around = { -1, 0, 1, 0, -1, 1, 1, -1, -1 };
		while(x!=W||y!=H){
			b[y][x]=".";
//			print(b);
			boolean flg=false;
			for(int i=0;i<4;i++){
				if("#".equals(b[y+around[i+1]][x+around[i]])){
					if(i==0||i==3){
						System.out.println("Impossible");
						return;
					}
					if(flg==false){
						y=y+around[i+1];
						x=x+around[i];
						flg=true;
					}
				}
			}
			if(!flg){
				ans="Impossible";
				break;
			}
		}
		b[H][W]=".";
		for(int i=0;i<b.length;i++){
			for(int k=0;k<b[i].length;k++){
				if("#".equals(b[i][k])){
					ans="Impossible";
				}
			}
		}

		System.out.println(ans);

	}

	public static void print(String[][] s){
		for(int i=0;i<s.length;i++){
			for(int k=0;k<s[i].length;k++){
				System.out.print(s[i][k]);
			}
			System.out.println();
		}
		System.out.println();
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 21076
import sys; input = sys.stdin.readline

s = int(input())
mod = int(1e9)+7
dp = [0]*(s+1)
dp[0] = 1
for i in range(3, s+1):
	for j in range(3, s+1):
		if i>=j: dp[i] = (dp[i] + dp[i-j])%mod
print(dp[s])

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

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 100000000000;

int r, g, b;

int main() {
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4 == 0) { print("YES"); }
	else { print("NO"); }
	return 0;
}

Measured memory_bytes: 256
alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

s=input()
for i in range(1,len(s)):
    if s[i]!=s[0]:
        break
else:
    print(0)
    exit()

ans=100
for moji in alphabetlist:
    count=0
    test=s
    while test:
        new=""
        flag=True
        for i in range(0,len(test)-1):
            if test[i]!=moji and test[i+1]!=moji:
                new+=test[i]
                flag=False
            else:
                new+=moji
        count+=1
        test=new
        if flag:
            break
    ans=min(ans,count)

print(ans)


Measured memory_bytes: 3064
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>

using namespace std;

const int N = 2e5 + 5;
const int lg = 20;
vector<int> red[N];
vector<int> blue[N];
int h[N];
int par[lg + 5][N];
int n, x, y;
bool winPos[N];
int disR[N];
int disB[N];


void dfs(int v = 0, int p = -1)
{
    for (int u : blue[v])
    {
        if (u != p)
        {
            par[0][u] = v;
            h[u] = h[v] + 1;
            dfs(u, v);
        }
    }
}

void pre()
{
    for (int k = 1; k < lg; k++)
    {
        for (int i = 0; i < n; i++)
        {
            par[k][i] = par[k - 1][ par[k - 1][i] ];
        }
    }
}

int lca(int v, int u)
{
    if(h[v] > h[u])
    {
        swap(v, u);
    }
    for (int i = 0; i < lg; i++)
    {
        if (h[u] - h[v] >> i & 1)
        {
            u = par[i][u];
        }
    }
    for (int i = lg - 1; i >= 0; i--)
    {
        if(par[i][v] != par[i][u])
        {
            v = par[i][v], u = par[i][u];
        }
    }
    return v == u ? v : par[0][v];
}

void dfs1(int v, int par = -1)
{
    if (disR[v] >= disB[v])
    {
        return;
    }
    for (auto u: red[v])
    {
        if (u != par)
        {
            disR[u] = disR[v] + 1;
            dfs1(u, v);
        }
    }
}

void dfs2(int v, int par = -1)
{
    for (auto u: blue[v])
    {
        if (u != par)
        {
            disB[u] = disB[v] + 1;
            dfs2(u, v);
        }
    }
}



int main()
{
    cin >> n >> x >> y;
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        red[u - 1].push_back(v - 1);
        red[v - 1].push_back(u - 1);
    }
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        blue[u - 1].push_back(v - 1);
        blue[v - 1].push_back(u - 1);
    }
    dfs();
    pre();
    for (int i = 0; i < n; i++)
    {
        for (auto u: red[i])
        {
            int tmp = lca(u, i);
            if (h[u] - h[tmp] + h[i] - h[tmp] > 2)
            {
                winPos[i] = true;
                winPos[u] = true;
            }
        }
    }
    memset(disR, 127, sizeof disR);
    disR[x - 1] = 0;
    dfs2(y - 1);
    dfs1(x - 1);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (winPos[i] && disR[i] < disB[i])
        {
            cout << -1 << endl;
            exit(0);
        }
        if (disR[i] < N)
        {
            //cout << endl;
            //cout << i << " " << disB[i] << endl;
            ans = max(ans, disB[i] * 2);
        }
    }
    //cout << (1 << 20) << endl;
    cout << ans << endl;






}


Measured memory_bytes: 55368
function Main(input) {
    const split = input.split(' ');
    const count = +split[0];
    const rate = +split[1];
    console.log(Math.max(rate + 100 * Math.max(10 - count, 0), 0));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int cnt1=0,cnt2=0,cnt3=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]<=a)
            cnt1++;
        if(a<arr[i] && arr[i]<=b)
            cnt2++;
        if(arr[i]>=b+1)
            cnt3++;
    }
    cout<<min(cnt1,min(cnt2,cnt3))<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>	

using namespace std;

int main(){
	string s, p;
	cin >> s >> p;
	s = s + s;
	if (s.find(p) != - 1) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3208
#include <algorithm>　　　 //STL通用算法
#include <bitset>　　　　　//STL位集容器
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>　　　　 //复数类
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>　　　　　 //STL双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream>
#include <functional>　　　//STL定义运算函数（代替运算符）
#include <limits>
#include <list>　　　　　　//STL线性列表容器
#include <map>　　　　　　 //STL 映射容器
#include <iomanip>
#include <ios>　　　　　　//基本输入／输出支持
#include<iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream>
#include <istream>　　　　 //基本输入流
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　//基于字符串的流
#include <stack>　　　　　 //STL堆栈容器　　　　
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　//底层输入／输出支持
#include <string>　　　　　//字符串类
#include <utility>　　　　 //STL通用模板类
#include <vector>　　　　　//STL动态数组容器
#include <cwchar>
#include <cwctype>

using namespace std;

const int N = 1e5+5;
int T,m,n,l,x;
int c[15],a[15][15];
int ability[15];
int read()
{
	int x=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
	   if(ch=='-')  w=-1;
	   ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	return x*w;
}

int main()
{
    n=read();
	m=read();
	x=read();
	for(int i=1;i<=n;i++)
	{
		c[i]=read();
		for(int j=1;j<=m;j++)
			a[i][j]=read();
	}
	int ans=0x7ffffff;
	for(int i=0;i<1<<n;i++)
	{
		int num=0;
		memset(ability,0,sizeof(ability));
		for(int j=0;j<n;j++)
		{
			if(i>>j & 1)
			{
				num+=c[j+1];
				for(int k=1;k<=m;k++)
				{
					ability[k]+=a[j+1][k];
				}
			}
		}
		bool flag=true;
		for(int j=1;j<=m;j++)
		{
			if(ability[j]<x)	
			{
				flag=false;
				break;
			}
		}
		if(flag)
		{
			ans=min(ans,num);
		}
	}
	printf("%d\n", ans == 0x7ffffff ? -1 : ans);
    return 0;
}

Measured memory_bytes: 3764
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {    
        h: usize, w: usize,
        a: [Chars; h]
    }

    let mut map = HashMap::new();
    for s in a {
        for c in s {
            *map.entry(c).or_insert(0) += 1;
        }
    }

    let need_fours = (h/2) * (w/2);
    let mut fours = 0;
    let mut ones = 0;
    for &v in map.values() {
        fours += v / 4;
        ones += v % 2;
    }
    let ans = if need_fours > fours {
        false
    } else if h % 2 == 1 && w % 2 == 1 {
        ones == 1
    } else {
        ones == 0
    };
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2220
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n; cin >> n;
	string S; cin >> S;

	int cnt = 0;

	for (int i = 0; i < n; ++i) {
		string si; cin >> si;
		int len = si.length();

		for (int j = 0; j < len; ++j) {
			if (si[j] == S[0]) {
				for (int k = 1; k < len; ++k) {
					for (int l = 1; l < len; ++l) {
						if (j + k*l >= len) break;
						if (si[j+k*l] != S[l]) break;
						if (l == S.length() - 1) {
							cnt++;
							goto next;
						}
					}
				}
			}
		}
		next:;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 1208
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const long long oo=1e9;
int main(){
	long long n;scanf("%lld",&n);
	long long x1=oo,y2=(n+oo-1)/oo,x2=1,y1=x1*y2-n;
	printf("0 0 %lld %lld %lld %lld\n",x1,y1,x2,y2);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;
int main(void){
    // Your code here!
    int s,t,u;
    cin>>s>>t;
    if(s%3==0||t%3==0||(s+t)%3==0){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x[102];
int main(){
	int n=0,m=0;
	int max=0,min=100;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x[i]);
		if(x[i]<=min)min=x[i];
		if(x[i]>=max)max=x[i];
	}
	int s=1e8,d=0;
	for(int i=min;i<=max;i++){
		d=0;
		for(int j=1;j<=n;j++){
			d+=(x[j]-i)*(x[j]-i);
		}
		if(d<s)s=d;
	}
	printf("%d",s);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
		int a, b, c;
	    scanf("%d%d%d", &a, &b, &c);
	    if(a == 5 && b == 5 && c == 7){printf("YES\n");}
	    else if(a == 7 && b == 5 && c == 5){printf("YES\n");}
	    else if(a == 5 && b == 7 && c == 5){printf("YES\n");}
	    else{ printf("NO\n");}
	    return 0;
		}


Measured memory_bytes: 128
/*
 _____ ____ _____   ___   ___   ___   ___ 
|_   _/ __ \_   _| |__ \ / _ \ |__ \ / _ \
  | || |  | || |      ) | | | |   ) | | | |
  | || |  | || |     / /| | | |  / /| | | |
 _| || |__| || |_   / /_| |_| | / /_| |_| |
|_____\____/_____| |____|\___/ |____|\___/ 
*/
#include <bits/stdc++.h>
#include <fstream>
//#include "ele.h"
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
// assert(x==y); gives run time when false
using namespace std;
int main()
{
    CIN;
    int n,m;
    cin >> n >> m;
    if(m<n){
        swap(n,m);
    }
    rep(i,0,m)cout << n;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long S){
	string str = to_string(S);
  int n = str.length();
  ll ans = 0;

  FOR(mask,0,(1<<(n-1))){
    string buf = "";buf += str[0];

    FOR(k,1,n){
      if(mask & (1 << (k-1))){
        ans += stol(buf.c_str());
        buf = "";
      }
      buf += str[k];

    }

    ans += stol(buf.c_str());
  }

  cout << ans << endl; 
}



int main(){
	ios::sync_with_stdio(false);
	long long S;
	cin >> S;
	solve(S);
	return 0;
}


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

typedef long long ll;

int N;
vector<int> G[50010];
int sub[50010];
ll F[50010] = {1};
ll R[50010];
ll mod = 1000000007;
ll dp[5010][5010];

int sub_size(int v,int p)
{
    int res = 1;
    for(int i = 0; i < G[v].size(); i++)if(p != G[v][i])res += sub_size(G[v][i],v);
    return sub[v] = res;
}

ll con(int a,int b)
{
    return F[a] * R[a - b] % mod * R[b] % mod;
}

ll pow_mod(ll a,ll b)
{
    if(b == 0)return 1;
    ll res = pow_mod(a * a % mod, b / 2);
    if(b & 1)res = res * a % mod;
    return res;
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N - 1; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for(int i = 1; i < 5010; i++)F[i] = F[i - 1] * i % mod;
    for(int i = 0; i < 5010; i++)R[i] = pow_mod(F[i],mod - 2);

    for(int i = 1; i <= N; i++)
    {
        for(int j = 0; j < G[i].size(); j++)
        {
            if(sub_size(i,G[i][j]) == sub_size(G[i][j],i))
            {
                printf("%lld\n",F[N / 2] * F[N / 2] % mod);
                return 0;
            }
        }
    }

    int c = 0,MIN = 1001001001;
    for(int i = 1; i <= N; i++)
    {
        int MAX = 0;
        for(int j = 0; j < G[i].size(); j++)MAX = max(MAX,sub_size(G[i][j],i));
        if(MIN > MAX)
        {
            c = i;
            MIN = MAX;
        }
    }

    dp[0][0] = 1;
    for(int i = 0; i < G[c].size(); i++)
    {
        for(int j = 0; j <= N; j++)
        {
            if(dp[i][j] == 0)continue;
            int m = sub_size(G[c][i],c);
            for(int k = 0; k <= m; k++)
            {
                if(j + k > N)continue;
                dp[i + 1][j + k] += dp[i][j] * con(m,k) % mod * con(m,k) % mod * F[k] % mod;
                dp[i + 1][j + k] %= mod;
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i <= N; i++)
    {
        ll tmp = dp[G[c].size()][i] * F[N - i] % mod;
        if(i % 2)ans -= tmp;
        else ans += tmp;
        ans = (ans + mod) % mod;
    }

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


Measured memory_bytes: 196352
loop do
  n = gets.chomp.to_i
  row_count = gets.chomp.to_i

  break if n == 0 && row_count == 0

  pairs = row_count.times.map { gets.chomp.split(' ').map(&:to_i) }

  f = pairs.select { |pair| pair[0] == 1 }.map(&:last)
  foaf = pairs.select { |pair|
      f.include?(pair[0]) || f.include?(pair[1])
    }.flatten

  puts (f | foaf).uniq.delete_if { |i| i == 1 }.size
end

Measured memory_bytes: 8784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int n, l, r, ans = 0;
  cin >> n;
  rep(i, n)
  {
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}

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

typedef long long ll;

int n;
ll t;

ll a[200010];

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

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

	ll res = 0;

	for(int i = 1;i < n;i++)
	{
		ll dis = a[i] - a[i - 1];

		res += min(dis , t);
	}

	res += t;

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int a[305][305],f[305];
bool v[305];
int main()
{
    int n,m,ans=INT_MAX,i,j,k,fmax,vmax;
    cin>>n>>m;
    for(i=1;i<=m;i++)
        v[i]=1;
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            cin>>a[i][j];
    for(k=0;k<m;k++)
    {
        fmax=vmax=0;
        for(i=1;i<=n;i++)
            for(j=1;j<=m;j++)
                if(v[a[i][j]])
                {
                    f[a[i][j]]++;
                    if(f[a[i][j]]>fmax)
                    {
                        fmax=f[a[i][j]];
                        vmax=a[i][j];
                    }
                    break;
                }
        memset(f,0,sizeof f);
        ans=min(ans,fmax);
        v[vmax]=0;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 640
n=int(input())-1
l=[[] for _ in range(10)]
l[0].append('a')
for i in range(n):
  for w in l[i]:
    s = sorted(set(w))
    for c in s:
      l[i+1].append(w+c)
    l[i+1].append(w+chr(ord(s[-1])+1))  
print(*l[n],sep='\n')

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

int main(){
    int n,x,ans=0,a[105]={};
    cin>>n;
    while(n--){
        cin>>x;
        if(!a[x]){
            ans++;
            a[x]=1;
        }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m, p;
    cin >> n >> m >> p;
    int a, b;
    ll c;
    vector<vector<pair<int, ll>>> edge(n);
    FOR(i, 0, m) {
        cin >> a >> b >> c;
        edge[--a].push_back(make_pair(--b, c - p));
    }

    vector<ll> ans(n, -LLINF);
    ans[0] = 0;
    bool neg = false;
    FOR(i, 0, n * 2) {
        FOR(j, 0, n) {
            for (auto next : edge[j]) {
                a = j;
                tie(b, c) = next;
                if (chmax(ans[b], ans[a] + c)) {
                    if (i >= n && b == n - 1)neg = true;
                }
            }
        }
    }

    cout << (neg ? -1 : max(ans[n - 1], 0LL)) << "\n";
}


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

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

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

ll ans = 1;
ll n,k;

int main(){
  cin >> n >> k;
  REP(i,n){
    if(i==0) ans *= k;
    else ans *= k-1;
  }
  cout << ans << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int cnt = a - 1;
  if(b >= a) cnt = a;
  
  cout << cnt << endl;
}

Measured memory_bytes: 3588
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class COtoshidama {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n,y;
	    in>>n>>y;

	    for(int i=0; i<=n; ++i){
	        for(int j=0; i+j<=n; ++j){
	            if(i*10000+j*5000+(n-i-j)*1000==y){
	                printf("%d %d %d\n",i,j,(n-i-j));
                    return;
	            }
	        }
	    }
	    printf("%d %d %d\n",-1,-1,-1);

	}
};


int main() {
	COtoshidama solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

struct Team{
	string name;
	int n,s;
	bool operator <(const Team t)const{
		if(s==t.s) return n<t.n;
		return s>t.s;
	}
};

int main(){
	Team T[10];
	int N,W,L,D;
	for(int ds=0; cin>>N,N; ds++){
		if(ds!=0) puts("");
		for(int i=0;i<N;i++){
			cin>>T[i].name>>W>>L>>D;
			T[i].n = i; T[i].s = W*3+D;
		}
		sort(T,T+N);
		for(int i=0;i<N;i++){
			cout<<T[i].name;
			printf(",%d\n",T[i].s);
		}
	}
}

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

int INF = 1001001001;


int main() {
    int h, a;
    cin >> h >> a;
    cout << (h+a-1) / a << endl;

    return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll a, b, c, d,LCM,GCD,count;
  cin >> a >> b >> c >> d;
  ll e[2] = {c,d};
  while(e[0] && e[1])
  {
      if(e[0] >= e[1]) e[0] %= e[1];
      else e[1] %= e[0];
  }
  GCD = e[0] + e[1];
  LCM = c * d/GCD;
  count = b-a+1-(b/c + b/d - b/LCM)+(a/c + a/d - a/LCM);
  if(a%c == 0 || a%d == 0) count--;
  cout << count << endl;
  return 0;
}


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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
ld eps=1e-9;
#define Seg_Max_N (1<<18) 

int ans=0;
int need;
int dfs(long long int num, int k,vector<int>&oks) {
	vector<int>v{ 3,5,7 };
	if(num<=need&&oks[0]&&oks[1]&&oks[2])ans++;
	if(num>=1e9)return 0;
	for (int i = 0; i < 3; ++i) {
		oks[i]++;
		dfs(num*10+v[i],k,oks);
		oks[i]--;
	}
	return 0;
}


vector<int>primes;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}
map<long long int, int>soinnsuu(long long int a) {
	hurui(1000);
	map<long long int, int>ans;
	for (auto i : primes) {
		if (i> a)break;
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}
int main() {

	int N;cin>>N;
	map<int,int>mp;
	for (int i = 1; i <= N; ++i) {
		auto m=soinnsuu(i);
	for(auto a:m){
			mp[a.first]+=a.second;
		}
	}
	vector<vector<long long int>>dp(mp.size()+1,vector<long long int>(76));
	int x=0;
	dp[0][1]=1;
	for (auto m : mp) {
		for (int i = 0; i <= 75; ++i) {
			for (int j = 1; j <= 75; ++j) {
				if (j - 1 <= m.second) {
					int k=i*j;
					if(k<=75)dp[x+1][k]+=dp[x][i];
				}
			}
		}
		x++;
	}
	cout<<dp[mp.size()][75]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <list>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <string>
#define N 100005
#define INF (1 << 30)
typedef long long ll;
using namespace std;

vector<int> child[N];
int parent[N];
int GetDepth(int idx)
{
	int ret = 0;
	while (parent[idx] != -1)
	{
		++ret;
		idx = parent[idx];
	}
	return ret;
}
const char *str[3] = { "root", "internal node", "leaf" };
int main()
{
	int n;
	cin >> n;
	fill(parent, parent + n, -1);
	int id, k, c;
	for (int i = 0; i < n; ++i)
	{
		cin >> id >> k;
		for (int j = 0; j < k; ++j)
		{
			cin >> c;
			parent[c] = id;
			child[id].push_back(c);
		}
	}
	for (int i = 0; i < n; ++i)
	{
		int depth = GetDepth(i);
		int status;
		if (depth == 0)
			status = 0;
		else if (child[i].size())
		{
			status = 1;
			sort(child[i].begin(), child[i].end());
		}
		else
			status = 2;
		printf("node %d: parent = %d, depth = %d, %s, ", i, parent[i], depth, str[status]);
		printf("[");
		for (int j = 0; j < child[i].size(); ++j)
		{
			if (j)
				printf(", ");
			printf("%d", child[i][j]);
		}
		printf("]\n");
	}
	return 0;
}

Measured memory_bytes: 6732
def main():
    N, M = map(int, input().split())
    ans = [0] * (N+1)
    for _ in range(M):
        a, b = map(int, input().split())
        ans[a] += 1
        ans[b] += 1
    for i in range(1, N+1):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
#include<stdio.h>
#include<stdlib.h>
#define MAX 101
#define INF 1000000

void initializeSingleSource();
void dijkstra();

int i,j,n,w,U,u[MAX],k[MAX],result=0,mincost,pi[MAX],color[MAX],d[MAX],c[MAX][MAX],v[MAX][MAX];

int main(){
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d %d",&u[i],&k[i]);
    for(j=0 ; j<k[i] ; j++){
      scanf("%d %d",&v[i][j],&c[i][j]);
    }
  }

  dijkstra();

  for(i=0 ; i<n ; i++){
    printf("%d %d\n",u[i],d[i]);
  }
  return 0;
}


void initializeSingleSource(){
  for(i=0 ; i<n ; i++){
    d[i]=INF;
    color[i]=0;
   
  }
  d[0]=0;
}
void dijkstra(){
  initializeSingleSource();
  while(1){
    mincost=INF;
    for(i=0 ; i<n ; i++){
      if(color[i] != 1 && d[i] < mincost){
	mincost=d[i];
	U=i;
      }
    }
      if(mincost == INF)break;
      color[U]=1;

      for(w=0 ; w<k[U] ; w++){
	if(color[v[U][w]] != 1 && (d[U]+c[U][w]) < d[v[U][w]]){
	
	  d[v[U][w]]=d[U]+c[U][w];
	  }
      }
  }
}
	  

	       	  
 

Measured memory_bytes: 676
#include <stdio.h>

int main(){
  int S;
  scanf("%d",&S);
  
  int sen,hyaku,ju,ichi;
  ichi = S%10;
  ju = (S/10)%10;
  hyaku = (S/100)%10;
  sen = S/1000;
  
  if(ichi == ju || ju == hyaku || hyaku == sen){
    printf("Bad");
  }else{
    printf("Good");
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 3e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll arr[N], poww[N];

ll mul(ll a, ll b) {
  return (a * b) % MOD;
}

ll add(ll a, ll b) {
  a += b;
  while(a > MOD)
    a -= MOD;
  while(a < 0)
    a += MOD;
  return a;
}

ll power(ll a, ll b) {
  ll ret = 1;
  while(b) {
    if(b & 1)
      ret = mul(ret, a);
    b /= 2;
    a = mul(a, a);
  }
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  ll S = power(2, n - 2), factor = power(2, n);
  poww[n - 1] = power(2, n - 1);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    if(i)
      poww[n - i - 1] = add(poww[n - i], S);
  }
  sort(arr, arr + n);
  ll total = 0;
  for (int i = 0; i < n; ++i) {
    ll cur = mul(poww[i], arr[i]);
    total = add(total , cur);
  }
  total = mul(total, factor);
  cout << total;
}


Measured memory_bytes: 3840
import math

n,d = map(int,input().split())
loc = [list(map(int,input().split())) for _ in range(n)]
dis = []
ans = 0
for i in range(n):
  for j in range(i+1,n):
    dis_k = 0
    for k in range(d):
      dis_k += (loc[i][k]-loc[j][k])**2
    dis.append(dis_k)
    
for d in dis:
  for i in range(1,math.ceil(math.sqrt(d))+1):
    if i**2 ==d:
      ans += 1
      break
    else:
      pass
    
print(ans)
     




Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

using namespace std;

typedef long long li;
typedef unsigned long long lu;
const li infl = ~0LLU >> 2;

template <class T>
inline void Min(T &x, T y) {
  if (y < x) x = y;
}
template <class T>
inline void Max(T &x, T y) {
  if (y > x) x = y;
}

const int mod = 998244353;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}
int Inv(int x) {
  return Pow(x, mod - 2);
}

// ----------------------------------------

const int maxn = 5e5;
int n, m;
int fact[maxn + 1], ifact[maxn + 1];
int down[maxn + 1];

void Init(void) {
  fact[0] = 1;
  for (int i = 1; i <= m; ++i) {
    fact[i] = Mul(fact[i - 1], i);
  }
  ifact[m] = Pow(fact[m], mod - 2);
  for (int i = m; i >= 1; --i) {
    ifact[i - 1] = Mul(ifact[i], i);
  }
  down[0] = 1;
  for (int i = 1; i <= m; ++i) {
    down[i] = Mul(down[i - 1], n - i + 1);
  }
}

int Binom(int n, int m) {
  return Mul(fact[n], ifact[m], ifact[n - m]);
}

int Sgn(int k) {
  return k & 1 ? mod - 1 : 1;
}

int main(void) {
  scanf("%d%d", &n, &m);
  if (n < m) swap(n, m);
  Init();
  int ans = 0;
  for (int k = 0; k <= m; ++k) {
    Add(ans, Mul(Mul(Binom(m, k), Sgn(k), down[k]),
                 Mul(Pow(n + 1, m - k), Pow(m + 1, n - k))));
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
int n,k;
llint a,b,sol;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		if(i%k==0){
			a++;
		}
		else if(i%k==k/2){
			b++;
		}
	}
	sol=a*a*a;
	if(k%2==0){
		sol+=b*b*b;
	}
	cout<<sol;
	return 0;
}

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

int n;
string s;

int main()
{
    cin >> s;
    int flag = 1;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '7')flag = 0;
    }
    if(flag) puts("No");
    else puts("Yes");

    return 0;
}

Measured memory_bytes: 3624
while 1:
    try:
        tmplist = list(map(int, input().split(",")))
    except:
        break

    lengthlist = tmplist[:10]
    v1 = tmplist[10]
    v2 = tmplist[11]

    lsum = sum(lengthlist)
    time = lsum / (v1 + v2)
    spot = time * v1

    le = 0
    for i, l in enumerate(lengthlist):
        le += l
        if le >= spot:
            print(i+1)
            break



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

int main(){
  int h1,w1,h2,w2;
  cin >> h1 >> w1 >> h2 >> w2;
  cout << (h1-h2)*(w1-w2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//バブルソート
//配列の要素を順番に出力
void trace(int A[],int N){
    int i;
    for(i = 0; i < N;i++){
        if(i > 0)printf(" ");//隣の要素の間に一つの空白を出力
        printf("%d",A[i]);
    }
    printf("\n");
}

void bubbleSort(int A[], int N){
    int i , j, t;
    int bubble_count = 0;

    for(i = 0;i < N-1;i++){
        for(j = N-1; i < j;j--){
            if(A[j] < A[j - 1]){
                t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
                bubble_count++;
            }
        }
    }
    trace(A, N);
    printf("%d\n", bubble_count);
}
int main(){
    int N, i;
    int A[100];

    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&A[i]);
    }
    bubbleSort(A,N);
    return 0;
}


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

using namespace std;

#define ll long long
int N, K;

const ll mod = (ll)(1e9+7);
int main()
{
	cin>>N>>K;
	ll ans = 1;
	for(int n = K; n <= N; ++n)
	{
			int M = (n + 1);
			ans += (ll)(K + M - 1) * (ll)(M - K) / 2;
			ans += 1;
			ans %= mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636