akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main() {
	string s, p;
	int count=0,q;
	bool judge = true;
	cin >> s >> p;
	for (int i = 0; i < s.length(); i++) {
		q = i;
		string s1;
		while (count < p.length()) {
			if (q > s.length()-1)q -= s.length();
			s1 += s[q];
			q++;
			count++;
		}
		count = 0;
		if (s1 == p) {
			judge = false;
			break;
		}
	}
	if (judge) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3152
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int m=s.size();
    for(int i=0;i<m;i++){
        s[i]='A'+(s[i]-'A'+n)%26;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

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

Measured memory_bytes: 256
def main():
    s = list(input())
    if s[0] == s[1] == s[2] == s[3]:
        print('No')
        return
    for i in range(3):
        if s[3] == s[i]:
            s.pop(3)
            s.pop(i)
            if s[0] == s[1]:
                print('Yes')
                return
            print('No')
            return
    print('No')
            
main()

Measured memory_bytes: 9016
n;s;e;w;i;main(){
    char t[1000];
    gets(t);
    
    for(;i<strlen(t);i++){
        if(t[i]=='N'){
            n=1;
        }else if(t[i]=='S'){
            s=1;
        }else if(t[i]=='E'){
            e=1;
        }else if(t[i]=='W'){
            w=1;
        }
    }
    
    puts(abs(n-s)+abs(w-e)?"No":"Yes");
    
}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  char ABCD[4+1];
  scanf("%s", ABCD);

  for (int i{}; i < (1 << (4-1)); ++i) {
    int calc = ABCD[0] & 0xF;
    for (int j{}; j < (4-1); ++j) {
      if (i & (1 << j))
        calc += ABCD[j+1] & 0xF;
      else
        calc -= ABCD[j+1] & 0xF;
    }
    if (calc == 7) {
      printf("%c", ABCD[0]);
      for (int j{}; j < (4-1); ++j) {
        printf("%c%c", (i & (1 << j)) ? '+' : '-', ABCD[j+1]);
      }
      printf("=7\n");
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 888
N = int(input())
H = [int(h) for h in input().split()]
dp = [0]*N
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])

Measured memory_bytes: 13780
h, w, a, b = gets.strip.split.map(&:to_i)

result = Array.new(h) { [0]*w }

h.times do |i|
  w.times do |j|
    if i < b && j < a
        result[i][j]=1
    end
    if i >= b && j >= a
        result[i][j]=1
    end
    
  end
end

h.times do |i|
  puts result[i].join('')
end


Measured memory_bytes: 11004
#include <iostream>
#include <string>
using namespace std;
 
int N;
void dfs(string s, char mx){
  if(s.length() == N){
    cout<<s<<endl;
  }else{
    for(char c='a';c<=mx;c++){
      char moji;
      if(c==mx){
        moji=char(mx+1);
      }else{
        moji=mx;
      }
      dfs(s+c, moji);
    }
  }
}
 
int main(void){
  cin >> N;
  dfs("", 'a');
  return 0;
}

Measured memory_bytes: 1536
/**
*    author:  yuya1234
*    created: 17.07.2020 17:13:01
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

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

  ll n,k;
  cin>>n>>k;

  vector<pair<ll,ll>> p(n);
  ll a,b;
  REP(i,n)
  {
    cin>>a>>b;
    p[i]=make_pair(a,b);
  }

  SORT(p);

  ll ans=0;
  REP(i,n)
  {
    k-=p[i].second;
    if(k-1<0)
    {
      ans=i;
      break;
    }
  }

  cout<<p[ans].first<<endl;

  return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;
if(str[1] == 'B'){
 cout<<"ARC";
 return 0;
}
cout<<"ABC"<<endl;
}


Measured memory_bytes: 3612
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //decimal s = Console.ReadLine();
        //decimal n = decimal.Parse(Console.ReadLine());
        decimal[] tmp = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
        decimal a = tmp[0];
        decimal b = tmp[1];
        decimal c = tmp[2];
        decimal d = tmp[3];
        decimal e = tmp[4];
        decimal f = tmp[5];

        decimal max = 0;
        decimal answ = 0;
        decimal anss = 0;
        for (int xa = 0; xa * 100 * a < f; xa++)
        {
            for (int xb = 0; xb * 100 * b < f; xb++)
            {
                for (int xc = 0; xc * c < f; xc++)
                {
                    for (int xd = 0; xd * d < f; xd++)
                    {
                        if (xa == 0 && xb == 0) continue;

                        decimal tmpg = xa * 100 * a + xb * 100 * b + xc * c + xd * d;
                        decimal tmpp = (100 * (xc * c + xd * d)) / ((xa * 100 * a + xb * 100 * b) + (xc * c + xd * d));
                        if (tmpg <= f && tmpp >= max && (100 * (xc * c + xd * d)) / (xa * 100 * a + xb * 100 * b) <= e)
                        {
                            answ = (xa * 100 * a + xb * 100 * b);
                            anss = (xc * c + xd * d);
                            max = tmpp;
                        }

                        if (tmpg > f) break;
                    }  
                }
            }
        }
        // 出力
        Console.WriteLine("{0} {1}", answ + anss, anss);
    }
}

Measured memory_bytes: 11476
<?php
list($N, $C) = ints();
for ($i = 0; $i < $C; ++$i) $D[] = ints();
for ($i = 0; $i < $N; ++$i) {
    $c[] = ints();
    for ($j = 0; $j < $N; ++$j) --$c[$i][$j];
}
echo dfs();
// 3種類のマスに3色を選ぶ全探索
function dfs($d = 0, $selected = [])
{
    global $C;
    if ($d === 3) return calcD(array_keys($selected));
    for ($i = 0; $i < $C; ++$i) {
        if (isset($selected[$i])) continue;
        $_selected = $selected;
        $_selected[$i] = true;
        $res[] = dfs($d + 1, $_selected);
    }
    return min($res);
}
// 違和感の計算
function calcD($a)
{
    global $memo;
    $res = 0;
    for ($mod = 0; $mod < 3; ++$mod) {
        // memo[mod][c]: 余り i になるマスを色 c に塗り替えた時の違和感の和
        if (!isset($memo[$mod][$a[$mod]])) $memo[$mod][$a[$mod]] = subCalcD($mod, $a[$mod]);
        $res += $memo[$mod][$a[$mod]];
    }
    return $res;
}
function subCalcD($mod, $to)
{
    global $N, $D, $c;
    $res = 0;
    for ($i = 0; $i < $N; ++$i) {
        for ($j = ($mod + 2 * $i) % 3; $j < $N; $j += 3) {
            $from = $c[$i][$j];
            $res += $D[$from][$to];
        }
    }
    return $res;
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 24180
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n)rep(j, m) cin >> a[i][j];

    int ans = n;
    vector<int> play(m, 1), idx(n, 0);
    rep(i, m){
        vector<int> ct(m, 0);
        bool stop = 0;
        rep(j, n){
            int k = a[j][idx[j]]-1;
            while(!play[k]){
                idx[j]++;
                if(idx[j] >= m){
                    stop = 1;
                    break;
                }
                k = a[j][idx[j]]-1;
            }
            if(stop) break;
            ct[k]++;
        }
        if(stop) break;
        int max_sport = max_element(all(ct)) - ct.begin();
        // cout <<max_sport+1<<endl;
        chmin(ans, ct[max_sport]);
        play[max_sport] = 0;

    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 200005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, s, ans, po[N]{1}, c[N];
int main()
{
	ll i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		po[i] = po[i - 1] * 2 % M;
	}
	for (i = 0; i < n; i++) scanf("%lld", &c[i]);
	sort(c, c + n);
	s = po[n - 1];
	for (i = n - 1; i >= 0; i--) {
		ans = (ans + s * c[i]) % M;
		s = (s + po[n - 2]) % M;
	}
    cout << ans * po[n] % M << endl;
    return 0;
}

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
n,a,b,c = list(map(int,input().split()))
abc = [a,b,c]
s = [tuple(map(lambda x:ord(x)-97,list(input().lower()))) for i in range(n)]

from copy import deepcopy

s.append(deepcopy(s[-1]))
ret = True
ret_choice = []
ra = ret_choice.append
for i,j in zip(s,s[1::]):
    #i[0]で+1,i[1]で-1をする場合
    if abc[i[0]] >=3  and abc[i[1]] >=3:
        abc[i[0]]+=1
        abc[i[1]]-=1
        ra(i[0])
    elif abc[i[0]] >=3 and abc[i[1]] < 3:
        abc[i[0]]-=1
        abc[i[1]]+=1
        ra(i[1])
    elif abc[i[0]] <3 and abc[i[1]] >= 3:
        abc[i[0]]+=1
        abc[i[1]]-=1
        ra(i[0])
    elif abc[i[0]]==0:
        abc[i[0]]+=1
        abc[i[1]]-=1
        ra(i[0])
    elif abc[i[1]]==0:
        abc[i[0]]-=1
        abc[i[1]]+=1
        ra(i[1])
    elif i[0] in j:
        abc[i[0]]+=1
        abc[i[1]]-=1
        ra(i[0])
    else:
        abc[i[0]]-=1
        abc[i[1]]+=1
        ra(i[1])
    if -1 in abc:
        ret = False
        break

if ret:
    print("Yes")
    for i in (map(lambda x:chr(x+65),ret_choice)):
        print(i)
else:
    print("No")

Measured memory_bytes: 17912
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, M; cin >> N >> M;
  vector<vector<int>> g(N);
  vector<pair<int, int>> ABs(M);
  for (auto &AB : ABs) {int A, B; cin >> A >> B; AB.first = A - 1; AB.second = B - 1;}
  for (auto AB : ABs) {g[AB.first].push_back(AB.second); g[AB.second].push_back(AB.first);}
  queue<int> q;
  vector<int> ds(N, -1);
  ds[0] = 0; q.push(0);
  while (q.size())
    {auto i = q.front(); q.pop();
    for (auto v : g[i])
      {if (ds[v] >= 0) continue;
      ds[v] = i + 1; q.push(v);}}
  for (int i = 1; i < N; ++i)
    {if (ds[i] == -1) {puts("No"); return 0;}}
  puts("Yes");
  for (int i = 1; i < N; ++i) cout << ds[i] << "\n";}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        mut a_s: [usize; n+1],
        mut b_s: [usize; n],
    }
    let mut count = 0usize;
    for i in 0..n {
        let num = std::cmp::min(a_s[i], b_s[i]);
        count += num;
        a_s[i] -= num;
        b_s[i] -= num;
        let num = std::cmp::min(a_s[i + 1], b_s[i]);
        count += num;
        a_s[i + 1] -= num;
    }
    println!("{}", count);
}


Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  for (int i = 0; i < a; i++) {
    if (s[i] == '-') {
      No;
      return 0;
    }
  }
  if (s[a] != '-') {
    No;
    return 0;
  }
  for (int i = a + 1; i < a + b + 1; i++) {
    if (s[i] == '-') {
      No;
      return 0;
    }
  }
  Yes;


  return 0;
}



Measured memory_bytes: 256
n, k  = map(int, input().split())
L = list(map(int, input().split()))
E = []
for i in range(len(L)):
  E.append((1+L[i])/2)
v = 0
for i in range(k):
  v += E[i]
S = [v]  
for i in range(k, len(E)):
  v = v + E[i] - E[i-k]
  S.append(v)
print(max(S)) 

Measured memory_bytes: 25604
a,b,c,d = map(int,input().split())
Alice = ['1' if i>=a and i<=b else '0' for i in range(101)]
Bob = ['1' if i>=c and i<=d else '0' for i in range(101)]
ans = 0
for i in range(101):
    if Alice[i]=='1' and Bob[i]=="1":
        ans+=1
print(0 if ans==0 else ans-1)

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

int sosuu(int X){
    int i = 2;
    while(i < sqrt(X)){
        if(X % i == 0) return -1;
        i = i+1;
    }

    return 0;
}

int main(void){
    int X; cin >> X;
    
    while(sosuu(X) != 0){
        X++;
    }

    cout << X << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  cout<<"square1001"<<endl;

  return 0;
}



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

int x;
pair <int, int> res;

pair <int, int> Factorization(int x) {
    for(int a = -1000; a <= 1000; a++)
        for(int b = -1000; b <= 1000; b++)
            if(pow(a, 5) - pow(b, 5) == x)
                return make_pair(a, b);
    return make_pair(0, 0);
}

int main() {
    cin>>x;
    res = Factorization(x);
    cout<<res.first<<" "<<res.second;
    return 0;
}


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

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

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;
using P = pair<int,int>;
 
const int INF = 1001001001;
const int MOD = 1000000007;

// auto MOD int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination MOD prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} comb(1000005);

int main() {
    int n,a,b;
    cin >> n >> a >> b;

    mint ans = 1;
    mint two = 2;
    int c = 1000000;
    int nc = n;
    while(nc>c) {
        nc -= c;
        ans = ans*two.pow(c);
    }
    ans = ans*two.pow(nc) - 1;
    mint tmp = 1;

    rep(i,b+1) {
        tmp = tmp*(n-i);
        tmp = tmp/(i+1);
        if (i+1==a || i+1==b) {
            ans -= tmp;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

bool isPrime(int n ){
	bool ans = true;
	if(n%2==0){ 
		if(n!=2){
		return false;
		}
		else{
			return true;
			}
	}
	else{
		int i =3;
		while(i<n/2){
			if(n%i ==0) return false;
			i++;
			}
		}
	return ans;
	}

int main(){
	int x;
	cin>>x;
	while(!isPrime(x)){
		x++;
		}
	cout<<x;
	return 0;
	}


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

int main(){
	int a[10],i;
	for(i=0;i<10;i++){
		cin>>a[i];
	}cout<<a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define PB push_back
#define MP make_pair
#define S second
#define F first
//#define D cout<<"*\n";
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define mod 1000000007 
#define inf 1e10;
const double pi = 3.14159265358979323846; 

int visited[100005];

int dfs(vector<int> graph[],int s)
{
	if(graph[s].size()==0)
	return 0;
	
	int &ans=visited[s];
	if(ans!=-1)
	return ans;
	for(int i=0;i<graph[s].size();i++)
	{
		int t=graph[s][i];
		 ans=max(dfs(graph,t),ans);
		 //cout<<"\n"<<t<<" "<<ans<<"\n";
	}
	
	ans=ans+1;
	return ans;
}
signed main()
{
    fast
    int t=1;
   // cin>>t;
    
    while(t--)
    {
      int m,n;
      cin>>m>>n;
      
      vector<int> graph[m+1];
      vector<int> graphT[m+1];
      
      for(int i=0;i<n;i++)
      {
      	int a,b;
      	cin>>a>>b;
      	graph[a].PB(b);
      	graphT[b].PB(a);
	  }
	  vector<int> ds;
	  for(int i=1;i<=m;i++)
	  {
	  	if(graphT[i].size()==0)
	  	ds.PB(i);
	  }
	  memset(visited,-1,sizeof(visited));
	  int ans=0;
	  for(int i=0;i<ds.size();i++)
	  {
	  	ans=max(ans,dfs(graph,ds[i]));
	  }
	  cout<<ans;
       
    }
	return 0;
}

	

Measured memory_bytes: 16640
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=int(1e5+5);
int n,m;
int a[MAXN];
int gcd(int a,int b) {
	return b==0?a:gcd(b,a%b);
}
int main()
{
	scanf("%d",&n);
	int ans=-1,x;
	for(int i=1;i<=n;i++) {
		scanf("%d",&x);
		if(ans==-1) ans=x;
		else ans=gcd(ans,x);
	}
	printf("%d",ans);
}

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

int main(){
  string S;
  long long int K,NowInd = 0;
  int ans = 0;

  cin >>S>>K;

  for(int i = 0;i < min((long long int)S.size(),K);i++){
    if(S[i] != '1'){
      ans = i;
      break;
    }
  }
  cout <<S[ans]<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc120_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

class DisjointSet {
public:
    DisjointSet(ll n) {
        rank.resize(n);
        parent.resize(n);
        sizes.resize(n);
        for (ll i=0; i<n; i++) rank[i] = 0, parent[i] = i, sizes[i] = 1;
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    void unite(ll x, ll y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        else if (rank[x] == rank[y]) rank[x]++;
        parent[y] = x;
        sizes.at(x) += sizes.at(y);
    }

    long long size(ll x) {
      return sizes.at(root(x));
    }

private:
    vector<ll> rank;
    vector<ll> parent;
    vector<long long> sizes;

    ll root(ll x) {
        if (x != parent[x]) {
            parent[x] = root(parent[x]);
        }

        return parent[x];
    }
};

struct Edge {
  ll a, b;
};

ll N, M;
vector<Edge> A;
void solve() {
  cin >> N >> M;
  ll a, b;
  loop(m,0,M) {
    cin >> a >> b;
    a--;b--;
    A.push_back((Edge){ a, b });
  }
  reverse(A.begin(), A.end());

  DisjointSet ds(N);

  vector<ll> result;
  result.push_back(0);
  for (auto&&edge: A) {
    if (ds.same(edge.a, edge.b)) {
      result.push_back(result[result.size()-1]);
      continue;
    }

    ll prev = result[result.size()-1];
    result.push_back(prev + ds.size(edge.a) * ds.size(edge.b));
    ds.unite(edge.a, edge.b);
  }

  ll all = N * (N-1) / 2;
  reverse(result.begin(), result.end());
  for (int n=1; n<=M; n++) cout << all - result[n] << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 7024
#include<bits/stdc++.h>
#define int long long
using namespace std;
 
int mp[500][500];
main(){
  int H,W,h,w;
  cin>>H>>W>>h>>w;
  int cnt=0,d;
  if(w*h!=1)d=(1000000000-1)/(w*h-1);
  else d=0;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)mp[i][j]=d;
  
  for(int i=h-1;i<H;i+=h)
    for(int j=w-1;j<W;j+=w)
      mp[i][j]=-(d*(h*w-1)+1);
  
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)cnt+=mp[i][j];

    
  if(cnt>0){
    cout<<"Yes"<<endl;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(j)cout<<" ";
	cout<<mp[i][j];
      }
      cout<<endl;
    }
  }
  else cout<<"No"<<endl;
  return 0;
}


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

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

    vector<int> a(M);
    vector<int> b(M);
    vector<int> numpath(N);
    
    rep(i,M){
        cin >> a.at(i) >> b.at(i);
    }

    rep(i,M){
        numpath.at(a.at(i) - 1)++;
        numpath.at(b.at(i) - 1)++;
    }

    rep(i,N){
        cout << numpath.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <atcoder/modint>
#include <atcoder/convolution>

namespace ac = atcoder;
using mint = ac::modint998244353;

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<mint> xs(n), ys(m);
    for (auto& x : xs) {
        int a;
        std::cin >> a;
        x = mint::raw(a);
    }
    for (auto& y : ys) {
        int a;
        std::cin >> a;
        y = mint::raw(a);
    }

    auto zs = ac::convolution(xs, ys);
    for (auto z : zs) std::cout << z.val() << " ";
    std::cout << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 19044
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main()
{
  int n;cin>>n;
  int a[n + 10];
  int b[n + 10];
  rep(i, n)
  {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n, greater<int>());

  rep(i,n){
    if(a[i]!=b[0])cout<<b[0]<<endl;
    else  cout<< b[1] << endl;
  }

  return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
 
const int inf = (int)1e18 + 10;

priority_queue < pii >  pq;
int a[N] , b[N];
signed main(){
  fast;
  

  int n , x , y , val , ans = 0;
  cin >> n;
  for(int i = 0 ; i < n ; i++)
       cin >> a[i];
  for(int i = 0 ; i < n ; i++){
       cin >> b[i];
       if(b[i] != a[i])
       pq.push(mp(b[i] , i));
     }
   int cnt = 0;
    while(pq.size() > 0){
          pii p = pq.top();
          pq.pop();
          x = p.ss;
          val = p.ff ;
          y = b[(x- 1 + n) % n] + b[(x + 1) % n];
          int r = (val - a[x])/y;
          if((val - a[x]) <  y){
            ans = -1;
            break;
          }
          
          ans += r;
          
          b[x] -= r*y;
          if(b[x] != a[x]) 
          pq.push(mp(b[x]  , x));

    }
    
    cout << ans << endl;

 
}

Measured memory_bytes: 9072
import java.util.Map;
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan=new Scanner(System.in);
String S= scan.next();

        String T= scan.next();

String TT=T.substring(0,S.length());

if(TT.equals(S)     ){System.out.println("Yes");}
else{System.out.println("No");}

}

       }

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int N, M; cin >> N >> M;
	vector<int> type(M, 0);
	rep(i, N) {
		int K; cin >> K;
		rep(i, K) {
			int a; cin >> a;
			type[--a]++;
		}
	}

	int ans = 0;
	rep(i, M) if (type[i] == N) ans++;
	cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Point struct {
	X int
	Y int
}

type Points []Point

func (p Points) Len() int {
	return len(p)
}

func (p Points) Less(i, j int) bool {
	return p[i].X < p[j].X
}

func (p Points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	var reds, blues []Point
	for i := 0; i < N; i++ {
		reds = append(reds, Point{nextInt(), nextInt()})
	}
	for i := 0; i < N; i++ {
		blues = append(blues, Point{nextInt(), nextInt()})
	}

	sort.Sort(Points(blues))

	c := 0
	for _, b := range blues {
		redPos := -1
		maxYRed := Point{-1, -1}
		for pos, r := range reds {
			if b.X > r.X && b.Y > r.Y {
				if maxYRed.Y < r.Y {
					maxYRed = r
					redPos = pos
				}
			}
		}

		if redPos != -1 {
			reds = append(reds[:redPos], reds[redPos+1:]...)
			c++
		}
	}

	fmt.Println(c)
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
//#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(1 << n);
  for (int i = 0; i < (1 << n); i++) {
    cin >> a[i];
  }
  vector<pair<int, int>> guys(1 << n, {-1e9, -1e9});
  guys[0] = {a[0], -1e9};
  for (int mask = 1; mask < (1 << n); mask++) {
    for (int mask2 = mask;; mask2 = (mask2 - 1) & mask) {
      if (a[mask2] > guys[mask].F) {
        guys[mask].S = guys[mask].F;
        guys[mask].F = a[mask2];
      }
      else if (a[mask2] > guys[mask].S) {
        guys[mask].S = a[mask2];
      }
      if (mask2 == 0) {
        break;
      }
    }
  }
  for (int i = 1; i < (1 << n); i++) {
    int ans = guys[i].F + guys[i].S, cur_mask = 0;
    for (int kek_bit = n - 1; kek_bit >= 0; kek_bit--) {
      if ((i >> kek_bit) & 1) {
        int mda = cur_mask | ((1 << kek_bit) - 1);
        /*if (i == 1) {
          cerr << kek_bit << ' ' << mda << ' ' << guys[mda].F + guys[mda].S << '\n';
        }*/
        cur_mask |= 1 << kek_bit;
        ans = max(ans, guys[mda].F + guys[mda].S);
      }
    }
    cout << ans << '\n';
  }
} 

