akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

class RollingHash {
 private:
  const uint64_t mod = (1ULL << 61) - 1;
  std::vector<uint64_t> hashes, pows;

  inline uint64_t add(uint64_t a, uint64_t b) const {
    a += b;
    if (a >= mod) a -= mod;
    return a;
  }

  inline uint64_t sub(uint64_t a, uint64_t b) const {
    if (a < b) a += mod;
    a -= b;
    return a;
  }

  inline uint64_t mul(uint64_t a, uint64_t b) const {
    uint64_t ah = a >> 31, al = a & ((1ULL << 31) - 1), bh = b >> 31,
             bl = b & ((1ULL << 31) - 1), m = ah * bl + al * bh,
             v = (ah * bh << 1) + (m >> 30) + ((m & ((1ULL << 30) - 1)) << 31) +
                 al * bl;
    v = (v & ((1ULL << 61) - 1)) + (v >> 61);
    return v;
  }

 public:
  template <typename T>
  RollingHash(const T &S, uint64_t base = 10007)
      : hashes(S.size() + 1, 0), pows(S.size() + 1, 0) {
    pows[0] = 1;
    for (size_t i = 0; i < S.size(); i++) {
      pows[i + 1] = mul(pows[i], base);
      hashes[i + 1] = add(mul(hashes[i], base), S[i]);
    }
  }

  // S[r, l)
  uint64_t slice(int l, int r) const {
    return sub(hashes[r], mul(hashes[l], pows[r - l]));
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  string S;
  cin >> N >> S;
  RollingHash rhs(S);
  auto f = [rhs, N](int x) {
    map<uint64_t, int> mp;
    for (int i = 0; i < N - x + 1; i++) {
      if (mp.find(rhs.slice(i, i + x)) == mp.end()) {
        mp[rhs.slice(i, i + x)] = i;
      } else {
        if (mp[rhs.slice(i, i + x)] + x <= i) {
          return true;
        }
      }
    }
    return false;
  };
  int lo = 0, hi = N;
  while (lo < hi) {
    int mi = (lo + hi + 1) / 2;
    if (f(mi)) {
      lo = mi;
    } else {
      hi = mi - 1;
    }
  }
  cout << lo << '\n';
  return 0;
}


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

using namespace std;
typedef long long ll;

int ev[3][3];

int main()
{
    ios_base::sync_with_stdio(0);

    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> ev[i][j];

    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x; cin >> x;
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++)
                if (ev[j][k] == x)
                    ev[j][k] = -1;
    }

    bool win = false;
    for (int i = 0; i < 3; i++)
    {
        int d = 0, d2 = 0;
        for (int j = 0; j < 3; j++)
        {
            if (ev[i][j] == -1) d++;
            if (ev[j][i] == -1) d2++;
        }
        if (d == 3 || d2 == 3) win = true;
    }

    if (ev[0][0] + ev[1][1] + ev[2][2] == -3) win = true;
    if (ev[0][2] + ev[1][1] + ev[2][0] == -3) win = true;
    if (win) cout << "Yes\n";
    else cout << "No\n";
}

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

