akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

void Show(int *array, int n){
    for(int i=0; i<n; ++i){
        if(i != n-1){
            std::cout << array[i] << " ";
        }else{
            std::cout << array[i];
        }
    }
    std::cout << std::endl;
}

int main() {
    int n;
    int A[110];
    int c = 0;

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

    bool flag = true;
    
    for(int i=0; flag; ++i){
        flag = false;
        for(int j = n-1; j>=i+1; j--){
            if(A[j] < A[j-1]){
                std::swap(A[j], A[j-1]);
                flag = true;
                c++;
            }
        }
    }
    
    Show(A, n);
    std::cout << c << std::endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_max int(1e5)


bool comp(pair<llong,llong>a,pair<llong,llong>b){
    return a.first < b.first;
}

int main(){
    int n;
    llong k;
    cin >> n >>k;
    pair<llong,llong> A[n_max+5];
    llong a,b;
    REP(i,n){
        scanf("%lld%lld",&a,&b);
        A[i] = make_pair(a,b);
    }
    sort(A,A+n,comp);
    llong cnt=0;
    int i=0;
    while(1){
        if(cnt + A[i].second >=k) break;
        cnt += A[i].second;
        i+=1;
    }
    cout << A[i].first << endl;
}

Measured memory_bytes: 1792
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.readline
readlines=sys.stdin.buffer.readlines

# 0-indexed
class UnionFind:
  N=0
  parent=None
  size=None
  def __init__(self,N):
    self.N=N
    self.parent=[i for i in range(self.N)]
    self.size=[1]*self.N
    
  def root(self,x):
    while x!=self.parent[x]:
      self.parent[x]=self.parent[self.parent[x]]
      x=self.parent[x]
    return x
  
  def same(self,x,y):
    return self.root(x)==self.root(y)
  
  def unite(self,x,y):
    x=self.root(x)
    y=self.root(y)
    if x==y:
      return
    if self.size[x]>self.size[y]:
      # 大きい方にくっつける
      self.parent[y]=x
      self.size[x]+=self.size[y]
    else:
      self.parent[x]=y
      self.size[y]+=self.size[x]
      
  def get_group_size(self,x):
    return self.size[self.root(x)]
  
  def get_roots(self):
    r=set()
    for i in range(self.N):
      r.add(root(i))
    return r
  
  def show_parent(self):
    print(self.parent)
    
  def show_size(self):
    print(self.size)
    
N,M,K=map(int,readline().split())
UF=UnionFind(N)
friends=[0]*N
for i in range(M):
  a,b=map(int,readline().split())
  UF.unite(a-1,b-1)
  friends[a-1]+=1
  friends[b-1]+=1

from collections import defaultdict
block=defaultdict(set)
for i in range(K):
  c,d=map(int,readline().split())
  block[c-1].add(d-1)
  block[d-1].add(c-1)

ans=[0]*N
for i in range(N):
  ans[i]=UF.get_group_size(i)-friends[i]-1
  for b in block[i]:
    if UF.same(i,b):
      ans[i]-=1
  if ans[i]<0:
    ans[i]=0
print(*ans)

Measured memory_bytes: 55640
#include<iostream>
using namespace std;
int main(){
    int n, a[3][3], b[10];
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> b[i];
    }
    
    for (int k = 0; k < n; k++){
        for (int i = 0; i < 3; i++){
            for (int j = 0; j < 3; j++){
                if (b[k] == a[i][j]){
                    a[i][j] = 0;
                }
            }
        }
    }
    for (int i = 0; i < 3; i++){
        if ((a[i][0] == a[i][1] && a[i][2] == a[i][1])
        || (a[0][i] == a[1][i] && a[2][i] == a[1][i])
        || (a[0][0] == a[1][1] && a[2][2] == a[1][1])
        || (a[2][0] == a[1][1] && a[0][2] == a[1][1])){
            cout << "Yes";return 0;
        }
    }
    cout << "No";return 0;
}

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

int n, a[100010], sol = 0;

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++)
	{
		if (a[i] == i + 1)
		{
			sol++;
			if (i < n - 1 and a[i + 1] == i + 2) i++;
		}
	}
	cout << sol;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin>>x;
    if(x>=30)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  int size = s.size();
  for(int i=0; i<size; i++){
    if(s.at(i) != t.at(i)){
      cout << "No";
      break;
    }
    else if(i == size-1)
      cout << "Yes";
  }
      
}


Measured memory_bytes: 3632
object Main extends App {
  import scala.util.control.Breaks._
  val nums = io.StdIn.readLine().toCharArray.map(_-48)
  breakable {
    for (bit <- 0 until 1 << 3) {
      var acc = nums(0)
      val builder = StringBuilder.newBuilder
      builder.append(nums(0))
      for (i <- 0 to 2; n = nums(i+1)) {
        val n = nums(i+1)
        if ((bit >> i & 1) == 0) {builder.append('+'); acc = acc + n}
        else {builder.append('-'); acc = acc - n}
        builder.append(n)
      }
      if (acc == 7) {println(builder.toString() + "=7"); break}
    }
  }
}

