akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import defaultdict
#n=int(input())
n,a,b,c,d=map(int,input().split())
#a=[int(i) for i in input().split()]
s='_'+input()

ans=['Yes','No']

#print(s,n,a,b,c,d)

def CanGo(x,y):
    cnt=0
    root=s[x:y]
    for c in root:
        if c=='#':
            cnt+=1
        elif c=='.':
            if cnt>2:
                return False
            cnt=0
    return True


def CanPass(x,y):  #(b,d)
    root=s[x-1:y+2]
    '''
    q=s[x-1:x+2]
    print(root,q)
    print(root,len(root)-3+1)
    for i in range(len(root)-3+1):
        if q=='...':
            return True
        q=q[1:3]+s[x+3+i]
    '''
    if root.find('...')!=-1:
        return True
    return False
        


if c<d:
    if CanGo(b,d) and CanGo(a,c):
        ai=0
    else:
        ai=1
elif c>d:
    if CanGo(b,d) and CanGo(a,c) and CanPass(b,d):
        ai=0
    else:
        ai=1
    
    

print(ans[ai])


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

string check(int num);

int main(){
	int n,c = 0,d = 0;
	string a,b;
	cin >> n;
	
	for(int i = 0;i < n;i++){
		cin >> a >> b;
		if(a > b){
			c += 3;
		}
		else if(b > a){
			d += 3;
		}
		else{
			c++;
			d++;
		}
	}
		cout << c << ' ' << d << "\n";
	
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <stack>
#include <queue>
#include <string>
using namespace std;

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

	int H, W;
	char a[100][100];
	char add[102];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < W+2; i++) {
		add[i] = '#';
		cout << add[i];
	}
	cout << "\n";
	
	for (int i = 0; i < H; i++) {
		cout << '#';
		for (int j = 0; j < W; j++) {
			cout << a[i][j];
		}
		cout << "#\n";
	}
	for (int i = 0; i < W + 2; i++) {
		cout << add[i];
	}
	cout << "\n";
	
	return 0;
}

Measured memory_bytes: 256
import heapq 
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i]*= -1
heapq.heapify(a)
for i in range(m):
    x = heapq.heappop(a)
    x *= -1
    x//=2
    heapq.heappush(a, -x)
print(-sum(a))

Measured memory_bytes: 14180
#include <iostream>
#include <cstdio>

using namespace std;

const long long M = 1e9 + 7;
long long n;
long long d[105][9][9][9];

long long f(long long p, long long q, long long r, long long s)
{
    long long re = 0;
    if(p == n)
    {
        return 1;
    }
    if(d[p][q][r][s]) return d[p][q][r][s];
    for(long long i = 0; i < 4; i++)
    {
        if(r == 0 && s == 1 && i == 2) continue;
        if(r == 0 && s == 2 && i == 1) continue;
        if(r == 1 && s == 0 && i == 2) continue;
        if(q == 0 && s == 1 && i == 2) continue;
        if(q == 0 && r == 1 && i == 2) continue;
        re += f(p + 1, r, s, i);
    }
    return d[p][q][r][s] = re % M;
}

int main()
{
    scanf("%lld", &n);
    printf("%lld", f(0, 4, 4, 4));
    return 0;
}


Measured memory_bytes: 768
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Main{
	static BufferedReader br;
	static int in() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        int n=in();
        int[] arr=split();
        long ans=1000;
        long x=arr[0];
        long s=0;
        long amount=1000;
        int i=1;
        while(i<n)
        {
        	while(i<n && arr[i]<x)
        	{
        		x=(long)arr[i];
        		i++;
        	}
        	s=amount/x;
        	amount=amount%x;
        	while(i<n && arr[i]>=x)
        	{
        		x=(long)arr[i];
        		i++;
        	}
        	amount=amount+s*x;
        	s=0;
        	ans=Math.max(ans, amount);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 32584
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[3]={};
	char b[3]={};	
	char c[3]={};
	char d[3][3]={};
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin >> d[i][j];
		}
	}
	cout << d[0][0]<<d[1][1]<<d[2][2];
	return 0;
}

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

