akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static int[] Accumulate(IList<int> a) { var s = new int[a.Count + 1]; for (var i = 0; i < a.Count; i++) s[i + 1] = s[i] + a[i]; return s; }
	const int MOD = 1000000007;
	public K()
	{
		var N = G[0];
		var A = G;
		var sum = Accumulate(A, 0, (a, b) => a ^ b);
		var zero = Accumulate(sum.Select(t => t == 0 ? 1 : 0).ToList());
		Func<IList<int>, int[]> getZero = l => MakeArray(l.Count - 1, i => zero[l[i + 1]] - zero[l[i]]);
		var dic = Indexes(sum);
		if (sum[N] != 0) WriteLine(DP(getZero(dic[sum[N]])).Last());
		else WriteLine((Pow(2, zero[N + 1] - 2, MOD) + dic.Where(t => t.Key != 0).Sum(t => DP(getZero(t.Value)).Sum())) % MOD);
	}
	static Dictionary<int, List<int>> Indexes(IList<int> x)
	{
		var dic = new Dictionary<int, List<int>>();
		for (var i = 0; i < x.Count; i++)
		{
			if (!dic.ContainsKey(x[i])) dic[x[i]] = new List<int>();
			dic[x[i]].Add(i);
		}
		return dic;
	}
	static long[] DP(IList<int> zs)
	{
		var L = zs.Count;
		var dp = new long[L + 1];
		dp[0] = 1;
		var sum = 1L;
		for (var j = 0; j < L; j++)
		{
			dp[j + 1] = (dp[j] + zs[j] * sum % MOD) % MOD;
			sum = (sum + dp[j + 1]) % MOD;
		}
		return dp;
	}
	public static long Pow(long a, long b, long mod)
	{
		long p = 1L, x = a;
		while (b > 0)
		{
			if ((b & 1L) == 1L) p = p * x % mod;
			b >>= 1;
			x = x * x % mod;
		}
		return p;
	}
}


Measured memory_bytes: 73384
#encoding: utf-8

a = %w(
大きさ  60cm以内    80cm以内    100cm以内   120cm以内   140cm以内   160cm以内
重さ    2kg以内     5kg以内     10kg以内    15kg以内    20kg以内    25kg以内
料金    600円   800円   1000円  1200円  1400円  1600円
).map(&:to_i).each_slice(7).to_a.transpose[1..-1]

loop do
    n = gets.to_i
    break if n == 0
    total = 0
    n.times do
        x, y, z, w0 = gets.split.map &:to_i
        s0 = x + y + z
        #p [s0, w0]
        total += (a.find{|s, w, _| s >= s0 && w >= w0} || [0]).last
    end
    p total
end

Measured memory_bytes: 9000
N, Y = [int(i) for i in input().split()]

ans = None

for i in range(N+1):
    for j in range(i+1):
        y = (N-i)*10000 + (i-j)*5000 + j*1000
        if y == Y:
            ans=(i, j)
            break
    if y == Y:
        break
        
if ans:
    answer = ' '.join(
        [str(N-ans[0]), str(ans[0]-ans[1]), 
         str(ans[1])])
else:
    answer = '-1 -1 -1'
    
print(answer)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

def resolve():
    return 

N,W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range (N)]

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j>=wv[i][0]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]] + wv[i][1])
        else:
            dp[i+1][j] = max(dp[i][j], dp[i+1][j])

print(dp[N][W])



Measured memory_bytes: 120300
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll n,m;cin>>n>>m;
  ll min_val = 100000000007;
  map<ll, ll> mp;
  for(int i=0;i<n;++i){
    ll t;cin>>t;
    min_val = min(min_val, t);
    if(mp.find(t) != mp.end()){
      mp[t] = mp[t] + 1;
    } else {
      mp[t] = 1;
    }
  }
  for(int i=0;i<m;++i){
    ll b,c;cin>>b>>c;
    if(c<min_val) continue;
    if(mp.find(c) != mp.end()){
      mp[c] = mp[c] + b;
    } else {
      mp[c] = b;
    }
  }
  vector<pair<ll, ll>> v;
  for (auto const& ele: mp) {
    v.push_back(make_pair(ele.first,ele.second));
  }
  sort(all(v),[](pair<ll,ll>& a,pair<ll,ll>& b){return a.first > b.first;});
  ll out =0;
  ll rest = n;
  for (auto const& ele: v)
  {
    if(rest==0) break;
    ll cnt = min(rest, ele.second);
    out += ele.first * cnt;
    rest = rest - cnt;
  }
  /*for(int i=0;i<n;++i){
    out += q.top();
    q.pop();
  }*/
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 18928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			boolean isEven = s.length % 2 == 0 ? true : false;
			int t = s.length / 2;

			int l, r;
			if (isEven) {
				l = t - 1;
				r = t;
			} else {
				l = t;
				r = t;
			}
			t++;
			boolean isCont = true;
			Set<Character> set = new HashSet<>();

			while (isCont) {
				if (l < 0 || r >= s.length) {
					t--;
					break;
				}
				set.add(s[l]);
				set.add(s[r]);
				if (set.size() == 2) {
					isCont = false;
					t--;
				} else {
					l--; r++; t++;
				}
			}
			out.println(t);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