int main()
{
    
    int n;
    cin>>n;
    char s1[100];
    char s2[100];
    cin>>s1>>s2;
    char out[10000];
    int k=0;
    for(int i=0;i<n;i++)
    {
        out[k]=s1[i];
        k++;
        out[k]=s2[i];
        k++;
        
    }
    out[k]='\0';
    cout<<out;
    
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

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

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

fn digits(n: u64) -> Vec<char> {
    n.to_string().chars().collect()
}

fn dfs(n: u64, upper: u64) -> u64 {
    if n > upper {
        return 0;
    }
    let mut count = 0;

    let d = digits(n);
    if d.contains(&'3') && d.contains(&'5') && d.contains(&'7') {
        count += 1;
    }

    for &i in &vec![3, 5, 7] {
        count += dfs(10 * n + i, upper);
    }

    count
}

fn main() {
    let n = read!(u64);

    println!("{}", dfs(0, n));
}


Measured memory_bytes: 4352
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


def solve(x, y):
    min_legs = 2 * x
    max_legs = 4 * x
    return (min_legs <= y <= max_legs) and y % 2 == 0



if __name__ == "__main__":
    x, y = arr_in()
    out("Yes" if solve(x, y) else "No")

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

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

int dp[1010][1010][2]; 
bool graph[1010][1010];

int win(int odd,int even,int e){
	//cout << odd << " " << even << " " << e << endl;
	int &ret=dp[odd][even][e];
	if(ret) return ret;
	ret=-1;
	if(odd+even==1) return 1; // game end

	if(e && win(odd,even,e^1)==-1) ret=1; 
	if(odd>=2 && win(odd-2,even+1,e)==-1) ret=1; 
	if(even>=2 && win(odd,even-1,e^1)==-1) ret=1; 
	if(odd>=1 && even>=1 && win(odd,even-1,e^1)==-1) ret=1; 
	
	return ret;
}

int par[1010];
vector<int> comp[1010];

void init(int* par,int n){rep(i,n) par[i]=i;}
int find(int* par,int x){return (par[x]==x)?x:par[x]=find(par,par[x]);}
void unite(int* par,int a,int b){a=find(par,a),b=find(par,b);par[a]=b;}
bool same(int* par,int a,int b){return find(par,a)==find(par,b);}

int main(void){
	int v;
	cin >> v;
	
	init(par,v);
	rep(i,v)rep(j,v){
		char tmp;
		cin >> tmp;
		graph[i][j]=(tmp=='Y');
		if(graph[i][j]) unite(par,i,j);
	}

	int odd=0,even=0,e=0;
	rep(i,v) comp[find(par,i)].push_back(i);

	rep(i,v){
		int n=int(comp[i].size());
		//cout << n << endl;
		if(n==0) continue;
		rep(k,n)rep(j,k) if(graph[comp[i][j]][comp[i][k]]==false) e^=1;
		if(n&1)
			odd++;
		else
			even++;
	}

	//cout << odd << " " << even << " " << e << endl;

	if(win(odd,even,e)==1)
		puts("Taro");
	else
		puts("Hanako");
	return 0;
}

Measured memory_bytes: 7036
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
   int N,D;
   cin >> N >> D;
   double ans=N*1.0/(2*D+1);
   cout << ceil(ans) << endl;
}


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

