akhauriyash/Code-Regression huggingface dataset:
using System;
class Program
{
  static void Main(string[] args)
  {
    // スペース区切りの整数の入力
    string[] input = Console.ReadLine().Split(' ');
    int _A = int.Parse(input[0]);
    int _B = int.Parse(input[1]);
    int _C = int.Parse(input[2]);
    
    if (_A+_B>=_C){  
      Console.WriteLine("Yes");
      }else{  
        Console.WriteLine("No");
      }
  }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cmath>

using namespace std;

bool is_orth(double xa, double ya, double xb, double yb, double xc, double yc, double xd, double yd) {

    double inner_product = (xa-xb)*(xc-xd) + (ya-yb)*(yc-yd);
    return fabs(inner_product) < 1e-10;
}

int main() {
    double xa, ya, xb, yb, xc, yc, xd, yd;
    string result;
    while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
        if(is_orth(xa, ya, xb, yb, xc, yc, xd, yd)) {
            result = "YES";
        } else {
            result = "NO";
        }
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
const int N=1e5+7;
int n,m,pv[4]={0,3,1,2},nx[4]={0,2,3,1},t[4],cn,cm,sl;
std::vector<int>e[N],er[N];
int col[N];
long long ans=0;
void dfs(int w,int c){
	if(col[w]){
		if(col[w]!=c)sl=1;
		return;
	}
	++cn;
	++t[col[w]=c];
	cm+=e[w].size();
	for(int i=0;i<e[w].size();++i)dfs(e[w][i],nx[c]);
	for(int i=0;i<er[w].size();++i)dfs(er[w][i],pv[c]);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,a,b;i<=m;++i){
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		er[b].push_back(a);
	}
	for(int i=1;i<=n;++i)if(!col[i]){
		t[1]=t[2]=t[3]=0;
		cn=cm=sl=0;
		dfs(i,1);
		if(sl)ans+=1ll*cn*cn;
		else if(t[1]&&t[2]&&t[3])ans+=1ll*t[1]*t[2]+1ll*t[2]*t[3]+1ll*t[3]*t[1];
		else ans+=cm;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 16256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

struct Union_Find {
  vector<int> data;
  Union_Find(int size) { data = vector<int>(size, -1); }
  bool union_set(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  GI2(N, M);
  Union_Find uf(N);
  FOR(i, M) {
    GI3(X, Y, Z);
    uf.union_set(X - 1, Y - 1);
  }
  int cnt = 0;
  FOR(i, N) {
    if (uf.data[i] < 0)
      cnt++;
  }
  print(cnt);
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,q;
int a[1000000];
int ans[1000000];
int main()
{
cin>>n>>q;
a[1]=1;
for(int i=1;i<n;i++)
  {
  	int x,y;
  	cin>>x>>y;
  	a[y]=x;
  	ans[i]=0;
  }
for(int i=1;i<=q;i++)
  {
  	int x,y;
  	cin>>x>>y;
  	ans[x]+=y;
  }
for(int i=2;i<=n;i++)ans[i]+=ans[a[i]];
for(int i=1;i<=n;i++)cout<<ans[i]<<" ";
return 0;
}

Measured memory_bytes: 7296
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
	ll n;
	cin >> n;
	ll x = 100;
	ll count = 0;
	while(x < n){
		ll per = x/100;
		x += per;
		count++;
	}
	cout << count << endl;
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}	


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

int main()
{
	int n,k;
	cin >> n >>k;
	
	int dp[n];
	int height[n];

	for(int i=0;i<n;i++)		cin >>height[i];

		dp[0]=0;
		dp[1]=abs(height[1]-height[0]);
	
	for(int i=2;i<n;i++)
	{
		dp[i]=dp[i-1]+abs(height[i]-height[i-1]);
		int j=1;
		while(j<=k and i>=j)
		{
			dp[i]=min(dp[i-j]+abs(height[i]-height[i-j]),dp[i]);
			j++;
		}
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 4428
#include <iostream>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

ll euclid(ll a, ll b)
{
    int nr = 0;
    while (b != 0)
    {
        int c = b;
        b = a % b;
        a = c;
        nr++;
    }
    return nr;

}
int main()
{
    int n, m;
    cin >> n >> m;
    map<int, int> mapa;
    for (int i = 0; i < m; i++)
    {
        mapa[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        int nr;
        cin >> nr;
        for (int i = 0; i < nr; i++)
        {
            int x;
            cin >> x;
            mapa[x]++;
        }
    }
    int nr2 = 0;
    for (auto& x : mapa)
    {
        if (x.second == n)
        {
            nr2++;
        }
    }
    cout << nr2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
signed main() {
    int H,W;
    cin >> H >> W;
    int ans = INF;
    for(int i = 1; i < H; i++) {
        int cnt = i*W;
        int X = (H-i)/2*W;
        int Y = ((H-i)-(H-i)/2)*W;
        int A = (H-i)*(W/2);
        int B = (H-i)*(W-W/2);
        ans = min(ans,max(max(cnt,X),Y)-min(min(cnt,X),Y));
        ans = min(ans,max(max(cnt,A),B)-min(min(cnt,A),B));
    }
    for(int i = 1; i < W; i++) {
        int cnt = i*H;
        int X = (W-i)/2*H;
        int Y = ((W-i)-(W-i)/2)*H;
        int A = (W-i)*(H/2);
        int B = (W-i)*(H-H/2);
        ans = min(ans,max(max(cnt,X),Y)-min(min(cnt,X),Y));
        ans = min(ans,max(max(cnt,A),B)-min(min(cnt,A),B));
    }
    cout << ans << endl;
}

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

int main(){

  int n;
  cin >> n;
  long long minmap[300][300];
  long long map[300][300];
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      scanf("%lld", &minmap[i][j]);
      map[i][j] = 1e9;
    }
  }

  for (int k = 0; k < n; k++){
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        if (i == j) {
          map[i][j] = 0;
        }
        if (k == i || k == j) continue;
        if (minmap[i][k] + minmap[k][j] < minmap[i][j]){
          printf("-1\n");
          return 0;
        }
        if (minmap[i][k] + minmap[k][j] == minmap[i][j]){
          map[i][j] = -1;
        }
      }
    }
  }

  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (map[i][j] != -1) {
        map[i][j] = min(map[i][j], minmap[i][j]);
      }
    }
  }

  long long ans = 0;

  for (int i = 0; i < n; i++){
    for (int j = i; j < n; j++){
      if (map[i][j] != -1) {
        ans += map[i][j];
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  
#include <numeric>
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define endl '\n'
using ll = long long;
 
const int precision = 3;
const int modulo =  1000000007; // 10^9 + 7
const ll lmodulo =  1000000007; // 10^9 + 7
 
const double EPS = 1e-9;
const ll inf = 1e18;
 
// void solve() {
// 	int n; cin >> n;
// 	vector<int> h(n), c(n);

// 	for (auto &it : h) cin >> it;

// 	for (auto i = 1; i < h.size(); ++i) {
// 		c[i] = abs(h[i] - h[i - 1]) + c[i - 1];
// 		if (i >= 2) {
// 			c[i] = min(c[i], abs(h[i] - h[i - 2]) + c[i - 2]);
// 		}
// 	}
// 	cout << c[n - 1];
// }

void solve() {
	int n; cin >> n;
	vector<int> h(3);
	vector<int> dp(3);

	cin >> h[0];
	for(auto i = 1; i < n; ++i) {
		auto cur = i % 3;
		auto p1 = (i - 1) % 3;
		auto p2 = (i - 2) % 3;

		cin >> h[cur];

		dp[cur] = abs(h[p1] - h[cur]) + dp[p1];
		if(i >= 2) {
			dp[cur] = min(dp[cur], abs(h[p2] - h[cur]) + dp[p2]);
		}
	}

	cout << dp[(n  - 1) % 3];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(precision);
  cout.setf(ios_base::fixed);
  solve();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

//1からsentenceまでの内で、含まれている0以外の数がcontain_minからcontain_maxまでを計測する
int DigitDP(string sentence, int contain_min, int contain_max)
{
	int len = sentence.size();
	vector<vector<vector<int>>> dp(len + 1, vector<vector<int>>(2, vector<int>(contain_max + 1, 0)));
	vector<int> digit(len);

	for (int i = 0; i < len; i++)
	{
		digit[i] = sentence[i] - '0';
	}
	dp[0][0][0] = 1;
	for (int i = 0; i < len; i++)
	{
		dp[i + 1][0][0] = (digit[i] == 0 ? dp[i][0][0] : 0);
		dp[i + 1][1][0] = dp[i][0][0] + dp[i][1][0];
		for (int j = 0; j < contain_max; j++)
		{
			dp[i + 1][0][j + 1] = (digit[i] != 0 ? dp[i][0][j] : dp[i][0][j + 1]);
			dp[i + 1][1][j + 1] = dp[i][1][j + 1] + (digit[i] != 0 ? dp[i][0][j] * (digit[i] - 1) + dp[i][0][j + 1] : 0) + dp[i][1][j] * 9;
		}
	}
	int re = 0;
	for (int i = contain_min; i <= contain_max; i++)
	{
		re += dp[len][0][i] + dp[len][1][i];
	}
	return re;
}

void execute()
{
	string N;
	int K;
	cin >> N;
	cin >> K;

	cout << DigitDP(N, K, K) << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
int main(){

    vector<int>a;
    while (1){
        int num;
        double weight,height;
        char c;
        cin >> num >> c >> weight >> c >> height;
        if(cin.eof()) break;
        double bmi;
        bmi = weight/(height*height);
        if(bmi>=25){
		a.push_back(num);
	}
     }
     if(a.size()==0) {cout<<"該当なし"<<endl;
     }else {
	  for(int i=0;i<a.size();i++){
		cout<<a[i]<<endl;
	   }
     }
}

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

int main(){
int n;
int count=0;
cin>>n;
rep(i,n){
string s=to_string(i);
if(s.size()%2==1)count++;
}
cout<<count;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

void solve(){
    int n;cin >> n;
    vector<int>a(n);
    for(int i = 0;i<n;i++) cin >> a[i];
    int ans = 0;
    for(int i = 0;i<n;i++){
        if(a[i]%2&&i%2==0) ans++;
    }
    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

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

    int n;
    cin >> n;

    vector<int> s(n);
    REP(i, n) cin >> s[i];

    vector<vector<bool> > dp(n + 1, vector<bool>(10001, false));

    dp[0][0] = true;
    REP(i, n) {
        REP(j, 10001) {
            if (dp[i][j]) {
                dp[i + 1][j] = true;
                dp[i + 1][j + s[i]] = true;
            }
        }
    }

    int ans = 0;
    REP(i, 10001)
        if (i % 10 && dp[n][i])
            ans = max(ans, i);

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


Measured memory_bytes: 384
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N, D = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for xy in XY:
    x, y = xy
    if x**2 + y**2 <= D**2:
        cnt += 1
print(cnt)

Measured memory_bytes: 101184
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    println!("{}", if a * b % 2 == 0 { "Even" } else { "Odd" });
}


Measured memory_bytes: 4352
def isPrime(x):
    ans = True

    for i in range(2, int(x**0.5)+1):
        if x%i == 0:
            ans = False
            break

    return ans

q = int(input())

queries = []
rMax = 1

for i in range(q):
    l, r = list(map(int, input().split()))

    queries.append((l, r))
    rMax = max(rMax, r)

cnt = [0] * (rMax+1)

for i in range(2, (rMax+1)//2+1):
    cnt[(2*i)-2] = cnt[(2*i)-3]

    if isPrime(i) and isPrime((2*i)-1):
        cnt[(2*i)-1] = cnt[(2*i)-2]+1
    else:
        cnt[(2*i)-1] = cnt[(2*i)-2]

for l, r in queries:
    print(cnt[r] - cnt[l-1])

Measured memory_bytes: 23928
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;


const int mod = 100000007;
const int inf = 100000005;
const int N = 3e5, M = N;
ll i,j,n,m;


void solve() {
    ll n,k;
    cin>>n>>k;
    vi vec(n);
    fo(i,0,n) {
        cin>>vec[i];
    }
    
    sortall(vec);
    ll ans =0 ;
    fo(i,0,k) ans+=vec[i];

    cout<<ans<<"\n";
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 3604
# @author 

import sys

class SDigitSum:
    def solve(self):
        MOD = 10 ** 9 + 7

        k = input().strip()
        d = int(input())

        s = len(k)
        dp = [[0] * d for _ in range(s + 1)]
        dp[0][0] = 1
        for i in range(10):
            dp[1][i % d] += 1

        # pre = [[0] * (d + 1) for _ in range(s + 1)]
        # for i in range(d):
        #     pre[1][i] = pre[1][i - 1] + dp[1][i]
        for l in range(2, s):
            # cur is sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10)
            # cur = sum(dp[l - 1][(-lm + 0) % d] for lm in range(1, 10))
            for r in range(d):
                dp[l][r] = (dp[l - 1][r] + sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10))) % MOD
                # dp[l][r] = (dp[l - 1][r] + cur) % MOD
                # cur -= dp[l - 1][(r - 9) % d]
                # cur += dp[l - 1][(r + 1 - 1) % d]


        ans = dp[s - 1][0]
        done = 0
        for i in range(s):
            lm = int(k[i])
            ans = (ans + sum(dp[s - 1 - i][(-done - (lm - v)) % d] for v in range(1, lm + 1 * (i != 0)))) % MOD
            done += lm

        if (sum(int(x) for x in k)) % d == 0:
            ans = (ans + 1) % MOD

        print((ans - 1) % MOD)

solver = SDigitSum()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 52956
#include<iostream>
#include<cstdio>
#define N 101
using namespace std;

int main() {
	int r, c;
	int A[N][N];
	cin >> r >> c;

	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= c; j++) {
			A[i][j] = 0;
		}
	}

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			A[i][c] += A[i][j];
			A[r][j] += A[i][j];
			A[r][c] += A[i][j];
		}
	}


	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= c; j++) {
		    if(j ) cout << " ";
			cout << A[i][j];
		}
		cout << endl;
	}

	return 0;

}


Measured memory_bytes: 3084
n = int(input())
v = list(map(int, input().split()))

odd = {}
even = {}

for i in range(len(v)):
    if i % 2 == 1:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1
    else:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1

#ソートして一番目、二番目を見る
odd_sorted  = sorted(odd.items(), key = lambda x : -x[1])
even_sorted  = sorted(even.items(), key = lambda x : -x[1])


def count_rewrite(odd, even):
    ans = 0
    for i in range(len(v)):
        if i % 2:
            if v[i] != odd:
                ans += 1
        else:
            if v[i] != even:
                ans += 1
    return ans


ans = 1000002
#候補が同じ場合
if odd_sorted[0][0] == even_sorted[0][0]:
    #奇数も偶数も2番目が存在する？
    if len(odd.keys()) > 1 and len(even.keys()) > 1:
        ans = min(ans, count_rewrite(odd_sorted[0][0], even_sorted[1][0]))
        ans = min(ans, count_rewrite(odd_sorted[1][0], even_sorted[0][0]))
    #お互いに二番目が存在しない(ただし数は必ず一致するのでどちらか)
    elif len(odd.keys()) == 1 and len(even.keys()) == 1:
        ans = min(ans, count_rewrite(-1, even_sorted[0][0]))
    #奇数に2番目が存在しない
    elif len(odd.keys()):
        ans = min(ans, count_rewrite(odd_sorted[0][0], even_sorted[1][0]))
    #偶数に2番目が存在しない
    else: #len(even.keys()):
        ans = min(ans, count_rewrite(odd_sorted[1][0], even_sorted[0][0]))

else:
    ans = min(ans, count_rewrite(odd_sorted[0][0], even_sorted[0][0]))


print(ans)

Measured memory_bytes: 20764
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define endl "\n"
#define int long long
#define ll long long
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define vi vector<int>
#define vii vector< vector<int> >
#define vpi vector< pair<int,int> >
#define pair <int, int> pii

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
    ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int modpow(int x, int n, int mod)
{
	x %= mod ;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % mod ;
		x = x * x % mod ;
		n >>= 1 ;
	}
	return res;
}

const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
const int N = 1e5 + 10 ;

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

        int x;
        cin>>x;

        int y;
        cin>>y;

        if(500*x>=y) {
                cout<<"Yes";
        }
        else {
                cout<<"No";
        }
	

return 0 ;
}


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

using namespace std;
using i64 = int64_t;

signed main(){
    
    int n;
    cin >> n;
    vector<int> m(3);
    vector<vector<int>> a(3);
    vector<int> d(n, 0);
    for(int i = 0; i < 3; ++i){
        cin >> m[i];
        a[i].resize(m[i]);
        for(int j = 0; j < m[i]; ++j){
            cin >> a[i][j];
            d[--a[i][j]] |= (1 << i);
        }
    }
    int ans = 0;
    for(auto& x : d)
        if(x == 4 || x == 6 || x == 7)
            ++ans;
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   string s;
   cin>>s;
   int n=s.size();
   if(s[0]==s[n-1])n++;
   if(n%2)cout<<"First"<<endl;
   else cout<<"Second"<<endl;
   return 0;
}

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


int main(){
    char c[6];
    for(int i=0;i<6;i++){
        cin>>c[i];
    }
    bool check=true;
    for(int i=0;i<3;i++){
        if(c[i]!=c[5-i]) check=false;
    }
    if(check){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int a;
int main(){
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3624
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        _n : usize,
        m : usize,
        mut war : [(usize, usize); m],
    }


    war.sort_by_key(|n| n.1);

    let mut count = 0;
    let mut pos = 0;

    //println!("{:?}", war);
    for w in &war {
        if w.0 >= pos {
            count+= 1;
            pos = w.1;
        }
    } 

    println!("{}", count);

}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((int)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

// void print(Vl v){
//     rep(i, 0, sz(v)){
//         if(i) cout << " ";
//         cout << v[i];
//     }
//     cout << endl;
// }

////////////////////////////////////////////////////////

ll dp[105][10005];

int main() {
    ll N, W; cin >> N >> W;
    Vl v(N), w(N);
    rep(i, 0, N) cin >> v[i] >> w[i];

    rep(i, 0, N){
        Rep(j, 0, W){
            chmax(dp[i+1][j], dp[i][j]);
            if(j-w[i]>=0) chmax(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
        }
    }

    co(dp[N][W]);
    return 0;
}



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

int main() {
	int n, m; cin >> n >> m;
	vector<int> cnt(m, 0);

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

	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (cnt[i] == n) ans++;
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
    int h, w;
    std::cin >> h >> w;
    std::vector<std::string> svec;
    for (int i = 0; i < h; i++)
    {
        std::string buf;
        std::cin >> buf;
        svec.push_back(buf);
    }

    for (int i = 0; i < h + 2; i++)
    {
        if (i == 0 || i == h + 1)
        {
            for (int j = 0; j < w + 2; j++) { std::cout << '#'; }
            std::cout << std::endl;
        }
        else
        {
            std::cout << '#';
            std::cout << svec[i - 1];
            std::cout << '#' << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
from math import factorial

def process(n):
    fac = list(str(factorial(n)))
    cnt = 0
    for f in fac[::-1]:
        if f == '0':
            cnt += 1
        else:
            break
    return cnt

while True:
    n = int(input())
    if n == 0: break
    ans = process(n)
    print(ans)


Measured memory_bytes: 6572
n = int(input())
x = input()[::-1]

f = [0] * n
for i in range(1, n):
    p = bin(i).count("1")
    r = i % p
    f[i] = f[r] + 1

p = x.count("1")
p1, p2 = p + 1, p - 1

if p == 1:
    ii = x.index("1")
    x1 = pow(2, ii, p1)
    for i in range(n)[::-1]:
        if i == ii:
            print(0)
        else:
            r = (x1 + pow(2, i, p1)) % p1
            print(f[r] + 1)
    exit()

x1 = x2 = 0
for i in range(n):
    if x[i] == "1":
        x1 += pow(2, i, p1); x2 += pow(2, i, p2)
        x1 %= p1; x2 %= p2

for i in range(n)[::-1]:
    if x[i] == "0":
        r = (x1 + pow(2, i, p1)) % p1
    else:
        r = (x2 - pow(2, i, p2)) % p2
    print(f[r] + 1)


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

int main(){
  string s, t;
  cin >> s;
  cin >> t;
  int len = s.length();
  for(int i = 0; i<len; i++){
    int buf_i = i;
    for(int j = 0; j<len; j++){
      if(buf_i >= len){
        buf_i = 0;
      }
      if(s[buf_i++] != t[j]){
        break;
      }else{
        // cout << buf_i -1 << " " << j << endl;
        if(j == len -1){
          cout << "Yes" << endl;
          return 0;
        }

      }
    }
  }

  cout << "No" << endl;


}


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

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int d, t, s;
    cin >> d >> t >> s;
    if (t * s >= d) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3608
// AtCoder ABC124: A - Buttons
// 2019.9.9 bal4u

#include <stdio.h>

int calc(int *a, int *b) {
	if (*a >= *b) return (*a)--;
	else return (*b)--;
}

int main()
{
	int A, B, ans;
	
	scanf("%d%d", &A, &B);
	ans = calc(&A, &B);
	ans += calc(&A, &B);
	printf("%d\n", ans);
	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 ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int a, b; cin >> a >> b;
	cout << a * b << " " << 2 * a + 2 * b << endl;
}

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



Measured memory_bytes: 3180
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  int K, X;
  cin >> K >> X;
  if(500*K >= X){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N, X = map(int, input().split())

sum_m = 0
min_m = 1001
for i in range(N):
    m = int(input())
    sum_m += m
    if m < min_m:
        min_m = m
        
remain_X = X - sum_m
ans = N
ans += remain_X // min_m
print(ans)


Measured memory_bytes: 3060
n=int(input())
t_p=0
h_p=0
for i in range(0,n):
    Taro,Hana = input().split()
    if(Taro==Hana):
        t_p+=1
        h_p+=1
    elif(Taro > Hana):
        t_p+=3
    else:
        h_p+=3
print(f"{t_p} {h_p}")


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
void dump(){cout<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cout<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

void solve1();void solve2();
int main(){
  solve1();
  return 0;
}

void solve1(){

  int n;
  string s;
  cin>>n>>s;
  if(n&1){cout<<"No"<<endl;return;}
  if(s.substr(0,n/2)==s.substr(n/2))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


}

Measured memory_bytes: 256
function main(input) {
  const tmp = input.trim().split('\n')
  const n = parseInt(tmp[0], 10)
  const s = tmp[1]

  let r = 0
  let g = 0
  let b = 0

  for (let i = 0; i < n; i++) {
    if (s[i] == 'R') {
      r++
    } else if (s[i] == 'G') {
      g++
    } else {
      b++
    }
  }

  let answer = r * g * b
  for (let i = 0; i < n - 1; i++) {
    for (let j = i + 1; 2 * j - i < n; j++) {
      const k = 2 * j - i
      if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
        answer--
      }
    }
  }

  console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 35432
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int

const int hell=1000000007;


int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;
    a%=10000000000LL;}
  return a;
}



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

bool cmp(pii a,pii b)
{
  return a.SS<b.SS;
}

int solve()
{  
 
int n,l;
cin>>n>>l;
vi a;
vii b;
int sum=0;
rep(i,1,n+1)
{
  a.pb(l+i-1);
  b.pb({abs(l+i-1),i});
  sum+=l+i-1;
}
sort(all(b));
sum-=a[b[0].SS-1];
cout<<sum;
    return 0;
}


signed main()
{  int t=1;
//pri();
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    




  clock_t time_req;

    // Without ung pow function
                                                                                                                   

  //cin>>t;

    int k=1;
   while(t--)
     {
      // cout<<"Case #"<<k<<":"<<" ";k++;
      solve();
     

     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
} 

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

int main() {
	long long H, N, MAX = 0;
	cin >> H >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int j = 0; j < N; j++) {
		MAX += A[j];
	}
	if (MAX >= H) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

namespace abc081b{
    class Program{
        static void Main (string[] args){
            var vs = Console.ReadLine().Split().Select(x=>int.Parse(x)).ToArray();
            var s = Console.ReadLine();
            int n = vs[0];
            int k = vs[1];
            string ans="";
            for(int i =0;i<n;i++){
                if(i==k-1){
                    ans += char.ToLower(s[i]);
                }
                else{
                    ans += s[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		long[]A = new long[N];
		int[]E = new int[40];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
			long a = 1;
			for(var j=0;j<40;j++){
				if(A[i]/a%2==1){
					E[j]++;
				}
				a *= 2;
			}
		}
		long[]ans = new long[N];
		for(var i=0;i<N;i++){
			int[]F = new int[40];
			long a = 1;
			long a1 = 0;
			for(var j=0;j<40;j++){
				if(A[i]/a%2==1){
					F[j]++;
				}
				if(E[j]%2!=F[j]){
					a1 += a;
				}
				a *= 2;
			}
			ans[i] = a1;
		}
		Console.Write(ans[0]);
		for(var i=1;i<N;i++){
			Console.Write(" "+ans[i]);
		}
	}
}


Measured memory_bytes: 45072
#include <stdio.h>
int main(void){
  int N = 0, M = 0;
  int cntM[31] = {0};
  int num = 0;
  int temp = 0;
  int suki = 0;
 
  scanf("%d %d", &N, &M);
  
  for(int cnt = 0; cnt < N; cnt++){
    scanf("%d", &num);
    for(int cnt_num = 0; cnt_num < num; cnt_num++){
      scanf("%d", &temp);
      cntM[temp]++;
    }
  }

  for(int cnt = 1; cnt <= M; cnt++){
	if(cntM[cnt] == N){
      suki++;
    }
  }	
  printf("%d\n", suki);
 return 0; 
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 1000000005
#define NIL -1
ll mod = 1e9+7;
int main(){
    int n; cin >> n;
    map<string, int> mp;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
        mp[s[i]]++;
    }
    int m; cin >> m;
    string t[m];
    for(int i = 0; i < m; i++){
        cin >> t[i];
        mp[t[i]]--;
    }
    int mx = 0;
    for(int i = 0; i < n; i++){
        mx = max(mp[s[i]], mx);
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  string S;
  cin>>S;
  cout<<S[0]<<S.size()-2<<S[S.size()-1];
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >>d;

  if (a+b == c+d) {
    cout << "Balanced" << endl;
  }
  else if(a+b > c+d){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


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

int main() {
 int a,b,c,d;
  cin >> a >> b >> c >> d;
if(a+b < c+d) cout << "Right" << endl;
if(a+b == c+d) cout << "Balanced" << endl;
if(a+b > c+d) cout << "Left" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

struct edge {
  int to, color;
};

int N;
vector<edge> Graph[101010];
int A[101010], B[101010];
int K;
map<Pii, int> ans;

void dfs(int cur, int from, int from_color) {
  int cnt = 1;
  for (int i = 0; i < Graph[cur].size(); ++i) {
    edge e = Graph[cur][i];
    if (cnt == from_color) ++cnt;

    if (e.to == from) {
      Graph[cur][i] = edge{e.to, from_color};
      ans[Pii(cur, e.to)] = from_color;
      continue;
    } else {
      Graph[cur][i] = edge{e.to, cnt};
      ans[Pii(cur, e.to)] = cnt;
      dfs(e.to, cur, cnt);
      ++cnt;
    }
  }
  chmax(K, cnt - 1);
}

int main() {
  cin >> N;
  rep(i, 0, N - 1) {
    int a, b;
    cin >> a >> b;
    Graph[a].push_back(edge{b, 0});
    Graph[b].push_back(edge{a, 0});
    A[i] = a;
    B[i] = b;
  }

  dfs(1, 0, 0);

  cout << K << "\n";
  rep(i, 0, N - 1) { cout << ans[Pii(A[i], B[i])] << "\n"; }
}


Measured memory_bytes: 22948
fn far_reaching(graph: &[Vec<(usize, i64)>], start: usize) -> (usize, i64) {
    let size = graph.len();
    let mut is_reached: Vec<bool> = vec![false; size];
    let mut dist = vec![-1; size];
    let mut stack = vec![start];
    dist[start] = 0;
    'dfs: while !stack.is_empty() {
        let from = *stack.last().unwrap();
        if !is_reached[from] {
            is_reached[from] = true;
        }
        for &(to, weight) in &graph[from] {
            if !is_reached[to] {
                dist[to] = dist[from] + weight;
                stack.push(to);
                continue 'dfs;
            }
            // For each edgse.
        }
        // Postorder
        let _from = stack.pop().unwrap();
    }
    dist.into_iter().enumerate().fold(
        (0, -1),
        |(node, dist), (n, d)| if dist < d { (n, d) } else { (node, dist) },
    )
}

fn solve(graph: Vec<Vec<(usize, i64)>>) {
    let start = 0;
    let (node, _) = far_reaching(&graph, start);
    let (_, dist) = far_reaching(&graph, node);
    println!("{}", dist);
}

use std::io::{BufRead, BufReader};
fn main() {
    let mut read = BufReader::new(std::io::stdin())
        .lines()
        .filter_map(|e| e.ok());
    let v = {
        let line = read.next().unwrap();
        let line: Vec<&str> = line.split(' ').collect();
        let v: usize = line[0].parse().unwrap();
        v
    };
    let graph = {
        let mut graph: Vec<Vec<_>> = vec![vec![]; v]; // Adj list
        for edge in read {
            let mut edge = edge.split(' ');
            let start: usize = edge.next().unwrap().parse().unwrap();
            let end: usize = edge.next().unwrap().parse().unwrap();
            let weight: i64 = edge.next().unwrap().parse().unwrap();
            graph[start].push((end, weight));
            graph[end].push((start, weight));
        }
        graph
    };
    solve(graph);
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  ll K, A, B; cin >> K >> A >> B;
  if (K < A + 1 || B - A <= 2) {
    cout << K + 1 << endl;
  }
  else {
    K -= A + 1;
    cout << B + (B - A) * (K / 2) + (K % 2) << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  string str,ans;

  cin>>n;
  cin>>str;

  for(int i=0;i<str.size();i++){
    if(str[i]+n>='A' && str[i]+n<='Z') printf("%c",(str[i]+n));
    else printf("%c",(str[i]+n-26));
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	lld x,k,d;
	cin >> x >> k >> d;
	if(x<0) x *= -1;
	lld vv = x/d;
	if(k<=vv) printf("%lld\n",x-d*k);
	else{
	//	printf("%lld %lld\n",k,vv);
		if((k%2)==(vv%2)){
			printf("%lld\n",x%d);
		}else{
			printf("%lld\n",d-(x%d));
		}
	}
	return 0;
}


Measured memory_bytes: 3760