string trace(const vector<vector<int>> &dp, string s, string t, int i, int j) {
  if (i == 0 or j == 0)
    return "";
  if (s[i - 1] == t[j - 1])
    return trace(dp, s, t, i - 1, j - 1) + s[i];
  if (dp[i][j - 1] > dp[i - 1][j])
    return trace(dp, s, t, i, j - 1);
  return trace(dp, s, t, i - 1, j);
}
void init() {
  string s, t;
  cin >> s >> t;
  int m = s.size(), n = t.size();
  vector<vector<int>> dp(m + 1, vector<int>(n + 1));
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= n; j++) {
      if (i == 0 or j == 0)
        dp[i][j] = 0;
      else if (s[i - 1] == t[j - 1])
        dp[i][j] = dp[i - 1][j - 1] + 1;
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }
//   cout << trace(dp, s, t, m, n) << endl;
  string ans = "";
  for (int i = m, j = n; (i > 0 && j > 0);) {
    if (s[i - 1] == t[j - 1])
      ans += s[i - 1], i--, j--;
    else if (dp[i][j - 1] > dp[i - 1][j])
      j--;
    else
      i--;
  }
  reverse(all(ans));
  cout << ans << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <map>

#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)
using namespace std;

int main(){
	long  N,i,j,A[200000],L[200000],R[200000],ans=0;
	map<long, long> mpL,mpR;
	cin >> N;
	myfor(i,N){
		cin >> A[i];
		L[i] = A[i] + i;
		R[i] = i - A[i];
		mpL[L[i]]++;
		mpR[R[i]]++;
	}
	for(auto itr = mpL.begin(); itr != mpL.end(); ++itr) {
     ans += mpR[itr->first] * itr->second;
  }
	cout << ans <<endl;

	return 0;
}




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

int main() {

    int n, m;
    cin>>n>>m;
    if(n>1&&m>1)
    cout<<n*(n-1)/2 +m*(m-1)/2<<endl;
    else if(n>1&&m<2)
    cout<<n*(n-1)/2<<endl;
    else if(m>1&&n<2)
    cout<<m*(m-1)/2<<endl;
    else
    cout<<"0"<<endl;

//	cout<<"GfG!";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

mons = 0
tmp = 0

for i in range(n):
    if a[i] <= b[i]+tmp:
        mons += a[i]
        if a[i] >= tmp:
            tmp = b[i]-(a[i]-tmp)
        else:
            tmp = b[i]
    else:
        mons += b[i]+tmp
        tmp = 0

if a[n] >= tmp:
    mons += tmp
else:
    mons += a[n]

print(mons)

Measured memory_bytes: 82020
NN = 202020
MOD = 10**9+7
INF = float("inf")


n, m, q = map(int, input().split())
train = [list(map(int, input().split())) for _ in range(m)]
query = [list(map(int, input().split())) for _ in range(q)]

trains = [[0]*(n+1) for _ in range(n+1)]
cum = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
    trains[train[i][0]][train[i][1]] += 1

for i in range(1, n+1):
    for j in range(1, n+1):
        cum[i][j] = trains[i][j] + cum[i-1][j] + cum[i][j-1] - cum[i-1][j-1]

# print(trains)
# print(cum)
for i in range(q):
    start, end = query[i]
    ans = cum[end][end] - cum[end][start-1] - cum[start-1][end] + cum[start-1][start-1]
    print(ans)


Measured memory_bytes: 111192
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll A,B;
    cin >> A >> B;
    cout <<max({A*B, A+B, A-B}) <<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

int loadLuggage(int max_weight, int track_num, int * lugs, int lugs_num) {
    int lug_idx = 0;
    for (int i = 0; i < track_num; i++) {
        int weight = 0;
        while (weight + lugs[lug_idx] <= max_weight) {
            weight += lugs[lug_idx];
            lug_idx++;
            if (lug_idx == lugs_num) {
                return lug_idx;
            }
        }
    }
    return lug_idx;
}

int binarySearch(int min_weight, int max_weight, int track_num, int * lugs, int lugs_num) {
    if (min_weight + 1 >= max_weight) {
        if (loadLuggage(min_weight, track_num, lugs, lugs_num) == lugs_num) {
            return min_weight;
        } else {
            return max_weight;
        }
    }

    int weight = (min_weight + max_weight) / 2;
    int track_weight = -1;
    if (loadLuggage(weight, track_num, lugs, lugs_num) == lugs_num) {
        track_weight = binarySearch(min_weight, weight, track_num, lugs, lugs_num);
    } else {
        track_weight = binarySearch(weight, max_weight, track_num, lugs, lugs_num);
    }
    return track_weight;
}

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

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

    int ans = binarySearch(0, sum, k, w, n);

    std::cout << ans << std::endl;
}