Measured memory_bytes: 27452
#include<iostream>
#include<vector>
#include<numeric>


using si = signed long int;
using ull = unsigned long long;

int main(){
	si n, k;
	std::cin >> n >> k;

	//auto sum_ = []( ull x )->ull {
	//	return x > 0 ? x * ( x + 1 )/2 : 0;
	//};

	const auto p = 1000000000 + 7;

	std::vector<ull> N_(n+1);
	std::iota( std::begin( N_ ), std::end( N_ ), 0 );

	//for( const auto e : N_ )
	//	std::cout << e << " ";

	ull ans = 0;
	auto max_ = std::accumulate( std::rbegin( N_ ), std::rbegin( N_ ) + k-1, ull{} );
	auto min_ = std::accumulate( std::begin( N_ ), std::begin( N_ ) + k-1, ull{} );

//	std::cout << min_ << " " << max_ << "\n";

	for( si i = k; i <= n + 1; ++i )
	{
		max_ += *( std::crbegin(N_) + i -1);
		min_ += *( std::cbegin( N_ ) + i-1 );
		ans +=  max_ - min_ + 1 ;
		ans %= p;
//		std::cout << min_ << ":" << max_ << ":" << ans << "\n";
	}

	std::cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 4436
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(b==1){
            System.out.println(0);
        }else{
            System.out.println((b-2)/(a-1)+1);
        }
    }


}


Measured memory_bytes: 25044
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n;
	cin >> n;
	vector<pair<char, int>> a(n), b(n);
	rep(i, n) {
		char x; int y;
		cin >> x >> y;
		a[i] = mp(x, y);
		b[i] = mp(x, y);
	}

	//bubble sort
	rep(i, n) {
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j].second < a[j - 1].second)swap(a[j], a[j - 1]);
		}
	}

	//selection sort
	rep(i, n) {
		int mini = i;
		FOR(j, i, n) {
			if (b[j].second < b[mini].second)mini = j;
		}
		swap(b[i], b[mini]);
	}

	rep(i, n) {
		cout << a[i].first << a[i].second;
		printf(i == n - 1 ? "\n" : " ");
	}
	puts("Stable");

	rep(i, n) {
		cout << b[i].first << b[i].second;
		printf(i == n - 1 ? "\n" : " ");
	}
	puts(a == b ? "Stable" : "Not stable");
}


Measured memory_bytes: 3228
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

n=inp[0]
st = []
3.times{st<<gets.chomp}
ans = 0
n.times do |i|
  if st[0][i] == st[1][i] and st[1][i] == st[2][i]
    ans += 0
  elsif st[0][i] == st[1][i] or st[1][i] == st[2][i] or st[0][i] == st[2][i]
    ans += 1
  else
    ans += 2
  end
end
p ans

Measured memory_bytes: 3836
#include<iostream>

using namespace std;

int main(){
  int c1,c2,c3,p;
  while(cin>>c1>>c2>>c3){
    p=20-(c1+c2);
    if(c1<=p)p--;
    if(c2<=p)p--;
    if(c3<=p)p--;
    if (p>3)cout<<"YES"<<endl;
    else cout<< "NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[5];
int main()
{
	scanf("%s",a);
	int l=strlen(a);
	sort(a,a+4);
	if(a[0]==a[1]&&a[2]==a[3]&&a[0]!=a[2])printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define MOD (ll)1e9+7
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    string a,b;cin>>a>>b;
    bool state=1;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i]){
            cout<<"No\n";state=0;break;
        }
    }
    if(!state)return 0;
    if(b.size()-1==a.size())cout<<"Yes\n";
    else cout<<"No\n";
}


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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {

    int N,M;
    cin >> N >> M;
    int H[N+1];
    for(int i=1;i<=N;++i) cin >> H[i];
    bool ch[N+1];
    for(int i=1;i<=N;++i) ch[i]=true;
    for (int i = 0; i < M; i++)
    {
        int a,b;
        cin >> a >> b;
        if(H[a] <= H[b]) ch[a] = false;
        if(H[a] >= H[b]) ch[b] = false;
    }
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        if(ch[i]) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4112
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
	int n,x=0,y=0;
	int ary[8] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a < 3200) ary[a / 400] = 1;
		else x++;
	}
	for (int i = 0; i < 8; i++) {
		if (ary[i] == 1) y++;
	}
	if (y == 0) cout << "1" << " " << x << endl;
	else cout << y << " " << y + x << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    map<int,int> m;
    rep(i,n) m[a[i]]++;
    ll ans = m.size();
    ll sum = 0;
    for(auto t : m){
        sum += t.second - 1;
    }
    if(sum%2!=0) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	int a,b,c;
	cin >> a>>b>>c;
	if (a % b == 0)cout << a / b * c << endl;
	else cout << (a / b + 1) * c << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>

