akhauriyash/Code-Regression huggingface dataset:
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


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

int main()
{
	optimize();

	int n, a;
	cin >> n;
	map<int,int> cnt;

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

	ll ans = 0;
	for ( auto u : cnt ) {
		if ( u.F > u.S ) ans += ( u.S );
		else ans += ( u.S - u.F );
	}

	cout << ans << endl;

	return 0;
}


















Measured memory_bytes: 8012
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input!{
        a: usize, b: usize, c: usize
    }
    if a+b >= c { println!("Yes"); } else { println!("No"); }
}

Measured memory_bytes: 4352
import core.bitop;
import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto k = input.front.to!( long );
	
	bool[ dstring ] ts;
	foreach( i; 0L .. s.length.signed )
	{
		foreach( j; i + 1 .. min( i + k, s.length.signed ) + 1 )
		{
			ts[ s[ i .. j ].idup ] = true;
		}
	}
	return ts.keys.sort()[ k - 1 ];
}


Measured memory_bytes: 4720
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] c = sc.next().toCharArray();
    if(c.length==2){
      if(c[0]==c[1])System.out.println(1+" "+2);
      else System.out.println(-1+" "+-1);
      return;
    }
    for(int i = 0;i <= c.length-3;i++){
      char x = c[i];
      char y = c[i+1];
      char z = c[i+2];
      if(x==y||y==z||z==x){
        System.out.println((i+1)+" "+(i+3));
        return;
      }
    }
    System.out.println(-1+" "+-1);
  }
}

Measured memory_bytes: 27860
import sys


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def main():
    n, q = map(int, sys.stdin.buffer.readline().split())
    bit = Bit(n)
    a = list(map(int, sys.stdin.buffer.readline().split()))
    for i in range(n):
        bit.add(i+1, a[i])
    for x in sys.stdin.buffer.readlines():
        q, p, x = map(int, x.split())
        if q:
            print(bit.sum(x) - bit.sum(p))
        else:
            bit.add(p+1, x)


if __name__ == "__main__":
    main()


Measured memory_bytes: 89996
#include <iostream>
#include <algorithm>
#include <string>

int main(){
    std::string str;
    int q;
    std::cin >> str >> q;

    std::string cmd;
    int a, b;
    for(int i = 0; i < q; ++i){
        std::cin >> cmd >> a >> b;
        if("print" == cmd){
            std::cout << str.substr(a, b - a + 1) << std::endl;
        }else if("reverse" == cmd){
            std::reverse(str.begin() + a, str.begin() + b + 1);
        }else if("replace" == cmd){
            std::string p;
            std::cin >> p;
            str.replace(a, b - a + 1, p);
        }
    }

    return 0;
}


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


int main() {
    int N, A;

    cin >> N;
    for (int i = 0; i < N; i++) {

        cin >> A;

        if (A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
                cout << "DENIED" << endl;
                break;
        }
        if (i+1 == N) {
            cout << "APPROVED" << endl;
        }

    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
    int i = 0;
    for (int j = 0; j < k; j++) {
        llong s = 0;
        while(s + T[i] <= P ) {
            s += T[i];
            i++;
            if ( i == n) return n;
        }
    }
    return i;
}

int solve() {
    llong left = 0;
    llong right = 100000 * 10000;
    llong mid;
    while( right - left > 1) {
        mid = (left + right) /2;
        int v = check(mid);
        if ( v >= n) right = mid;
        else left = mid;
    }
    
    return right;
}

main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
}


Measured memory_bytes: 3904
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
long long const INF = 1LL << 60;


