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

#define    ll     long long int

int main( )
{
    ll n, m, s;
    cin >> n >> m;
    if (n > m) swap(n, m);
    if (n == 1) {
        if (m == 1) {
            cout << "1\n";
            return 0;
        }
        cout << max(m - 2, 0LL) << '\n';
    }
    else {
        cout << ((n * m) - (2 * (n - 1) + 2 * (m - 1))) << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Dictionary<int,int> ret = new Dictionary<int, int>();
            foreach (var item in As)
            {
                if (!ret.ContainsKey(item))
                {
                    ret[item] = 1;
                }
                else
                {
                    ret[item]++;
                }
            }

            for (int i = 1; i <= N; i++)
            {
                if (ret.TryGetValue(i,out int val))
                {
                    Console.WriteLine(val);
                }
                else
                {
                    Console.WriteLine(0);
                }
            }
        }
    }
}

Measured memory_bytes: 52992
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll a[n];
    ll ans=0;
    rep(i,0,n){
        cin>>a[i];
        while(a[i]%2==0){
            ans++;
            a[i]/=2;
        }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long i,j,c,n,d,x,r,a[100],m=100;
int main(){
  for(cin>>n;i<n;i++)cin>>a[i],d+=a[i];
  for(i=0;i<n;i++){
    c+=a[i];
    m=min(m,abs(d-2*c));
  }
  cout<<m;
}

Measured memory_bytes: 256
import numpy as np 
import sys

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

def lcm(a, b):
    return (a * b)//gcd(a,b)

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

A = np.array(a)

while np.sum(A%2) == 0:
    A = A//2

if np.sum(A%2) != len(A):
    print("0")
    sys.exit()
    
tmp = 1##LCM

for i in range(N):
    tmp = lcm(tmp,a[i]//2)

if tmp > M:
    print("0")

else:
    print((M//tmp+1)//2)

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

int main()
{
    int a,b,c,k;
    cin >> a >>b >> c >> k;

    if(a < k)
    {
        if(b < k - a)
        {
            cout << a - (k - a - b) << endl;
        }
        else
        {
            cout << a << endl;
        }
        
    }
    else
    {
        cout << k << endl;
    }
    
}


Measured memory_bytes: 3636
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	print(n*n*n)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 5712
#include<stdio.h>
int main()
{
	int a,b,c,d,i,j,n,m,sum;
	sum=0;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
	{
		if((a<b&&b<=c&&c<d)||(c<d&&d<=a&&a<b))
		{sum=0;}
		if(a<=c&&c<=b&&b<=d)
		{sum=b-c;}
		if(a<=c&&c<=d&&d<=b)
		{sum=d-c;}
		if(c<=a&&a<=d&&d<=b)
		{sum=d-a;}
		if(c<=a&&a<=b&&b<=d)
		{sum=b-a;}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 128
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

class UnionFind:
    # uf = UnionFind(N)
    # for x, y in pairs: uf.unite(x, y)
    # ans = max([uf.size(i) for i in range(N)])
    def __init__(self, n):
        self.n = n
        self.sizes = [1]*n
        self.parents = list(range(n))

    def find(self, x):
        while x != self.parents[x]:
            self.parents[x] = self.parents[self.parents[x]]
            x = self.parents[x]
        return self.parents[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.parents[y] = x
        self.sizes[x] += self.sizes[y]

N, Q = rl()
uf = UnionFind(N)
for i in range(Q):
    t, u, v = rl()
    u, v = u-1, v-1
    if t == 0:
        uf.unite(u, v)
    else:
        if uf.find(u) == uf.find(v):
            print(1)
        else:
            print(0)


Measured memory_bytes: 77716
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	bool b=0;
	cin>>a;
	for(int i=0;i<3;i++){
		if(a[i]==a[i+1])
			b=1;
	}
	if(b==0)
		cout<<"Good"<<endl;
	else
		cout<<"Bad"<<endl;
	return 0;
}

Measured memory_bytes: 256
/// @pSaurabh

#include <bits/stdc++.h>

using namespace std;

#define read(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define print(a, n) for(int i = 0; i < n; i++) cout << a[i] << " ";

typedef long long ll;
const ll mod = 1e9 + 7;

void fast(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout .tie(0);
}

int main(){
	// fast();

	int n, k;
	cin >> n >> k;

	int h[n];
	read(h, n);

	int dp[n + 1];
	dp[0] = 0;

	for(int i = 1; i < n; i++){
		int c;

		dp[i] = INT_MAX;
		
		for(int j = i - 1; j >= max(i - k, 0); j--){
			c = dp[j] + abs(h[i] - h[j]);
			dp[i] = min(dp[i], c);
		}
	}

	cout << dp[n - 1];

	return 0;
}


Measured memory_bytes: 4400
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


#define NUM_2_MAX 1000000
#define INF (1e+12)

int64_t power(int64_t val, int num) {
    if(val > NUM_2_MAX) {
        return num == 1 ? val : INF+1;
    }
    int64_t ans = 1;
    while(num--) {
        if(ans > INF) return INF+1;
        ans *= val;
    }
    return ans;
}

int main(void) {
    int64_t num, prod;
    cin >> num >> prod;
    int prod_2 = sqrt(0.5 + prod);
    int64_t ans = 1;
    if(num == 1) {
        cout << prod << endl;
        return 0;
    }
    for(int div = 2; div <= prod_2; div++) {
        int64_t est;
        if(prod%div) continue;
        est = power(prod/div, num);
        if(prod%est == 0) { ans = prod/div; break; }
        est = power(div, num);
        if(prod%est == 0) ans = div;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
S=input()
def culc(s,a):
  a.sort()
  res=int(s[:a[0]])
  for i in range(1,len(a)):
    x=int(s[a[i-1]:a[i]])
    res+=x
  res+=int(s[a[-1]:])
  return res

bits=2**(len(S)-1)
ans=int(S)
for i in range(1,bits):
  cnt=[]
  for j in range(len(S)-1):
    if (i>>j)&1:
      cnt.append(j+1)
  ans+=culc(S,cnt)
print(ans)

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

def abc138_d():
    N, _ = map(int, readline().strip().split())
    input_data = [tuple(map(int, ln.strip().split())) for ln in readlines()]

    # 隣接リスト作成
    graph = [[] for _ in range(N+1)]
    for a, b in input_data[:N-1]:
        graph[a].append(b)
        graph[b].append(a)

    # クエリをもとにスコア加算　※頂点pだけに加算し、子へは加算しない
    val = [0] * (N+1)
    for p, x in input_data[N-1:]:
        val[p] += x

    # DFSで根元から順に足していく
    stack = [1]
    visited =set([1])
    while stack:
        x = stack.pop()
        for y in graph[x]:
            if y in visited: continue
            stack.append(y)
            visited.add(y)
            val[y] += val[x]

    print(*val[1:], sep=' ')

abc138_d()

Measured memory_bytes: 105436
h, w = gets.split.map(&:to_i)

t = (1..h).map{gets.chomp.split(//).map{|v| v == "#" ? -1 : 0}}

(0...h).each{|y|
  (0...w).each{|x|
    if t[y][x] == -1
      t[y]  [x-1] = t[y]  [x-1] + 1 if x > 0   &&            t[y]  [x-1] >= 0
      t[y]  [x+1] = t[y]  [x+1] + 1 if x < w-1 &&            t[y]  [x+1] >= 0
      t[y-1][x]   = t[y-1][x]   + 1 if            y > 0   && t[y-1][x]   >= 0
      t[y+1][x]   = t[y+1][x]   + 1 if            y < h-1 && t[y+1][x]   >= 0
      t[y-1][x-1] = t[y-1][x-1] + 1 if x > 0   && y > 0   && t[y-1][x-1] >= 0
      t[y-1][x+1] = t[y-1][x+1] + 1 if x < w-1 && y > 0   && t[y-1][x+1] >= 0
      t[y+1][x-1] = t[y+1][x-1] + 1 if x > 0   && y < h-1 && t[y+1][x-1] >= 0
      t[y+1][x+1] = t[y+1][x+1] + 1 if x < w-1 && y < h-1 && t[y+1][x+1] >= 0
    end
  }
}

puts t.map{|l| l.map{|v| v == -1 ? '#' : v.to_i}.join}.join("\n")


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

int main(){
  int h,w;
  cin>>h>>w;
  
  char lis[h+1][w+1];
  memset(lis,'0',sizeof(lis));
  rep(i,0,h){
    rep(j,0,w){
      cin>>lis[i][j];
    }
  }
  
  int cnt;
  rep(i,0,h){
    rep(j,0,w){
      if(lis[i][j]=='.'){
        cnt=0;
        if(lis[i-1][j-1]=='#')cnt++;
        if(lis[i-1][j]=='#')cnt++;
        if(lis[i-1][j+1]=='#')cnt++;
        if(lis[i][j-1]=='#')cnt++;
        if(lis[i][j+1]=='#')cnt++;
        if(lis[i+1][j-1]=='#')cnt++;
        if(lis[i+1][j]=='#')cnt++;
        if(lis[i+1][j+1]=='#')cnt++;
        lis[i][j]='0'+cnt;
      }
    }
  }

  rep(i,0,h){
    rep(j,0,w){
      if(j==w-1){cout<<lis[i][j]<<endl;}
      else{cout<<lis[i][j];}
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds1;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

void solve(){
    int n;
    cin>>n;
    map<int,int> m;
    vi a(n);
    int sum = 0;
    loop(i,0,n){
        cin>>a[i];
        m[a[i]]++;
        sum += a[i];
    }
    int q;
    cin>>q;
    while(q--){
        int x,y;
        cin>>x>>y;
        int cnt = x*m[x];
        int cnt1 = y*m[x];
        int cnt2 = m[x];
        m[x] = 0;
        m[y] += cnt2;
        sum -= cnt;
        sum += cnt1;
        cout<<sum<<endl;
    }

}

int32_t main(){
    get_it_done(); 
    int tc=1;
    // cin >> tc;
    while (tc--){
        solve();        
    }
}


Measured memory_bytes: 10084
use std::io;
use std::str::FromStr;

fn main() {

    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| f64::from_str(n).unwrap());
    let a = it.next().unwrap();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| f64::from_str(n).unwrap());
    let b = it.next().unwrap();

    // ( a + x ) / 2 = b;
    // a + x = 2 * b;
    // x = 2 * b - a;

    println!("{}", (2_f64 * b - a));

}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define vint vector<int>


int main(){
	char c;
	cin >> c;
	
	if(islower(c)) cout << "a\n";
	else cout << "A\n";
	
	
	
	return 0;
}

Measured memory_bytes: 3632
package main

import (
        "fmt"
)

func solution(n int) int {
        out := 0
        for i := 1; i < n+1; i = i + 2 {
                c := 0
                for j := 1; j < n+1; j++ {
                        if i%j == 0 {
                                c++
                        }
                }
                if c == 8 {
                        out++
                }
        }
        return out
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}

Measured memory_bytes: 1768
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
 
ll inv[4000001], f[4000001], fi[4000001];

ll C(int N, int K) {
	return f[N] * fi[K] % MOD * fi[N - K] % MOD;
}

ll H(int N, int K) {
	if (K == 0) return !N;
	return H(N + K - 1, K - 1);
}

int main() {
	inv[1] = 1;
	for (int i = 2; i <= 4000000; i++)
		inv[i] = -MOD / i * inv[MOD % i] % MOD;
	f[0] = fi[0] = 1;
	for (int i = 1; i <= 4000000; i++) {
		f[i] = f[i - 1] * i % MOD;
		fi[i] = fi[i - 1] * inv[i] % MOD;
	}
	vector<ll> p3(4000001);
	p3[0] = 1;
	for (int i = 1; i <= 4000000; i++)
		p3[i] = p3[i - 1] * 3 % MOD;
	vector<ll> p2(4000001);
	p2[0] = 1;
	for (int i = 1; i <= 4000000; i++)
		p2[i] = p2[i - 1] * 2 % MOD;
	int N, M, L;
	cin >> N >> M >> L;
	N++;
	if (M > L) swap(M, L);
	ll ans = 0;
	ll hoge = 0;
	for (int k = 0; k <= M + L; k++) {
		ll unko = 0;
		unko = (unko + p2[k]) % MOD;
		hoge = hoge * 2 % MOD;
		if (k > M) hoge = (hoge + C(M + k - M - 1, k - M - 1)) % MOD;
		if (k > L) hoge = (hoge + C(L + k - L - 1, k - L - 1)) % MOD;
		unko = (unko - hoge) % MOD;
		ans = (ans + unko * p3[M + L - k] % MOD * C(N - 2 + k, k)) % MOD;
	}
	cout << (ans + MOD) % MOD << endl;
}


Measured memory_bytes: 156544
function Main(arg) {
  var n = arg.split("\n")[0].split(" ")[0] - 0;
  var k = arg.split("\n")[0].split(" ")[1] - 0;

  console.log(Math.ceil((n - 1) / (k - 1)));
}

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

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

pair<int,string> a[37],b[37];
int main(){
    int n;
    cin>>n;
    string s;
    rep(i,n){
        cin>>s;
        a[i].second=s;a[i].first=s[1]-'0';
        b[i].second=s;b[i].first=s[1]-'0';
    }
    while(1){
        bool flag=true;
        rep(i,n-1)if(a[i].first>a[i+1].first) swap(a[i],a[i+1]),flag=false;
        if(flag) break;
    }
    rep(i,n) cout<<a[i].second<<(i==n-1?"":" ");
    cout<<endl;
    cout<<"Stable"<<endl;
    rep(i,n){
        int t=i;
        FOR(j,i,n)if(b[j].first<b[t].first) t=j;
        if(i!=t) swap(b[i],b[t]);
    }
    bool flag=true;
    rep(i,n){
        if(a[i].second!=b[i].second) flag=false;
        cout<<b[i].second<<(i==n-1?"":" ");
    }
    cout<<endl;
    if(flag) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B >> C;
    REPS(i, B) {
        if ((A * i) % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    int N,i=0;
    string S;
    cin>>N>>S;
    if(N%2==1){
        cout<<"No"<<endl;
    }else{
        while(i<N/2){
            if(S[i]!=S[N/2+i]){
                cout<<"No"<<endl;
                break;
            }
            i+=1;
        }
        if(i==N/2){
            cout<<"Yes"<<endl;
        }
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, k;
	cin >> n >> k;
	vecll h(n);
	rep(i, n) cin >> h[i];
	sort(all(h));
	ll ans = INT_MAX;
	for (int i = 0; i < n - k + 1; i++)
	{
		ans = min(ans, h[i + k - 1] - h[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3956
use std::io;
use std::f64;
use std::f64::consts;

struct Point {
    x: f64,
    y: f64,
}

impl Point {
    fn new(x: f64, y: f64) -> Point {
        Point {
            x,
            y,
        }
    }

    /// 与えられた線分を三等分する二点s,tと、これを頂点とする正三角形(s,u,t)を計算する。
    /// この時、(s,u,t)を返す
    fn koch_curve(p1: &Point, p2: &Point) -> (Point, Point, Point) {
        let s = Point::new(
            (p1.x*2.0 + p2.x) / 3.0, 
            (p1.y*2.0 + p2.y) / 3.0);
        let t = Point::new(
            (p1.x + p2.x*2.0) / 3.0, 
            (p1.y + p2.y*2.0) / 3.0);
        let u = Point::triangle_point(&s, &t);

        (s,u,t)
    }

    // 与えられた2点から、正三角形の頂点を計算して返す関数
    fn triangle_point(p1: &Point, p2: &Point) -> Point {
        let r = ((p2.x-p1.x).powi(2) + (p2.y-p1.y).powi(2)).sqrt();
        let t = ((p2.y-p1.y)/(p2.x-p1.x)).atan();   // arctanからθを計算。
        
        // tは戻り値が-pi/2~pi/2。回転に際して分岐が必要。
        // case1: p1よりp2が右にある場合はt=-pi/2~pi/2となるので問題ない
        // case2: p1よりp2が左にある場合はt=pi/2~3pi/2となるとする。こうしないと三角形の残る頂点が逆向きになってしまう

        let t2 = if p2.x < p1.x {
            t + consts::PI/3.0 + consts::PI // 60°回転＋象限の補正
        } else {
            t + consts::PI/3.0  // 60°回転
        };

        let x = p1.x + r * t2.cos();
        let y = p1.y + r * t2.sin();
        Point::new(x,y)
    }

    fn print(&self) {
        println!("{:.8} {:.8}", self.x, self.y);
    }
}

/// n回の再帰によって、koch曲線の座標を出力する
fn koch_curve_rec(n: i32, p1: &Point, p2: &Point) {
    if n > 0 {
        let (s,u,t) = Point::koch_curve(&p1, &p2);
        koch_curve_rec(n-1, &p1, &s);
        s.print();
        koch_curve_rec(n-1, &s, &u);
        u.print();
        koch_curve_rec(n-1, &u, &t);
        t.print();
        koch_curve_rec(n-1, &t, &p2);
    }
}

fn koch_curve(n: i32) {
    let x = Point::new(0.0, 0.0);
    let y = Point::new(100.0, 0.0);
    x.print();
    koch_curve_rec(n, &x, &y);
    y.print();
}

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let n: i32 = buf.trim().parse().unwrap();
    koch_curve(n);
}



Measured memory_bytes: 5208
while 1:
	n=input()
	if n==0:break
	s=[map(int,raw_input().split()) for i in range(n)]
	for i in range(n):
		s[i].append(4*s[i][1]+9*s[i][2]+4*s[i][3])
	r=map(int,raw_input().split())
	flag=0
	for i in s:
		if i[1]<=r[0] and i[2]<=r[1] and i[3]<=r[2] and i[4]<=r[3]:
			print i[0]
			flag=1
	if flag==0:print "NA"

Measured memory_bytes: 4516
while 1:
    N, M = map(int, input().split())
    if N == 0:
        break
    S = [list(map(int, input().split())) for i in range(M)]
    ans = 0
    for i in range(N):
        ans = max(ans, sum(S[j][i] for j in range(M)))
    print(ans)



Measured memory_bytes: 7668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min({a,b,c})<<" "<<max({a,b,c})<<endl;
}




Measured memory_bytes: 3132
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int gcd(int a,int b,int c){
  int MIN=min(min(a,b),c);
  for(int i=MIN;i>=1;i--){
    if(a%i==0&&b%i==0&&c%i==0)return i;
  }
  return 0;
}

int main(){
  int k;
  ll ans=0;
  cin>>k;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        ans+=gcd(i,j,l);
      }
    }
  }
  cout<<ans;
  return 0;
}


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

int main(){
  int n,ans; 
  cin>>n;
  int v[20],c[20],a[20];
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n;i++){
    cin>>c[i];
  }
  for(int i=0;i<n;i++){
    a[i]=v[i]-c[i];
  }
  for(int i=0;i<n;i++){
  if(a[i]>0){
    ans+=a[i];
   }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string s;
signed main() {
    cin >> s;
    if ((s[0] == s[s.length() - 1]) ^ (s.length() % 2 == 1)) { cout << "First" << endl; }
    else { cout << "Second" << endl; }
}


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

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

  int a, b, c; cin >> a >> b >> c;

  for (int i = i; i <= b; i++) {
    if (a*i%b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import math
N, D = map(int, input().split())

ten = []

for i in range(N):
    ten.append([int(i) for i in input().split()])

count = 0
for i in range(N):
    s = 0
    for j in range(i+1, N):
        for k in range(D):
            ss = ten[i][k]-ten[j][k]
            if ss < 0: ss = -ss

            s2 = pow(ss, 2)

            s += s2

        ans = math.sqrt(s)
        if ans.is_integer()==True:
            count += 1
        s = 0

print(count)







Measured memory_bytes: 3064
/*
MANAS IS THE SEXIEST MEMBER OF PAG
SOLVED WITH PERSISTENCE
*/


#include <bits/stdc++.h>
#include <stdio.h>
 
const int MANAS_FOR_WF = 1e6 + 5;
int spf[MANAS_FOR_WF];

using namespace std;
 
// #define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
void solve() {
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for (int i = 1; i <= m; i += 1) {
		for (int j = 1; j <= d; j += 1) {
			string lol = to_string(j);
			if ((int) lol.size() != 2)
				continue;
			int jj = j;
			int one = jj % 10;
			jj /= 10;
			int ten = jj % 10;
			if (one >= 2 and ten >= 2)
				if (one * ten == i)
				ans++; 
		}
	}
	cout << ans;
}		


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

std::vector<std::pair<char, long long> > runlength(std::string str)
{
        std::vector<std::pair<char, long long> > enc;
        long long strsize = static_cast<long long>(str.size());

        char now = str[0];
        long long cnt = 0;
        for (long long i = 0; i < strsize; ++i) {
                if (str[i] == now) {
                        ++cnt;
                } else {
                        enc.push_back(std::pair<char, long long>(now, cnt));
                        now = str[i];
                        cnt = 1;
                }
        }
        enc.push_back(std::pair<char, long long>(now, cnt));
        return enc;
}

int main()
{
        ll N;
        string S;
        cin >> N >> S;
        auto ans = runlength(S);
        cout << len(ans) << endl;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
struct poi{
    int x;
    int y;
    int num1;
    int num2;
}a[100005];
poi b[100005];
int fa[100005];
bool cmp1(poi q,poi w){
    return q.x<w.x;
}
bool cmp2(poi q,poi w){
    return q.y<w.y;
}
int Find(int x)
{
	int r=x;
	while(r!=fa[r])
		r=fa[r];

	int i=x,j;

	while(fa[i]!=r)
	{
		j=fa[i];
		fa[i]=r;
		i=j;
	}

	return r;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i].x,&a[i].y);
        a[i].num1=i;
        b[i]=a[i];
    }
    sort(a,a+n,cmp1);
    sort(b,b+n,cmp2);
    for(int i=0;i<n-1;i++)
    {
        a[i].x=a[i+1].x-a[i].x;
        a[i].num2=a[i+1].num1;
    }
    for(int i=0;i<n-1;i++)
    {
        b[i].y=b[i+1].y-b[i].y;
        b[i].num2=b[i+1].num1;
    }
    sort(a,a+n-1,cmp1);
    sort(b,b+n-1,cmp2);

    for(int i=0;i<n;i++) fa[i]=i;
    int s1=0;
    int s2=0;
    long long ans=0;

    while(s1<n-1&&s2<n-1){
        int temp1=a[s1].x;
        int temp2=b[s2].y;
        if(temp1<temp2){
            int fa1=Find(a[s1].num1);
            int fa2=Find(a[s1].num2);
            if(fa1!=fa2){
                fa[fa1]=fa2;
                ans+=temp1;
            }
            s1++;
        }
        else{
            int fa1=Find(b[s2].num1);
            int fa2=Find(b[s2].num2);
            if(fa1!=fa2){
                fa[fa1]=fa2;
                ans+=temp2;
            }
            s2++;
        }
        //printf("%d %d %lld\n",temp1,temp2,ans);

    }
    printf("%lld\n",ans);

}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define pi pair<int,int>
#define pb push_back
#define pll pair<ll,ll>
#define inf 1e16
using namespace std;
typedef long long ll;

const int N = 109;

void slv()
{
    ll x,k,d;
    cin >> x >> k >> d;
    x=abs(x);
    ll mv=x/d;
    mv=min(mv,k);
    k-=mv;
    x -= d*mv;
    k %= 2;
    if(k==0) cout<<x<<endl;
    else cout<<min(abs(x-d),abs(x+d))<<endl;
}
int main()
{
    int t;
    t=1;
    for(int cs=1;cs<=t;cs++)
    {
        //printf("Case #%d: ",cs);
        slv();
    }
    return 0;
}


Measured memory_bytes: 3632
N,K = map(int,input().split())
H = [int(input()) for i in range(N)]
H.sort()
ans = H[K-1]-H[0]
for j in range(N-K+1):
  if ans >= H[K+j-1]-H[j]:
    ans = H[K+j-1]-H[j]
print(ans)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int W,H;
  cin >> W >> H;
  vector<vector<int>> rec(W,vector<int>(H));
  for(int i = 0; i < W; i++){
    for(int j = 0; j < H; j++){
      rec.at(i).at(j) = 1;
    }
  }
  int N;
  cin >> N;
  vector<vector<int>> com(N,vector<int>(3));
    for(int i = 0; i < N; i++){
      for(int j = 0; j < 3; j++){
      cin >> com.at(i).at(j);
    }
  }
    for(int k = 0; k< N; k++){
      if(com.at(k).at(2) == 1){
        for(int i = 0; i < com.at(k).at(0); i++){
          for(int j = 0; j < H; j++){
            rec.at(i).at(j) = 0;
          }
        }
      }
      if(com.at(k).at(2) == 2){
        for(int i = com.at(k).at(0); i < W; i++){
          for(int j = 0; j < H; j++){
            rec.at(i).at(j) = 0;
          }
    }
  }  
      if(com.at(k).at(2) == 3){
        for(int i = 0; i < W; i++){
          for(int j = 0; j < com.at(k).at(1); j++){
          rec.at(i).at(j) = 0;
        }
      }
    }
    if(com.at(k).at(2) == 4){
      for(int i = 0; i < W; i++){
        for(int j = com.at(k).at(1); j < H; j++){
        rec.at(i).at(j) = 0;
      }
    }
  }    
}
int count =0;
for(int i = 0; i < W; i++){
  for(int j = 0; j < H; j++){
    if(rec.at(i).at(j) == 1)count++;
  }
}
cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	print(s < t ? "Yes" : "No");
}

Measured memory_bytes: 3612
MOD = 10**9 + 7

def main():
    s = [int(in_i) if in_i != '?' else -1 for in_i in list(open(0).read())[:-1]]
    n = len(s)

    cnt = [0] * 13
    if s[0] == -1:
        for j in range(10):
           cnt[j] = 1
    else:
        cnt[s[0]] = 1

    for cur_s in s[1:]:
        dp = [0] * 26
        for i in range(13):
            dp[i*10%13] = cnt[i] % MOD
        dp[13:] = dp[:13]

        if cur_s == -1:
            for i in range(13):
                cnt[i] = sum(dp[i+4:i+14])
        else:
            for i in range(13):
                cnt[i] = dp[i+13-cur_s]

    ans = cnt[5] % MOD
    print(ans)
    return()

if __name__ == '__main__':
    main()


Measured memory_bytes: 4784
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a, b, c, d, e, f;
    scanf("%ld%ld%ld%ld%ld%ld", &a, &b, &c, &d, &e, &f);

    double max=-1.0;
    long   wmax=0;
    long   smax=0;

    long i, j, k, m;
    for(i=0; i<=30; i++) {
        for(j=0; j<=30; j++) {
            long w = 100*a*i + 100*b*j;
            long v = f - w;
            if(v<0 || w==0) continue;
            long ss = MIN(v, w*e/100);
            for(k=0; k<=ss/c; k++) {
                long ss2 = ss - c*k;
                m = ss2/d;

                double tmp = (double)(c*k + d*m) / (w + c*k + d*m);
                if(max<tmp) {
                    max = tmp;
                    wmax=w;
                    smax=(c*k + d*m);
                }
            }
        }
    }


    printf("%ld %ld\n", wmax+smax, smax);
  
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
int inf_int=2e9;
ll inf_ll=1e18;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
const double pi=3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz size()

bool debug=0;
const int MAXN=1e5+100000;
int mod=1e9+9;


#define rank asfalgalsglasgllzxdgl

struct point
{
    int x, y;
};

double dis(point a,point b)
{
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
double fun(point x,point y,point z)
{
    double a=dis(x,y);
    double b=dis(y,z);
    double c=dis(x,z);
    return acos((a+b-c)/(2*(sqrt(a*b))));
   // return acos()
}
double eps=0.0000009;

void solve()
{
   string a;
   cin >> a;
   for(int i=0;i<a.sz;++i)
   {
       if(a[i]==',')
        a[i]=' ';
   }
   cout << a<<"\n";
}



#define FILE "stupid_rmq"
int main()
{
        #ifdef zxc
            freopen("input.txt","r",stdin);
    //       freopen("output.txt","w",stdout);
        #endif // zxc

    //    freopen(FILE".in","r",stdin);
   //   freopen(FILE".out","w",stdout);

       if(!debug)
       {
            ios_base::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
       }

        int t=1;
         while(t--)
            solve();

        return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
	cout.tie(0);
    int n;
    cin>>n;
    char s[n];
    cin>>s;
    if(n%2==1)
    cout<<"No";
    else{
        int cnt=0;
        for(int i=0; i<n/2; i++){
            if(s[i]==s[i+n/2])
              cnt++;
        }
        if(cnt ==n/2)
        cout<<"Yes";
        else 
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,hp;
long long knife[100005];
long long maxhit;
long long attack;
int main(){
	cin>>n>>hp;
	for(int i=1; i<=n; i++){
		long long a;
		cin>>a>>knife[i];
		maxhit = max(maxhit,a);
	}
	sort(knife+1,knife+n+1);
	for(int i=n-1; i>=1; i--) knife[i]+=knife[i+1];
	attack = hp/maxhit+(hp%maxhit?1:0);
	for(int i=n; i>=1; i--){
		long long adc = n-i+1;
		long long h = max(hp-knife[i],(long long)0);
		adc+=(h/maxhit+(h%maxhit?1:0));
		attack = min(attack,adc);
	}
	cout<<attack;
}

Measured memory_bytes: 4416
import java.util.*;

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

        int tasu = A+B;
        int hiku = A-B;
        int kakeru = A*B;

		System.out.println(Math.max(kakeru,Math.max(tasu,hiku)));
}
}

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

using namespace std;

int n, a[100005], ans;

int ef(int l, int r, int v)
{
    if (l == r) return l;
    int mid = (l + r) / 2 + 1;
    if (a[mid] < v) return ef(mid, r, v);
    else return ef(l, mid - 1, v);
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    for (int i = 1; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int x = ef(j, n, a[i] + a[j]);
            ans += (x - j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import queue

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

ans=0
for i in range(H+2):
    for g in range(W+2):
        if c[i][g]==".":
            ans+=1

dist=[[-1]*(W+2) for _ in range(H+2)]
que=queue.Queue()
que.put((1,1))
dist[1][1]=0

while not que.empty():
    h,w=que.get()
    direction=[(0,-1),(0,1),(1,0),(-1,0)]
    for y,x in direction:
        if c[h+y][w+x]=="." and dist[h+y][w+x]==-1:
            que.put((h+y,w+x))
            dist[h+y][w+x]=dist[h][w]+1

if dist[H][W]==-1:
    print(-1)
else:
    print(ans-dist[H][W]-1)

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

int main() {
  string s;cin>>s;
  string hoge[3] = {"Sunny", "Cloudy", "Rainy"};
  for(int i=0;i<3;++i){
    if (s==hoge[i]){
      	cout<<hoge[(i+1)%3]<<endl;
      return 0;
    }
  }
}


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


def f(S, H, W, y, x):
    if S[y][x] == '#':
        return 0
        
    C = [-1]*(H*W)
    C[y*W + x] = 0
    Q = [(y, x)]

    while len(Q) > 0:
        Q2 = []
        for y2, x2 in Q:
            c = C[y2*W + x2]

            for dy, dx in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
                y3 = y2 + dy
                x3 = x2 + dx

                if (y3 >= 0 and y3 < H and x3 >= 0 and x3 < W and
                    S[y3][x3] == '.' and C[y3*W + x3] == -1):

                    C[y3*W + x3] = c + 1
                    Q2.append((y3, x3))

        Q = Q2

    return max(C)
                

def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]

    print(max(f(S, H, W, y, x) for y in range(H) for x in range(W)))
        


if __name__ == '__main__':
    main()


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

int main(void){
    int h, w;
    cin >> h >> w;
    int a[500][500];
    for(int i = 0; i < h; i ++){
        for(int j = 0; j < w; j ++){
            cin >> a[i][j];
        }
    }
    
    vector<string> strs;
    char str[100];
    for(int i = 0; i < h; i ++){
        // ->
        if(i % 2 == 0){
            for(int j = 0; j < w-1; j ++){
                if(a[i][j] % 2 == 1){
                    a[i][j+1] ++;
                    sprintf(str, "%d %d %d %d", i+1, j+1, i+1, j+1+1);
                    strs.push_back(str);
                }
            }
            if(i < h-1 && a[i][w-1] % 2 == 1){
                a[i+1][w-1] ++;
                sprintf(str, "%d %d %d %d", i+1, w-1+1, i+1+1, w-1+1);
                strs.push_back(str);
            }
        }
        
        // <-
        else{
            for(int j = w-1; j > 0; j --){
                if(a[i][j] % 2 == 1){
                    a[i][j-1] ++;
                    sprintf(str, "%d %d %d %d", i+1, j+1, i+1, j-1+1);
                    strs.push_back(str);
                }
            }
            if(i < h-1 && a[i][0] % 2 == 1){
                a[i+1][0] ++;
                sprintf(str, "%d %d %d %d", i+1, 0+1, i+1+1, 0+1);
                strs.push_back(str);
            }
        }
    }
    
    int c = (int)strs.size();
    cout << c << "\n";
    for(int i = 0; i < c; i ++) cout << strs[i] << "\n";
}


Measured memory_bytes: 9972