using namespace std;

int main(){
	int n;
	long long march[5] = {0};
	const char pat[] = "MARCH";

	cin >> n;
	for(int i=0; i<n ;i++){
		string s;
		cin >> s;
		for(int t=0; t<5; t++){
			if(pat[t] == s[0])
				march[t] += 1;
		}
	}

	long long ans = 0;

	for(int a=0; a<5; a++)
		for(int b=a+1; b<5; b++)
			for(int c=b+1; c<5; c++){
				ans += march[a] * march[b] * march[c];
			}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        l = len(s)
        self.pw = pw = [1]*(l+1)
        self.h = h = [0]*(l+1)
        for i in range(l):
            h[i+1] = (h[i] * base + ord(s[i])) % mod
            pw[i+1] = pw[i] * base % mod

    def get(self, l, r): # [l, r)
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

def main():
  s = input()
  t = input()
  ls,lt = len(s), len(t)
  m = (ls+lt-1)//ls + 1
  s *= m
  s1 = RollingHash(s, 1007, 10**9+7)
  t1 = RollingHash(t, 1007, 10**9+7)
  w = t1.get(0,lt)
  g = [None]*ls
  for i in range(ls):
    if s1.get(i, i+lt) == w:
      g[i] = (i+lt)%ls
  
  f = [None]*ls
  for i in range(ls):
    if f[i] is None:
      f[i] = ls
      q = [i]
      while q:
        if g[q[-1]] is None:
          f[q[-1]] = 0
          q.pop()
        elif f[g[q[-1]]] is None:
          q.append(g[q[-1]])
        else:
          f[q[-1]] = f[g[q[-1]]] + 1
          q.pop()
  print(max(f) if max(f) < ls else -1)
  return
  
main()

Measured memory_bytes: 203292
while True:
    N = int(input())
    if not N: break
    seeds = []
    for i in range(N):
        plant = input().split()
        name, price = plant[0], int(plant[1])
        seed_to_leaf, leaf_to_fruit = sum(map(int, plant[2:5])), sum(map(int, plant[5:7]))
        num_per, sold, mult = int(plant[7]), int(plant[8]), int(plant[9])
        seeds.append((-(num_per * sold * mult - price) / (seed_to_leaf + leaf_to_fruit * mult), name))
    for _, name in sorted(seeds):
        print(name)
    print('#')

Measured memory_bytes: 6728
#include <bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << endl
#define REP(i , n) for(Long i = 0; i < (Long)n ; i++)
#define fore(i, a, b) for (Long i = a, to = b; i < to; i++)
#define foref(i, a, b) for (Long i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back

using namespace std;
typedef long long Long;
typedef pair<Long, Long> Pair;

const int MX=(2e5);
const Long INF=(1e18);
Long A[MX+2];
Long acum[MX+2];
Long acum2[MX+2];
int n;
set<Long> S1,S2;
Long ans = INF;
void solve(vector<Pair> izq,vector<Pair> der){
	fore(i,0,SZ(izq)){
		fore(j,0,SZ(der)){
			vector<Long> asd;
			asd.pb(izq[i].first);
			asd.pb(izq[i].second);
			asd.pb(der[j].first);
			asd.pb(der[j].second);
			//fore(k,0,4)cout<<asd[k]<<(char)(k+1==4?10:32);
			sort(all(asd));
			ans = min(ans,asd[3] - asd[0]);
		}
	}
}

void show(){
	cout<<"der"<<endl;
	for(auto x:S1){
		cout<<x<<" ";
	}
	cout<<endl;
	cout<<"izq"<<endl;
	for(auto x:S2){
		cout<<x<<" ";
	}
	cout<<endl;
}

void prueba(Long current){
	//show();
	Long search1 = current/2;
	auto it = S1.lower_bound(search1);
	vector<Pair> izq;
	if(it!=S1.end()){
		Long p = (*it);
		Long q = current - p;
		izq.pb({p,q});
	}
	if(it!=S1.begin()){
		it--;
		Long p = (*it);
		Long q = current - p;
		izq.pb({p,q});
	}
	
	Long total = acum[n-1] - current;
	Long search2 = total/2;
	auto it2 = S2.lower_bound(search2);
	vector<Pair> der;
	if(it2!=S2.end()){
		Long p = (*it2);
		Long q = total - p;
		der.pb({p,q});
	}
	if(it2!=S2.begin()){
		it2--;
		Long p = (*it2);
		Long q = total - p;
		der.pb({p,q});
	}
	solve(izq,der);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	fore(i,0,n) cin>>A[i];
	acum[0] = A[0];
	fore(i,1,n) acum[i]=A[i] + acum[i-1];
	
	acum2[n-1] = A[n-1];
	foref(i,0,n-1){
		acum2[i] = acum2[i+1] + A[i];
	}
	fore(i,0,n) S2.insert(acum2[i]);
	
	fore(i,0,n){
		S1.insert(acum[i]);
		S2.erase(acum2[i]);
		if(i>0 && i<n-2)prueba(acum[i]);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main (){
    int N;
    long long a[100007]={};

    int k = 1;
    long long l[3]={};

    cin >> N;
    rep(i,N){
        cin >> a[i];
    }

    sort(a,a+N);
    
    for(int i=N-1; i>0; i--){
        if(a[i]==a[i-1]){
            l[k] = a[i];
            k++;
            i--;
            if(k==3){
                break;
            }
            continue;
        }
        
    }

    cout << l[1]*l[2] << endl;


}

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second	
typedef pair < int , int > pp;

signed main(){
	int L;
    cin >> L;
    int t = 1;
    vector < pair< pp , int > > ans;
    for(int i=19; i>=2; i--){
        ans.pb(mp(mp(i,i+1),0));
        ans.pb(mp(mp(i,i+1),t));
        t = t+t;
    }
    
    t = 0;
    for(int i=0; i<=18; i++){
        if(L & (1 << i)){
	        ans.pb(mp(mp(1,20-i),t));
            t += (1 << i);
        }
    }
    
    if(L & (1 << 19)){
        ans.pb(mp(mp(1,2),t));
        t += (1 << 18);
        ans.pb(mp(mp(1,2),t));
    }
        
    cout << "20 " << ans.size() << endl;
    for(int i=0; i<ans.size(); i++)
        cout << ans[i].st.st << " " << ans[i].st.nd << " " << ans[i].nd << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
   double n,k; cin>>n>>k;
  long double ans=0,memo=0;
  
  rep(i,n){
    if(i+1>=k)ans+=2;
    else ans+=pow(0.5,ceil(log2(k/(i+1))-1));
  }
  
  ans/=2*n;
  cout<<fixed<<setprecision(12);
  cout<<ans<<endl;
}


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

#define ll long long
#define pii pair<int,int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(int i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

const int MOD = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

void kekek()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef EBUCHKA
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
}

long long dp[100228][20];

long long powt(int pw) {
    long long ans = 1;
    for (int i = 0; i < pw; i++) {
        ans *= 10;
        ans %= 13;
    }
    return ans;
}

int main() {
    kekek();
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    int st = -1;
    if (s[0] == '?') {
        for (int i = 0; i < 10; i++) {
            dp[1][i] = 1;
        }
        st = 2;
    }
    else {
        dp[1][(int)(s[0] - '0')] = 1;
        st = 2;
    }
    long long pwt = 1;
    for (int i = 1; i <= (int)s.size(); i++) {
        if (s[i - 1] == '?') {
            for (int j = 0; j <= 9; j++) {
                for (int k = 0; k < 13; k++) {
                    int t = (j * pwt) % 13 + k;
                    dp[i][t % 13] += (dp[i - 1][k] % MOD);
                    dp[i][t % 13] %= MOD;
                }
            }
        }
        else {
            for (int k = 0; k < 13; k++) {
                int t = (int)(s[i - 1] - '0') * pwt;
                t = (t + k) % 13;
                dp[i][t] += (dp[i - 1][k] % MOD);
                dp[i][t] %= MOD;
            }
        }
        pwt *= 10;
        pwt %= 13;
    }
    cout << dp[(int)s.size()][5];
}

Measured memory_bytes: 16080
#include<iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '?')break;
        if(op == '+'){
            cout << a+b << endl;
        }else if(op == '-'){
            cout << a-b << endl;
        }else if(op == '/'){
            cout << a/b << endl;
        }else{
            cout << a*b << endl;
        }
    }return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ll long long

#define INF 999999999

using namespace std;

// input
int a,b,x;

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

    cin >> x >> a >> b;

    if(abs(x-a)<abs(x-b)){
        cout << "A" << "\n";
    }
    else{
        cout << "B" << "\n";
    }
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<cmath>
#include<iostream>
#include<cstring>
#include<map>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=200005;
int n,m,h[MAXN],ans,egcnt,head[MAXN];
struct _EDGE
{
    int to,nxt;
}e[MAXN<<1];

inline void addedge(int from,int to)
{
    e[++egcnt].to=to;
    e[egcnt].nxt=head[from];
    head[from]=egcnt;
    e[++egcnt].to=from;
    e[egcnt].nxt=head[to];
    head[to]=egcnt;
}

inline bool check(int rt)
{
    for (register int i = head[rt]; i; i = e[i].nxt)
        if(h[e[i].to] >= h[rt])
        {
            return false;
        }

    return true;
}

int main()
{
    read(n);
    read(m);
    for (register int i=1;i<=n;++i) read(h[i]);
    while(m--)
    {
        int a, b;
        read(a);
        read(b);
        addedge(a,b);
    }
    for (register int i=1;i<=n;++i)
        if(check(i)) ++ans;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 6096
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()

	arr := make([]int, n+1)
	for i := 0; i <= n; i++ {
		arr[i] = sc.NextInt()
	}

	prev := 0
	ans := 0
	for i := 0; i < n; i++ {
		b := sc.NextInt()
		if prev > arr[i] {
			ans += arr[i]
			prev = b
			continue
		}
		ans += prev
		arr[i] -= prev
		if arr[i] > b {
			prev = 0
			ans += b
		} else {
			prev = b - arr[i]
			ans += arr[i]
			prev = b - arr[i]
		}
	}
	if prev > arr[n] {
		ans += arr[n]
	} else {
		ans += prev
	}
	fmt.Printf("%+v\n", ans) // output for debug

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  queue<int> que;
  que.push(3);que.push(5);que.push(7);
  int a = 0;
  while(true){
    a = que.front();
    que.pop();
    if(a > n) break;
    que.push(a*10+3);
    que.push(a*10+5);
    que.push(a*10+7);
    int tmp = a;
    unordered_set<int> judge;
    while(tmp > 0){
      judge.insert(tmp%10);
      tmp /= 10;
    }
    if(judge.size() == 3) ans++;
    
  }
  cout << ans <<endl;
}

Measured memory_bytes: 640
def check_jp(passed, A, B):
    return passed < A + B


def check_foreign(passed, A, B, passed_b):
    return passed < A + B and passed_b < B


def resolve():
    N, A, B = map(int, input().split())
    S = list(input())

    passed = 0
    passed_b = 0
    for i, p in enumerate(S):
        if p == "a":
            if check_jp(passed, A, B):
                print("Yes")
                passed += 1
            else:
                print("No")
        elif p == "b":
            if check_foreign(passed, A, B, passed_b):
                print("Yes")
                passed += 1
                passed_b += 1
            else:
                print("No")
        else:
            print("No")

resolve()

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

const long long N = 1e5+7;
vector<pair<long long, long long>> cols[N], rows[N];
vector<pair<long long, long long>> adj[N];
long long rowbound[N], colbound[N];

bool bad;
bool vis[N];
long long id[N];
long long value[N], root[N];
long long dfs(long long u, long long val, long long s) {
    assert(!vis[u]);
    vis[u] = 1;
    value[u] = val;
    id[u] = s;

    long long ans = value[u];

    for (auto pr: adj[u]) {
        long long v = pr.first;
        long long d = pr.second;

        if (!vis[v])    ans = min(ans, dfs(v, val+d, s));
        if (value[v] != val+d)  bad = true;
    }
    return ans;
}

bool okay(vector<pair<long long, long long>> *rows, long long R, long long C, long long *bound) {
    for (long long i=1; i<=C; i++) adj[i].clear(), vis[i] = 0;

    for (long long i=1; i<=R; i++) {
        sort(rows[i].begin(), rows[i].end());
        for (long long j=1; j<rows[i].size(); j++) {
            long long x = rows[i][j-1].first, y = rows[i][j].first;
            long long d = rows[i][j].second - rows[i][j-1].second;
            adj[x].push_back({y, d});
            adj[y].push_back({x, -d});
//
//            cout<<x << " to " << y<<" "<<d<<endl;
//            cout<<y << " to " << x<<" "<<-d<<endl;
        }
    }
    bad = false;
    for (long long i=1; i<=C; i++) {
        if (vis[i])    continue;
        long long mn = dfs(i, 0, i);
        root[i] = mn;
//        cout<<"Comp at "<<i<<" "<<mn<<endl;
    }

    for (long long i=1; i<=C; i++) {
        long long lo = value[i] - root[id[i]];
        bound[i] = lo;
//        cout<<"Bound "<<i<<" "<<value[i]<<" "<<id[i]<<" "<<bound[i]<<endl;
        assert(bound[i] >= 0);
    }
    return !bad;
}

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

    long long R, C;
    cin>>R>>C;

    long long n;
    cin>>n;

    vector<tuple<long long, long long, long long>> cells;
    for (long long i=1; i<=n; i++) {
        long long x, y, v;
        cin>>x>>y>>v;
        rows[x].push_back({y, v});
        cols[y].push_back({x, v});
        cells.push_back({x, y, v});
    }

    bool good = okay(rows, R, C, colbound) && okay(cols, C, R, rowbound);

    for (auto tp: cells) {
        long long x = get<0> (tp);
        long long y = get<1> (tp);
        long long v = get<2> (tp);

        good &= (rowbound[x]<=v && colbound[y]<=v);
    }
    if (good)   cout<<"Yes\n";
    else        cout<<"No\n";
}


