akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  vvint places(210000);
  int n;
  cin >> n;
  vint C(n);
  rep(i,0,n) cin >> C[i];
  rep(i,0,n) places[C[i]].push_back(i);

  vint dp(210000);
  dp[0] = 1;
  for(int i = 1;i <= n;i++){
    dp[i] += dp[i-1];
    dp[i] %= MOD;

    int k = lower_bound(places[C[i-1]].begin(),places[C[i-1]].end(),i-1) - places[C[i-1]].begin();
    if(k > 0){
      int j = places[C[i-1]][k-1];
      if((i-1) - j > 1){
        dp[i] += dp[j+1];
        dp[i] %= MOD;
      }
    }
  }
  cout << dp[n] << endl;  
}

Measured memory_bytes: 14592
package main

import "fmt"

// https://atcoder.jp/contests/abc158/tasks/abc158_a

func main() {
	var s string
	fmt.Scan(&s)


	slice := split(s)
	if slice[0] == slice[1] && slice[0]== slice[2] {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}
func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}



Measured memory_bytes: 512
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<ll> x;
    rep(i, 50) {
        rep(j, 50) {
            if (100 * A * i + 100 * B * j <= F) {
                x.push_back(100 * A * i + 100 * B * j);
            }
        }
    }
    vector<ll> y;
    rep(i, F+1) {
        rep(j, F+1) {
            if (C * i + D * j <= F) {
                y.push_back(C * i + D * j);
            }
        }
    }
    ll ans_g = 0;
    ll ans_s = 0;
    rep(i, x.size()) {
        rep(j, y.size()) {
            if (x[i] + y[j] > F) continue;
            if (E * x[i] / 100 >= y[j]) {
                if (y[j] * ans_g >= ans_s * (x[i] + y[j])) {
                    ans_g = x[i] + y[j];
                    ans_s = y[j];
                }
            }
        }
    }
    print(ans_g << " " << ans_s);
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