int main()
{
	int n, a, b, c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c;
		int m = max(a, max(b, c));
		int l = min(a, b);
		int n = min(b, c);
		if (l == n) {
			n = min(a, c);
		}
		if (m*m == n*n + l*l) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3068
n,k=map(int,input().split())

l=list(map(int,input().split()))
mod=10**9+7

ain=0
aout=0

for i in range(n):
    for j in range(n):
        if l[i]>l[j]:
            aout+=1
            if i<j:
                ain+=1
ain*=k
aout*=k*(k-1)//2

print((ain+aout)%mod)

Measured memory_bytes: 3188
s = input()
counter = 1
buffer = 0
if 'R' not in s:
    print(0)
else:
    for i in range(len(s)):
        if s[i] == 'R':
            buffer += 1
        else:
            if buffer > counter:
                counter = buffer
            buffer = 0
        if buffer > counter:
            counter = buffer
    print(counter)

Measured memory_bytes: 8952
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll cntN = 0, cntW = 0, cntS = 0, cntE = 0;
    rep(i, s.size()) {
        if(s[i] == 'N') {
            cntN = 1;
        }
        else if(s[i] == 'W') {
            cntW = 1;
        }
        else if(s[i] == 'S') {
            cntS = 1;
        }
        else if(s[i] == 'E') {
            cntE = 1;
        }
    }

    if( (cntN + cntS == 1) || (cntW + cntE == 1) ) {
        out("No");
    }
    else {
        out("Yes");
    }

    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,d[SZ],up[SZ]; Edg
int pr[SZ],seg[SZ];
int qmin(int l,int r)
{
	int ans=1e9; ++l, ++r;
	for(l+=M-1,r+=M+1;l^r^1;l>>=1,r>>=1)
	{
		if(~l&1) ans=min(ans,seg[l^1]);
		if(r&1) ans=min(ans,seg[r^1]);
	}
	return ans;
}
bool mat(int l1,int r1,int r2)
{
	if(l1>r1) return 1;
	//for i in [l1,r1]
	//pr[i]>=r2+l1-i
	return qmin(l1,r1)>=l1+r2;
}
bool chk(int x,int l,int f=0)
{
	vector<int> ch;
	for esb(x,e,b) if(b!=f)
	{
		bool s=chk(b,l,x);
		if(!s||up[b]>l) return 0;
		ch.pb(up[b]);
	}
	sort(ch.begin(),ch.end());
	int s=ch.size();
	if(s%2==0) //easy
	{
		bool bad=0;
		for(int i=0;i<s/2;++i)
			if(ch[i]+ch[s-1-i]>l) bad=1;
		if(!bad) {up[x]=1; return 1;} --s;
	}
	for(int i=0,j=s-1;i<s;++i)
	{
		while(j>=0&&ch[i]+ch[j]>l) --j;
		pr[i]=j;
	}
	M=1; while(M<=s+3) M<<=1;
	for(int i=0;i<s;++i) seg[i+M+1]=pr[i]+i;
	for(int i=M-1;i>=1;--i)
		seg[i]=min(seg[i+i],seg[i+i+1]);
	up[x]=-1;
	for(int i=0;i<s;++i)
	{
		bool c1=0;
		if(i<s/2)
			c1=mat(0,i-1,s-1)&&mat(i+1,s/2,s-i-1);
		else
			c1=mat(0,s-i-2,s-1)&&mat(s-i-1,s/2-1,i-1);
		if(!c1) continue;
		up[x]=ch[i]+1; break;
	}
	if(up[x]==-1) return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1,a,b;i<n;++i)
		scanf("%d%d",&a,&b),adde(a,b),++d[a],++d[b];
	int ans=n,ro=1;
	for(int i=n;i>=1;--i)
		if(d[i]&1) ro=i;
	for(int i=1;i<=n;++i)
		ans-=(d[i]-(i!=ro)+1)/2;
	printf("%d ",ans);
	int l=0,r=n;
	while(l<r)
	{
		int m=(l+r)>>1;
		bool s=chk(ro,m);
		if(s&&up[ro]<=m+1) r=m; else l=m+1;
	}
	printf("%d\n",l);
}


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