Measured memory_bytes: 29508
import java.lang.Math;
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();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int answer = 0;
        if (A/2 + B/2 >= C) {
            if (X >= Y) {
                answer += C * Y * 2;  // 要求数が少ない方を先に充足させる
                if (A*(X-Y) < C*2*(X-Y)) {  // 要求数が多い方の要求数も, 少ない方の要求数だけ減っている
                    answer += A * (X-Y);
                }
                else {
                    answer += C*2 * (X-Y);
                }
            }
            else {
                answer += C * X * 2;
                if (B*(Y-X) < C*2*(Y-X)) {
                    answer += B * (Y-X);
                }
                else {
                    answer += C*2 * (Y-X);
                }
            }
        }
        else {
            answer += A * X + B * Y;
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  105
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l,r,a=0,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n;
    map<ll,int> M;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
            {
                M[i]++;
                n/=i;
            }
        }
    }
    if(n!=1) M[n]++;
    ll ans = 0;
    for(auto it:M)
    {
        for(i=1;i<=it.S;i++)
        {
            ans += 1;it.S -= i;
        }
    }

    cout << ans ;

}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 3656
# frozen_string_literal: true

n = gets.to_i
p = gets.split.map(&:to_i)

sp = p.sort

count = 0
0.upto(n - 1) do |i|
  count += 1 if p[i] != sp[i]
