akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;

/*** typedef ***/
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;
typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;
typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;

/*** define ***/
#define sz(x)			((int)x.size())
#define tin(x)			scanf("%d",&x)
#define all(x)			x.begin(),x.end()
#define Set(b,a)		memset(b,a,sizeof b)
#define print1(x)		printf("Case %d:",x++)
#define tin2(x,y)		scanf("%d%d",&x,&y)
#define tin3(x,y,z)		scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)	for(int i=i0 ; i<in ; i++)
#define rep(i,n)		for(int i=0 ; i<(n) ; i++)
#define _rep(i,n)		for(int i=n-1 ; i>=0 ; i--)
#define _loop(i,in,i0)	for(int i=in-1 ; i>=i0 ; i--)
#define Fore(it, x)		for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

const int       maxn = 1000000+4;
const long double PI = 3.1415926535897932384626433832795;

int mp[maxn];
bool prime[maxn];

void sieve(int n){
	int cnt=0;
	Set(prime,0);
	prime[0]=prime[1]=1;
	loop(i,2,n){
		if(!prime[i]){
			mp[i]=++cnt;
			if(n/i>=i)
				for(int j=i*i ; j<=n ; j+=i)
					prime[j]=1;
		}
		else
			mp[i]=cnt;
	}
}

     
int main()  
{  
#ifdef Online_Judge
	freopen("a.in","r",stdin);
#endif
	int n;
	sieve(1000000);
	while(~tin(n))
		printf("%d\n",mp[n]);
	return 0;
}

Measured memory_bytes: 6076
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

//#include "Union_Find.h"

LL N;
int main() {
	cin >> N;
	cout << ((N - 1) / 11) * 2 + ((N - 1) % 11 + 1) / 7 + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        for _ in range(num): return []
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(map(int, input().split())) for _ in range(N)]
        return map(list,zip(*read_all))

#################

H,W,A,B = II()

s = [['0']*W for _ in range(H)]

for i in range(B):
    for j in range(A):
        s[i][j] = '0'
    for j in range(A,W):
        s[i][j] = '1'

for i in range(B,H):
    for j in range(A):
        s[i][j] = '1'
    for j in range(A,W):
        s[i][j] = '0'

for i in range(H):
    print(''.join(s[i]))

Measured memory_bytes: 49648
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    if (n >= k) {
      System.out.println(x*k+y*(n-k));
    } else {
      System.out.println(n*x);
    }
  }

}


Measured memory_bytes: 21844
// ABC088C - Takahashi's Information

#include <bits/stdc++.h>
using namespace std;

int main() {
	int c[3][3];
	bool ans = true;

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			int diff;
			cin >> c[i][j];
			if (j == 0) {
				diff = c[i][j] - c[0][j];
			} else {
				if (c[i][j] - c[0][j] != diff) {
					ans = false;
				}
			}
		}
	}

	if (ans) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
using namespace std;
ll ans;
ll N,K;
ll A[200001];
ll sum[200001];
int main() {
	cin >> N >> K;
	if (N%K == 0)cout << 0 << endl;
	else cout << 1 << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
    double stack[80];
    int top;
    char in[82], *p;
 
    while (fgets(in, 81, stdin) != NULL) {
        top = -1;
        for (p = strtok(in, " \n"); p != NULL; p = strtok(NULL, " \n")) {
            if (strlen(p) == 1) {
                if (*p == '+') {
                    stack[top-1] += stack[top];
                    top--;
                } else if (*p == '-') {
                    stack[top-1] -= stack[top];
                    top--;
                } else if (*p == '*') {
                    stack[top-1] *= stack[top];
                    top--;
                } else if (*p == '/') {
                    stack[top-1] /= stack[top];
                    top--;
                } else {
                    stack[++top] = strtod(p, NULL);
                }
            } else {
                stack[++top] = strtod(p, NULL);
            }
        }
        printf("%.6f\n", stack[top]);
    }
    return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <string.h>

void reverse( char *s, char *e ){
	char t;
	
	while( s < e ){
		t=*e; *e = *s; *s=t;
		e--; s++;
	}
}

void str_reverse( char *str ){
	char *end = &str[ strlen(str)-1 ];
	
	reverse( str, end );
}

int main(){
	char str[21];

	scanf("%s", str);
	str_reverse( str );
	printf("%s\n", str);

	return 0;
}

Measured memory_bytes: 524
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(elem => int.Parse(elem));
            var table = new Dictionary<int, int>();
            foreach (var num in A.Where(elem => elem != 0))
            {
                if (!table.ContainsKey(num))
                {
                    table[num] = 0;
                }

                table[num]++;
            }

            foreach (var num in Enumerable.Range(1, N))
            {
                Console.WriteLine(table.ContainsKey(num) ? table[num] : 0);
            }
        }
    }
}