Measured memory_bytes: 6404
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int d[1005][1005];

int main()
{ios_base::sync_with_stdio(false);
int n,m;
cin>>n>>m;
rep(i,1,n)rep(j,1,n)d[i][j]=1e7+7;

while(m--)
{
	int a,b;
	cin>>a>>b;
	d[a][b]=1;
}

rep(k,1,n)rep(i,1,n)rep(j,1,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);



int id=0,mncyc=1e6+7;

rep(i,1,n)
{
	if(d[i][i]<mncyc)
	{
		mncyc=d[i][i];
		id=i;
	}
}

if(id==0)
{
	ol("-1");
	return 0;
}

ol(mncyc);on;
ol(id);on;
int ptr=id;

rep(ii,1,mncyc-1)
{
	int to=0;
	rep(i,1,n)
	{
		if(d[ptr][i]==1&&d[i][id]==mncyc-ii)
		{
			to=i;
			break;
		}
	}
	ol(to);on;
	ptr=to;
}
return 0;
}



Measured memory_bytes: 4352
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for a, b in ab:
    ans = 0
    temp_min = float("inf")
    for i, (c, d) in enumerate(cd):
        dist = abs(a - c) + abs(b - d)
        if dist < temp_min:
            ans = i + 1
            temp_min = dist
        
    print(ans)