end

if count.zero? || count == 2
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 1788
import sys
input = sys.stdin.readline

class Bingo():
    def __init__(self, board):
        self.board = board
        self.length = 3
        self.check = [[False] * self.length for i in range(self.length)]
    
    def punch(self, num):
        for i in range(self.length):
            for j in range(self.length):
                if self.board[i][j] == num:
                    self.check[i][j] = True

    def bingo_count(self):
        ret = 0
        # 横方向
        for i in range(self.length):
            ok = True
            for j in range(self.length):
                if not self.check[i][j]:
                    ok = False
                    break
            if ok:
                ret += 1
        # 縦方向
        for i in range(self.length):
            ok = True
            for j in range(self.length):
                if not self.check[j][i]:
                    ok = False
                    break
            if ok:
                ret += 1
        # ななめ
        ok = True
        for i in range(self.length):
            if not self.check[i][i]:
                ok = False
                break
        if ok:
            ret += 1
        
        ok = True
        for i in range(self.length):
            if not self.check[i][-i-1]:
                ok = False
                break
        if ok:
            ret += 1
        
        return ret

def main():
    bingo = Bingo([list(map(int, input().split())) for i in range(3)])
    N = int(input())

    for _ in range(N):
        b = int(input())
        bingo.punch(b)
    
    if bingo.bingo_count() > 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

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