map<ll,ll> st;
int main(){
    int n,ai;
    cin>>n;
    rep(i,n){
        cin>>ai;
        ++st[ai];
    }
    ll p=0;
    for(map<ll,ll>::reverse_iterator it=st.rbegin();it!=st.rend();++it){
        if(it->second>=4&&p==0){
            cout<<it->first*it->first<<endl;return 0;
        }
        else if(it->second>=2&&p==0) p=it->first;
        else if(it->second>=2&&p>0){
            cout<<p*it->first<<endl;return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#define SENTINEL 2000000000
#define MAX 500000
using namespace std;

int cnt;
int L[MAX / 2+2],R[MAX / 2+2];

void merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++){
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++){
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = SENTINEL;
    int i = 0;
    int j = 0;
    for (int k = left; k < right ; k++){
        cnt++;
        if (L[i] < R[j]){
            A[k] = L[i];
            i = i + 1;
            
        } else {
            A[k] = R[j];
            j = j + 1;
        }
    }
}
void mergeSort(int A[], int n, int left, int right)
{
    if (left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main()
{
    int n;
    int S[MAX];
    cnt = 0;
    
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> S[i];
    }
    mergeSort(S, n, 0, n);
    for (int i = 0; i < n; i++ ){
        if (i) cout << " ";
        cout << S[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
    
}

Measured memory_bytes: 5064
def combination(n, k):
    result = 1
    for i in xrange(1,n+1):
        result*=i
    for i in xrange(1,k+1):
        result/=i
    for i in xrange(1,n-k+1):
        result/=i
    return result

n,p = [int(i) for i in raw_input().split()]
a = [int(i) for i in raw_input().split()]

even = len([i for i in a if i % 2 == 0])
odd = len(a) - even

fact_even = 0
for k in xrange(0,even+1):
    fact_even+=combination(even,k)

fact_odd = 0
for k in xrange(p,odd+1,2):
    fact_odd+=combination(odd,k)

print fact_even * fact_odd


Measured memory_bytes: 2692
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(S, T):
    d = dict()
    for i in range(len(S)):
        if S[i] != T[i]:
            if T[i] not in d:
                d[T[i]] = True
                S = ''.join([T[i] if s == S[i] else S[i] if s == T[i] else s for s in S])
            else:
                return False
    if S == T:
        return True
    return False

if __name__ == '__main__':
    input = sys.stdin.readline
    S = input().rstrip()
    T = input().rstrip()
    ans = main(S, T)
    print('Yes' if ans else 'No')


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

using namespace std;

bool tryRestore(const string& s, const string& t, size_t pos, string& result) {
  result = s;
  for(size_t j = 0; j < t.size(); ++j){
    if(result[pos + j] == '?'){
      result[pos + j] = t[j];
    }else{
      if(result[pos + j] != t[j]){
        return false;
      }
    }
  }
  for(char& c: result){
    if(c == '?'){
      c = 'a';
    }
  }
  return true;
}

int main() {
  string s, t;
  cin >> s >> t;
  string result;
  for(size_t i = 0; i + t.size() <= s.size(); ++i){
    string tmp;
    bool ok = tryRestore(s, t, i, tmp);
    if(ok){
      if(result.empty()){
        result = tmp;
      }else{
        result = min(result, tmp);
      }
    }
  }
  if(result.empty()){
    result = "UNRESTORABLE";
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
//#include <cmath>
#include <vector>
// #include <algorithm>
// #include <bits/stdc++.h>
using namespace std;

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

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

  call(n);
  return 0;
}



Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;

class Main {
    static int TABLE_SIZE = 5;

    public static void main(String[] args) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(r.readLine());
        String[] str = r.readLine().split(" ");

        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(str[i]);
        }

        LinkedList<Integer>[] listTable = generateHashedTable(arr);

        int q = Integer.parseInt(r.readLine());
        String[] str2 = r.readLine().split(" ");

        Integer[] arr2 = new Integer[q];
        for(int i = 0; i < q; i++) {
            arr2[i] = Integer.parseInt(str2[i]);
        }

        int count = 0;
        for(Integer v: arr2) {
            if (search(listTable, v)) {
                count ++;
            }
        }

        System.out.println(count);
    }

    private static LinkedList<Integer>[] generateHashedTable(Integer[] arr) {
        @SuppressWarnings("unchecked")
        LinkedList<Integer>[] listTable = (LinkedList<Integer>[]) new LinkedList[TABLE_SIZE];

        for (Integer v : arr) {
            int h = generateHash(v);
            if (listTable[h] == null) {
                listTable[h] = new LinkedList<>();
            }

            LinkedList<Integer> list = listTable[h];
            list.add(v);
        }

        return listTable;
    }

    private static boolean search(LinkedList<Integer>[] listTable, Integer searchNum) {
        int h = generateHash(searchNum);

        LinkedList<Integer> list = listTable[h];
        if (list == null) { return false; }

        return list.contains(searchNum);
    }

    private static int generateHash(Integer v) {
        int h = v.hashCode();
        if (h < 0) {  h = 0 - h; }
        return h % TABLE_SIZE;
    }
}

Measured memory_bytes: 27884
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int collatzProblem(int n){
	return ((n % 2) ? (3 * n + 1) : (n / 2));
}

int main(int argc, char const *argv[])
{
	int cir[503];

	scanf("%d",&cir[1]);
	for (int i = 2; i < 500; ++i)	cir[i] = collatzProblem(cir[i - 1]);
	for (int i = 1; i + 3 < 500; ++i)
	{
		if(cir[i] == cir[i + 3]){
			printf("%d\n", i + 3);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,l,r) for (ll i=l;i<=r;i++)
using namespace std;
typedef long long ll;
struct st1{ll x,y;};
ll a,b,c,d,ans,N,K,fax[100007],fay[100007];
ll nx[100007],ny[100007];
st1 q[100007];
ll get(ll *fa,ll x1){
	if (fa[x1]==x1) return x1;
	fa[x1]=get(fa,fa[x1]);
	return fa[x1];
}
bool cmp1(st1 x1,st1 x2){return x1.x<x2.x;}
bool cmp2(st1 x1,st1 x2){return x1.y<x2.y;}
bool cmp3(st1 x1,st1 x2){
	return x1.x<x2.x||(x1.x==x2.x&&x1.y<x2.y);
}
int main(){
	scanf("%lld",&N);
	rep(i,1,100000) fax[i]=i,fay[i]=i,nx[i]=1,ny[i]=1;
	rep(i,1,N) scanf("%lld%lld",&q[i].x,&q[i].y);
	sort(q+1,q+N+1,cmp1);
	rep(i,1,N) if (q[i].x==q[i-1].x){
		a=get(fay,q[i-1].y);b=get(fay,q[i].y);
		if (a!=b){ny[b]+=ny[a];fay[a]=b;}
	}
	sort(q+1,q+N+1,cmp2);
	rep(i,1,N) if (q[i].y==q[i-1].y){
		a=get(fax,q[i-1].x);b=get(fax,q[i].x);
		if (a!=b){nx[b]+=nx[a];fax[a]=b;}
	}
	rep(i,1,N) q[i].x=get(fax,q[i].x),q[i].y=get(fay,q[i].y);
	sort(q+1,q+N+1,cmp3);
	rep(i,1,N) if (q[i].x!=q[i-1].x||q[i].y!=q[i-1].y) ans+=nx[q[i].x]*ny[q[i].y];
	printf("%lld\n",ans-N);
	return 0;
}


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

using namespace std;
int main(){
    long long int N, K, a, temp, counter=0;
    int QQ[101];

    

    cin>>N;
    cin>>K;

    for(int i=1; i<=N; i++){
        QQ[i] = 0;
    }

    for(int i=0;i<K;i++){
        cin>>a;
        for(int j=0;j<a;j++){
            cin>>temp;
            QQ[temp] = 1;
        }
    }
    for(int i=1; i<=N; i++){
        // cout<<QQ[i]<<" ";
        if(QQ[i]==0){
            counter++;
        }
    }
    // cout<<"\n";

    cout<<counter<<"\n";

    return 0;
}



Measured memory_bytes: 3636
N = int(input())
S = input().rstrip()
maximum = -10**9
for i in range(N-1):
    X = S[:i+1]
    Y = S[i+1:]
    X_char = set(X)
    Y_char = set(Y)
    count = 0
    for i in list(X_char):
        if i in Y_char:
            count += 1
    if count > maximum:
        maximum = count
print(maximum)

Measured memory_bytes: 3064
MOD = 2019
while True:
    try:
        L, R = map(int, input().split())
        ans = 2019*2019
        if R-L <= MOD-1:
            for i in range(L, R+1):
                for j in range(i+1, R+1):
                    ans = min(ans, i*j%MOD)
            print(ans)
        else:
            print(0)
    except:
        break

Measured memory_bytes: 3060
import collections

INF = 10 ** 5

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    H, W = ZZ()
    Maze = [input() for _ in range(H)]
    D = [(1, 0), (-1, 0), (0, 1), (0, -1)]

    def bfs(sx, sy):
        dist = [[INF] * W for _ in range(H)]
        dist[sx][sy] = 0
        deq = collections.deque()
        deq.append([sx, sy])
        while deq:
            v = deq.popleft()
            for dx, dy in D:
                nx, ny = v[0]+dx, v[1]+dy
                if 0 <= nx < H and 0 <= ny < W and dist[nx][ny] == INF and Maze[nx][ny] == '.':
                    dist[nx][ny] = dist[v[0]][v[1]] + 1
                    deq.append([nx, ny])
        return dist[v[0]][v[1]]

    max_d = -1

    for i in range(H):
        for j in range(W):
            if Maze[i][j] == '.': max_d = max(max_d, bfs(i, j))
    print(max_d)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
 
#define loop(x) for(int i = 0; i < x; i++)
#define deb(x) cout<< #x << x << endl;
#define ll long long
#define LINF 1e18L + 5 
using namespace std;

string f(string s1, string s2) {
    vector<vector<int>> dp(s1.size() + 1, vector<int>(s2.size() + 1, 0));
    vector<vector<int>> direc(s1.size() + 1, vector<int>(s2.size() + 1, 0));
    for(int i = 1; i <= s1.size(); i++) {
        for(int j = 1; j <= s2.size(); j++) {
            if(s1[i - 1] == s2[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                direc[i][j] = 2;
            } else {
                if(dp[i][j - 1] > dp[i - 1][j]) {
                    dp[i][j] = dp[i][j - 1];
                    direc[i][j] = 1;
                } else {
                    dp[i][j] = dp[i - 1][j];
                    direc[i][j] = 3;
                }
            }
        }
    }
    int i = s1.size(), j = s2.size();
    string r;
    while(direc[i][j] != 0) {
       if(direc[i][j] == 2) {
            r.push_back(s1[i - 1]);
            i--;
            j--;
       } else if(direc[i][j] == 1) {
            j--;     
       } else {
            i--;
       }
   }
    reverse(r.begin(), r.end());
    return r;
}
int main() {
 
    int t = 1;
    //cin>>t;
    while(t--) {
        // FOR ARRAY
        // int n;
        // cin>>n;
        // string arr;
        // for(int i = 0; i < n; i++) {
        //     char x;
        //     cin>>x;
        //     arr.push_back(x);
        // }
        // f(arr);
 
        // FOR MATRIX
        // int row, col;
        // cin>>row;
        // cin>>col;
        // vector<vector<int>> arr(row, vector<int>(col, 0));
        // for(int i = 0; i < row; i++) {
        //     for(int j = 0; j < col; j++) {
        //         cin>>arr[i][j];
        //     }
        // }
        // f(arr);
        
        //FOR MATRIX
        string s1, s2;
        cin>>s1>>s2;
        cout<<f(s1, s2)<<endl;
 
    }
    return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define INF 100000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;


int main() {
    
    string s;
    
    cin >> s;
    if(s[s.size()-1]=='s'){
        s += "es";
    }else{
        s += "s";
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
H_list = list(map(int,input().split()))

# reverse
H_list.reverse()

ans =0
val =0


for i in range(N-1):
    if H_list[i]<=H_list[i+1]:
        val+=1
        ans = max(ans,val)
    else:
        val =0
print(ans)




Measured memory_bytes: 15020
#include <iostream>
#include <queue>
#include <string>
using namespace std;

int main(){
	
	char com[20];
	priority_queue<int> PQ;
	
	while(true){
		cin>>com;
		if(com[0]=='i'){
			int key;
			cin>>key;
			PQ.push(key);
		}
		else if(com[1]=='x'){
			cout<<PQ.top()<<endl;
			PQ.pop();
		}
		else if(com[0]=='e'){
			break;
		}
	}
	
	return 0;
} 


Measured memory_bytes: 6844
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let mut buffer = read::<String>();
  let mut prev = 'A';
  let mut ans = "Good";

  for i in buffer.chars() {
    if prev == i {
      ans = "Bad"
    }
    prev = i;
  }

  println!("{}", ans);
}



Measured memory_bytes: 4352
# abc093_b.py
A, B,K = map(int,input().split())
ans = []
for i in range(K):
#    print(i)
    ans.append(i+A)
    if i >(B-A-1):
        break
for i in range(K):
#    print(A-i)
#    print(i)
    ans.append(B-i)
    if i >(B-A-1):
        break
ans = list(set(ans))
ans.sort()
for i in ans:
    print(i)

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

  int main()
  {
	int a, b, ansA,ansB;
    cin >> a >> b;
    int c = min(a, b);
    for(int i = 0; i <= 10000; i++)
    {
	  if(i * 8 /100 == a && i * 10 / 100 == b) 
      {
        cout << i << endl;
      	return 0;
      }
    }
    cout << -1 << endl;
    return 0;
  }


Measured memory_bytes: 256
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		boolean a = scan.nextInt() % 2 != 0;
		boolean b = scan.nextInt() % 2 != 0;
		System.out.println(a && b ? "Yes" : "No");
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 35528
N, M = map(int, input().split())
H = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
ans = 0
for i in range(N):
    for j in G[i]:
        if H[i] <= H[j]:
            break
    else:
        ans += 1
print(ans)


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

struct edge {
  ll to, cost;
};

typedef pair<ll, ll> P;

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

  vector<edge> G[N];
  rep0(i, M) {
    ll l, r, c;
    cin >> l >> r >> c;
    l--, r--;
    edge e;
    e.to = r, e.cost = c;
    G[l].push_back(e);
  }
  rep0(i, N - 1) {
    edge e;
    e.to = i, e.cost = 0;
    G[i + 1].push_back(e);
  }


  priority_queue< P, vector<P>, greater<P> > q;
  vector<ll> d(N, 1e15);
  d[0] = 0;
  q.push(P(0, 0));

  while(!q.empty()) {
    P p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;

    for(auto e: G[v]) {
      if(d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          q.push(P(d[e.to], e.to));
      }
    }
  }

  if(d[N - 1] >= 1e15) d[N - 1] = -1;
  cout << d[N - 1] << BR;
  return 0;
}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout << "debug... " << n1 << "\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
public:
    ll x, y;
};
ll val(ll n, ll x, ll y)
{
    ll cnt = 0;
    rep(i, 1, n + 1)
    {

        ll f = 0, n1 = i;
        while (true)
        {
            f = n1;
            n1 /= 10;
            if (n1 == 0)
            {
                bb;
            }
        }
        if (i % 10 == y && f == x)
        {
            cnt++;
        }
    }
    return cnt;
}
int main()
{
    FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
        ll n;
    cin >> n;
    ve<pair<ll, ll>> v1;
    rep(i, 1, 10)
    {
        rep(j, i, 10)
        {
            v1.pb({i, j});
        }
    }
    ll ans = 0;
    // val(n, 1, 1);
    rep(i, 0, v1.size())
    {
        ll x = v1[i].first, x1 = v1[i].second;
        ll y = v1[i].second, y1 = v1[i].first;
        // cout<<"x.. "<<x<<"\n";
        // cout<<"y.. "<<y<<"\n";
        ll a1 = val(n, x, y);
        ll a2 = val(n, x1, y1);
        // cout<<"a1.. "<<a1<<" a2.. "<<a2<<"\n";
        if (x==y)
        ans += a1*a2;
        else
        {
            ans+=2*a1*a2;
        }
    }
    cout << ans << "\n";
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

// 頂点をインデックスで管理
struct UnionFind
{
    std::vector<int> rank, p, cnt;
    set<int> roots;

    UnionFind(){};
    UnionFind(int size)
    {
        init(size);
    }

    void init(int size)
    {
        rank.resize(size, 0);
        p.resize(size, 0);
        cnt.resize(size, 0);
        for (int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x)
    {
        p[x] = x;
        rank[x] = 0;
        cnt[x] = 1;
        roots.insert(x);
    }

    bool same(int x, int y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)
    {
        if (same(x, y))
            return;
        link(findSet(x), findSet(y));
    }

    void link(int x, int y)
    {
        if (rank[x] > rank[y])
        {
            p[y] = x;
            roots.erase(y);
            cnt[x] += cnt[y];
        }
        else
        {
            p[x] = y;
            roots.erase(x);
            cnt[y] += cnt[x];
            rank[y] += (rank[x] == rank[y]);
        }
    }

    int findSet(int x)
    {
        if (x != p[x])
        {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }

    int setSize(int x)
    {
        return cnt[findSet(x)];
    }
};

void solve()
{
    LL N, M;
    cin >> N >> M;
    UnionFind uf(N);
    vector<pii> E(M);

    REP0 (i, M)
    {
        cin >> E[i].first >> E[i].second;
        E[i].first--;
        E[i].second--;
    }

    vector<LL> ans;
    ans.push_back(N * (N - 1) / 2);
    LL c = 0;

    for (int i = M - 1; i >= 0; i--)
    {
        int s = E[i].first, t = E[i].second;

        if (!uf.same(s, t))
            c = LL(uf.setSize(s)) * LL(uf.setSize(t));
        else
            c = 0;

        ans.push_back(ans.back() - c);

        uf.unite(s, t);
    }

    for (int i = M - 1; i >= 0; i--) cout << ans[i] << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

int main() {
  int K;
  cin >> K;
  
  int A, B;
  cin >> A >> B;
  
  bool ans = false;  // 始めはfalseにしておき、条件を満たすときにtrueになるようにする
 
  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      ans = true;
    }
  }
  
   if (ans) {
      cout << "OK" << endl;
   }
  
   else {
      cout << "NG" << endl;
   }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int a = 0, b = 0;
	int len = s.length();
	for (char c : s) {
		a += (c == 'x');
		b += (c == 'o');
	}
	int cnt = 15 - len;
	cout << (cnt + b >= 8 ? "YES" : "NO");
}


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

int main() {
    vector<vector<int>> num(3, vector<int>(3)); 
    vector<vector<bool>> atari(3, vector<bool>(3, false)); 
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> num[i][j];
        }
    }
    int N; cin >> N;
    for (int i = 0; i < N; i++)
    {
        int b; cin >> b;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if(b==num[i][j]) atari[i][j] = true;
            }
        }
    }

    for (int i = 0; i < 3; i++)
    {
        if(atari[i][0] && atari[i][1] && atari[i][2] == true || atari[0][i] && atari[1][i] && atari[2][i] == true){
            cout << "Yes" << endl;
            return 0; 
        }
    }
    if(atari[0][0] && atari[1][1] && atari[2][2] == true || atari[2][0] && atari[1][1] && atari[0][2] == true ){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

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

double inf = numeric_limits<double>::infinity();

int main() {
    long x;
    cin >> x;
    
    long t = x / 11;
    if (x % 11 == 0) {
        cout << 2 * t << endl;
    } else {
        if (x % 11 <= 6) {
            cout << 2 * t + 1 << endl;
        } else {
            cout << 2 * t + 2 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using pii = pair<int, int>;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

//pow(llpow,modpow)
template <class T>
ll llpow(ll x, T n)
{
    ll ans = 1;
    if (x == 0)
        ans = 0;
    while (n)
    {
        if (n & 1)
            ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
template <class T>
inline T gcd(T x, T y)
{
    if (y == 0)
        return x;
    else
    {
        return gcd(y, x % y);
    }
}
//最小公倍数
template <class T>
inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
//逆元
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL << 60;
int main()
{
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vi a(n);
    rep(i, 0, n) cin >> a[i];
    int nx = 0;
    int ny = 0;
    bool dirc = true;
    vi buff;
    rep(c, 0, n)
    {
        int color = c + 1;
        rep(i, 0, a[c])
        {
            buff.push_back(color);
            if (dirc)
            {
                nx++;
            }
            else
            {
                nx--;
            }
            if (nx >= w )
            {
                rep(i,0,buff.size())cout<<buff[i]<<" ";
                cout<<endl;
                buff.clear();
                ny++;
                nx--;
                dirc^=true;
            }
            if(nx<0){
                reverse(buff.begin(),buff.end());
                rep(i,0,buff.size())cout<<buff[i]<<" ";
                cout<<endl;
                buff.clear();
                ny++;
                nx++;
                dirc^=true;
            }

        }
    }
}


Measured memory_bytes: 384
n, k, q = map(int, input().split())
a = [0]*q
point = [k-q]*(n+1)
for i in range(q):
	point[int(input())] += 1
for i in range(1,n+1):
	if point[i] <= 0:
		print('No')
	else:
		print('Yes')

Measured memory_bytes: 7364
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
Q = li2(M)
Q = sorted(Q, key=lambda x:x[1])

l = [N]*N
for i in range(M):
    ind = max(0, Q[i][0]-1)
    l[ind] = min(Q[i][1]-1, l[ind])

for i in reversed(range(N-1)):
    l[i] = min(l[i], l[i+1])

cnt = 0
i = 0
#print(l)
while True:
    i = l[i]
    cnt += 1
    if l[i] == N:
        break

print(cnt)

Measured memory_bytes: 92304
/**
*    created: 04.07.2020 20:51:00
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#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(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n;
    cin >> n;
    map<int,int> mp;
    rep(i,n) {
        int a;
        cin >> a;
        if (mp[a] == 0) mp[a]++;
        else mp.erase(a);
    }
    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 9884
#include<iostream>
#include<algorithm>
#include<numeric>
#include<iomanip>
using namespace std;
bool myfunction(int i, int j) { return (i > j); }
int main()
{
	long long N, M,a,b;
	cin >> N >> M;
	a = N % M;
	b = M - a;
	if (a < b)cout << a;
	else cout << b;
}






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

using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
int N, M;
int k[10];
int p[10];
int s[10][10];
signed main() {
  cin >> N >> M;
  REP(i,M) {
    cin >> k[i];
    REP(j,k[i]) {
      cin >> s[i][j];
      --s[i][j];
    }
  }
  REP(i,M) {
    cin >> p[i];
  }
  int ans = 0;
  // スイッチのbit全探索
  REP(bit, 1<<N) {
    bool lightOn = true;
    // 全ての電球について検査
    REP(i, M) {
      int onCounter = 0;
      // 全ての電球につながっているスイッチについて検査
      REP(j,k[i]) {
        if((bit>>s[i][j])&1) ++onCounter;
      }
      if(onCounter%2 != p[i]) {
        lightOn = false;
        break;
      }
    }
    if(lightOn) ++ans;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll a[10],b[10];
ll n;


ld compute(ll x1, ll y1, ll x2, ll y2)
{
    ld a1,a2,b1,b2;
    a1 = (x1-x2)*(x1-x2);
    a2 = (y1-y2)*(y1-y2);
    b1 = sqrtl(a1+a2);
    return b1;
}

ll fact(ll n)
{
    ll mul=1;
    for(ll i=2; i<=n; i++) mul*=i;
    return mul;
}

int main()
{
   fast;
   ll cc[10];
   cc[2]=2;
   for(ll i=3; i<=9; i++) cc[i] = cc[i-1]*(i-1);
   cin >> n;
   for(ll i=0; i<n; i++){
      ll aa,bb;
      cin >> aa >> bb;
      a[i]=aa,b[i]=bb;
   }
   ld sum=0;
   for(ll i=0; i<n; i++){
      for(ll j=i+1; j<n; j++){
         sum+=compute(a[i],b[i],a[j],b[j])*cc[n];
      }
   }
   cout << setprecision(12) << (sum/fact(n)) << "\n";


   return 0;
}


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

using namespace std;


void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int sum = 0;
    for (auto& x: a) {
        cin >> x;
        sum += x;
    }
    vector<int> d;
    for (int i = 1; i*i <= sum; i++) {
        if (sum % i == 0) {
            d.emplace_back(i);
            if (i*i < sum) {
                d.emplace_back(sum/i);
            }
        }
    }
    sort(d.begin(), d.end(), greater<int>());
    for (int x: d) {
        auto r = a;
        for (auto& y: r) {
            y %= x;
        }
        sort(r.begin(), r.end());
        vector<int> pre(n), suf(n);
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            pre[i] = tmp += r[i];
        }
        tmp = 0;
        for (int i = n-1; i >= 0; i--) {
            suf[i] = tmp += r[i];
        }
        int least = -1;
        int tot = suf[0];
        for (int i = n-1; i >= 0; i--) {
            if (tot == x*(n-i-1)) {
                least = pre[i];
                break;
            }
        }
        assert(least > -1);
        if (least <= k) {
            cout << x;
            break;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int N, W;
    cin >> N >> W;
    LL w, u;
    cin >> w >> u;
    vector< LL > v[4];
    v[0].pb(u);

    for( int i = 1; i < N; ++i ) {
        LL a, b;
        cin >> a >> b;
        v[a - w].pb(b);

    }

    for( int i = 0; i < 4; ++i ) {
        sort(all(v[i]), greater< LL >());

    }

    LL res = 0;
    LL w1 = 0, v1 = 0;
    for( int i = 0; i <= v[0].size(); ++i ) {
        if( i != 0 ) {
            ++w1;
            v1 += v[0][i - 1];

        }
        LL w2 = 0, v2 = 0;
        for( int j = 0; j <= v[1].size(); ++j ) {
            if( j != 0 ) {
                ++w2;
                v2 += v[1][j - 1];

            }
            LL w3 = 0, v3 = 0;
            for( int k = 0; k <= v[2].size(); ++k ) {
                if( k != 0 ) {
                    ++w3;
                    v3 += v[2][k - 1];

                }
                LL w4 = 0, v4 = 0;
                for( int l = 0; l <= v[3].size(); ++l ) {
                    if( l != 0 ) {
                        ++w4;
                        v4 += v[3][l - 1];

                    }
                    if( w1 * w + w2 * (w + 1) + w3 * (w + 2) + w4 * (w + 3) <= W ) {
                        res = max(res, v1 + v2 + v3 + v4);

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



Measured memory_bytes: 256
// Karm Kar, Phal Ki Chinta na Kar:)
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
int main()
{
    ll n;
    cin>>n;

    string s;
    cin>>s;
    if(n==1)
    {
        cout<<1;
    }
    else
    {
    ll ans=0,res=0;
    ll i;
    for(i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1])
        {
            ans++;
        }
        else
        {
            ans=0;
            res++;
        }
    }
    cout<<res+1;
    }

}



Measured memory_bytes: 512
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      h: usize,
      w: usize,
      k: usize,
      c: [Bytes; h]
   }

   let mut ans = 0;
   for n in 0..(1 << h) {
      for m in 0..(1 << w) {
         let mut xs = BTreeSet::new();
         let mut ys = BTreeSet::new();
         for i in 0..h {
            if (n >> i) & 1 == 1 {
               xs.insert(i);
            }
         }
         for i in 0..w {
            if (m >> i) & 1 == 1 {
               ys.insert(i);
            }
         }
         let mut x = 0;
         for i in 0..h {
            for j in 0..w {
               if !xs.contains(&i) && !ys.contains(&j) && c[i][j] == b'#' {
                  x += 1;
               }
            }
         }
         if x == k {
            ans += 1;
         }
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 2208
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  vector <int> a(N);
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  cout << a[(N/2)] - a[(N/2)-1] << endl;
  return 0;
}


Measured memory_bytes: 640
D, G = map(int, input().split())
problems = [tuple(map(int, input().split())) for i in range(D)]

ans = 1000
for i in range(1 << D):
    S = G
    P = 0
    max_j = 0
    for j in range(D):
        if i >> j & 1 == 1:
            P += problems[j][0]
            S -= 100 * (j + 1) * problems[j][0] + problems[j][1]
        else:
            max_j = j
    if S > 0:
        p = 100 * (max_j + 1)
        need = (S + p - 1) // p
        if need >= problems[max_j][0]:
            continue
        P += need
    ans = min(P, ans)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
constexpr int mod = 1e9 + 7;
constexpr int maxn = 2e6 + 10;
LL fac[maxn], ifac[maxn];
int inv_t[maxn];
void inv_table(int n, int mod) {
  inv_t[1] = 1;
  for (int i = 2; i < n; ++i)
    inv_t[i] = (mod - 1LL * (mod / i) * inv_t[mod % i] % mod) % mod;
}

void init_fac(int n, int mod) {
  fac[0] = ifac[0] = 1;
  inv_table(n, mod);
  for (int i = 1; i < n; ++i) {
    fac[i] = fac[i - 1] * i % mod;
    ifac[i] = ifac[i - 1] * inv_t[i] % mod;
    assert(fac[i] * ifac[i] % mod == 1);
  }
}
int main() {
  init_fac(maxn, mod);
  ios_base::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  const int m = s.size();
  const int nm = n + m;
  LL ans = 0;
  LL d = 1;
  for (int i = nm; i >= m; --i) {
    LL f = (ifac[i] * ifac[nm - i] % mod) * fac[nm] % mod;
    ans += f * d;
    ans %= mod;
    d = d * 25 % mod;
  }
  cout << ans << endl;
  return 0;
}



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

int main()
{
    int count=0;
    int n;
    cin>>n;
    int a[n];

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

    int q;
    cin>>q;
    int x;
    for(int i=0;i<q;i++)
    {
        cin>>x;
        for(int j=0;j<n;j++)
        {
            if(x==a[j])
            {
                count++;
                break;
            }
        }
    }

    cout<<count<<endl;
    return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

long double R = 1e6;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<long double> x(n), y(n), cnt(n, 0);
    rep(n){
        cin >> x[i] >> y[i];
    }

    rep(2*(int)R){
        long double xs = cos(((long double)i / (2.0*R)) * 2.0 * M_PI);
        long double ys = sin(((long double)i / (2.0*R)) * 2.0 * M_PI);
        long double mindist = 1e20;
        int mindist_point;
        repp(j, n){
            // long double d = x[j]*x[j] + y[j]*y[j] - 2*R*(xs*x[j]+ys*y[j]) + R*R;
            long double d = -xs*x[j]-ys*y[j];
            if(mindist > d){
                mindist = d;
                mindist_point = j;
            }
        }
        cnt[mindist_point] += 1.0;
    }
    rep(n){
        cnt[i] /= 2.0*R;
        printf("%.6Lf\n", cnt[i]);
    }
}


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

int main() {
    string a,b;
    cin >> a >> b;
    if (a == "H") {
        cout << b << endl;
        return 0;
    } else {
        if (b == "H") {
          cout << "D" << endl;
        } else {
          cout << "H" << endl;
        }
    }
}


Measured memory_bytes: 256
n,x= map(int, input().split())
if(x%2!=0):
    print("No")
else:
    tp=x//2
    tp=tp-n
    if(tp<0):
        print("No")
    else:
        tp*=2
        tp=(x//2)-tp
        if(tp<0):
            print("No")
        else:
            print("Yes")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 1030, M = N << 1;

int n, m, b[N][N], a[N][N];

inline int popcnt(int x)
{
	int res = 0;
	while (x)
	{
		if (x & 1) ++res;
		x >>= 1;
	}
	return res;
}

int main()
{
	//File("");
	n = gi(), m = gi();
	int r = 1, c = 1;
	for (int i = 1; i <= n; i+=1) r <<= 1;
	for (int i = 1; i <= m; i+=1) c <<= 1;
	--r, --c;
	for (int i = 1; i <= r; i+=1)
		for (int j = 1; j <= c; j+=1)
			b[i][j] = popcnt(i & j) % 2;
	for (int i = 1; i <= r; i+=1)
	{
		for (int j = 1; j <= c; j+=1)
			a[i][j] = ((b[i][j] - b[i - 1][j] - b[i][j - 1] + b[i - 1][j - 1]) % 2 + 2) % 2,
				printf("%d", a[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 11880
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> d[10];

	rep(i,s.size()) {
		d[s[i] - '0'].push_back(i);
	}

	int ans = 0;

	rep(i, 10)rep(j, 10)rep(k, 10) {
		int p = -1;
		auto it = upper_bound(all(d[i]), p);
		if (it == d[i].end())continue;
		p = *it;

		it = upper_bound(all(d[j]), p);
		if (it == d[j].end())continue;
		p = *it;

		it = upper_bound(all(d[k]), p);
		if (it == d[k].end())continue;
		p = *it;
		ans++;
	}


	cout << ans << endl;



	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define str(n) to_string(n)
#define int(w) stoi(w)
#define len(l) l.size()
#define append(l,i) l.push_back(i)
void dfs(int s,vector<int> prev,int &count,vector<vector<int>> &g){
    for (int x :g.at(s)){
        if (prev.at(x-1)==1){
            continue;
        }
        else{
            prev.at(x-1)=1;

            int b=1;
            rep(i,prev.size()){
                if (prev.at(i)==0){
                    b=0;
                }
            }
            if (b==0){
                dfs(x,prev,count,g);
                prev.at(x-1)=0;
            }
            else{
                count+=1;
            }
            
        }
    }
}
int main() {
    vector<vector<int>> g;
    int n,m;
    cin>>n>>m;
    rep(i,n+1){
        append(g,{});
    }
    int a,b;
    rep(i,m){
        cin>>a>>b;
        append(g.at(a),b);
        append(g.at(b),a);
    }
    vector<int> prev;
    rep(i,n){
        append(prev,0);
    }
  prev.at(0)=1;
    int count=0;
    dfs(1,prev,count,g);
    cout<<count<<endl;



    return 0;
}

Measured memory_bytes: 256