int main()
{
    int n,m;
    cin >> n >> m;
    vector<ll> x(n),y(n),z(n);
    rep(i,n) cin >> x[i] >> y[i] >> z[i];


    ll res = -INF;
    rep(p,2) {
        rep(q,2) {
            rep(r,2) {
                vector<ll> v(n);
                rep(i,n) v[i] = (p?1:-1)*x[i] + (q?1:-1)*y[i] + (r?1:-1)*z[i];
                sort(v.rbegin(), v.rend());
                ll sum = 0;
                rep(i,m) sum += v[i];
                chmax(res,sum);
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3644
n = int(input())
H = list(map(int,input().split()))

for i in range(n-1):
  if H[i] == 1+ H[i+1]:
    H[i+1] += 1
  elif H[i] >1+ H[i+1]:
    print('No')
    break
else:
  print('Yes')


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

typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e3 + 3;

char grid[maxn][maxn];
ll dp[maxn][maxn];

void add_self(ll &a, ll b) {
    a += b;
    if (a >= mod)
        a -= mod;
}

int main() {

    int H, W;
    scanf("%d%d", &H, &W);

    for (int i = 0; i < H; ++i) {
        scanf("%s", grid[i]);
    }

    dp[0][0] = 1;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (grid[i][j] == '.') {
                if (i-1 >= 0) add_self(dp[i][j], dp[i-1][j]);
                if (j-1 >= 0) add_self(dp[i][j], dp[i][j-1]);
            }
        }
    }

    printf("%lld\n", dp[H-1][W-1]);
}

Measured memory_bytes: 9088
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n,i;
	string s;
	n=s.size();
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
	{
		cout<<"Bad";
	}
	else 
	{
		cout<<"Good";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    char op;    //文字にする
    while (1){
    cin >> a >> op >> b;
    if (op == '+'){
        cout << (a+b) << endl;
    } else if ( op == '-' ){
        cout << (a-b) << endl;
    } else if ( op == '*' ){
        cout << (a*b) << endl;
    } else if ( op == '/' ){
        cout << (a/b) << endl;
    } else {
        break;
    }
    }
}


Measured memory_bytes: 3068
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int n, d;
    int x[10][10];
    double dist;

    int i, j, k;
    int count, temp;

    cin >> n;
    cin >> d;

    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            cin >> x[i][j];
        }
    }

    count = 0;

    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            dist = 0;
            for(k=0;k<d;k++){
                temp = (x[i][k] - x[j][k]);
                dist += temp * temp;
            }
            dist = sqrt(dist);

            if(ceil(dist) == floor(dist)){
                count++;
            }
        }
    }

    cout << count;
    return 0;








}

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

  
int main() {
	int n, gcd, x;
	cin >> n >> x;
	vector<int> a(n);
	for(int i = 0; i < n; ++i) cin >> a[i];
	
	a.push_back(x);
	sort(a.begin(), a.end());
	
	for(int i = 1; i < a.size(); ++i){
		int numero = a[i] - a[i - 1];
		if(i == 1) gcd = numero;
		else gcd = __gcd(gcd, numero);
	}
	cout << gcd << endl;
	
	return 0;
}

Measured memory_bytes: 1024
import math
import copy
import sys
import bisect
input = sys.stdin.readline