int main(){
  int n;
  int allgcd;
  bool pairwise=true;

  vector<bool> st(1000005);//素因数
  vector<bool> sosu(1000005);

  for(int i=2;i<1000001;i++){
    bool flag=true;
    for(int j=2;j*j<=i;j++){
      if(i%j==0)flag=false;
    }
    if(flag)sosu[i]=true;
  }

  cin >> n;
  rep(i, n){
    int tmp;
    cin >> tmp;
    //setwiseの判定
    if(i==0)allgcd = tmp;
    else allgcd = gcd(allgcd, tmp);
    //pairwiseの判定
    if(tmp==1)continue;
    if(pairwise){
      if(sosu[tmp]==true){
        if(st[tmp]==true)pairwise=false;
        else st[tmp]=true;
      }else{
        for(int a=2;a*a<=tmp;a++){
          if(tmp%a!=0)continue;
          while(tmp%a==0){
            tmp/=a;
          }
          // cout << "[" << a << "]";
          if(st[a]==true)pairwise=false;
          else st[a]=true;
          if(tmp>2){
            // cout << "[" << tmp << "]";
            if(st[tmp]==true)pairwise=false;
            else st[tmp]=true;
          }
        }
      }
    }
  }

  if(pairwise)cout << "pairwise coprime";
  else if(allgcd==1)cout << "setwise coprime";
  else cout << "not coprime";

  return 0;
}


Measured memory_bytes: 3848
import sys


class BinarySearchTree:
    class Node:
        def __init__(self, value):
            self.value = value
            self.left = None
            self.right = None

        def has_left(self):
            return self.left is not None

        def has_right(self):
            return self.right is not None

        def __str__(self):
            return str(self.value)

    def __init__(self):
        self.root = None

    def insert(self, value):
        if self.root is None:
            self.root = self.Node(value)
            return

        node = self.root
        while True:
            if node.value > value:
                if node.has_left():
                    node = node.left
                else:
                    node.left = self.Node(value)
                    break
            else:
                if node.has_right():
                    node = node.right
                else:
                    node.right = self.Node(value)
                    break

    def preorder(self):
        def _preorder(node):
            yield node
            if node.has_left():
                yield from _preorder(node.left)
            if node.has_right():
                yield from _preorder(node.right)
        if self.root is not None:
            yield from _preorder(self.root)

    def inorder(self):
        def _inorder(node):
            if node.has_left():
                yield from _inorder(node.left)
            yield node
            if node.has_right():
                yield from _inorder(node.right)
        if self.root is not None:
            yield from _inorder(self.root)

    def postorder(self):
        def _postorder(node):
            if node.has_left():
                yield from _postorder(node.left)
            if node.has_right():
                yield from _postorder(node.right)
            yield node
        if self.root is not None:
            yield from _postorder(self.root)


