akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 100100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

 
int main(){
    int x,y; cin >> x >> y;
    
    int ans = 0;
    if(x == 1) ans += 300000;
    if(x == 2) ans += 200000;
    if(x == 3) ans += 100000;
    if(y == 1) ans += 300000;
    if(y == 2) ans += 200000;
    if(y == 3) ans += 100000;
    
    if(x == y && x == 1) ans += 400000;
    
    cout << ans << endl;
    
    
    
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<iomanip>
#include<stdio.h>

int main() {
	int a,b=0;
	int d,r=0;
	double f=0.0;

	cin >> a >>b;
	d = a / b;
	r = a % b;
	f = (1.0 * a) / b;

printf("%d %d %.8lf\n",d ,r, f);
	return 0;
}


Measured memory_bytes: 3148
// AtCoder Beginner Contest 092 - Problem A: Travelling Budget (https://atcoder.jp/contests/abc092/tasks/abc092_a)
#include <bits/stdc++.h>

using namespace std;


int main()
{
    ios::sync_with_stdio(false);

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    auto ans = min(A, B) + min(C, D);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
<?php

const INPUT_DELIMITER = " ";
$input = fgets(STDIN);
list($L, $R) = array_map('intval', explode(INPUT_DELIMITER, $input));


const MOD = 2019;

// $Lか$Rが2019の倍数を取りうる時
//（差が2019以上であればどっちかが2019の倍数に出来る）
if ($R - $L > MOD) {
    echo 0;
    return;
}

// それ以外のときは地道に計算してみる
$min = MOD;
for ($i = $L; $i <= $R - 1; $i++) {
    $A = $i % MOD;
    for ($j = $i + 1; $j <= $R; $j++) {
        $B = $j % MOD;
        $tmp = ($A * $B) % MOD;
        if ($min > $tmp) {
            $min = $tmp;
        }
    }
}

echo $min;

Measured memory_bytes: 3828
import math
import queue
import bisect
import heapq
import time
import itertools

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def main():
    n = int(input())
    s = input()
    ans = []
    for i in range(len(s)):
        asc = ord(s[i])+n
        if asc>90:
            asc -= 26
        ans.append(chr(asc))
    print(''.join(ans))
    return


if __name__=='__main__':
    main()

Measured memory_bytes: 4204
N = int(input())
h = list(map(int,input().split()))

dp = [-1]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
  a = dp[i-1]+abs(h[i]-h[i-1])
  b = dp[i-2]+abs(h[i]-h[i-2])
  dp[i] = min(a,b)
print(dp[N-1])


Measured memory_bytes: 52208
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

#define ll long long

using namespace std;

int main(void){
	int n,tmp;
	cin >> n;
	
	ll dp[n][21];
	memset(dp, 0, sizeof(dp));
	
	vector<int> v;
	for(int i=0;i<n;i++){
		cin >> tmp;
		v.push_back(tmp);
	}
	
	dp[0][v[0]] = 1;
	for(int i=0;i<v.size()-2;i++){
		for(int j=0;j<21;j++){
			if(dp[i][j] > 0){
				if(0 <= j+v[i+1] && j+v[i+1] <= 20){
					dp[i+1][j+v[i+1]] += dp[i][j];
				}
				if(0 <= j-v[i+1] && j-v[i+1] <= 20){
					dp[i+1][j-v[i+1]] += dp[i][j];
				}
			}
		}
	}
	cout << dp[v.size()-2][v.back()] << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int D;
    int p[11];
    int c[11];
    ll G;
    cin >> D >> G;
    rep(i, D){
        cin >> p[i];
        cin >> c[i];
    }

    ll ans = 100000;
    rep(i, 1 << D){
        ll tmp = 0;
        ll cou = 0;
        int l[11];
        int ind = 0;
        rep(j, D){
            if (i & (1 << j)) {
                tmp += 100*(j+1)*p[j] + c[j];
                cou += p[j];
            } else {
                l[ind] = j;
                ind++;
            }
        }


        if (tmp >= G){
            ans = min(ans, cou);
        } else {
            for(int j = ind-1; j >= 0; --j){
                rep(k, p[l[j]]){
                    if (tmp < G){
                        tmp += 100*(l[j]+1);
                        cou++;
                    } else {
                        ans = min(ans, cou);
                        break;
                    }
                }
//                if (G - tmp <= (p[l[j]]-1)*100*(l[j]+1)) {
//                    ans = min(ans, cou + (G - tmp)/(100*(l[j]+1)));
//                    break;
//                } else {
//                    cou += p[l[j]]-1;
//                    tmp += (p[l[j]]-1)*100*(l[j]+1);
//                }
            }
        }

    }

    cout << ans << endl;



}

Measured memory_bytes: 256
H, W, A, B = map(int, input().split())
ans = [[0] * W for _ in range(H)]
row = [W-A] * H
column = [H-B] * W
for h in range(H):
    for w in range(W):
        if row[h] == 0:
            pass
        elif column[w] == 0 :
            pass
        else:
            ans[h][w] = 1
            row[h] -= 1
            column[w] -= 1

for row in ans:
    print(*row, sep="")


Measured memory_bytes: 78172
n=int(input())
l=[input() for i in range(n)]
ct=0;cta=0;ctb=0;ctab=0
for i in range(len(l)):
  for j in range(len(l[i])-1):
    if l[i][j]=='A' and l[i][j+1]=='B':ct+=1
  if l[i][0]=='B' and l[i][len(l[i])-1]=='A':
    ctab+=1
    cta+=1
    ctb+=1
  elif l[i][len(l[i])-1]=='A':cta+=1
  elif l[i][0]=='B':ctb+=1
x=min(cta,ctb)

if ctab==cta and ctab==ctb and ctab!=0:
  print(ct+x-1)
else:
  print(ct+x)

Measured memory_bytes: 3828
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		//変数
		int count=0;
		boolean sw=false;
		int answer=0;
		//long answer=0;
		//double answer=0;
		//String answer="NO";
		List<Integer> h=new ArrayList<Integer>();
		//int af=Integer.MAX_VALUE;
		int L=0;
		//int sub=0;
		int n=0;
		int m=0;
		int c[]=new int[31];
		for(int i=0;i<31;i++)
		{
			c[i]=0;
		}
		//int t[]=new int[(int)Math.pow(10,5)];
		
		//入力
		Scanner sc = new Scanner(System.in);
		n=sc.nextInt();
		m=sc.nextInt();
		//X=sc.nextDouble();
		int a[][]=new int[n][m];
		int k[]=new int[n];
		for(int i=0;i<n;i++)
		{
			k[i]=sc.nextInt();
			for(int j=0;j<k[i];j++)
			{
				a[i][j]=sc.nextInt();
			}
		}
		
		//int A[]=new int[L];
		//for(int i=0;i<L;i++)
		//{
		//	A[i]=sc.nextInt();
		//}
		//String S=sc.next();
		
		//処理
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<k[i];j++)
			{
				c[a[i][j]]+=1;
			}
		}
		for(int i=0;i<31;i++)
		{
			if(c[i]==n)
			{
				answer++;
			}
		}
		// 出力
		//System.out.println(Arrays.toString(X))
		//System.out.println(Arrays.deepToString(a));
		//System.out.println(Arrays.toString(h.toArray()));
		System.out.println(answer);
	}
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;

  std::vector<ll> A(N);
  rep(i, N) {
    std::cin >> A[i];
  }

  std::vector<ll> X(N);
  std::map<int, int> cnt[2];

  for(int i = N - 1; i >= 0; --i) {
    rep(d, 60) {
      int b = 1LL & (A[i] >> d);
      int c = cnt[1 ^ b][d] % MOD;
      X[i] += (1LL << d) % MOD * c % MOD;
      ++cnt[b][d];
    }
  }

  ll ans = 0;
  rep(i, N - 1) {
    ans += X[i];
    ans %= MOD;
  }
  std::cout << ans << '\n';

}


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