Measured memory_bytes: 3064
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  vector<int> hon = {2, 4, 5, 7, 9};
  vector<int> pon = {0, 1, 6, 8};
  int n;cin>>n;
  n %= 10;
  if(count(hon.begin(), hon.end(), n)!=0)cout<<"hon"<<endl;
  else if(count(pon.begin(), pon.end(), n)!=0)cout<<"pon"<<endl;
  else cout<<"bon"<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

int main() {
    int N;
    cin >> N;
    bool n = true;
    vector<int>A(N);
    for (int i=0;i<N;i++){
        cin >> A[i];
        if (A[i]%2==1){
            continue;
        }
        else{
            if(A[i]%3==0||A[i]%5==0){
                continue;
            }
            else{
                n = false;
                break;
            }
        }
    }
    if(n){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    }
}


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

int main(void)
{
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;

    for(int i = 1; i <= N; ++i){
        int a = i % 10 + i/10 % 10 + i/100 % 10 + i/1000 % 10 + i/10000;
        if (a >= A && a <= B) ans += i; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

struct Point{ int y,x; };

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

int main(void){
    int Y, X, K;
    cin >> Y >> X >> K;
    int sx,sy, gx,gy;
    cin >> sy >> sx >> gy >> gx;
    sx--,sy--,gx--,gy--;
    vector<string> s(Y);
    rep(y,Y) cin >> s[y];

    vector<vector<int>> dp(Y, vector<int>(X, INF));
    dp[sy][sx] = 0;
    queue<Point> qu;
    qu.push({sy,sx});
    while(qu.size()) {
        Point p = qu.front(); qu.pop();
        rep(dir,4){
            rep1(k,K){
                int ny = p.y + dy[dir]*k;
                int nx = p.x + dx[dir]*k;
                if (ny < 0 || nx < 0 || ny >= Y || nx >= X) break;
                if (s[ny][nx] == '@') break;
                if (dp[ny][nx] <= dp[p.y][p.x]) break;
                if (dp[ny][nx] > dp[p.y][p.x] + 1) {
                    dp[ny][nx] = dp[p.y][p.x] + 1;
                    qu.push({ny,nx});
                }
            }
        }
    }
    cout << ((dp[gy][gx] == INF) ? -1 : dp[gy][gx]) << endl;
    return 0;
}


Measured memory_bytes: 12064
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN


int main() {
	string s,ans="1";
	ll k;
	cin>>s>>k;
	rep(i,s.size()){
		if(k-1<i)break;
		if(s[i]!='1'){
			ans=s[i];
			break;
		}
	}
	// cout<<s<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
char mat[22][22];

int q[100100][2];
bool book[22][22];
int dis[22][22];
int ans;
int st,ed;
bool check(int x,int y)
{
	if(x<1||y<1||x>n||y>m)return 0;
	if(mat[x][y]=='#')return 0;
	return 1;
}
int fl[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
void BFS(int x,int y)
{
	st=ed=0;
	q[++ed][0]=x;q[ed][1]=y;
	memset(book,0,sizeof(book));
	book[x][y]=1;
	memset(dis,0,sizeof(dis));
	int nx,ny;
	while(st<ed)
	{
		x=q[++st][0];y=q[st][1];
		ans=max(ans,dis[x][y]);
		for(int i=0;i<4;++i)
		{
			nx=x+fl[i][0];ny=y+fl[i][1];
			if(!check(nx,ny)||book[nx][ny])continue;
			dis[nx][ny]=dis[x][y]+1;
			q[++ed][0]=nx;q[ed][1]=ny;
			book[nx][ny]=1;
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",mat[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(mat[i][j]=='.')
				BFS(i,j);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while(true){
    C = C - B;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    
    A = A - D;
    if(A <= 0){
      cout << "No" << endl;
      break;
    }
  }

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int res = 0;
  for (int i=L; i<=R; i++) {
    if (i%d==0) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

int main() {
  double x, y;
  vector<pair<double, double>> v;
    char c;
    while(cin >> x >> c >> y) v.push_back(make_pair(x,y));     

  double S = 0;
  for(int i = 1; i < v.size()-1; i++) {
    double x1 = v[0].first,   y1 = v[0].second;
    double x2 = v[i].first, y2 = v[i].second;
    double x3 = v[i+1].first, y3 = v[i+1].second;
  
    double a = hypot(x2-x1, y2-y1), b = hypot(x3-x2, y3-y2), c = hypot(x1-x3, y1-y3);
    double z = (a+b+c) / 2;
    S += sqrt(z * (z-a) * (z-b) * (z-c));
  }
  
  printf("%.6lf\n", S);
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;


int main(){
  
  ll ans{};
  int n; cin>>n;
  vector<int> a(n);
  for(auto &i:a) cin>>i;
  int now = a.front();
  for(int i=0; i<n; i++){
    if(now>a.at(i)){
      ans += now - a.at(i);
    }
    else if(now<a.at(i)){
      now = a.at(i);
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 3992
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter
from itertools import takewhile
from operator import itemgetter

counter = Counter()
for line in stdin:
    if not line.split():
        break
    counter[int(line)] += 1

v = counter.most_common(1)[0][1]
mc = takewhile(lambda x: v == x[1], counter.most_common(100))
for n, _ in sorted(mc, key=itemgetter(0)):
    print(n)

Measured memory_bytes: 4656
// Confessions of a Dangerous Mind

/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

long long ans[N];

long long f(long long a){
	return (a * (a - 1)) / 2;
}

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

/*
	"With self-discipline most anything is possible."
*/	
	
	long long n; cin >> n;
	vector<long long> a(n);
	map<long long, long long> m;
	for(long long i = 0; i < n; i++){
		cin >> a[i];
		m[a[i]]++;
	}
	
	long long R = 0;
	for(auto i : m){
		R += f(i.second);
	}
	
	for(auto i : m){
		ans[i.first] = R - f(i.second) + f(i.second - 1);
	}
	
	for(long long i = 0; i < n; i++){
		cout << ans[a[i]] << "\n";
	}
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/

Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,n;
  cin >> N;
  n=0;
  
  for (int i=0; i<N; i++){
    int l, r;
    cin >> l >> r;
    n += r-l+1;
    
  }
  cout << n << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if( a < b){
			System.out.println("a < b");
		}else if(a > b ){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17324
using System;
class c
{
    static void Main()
    {
        Console.ReadLine();
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        int ans = int.MaxValue;
        for (int i = 0; i < s.Length; i++)
        {
            for (int j = 0; j < s.Length; j++)
            {
                if (s[i + j] != t[j]) break;
                else if (i + j == s.Length - 1)
                {
                    ans = Math.Min(ans, s.Length + i);
                    break;
                }
            }
        }
        Console.WriteLine(ans == int.MaxValue ? 2 * s.Length : ans);
    }
}

Measured memory_bytes: 11092