def run():
    _ = int(input())
    tree = BinarySearchTree()

    for line in sys.stdin:
        command = line.split()
        if command[0] == 'insert':
            tree.insert(int(command[1]))
        elif command[0] == 'print':
            inorder = ''
            for node in tree.inorder():
                inorder += " {}".format(node)
            print(inorder)
            preorder = ''
            for node in tree.preorder():
                preorder += " {}".format(node)
            print(preorder)
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()



Measured memory_bytes: 118052
from collections import deque

N,M = map(int,input().split())

p = list(map(int,input().split()))

for i in range(N):
    p[i] -= 1

data = [[] for i in range(N)]

for i in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    data[x].append(y)
    data[y].append(x)

group = [0] * N
count = 1
for i in range(N):
    if group[i] != 0:
        continue
    group[i] = count
    stack = deque([[i,i]])
    while stack:
        x = stack.pop()
        for y in data[x[1]]:
            if y == x[0] or group[y] != 0:
                continue
            stack.append([x[1],y])
            group[y] = count
    count += 1

#print(group)

p_inv = [0] * N

for i in range(N):
    p_inv[p[i]] = i

ans = 0

for i in range(N):
    if group[i] == group[p_inv[i]]:
        ans += 1

print(ans)




Measured memory_bytes: 72684
def ans_is_zero():
    print(0)
    exit(0)

def solve():
    n=int(input())
    if n > 23: ans_is_zero()

    d=list(map(int,input().split()))
    for num in d:
        if num == 0: ans_is_zero()

    ans=0
    d.sort()

    N = 1 << n
    for i in range(N):#left or right
        t=1
        ret = 100

        for j in range(n):
            if (i>>j)&1: num = d[j]
            else: num = 24 - d[j]

            if (t >> num)&1:
                ret = -1
                break
            t |= (1 << num)

        if ret == -1: continue
        prev = 0

        for j in range(1, 24):
            if ((t>>j)&1) == 0: continue
            ret = min(ret, j - prev)
            prev = j

        ret = min(ret, 24-prev)
        ans = max(ans, ret)
    print(ans)
solve()


Measured memory_bytes: 68276
n = int(input())

list = list(map(int, input().split()))

list = [0] + list + [0]

total = 0

#まずはすべての地点を経由する場合(最大値)にどれくらいコストがかかるのか計算する
for i in range(n+1):
    total += abs(list[i + 1] - list[i])

#最大値から地点i-1から地点iまでの距離、地点iから地点i+1までの距離を引き、地点i-1から地点i+1までの距離を足してあげる
for i in range(1, n+1):
    print(total - abs(list[i] - list[i-1]) - abs(list[i+1] - list[i]) + abs(list[i+1] - list[i-1]))

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