int main() {
  char c;
  cin >> c;
  cout << (char)(c+1) << endl;
    
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

x,y = map(int, input().split())
leg2 = 0 
leg4 = x
flg =  0
while(leg4!=-1):
    if leg2*2 + leg4*4 == y:
        flg = 1
        break
    else:
        leg2 += 1
        leg4 -= 1
    #print(i,leg2*2 + leg4*4)

if flg == 1:
    print("Yes")
else:
    print("No")

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;
    vector<char> array(N, 0);

    ll red_count = 0;
    REP(i, N){ 
        cin >> array[i];
        if (array[i] == 'R'){
            red_count++;
        }
    }

    ll count = 0;
    for(int i = 0 ; i < red_count; i++ ){
        if( array[i] == 'W' ){
            count++;
        }
    }
     
    cout << count << endl;
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

signed main() {
    ll n, m;
    cin >> n >> m;
    while(n != 0 || m != 0) {
        VL a(n);
        for(int i = 0; i < n; i++) {
            cin >> a[i];
        }
        string ans = "NONE";

        ll tmp = 0;
        for(int i = 0; i < n - 1; i++) {
            for(int j = i + 1; j < n; j++) {
                if(a[i] + a[j] <= m) {
                    tmp = max(tmp, a[i] + a[j]);
                    ans = to_string(tmp);
                }
            }
        }

        cout << ans << endl;
        cin >> n >> m;
    }
}



Measured memory_bytes: 3220
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var a = rstr();
        int ans = 0;
        for(int i = 0; i < a.Length; i++)
        {
            ans += a[i] -  '0';
            ans %= 9;
        }
        if(ans%9 == 0)
        {
            Write("Yes");
        }
        else
        {
            Write("No");
        }
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 26684
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;

vector<int> topological_sort(const graph& G) {
	int n = G.size();
	vector<int> used(n), idx; idx.reserve(n);
	function<void(int)> dfs = [&](int v) {
		used[v] = true;
		for (int w : G[v]) if (!used[w]) dfs(w);
		idx.push_back(v);
	};
	for (int i = n - 1; i >= 0; i--) {
		if (!used[i]) dfs(i);
	}
	reverse(idx.begin(), idx.end());
	return idx;
}

const int mod = 1e9 + 7;

int main()
{
	int H, W;
	cin >> H >> W;
	graph G(H * W);
	vector<string> s(H);
	for (int i = 0; i < H; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) if (s[i][j] != '#') {
			if (i + 1 < H && s[i + 1][j] != '#') {
				G[i * W + j].push_back((i + 1) * W + j);
			}
			if (j + 1 < W && s[i][j + 1] != '#') {
				G[i * W + j].push_back(i * W + j + 1);
			}
		}
	}
	auto id = topological_sort(G);
	vector<int> dp(H * W);
	dp[0] = 1;
	for (auto v : id) {
		for (auto to : G[v]) {
			dp[to] += dp[v];
			if (dp[to] >= mod) dp[to] -= mod;
		}
	}
	cout << dp.back() << endl;
	return 0;
}


Measured memory_bytes: 63804
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;  

#define pb push_back
#define ll long long int
#define db double
#define SORTA(v) sort(v.begin(),v.end())
#define SORTD(v) sort(v.begin(),v.end(),greater<>())
#define endl '\n'
#define nod(N) floor(log10(N)) + 1
#define LB(a) lower_bound(a)
#define UB(a) upper_bound(a)
#define F first
#define S second
#define FOR(i,n) for(long long int i = 0;i<n;i++)
#define FOR1(i,n) for(long long int i=1;i<=n;i++)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REVERSE(s) reverse(s.begin(),s.end())
#define LBV(v,a) lower_bound(v.begin(),v.end(),a)
#define UBV(v,a) upper_bound(v.begin(),v.end(),a)
#define GCD(a,b) __gcd(a,b)
#define MAX pow((ll)2,63) - 999;
#define ITX(it,x1) for(auto it = x1.begin();it!=x1.end();it++)
#define I insert
#define stll(x) stoll(x, nullptr, 10);
#define VFIND(v1,val) find(v1.begin() , v1.end() , val )
#define VFILL(v1 , val)   std::fill(v1.begin(), v1.end(), val);
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define all(x) x.begin() , x.end() 

// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }
ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }
ll cl(ll a, ll b){if(a%b == 0)return a/b;else return a/b + 1;}
const int MOD = 1e9 + 7;

long long int powxy(long long int x, long long int y) 
{
    if (y == 0) return 1;
    if (y%2 == 1) return (x*powxy(x, y-1))%MOD;
    long long int t = powxy(x, y/2);
    return (t*t)%MOD;
}
void DPM(map<ll,ll>m1)
{
    for(auto it = m1.begin();it!=m1.end();it++)
    {
        cout<<it->first<<" "<<it->second<<endl;
    }
    cout<<endl;
}
void DPV(vector<ll>v)
{
    FOR(i,v.size())cout<<v[i]<<" ";cout<<endl;
}
void DPS(set<ll>s1)
{
    for(auto it =s1.begin();it!=s1.end();it++)cout<<*it<<" ";cout<<endl;
}
void DPA(ll arr[],ll n)
{
    FOR(i,n)cout<<arr[i]<<" ";cout<<endl;
}