def main():
    n=int(input())
    a = list(map(int,input().split()))
    b=[0 for _ in range(n)]
    for i in range(n):
        b[i]=a[i]-i-1
    b.sort()
    if n%2==1:
        mid=b[(n-1)//2]
        ans=0
        for i in range(n):
            ans+=abs(b[i]-mid)
        print(ans)
    else:
        mid = (b[(n//2)-1]+b[(n//2)])//2
        ans=float('inf')
        for i in range(mid,mid+2):
            ans1=0
            for j in range(n):
                ans1+=abs(b[j]-i)
            ans=min(ans1,ans)
        print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;
int c[1000];//97
int main()
{
int n,mi=10000,mi1=10000,mi2=10000,mi0=2000,z=10000,x=100000;
    char a[100000];
    scanf("%s",a);
    n=strlen(a);
    for(int i=0;i<n-2;i++){
        mi0=(a[i]-'0')*100;
        mi1=(a[i+1]-'0')*10;
        mi2=(a[i+2]-'0');
        mi0=mi0+mi1+mi2;
        mi0=abs(mi0-753);
        mi=min(mi0,mi);
    }
    printf("%d",mi);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = n/(a+b)*a+min(a, n%(a+b));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INFTY (1 << 21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int M[100][100];

int Prim();

int main(){
  int i, j, a;
  int P;

  scanf("%d",&n);
for(i=0;i<n;i++)

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      scanf("%d",&a);
      M[i][j] = a;
      if(M[i][j] == -1) M[i][j] = INFTY;
    }
  }

  P = Prim();
  printf("%d\n",P);

  return 0;
}

int Prim(){
  int i, u, min;
  int d[100], p[100], color[100];
  int sum = 0;

  for(i = 0 ; i < n ; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    min = INFTY;
    u = -1;
    for(i = 0 ; i < n ; i++){
      if(min > d[i] && color[i] != BLACK){
 u = i;
 min = d[i];
      }
    }

    if(u == -1) break;

    color[u] = BLACK;
    for(i = 0 ; i < n ; i++){
      if(color[i] != BLACK && M[u][i] != INFTY){
 if(d[i] > M[u][i]){
   d[i] = M[u][i];
   p[i] = u;
   color[i] = GRAY;
 }
      }
    }
  }

  for(i = 0 ; i < n ; i++){
    if(p[i] != -1) sum += M[i][p[i]];
  }

  return sum;
}



Measured memory_bytes: 2108
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    string s ;
    cin >> s ;
    size_t n = s.length();

    int count = 0 ;
    
        for(int i = 0 ; i < (int)n/2; i++ ){
            if(s[i] != s[n-1 - i]){
                count++ ;
               
            }
           
        }
   
       
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int32_t N, K, X, Y;
	cin >> N >> K >> X >> Y;

	if (N < K) {
		cout << N * X << endl;
	} else {
		cout << K * X + (N - K) * Y << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#![allow(dead_code)]
use std::io;

fn main() {
    solve_a();
}

fn solve_d() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();

    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<i64> = x.trim()
        .split(' ')
        .map(|s| s.parse::<i64>().unwrap())
        .collect();

    let mut max = -1 * 1_000_000_i64;
    let mut min = 1_000_000_i64;
    let mut sum = 0;

    for i in v {
        if max < i {
            max = i;
        }
        if i < min {
            min = i;
        }
        sum += i;
    }
    println!("{} {} {}", min, max, sum);
}

fn solve_c() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<&str> = x.trim().split(' ').collect();

        let a = v[0].parse::<i64>().unwrap();
        let op = v[1].to_string();
        let b = v[2].parse::<i64>().unwrap();
        if op == "+".to_string() {
            println!("{}", a + b);
        } else if op == "-".to_string() {
            println!("{}", a - b);
        } else if op == "*".to_string() {
            println!("{}", a * b);
        } else if op == "/".to_string() {
            println!("{}", a / b);
        } else {
            break;
        }
    }
}

fn solve_b() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();
    let r = x.trim().parse::<f64>().unwrap();

    println!(
        "{:.6} {:.6}",
        r * r * std::f64::consts::PI,
        2_f64 * r * std::f64::consts::PI
    );
}

fn solve_a() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<u64> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        let h = v[0];
        let w = v[1];
        if h == 0 && w == 0 {
            break;
        } else {
            for _i in 0..h {
                for _j in 0..w {
                    print!("#");
                }
                print!("\n");
            }
            print!("\n");
        }
    }
}



Measured memory_bytes: 5020
// https://atcoder.jp/contests/abc132/tasks/abc132_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}


#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        s: chars
    };
    let mut mp = HashMap::new();
    for si in s {
        let v = *mp.get(&si).unwrap_or(&0);
        mp.insert(si, v+1);
    }
    let mut ok = mp.len() == 2;
    for (k, v) in mp {
        if v != 2 {
            ok = false;
        }
    }

    println!("{}", ifv!(ok, "Yes", "No"));
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        String temp = scan.nextLine();
        String s = scan.nextLine();
        if(a >= 3200){
            System.out.println(s);
        }
        else{
            System.out.println("red");
        }

    }
}


Measured memory_bytes: 22612
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n, t, a;
    cin >> n >> t >> a;
    vector<ll> H(n);
    for (auto & h : H ) {
        cin >> h;
    }
    ll k = 0;
    ll cur = 1000 * 1000;
    for (ll i = 0; i < n; ++i) {
        auto h = H[i];
        auto tmp = abs(a * 1000 - (t * 1000 - h * 6));
        if (tmp < cur) {
            cur = tmp;
            k = i;
        }
        //cerr << i << ":" << tmp << endl;
    }
    cout << k + 1 << endl;
}


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

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

    int prev = 0;
    for (int i = 0; i < N; ++i)
    {
        if (S[i] == '.')
        {
            ++prev;
        }
    }

    int ans = prev;
    for (int i = 0; i < N; ++i)
    {
        int cur = S[i] == '.' ? prev - 1 : prev + 1;
        ans = std::min(ans, cur);
        prev = cur;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)1e3 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = (int)1e9 + 7;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