int main(){
  int n;
  cin >> n;
  vector <int> p(n);
  for (int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  cout << accumulate(p.begin(), p.end(),0)-*max_element(p.begin(), p.end())/2 <<endl;
}



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

typedef long long          ll;
typedef long double        ld;
typedef unsigned long long ull;
typedef vector<ll>         vl;
typedef vector<vl>         vvl;
typedef pair<ll,ll>        pll;
typedef vector<pll>        vpll;

#define ff          first
#define ss          second
#define mp          make_pair
#define mt          make_tuple
#define pb          push_back
#define eb          emplace_back
#define fr(i,n)     for(ll i = 0; i < n; ++i)
#define frs(i,s,n)  for(ll i = s; i < n; ++i)
#define frb(i,s,e)  for(ll i = s; i <= e; ++i)
#define rfr(i,n)    for(ll i = n-1; i >= 0; i--)
#define frbr(i,e,s) for(ll i = e; i >= s; i--)
#define all(x)      (x).begin(), (x).end()
#define sz(x)       ((ll)(x).size())

#ifdef LOCAL
#include </home/udaya_bhaskar/Desktop/debugger.h>
#else
#define dbg(x...)      {}
#define dbg_arr(a,n)   {}
#define dbg_mat(m,r,c) {}
#define dbg_time()     {}
#endif

const ll MOD  = 1e9+7; // 998244353;
const ll INF  = 1e18;
const ll MAX  = 100100;




void pre()
{
  // factorizer::sieve();
  // prepare_factorials();
}




void solve()
{
  string s; cin >> s; 
  if(s[sz(s) - 1] == 's')
  	s += "es";
  else
  	s += "s";
  cout << s << "\n";
}




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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  // cout << fixed << setprecision(15);
  
  pre();

  ll t = 1;
  // cin >> t;
  frb(CASE, 1, t)
  {
    // cout << "Case #" << CASE << ": ";
    // dbg(CASE);
    solve();
  }

  dbg_time();
  
  return 0;
}     
     


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main(void) {
  int N;
  unsigned long int M=0, A=0, R=0, C=0, H=0;
  unsigned long int result = 0;
  string tmp;

  cin >> N;
  for(int i=0;i < N;i++) {
    cin >> tmp;
    if (tmp[0] == 'M') {
      M++;
    } else if (tmp[0] == 'A') {
      A++;
    } else if (tmp[0] == 'R') {
      R++;
    } else if (tmp[0] == 'C') {
      C++;
    } else if (tmp[0] == 'H') {
      H++;
    }
  }

  result = M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + M*C*H + A*R*C + A*R*H + A*C*H + R*C*H;

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import deque
def bfs(succs, preds, start):
    saisyoku = {}
    queue = deque([start])
    used = 0
    while queue:
        v = queue.popleft()
        for u in preds[v]:
            used = saisyoku[preds[v][u]]
        c = 1
        for w in succs[v]:
            if used and c == used:
                c += 1
            saisyoku[succs[v][w]] = c
            queue.append(w)
            c += 1
    return saisyoku
  
n = int(input())
vertices = range(1, n+1)
edges = [list(map(int, input().split())) for _ in range(n-1)]
jisu = {v: 0 for v in vertices}
succs = {v: {} for v in vertices}
preds = {v: {} for v in vertices}
for i, (u, v) in enumerate(edges):
  succs[u][v] = i
  preds[v][u] = i
  jisu[u] += 1
  jisu[v] += 1
colors = max(jisu.values())
print(colors)
saisyoku = bfs(succs, preds, 1)
for _, c in sorted(saisyoku.items()):
    print(c)

Measured memory_bytes: 133248
dic = {0:"A", 1:"B", 2:"C", 3:"D", 4:"E"}
while True:
  sa = list(map(int, input().split()))
  if sa == [0, 0]:
    break
  lst = [sum(sa)]
  for _ in range(4):
    lst.append(sum(map(int, input().split())))
  print(dic[lst.index(max(lst))], max(lst))


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
int m,n,ans;
bool d[92][92];
int dx[] = {0,-1,0,1};
int dy[] = {1,0,-1,0};

void dfs(int i,int j,bool t[][92],int sum){
	ans = max(ans,sum);
	t[i][j] = false;
	for(int h = 0;h < 4;h++){
		int nx = i + dx[h];
		int ny = j + dy[h];
		if(nx >= 0 && nx < n && ny >= 0 && ny < m && t[nx][ny] == true)dfs(nx,ny,t,sum+1);
	}
	t[i][j] = true;
	return;
}

int main(){
while(1){
	cin >> m >> n;
	if(m == 0 && n == 0)break;
	ans = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			cin >> d[i][j];
		}
	}

	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			if(d[i][j] == true) dfs(i,j,d,1);
		}
	}
	printf("%d\n",ans);
}
	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
  static int count = 0;

  static void insertionSort(int[] a, int n, int g) {
    int t, j;
    for (int i = g; i < n; i++) {
      t = a[i];
      j = i - g;
      while (j >= 0 && a[j] > t) {
        a[j + g] = a[j];
        j -= g;
        count++;
      }
      a[j + g] = t;
    }
  }

  static void shellSort(int[] a, int n) {
    int g = 1;
    int m = 0;
    for (int g_tmp = 1; g_tmp <= n; g_tmp = 3 * g_tmp + 1) {
      g = g_tmp;
      m++;
    }
    System.out.println(m);
    int[] G = new int[m];
    for (int i = 0; i < m; i++) {
      G[i] = g;
      g = g / 3;
      insertionSort(a, n, G[i]); 
      System.out.print(G[i]);
      if (i != m - 1) System.out.print(" ");
      else System.out.println();
    }
  }

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) 
      a[i] = stdIn.nextInt();
    shellSort(a, n);
    System.out.println(count);
    for (int i = 0; i < n; i++)
      System.out.println(a[i]);
  }
}

Measured memory_bytes: 299320
N = int(input())
A = [0]
A += list(map(int, input().split()))
A += [0]

cost = [abs(A[i] - A[i+1]) for i in range(N+1)]
original_cost = sum(cost)

for i in range(N):
    ans = original_cost
    ans -= cost[i]
    ans -= cost[i+1]
    ans += abs(A[i] - A[i+2])
    
    print(ans)

Measured memory_bytes: 14048
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
char s[10000];
signed main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	bool bl=0;
	for (int i=1;i<=len;i++)
	{
		if (s[i]=='7')
		{
			bl=1;
			break;
		}
	}
	if (bl) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 3684