Measured memory_bytes: 52184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		String[] s = sc.next().split("",0);
		int i = 0;
		int l = 0;
		int r = 0;
		for(String str : s) {
			if (i%2 == 0) {
				if (str.equals("0")) {
					l++;
				} else {
					r++;
				}
			} else {
				if (str.equals("1")) {
					l++;
				} else {
					r++;
				}
			}
			i++;
		}
		System.out.println(Math.min(l, r));

	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 30804
n = int(input())
dpa = [0 for i in range(n)]
dpb = [0 for i in range(n)]
dpc = [0 for i in range(n)]
a,b,c = map(int,input().split())
dpa[0] = a
dpb[0] = b
dpc[0] = c
for i in range(1,n):
    a,b,c = map(int,input().split())
    dpa[i] = max(dpb[i-1],dpc[i-1])+a
    dpb[i] = max(dpc[i-1],dpa[i-1])+b
    dpc[i] = max(dpa[i-1],dpb[i-1])+c
print(max(dpa[n-1],dpb[n-1],dpc[n-1]))

Measured memory_bytes: 53772
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7
import fractions
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors

def is_prime(n):
    if n == 1: return False

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

A, B = MAP()
yakusu = make_divisors(fractions.gcd(A, B))
count = 1
for yy in yakusu:
    if is_prime(yy):
        count += 1
print(count)


Measured memory_bytes: 66664
S = input()
N = len(S)
MOD = 10 ** 9 + 7
dp = [[0] * 13 for i in range(N + 1)]
dp[0][0] = 1

for i, s in enumerate(S[::-1], start=1):
    p10 = pow(10, i - 1, 13)
    if s != '?':
        for k in range(13):
            dp[i][(int(s) * p10 + k) % 13] += dp[i - 1][k]
            dp[i][(int(s) * p10 + k) % 13] %= MOD
    else:
        for j in range(10):
            for k in range(13):
                dp[i][(j * p10 + k) % 13] += dp[i - 1][k]
                dp[i][(j * p10 + k) % 13] %= MOD

print(dp[N][5] % MOD)


Measured memory_bytes: 62812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d,j,k,m,p,n,i,t,T,f1,f2,ans;

int main(){
    scanf("%lld%lld",&t,&n);
    if(t>=10)
    	printf("%lld\n",n);
    else
    {
    	b=100*(10-t);
    	printf("%lld\n",n+b);
    }
}


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


#define MAX_N 1000000
int prime[MAX_N];//i番目の素数
bool is_prime[MAX_N+1];
int sieve(int n){
	int p=0;
	memset(is_prime,true,sizeof(is_prime));
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
		}
	}
	return p;
}