ll dx[4] = { 0,0,1,-1 };
ll dy[4] = { 1,-1,0,0 };
string pos = "RLDU";


int main()
{
    FAST;
    ll i ,j , T = 1;
    // cin>>T;
    while(T--)
    {
        i=0;j=0;

        string s; cin>>s;

        int ans = 0 ;

        while(i<s.size() )
        {
            int c = 0 ;

            if(s[i] == 'R')
            {
                while(i<s.size() && s[i] == 'R')i++,c++;
            }
            else i++;

            ans = max(ans,c);

        }
        cout<<ans;
        
        
    }
}  



Measured memory_bytes: 3652
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    H, W, K = map(int, input().split())
    C = [list(input()) for _ in range(H)]
    answer = 0
    for i in range(2 ** H):
        for j in range(2 ** W):
            black = 0
            for h in range(H):
                for w in range(W):
                    if (i >> h) & 1 == 0 and (j >> w) & 1 == 0 and C[h][w] == "#":
                        black += 1
            if black == K:
                answer += 1
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
//
//  main.cpp
//  codeforces 1
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define int long long
#define N 1500002
using namespace std;
signed main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=0,w=0;
    char t[n];
    for(int i=0;i<n;i++) {
        t[i]=s[i];
        if(s[i]=='R') {
            r++;
        }
        else {
            w++;
        }
    }
    int j=n-1,C1=0;
    while(t[j]!='R'&&j>=0) {
        C1++;
        j--;
    }
    j=0;
    int C2=0;
    while(t[j]!='W'&&j<=n-1) {
        C2++;
        j++;
    }
    r=r-C2; w=w-C1;
    //cout<<r<<" "<<w<<endl;
    char arr[n-C1-C2];
    if(n-C1-C2==0) {
        cout<<0<<endl;
        return 0;
    }
    for(int i=C2;i<n-C1;i++) {
        arr[i-C2]=s[i];
        //cout<<arr[i-C2]<<" ";
    }
    if(n-C1-C2==0) {
        cout<<0<<endl;
    }
    else {
        n=n-C1-C2;
        int count=0;
        for(int i=r;i<n;i++) {
            if(arr[i]=='R') {
                count++;
            }
        }
        cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 4164
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, m) = readIntegerList()
    val nn = if (n - 1 > 0) n * (n - 1) / 2 else 0
    val mn = if (m - 1 > 0) m * (m - 1) / 2 else 0
    out.println(nn + mn)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 37868
#pragma GCC optimize("Ofast")

//#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x % N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % N;
		y = y >> 1;
		x = (x * x) % N;
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2 != 0)
	{
		cout << "No";
	}
	else
	{
		string s1 = "", s2 = "";
		char flag = 'Y';
		f(i, 0, n / 2)
		{
			if (s[i] != s[i + (n / 2)])
			{
				flag = 'N';
				break;
			}
		}
		if (flag == 'N')
			cout << "No";
		else
			cout << "Yes";
	}
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> a(H+2, vector<char>(W+2, '#'));
  
  for (int y = 1; y < H+1; y++) {
    for (int x = 1; x < W+1; x++) {
      cin >> a.at(y).at(x);
    }
  }
  
  for (int y = 0; y < H+2; y++) {
    for (int x = 0; x < W+2; x++) {
      cout << a.at(y).at(x);
    }
    
    cout << endl;
  }
}