int main(void){
    string str;
    cin >> str;
    for(int i=0;i<str.length();i++){
        if(str[i]=='1'){
            str[i]='9';
        }else{
            str[i]='1';
        }
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define KETA 40

using namespace std;

typedef long long  ll;
typedef pair<ll,ll> P1;
typedef pair<string,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<Pi,int> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	string s;
	cin>>s;

	int p=0;
	rep(i,s.size()){
		if(s[i]=='p')p++;
	}
	cout<<s.size()/2-p<<endl;
	return 0;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 


int main() {
  int now = 0;
  int mx = 0;
  rep(i,3)  {
    char c; cin >> c;
    if (c=='R') now++;
    else now = 0;
    chmax(mx, now);
  }
  cout << mx << endl;
  return 0;
}

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

int main() {
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int can = ((h2 - h1 - 1) * 60) + (m2 + 60 - m1) - k;

  cout << can << endl;

  return 0;
}

Measured memory_bytes: 3636
'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''
'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''
'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''
'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''
'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''
'''
sort()
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''
'''
リスト同士の演算
list(map(lambda x, y: x+y, el2, el3))
'''
'''
配列の初期化
配列名=[a]*n+[b]*m
'''
'''
重複
list(set())
２次元配列
list(map(list, set(map(tuple, addition))))
'''
'''
順列
for el in itertools.permutations(配列のパターン):
'''
'''
Decimal()
'''
# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()




from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul
def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


N = int(stdin.readline().rstrip())
A = [int(s) for s in stdin.readline().rstrip().split()]
res = lcm(A)
part = 0
for k in range(len(A)):
    part += res//A[k]
print(part % (10**9+7))


Measured memory_bytes: 5656
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::fastout;
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
       k: usize
    }
    let mut g = vec![vec![1; 201]; 201];
    for i in 1..201 {
        for j in 1..201 {
            if i == j {
                g[i][j] = i;
            }
            if i > j {
                g[i][j] = g[j][i];
            }
            g[i][j] = gcd(j, i);
        }
    }
    let mut ans = 0;
    for i in 1..k + 1 {
        for j in 1..k + 1 {
            for l in 1..k + 1 {
                ans += g[i][g[j][l]];
            }
        }
    }
    println!("{}", ans);
    //    // 同じ数
    //    let ans1 = k * (k + 1) / 2;
    //    // 2つが同じ数。
    //    // 各ペアの6倍。
    //    let mut ans2 = 0;
    //    for i in 1..k {
    //        for j in i + 1..k + 1 {
    //            ans2 += g[i][j];
    //        }
    //    }
    //    ans2 *= 6;
    //    let mut ans3 = 0;
    //    for i in 1..k - 1 {
    //        for j in i + 1..k {
    //            for l in j + 1..k + 1 {
    //                ans3 += g[i][g[j][l]];
    //            }
    //        }
    //    }
    //    ans3 *= 6;
    //
    //    println!("{}", ans1 + ans2 + ans3);
}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

//fn gcd3(a: u64, b: u64, c: u64) -> u64 {
//    gcd(a, gcd(b, c))
//}


Measured memory_bytes: 2340
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a, b;
  cin >> a >> b;


  int i = 1, x = 0, y = 0; 
  while(x <= a && y <= b){
	   x = i * 0.08;
	   y = i * 0.1;
	   if(x == a && y == b){
	       cout << i << "\n";
	       return 0;
	   }
	   i++;
   }
   cout << "-1" << "\n";
	        
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int coudp[100001];

int main() {
	string s;
	cin >> s;
	bool a = true;
	for (int i = 0;i < s.size();++i) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				a = false;
			}
		}
		else {
			if (s[i] == 'R') {
				a = false;
			}
		}
	}
	if (a) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [A[0]]
for i in range(1, N):
    B.append(A[i]+B[i-1])
ans = 1 << 50
for i in range(0, N-1):
    tmp = abs(2*B[i]-B[N-1])
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 24832
/*	ex3_1
	suzuto	*/

  #include <stdio.h>

  int main(void) {
    int num, first_place; /*変数の宣言*/

    scanf("%d",&num); /*本数の入力*/
    first_place = num % 10; /*本数の一の位をfirst_placeに代入*/

    switch (first_place) {
      case 2:
      case 4:
      case 5:
      case 7:
      case 9:
        printf("hon\n"); /*読み方が「ほん」の時*/
        break;
      case 0:
      case 1:
      case 6:
      case 8:
        printf("pon\n"); /*読み方が「ぽん」の時*/
        break;
      case 3:
        printf("bon\n"); /*読み方が「ぼん」の時*/
        break;
    }
    return 0;
  }


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int N,M;cin >> N >> M;
    const int MAXM=100001;
    int L[MAXM],R[MAXM];
    int maxl = 0,minr = MAXM;
    rep(i,M){
        cin >> L[i] >> R[i];
        maxl = max(maxl,L[i]);
        minr = min(minr,R[i]);
    }
    int ans = 0;
    Rep(i,N){
        if(maxl<=i && minr >= i)ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4412
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll x,y,z,k;cin>>x>>y>>z>>k;
    ll a[x],b[y],c[z];
    vector<ll>vec;
    rep(i,0,x)cin>>a[i];
    rep(i,0,y)cin>>b[i];
    rep(i,0,z)cin>>c[i];
    sort(a,a+x,greater<ll>());
    sort(b,b+y,greater<ll>());
    sort(c,c+z,greater<ll>());
    rep(i,0,x){
        rep(j,0,y){
            rep(l,0,z){
                if((i+1)*(j+1)*(l+1)<=k)vec.push_back(a[i]+b[j]+c[l]);
                else break;
            }
        }
    }
    sort(vec.begin(),vec.end(),greater<ll>());
    rep(i,0,k){
        cout<<vec[i]<<endl;
    }
}


Measured memory_bytes: 1528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] color = Console.ReadLine().Split(' ');

            bool frag = false;
            foreach(string item in color)
            {
                if (item == "Y")
                {
                    frag = true;
                    break;
                }
            }

            if (frag)
            {
                Console.WriteLine("Four");
            }
            else
            {
                Console.WriteLine("Three");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
int n;
vector<ll> x;
vector<ll> d;
vector<int> mul(vector<int>&a,vector<int>&b){
    int m = b.size();
    vector<int> res(m);
    for(int i=0;i<m;i++){
        res[i] = b[a[i]];
    }
    return res;
}
vector<int> calc(vector<int>&a,ll k){
    int m = a.size();
    if(k==0){
        vector<int> res;
        rep(i,m){
            res[i] = i;
        }
        return res;
    }else if(k==1){
        return a;
    }
    if(k%2==0){
        vector<int> res;
        res = calc(a,k/2);
        return mul(res,res);
    }else{
        vector<int> res;
        res = calc(a,k/2);
        res = mul(res,res);
        res = mul(res,a);
        return res;
    }
}
int main(){
    cin >> n;
    x.resize(n);
    d.resize(n-1);
    rep(i,n)cin >> x[i];
    rep(i,n-1){
        d[i] = x[i+1]-x[i];
    }
    int m;
    ll k;
    cin >> m >> k;
    vector<int>a(m);
    rep(i,m){
        cin >> a[i];
        a[i]-=2;
    }
    vector<int>b(n-1);
    rep(i,n-1){
        b[i] = i;
    }
    rep(i,m){
        swap(b[a[i]],b[a[i]+1]);
    }
    // rep(i,n-1){
    //     cerr << b[i] << " ";
    // }
    // cerr << endl;
    vector<int> res = calc(b,k);
    // for(int i=0;i<n-1;i++){
    //     cerr << res[i] << " ";
    // }
    // cerr << endl;
    for(int i=0;i<n-1;i++){
        x[i+1] = x[i] + d[res[i]];
    }
    for(int i=0;i<n;i++){
        cout << x[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 4464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string t;
    cin>>t;
    deque<char> s(t.size());
    rep(i,t.size()) s[i]=t[i];
    bool flag=true;
    int q;
    cin>>q;
    while(q--){
        int c;
        cin>>c;
        if(c==1){
            flag=!flag;
        }else{
            int f;
            char ch;
            cin>>f>>ch;
            if(f==1){
                if(flag) s.push_front(ch);
                else s.push_back(ch);
            }else{
                if(!flag) s.push_front(ch);
                else s.push_back(ch);
            }
        }
    }
    if(!flag){
        reverse(begin(s),end(s));
    }
    for(auto c:s) cout<<c;
    cout<<endl;
}

Measured memory_bytes: 976
//#define TEST
 
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;
 
class Program
{
    static int N;
    static int[] h;
 
    static void Main()
    {
        N = int.Parse(Console.ReadLine());
        h = Console.ReadLine().Split().Select(int.Parse).ToArray();
 
        long[] dp = new long[N];
        for (int i = 1; i < N; i++)
        {
            dp[i] = dp[i - 1] + Abs(h[i] - h[i - 1]);
            try
            {
                dp[i] = Min(dp[i], dp[i - 2] + Abs(h[i - 2] - h[i]));
            }
            catch { continue; }
        }
#if TEST
        foreach (var c in dp)
            Console.Write("{0} ", c);
        Console.WriteLine();
#endif
        Console.WriteLine(dp[N - 1]);
    }
}

Measured memory_bytes: 20192
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

ll fx[] = {0, 0, 0, 1, -1, 1, 1, -1, -1};
ll fy[] = {0, 1, -1, 0, 0, 1, -1, -1, +1};
map< ll, bool >mp;
vector<ll>a, b, v;
vector< pair< int , int > > gr[ 200005 ];
ll ar[ 2000005 ], br[ 2000005 ], ans[ 200005 ], per[ 2000005 ];

ll bs(ll A, ll B, ll X)
{
    ll l = 0, r = 1000000000, ans = 0 ;

    while( l <= r )
    {
        ll m = ( l + r ) / 2;
        ll x = m, cn = 0;
        while( x > 0 )
        {
            cn++ ;
            x /= 10;
        }
        ll eq = (A * m) + (B * cn);
        if( eq <= X ) ans = max(ans, m);
        if( eq < X )
        {
            l = m + 1 ;
        }
        else
        {
            r = m - 1;
        }
    }
    return ans;
}

string s = "";

ll totColor = 0;
void dfs(ll par, ll s, ll color)
{
    totColor = max( totColor, color );
    int var = 1;
    for(auto a: gr[ s ])
    {
        if( var == color ) var++;
        if( a.first == par ) continue;
        ans[ a.second ] = var;
        dfs( s, a.first, var  );
        var++;
    }
}
int main()
{
    ll n ;
    cin>>n;
    for(int i = 0; i < n - 1; i++)
    {
        ll u, v ;
        cin>>u>>v;
        gr[ u ].pb( {v, i} );
        gr[ v ].pb( {u , i});
    }
    dfs(-1, 1, 0 );
    cout<<totColor<<"\n";
    for(int i = 0; i < n - 1; i++) cout<<ans[ i ]<<"\n";
    return 0;
}
/*7 5
12 444 876 1309 1740 2174 2604
*/


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

int main(){
  
  int n;
  cin>>n;
  int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  cout<<a[n-1]<<endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	float a,b;
	while (scanf("%f %f",&a,&b)!= EOF) {
/*	while(a!=0 && b!=0) {*/
		if(a<35.50 && b<71.00) {
			printf("AAA\n");
		}
		else if(a<37.50 && b<77.00) {
			printf("AA\n");
		}
		else if(a<40.00 && b<83.00) {
			printf("A\n");
		}
		else if(a<43.00 && b<89.00) {
			printf("B\n");
		}
		else if(a<50.00 && b<105.00) {
			printf("C\n");
		}
		else if(a<55.00 && b<116.00) {
			printf("D\n");
		}
		else if(a<70.00 && b<148.00) {
			printf("E\n");
		}
		else {
			printf("NA\n");
		}
	}
/*	scanf("%f %f",&a,&b);
	}*/
	return 0;
}

Measured memory_bytes: 604
#a,b,c = map(int,inpput().split(" "))
#n = int(input())
#print(a,b,c)
t=[]
for i in range(5):
    t.append(int(input()))
n = int(input())
flag = True
for i in range(5):
    for j in range(5-i-1):
        if abs(t[i]-t[j+i+1]) >n:
            flag =False
            break
if not flag:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
int main(){
	int n,r;
	while(scanf("%d%d",&r,&n),n||r){
		double rr=r;
		vector<int> v1(2*r+1,0),v2(2*r+1,0);
		rep(i,n){
			int a,b,c;
			scanf("%d%d%d",&a,&b,&c);
			a=max(a,-r);
			b=min(b,r);
			reep(j,a,b+1){
				if(j-a){
					if(v1[j+r]==0){
						v1[j+r]=c;
					}
					else{
						v1[j+r]=max(v1[j+r],c);
					}
				}
				if(j-b){
					if(v2[j+r]==0){
						v2[j+r]=c;
					}
					else{
						v2[j+r]=max(v2[j+r],c);
					}
				}
			}
		}
		double ans=1e20;
		reep(i,-r,r+1){
			int mx=1e8;
			if(r+i) mx=min(mx,v1[i+r]);
			if(r-i) mx=min(mx,v2[i+r]);
			ans=min(ans,mx+rr-sqrt(rr*rr-pow(abs(i),2)));
		}
		printf("%lf\n",ans);
	}
}

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

int main() {
    int A,B,C,X;
    cin>>A>>B>>C>>X;
    
    vector<int> ways;
    
    for (int i=0; i<A+1; i++) {
        for (int j=0; j<B+1; j++) {
            for (int k=0;k<C+1;k++){
                if(500*i+100*j+50*k==X){
                    ways.push_back(1);
                }
            }
        }
    }
    
    cout<<ways.size()<<endl;
    return 0;
}

Measured memory_bytes: 384
s = input()
t = input()

ss = len(s)
tt = len(t)

dp = [[0 for _ in range(tt+1)] for __ in range(ss+1)]

for i in range(1, ss+1):
    for j in range(1, tt+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = max(dp[i-1][j-1] + 1, dp[i][j-1], dp[i-1][j])
        else:
            dp[i][j] = max(dp[i][j-1],dp[i-1][j])

i = ss
j = tt
ans = []

while i>0 and j>0:
    if s[i-1] == t[j-1]:
        ans.append(s[i-1])
        i -= 1
        j -= 1
    else:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        else:
            j -= 1

print(''.join(reversed(ans)))

Measured memory_bytes: 120156
/*
Read the question and constraints carefully .Take pen and paper and start solving.
write it down
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define pi acos(-1.0)/*
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second*/
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{

    int n,i,j,o,c,tot=0,k;

    cin>>n;

    string s;
    pair<int,string> p[n];

    rep(i,0,n)
    {
        cin>>s;
        p[i].second = s;

        tot += s.size();

        for(j=o=c=0;j<s.size();++j)
        {
            if(s[j]=='(')
                ++o;
            else
                ++c;
        }

        
        if(o==0)
            p[i].first = INT_MIN;
        else if(c==0)
            p[i].first = INT_MAX;
        else if(o>c)
            p[i].first = INT_MAX-c;
        else if(o<c)
            p[i].first = INT_MIN+o+1;
        else
            p[i].first = 0;



    }

    sort(p,p+n,greater<pair<int,string>>());

     string ans(tot,'a');



    k=0;
    for(i=0;i<n;++i)
    {
        s = p[i].second;

        for(j=0;j<s.size();++j,++k)
        {
            ans[k] = s[j];
        }
    }


    //cout<<ans<<"\n";

    for(i=o=c=0;i<tot;++i)
    {
        if(ans[i]=='(')
            ++o;
        else
            --o;

        if(o<0)
        {
            cout<<"No";
            return 0;
        }
    }


    if(o==0)
        cout<<"Yes";
    else
        cout<<"No";


    return 0;
}

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

int  main(void) {
  int h, w, n;
  cin >> h >> w >> n;
  int ans = 0;

  if (n % max(h, w) == 0) ans += n / max(h, w); 
  else ans += n / max(h, w) + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int x[5], ans = 0;
  REP(i, 5) {
    cin >> x[i];
    ans += x[i];
  }
  cout << 15 - ans << "\n";
  return 0;
}


Measured memory_bytes: 3568
import sys
import numpy as np 
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m = I[:2]
a, b, c = I[2:].reshape(m, 3).T
a -= 1; b -= 1
graph = np.zeros((n, n))
graph[a, b] = c

def main():
    dist = floyd_warshall(csgraph=csr_matrix(graph), directed=False)
    bl =  (dist[:, a] == dist[:, b] + c) | (dist[:, b] == dist[:, a] + c)
    res = np.any(bl, axis=0)
    ans = m - np.count_nonzero(res)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 17720
#include <iostream>

using namespace std;

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

    if (a == 'H' && b == 'H') cout << 'H' << endl;
    if (a == 'H' && b == 'D') cout << 'D' << endl;
    if (a == 'D' && b == 'H') cout << 'D' << endl;
    if (a == 'D' && b == 'D') cout << 'H' << endl;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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

const int N = 1e6+5;

string s;

int main(){
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'C' || s[i] == 'A')
         continue;
        if(s[i] >= 'A' && s[i] <= 'Z'){
            puts("WA");
            return 0;
        }
    }
    int cnt = 0;
    for(int j = 2; j < s.size()-1; j++){
       cnt += (s[j] == 'C');
    }
    if(cnt == 1 && s[0] == 'A' && s[1] != 'C' && s[s.size()-1] != 'C'){
        puts("AC");
    } else {
        cout << "WA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m, q = gets.split.map(&:to_i)
l = []
q.times do
  l << gets.split.map(&:to_i)
end
max = 0
[*1..m].repeated_combination(n).to_a.each do |a|
  s = l.inject(0) do |acc, cur|
    p = a[cur[1]-1] - a[cur[0]-1] == cur[2] ? cur[3] : 0
    acc + p
  end
  max = [max, s].max
end
puts max


Measured memory_bytes: 31540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll k,n;
	cin>>k>>n;
	ll a[200010];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	ans=max(ans,k-a[n-1]+a[0]);
	for(ll i=1;i<n;i++){
		ll dx=a[i]-a[i-1];
		ans=max(ans,dx);
	}
	cout << k-ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

struct edge{
	int to,cap,cost,rev;
};

class Network{
	private:
	int V;
	vi h,d,pv,pe;
	public:
	vector<vector<edge> > g;
	Network(int v){
		V=v;
		g=vector<vector<edge> >(v);
	}
	void add_edge(int s,int t,int cap,int cost){
		g[s].push_back(edge{t,cap,cost,(int)g[t].size()});
		g[t].push_back(edge{s,0,-cost,(int)g[s].size()-1});
	}
	int min_cost_flow(int s,int t,int f){
		int res=0;
		h=pv=pe=vi(V);
		while(f>0){
			priority_queue<P> q;
			d=vi(V,inf);
			d[s]=0;
			q.push({0,s});
			while(!q.empty()){
				P p=q.top();
				q.pop();
				int v=p.second;
				if(d[v]<-p.first) continue;
				for(int i=0;i<g[v].size();i++){
					edge &e=g[v][i];
					if(e.cap>0&&d[e.to]>d[v]+e.cost+h[v]-h[e.to]){
						d[e.to]=d[v]+e.cost+h[v]-h[e.to];
						pv[e.to]=v;
						pe[e.to]=i;
						q.push({-d[e.to],e.to});
					}
				}
			}
			if(d[t]==inf) return -1;
			for(int i=0;i<V;i++) h[i]+=d[i];
			int D=f;
			for(int i=t;i!=s;i=pv[i]) D=min(D,g[pv[i]][pe[i]].cap);
			f-=D;
			res+=D*h[t];
			for(int i=t;i!=s;i=pv[i]){
				edge &e=g[pv[i]][pe[i]];
				e.cap-=D;
				g[i][e.rev].cap+=D;
			}
		}
		return res;
	}
};

int n;
vvi a,b;

int main(){
	cin>>n;
	Network nt(2*n+2);
	a=b=vvi(n,vi(n));
	int res=0;
	vvi d(n,vi(n));
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>b[i][j];
	for(int i=0;i<n;i++) for(int j=0;j<n;j++){
		char c;
		cin>>c;
		if(c=='.') nt.add_edge(i+1,n+j+1,1,a[i][j]);
		else{
			res+=b[i][j];
			d[i][j]=-1;
			nt.add_edge(i+1,n+j+1,1,-b[i][j]);
		}
	}
	for(int i=0;i<n;i++) nt.add_edge(0,i+1,1,0);
	for(int i=0;i<n;i++) nt.add_edge(n+i+1,2*n+1,1,0);
	cout<<res+nt.min_cost_flow(0,2*n+1,n)<<endl;
	int cnt=0;
	vi x,y;
	vs s;
	for(int i=1;i<=n;i++) for(int j=0;j<nt.g[i].size();j++){
		edge &e=nt.g[i][j];
		if(e.to){
			int tmp=e.to-n-1,v=d[i-1][tmp];
			if(!e.cap){
				if(!v) v=1;
				if(v==-1) v=0;
			}
			if(v!=0){
				cnt++;
				x.push_back(i);
				y.push_back(tmp+1);
				if(v==1) s.push_back("write");
				else s.push_back("erase");
			}
		}
	}
	cout<<cnt<<endl;
	for(int i=0;i<cnt;i++) cout<<x[i]<<' '<<y[i]<<' '<<s[i]<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,t,ans=0,nows=0,nowe=0;
	cin >>n>>t;
	for(int i=0;i<n;i++){
		int z;
		cin>>z;
		if(z<nowe){
			ans+=z-nows;
		}
		else{
			if(i!=0){
				ans+=t;
			}
		}
		nows=z;nowe=z+t;
	}
	cout << ans+t;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = 0LL;
	if (n >= m / 2) {
		ans += m / 2;
	}
	else {
		ans += n;
		m -= 2 * n;
		ans += m / 4;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    if ((B - 1) % (A - 1) == 0)
        cout << (B - 1) / (A - 1) << endl;
    else
        cout << (B - 1) / (A - 1) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
//#define sort(v,n) sort(v,v+n)
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;
bool a[1299710];

inline void prime() {
	int now = 2;
	while (now<=650000) {
		if (a[now] == 1) {
			now++;
			continue;
		}
		for (int i = now*2; i <= 1299709; i += now) {
			a[i] = 1;
		}
		now++;
	}
	a[0] = 1;
	a[1] = 1;
}

int main() {
	prime();
	while (cin >> n, n) {
		if (a[n] == 0) {
			cout << 0 << endl;
		}
		else {
			int c, d;
			for (int i = n - 1;; i--) {
				if (a[i] == 0) {
					c = i;
					break;
				}
			}
			for (int i = n + 1;; i++) {
				if (a[i] == 0) {
					d = i;
					break;
				}
			}
			cout << d - c << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4332
#include <iostream>
using namespace std;
int a[35];
int main()
{
	int n,m,num;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		int flag;
		cin>>num;
		for(int j=1;j<=num;++j)
		{
			cin>>flag;
			a[flag]++;
		}
	}
	int ans=0;
	for(int i=1;i<=m;++i)
	{
		if(a[i]==n)
		{
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int N = s.size();
    for (int i = 0; i < N; ++i) cout << "x";
    cout << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT32_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#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++)

int main() {
    int n, a[MAX_N], ans = 0;
    cin >> n;
    REP(i, n) { cin >> a[i]; }
    sort(a, a + n);
    int t = 0, c = 0;
    REP(i, n) {
        if (t != a[i]) {
            ans += c % 2;
            t = a[i];
            c = 1;
        }
        else{
            c++;
        }
    }
    ans += c%2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    long long dp[s.size()+1][13];
    rep(i,s.size()+1)rep(j,13)dp[i][j]=0;
    dp[0][0] = 1;
    long long i,j,k,g;
    for(i=0;i<s.size();i++)
    {
        for(j=0;j<13;j++)
        {
            if (s[i] == '?')
            {
                for(k=0;k<10;k++)
                {
                    g=(j*10 + k)%13;
                    dp[i + 1][g] += dp[i][j];
                    if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
                }
            }
            else
            {
                g=(j * 10 + (s[i] - '0'))%13;
                dp[i + 1][g] += dp[i][j];
                if(dp[i + 1][g]>=MOD)dp[i + 1][g]-=MOD;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
}


Measured memory_bytes: 10704
from sys import stdin,stdout
for _ in range(1):#int(stdin.readline())):
    # n=int(stdin.readline())
    x,k,d=list(map(int,stdin.readline().split()))
    '''if x==k==d:
        print(0 if k&1 else x)
        continue'''
    x=abs(x)
    des=x%d
    op=x//d
    # print(des,op)
    a=[des,des-d]
    if k<op:#check for eq
        print(x-k*d)
    else:
        print(abs(a[(k-op)%2]))

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        String s = sc.next();
      	String t = sc.next();
     
       char[] schar = s.toCharArray();
       char[] tchar = t.toCharArray();
      for(int i=0; i<n; i++){
        System.out.print(schar[i]+""+tchar[i]);
      }
	}
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define Phuong ios_base::sync_with_stdio(0); cin.tie(0);
typedef unsigned long long ll;
using namespace std;
typedef pair<int,int> pii;
#define mpp make_pair
#define pb push_back
int dp[3][10];

int main()
{
#ifndef RICARDO
    //freopen("input.inp", "r", stdin);
#endif // RICARDO
    Phuong;
    int n;
    string s;
    cin >> n;
    cin >> s;
    memset(dp,0,sizeof(dp));
    for(int i=0; i<n; ++i)
    {
        int id = s[i]-'0';
        for(int u=2; u>=0; --u)
        {
            if (u==0)
            {
                dp[u][id]=1;
                continue;
            }
            int sum=0;
            for(int j=0; j<10; ++j) sum += dp[u-1][j];
            dp[u][id] = max(dp[u][id],sum);
        }
    }
    int ans =0;
    for(int i=0; i<10; ++i) ans += dp[2][i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
import std;
import core.bitop;

// dfmt off
ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
void aryWrite(T = long)(T[] ary){ ary.map!(x => x.text()).join(' ').writeln(); }
alias Pair = Tuple!(long, "H", long, "W", long, "cost");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto s = sread();
    auto k = lread();
    auto ans = new char[](s.length);
    foreach (i, e; s)
    {
        auto diff = ('z' - e + 1) % 26;
        // diff.writeln();
        if (diff <= k)
        {
            ans[i] = 'a';
            k -= diff;
        }
        else
        {
            ans[i] = e;
        }
    }

    ans[$ - 1] += k % 26;

    ans.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 3908
using System;
using static System.Console;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int D = 25 - int.Parse(ReadLine());
            string tmp = "Christmas";
            for(int i = 0; i < D; i ++)
            {
                tmp += " Eve";
            }
            WriteLine(tmp);
        }
    }
}

Measured memory_bytes: 11092
n,k=map(int,input().split())
s=list(input())
st=[]
en=[]
if s[0]=="1":
    st.append(0)
for i in range(1,n):
    if s[i-1]=="0" and s[i]=="1":
        st.append(i)
    if s[i-1]=="1" and s[i]=="0":
        en.append(i)
if s[n-1]=="1":
    en.append(n)
ans=0
if len(en)+1<=k:
    print(n)
    exit()
if len(en)<=k and s[0]=="1":
    print(n)
    exit()
if len(en)<=k and s[n-1]=="1":
    print(n)
    exit()
if len(en)-1<=k and s[n-1]=="1" and s[0]=="1":
    print(n)
    exit()
    
if len(en)<=k:
    k=len(en)
for i in range(len(en)-k):
    ans=max(ans,en[i+k]-st[i])
if s[0]=="0":
    ans=max(ans,en[k-1])
if s[n-1]=="0":
    ans=max(ans,n-st[len(st)-k])
print(ans)


Measured memory_bytes: 7824
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < W; i++) printf("#");
        printf("\n");
 
        for(int i = 1; i < H-1; i++){
            printf("#");
            for(int j = 1; j < W-1; j++) printf(".");
            printf("#\n");
        }
 
        if(H > 1){
            for(int i = 0; i < W; i++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2612
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int cul(int x1,int x2,int x3,int x4,int x5,int x6,int x7) {
	return x1 + 2 * x2 + 4 * x3 + 8 * x4 + 16 * x5 + 32 * x6 + 64 * x7;
}
int main() {
	int trans[128];
	string s;
	while (cin >> s) {
		if (s == "#")break;
		rep(i, 128) {
			trans[i] = s[i] - '0';
		}
		int a[19] = {};
		bool f = true;
		rep(i, (1 << 19)) {
			rep(j, 19) {
				if (i&(1 << j)) {
					a[j] = 1;
				}
				else {
					a[j] = 0;
				}
			}
			int b[7];
			b[0] = trans[cul(a[1], a[2], a[6], a[0], a[3], a[5], a[4])];
			b[1] = trans[cul(a[7], a[8], a[18], a[1], a[2], a[6], a[0])];
			b[2] = trans[cul(a[8], a[9], a[1], a[2], a[10], a[0], a[3])];
			b[3] = trans[cul(a[2], a[10], a[0], a[3], a[11], a[4], a[12])];
			b[4] = trans[cul(a[0], a[3], a[5], a[4], a[12], a[14], a[13])];
			b[5] = trans[cul(a[6], a[0], a[16], a[5], a[4], a[15], a[14])];
			b[6] = trans[cul(a[18], a[1], a[17], a[6], a[0], a[16], a[5])];
			int c = trans[cul(b[1], b[2], b[6], b[0], b[3], b[5], b[4])];
			if (b[0] != c) {
				f = false; break;
			}
		}
		if (f)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}


Measured memory_bytes: 3212