int main() {
//    freopen("../in.txt", "r", stdin);
    int n, m;
    int p[12], k, s;
    vector<int> S[13];
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i) {
        scanf("%d", &k);
        while (k--) {
            scanf("%d", &s);
            S[i].push_back(s-1);
        }
    }
    for (int i = 0; i < m; ++i) {
        scanf("%d", p+i);
    }
    int ans = 0;
    for (int i = (1<<n)-1; i >= 0; --i) {
        int cnt = 0;
        for (int j = 0; j < m; ++j) {
            k = 0;
            for (int x : S[j]) {
                if ((1<<x)&i) {
                    ++k;
                }
            }
            if (k%2==p[j]%2) {
                ++cnt;
            } else {
                break;
            }
        }
        if (cnt==m) {
            ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main() {
    std::string s;
    std::cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '9') {
            s[i] = '1';
        }
        else if (s[i] == '1') {
            s[i] = '9';
        }
    }
    std::cout << s << std::endl;
}


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


int main(){
    int    x1, x2, x3, x4, x5;

    scanf("%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);

    if     ( x1 == 0 ){ printf("1\n"); }
    else if( x2 == 0 ){ printf("2\n"); }
    else if( x3 == 0 ){ printf("3\n"); }
    else if( x4 == 0 ){ printf("4\n"); }
    else if( x5 == 0 ){ printf("5\n"); }
    
    return 0;
}

Measured memory_bytes: 1620
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

template <typename T>
T clamp(T x, T mini, T maxi) {
  return min(max(x, mini), maxi);
}

int main() {
  int n;
  scanf("%d", &n);

  int bucket[6] = {};
  for (int i = 0; i < n; i++) {
    int height;
    scanf("%d.%*d", &height);
    bucket[clamp((height - 160) / 5, 0, 5)]++;
  }
  for (int i = 0; i < 6; i++) {
    cout << i + 1 << ':' << string(bucket[i], '*') << '\n';
  }
  return 0;
}

Measured memory_bytes: 1216
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n;
int a[1<<18],b[1<<18],s[8<<17];
int fail[8<<17];

int main(){
	scanf("%d",&n);
	loop(i,n)scanf("%d",a+i);
	loop(i,n)scanf("%d",b+i);
	loop(i,n){
		s[i]=(a[i]^a[(i+1)%n]);
		s[i+n]=s[i+n+n]=(b[i]^b[(i+1)%n]);
	}
	s[n]=-1;
	int now=fail[0]=-1;
	loop(i,3*n){
		while(~now&&s[i]!=s[now])now=fail[now];
		fail[i+1]=++now;
	}
	loop(i,n)if(fail[n*3-i]==n)printf("%d %d\n",i,a[i]^b[0]);
	return 0;
}

Measured memory_bytes: 10016
#include <bits/stdc++.h>
#define INF 1e+18
#define int long long
using namespace std;

signed main(){
	int n,m,dp[10010],match[] = {0,2,5,5,4,5,6,3,7,6};
	string ans = "";
	bool ok[15] = {};
	cin >> n >> m;
	for(int i = 0;i <= n;i++) dp[i] = -1;
	dp[0] = 0;
	for(int i = 0;i < m;i++){
		int a;
		cin >> a;
		ok[a] = true;
	}
	for(int i = 0;i < n;i++){
		for(int j = 1;j <= 9;j++){
			if(ok[j]) dp[i + match[j]] = max(dp[i + match[j]],dp[i] + 1);
		}
	}
	while(n){
		int num;
		for(int i = 9;i >= 1;i--){
			if(ok[i] && n >= match[i] && dp[n - match[i]] == dp[n] - 1){
				num = i;
				break;
			}
		}
		ans += (char)(num + '0');
		n -= match[num];
	}
	cout << ans << endl;
}

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

int main(){

    int number;
    char c;
    double weight,tall;
    vector<int> ans;

    while(cin >> number >> c >> weight >> c >> tall){
        if(weight/(tall*tall) >= 25.0){
            ans.push_back(number);
        }
    }

    vector<int>::iterator it = ans.begin();

    for(;it != ans.end();){
        cout << *it << endl;
        it++;
    }

    return 0;
}

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

lli n;

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

lli lcm(lli a, lli b){
	lli g = gcd(a, b);
	return a/g*b;
}

int main(void){
	cin >> n;
	vector<lli> t(n);
	lli ans = 1;
	rep(i, n){
		cin >> t[i];
		ans = lcm(ans, t[i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3580
n, m = [int(i) for i in input().split()]

k =[]
for i in range(n):
    k1 = [int(i) for i in input().split()]
    k.append(k1)

num = [0]*m

for i in k:
    for j in range(len(i)):
        if j != 0:
            num[i[j]-1] +=1


ans =0
for i in num:
    if i == n:
      ans+=1

print(ans)

Measured memory_bytes: 3064
from collections import deque

def BFS(s):
  q = deque()
  q.append(s)
  dist = [[10**10]*(W+2) for _ in range(H+2)]
  dist[s[0]][s[1]] = 0
  d = ((0,1),(0,-1),(1,0),(-1,0))
  far = []
  
  while len(q)>0:
    i,j = q.popleft()
    for di,dj in d:
      if field[i+di][j+dj] == "." and dist[i+di][j+dj] == 10**10:
        q.append([i+di,j+dj])
        dist[i+di][j+dj] = dist[i][j]+1
    res = dist[i][j]
  
  return res



H,W = map(int,input().split())
field = ["#"*(W+2)]
field += ["#"+input()+"#" for _ in range(H)]
field += ["#"*(W+2)]
res = 0

for i in range(H+2):
  for j in range(W+2):
    if field[i][j] == ".":
      s = [i,j]
      res = max(res,BFS(s))
      
print(res)

Measured memory_bytes: 74328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Gcd(long a, long b)
        {
            return (a < b) ? Gcd(b, a)
                 : (b > 0) ? Gcd(b, a % b)
                           : a;
        }
        static bool Solve(long A, long B, long C, long D)
        {
            if (A < B) { return false; }
            if (D < B) { return false; }
            if (C >= B - 1) { return true; }
            if (B == 1) { return true; }
            long gcd = Gcd(B, D % B);
            long a = A % B;
            long b = (B - a - 1) / gcd;
            long c = a + b * gcd;
            return c <= C;
        }
        static void Main(string[] args)
        {
            int T = ReadInt();
            long[][] V = new long[T][];
            for (int i = 0; i < T; ++i) { V[i] = ReadLongs(); }
            foreach (var v in V) { Console.WriteLine(Solve(v[0], v[1], v[2], v[3]) ? "Yes" : "No"); }
        }
    }
}


Measured memory_bytes: 11220
# ABC088 B

def main():
    n = int(input())
    A = list(map(int, input().split()))

    Alice = 0
    Bob = 0
    A_sorted = sorted(A)[::-1]

    for i in range(n):
        if i % 2:
            Bob += A_sorted[i]
        else:
            Alice += A_sorted[i]
    
    print(Alice - Bob)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    lint n,m;cin>>n>>m;
    string s,t;cin>>s>>t;
    lint lcm=n/__gcd(n,m)*m;
    lint nc=lcm/n,mc=lcm/m;
    vector<pair<lint,char>> vec(0);
    int np=1,mp=1;
    for(int i=0;i<n;i++){
        vec.pb(make_pair(np,s[i]));
        np+=nc;
    }
    for(int i=0;i<m;i++){
        vec.pb(make_pair(mp,t[i]));
        mp+=mc;
    }
    sort(all(vec));
    lint rn=0;char rc;
    for(auto p:vec){
        if(p.first==rn){
            if(rc!=p.second)lcm=-1;
        }
        rn=p.first;
        rc=p.second;
    }
    cout<<lcm<<endl;
}


Measured memory_bytes: 7700
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
	while(cin >> s) {
		int p = 0, q = 0;
		for(int i = 2; i < s.size(); i++) {
			if(s.substr(i - 2, 3) == "JOI") p++;
			if(s.substr(i - 2, 3) == "IOI") q++;
		}
		cout << p << endl << q << endl;
	}
}

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

public class Main {
	
	static int cnt;
	static int vis[];
	static HashMap<Integer,ArrayList<Integer>> gph;
	
	static void dfs(int a) {
		vis[a]=1;
		cnt++;
		for(int x : gph.get(a)) {
			if(vis[x]!=1) {
				dfs(x);
			}
		}
	}

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt() , m = in.nextInt();
        gph = new HashMap<>();
        HashSet<Long> set = new HashSet<>();
        for(int i=0;i<m;i++) {
        	int a,b;
        	a = in.nextInt(); b = in.nextInt();
        	if(!set.contains(hashInt(a,b))) {
        		set.add(hashInt(a,b));set.add(hashInt(b,a));
        		if(gph.containsKey(a)) gph.get(a).add(b);
        		else {
        			ArrayList<Integer> ar = new ArrayList<>(); ar.add(b);
        			gph.put(a, ar);
        		}
        		if(gph.containsKey(b)) gph.get(b).add(a);
        		else {
        			ArrayList<Integer> ar = new ArrayList<>(); ar.add(a);
        			gph.put(b, ar);
        		}
        	}
        }

    	vis = new int[n+1];
        int ans = 0;
        for(int i=1;i<=n;i++) {
        	if(vis[i]!=1&&gph.containsKey(i)) {
        		cnt=0;
        		dfs(i);
        		ans = Math.max(ans, cnt);
        	}
        }
        out.println((m==0)?"1":ans);
        
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
	
	static boolean arrayEquals(char a[], char b[]) {
		int n = a.length;
		boolean verdict = true;
		for(int i=0;i<n;i++) {
			if(a[i]!=b[i]) {
				verdict = false;break;
			}
		}
		return verdict;
	}
	
	static long lcm(long a, long b) {
		return (a*b)/gcd(a,b);
	}
	
	static long gcd(long a, long b) {
		if(b==0) return a;
		else return gcd(b,a%b);
	}
	
	static long hashInt(int x,int y) {
		return x*(1_000_000_000L)+y;
	}
}










Measured memory_bytes: 150228
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,i;
  cin>>n;
  int s=0,arr[n];
  for(i=0;i<n;i++){
      cin>>arr[i];
      s^=arr[i];
  }
  for(i=0;i<n;i++)cout<<(s^arr[i])<<" ";
}