Measured memory_bytes: 256
//Zory in 2018
//*******************头文件*******************
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
typedef long long ll;
typedef unsigned long long ull;
int mymax(int x,int y) {return x>y?x:y;}
int mymin(int x,int y) {return x<y?x:y;}
int myabs(int x) {return x>0?x:-x;}
//*******************全局常量*******************
const int MAXN=1100000;
//*******************全局定义*******************
int a,b,c,x,y;
//*******************实现*******************
int solve()
{
    if(a+b<=2*c)
    {
        return a*x+b*y;
    }
    else
    {
        if(x>y) std::swap(x,y),std::swap(a,b);
        if(2*c<=b) return 2*c*y;
        return 2*c*x+(y-x)*b;
    }
}
//*******************主函数*******************
int main()
{
	//freopen("tmp.in","r",stdin);
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    printf("%d",solve());
}


Measured memory_bytes: 128
S = input()

ans = 0
if len(S) % 2 == 0:
    ans = len(S)//2
    c = ans
    t = S[ans]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
else:
    ans = len(S)//2+1
    c = ans
    t = S[ans-1]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break


print(ans)


Measured memory_bytes: 39408
N, M = [int(x) for x in input().split()]

max_a, min_b = 0, 10000000
for _ in range(M):
  a, b = [int(x) for x in input().split()]
  if a > max_a:
    max_a = a
  if b < min_b:
    min_b = b
if min_b < max_a:
  print(0)
else:
  print(min_b - max_a + 1)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
using namespace std;

int mod = 998244353;

#define swap(x,y){ long long temp = x; x = y; y = temp;}


int main()
{
	 int h1,h2,m1,m2;
	 long long k;
	 cin >> h1 >> m1 >> h2 >> m2 >> k;
	 long long ans = 60*(h2-h1)+(m2-m1)-k;
	 cout << ans << endl;



}