int main(){
	int num=sieve(MAX_N),n;
	while(cin>>n&&n){
		int ans=0,x;
		int p,m;
		for(int i=0;i<n;i++){
			cin>>p>>m;
			x=upper_bound(prime,prime+num,p+m)-lower_bound(prime,prime+num,p-m);
			if(x==0)ans--;
			else ans+=x-1;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int n,k;
int pre[maxn];
bool check(int mid) {
	ll cnt=0;
	for(int i=1;i<=n;i++) {
		cnt+=(pre[i]-1)/mid;
		if(cnt>k) return false;
	}
	return true;
}
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>pre[i];
    int l=0,r=1e9+10;
	while(l+1<r) {
		int mid=l+r>>1;
		if(check(mid)) r=mid;
		else l=mid;
	}
	cout<<r<<endl;
    return 0;
}

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

int main(){
	int N,K;
	cin >> N >> K;
	double ans(0);
	int now;
	for(int i(1);i<=N;++i){
		now = i;
		double p = 1.0/N;
		while(now < K){
			p *= 0.5;
			now *= 2;
		}
		ans += p;
	}
	cout << fixed << setprecision(30) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace abc104
{
    class Program
    {
        static void Main(string[] args)
        {
            var dg = ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int d = dg[0];
            int g = dg[1];
            var p = new int[d];
            var c = new int[d];
            for (int i = 0; i < d; i++)
            {
                var pc = ReadLine().Split().Select(x => int.Parse(x)).ToArray();
                p[i] = pc[0];
                c[i] = pc[1];
            }
            int ans = (int)1e9;
            for (int i = 0; i < (1 << d); i++)
            {
                int s = 0, num = 0, rest_max = -1;
                for (int j = 0; j < d; j++)
                {
                    
                    if((i >> j & 1) != 0)
                    {
                        s += 100 * (j + 1) * p[j] + c[j];
                        num += p[j];
                    }
                    else
                    {
                        rest_max = j;
                    }
                    
                }
                if(s < g)
                {
                    int s1 = 100 * (rest_max + 1);
                    int need = (g - s + s1 - 1) / s1;
                    if (need >= p[rest_max])
                    {
                        continue;
                    }
                    num += need;
                }
                ans = Math.Min(ans, num);
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>

using namespace std;

long long dp[3001][3001];
int a[3001];

const int mod = 998244353;

int main()
{
  int N, S;
  
  scanf("%d %d", &N, &S);
  
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    dp[i - 1][0] = i;
    for (int j = S; j >= 0; j--) {
      dp[i][j] = (dp[i - 1][j] + (j >= a[i] ? dp[i - 1][j - a[i]] : 0)) % mod;
    }
    ans = (ans + dp[i][S]) % mod;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

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

int main() {
  int a1,a2,s1,s2,s3,temp;
  cin>>a1>>a2;
  s1 = a1+a2;s2=a1-a2;s3=a1*a2;

  if (s1>s2){
    temp = s1;
  }
  else{
    temp = s2;
  }

  if (temp > s3){
    cout<<temp;
  }
  else{
    cout<<s3;
  }
return 0;
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<int,int> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}

int m,cont;

bool ok(string num){
	bool a = false, b = false, c = false;
	rep(i,0,sz(num)-1){
		if(num[i] == '3')
			a = true;
		if(num[i] == '5')
			b = true;
		if(num[i] == '7')
			c = true;
	}
	if(a && b && c) return true;
	return false;
}

void solve(int n, string num){
	//~ cout<<num <<" ";
	if(n == 0){
		if(ok(num) && m >= conv(num) ){
			cont += 1;
		}
		return;
	}
	if(ok(num) && m >= conv(num) ){
		cont += 1;
	}
	solve(n-1, num+conv(3));
	solve(n-1, num+conv(5));
	solve(n-1, num+conv(7));
	
}

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

	cont = 0;
	m = conv(p);
	int n = sz(p);
	solve(n,"");
	cout<<cont;
	return 0;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR0(i, n) for (int i = 0; i < n; i++)
#define FOR1(i, n) for (int i = 1; i <= n; i++)
#define FORl(i, l, n) for (int i = l; i < n; i++)
using namespace std;
#define pi pair<ll, ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x, 0, sizeof(x));
#define vi vector<ll>
#define sync                      \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
#define endl '\n'
#define sp << " " <<
#define intmax 1e14
ll mod = 1e9 + 7;

ll power(ll num, ll g, ll mod)
{
	if (g == 0)
		return 1;
	if (g % 2 == 1)
		return (num * power((num * num) % mod, g / 2, mod)) % mod;
	return power((num * num) % mod, g / 2, mod);
}

ll n, m ,k;
const int  N = 200005;
ll a[N], b[N], dp[N], pp[N];
int main() {
    cin >> n >> m >> k;
	FOR0(i,n){
		cin >> a[i];
		if(i == 0){
			dp[i] = a[i];
			continue;
		}
		dp[i] = dp[i-1] + a[i];
	}
	FOR0(i,m){
		cin >> b[i];
		if(i == 0){
			pp[i] = b[i];
			continue;
		}
		pp[i] = pp[i-1] + b[i];
	}
	ll p1 = 0, p2 = 0;
	FOR0(i,n){
		if(dp[i] <= k){
			p1 = i + 1;
		}
	}
	FOR0(i,m){
		if(pp[i] <= k){
			p2 = i + 1;
		}
	}
	ll ans = 0;
	FOR0(i,n){
		ll val = k - dp[i]; 
		if(val < 0){
			break;
		}
		ll pos = lower_bound(pp,pp+m,val) - pp;
		if(pos == m){
			pos--;
		}
		else if(pp[pos] != val){
			pos--;
			if(pos < 0){
				continue;
			}
		}
		ans = max(ans, pos + i + 2);
	}
	ans = max(ans, max(p1,p2));
	cout << ans << endl;
}

Measured memory_bytes: 9860
//#include"cpp_kyopro.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include<stdio.h>

using namespace std;
int main() {
	int h, w; cin >> h >> w;
	vector<string> s(h);
	vector<int> v(w,h);
	for (int i = 0; i < h; ++i) {
		cin >> s.at(i);
	}
		
		int x[3] = { -1,0,1};
		int y[3] = { -1,0,1 };

		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; j++) {
				int ans = 0;
				if (s[i][j] == '#') continue;
				for (int  k=0; k < 3;k++) {
					int  xx = i + x[k];
					for (int l=0; l < 3;l++) {
						int yy = j + y[l];
						if (!(xx >= 0 && xx < h && yy >= 0 && yy < w))continue;
						if (s[xx][yy] == '#')ans++;
					}
				}
				s[i][j] = char(ans+'0');

			}
			cout << s[i] << endl;
		}
				

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
const int MOD = 1e9 + 7;
int p[1000000];
vector<int> divi;
void Eratosthenes(int N){
	fill(p,p + (N + 3),1);
	p[0] = p[1] = 0;
	for(int i = 2; i <= N; i++){
		if(p[i] == 1){
			divi.push_back(0);
			for(int j = i; j <= N; j+=i){
				p[j] = 0;
				int tmpj = j;
				while(tmpj % i == 0){
					tmpj /= i;
					divi[divi.size()-1]++;
				}
			}
		}
	}
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	cin >> n;
	Eratosthenes(n);
	long long ans = 1;
	REP(i,divi.size()){
		ans = ans * (divi[i] + 1) % MOD;
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

const int INF = 1 << 30;

using Edge = std::pair<int, int>;
using Graph = std::vector<std::vector<Edge>>;
Graph G;

std::vector<bool> visited;
std::vector<int> X;

void dfs(const int v, bool &res) {
  visited[v] = true;

  for (auto e : G[v]) {
    int nv = e.first;
    if (visited[nv]) {
      if (X[nv] != X[v] + e.second)
        res = false;
      continue;
    }

    X[nv] = X[v] + e.second;
    dfs(nv, res);
  }
}

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> L(M), R(M), D(M);
  for (int i = 0; i < M; ++i) {
    std::cin >> L[i] >> R[i] >> D[i];
    --L[i], --R[i];
  }

  G.resize(N);
  for (int i = 0; i < M; ++i) {
    G[L[i]].push_back(std::make_pair(R[i], D[i]));
    G[R[i]].push_back(std::make_pair(L[i], -D[i]));
  }

  visited.assign(N, false);
  X.assign(N, INF);

  bool res = true;
  for (int v = 0; v < N; ++v) {
    if (visited[v])
      continue;
    dfs(v, res);
  }

  if (res)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 14336
package main

import (
	"fmt"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func printG(row, rest int, one, much byte) {
	for i := 0; i < row; i++ {
		for j := 0; j < 99; j++ {
			fmt.Printf("%c", one)
		}
		fmt.Println()
		for j := 0; j < 99; j++ {
			if j%2 == 0 {
				fmt.Printf("%c", one)
			} else {
				fmt.Printf("%c", much)
			}
		}
		fmt.Println()
	}
	for i := 0; i < 99; i++ {
		fmt.Printf("%c", one)
	}
	fmt.Println()
	if rest > 0 {
		for i := 0; i < 99; i++ {
			if i < 2*rest {
				if i%2 == 0 {
					fmt.Printf("%c", one)
				} else {
					fmt.Printf("%c", much)
				}
			} else {
				fmt.Printf("%c", one)
			}
		}
		fmt.Println()
		for i := 0; i < 99; i++ {
			fmt.Printf("%c", one)
		}
		fmt.Println()
	}
}

func main() {
	A := 0
	B := 0
	fmt.Scanf("%d", &A)
	fmt.Scanf("%d", &B)
	ARow := (A - 1) / 49
	BRow := (B - 1) / 49
	ARest := A - ARow*49 - 1
	BRest := B - BRow*49 - 1
	rowA, rowB := 0, 0
	if ARow > 0 {
		rowA = 2*ARow + 1
	}
	if BRow > 0 {
		rowB = 2*BRow + 1
	}
	if ARest > 0 {
		if rowA > 0 {
			rowA += 2
		} else {
			rowA += 3
		}
	}
	if BRest > 0 {
		if rowB > 0 {
			rowB += 2
		} else {
			rowB += 3
		}
	}
	if A == 1 {
		rowA += 1
	}
	if B == 1 {
		rowB += 1
	}
	row := rowA + rowB
	fmt.Printf("%d %d\n", row, 99)
	printG(ARow, ARest, '#', '.')
	printG(BRow, BRest, '.', '#')
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.Stream;
import static java.util.stream.Collectors.joining;

class Main {
    final static int k = 10001;
  static int[] C = new int[k];

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

    for (int i = 0; i < size; i++) C[A[i] = Integer.parseInt(sc.next())]++;
    for (int i = 1; i < k; i++) C[i] += C[i - 1];
    for (int i = size - 1; i >= 0; i--) B[--C[A[i]]] = A[i];
    System.out.println(Arrays.stream(B).boxed().map(n -> n.toString()).collect(joining(" ")));
  }
}



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

int main() {
  ll A,B,N;
  cin >> A >> B >> N;
  
  if(N < B){
	cout << (ll)(A*N/B) << endl;
  }else{
    cout << (ll)(A*(B-1)/B) << endl;
  }
  return(0);
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(){
  int n,min,max,result;
  int score[100];

  while(true){

    cin >> n;
    if(n == 0) break;

    result = 0;
    min = 1000;
    max = 0;

    REP(i,n){
      int score;
      cin >> score;
      if(max < score) max = score;
      if(min > score) min = score;
      result += score;
    }
    cout << (result - max - min)/(n-2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n, k = gets.split.map(&:to_i)
$v = gets.split.map(&:to_i)
ans = 0

def calc(l, r, k, n)
    k -= (l + r)
    return -1 if k < 0 || (l + r) > n
    tmp = $v[0, l] + $v[-r, r]
    tmp.sort!
    k = [k, tmp.size].min
    res = 0
    tmp.each { |x| res += x }
    k.times do |i|
        res -= tmp[i] if tmp[i] < 0
    end
    res
end

(0..k).each do |l|
    (0..k).each do |r|
        ans = [ans, calc(l, r, k, n)].max
    end
end

puts ans

Measured memory_bytes: 1788
//author-micheal corleone
//the godfather
#include <bits/stdc++.h>
#include <set> 
#include<algorithm>
#include <set> 
#include<algorithm>
#define ll long long int
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define out(n) printf("%lld\n",n)
#define inf 100000000000000
#define endl "\n"
#define precise(x) fixed << setprecision(x) 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
const int MOD =1000000007;
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
 
using namespace std;

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[1] < v2[1]; 
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}
 //ll power(ll x, ll y) 
//{ 
  //  ll temp; 
    //if( y == 0) 
     //   return 1; 
    //temp = power(x, y/2); 
    //temp=temp%MOD;
    //if (y%2 == 0) 
     //   return (temp%MOD)*(temp%MOD); 
    //else
      //  return (x%MOD)*(temp%MOD)*(temp%MOD); 
//} 
 
 
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
 //diamond[2000005],ans[1000006];
 const int maxn=2e5+100;
 const int N = 3010;
double p[N], dp[N][N];
ll n;
 double solve(ll i,ll h)
 {
 	if (i == n + 1) {
        if (h >= (n + 1) / 2) {
            return 1.0;
        } else {
            return 0;
        }
    }
    
    if(dp[i][h]!=-1.0) return dp[i][h];
    
    return dp[i][h]=p[i]*solve(i+1,h+1)+(1-p[i])*solve(i+1,h);
 }

int main()
{
	ios_base::sync_with_stdio(0);
   cin.tie(0);
    cout.tie(0);
     ll t;
   //cin>>t;
   
   t=1;	
   while(t--)
    {
        ll i1,i2,k,j,j1,a1,i31,i3,j2,i5,i4,i6,i7,i,m;
        ll x,y,z;
        ll total=0,cnt=0;
        ll flag=0;
        y=0;
        ll res,res1,ans,res2,q;
        ans=0;
        res1=0,res=0;
        ll s1,s2,s3;
        s2=0;
        ll sum=0,flag1=0;
        s1=0;
        ll k1,k2,k3;
        k1=0,k2=0;
        ll d,required,days,h,w;
        //cin>>h>>c>>required;
         cin >> n;
        for ( i = 1; i <= n; i++)  cin >> p[i];
        
       for (int i = 0; i < N; i++) {
        fill_n(dp[i], N, -1.0);
    }
		
        double answer=solve(1,0);
        
        cout<<fixed<<setprecision(12)<<answer;
    
     }
    
}
	

Measured memory_bytes: 71296
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n ;
  cin >> n;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
  cin >> vec.at(i);
 }
  vector<int>ans(n);
  for(int i=0;i<n;i++){
  int p=vec.at(i);
  ans.at(p-1)=i+1;}  
  for(int i=0;i<n;i++){
  cout << ans.at(i) <<endl;}
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<set>
using namespace std;
typedef long long ll;

int n,m,a,b,ans;
int h[100005]; 
set<int> s[100005];

int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	while(m--)
	{
		cin>>a>>b;
		s[a].insert(b);
		s[b].insert(a);
	}
	
	for(int i=1;i<=n;i++)
	{
		if(s[i].empty()) ans++;
		else
		{
			int mark=1;
			for(set<int>::iterator  j=s[i].begin();j!=s[i].end();j++)
			{
				if(h[i]<=h[*j])
				{
					mark=0;
					break;
				}
			}
			ans+=mark;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int h,w,c;
int p[10][10];
bool bp[10][10];

int cou;
void dfs(int y,int x){
	if(y==0&&x==0){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				bp[i][j]=0;
			}
		}
		cou=0;
	}
	bp[y][x]=1;
	REP(i,4){
		int ty=y+dy[i];
		int tx=x+dx[i];
		if(0<=tx&&tx<w&&0<=ty&&ty<h&&bp[ty][tx]==0&&p[0][0]==p[ty][tx]){
			dfs(ty,tx);
		}
	}
	cou++;
}
	

int calc(int times){
	if(times>=4){
		dfs(0,0);
		int tmp[10][10];
		REP(k,h){
			REP(j,w){
				tmp[k][j]=p[k][j];
			}
		}
		for(int k=0;k<h;k++){
			for(int j=0;j<w;j++){
				if(bp[k][j]==1){
					p[k][j]=c;
				}
			}
		}
		dfs(0,0);
		REP(k,h){
			REP(j,w){
				p[k][j]=tmp[k][j];
			}
		}
		return cou;
	}
	int ans=-1;
	for(int i=1;i<=6;i++){
		if(i!=p[0][0]){
			dfs(0,0);
			int tmp[10][10];
			REP(k,h){
				REP(j,w){
					tmp[k][j]=p[k][j];
				}
			}
			for(int k=0;k<h;k++){
				for(int j=0;j<w;j++){
					if(bp[k][j]==1){
						p[k][j]=i;
					}
				}
			}
			ans=max(ans,calc(times+1));
			REP(k,h){
				REP(j,w){
					p[k][j]=tmp[k][j];
				}
			}
		}
	}
	return ans;
}
			

int main(){
	while(1){
		cin>>h>>w>>c;
		if(h==0&&w==0&&c==0){
			break;
		}
		REP(i,h)
			REP(j,w)
				cin>>p[i][j];
		
		cout<<calc(0)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3064
use proconio::input;

#[allow(non_snake_case)]
fn main() {
    input! {
        D: usize,
        T: usize,
        S: usize,
    }

    if (D + S - 1) / S > T {
        println!("No");
    } else {
        println!("Yes");
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int N, M;
vi g[MX];
ll d[2][MX], ass[MX];
bool vis[MX];

void bfs(int nod) {
    queue<int> q;
    q.push(nod); d[0][nod] = 1;
    while(sz(q)) {
        int u = q.front(); q.pop();

        trav(v, g[u]) if (d[0][v] == 0) {
            d[0][v] = d[0][u]+1;
            q.push(v);
        }
    }
}

void construct(int nod) {
    queue<int> q; q.push(nod); ass[nod] = 1; d[1][nod] = 1;
    while(sz(q)) {
        int u = q.front(); q.pop();

        trav(v, g[u]) if (!ass[v]) {
            ass[v] = u; d[1][v] = d[1][u]+1;
            q.push(v);
        }
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> N >> M;

    FOR(i, 1, M+1) {
        int u, v; cin >> u >> v;

        g[u].pb(v); g[v].pb(u);
    }

    bfs(1); construct(1);

    bool ok = true;
    FOR(i, 1, N+1) {
        ok &= (d[0][i] == d[1][i]);
    }

    if (!ok) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        FOR(i, 2, N+1) {
            cout << ass[i] << "\n";
        }
    }
}


Measured memory_bytes: 14704
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans;
    if (K <= A)
        ans = K;
    else if (K <= A + B)
        ans = A;
    else
        ans = A - (K - A - B);
    cout << ans << endl;

    solve();
    return 0;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> int least_bit(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return __builtin_ffs(n) - 1;
  if (sizeof(T) == 8) return __builtin_ffsll(n) - 1;
}

// n must be greater than 0.
template<typename T> int least_bit_fast(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return __builtin_ctz(n);
  if (sizeof(T) == 8) return __builtin_ctzll(n);
}

template<typename T> int most_bit(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return n ? 31 - __builtin_clz(n) : -1;
  if (sizeof(T) == 8) return n ? 63 - __builtin_clzll(n) : -1;
}

template<typename T> int count_bit(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return __builtin_popcount(n);
  if (sizeof(T) == 8) return __builtin_popcountll(n);
}

class BitIterator : public iterator<input_iterator_tag, int> {
public:

  class Iterator : public iterator<input_iterator_tag, int> {
  private:
    int val, bit;

  public:
    Iterator(int val, int bit) : val(val), bit(bit) {}

    Iterator operator*() {return *this;}

    bool operator!=(const Iterator& itr) const {return val != itr.val;}

    void operator++() {val = least_bit(bit & -(1 << (val + 1)));}

    operator int() {return val;}
  };
  
  Iterator i, n;
  int bit;

  BitIterator(int n) : i(least_bit(n), n), n(-1, n), bit(n) {}

  bool operator!=(const BitIterator& itr) const {return i != itr.i;}

  void operator++() {*this = BitIterator(bit + 1);}

  operator int() const {return bit;}

  bool in(int i) const {return bit & (1 << i);}

  Iterator& begin() {return i;}

  Iterator& end() {return n;}
};

class FixSizeSet {
private:
  struct Iterator : public iterator<input_iterator_tag, int> {
  private:
    BitIterator val, n;

  public:
    Iterator(int val, int n) : val(val), n(n) {}

    Iterator operator*() {
      return *this;
    }

    bool operator!=(const Iterator& itr) const {
      return n != itr.n;
    }

    void operator++() {
      int x = val & -val, y = val + x;
      val = ((val & ~y) / x / 2) | y;
      if (val >= (1 << n)) n = 0;
    }

    operator int() const {
      return val;
    }

    bool in(int i) const {
      return val.in(i);
    }

    BitIterator::Iterator& begin() {
      return val.begin();
    }

    BitIterator::Iterator& end() {
      return val.end();
    }
  };
  
  Iterator i, n;

public:
  FixSizeSet(int n, int k) : i((1 << k) - 1, n), n(0, 0) {}

  Iterator& begin() {
    return i;
  }

  Iterator& end() {
    return n;
  }
};

int main() {
  while (true) {
    int n, k, s, res = 0;
    cin >> n >> k >> s;
    if (n == 0 && k == 0 && s == 0) break;
    for (auto iter : FixSizeSet(n, k)) {
      int sum = 0;
      for (auto i : iter) sum += i + 1;
      if (sum == s) ++res;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

using namespace std;

typedef long long ll;

#define f first
#define s second

long long n, k,  nr, dp[100002][3], c[3], ans;
char s[100002];

bool bate (int a, int b) {
  if ((a + 1) % 3 == b)
    return 1;
  return 0;
}

map<char, int>mp;


int main()
{
  cin >> n >> k;
  cin >> c[0] >> c[1] >> c[2];
  cin >> (s + 1);
  mp['r'] = 0;
  mp['s'] = 1;
  mp['p'] = 2;
  for (int i = 1; i <= k; i++) {
    nr = 0;
    for (int j = i; j <= n; j += k) {
      ++nr;
      dp[nr][0] = dp[nr][1] = dp[nr][2] = 0;
      for (int k = 0; k < 3; k++)
        dp[nr][k] = max(dp[nr][k], max(dp[nr - 1][(k + 1) % 3], dp[nr - 1][(k + 2) % 3]) + bate(k, mp[s[j]]) * c[k]);
    }
    ans += max(dp[nr][0], max(dp[nr][1], dp[nr][2]));
  }
  cout << ans;
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	string S,T; cin >> S >> T;
	int n = S.size();
	repp(i,0,n) repp(j,0,n){
		if(S[j] != T[(i+j)%n]) break;
		if(j == n-1) return cout << "Yes" << endl , 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
const int MAXN = (int)1e6 + 7;
const int V = (int)63 * MAXN;
const int infint = (int)1e9;
const int MOD = (int)1e9 + 9;
const ll inf = (ll)2e18 + 2;
ll n, m, a[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll gc = a[0];
	for (int i = 1; i < n; i++)
		gc = __gcd(a[i], gc);
	ll mx = 0;
	for (int i = 0; i < n; i++)
		mx = max(mx, a[i]);
	if(m % gc == 0 && mx >= m)
		cout << "POSSIBLE";
	else
		cout << "IMPOSSIBLE";
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {

    static void print_lst(List<Integer> lst, int n) {
        for(int i=0; i<n-1; i++) {
            System.out.print(lst.get(i) + " ");
        }
        System.out.println(lst.get(n-1));
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        List<Integer> lst = new ArrayList<>();

        n = sc.nextInt();
        for(int i=0; i<n; i++) {
            lst.add(sc.nextInt());
        }
        print_lst(lst, n);

        for(int i=1; i<n; i++) {
            int tmp = lst.get(i);
            int j = i-1;
            while(j >=0 && lst.get(j) > tmp) {
                lst.set(j+1, lst.get(j));
                j--;
            }
            lst.set(j+1, tmp);
            print_lst(lst, n);
        }

    }
}

Measured memory_bytes: 32380
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}

struct Edge{
	int src,dst;
	Edge(){}
	Edge(int s,int d):src(s),dst(d){}
};
typedef vector<vector<Edge> > Graph;

bool Augment(const Graph& g,int u,vi& vis,vi& match)
{
	rep(i,g[u].size()){
		int v=g[u][i].dst;
		if(vis[v]) continue;
		vis[v]=1;
		if(match[v]==-1 || Augment(g,match[v],vis,match)){
			match[u]=v;
			match[v]=u;
			return true;
		}
	}
	return false;
}

int BipartiteMatching(const Graph& g,vi& match)
{
	int n=g.size();
	match.assign(n,-1);
	int res=0;
	rep(i,n) if(match[i]==-1){
		vi vis(n);
		res+=Augment(g,i,vis,match);
	}
	return res;
}

int main()
{
	for(int m,n;cin>>m>>n,m|n;){
		vi bs(m),rs(n);
		rep(i,m) cin>>bs[i];
		rep(i,n) cin>>rs[i];
		
		Graph g(m+n);
		rep(i,m) rep(j,n) if(gcd(bs[i],rs[j])>1){
			g[i].push_back(Edge(i,m+j));
			g[m+j].push_back(Edge(m+j,i));
		}
		
		vi match;
		cout<<BipartiteMatching(g,match)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
int a,n;
string b[105];
int main()
{
    cin>>a>>n;
    for(int s=0;s<a;s++)
    {
        cin>>b[s];
    }
    sort(b,b+a);
    for(int s=0;s<a;s++)
        cout<<b[s];
    cout<<endl;
    return 0;
}

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

#define MAX_N 300

using namespace std;

typedef pair<int, int> P;

int N;
int A[MAX_N][MAX_N];

long long solve()
{
    long long answer = 0;
    P b[MAX_N];
    for (int u = 0; u < N; u++) {
        for (int i = 0; i < N; i++) {
            b[i] = P(A[u][i], i);
        }
        sort(b, b + N);
        // b[0] == (0, i);
        for (int i = 1; i < N; i++) {
            int v = b[i].second;
            if (v > u) {
                continue;
            }
            bool needRoad = true; // need a road between city u and v with length A[u][v].
            for (int j = 1; j < i; j++) {
                int w = b[j].second;
                int determinant = A[u][w] + A[w][v] - A[u][v];
                if (determinant < 0) {
                    return -1;
                }
                if (determinant == 0) {
                    needRoad = false;
                    break;
                }
            }
            if (needRoad) {
                answer += A[u][v];
            }
        }
    }
    return answer;
}

int main(void)
{
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int func(string s, string t) {
  int ans = 0;
  for (char c = 'a'; c <= 'z'; c++) {
    bool founds = false, foundt = false;
    rep(i,s.size()) {
      if (s.at(i)==c) {
        founds = true;
      }
    }
    rep(i,t.size()) {
      if (t.at(i)==c) {
        foundt = true;
      }
    }
    if (founds && foundt) ans++;
  }
  return ans;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int ans = 0;
  repi(i,1,N-2) {
    int tmp = func(S.substr(0,i),S.substr(i));
    ans = max(ans,tmp);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
lis=[]
for _ in range(n):
    x,l = map(int,input().split())
    lis.append([x+l,x-l])

lis.sort()

m = -(10**9+7)
ans = 0

for i in range(n):
    a ,b = lis[i]
    if m <= b:
        ans += 1
        m = a
    
print(ans)


Measured memory_bytes: 24436