Measured memory_bytes: 4404
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef pair<int, int> P;

int dp[205];

int main()
{

	int n, m;
	while ( cin >> n && n ){
		vector <P> d;
		d.clear();
		memset (dp, 0, sizeof (dp ) );
		rep (i, n ){
			int h, r;
			cin >> h >> r;
			d.push_back (P (h, r ) );
		} // end rep 
		cin >> m;
		rep (i, m ){
			int h, r;
			cin >> h >> r;
			d.push_back (P (h, r ) );
		} // end rep
		sort (ALL (d ) );

		int res = 0;
		rep (i, n+m ){
			dp[i] = 1;
			rep (j, i ){
				if (d[j].first < d[i].first && d[j].second < d[i].second ) {
					dp[i] = max (dp[i], dp[j]+1 );
				} // end if
			} // end rep
			res = max (res, dp[i] );
		} // end rep
		cout << res << endl;
	} // end loop

	return 0;
}

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

int main(){
  string s;
  cin >> s;

  string ret = "NO";
  
  for(int i = 0;i < 8;i++){
    string sf = s.substr(0,i);
    string sl = s.substr(s.length()-(7-i),7-i);

    if(sf + sl == "keyence"){
      ret = "YES";
      break;
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*f;
}
const int N=5e3+10,mod=1e9+7;
int n,cnt,head[N],size[N],f[N][N],temp[N],g[N];
struct Edge{
	int v,next;
}e[N<<1];
inline void add(int u,int v)
{
	e[++cnt].v=v;
	e[cnt].next=head[u];
	head[u]=cnt;
}
inline void Add(int u,int v)
{
	add(u,v);
	add(v,u);
}
inline void dfs(int u,int fa)
{
	size[u]=1;
	f[u][1]=1;
	for(int i=head[u];i;i=e[i].next)
	{
		int v=e[i].v;
		if(v==fa) continue;
		dfs(v,u);
		memset(temp,0,sizeof(temp));
		for(int s=0;s<=size[u];s++)for(int x=0;x<=size[v];x++)
		{
			temp[s+x]+=f[u][s]*f[v][x];
			temp[s+x]%=mod;
		}
		size[u]+=size[v];
		for(int s=0;s<=size[u];s++)f[u][s]=temp[s];
	}
	int t=0;
	for(int i=1;i<=size[u];i++)t+=mod-f[u][i]*g[i]%mod;
	f[u][0]=t%mod;
}
signed main(void)
{
	n=read();
	for(int i=1;i<n;i++)Add(read(),read());
	g[0]=1;
	for(int i=2;i<=n;i+=2)g[i]=g[i-2]*(i-1)%mod;
	dfs(1,0);
	printf("%lld\n",mod-f[1][0]);
	return 0;
}

Measured memory_bytes: 194816
n=int(input())
l=list(map(int,input().split()))
count=0
for i in range(n):
    for j in range(i+1,n):
        if l[i]==l[j]:
            continue
        for k in range(j+1,n):
            if l[i]!=l[k] and l[j]!=l[k] and abs(l[i]-l[j])<l[k]<l[i]+l[j]:
                count+=1
print(count)


Measured memory_bytes: 68176
import numpy as np
N = int(input())
T = [np.array([int(i) for i in input().split()])for i in range(N)]
S = 0
for i in range(N-1):
    for j in range(i,N):
        S = S + np.linalg.norm(T[i]-T[j])
print(S*2/N)

Measured memory_bytes: 21848
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define pb push_back
#define mod 1000000007
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin>>c;
    int t;
    t=c;
    t++;
    if(c!='z')
    cout<<char(t)<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector <ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <vector<ll>> vv;
typedef vector <string> vs;
typedef vector <char> vc;
 
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
 
/*--------------------template--------------------*/
 
 
int main() {
    cin >> s;
    ll a[4] = { 0 };
    REP(i, 4) {
        a[i] = s[i] - '0';
    }
 
    ans = a[0] + a[1] + a[2] + a[3];
    if (ans == 7) {
        cout << a[0] << '+' << a[1] << '+' << a[2] << '+' << a[3] << "=7" << endl;
        return 0;
    }
    ans = a[0] + a[1] + a[2] - a[3];
    if (ans == 7) {
        cout << a[0] << '+' << a[1] << '+' << a[2] << '-' << a[3] << "=7" << endl;
        return 0;
    }
    ans = a[0] + a[1] - a[2] + a[3];
    if (ans == 7) {
        cout << a[0] << '+' << a[1] << '-' << a[2] << '+' << a[3] << "=7" << endl;
        return 0;
    }
    ans = a[0] + a[1] - a[2] - a[3];
    if (ans == 7) {
        cout << a[0] << '+' << a[1] << '-' << a[2] << '-' << a[3] << "=7" << endl;
        return 0;
    }
    ans = a[0] - a[1] + a[2] + a[3];
    if (ans == 7) {
        cout << a[0] << '-' << a[1] << '+' << a[2] << '+' << a[3] << "=7" << endl;
        return 0;
    }
    ans = a[0] - a[1] + a[2] - a[3];
    if (ans == 7) {
        cout << a[0] << '-' << a[1] << '+' << a[2] << '-' << a[3] << "=7" << endl;
        return 0;
    }
    ans = a[0] - a[1] - a[2] + a[3];
    if (ans == 7) {
        cout << a[0] << '-' << a[1] << '-' << a[2] << '+' << a[3] << "=7" << endl;
        return 0;
    }
    ans = a[0] - a[1] - a[2] - a[3];
    if (ans == 7) {
        cout << a[0] << '-' << a[1] << '-' << a[2] << '-' << a[3] << "=7" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	string s;
	cin >> s;
	
	int n = s.length();
	vvi dp(n + 1, vi(13, 0));
	dp[0][0] = 1;
	for(int i = 0; i < n; i++) {
		if(s[i] == '?') {
			for(int j = 0; j < 13; j++) {
				for(int k = 0; k < 10; k++) {
					(dp[i + 1][(10 * j + k) % 13] += dp[i][j]) %= P;
				}
			}
		} else {
			for(int j = 0; j < 13; j++) {
				(dp[i + 1][(j * 10 + (s[i] - '0')) % 13] += dp[i][j]) %= P;
			}
		}
	}
	
	cout << dp[n][5] << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 11980
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[7];
int main(){
	scanf("%s", s);
	if(s[2] == s[3] && s[4] == s[5]) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <stdio.h>

int mat[510][510];

int main()
{
    int N, M, Q;
    scanf("%d %d %d", &N, &M, &Q);

    for (int i = 0; i < M; i++) {
        int L, R;
        scanf("%d %d", &L, &R);

        for (int j = 1; j <= L; j++) {
            for (int k = R; k <= N; k++) {
                mat[j][k] += 1;
            }
        }

    }

    for (int i = 0; i < Q; i++) {
        int p, q;
        scanf("%d %d", &p, &q);
        printf("%d\n", mat[p][q]);
    }

    return 0;
}


Measured memory_bytes: 1920
# union-find
class UnionFind:
    def __init__(self, n):
        self.prsz = [-1] * n # parent & size
    def find(self, v): # root
        if self.prsz[v] < 0: return v
        self.prsz[v] = self.find(self.prsz[v])
        return self.prsz[v]
    def union(self, v, u): # unite
        v = self.find(v); u = self.find(u)
        if v == u: return False
        if self.prsz[v] > self.prsz[u]: v, u = u, v # size(v) < size(u)
        self.prsz[v] += self.prsz[u]
        self.prsz[u] = v
        return True

n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    uf.union(a, b)
ans = -1
for a in uf.prsz:
    if a < 0: ans += 1
print(ans)


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
int main()
{ int n,m;
cin>>n>>m;
char mat[n][m];
int mod=1e9+7;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++) cin>>mat[i][j];
int dp[n][m];
dp[0][0]=1;
for(int i=1;i<m;i++) if(mat[0][i]=='.') dp[0][i]=dp[0][i-1];
else dp[0][i]=0;
for(int i=1;i<n;i++) if(mat[i][0]=='.') dp[i][0]=dp[i-1][0];
else dp[i][0]=0;

for(int i=1;i<n;i++)
for(int j=1;j<m;j++) if(mat[i][j]=='#') dp[i][j]=0;
else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
cout<<dp[n-1][m-1];

return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n;
char s[1000],t[1000];
int main()
{
    n=read();scanf("%s",s+1);scanf("%s",t+1);
    for(reg int i=1;i<=n;++i)cout<<s[i]<<t[i];
	return 0;
}

Measured memory_bytes: 256
a500 = int(input())
b100 = int(input())
c50 = int(input())
X = int(input())
ans = 0
goukei = 0
is_over = False
for i in range(a500+1):
  for j in range(b100+1):
    for k in range(c50+1):
      goukei = i * 500 + j * 100 + k * 50
      if goukei == X:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>

#define ll long long
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

string to_string(string s){
    return s;
}

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

void debug(){
    cerr<<endl;
}

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

int main(){
    int N;
    cin>>N;
    if(N%2==0){
        cout<<N*(N-1)/2-N/2<<endl;
        for(int i=0;i<N;++i){
            for(int j=i+1;j<N;++j){
                if(i+j!=N-1){
                    cout<<i+1<<" "<<j+1<<endl;
                }
            }
        }
    }else{
        cout<<N*(N-1)/2-N/2<<endl;
        for(int i=0;i<N;++i){
            for(int j=i+1;j<N;++j){
                if(i+j!=N-2){
                    cout<<i+1<<" "<<j+1<<endl;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

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

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

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

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

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

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

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

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

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


uf = UnionFind(n)
al = [0] * m
bl = [0] * m
for i in range(m):
    al[i], bl[i] = map(int, input().split())

ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i == j:
            continue
        else:
            uf.union(al[j]-1, bl[j]-1)
    if uf.size(0) == n:
        continue
    else:
        ans += 1

print(ans)


Measured memory_bytes: 40816