Measured memory_bytes: 3632
"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");

  const N = Number(inputs[0]);
  const T = Number(inputs[1].split(" ")[0]);
  const A = Number(inputs[1].split(" ")[1]);
  const H = inputs[2].split(" ").map(Number);

  const f = h => Math.abs(T - h * 0.006 - A);
  const result = [...H].sort((a,b) => f(a)-f(b));
  console.log(H.findIndex(h=> h === result[0]) + 1);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; ++i) {
        if (2 * i + 4 * (x - i) == y) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int ans = 0;
    for (int i=0; i<3; i++) {
       if(s[i] == '1')  {
           ans++;
       }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> A;
	int ans = 0;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	sort(A.begin(), A.end(), greater<int>());
	
	for(int i = 1; i < N; i++){
		A.push_back(A[i]);
	}
	
	sort(A.begin(), A.end(), greater<int>());
	
	for(int i = 0; i < N-1; i++){
		ans += A[i];
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto A=in();
	if(A==1ll){
		out(0);
		return 0;
	}

	auto P = enum_prime(10000003);
	ll S=0;
	for(auto& x:P){
		if(A==1ll) break;
		ll y = x;
		while(!(A%y)){
			S++;
			A /= y;
			y *= x;
		}
	}

	for(auto& x:P){
		while(!(A%x)) A/=x;
	}

	if(A>1ll) S++;

	out(max(S,1ll));
	return 0;
}


Measured memory_bytes: 21840
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int ans=0,t=1;
    for(int i=0;i<a.size()-1;i++){
        if(a[i]==a[i+1])t++;
        if(a[i]!=a[i+1]&&t==1)ans++;
        if(a[i]!=a[i+1]&&t!=1){
            if(t%2==1){
                ans++;
            }
            t=1;
        }
        if(i==a.size()-2&&t%2==1)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;
typedef long long  ll;

const ll inf=1LL<<53;

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

int n,m;

ll lcost[210][210];
ll scost[210][210];
ll dp[1010][210];

int r;
int z[1010];

int main(void){
	
	while(cin >> n >> m,n|m){
		rep(i,210)rep(j,210) lcost[i][j]=scost[i][j]=((i==j)?0:inf);

		rep(i,m){
			ll x,y,t;
			char sl;
			cin >> x >> y >> t >> sl;
			x--;y--;
			if(sl=='S'){
				scost[x][y]=min(scost[x][y],t);
				scost[y][x]=min(scost[y][x],t);
			}else{
				lcost[x][y]=min(lcost[x][y],t);
				lcost[y][x]=min(lcost[y][x],t);
			}
		}

		cin >> r;
		rep(i,r){cin >> z[i];z[i]--;}

		rep(k,n)rep(i,n)rep(j,n) scost[i][j]=min(scost[i][j],scost[i][k]+scost[k][j]);
		rep(k,n)rep(i,n)rep(j,n) lcost[i][j]=min(lcost[i][j],lcost[i][k]+lcost[k][j]);

		rep(i,1010)rep(j,210) dp[i][j]=inf;
		dp[0][z[0]]=0;
		rep(i,r-1)rep(j,n)rep(k,n){
			 dp[i+1][k]=min(dp[i+1][k],dp[i][k]+lcost[z[i]][z[i+1]]);
			 dp[i+1][k]=min(dp[i+1][k],dp[i][j]+lcost[z[i]][j]+scost[j][k]+lcost[k][z[i+1]]);
		}
		ll ans=inf;
		rep(i,n) ans=min(ans,dp[r-1][i]);
		cout << ans << endl; 
	}
	return 0;

}

Measured memory_bytes: 3512
N = int(input())
An = list(map(int, input().split()))
Bn = map(int, input().split())
Cn = list(map(int, input().split()))

s = sum(Bn)
for i, (ani, ani1) in enumerate(zip(An, An[1:])):
	#print(i, ani, ani1)
    if ani + 1 == ani1:
      s += Cn[ani - 1]
print(s)
  


Measured memory_bytes: 3060
fun main(args: Array<String>){
    val N = readLine()!!.toLong()

    if(N % 2 == 1L){
        println(0)
    }else{
        var x = 10L
        var ans = 0L
        while (x <= N){
            ans += N / x
            x *= 5
        }
        println(ans)
    }
}

Measured memory_bytes: 31732
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define forN(i, n) for(int i = 1; i <=n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const int N = 3005;
ll n , A[N],DP[N][N];
/*
ll taro = max(calc(i+1,j)+A[i],calc(i,j-1)+A[j]);
    ll jaro = min(calc(i+1,j)+A[i],calc(i,j-1)+A[j]);
*/
ll calc(int i , int j){
    if(i == j)return A[i];
    if(DP[i][j]!=-1)return DP[i][j];
    ll left = A[i] - calc(i+1,j);
    ll right = A[j] - calc(i,j-1);
    return DP[i][j] = max(left,right);

}

int main(){
    fastIO;
    cin>>n;
    forN(i,n)cin>>A[i];
    memset(DP,-1,sizeof DP);
    cout<<calc(1,n);
}



Measured memory_bytes: 74356
import java.util.Scanner;

public class Main {

	static final int INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		int[] h = new int[N + 1];
		int[] d = new int[N + 1];
		for (int i=1; i <= N; i++) {
			h[i] = in.nextInt();
			d[i] = INF;
		}
		d[1] = 0;
		d[2] = Math.abs(h[2] - h[1]);
		for(int i=3; i<=N; i++) {
			for(int j=1; j<=K && i-j >= 1; j++) {
				d[i] = Math.min(d[i], d[i-j] + Math.abs(h[i-j]-h[i]));
			}
		}
		System.out.println(d[N]);
	}
}

Measured memory_bytes: 59712
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main( void )
{
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int N = S.size();
  int M = T.size();
  string ret;
  bool first = true;
  for( int i=0; i<=N-M; i++ ){
    bool f = true;
    for( int j=0; j<M; j++ ){
      if( S[i+j] != T[j] && S[i+j] != '?' ){
        f = false;
        break;
      }
    }
    if( f ){
      string U = S;
      for( int j=0; j<i; j++ )
        if( U[j] == '?' ) U[j] = 'a';
      for( int j=0; j<M; j++ )
        U[i+j] = T[j];
      for( int j=i+M; j<N; j++ )
        if( U[j] == '?' ) U[j] = 'a';
      if( first || ret > U ){
        first = false;
        ret = U;
      }
    }
  }
  if( first ) cout << "UNRESTORABLE" << endl;
  else cout << ret << endl;
}

Measured memory_bytes: 256
N = int(input())
DP = [0] * (N+1)
DP[0] = 1
su = [0] * (2*(10**5)+1)
prev = None
MOD = 10**9+7
for i in range(N):
    C = int(input())
    if prev == C:
        DP[i+1] = DP[i]
    else:
        su[C] += DP[i]
        su[C] %= MOD
        DP[i+1] = su[C]
    DP[i+1] %= MOD
    prev = C
print(DP[N])

Measured memory_bytes: 48508
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N;
int c[10][10];


signed main(){
    cin >> N;

    repe(i, 1, N){
        int x = i%10;
        int y = i;
        while(y > 9) y /= 10;
        c[x][y]++;
    }

    int ans = 0;
    repe(i, 1, 9) repe(j, 1, 9) ans += c[i][j]*c[j][i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main(void){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<pair<ll, ll>> t;
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    for(ll i = 0; i < m; i++){
        ll b, c;
        cin >> b >> c;
        t.push_back(make_pair(c,b));
    }
    sort(a.begin(), a.end());
    sort(t.begin(), t.end());
    ll count = 0; ll cm = m-1;
    ll sum = 0;
    for(ll i = 0; i < n; i++){
        //cout << a[i] << endl;
        if(a[i] < t[cm].first){
            a[i] = t[cm].first;
            count++;
            if(count == t[cm].second){
                cm--;
                count = 0;
            }
        }
        sum += a[i];
        if(cm == -1){
            for(ll j = i+1; j < n; j++)
                sum += a[j];
            break;
        }
    }
    cout << sum << endl;
    return 0;
}

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

const int mod = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;
  int ans = 0;
  while (n > 0) {
    n = n / k;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools

def sRaw():
    return input().rstrip("\r")

def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    
def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i =1
    j =0
    A[0]=l
    while i<l:
        while i+j<l and s[j] == s[i+j]:
            j+=1
        if j==0:
            i+=1
            continue
        A[i]=j
        k=1
        while (i+k<l) and (k+A[k]<j):
            A[i+k] =A[k]
            k+=1
        i+=k
        j-=k
    return A


DIV = 998244353

def main():
    N = iRaw()
    X1 = int(N/1.08)
    X2 = X1+1
    if int(X1*1.08)==N:
        return X1
    elif int(X2*1.08)==N:
        return X2
    else:
        return ":("

if __name__ == "__main__":
    print(main())


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

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

  rep(i, N + 1) {
    if (N == (int)(i * 1.08)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int A, B;
	cin >> A >> B;
	int ans = A * B;
	cout << ans;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		if(A > C) {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		}

		if(B < C) {
			System.out.println("0");
		} else if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		}

	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

ll N,K,Q;
ll table[SIZE];

int main(){

	scanf("%lld %lld %lld",&N,&K,&Q);

	for(ll i = 0; i < N; i++){

		table[i] = 0;
	}

	ll tmp;
	for(ll i = 0; i < Q; i++){

		scanf("%lld",&tmp);
		tmp--;

		table[tmp]++;
	}

	for(ll i = 0; i < N; i++){

		tmp = K-Q+table[i];

		if(tmp > 0){

			printf("Yes\n");

		}else{

			printf("No\n");
		}
	}


	return 0;
}


Measured memory_bytes: 1408