using namespace std;
using ll = long long int;

struct Pair
{
    int a, b, c, d;
};
vector<Pair> P;

int Dfs(int array[], int index, int last, int n, int m)
{
    if (index >= n)
    {
        //for (int i = 0; i < n; i++)
        //{
        //    cout << array[i] << " ";
        //}

        //cout << endl;

        int score = 0;
        for (auto &p : P)
        {
            if (array[p.b - 1] - array[p.a - 1] == p.c)
            {
                score += p.d;
            }
        }
        //cout << score << endl;
        return score;
    }

    int ans = 0;
    for (int digit = last; digit <= m; digit++)
    {
        array[index] = digit;
        ans = max(ans, Dfs(array, index + 1, digit, n, m));
    }

    return ans;
}

int main()
{
    int n, m, q;
    cin >> n >> m >> q;

    for (int i = 0; i < q; i++)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        P.push_back({ a, b, c, d });
    }

    int array[20];
    int ans = Dfs(array, 0, 1, n, m);
    cout << ans << endl;
}

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

#define ucin ios::sync_with_stdio(0), cin.tie(0)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = (ll) a * a % mod)
		if(b & 1) ans = (ll) ans * a % mod;
	return ans;
}
ll n, m;
ll C(ll n) {
	return n * (n - 1) / 2;
} 
int main() {
	cin >> n >> m;
	cout << (C(n) + C(m));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
 
   int x;    // define variable
   int cnt=1;    // define counter
 
   scanf("%d", &x);
 
   while(x!=0){
      printf("Case %d: %d\n", cnt, x);
      cnt++;
      scanf("%d", &x);
   }
 
   return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define fs first
#define sc second
#define MAXN 100005
#define LIMIT 1500
#define LOGN 1048575
#define ll long long
#define pb push_back
#define ld long double
#define eps 1e-6
#define endl '\n'
#define lc 2*pos
#define rc 2*pos+1
using namespace std;
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	int a,b;
	cin>>a>>b;
	if(a>=13){
		cout<<b<<endl;
	}else if(a>=6){
		cout<<b/2<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,m,a[N],parent[N],siz[N];
mii g[N];

int find(int a){return a == parent[a] ? a : parent[a] = find(parent[a]);}

void merge(int x, int y){
    x = find(x), y = find(y);
    if(siz[x] < siz[y]) swap(x, y);
    for(pii p : g[y]) g[x][p.f] += p.s;
    siz[x] += siz[y];
    parent[y] = x;
}

int main(){
    read2i(n,m);
    lp(i,1,n){
        readi(a[i]);
        parent[i] = i;
        siz[i] = 1;
        ++g[i][a[i]];
    }

    lp(i,1,m){
        int x,y;
        read2i(x,y);
        ++x, ++y;
        merge(x, y);
    }

    si parents;
    lp(i,1,n) parents.insert(find(i));

    set<pii> st;
    for(int i : parents) st.insert(pii(siz[i], i));

    ll ans = 0;
    while(sz(st) > 1){
        pii f = *st.rbegin();
        st.erase(f);
        pii s = *st.rbegin();
        st.erase(s);

        if(!f.f or !s.f) return cout <<"Impossible", 0;

        int i = f.s, j = s.s;
        ans += g[i].begin()->f + g[j].begin()->f;
        --g[i].begin()->s, --g[j].begin()->s;
        --siz[i], --siz[j];
        if(!g[i].begin()->s) g[i].erase(g[i].begin());
        if(!g[j].begin()->s) g[j].erase(g[j].begin());
        merge(i, j);

        st.insert(pii(siz[i] + siz[j], i));
    }
    cout <<ans;
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 21120
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll N, K;
  cin >> N >> K;
  ll res = 0;
  for (ll b = 1; b <= N; b++) {
    ll q = N / b, r = N % b;
    res += max(0ll, b - K) * q;
    res += max(0ll, r - K + 1);
  }
  if (K == 0) {
    res -= N;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
    int N,A;
    cin >> N >> A;
    vector<int>x(N);
    for (int i = 0; i < N; i++) {
        cin >> x.at(i);
        x.at(i) = abs(x.at(i)-A);
    }

    if (N == 1){
        cout << x.at(0) << endl;
        return 0;
    }
    
    int X = x.at(0);
    int Y = x.at(1);
    int Z = X % Y;
    int count;

    for (int i = 1; i < N; i++) {
      count = 0;
      while (count == 0){
        if (Z == 0){
          if (i != N-1){
            X = x.at(i+1);
            Z = X % Y;
          }
          count++;
        }
        else {
          X = Y;
          Y = Z;
          Z = X % Y;
        }
      }
    }
    cout << Y << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i <= n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/



int main(){
  int r,g,b,n;
  ll ans=0;
  cin>>r>>g>>b>>n;
  rep(i,n){
    rep(j,n){
      if((n-i*r-j*g)/b>=0&&(n-i*r-j*g)/b<=n&&(double)(n-i*r-j*g)/b-(int)(n-i*r-j*g)/b==0){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;

    vector<int> a;
    int k;
    for(int i = 0; i < N; i++){
        cin >> k;
        a.push_back(k);
    } 

    sort(a.begin(), a.end());

    int s = 0;
    s = N / 2;

    int ans = a[s];
    int qwe = a[s - 1];

    ans -= qwe;

    cout << ans << endl;

}

Measured memory_bytes: 892
#include <iostream>

int solve(int a, int b, int c) {
  if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0)
    return 0;
  if (a == b && a == c)
    return -1;
  return solve((b + c) / 2, (c + a) / 2, (a + b) / 2) + 1;
}

int main(int argc, char *argv[]) {
  int a, b, c;
  std::cin >> a >> b >> c;
  int ans = solve(a, b, c);
  std::cout << ans << std::endl;
}


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

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

  int a;
  cin >> a;
  cout << a + (a * a) + (a * a * a) << endl;

  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

	if (a == b && b == c) {
		if (a % 2 == 0) {
			cout << -1 << endl;
		}
		else {
			cout << 0 << endl;
		}
		return 0;
	}

	ll cnt = 0;
	while (1) {
		if (a % 2 || b % 2 || c % 2) break;

		ll ta = a / 2, tb = b / 2, tc = c / 2;
		a = tb + tc;
		b = tc + ta;
		c = ta + tb;
		cnt++;
	}
	
	cout << cnt << endl;
	return 0;
}

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

int main() {
	int N, K;
	int d;
	cin >> N >> K;
	int mar[105][105];
	int cnt[105];
	memset(mar, -1, sizeof(mar));
	for(int i=1;i<=K;i++) {
		int d;
		int tmp;
		cin >> d;
		for(int j=0;j<d;j++) {
			cin >> tmp;
			mar[tmp][i] = 1;
		}
	}
	memset(cnt, 0, sizeof(cnt));

	vector<int> res;
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=K;j++) {
			if(mar[i][j] == 1)
				cnt[i]++;
		}
		if(cnt[i] == 0)
			res.push_back(i);
	}

	cout << res.size() << endl;

	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>

using namespace std;

typedef pair<int, int> P;

class Edge{
public:
  int to, dist, cost;
  Edge(){}
  Edge(int to, int dist, int cost) : to(to), dist(dist), cost(cost) {}
};

static const int N = 10000;
static const int INF = (1<<28);

vector<Edge> G[N];
vector<int> prevc[N];
int dist[N], n, m;

int solve(){
  fill(dist, dist+n, INF);
  priority_queue<P, vector<P>, greater<P> > q;
  dist[0] = 0;
  q.push(P(0, 0));
  while(!q.empty()){
    P u = q.top(); q.pop();
    if(dist[u.second] < u.first) continue;
    for(int i=0;i<G[u.second].size();i++){
      Edge& e = G[u.second][i];
      if(dist[e.to] > dist[u.second] + e.dist){
        dist[e.to] = dist[u.second] + e.dist;
        prevc[e.to].clear();
        prevc[e.to].push_back(e.cost);
        q.push(P(dist[e.to], e.to));
      }else if(dist[e.to] == dist[u.second] + e.dist) prevc[e.to].push_back(e.cost);
    }
  }
  int res = 0;
  for(int i=1;i<n;i++){
    int tmp = INF;
    for(int j=0;j<prevc[i].size();j++) tmp = min(tmp, prevc[i][j]);
    res += tmp;
  }
  return res;
}

main(){
  while(cin >> n >> m && (n|m)){
    for(int i=0;i<n;i++){
      G[i].clear();
      prevc[i].clear();
    }
    for(int i=0;i<m;i++){
      int u, v, d, c;
      cin >> u >> v >> d >> c;
      G[u-1].push_back(Edge(v-1, d, c));
      G[v-1].push_back(Edge(u-1, d, c));
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 3844
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
#define endl "\n"
const int mod=1e9+7;
const double pi=acos(-1.0);
bool is_pallindrome(string &s)
{
	int low=0,high=s.size()-1;
	while(low<high)
	{
		if(s[low]!=s[high])
		{
			return false;
		}
		low++,high--;
	}
	return true;

}
int main(int argc, char const *argv[])
{
    /*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    string s;
    cin>>s;
    int n=s.length();
    string x,y;
    int sz=(n-1)/2;
    x=s.substr(0,sz);
    int l=(n+3)/2-1;
    y=s.substr(l,n-l+1);
    if(is_pallindrome(s)&&is_pallindrome(x)&&is_pallindrome(y))
    {
    	cout<<"Yes"<<endl;
    }
    else
    {
    	cout<<"No"<<endl;
    }


}

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

void solve()
{
    string s;
    cin>>s;
    int flag=0;
    for(int i=0;s[i];i++)
    {
        if(i&1){
        if(s[i]!='L' and s[i]!='U' and s[i]!='D'){
        flag=1;break;}}
        
        else{
        if(s[i]!='R' and s[i]!='U' and s[i]!='D'){
        flag=1;break;}}
    }
    if(flag==1)
    cout<<"No\n";
    else cout<<"Yes\n";
}


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


Measured memory_bytes: 256
#![allow(unused)]

#[allow(unused_imports)]
use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::*;
use collections::{HashMap, HashSet};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let s = read_line().chars().collect::<Vec<_>>();

    if contains_one(&s, 'a') && contains_one(&s, 'b') && contains_one(&s, 'c') {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn contains_one(heystack: &[char], needle: char) -> bool {
    heystack.iter().filter(|c| **c == needle).count() == 1
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<char>> C(H  * 2, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> C[i * 2][j];
			C[i * 2 + 1][j] = C[i * 2][j];
		}
	}
	for (int i = 0; i < H * 2; i++) {
		for (int j = 0; j < W - 1; j++) {
			cout << C[i][j];
		}
		cout << C[i][W - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
count = 0
ans = 0
for i in range(1,n):
    if h[i] <= h[i-1]:
        count += 1
        ans = max(ans,count)
    else:
        # ans = max(ans,count)
        count = 0
    # print(count)
    # print(ans)

print(ans)


Measured memory_bytes: 15020
def chain(y, x):
	bomb[y][x] = "0"
	if bomb[y + 1][x] == "1" : chain(y + 1, x)
	if bomb[y + 2][x] == "1" : chain(y + 2, x)
	if bomb[y + 3][x] == "1" : chain(y + 3, x)
	if bomb[y - 1][x] == "1" : chain(y - 1, x)
	if bomb[y - 2][x] == "1" : chain(y - 2, x)
	if bomb[y - 3][x] == "1" : chain(y - 3, x)
	if bomb[y][x + 1] == "1" : chain(y, x + 1)
	if bomb[y][x + 2] == "1" : chain(y, x + 2)
	if bomb[y][x + 3] == "1" : chain(y, x + 3)
	if bomb[y][x - 1] == "1" : chain(y, x - 1)
	if bomb[y][x - 2] == "1" : chain(y, x - 2)
	if bomb[y][x - 3] == "1" : chain(y, x - 3)
	return

n = input()
for d in range(0, n):
	raw_input()
	bomb = []
	for _ in range(0, 3) : bomb.append(list("00000000000000"))
	for _ in range(0, 8) : bomb.append(list("000" + raw_input() + "000"))
	for _ in range(0, 3) : bomb.append(list("00000000000000"))
	
	x = input() + 2
	y = input() + 2
	
	chain(y, x)
	
	print "Data {}:".format(d + 1)
	for var in bomb[3:11]:
		print "".join(var[3:11])

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

int main() {
	int a, b, k, cnt=0,ans[100];
	cin >>a>>b>>k;
	for (int i = 1; i<=100; i++) {
		if (a%i == 0 && b%i == 0) {
			cnt++;
			ans[cnt] = i;
		}
	}
	cout << ans[cnt+1-k] << endl;
	cin >> a;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
string c[4]={"AC","WA","TLE","RE"};
int main(){
	int n;	
	int a[4]={};
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		for(int j=0;j<4;j++) if(s==c[j]) a[j]++;
	}
	for(int i=0;i<4;i++){
		cout<<c[i]<<" x "<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int a,b,c;
	while(cin >> a >> b >> c,a+b+c!=-3){
		int sum=0;
		sum+=(a!=-1?a:0)+(b!=-1?b:0);
		if(a==-1||b==-1){
			cout << "F" << endl;
		}
		else if(sum>=80){
			cout << "A" << endl;
		}
		else if(sum>=65){
			cout << "B" << endl;
		}
		else if(sum>=50){
			cout << "C" << endl;
		}
		else if(sum>=30){
			if(c>=50){
				cout << "C" << endl;
			}
			else{
				cout << "D" << endl;
			}
		}
		else{
			cout << "F" << endl;
		}
	}
}


Measured memory_bytes: 3096
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    N, A, B = Scanner.map_int()
    if A % 2 == B % 2:
        print((B - A) // 2)
    else:
        t1 = A + (B - A) // 2
        t2 = (N - B) + 1 + (N - (A + (N - B + 1))) // 2
        print(min(t1, t2))

    return


if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef vector<ll> vll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
#define MOD 1000000007LL
#define BITS 60

int main()
{
    int N; cin >>N;
    vll A(N); cin >> A;
    ll ans = 0;

    for (int b = 0; b < BITS; b++) {
        int popcnt = 0;
        ll m = 1LL << b;
        for (int i = 0; i < N; i++) {
            if (A[i] & m) popcnt++;
        }
        ans += (ll)popcnt * (N - popcnt) % MOD * ((1LL<<b) % MOD) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}



Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30
#define MAX_P 33000

int main(){
  bool p[MAX_P] = {};
  p[0] = p[1] = true;
  for(int i = 2; i < MAX_P/2; i++){
    if(!p[i]){
      for(int j = i+i; j < MAX_P; j+=i) p[j] = 1;
    }
  }

  int dp[MAX_P] = {};
  rep(i, MAX_P) REP(j, i, MAX_P) if(!p[i] && !p[j] && i+j < MAX_P) dp[i+j]++;

  int n;
  while(scanf("%d", &n) && n) printf("%d\n", dp[n]);
  //  rep(i, 100) if(!p[i]) printf("%d ", i); puts("");
  return 0;
}

Measured memory_bytes: 1356
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>

using namespace std;

using vi = vector<int>;

int n, m;
vector<int> s;
const int mod = 1e9 + 7;
long long dp[100005][2];
vector<vi> adjlist;


void dfs(int at, int prev) {
	dp[at][0] = dp[at][1] = 1LL;
	
	for (int next : adjlist[at]) {
		if (prev == next) continue;
		dfs(next, at);

		dp[at][0] *= (dp[next][0] + dp[next][1]) % mod;
		dp[at][0] %= mod;

		dp[at][1] *= dp[next][0];
		dp[at][1] %= mod;
	}
}

int main() {
	cin >> n;
	adjlist.assign(n, vi());
	for (int i = 0; i < n-1; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		adjlist[x].push_back(y);
		adjlist[y].push_back(x);
	}

	dp[0][0] = dp[0][1] = 1LL;
	dfs(0, -1);
	cout << (dp[0][0] + dp[0][1]) % mod << "\n";
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	} else {
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 256
;; C - Replacing Integer

(defun solve (n k)
  "「nを|n-k|に置き換える」ことを繰り返したときのnの最小値"
  (let ((m (mod n k))) ; kずつ減らしていくとmになる
    (min m (- k m))))

(let ((n (read))
      (k (read)))
  (princ (solve n k)))


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 165, task d , 2020/05/03
//ms,
/*
ＡＣしたが、いちから想定解法でやり直す。
*/
#define f(x) ((A*x/B)-A*(x/B))


int main(void){
  int64_t A, B, N;
  cin >>A >>B >>N;

  cout <<f(min(N, B-1)) <<endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3600
#include <stdio.h>

int main(int argc, char *argv[])
{
    char buf[100032];
    int i;
    int n = 0, prev = 0;
    fgets(buf, sizeof(buf), stdin);
    for ( i = 0; buf[i] != '\n'; i++ ){
        if ( prev != buf[i] ){
            n++;
            prev = buf[i];
        }
    }
    printf("%d\n", n-1);
    return 0;
}

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

int main(){
  int n, d, x;
  cin >> n >> d >> x;

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

  int ans = x;
  vector<int> b(n+1, 0);
  for(int i = 1; i <= d; i++){
    for(int j = 1; j <= n; j++){
      if(b[j] * a[j] + 1 == i){
        ans++;
        b[j]++;
      }
    }
  }

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

Measured memory_bytes: 256
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []

for i in range(N):
  tmp = list(map(int, input().split()))
  A.append(tmp)

test = 0
cnt = 0

for i in range(N):
  for j in range(M):
    test += A[i][j]*B[j]
  if test > -C:
    cnt += 1
  test = 0
print(cnt)

Measured memory_bytes: 9148
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	foods := make([]int, N)
	satisfactions := make([]int, N)
	bonuses := make([]int, N-1)

	for i := 0; i < N; i++ {
		fmt.Scan(&foods[i])
	}
	for i := 0; i < N; i++ {
		fmt.Scan(&satisfactions[i])
	}
	for i := 0; i < N-1; i++ {
		fmt.Scan(&bonuses[i])
	}

	ans := 0
	for i := 0; i < N; i++ {
		ans += satisfactions[i]
		if i > 0 && foods[i]-foods[i-1] == 1 {
			ans += bonuses[foods[i-1]-1]
		}
	}

	fmt.Println(ans)
}


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

int tim = 1, q, n, t1, t2, t3, start[100005], nd[100005], f[100005];
vector <int> v[100005];

void dfs(int node) {
	start[node] = tim++;
	for (int i : v[node]) {
		dfs(i);
	}
	nd[node] = tim;
	return;
}

int query(int p) {
	int re = 0;
	while (p > 0) {
		re += f[p];
		p -= ((-p) & p);
	}
	return re;
}

void update(int p, int val) {
	while (p <= n) {
		f[p] += val;
		p += ((-p) & p);
	}
	return;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t1;
		for (int j = 0; j < t1; j++) {
			cin >> t2;
			v[i].push_back(t2);
		}
	}
	dfs(0);
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> t1;
		if (t1 == 0) {
			cin >> t2 >> t3;
			update(start[t2], t3);
			update(nd[t2], -t3);
		}
		else {
			cin >> t2;
			cout << query(start[t2]) << endl;
		}
	}
}



Measured memory_bytes: 12832
#include <stdio.h>

int main(void) {
  int a, b, max;

  scanf("%d %d", &a, &b);

  max = a + b;
  if (max < a - b) {
    max = a - b;
  }
  if (max < a * b) {
    max = a * b;
  }

  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main() {
	ll n; cin>>n;
	if(n==1) return cout<<0<<endl,0;
	ll ans=0LL;
	ll g=n;
	ll last=2LL;
	for(ll i=2; i*i<=g; i++){
		ll cnt=1LL, tmp=0LL;
		while(n%i==0){
			n/=i; tmp++;
			if(tmp==cnt){
				ans++;
				tmp=0LL; cnt++;
			}
		}
		last=i;
	}
	if(n>last) ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
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;
}


int main() {
    int x;
    cin >> x;
    int res =0;
    for(int i=1; i<=x; ++i) {
        int j=2;
        int _res = 0;
        while(j<=10 && pow(i,j)<=x) {
            _res = pow(i,j);
            ++j;
        }
        if (_res <=x) {
            res = max(_res, res);
        }
    }
    cout << res << "\n";
}


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

int main() {
const int ARR_SIZE = 3;	
	int arr[ARR_SIZE];
	cin >> arr[0] >> arr[1] >> arr[2];
	//int sum = accumulate(arr,arr+ARR_SIZE,0);
	int max, maxIdx;
	[&](){
		int tmpMax = numeric_limits<int>::min();
		for(int i = 0; i < ARR_SIZE; ++i) {
			if(arr[i] > tmpMax) {
				tmpMax = arr[i];
				maxIdx = i;
			}
		}
		max = tmpMax;
	}();
	int lesserCandies = 0;
	for(int i = 0; i < ARR_SIZE; ++i) {
		if(i == maxIdx) continue;
		lesserCandies += arr[i];
	}
	if(max == lesserCandies) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	m := iScan()
	d := make([][]bool, n)
	for i := 0; i < n; i++ {
		k := iScan()
		d[i] = make([]bool, m)
		for j := 0; j < k; j++ {
			d[i][iScan()-1] = true
		}
	}
	ans := 0
	for i := 0; i < m; i++ {
		f := true
		for j := 0; j < n; j++ {
			f = f && d[j][i]
		}
		if f {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
#include <iostream>
#include <algorithm>

using namespace std;

bool check(int i, int n, int s, int c) {
  int x[3] = {1, 10, 100};
  // smaller than n digits
  if (n > 1 && i < x[n - 1])
    return false;
  int cc = (i / x[n - s]) % 10;
  if (cc != c)
    return false;
  return true;
}

int main() {
  int n, m;
  cin >> n >> m;

  int s[m];
  int c[m];
  for (int i = 0; i < m; ++i) {
    cin >> s[i] >> c[i];    
  }

  for (int i = 0; i < 1000; ++i) {
    int x[3] = {1, 10, 100};
    // smaller than n digits
    if (n > 1 && i < x[n - 1])
      continue;
    bool ok = true;
    for (int j = 0; j < m; ++j) {
      if (!check(i, n, s[j], c[j])) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main()
{
    cout << fixed << setprecision(15);
    string O, E;
    cin >> O >> E;

    ll a = O.length();
    ll b = E.length();
    
    if(a == b){
        REP(i, a){
            cout << O[i];
            cout << E[i];
        }
    }
    else{
        REP(i, a){
            cout << O[i];
            if(i == a-1) break;
            cout << E[i];
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; long long k; cin>>n>>k;
  vector<int> a(n+1);
  for(int i=1; i<=n; ++i) cin>>a[i];
  vector<int> b,d; vector<bool> c(n+1,false);
  for(int i=a[1]; c[i]==false; i=a[i]){ b.push_back(i); c[i]=true;}
  c=vector<bool>(n+1,false);
  for(int i=a[b.back()]; c[i]==false; i=a[i]){ d.push_back(i); c[i]=true;}
  if(--k>=b.size()) cout<<d[(k-b.size())%(d.size())]; else cout<<b[k%b.size()];
  return 0;
}


Measured memory_bytes: 6296
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N, W; cin >> N >> W;
    vector<vector<ll>> dp(N+1, vector<ll>(2 * W));
    vector<int> c(N), v(N);
    for(int i=0; i<N; i++){
        cin >> c[i] >> v[i];
    }
    
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            dp[i+1][j+c[i]] = max(dp[i+1][j], dp[i][j] + v[i]);
        }
    }
    
    ll ans = 0;
    for(int i=0; i<=W; i++){
        ans = max(ans, dp[N][W]);
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 159744
import java.util.Scanner;

public class Main {

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

	    int n=gi();
	    String S=gs();
	    int b=0;
	    int w=0;
	    int[] ba=new int[n+1];
	    int[] wa=new int[n+1];
	    for(int i=0; i<n;i++) {
	    	char c=S.charAt(i);
	    	if(c=='.') {
	    		w++;
	    		ba[i+1]=ba[i];
	    		wa[i+1]=wa[i]+1;
	    	} else {
	    		b++;
	    		ba[i+1]=ba[i]+1;
	    		wa[i+1]=wa[i];
	    	}
	    }

	    int min=b;
	    for (int i=1; i<n+1;i++) {
	    	int m=(w-wa[i-1])+ba[i-1];
	    	if(m<min)min=m;
	    }
//	    if (s>x) {
//	    	System.out.println(n-1);
//	    } else {
//	    	Arrays.parallelSort(a);
//
//	    	System.out.println(c);
//	    }
	    System.out.println(min);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 41928
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
using P = pair<ll,ll>;
int N,Q;
const int MN = 200010;
ll a[MN],b[MN];
set<P> stplus,stminus;
int main(){
	cin>>N>>Q;
	N*=2;
	rep(i,N) cin>>a[i];
	rep(i,N) cin>>b[i];

	ll suma = 0;
	ll sump = 0;

	rep(i,N){
		if(i==0 || i==N-1) continue;
		suma += a[i];
		if(b[i]-a[i]>=0){
			stplus.insert(P(b[i]-a[i],i));
			sump += b[i]-a[i];
		}else{
			stminus.insert(P(b[i]-a[i],i));
		}
	}
	rep(qt,Q){
		int i;
		ll x,y;
		cin>>i>>x>>y;
		i--;
		if(i==0 || i==N-1){
			a[i] = x;
			b[i] = y;
		}else{
			if(b[i]-a[i]>=0){
				stplus.erase(P(b[i]-a[i],i));
				sump -= b[i]-a[i];
			}else{
				stminus.erase(P(b[i]-a[i],i));
			}
			suma -= a[i];
			a[i] = x, b[i] = y;
			if(b[i]-a[i]>=0){
				stplus.insert(P(b[i]-a[i],i));
				sump += b[i]-a[i];
			}else{
				stminus.insert(P(b[i]-a[i],i));
			}
			suma += a[i];
		}

		if(stplus.size()%2 == 0){
			cout<<suma+sump+a[0]+a[N-1]<<endl;
		}else{
			ll tmp = max(- (stplus.begin()->fs) , stminus.rbegin()->fs);
			cout<<suma+sump+a[0]+a[N-1]+tmp<<endl;
		}
	}
	
}


Measured memory_bytes: 17280
let count arr n k =
  let c = ref 0 in
  for i = 0 to n - 1 do
    if arr.(i) >= k then c := !c + 1
  done ;
  !c

let () =
  let n, k = Scanf.scanf "%d %d\n" (fun a b -> (a, b)) in
  let hight = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
  count hight n k |> print_int


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<tuple<int, string, int>> restaurants(N);
    REP(i, N) {
        string S;
        int P;
        cin >> S >> P;
        restaurants[i] = make_tuple(i+1, S, P);
    }
    sort(ALL(restaurants), [](auto& l, auto& r) {
        if (get<1>(l) == get<1>(r)) return get<2>(l) > get<2>(r);
        else return get<1>(l) < get<1>(r);
    });
    REP(i, N) {
        cout << get<0>(restaurants[i]) << '\n';
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int count = 0;
	if (a != b) {
		count++;
	}
	if (b != c) {
		count++;
	}
	if (a != c) {
		count++;
	}
	if ((a == b) && (b == c) && (a == c)) {
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
  string s1,s2;
  cin>>s1>>s2;
  int count=0;
  for(int i=0;i<3;i++)
  if(s1[i]==s2[i])
  count++;
  cout<<count;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9 + 7;




int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	ll n = s.length();

	vector<ll> cnt(26, 0);
	for (ll i = 0; i < n; i++)
	{
		cnt[s[i] - 'a']++;
	}
	ll ans = n * (n - 1) / 2;

	for (ll i = 0; i < 26; i++)
	{
		ans -= cnt[i] * (cnt[i] - 1) / 2;
	}
	cout << ans+1 << endl;

	

	return 0;
}


Measured memory_bytes: 720