Measured memory_bytes: 3480
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int x = (int)Math.ceil((a+b)/2.0d);
        
        System.out.println(x);
        scan.close();
        
    }
}

Measured memory_bytes: 19412
N,M = map(int,input().split())
lis = [0] * N
for i in range(M):
    a,b = map(int,input().split())
    lis[a-1] += 1
    lis[b-1] += 1
ans = 'YES'
for i in lis:
    if i % 2 == 1:
        ans = 'NO'
print(ans)


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

int main() {
    int a;
    cin >> a;
    a += 1;
    long long ans = 0;
    rep(i,a){
        if(i % 3 == 0 || i % 5 == 0 || i % 15 == 0){

        }else{
            ans += i;
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int mod = 1e9 + 7;

vll get_coef(int k) {
  vll ret(k, 0);
  ret[0] = k;
  rep (i, k-1) {
    ret[i+1] = ret[i] + (k - (i+1) * 2);
  }
  rep (i, k) {
    ret[i] %= mod;
  }
  return ret;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vi x(n), y(m);
  rep (i, n) {
    scanf("%d", &x[i]);
  }
  rep (i, m) {
    scanf("%d", &y[i]);
  }
  sort(all(x));
  sort(all(y));
  vi dx(n-1), dy(m-1);
  rep (i, n-1) {
    dx[i] = x[i+1] - x[i];
    dx[i] %= mod;
  }
  rep (i, m-1) {
    dy[i] = y[i+1] - y[i];
    dy[i] %= mod;
  }

  vll x_coef = get_coef(n-1);
  vll y_coef = get_coef(m-1);
  ll x_sum, y_sum;
  x_sum = y_sum = 0;
  rep (i, n-1) {
    x_sum += x_coef[i] * dx[i];
    x_sum %= mod;
  }
  rep (i, m-1) {
    y_sum += y_coef[i] * dy[i];
    y_sum %= mod;
  }
  ll ans = x_sum * y_sum % mod;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3328
# _*_ coding:utf-8 _*_

import sys

N = sys.stdin.readline().replace('\n','')
N = int(N)

def Func(a,b):
	if a > b:
		return digit(a)
	else: return digit(b)
		
def digit(num):
	d = len(str(num))
	return d

ans = 10

for i in range(1,N+1):
	if i*i > N: break
	if N % i == 0:
		dum = Func(N//i,i)
		if ans > dum:
			ans = dum

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include <numeric>
using namespace std;
const long long int INF = 10000000;
int main()
{
	int n, x;
	long long int max = -INF, min = INF, sum = 0;
	vector<int> v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		v.push_back(x);
		if (max < x)max = x;
		if (min > x)min = x;
		sum += x;
	}
	cout << min << " " << max << " " << sum << endl;
	//cout << *min_element(v.begin(), v.end()) << " " << *max_element(v.begin(), v.end()) << " " << accumulate(v.begin(), v.end(), 0) << endl;
    return 0;
}

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

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

  int N, K, k;
  cin >> N >> K;
  set<int> set;
  rep(i, 0, 10) { set.insert(i); }

  rep(i, 0, K) {
    cin >> k;
    set.erase(k);
  }

  bool ok;
  int ans = N;

  while (true) {
    string str = to_string(ans);
    ok = true;
    rep(i, 0, str.size()) {
      if (!set.count(str[i] - '0')) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << ans << endl;
      break;
    }
    ans++;
  }
  getchar();
}

Measured memory_bytes: 3724
import java.util.Scanner;

import java.util.TreeMap;


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

    int n = sc.nextInt();
    int t = sc.nextInt();
    int a ;
    int b ;
    TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>();
    for(int i=0; i<n; i++){
     a = sc.nextInt();
     b = sc.nextInt();
     if(b<=t){
       map.put(a,b);
     }
    }
    if(map.size()==0){
      System.out.println("TLE");
    }else{
      System.out.println(map.firstKey());
    }

  }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin >>h[i];
    for(int i=n-1;i>0;i--){
        if(h[i]==h[i-1]-1){
            h[i-1]--;
        }
        if(h[i]<h[i-1]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	while(getline(cin,s)){
		string ans="";
		for(string::size_type i=0; i<s.size(); i++){
			if(s.substr(i,5) == "peach"){
				ans+="apple";
				i+=4;
			}
			else if(s.substr(i,5) == "apple"){
				ans+="peach";
				i+=4;
			}
			else ans+=s[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,ans=1;
	cin>>n>>m;
	if(n==1||m==1){
		cout<<1<<endl;
		return 0;
	}
	long long nn=(n%2==1)?(n+1)/2:n/2,mm=(m%2==1)?(m+1)/2:m/2;
	cout<<nn*mm+(n-nn)*(m-mm);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll x, a, b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  string S;
  cin>>N>>K>>S;
  if(S[K-1]=='A'){
    S[K-1]='a';
  }
  else if(S[K-1]=='B'){
    S[K-1]='b';
  }
  else{
    S[K-1]='c';
  }
  cout<<S<<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define mod 1000000007
#define ll long long
#define PI acos(-1)
#define mp make_pair
#define mod 1000000007
int main()
{
	int a,b;
	cin>>a>>b;
	int ans=a*b-a-b+1;
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int M = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         LinkedList<Integer>[] edges = new LinkedList[N+1];
         for(int i=1; i <= N; i++)
            edges[i] = new LinkedList<Integer>();
         for(int i=0; i < M; i++)
         {
            st = new StringTokenizer(infile.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            edges[a].add(b);
            edges[b].add(a);
         }
         int res = 0;
         for(int i=1; i <= N; i++)
         {
            boolean tag = true;
            for(int next: edges[i])
               if(arr[i-1] <= arr[next-1])
                  tag = false;
            if(tag)res++;
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 67284
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<iomanip>
#include<cassert>
#include<functional>
typedef long long ll;

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

	std::string str;
	int count = 0;

	std::cin >> str;
	for (int i = 0; i < str.length(); i++){
		if (str[i] == '2'){
			count++;
		}
	}

	std::cout << count << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int ans[10005];
signed main(){
	int N;
	cin>>N;
	REP(i,101)REP(j,101)REP(k,101){
		int n=i*i+j*j+k*k+i*j+i*k+j*k;
		if(n<=10000)ans[n]++;
	}
	REP(i,N+1){
		cout<<ans[i]<<"\n";
	}
}


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

const int sz=524288;
int seg[sz*2];

int sum(int l,int r,int node=1,int nodel=0,int noder=sz-1) {
    if (r<nodel||l>noder) {
        return 0;
    }
    if (l<=nodel&&noder<=r) {
        return seg[node];
    }
    int mid=(nodel+noder)/2;
    return max(sum(l,r,node*2,nodel,mid),sum(l,r,node*2+1,mid+1,noder));
}

void update(int i,int val) {
    i+=sz;
    seg[i]=max(seg[i],val);
    while (i>1) {
        i/=2;
        seg[i]=max(seg[i*2],seg[i*2+1]);
    }
}

int main(void) {
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++) {
        int x;
        scanf("%d",&x);
        update(x,sum(max(0,x-k),min(x+k,sz-1))+1);
    }
    printf("%d",sum(0,sz-1));
}

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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

vector<int> adj[100005];
bool vis[100005];
int dis[100005];

int rec(int node){
	int ans = 2;
	rep(i,0,adj[node].size()){
		int to=adj[node][i];
		if(vis[to]){
			if(dis[to] == dis[node])
				ans=1;
			continue;
		}
		vis[to]=1;
		dis[to]=1-dis[node];
		if(rec(to) == 1)
			ans=1;
		
	}
	return ans;
}

int main(){
	int N, M;
	scanf("%d%d", &N, &M);
	rep(i,0,M){
		int a, b;
		scanf("%d%d", &a, &b);
		--a;--b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	ll s=0, d=0, l=0;
	rep(i,0,N){
		if(vis[i])
			continue;
		int type = rec(i);
		if(adj[i].size() == 0)
			type = 0;
		if(type == 0)
			++l;
		else if(type == 1)
			++s;
		else
			++d;
	}
	ll ans = 2*l*N-l*l;
	ans += s*s+2*s*d+2*d*d;
	cout << ans << endl;
}

Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	string n;
	char c;
	int cnt=0;
	int max=0;
	
	cin>>n;
	c=n[0];
	cnt++;
	max++;
	for(int i=1;i<4;i++)
	{
		if(c==n[i])
		{
			cnt++;
		}else{
			c=n[i];
			if(max<cnt)
			{
				max=cnt;
			}
			cnt=1;
		}
	}
	if(max<cnt)
	{
		max=cnt;
	}
	if(max>2)
	{
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
using namespace std;

int main(){
	string s;
	int k;
	cin >> s;
	cin >> k;
	int len = s.size();

	int i;
	rep(i,len){
		if(s[i] == 'a') continue;
		int temp = 26 - (s[i] - 'a');
		if(temp <= k){
			k -= temp;
			s[i] = 'a';
		}
		if(k == 0)
			break;
	}

	k %= 26;
	while(k--){
		if(s[len-1] == 'z')
			s[len-1]='a';
		else
			s[len-1]++;
	}

	cout << s << endl;

	return 0;
}



Measured memory_bytes: 512
#include<iostream>
using namespace std;
  
int main(){
    int i;
    int A[10];
    for(i = 0; i < 10; i++){
        cin >> A[i];
    }
    int a = -1, b = -1, c = -1;
    for(i = 0; i < 10; i++){
		if(A[i] >= a){ c = b, b = a, a = A[i]; }
		else if(A[i] >= b){ c = b, b = A[i]; }
		else if(A[i] >= c){ c = A[i]; }
    }
    cout << a << endl;
    cout << b << endl;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3088
import collections
n = int(input())
a = list(map(int, input().split()))
if (n==1):
    print(0)
    exit()
for i in range(n):
    a[i] -= i+1
a.sort()
ans1 = 0
ans2 = 0
x = a[n//2]
y = a[n//2-1]
for i in range(n):
    ans1 += abs(a[i]-x)
    ans2 += abs(a[i]-y)
print(min(ans1,ans2))


Measured memory_bytes: 32320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
const ll mod = 1e9 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<char> d(k);
    rep(i, k) cin >> d[i];
    int ans = 0;
    while (true)
    {
    loop:
        string s = to_string(n);
        for (int i = 0; i < s.length(); i++)
        {
            for (int j = 0; j < k; j++)
            {
                if (s[i] == d[j])
                {
                    n++;
                    goto loop;
                }
            }
        }
        break;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    cout << N*M - N-M +1 << endl;
    return 0;
}

Measured memory_bytes: 3536
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>
#include<cmath>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N ;
   int t[N] ;
   int x[N] ;
   int y[N] ;

   REP(i,N){
    cin >> t[i] ;
    cin >> x[i] ;
    cin >> y[i] ;
   }
   REP(i,N){
    if(t[i] < (x[i]+y[i]) )
    {
      cout << "No" << endl ;
      return 0 ;
    }
    t[i] -= (x[i] + y[i]) ;
    if(t[i] == 0 || t[i] %2 ==0){
    }else{

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


   }

      cout << "Yes" << endl ;
  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}



Measured memory_bytes: 1408
// https://atcoder.jp/contests/abc148/tasks/abc148_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

bool fill_path(ll u, ll p, ll goal, VL& path, VVL& edge_list) {
  if (p >= 0 && edge_list[u].size() == 1 && u != goal) return false;

  path.push_back(u);
  if (u == goal) return true;

  bool exist = false;

  for (auto v : edge_list[u]) {
    if (v == p) continue;

    if (fill_path(v, u, goal, path, edge_list)) {
      exist = true;
      break;
    }
  }

  if (!exist) path.pop_back();

  return exist;
}

ll N, tU, aV;
VVL edge_list;
ll limit_v, ng_v;
// VL t_ds;
VL a_ds;

ll dfs(ll u, ll p) {
  ll res = a_ds[u] - 1;

  for (ll v : edge_list[u]) {
    if (v == ng_v || v == p) continue;

    ll _res = dfs(v, u);
    chmax(res, _res);
  }

  return res;
}

void fill_ds(ll u, ll p, ll cur_d, VL& ds) {
  chmin(ds[u], cur_d);

  for (ll v : edge_list[u]) {
    if (v == p) continue;
    fill_ds(v, u, cur_d + 1, ds);
  }
}

void solve() {
  cin >> N >> tU >> aV;
  tU--, aV--;

  if (tU == aV) drop(0);

  edge_list = VVL(N, VL(0));

  rep(i, N - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edge_list[a].push_back(b);
    edge_list[b].push_back(a);
  }

  // t_ds = VL(N, INF);
  a_ds = VL(N, INF);
  // fill_ds(tU, -1, 0, t_ds);
  fill_ds(aV, -1, 0, a_ds);

  VL path(0);
  fill_path(tU, -1, aV, path, edge_list);

  limit_v = path[path.size() / 2 - 1];
  ng_v = path[path.size() / 2];

  ll res = dfs(limit_v, -1);
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main() {
  int N;
  cin >> N;
  int X = N;
  int d = 8;
  int H = 0;
  int p = 100000000;
  for (int i = 0; i < d+1; i++){
    H += N/p;
    N -= (N/p)*p;
    p /= 10;
  }
  
  if (X%H==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN = 410;
const long long INF = 0x7f7f7f7f7f7f7f; 
int n, a[MAXN];
long long sum[MAXN], f[MAXN][MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			f[i][j] = INF;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),sum[i] = sum[i-1]+a[i], f[i][i]=0;
	for(int l=1;l<n;l++)
		for(int i=1,j=i+l;i<=n&&j<=n;i++,j=i+l)
			for(int k=i;k<j;k++)
				f[i][j] = min(f[i][j], f[i][k]+f[k+1][j]+sum[j]-sum[i-1]); 
	printf("%lld\n",f[1][n]);
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define LL long long

const int maxn=2e5+10;
int len,n;
LL A,B,a[maxn],pre[maxn],dp[maxn],Ans=1e18;

struct SegTree{
	LL mn[maxn<<2];
#define lc (nd<<1)
#define rc (nd<<1|1)
#define mid ((s+t)>>1)

	void init()
	{
		memset(mn,0x3f3f3f3f,sizeof(mn));
	}

	void check(int nd,int s,int t,int pos,LL val)
	{
		if (s==t)
		{
			mn[nd]=min(mn[nd],val);
			return;
		}
		if (pos<=mid) check(lc,s,mid,pos,val);
		else check(rc,mid+1,t,pos,val);
		mn[nd]=min(mn[lc],mn[rc]);
	}

	LL query(int nd,int s,int t,int l,int r)
	{
		if (l<=s&&t<=r) return mn[nd];
		LL Ans=1e18;
		if (l<=mid) Ans=min(Ans,query(lc,s,mid,l,r));
		if (r> mid) Ans=min(Ans,query(rc,mid+1,t,l,r));
		return Ans;
	}
#undef lc
#undef rc
#undef mid
}S1,S2;

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i;
	scanf("%d%d%lld%lld",&len,&n,&A,&B);
	for (i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for (i=2;i<=n;i++)
		pre[i]=abs(a[i]-a[i-1]);
	for (i=2;i<=n;i++)
		pre[i]+=pre[i-1];
	S1.init();
	S2.init();
	for (i=2;i<=n;i++)
	{
		dp[i]=min(abs(a[1]-A)+pre[i-1]+abs(a[i]-B),abs(a[1]-B)+pre[i-1]+abs(a[i]-A));
//		a[j-1]<=a[i] : dp[j]-pre[j]-a[j-1]+pre[i-1]+a[i]
//		a[j-1]>=a[i] : dp[j]-pre[j]+a[j-1]+pre[i-1]-a[i]
		dp[i]=min(dp[i],S1.query(1,1,len,1,a[i])+pre[i-1]+a[i]);
		dp[i]=min(dp[i],S2.query(1,1,len,a[i],len)+pre[i-1]-a[i]);
		S1.check(1,1,len,a[i-1],dp[i]-pre[i]-a[i-1]);
		S2.check(1,1,len,a[i-1],dp[i]-pre[i]+a[i-1]);
		Ans=min(Ans,dp[i]+pre[n]-pre[i]);
	}
	printf("%lld\n",Ans);
}


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

import math

r,g,b,n = map(int,input().split())

ans = 0
for i in range(math.ceil(n / r)+1):
    for j in range(math.ceil(n / g)+1):
        if (n - r * i - g * j) % b == 0 and (n - r * i - g * j) >= 0:
            ans += 1

print(ans)


Measured memory_bytes: 40560
import numpy as np
N, K = map(int, input().split())

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

cnt = 0
sum_ans = K
while True:
    if sum_ans >= N:
        cnt += 1
        break
    else:
        sum_ans += K-1
        cnt += 1

print(cnt)

Measured memory_bytes: 23396
#!/usr/local/gnu/bin/bash
function frac(){
    readonly mul=100000000
    readonly mullen=${#mul}
    a=$1
    b=$2
    tmp=`printf "%0${mullen}d" $((a*mul/b))`
    tmplen=${#tmp}
    ilen=$((tmplen-(mullen-1)))
    flen=$((mullen-1))
    echo ${tmp:0:$ilen}.${tmp: -$flen}
}

read t x
frac $t $x


Measured memory_bytes: 632
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N,A; cin >> N >> A;
  ll T=A-N;
  cout << T*(T+1)/2-A << endl;
}

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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 2e5 + 5;
int n, k, t, sum;
ll res;
int temp[N];

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

  cin >> n >> k;
  unordered_map<int, int> ma;
  ma[0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (i >= k) {
      --ma[temp[i - k]];
    }
    cin >> t;
    sum = (sum + t - 1) % k;
    temp[i] = sum;
    if (ma.count(sum))
      res += ma[sum];
    ++ma[sum];
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 9288
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 30010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int last[MAXN][10];
string S;

int ok(int a, int b, int c){
	int tmp=last[n][c]-1;
	if (tmp<0) return 0;
	tmp=last[tmp][b]-1;
	if (tmp<0) return 0;
	tmp=last[tmp][a]-1;
	if (tmp<0) return 0;
	
	return 1;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>S;
	S="."+S;
	for (int i=1; i<=n; i++){
		for (int j=0; j<10; j++) last[i][j]=last[i-1][j];
		last[i][S[i]-'0']=i;
	}
	for (int a=0; a<10; a++) for (int b=0; b<10; b++) for (int c=0; c<10; c++) ans+=ok(a, b, c);
	cout<<ans<<'\n';
	
	
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <queue>
#include <string.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n;
map<string,int>mm;
string s;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s;
        mm[s]++;
    }
    int mx=-1;
    for(auto x:mm){
        mx=max(mx,x.S);
    }
    for(auto x:mm){
        if(x.S==mx)cout<<x.F<<endl;
    }
    return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
int main(void){
    boost::multiprecision::cpp_int a,sum=1;
    std::deque<boost::multiprecision::cpp_int> deq;
    int n;
    cin>>n;
    int flag=0;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end());
    for (int j=0;j<n;j++) {
        sum*=deq[j];
        if (sum>1000000000000000000) {
            flag=1;
            break;
        }
    }
    if (flag==1) {
        cout<<-1<<endl;
    } else {
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 7024
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..


int main(void) {
  int n;
  cin >> n;

  int num = n / 100;

  if (n % 100 <= num * 5) cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [[1, int(i)] for i in input().split()]
BC = A + [[int(i) for i in input().split()] for _ in range(M)]

BC.sort(key=lambda x: x[1], reverse=True)

i = 0
res = 0

for B, C in BC :
    if i + B <= N :
        res += C * B
        i += B
    else :
        res += C * (N - i)
        break

print(res)


Measured memory_bytes: 39544
#include <stdio.h>

int f[45];

int fibo(int n){
	if(n==0||n==1){
		f[n] = 1;
		return 1;
	}
	else if(f[n]!=0){
		return f[n];
	}else{
		f[n] = fibo(n-1) + fibo(n-2);
		return f[n];
	}
}

int main(void){
	int n;
	scanf("%d",&n);
	printf("%d\n",fibo(n));
}


Measured memory_bytes: 2056
/**
*    author:  velengel
*    created: 08.05.2020 20:00:25
*    to run & test the code, type below command.
*    cptest abc000_a
**/

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

ll a, b, n;

ll ffunc(ll x){
  return floor(a * x / b) - a * floor(x / b);
}

ll search(ll left, ll right)
{
	for (int loop = 0; loop < 10000; ++loop){
		if (ffunc((left * 2 + right) / 3) > ffunc((left + right * 2) / 3)){
			right = (left + right * 2) / 3;
		} else {
			left = (left * 2 + right) / 3;
		}
	}
	return (right + left) /2;
}

// ll search(ll from, ll to) {
// 	for (;to - from > 1;) {
// 		int mid = (from + to) / 2;
// 		(ffunc(mid) - ffunc(mid - 1) > 0 ? from : to) = mid;
// 	}

// 	return from;
// }

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> a >> b >> n;
  cout << ffunc(search(-1,n+1)) << endl;
  return 0;
}

Measured memory_bytes: 3660
K, N = map(int, input().split())
A = list(map(int, input().split()))
K+=A[0] 
for i in range(len(A)-1):
    A[i]=A[i+1]-A[i]
A[len(A)-1]=K-A[len(A)-1]
print(sum(A)-max(A))

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

int main(){
    int a[3];

    for (int i = 0; i < 3; i++)
        cin >> a[i];
    sort(a, a + 3);
    cout << (a[1] - a[0]) + (a[2] - a[1]) << endl;
    
    return 0;
}

Measured memory_bytes: 256
//ll _(){
//    ll n,k;
//    cin >> n >> k;
//    return (k*1900+(n-k)*100)<<k;
//}
//
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
ll _(){
    ll n,k;
    cin >> n >> k;
    return (k*1900+(n-k)*100)<<k;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


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

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b(x) push_back(x)
#define m_p(x) make_pair(x,y)

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
vector<ll>v;

bool isP(ll n){
    bool f=true;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            f=false;
            break;
        }
    }
    return f;
}

int main(){
    _fastio
    ll x;
    cin>>x;

    for(ll i=x;;i++){
        if(isP(i)){
            cout<<i<<endl;
            break;
        }
    }



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<ll>d(n);
    rep(i,n)cin>>d[i];
    ll ans=0;
    rep(i,n-1){
        REP(j,i+1,n){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
}

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();
		int k = sc.nextInt();
		if(n % k == 0) {
			System.out.println(0);
		} else {
			System.out.println(1);
		}
	}
}


Measured memory_bytes: 23252
#include<algorithm>
#include<string>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

struct Data{
    llong w;
    llong p;
    double ka;
};

bool Cmp(struct Data &prev,struct Data &next){
    return prev.ka>next.ka;
}
 
 
int main(){
    int n,h,w;
    cin >> n >> h >> w;
    vi a(n),b(n);
    int count = 0;
    REP(i,n){
        cin >> a[i] >> b[i];
        if(a[i]>=h && b[i]>=w){
            count++;
        }
    }


    cout << count << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  std::string x;
  std::string y;
  std::string z;
  std::string aa;
  std::cin >> x;
  int a;
  int b;
  int c;
  int m = 0;
  a = x.size();
  b = (a - 1)/2;
  c = (a + 3)/2;
  std::reverse(x.begin(), x.end());
  y = x;
  std::reverse(x.begin(), x.end());
  if (x == y) {
	std::string substr = x.substr(0,b);
    z = substr;
    std::reverse(z.begin(), z.end());
    aa = z;
    std::reverse(z.begin(), z.end());
    if (z == aa) {
      m++;
    }
  }
  if (x == y) {
	std::string substr = x.substr(c-1);
    z = substr;
    std::reverse(z.begin(), z.end());
    aa = z;
    std::reverse(z.begin(), z.end());
    if (z == aa) {
      m++;
    }
  }
  if (m == 2) {
    std::cout << "Yes";
  } else {
    std::cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;

    for(int i=0;i<11;i++){
        if(i*1000>=N){
            cout<<i*1000-N<<endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3636