akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

struct BIT
{
	int size;
	std::vector<int> data;
	BIT(int n) : data(n+1,0), size(n) {}
	void add(int i,int v) {
		i+=1;
		while(i<=size) {
			data[i]+=v;
			i += i&-i;
		}
	}
	int query(int l, int r) {
		// [l, r)
		int rv = 0;
		while(r>0) {
			rv+=data[r];
			r -= r&-r;
		}
		int lv = 0;
		while(l>0) {
			lv+=data[l];
			l -= l&-l;
		}
		return rv-lv;
	}
};

// requires <BIT>

int inversion_number(const std::vector<int>& a) {
	int n = a.size();
	std::vector<int> b = a;
	std::sort(all(b));
	std::vector<int> c(n);
	for(int i=0;i<n-1;i++) {
		c[i+1] = c[i];
		if(b[i+1]!=b[i]) c[i+1]++;
	}

	// reconstruct
	std::vector<int> d(n);
	for(int i=0;i<n;i++) {
		d[i] = c[std::lower_bound(all(b),a[i]) - b.begin()];
	}

	BIT bit(n);
	int count = 0;
	for(int i=0;i<n;i++) {
		count += bit.query(0,d[i]);
		bit.add(d[i],1);
	}

	return count;
}


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::vector<int> b = a;
	std::sort(all(b));
	std::vector<int> c(n+1,0);
	rep(i,n) c[i+1] = c[i] + b[i];
	int k = 0;
	int sum = 0;
	rep(i,n) sum+=a[i];
	int lastj = 0;
	rep(i,n) {
		if(a[i] <= k) {
			print(0);
			continue;
		}
		// x<=k are already dead
		int x = a[i];
		int j = std::upper_bound(all(b),x) - b.begin();
		int y = 0;
		y += c[j] - c[lastj] - (j-lastj)*k;
		y += (n-j)*(x-k);
		print(y);
		k = std::max(k,x);
		lastj = j;
	}
	return 0;
}


Measured memory_bytes: 3456
# !/usr/nbin/python3

"""
https://atcoder.jp/contests/abc152/tasks/abc152_a
AC or WA.
"""

def solve(n, m):
    if n == m: print("Yes")
    else: print("No")

if __name__ == "__main__":
    n, m = list(map(int, input().split()))

    solve(n, m)


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

const int Maxn = 600015;
const int nil = 300005;

char S[Maxn];
int slen;
int vals[Maxn];
bool cur;
char res[Maxn];
int st, en;

int main()
{
    scanf("%s", S); slen = strlen(S);
    int q; scanf("%d", &q);
    while (q--) {
        int t; scanf("%d", &t);
        if (t == 1) cur ^= true;
        else {
            int f; char ch; scanf("%d %c", &f, &ch);
            bool my = f == 1;
            S[slen] = ch; vals[slen] = (my ^ cur);
            slen++;
        }
    }
    st = en = nil;
    for (int i = 0; i < slen; i++)
        if (vals[i] ^ cur) res[--st] = S[i];
        else res[en++] = S[i];
    res[en] = '\0';
    printf("%s\n", res + st);
    return 0;
}


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

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		str = br.readLine().split(" ");
		int[] a = new int[n];
		for(int i = 0; i < n; i++) a[i] = Integer.parseInt(str[i]);
		int[] b = prev_permutation(a);
		if(a != b) printArray(b);
		printArray(a);
		b = next_permutation(a);
		if(a != b) printArray(b);
	}
	public static void printArray(int[] a){
		for(int i = 0; i < a.length; i++){
			System.out.print(a[i]);
			if(i != a.length - 1) System.out.print(" ");
		}
		System.out.print("\n");
	}
	public static int[] next_permutation(int[] a){
		int[] ret = new int[a.length];
		int front = -1, rear = -1;
		for(int i = 0; i < a.length; i++){
			for(int j = i + 1; j < a.length; j++){
				if(a[i] < a[j]){
					front = i;
					rear = j;
				}
			}
		}
		if(front == -1) return a;
		for(int i = 0; i < a.length; i++){
			if(i == front) ret[i] = a[rear];
			else if(i == rear) ret[i] = a[front];
			else ret[i] = a[i];
		}
		Arrays.sort(ret, front + 1, a.length);
		return ret;
	}
	public static int[] prev_permutation(int[] a){
		int[] ret = new int[a.length];
		int front = -1, rear = -1;
		for(int i = 0; i < a.length; i++){
			for(int j = i + 1; j < a.length; j++){
				if(a[i] > a[j]){
					front = i;
					rear = j;
				}
			}
		}
		if(front == -1) return a;
		for(int i = 0; i < a.length; i++){
			if(i == front) ret[i] = a[rear];
			else if(i == rear) ret[i] = a[front];
			else ret[i] = a[i];
		}
		Arrays.sort(ret, front + 1, a.length);
		for(int i = 0; i < (a.length - front) / 2; i++){
			int bf = ret[front + 1 + i];
			ret[front + 1 + i] = ret[a.length - i - 1];
			ret[a.length - i - 1] = bf;
		}
		return ret;
	}
}



Measured memory_bytes: 26368
#include <bits/stdc++.h>
using namespace std;
#define M0D 1000000007

int main(){

  int N,ans=0;
  bool lef,rit,mid;
  string S;
  cin >> N;
  cin >> S;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      for(int k=0; k<10; k++){
        lef=false; mid=false; rit=false;
        for(int m=0; m<N; m++){
          if((S[m]-'0')==i && !lef) lef=true, m++;
          if((S[m]-'0')==j && lef && !mid) mid=true, m++;
          if((S[m]-'0')==k && lef && mid && !rit) rit=true;
        }
        if(lef && mid && rit) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long int ll;
typedef vector<long long int> vi;

int main(){
	ll a, b, i = 0;
	char s[10] = {};
	while (cin >> a >> b){
		sprintf(s, "%d", a + b);
		cout << strlen(s) << "\n";
	}
	return 0;
}

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

#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) (v.begin(),v.end())
#define vi vector<int>

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n,m;
    cin >> n >> m;
    map<int,int> ac;
    map<int,int> wa;
    int w = 0, c = 0;
    ffor(i,m){
        int x;
        cin >> x;
        string s;
        cin >> s;
        if(ac[x] != 0) continue;
        if(s == "AC"){
            ac[x]++;
            ++c;
        }
        if(s == "WA"){
            if(ac[x] == 0){
                wa[x]++;
                ++w;
            }
        }
    }

    for(auto z : wa){
        if((z.second != 0) && (ac[z.first] == 0)){
            w -= z.second;
        }
    }
    cout << c << ' ' << w;
}

Measured memory_bytes: 6144
N, M = map(int, input().split())
roads = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    roads[a - 1].append(b - 1)
    roads[b - 1].append(a - 1)
for r in roads:
    print(len(r))

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, k;
  cin >> n >> k;
  if (k>(n-1)*(n-2)/2) {
    cout << -1 << endl;
    return 0;
  }
  cout << n*(n-1)/2 - k << endl;
  for (int i=1; i<=n; ++i) {
    for (int j=i+1; j<=n; ++j) {
      if (i>1 && k > 0) k--;
      else cout << i << " " << j << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int hrow, wrow;
    int h, w;
    
    int spot;
    
    scanf("%d %d", &hrow, &wrow);
    scanf("%d %d", &h, &w);
    
    spot = hrow * wrow;
    
    spot -= (hrow*w + wrow*h - h*w);
    
    printf("%d", spot);
}


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

using namespace std;

int main() {
	stack<int> s;
	while (int c = cin.peek()) {
		if (c == cin.eof()) break;
		if (c <= 32) break;

		if (c >= '0' && c <= '9') {
			int x;
			cin >> x;
			s.push(x);
		} else {
			char op;
			cin >> op;

			int y = s.top();
			s.pop();
			int x = s.top();
			s.pop();

			if (op == '+') {
				s.push(x + y);
			} else if (op == '-') {
				s.push(x - y);
			} else {
				s.push(x * y);
			}
		}

		cin.ignore();
	}

	cout << s.top() << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 100001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
int main()
{
    AKASH_PATEL;
    SVNIT_SURAT;
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1];
    return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>

int main()
{
    long long n, a, sum=0, min=1000000;
    double p = 3.1415;
    long long max = 1-1000001;

    scanf("%lld", &n);
    for (int i = 0; i<n; i++){
        scanf("%lld", &a);
        sum += a;
        if(a>max){
            max = a;
        }
        if(a<min){
            min = a;
        }
    }
    printf("%lld %lld %lld\n", min, max, sum);

        return 0;
}           


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

void solve () {
	int h, w, k;
	cin >> h >> w >> k;
	char c[h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < (1 << h); i++) {
		for (int j = 0; j < (1 << w); j++) {
			int cnt = 0;
			for (int u = 0; u < h; u++) {
				for (int v = 0; v < w; v++) {
					if (((1 << u) & i) || ((1 << v) & j)) 
						continue;
					if (c[u][v] == '#')
						cnt++;
				}
			}
			if (cnt == k) {
				ans++;
			}
		}
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
  #endif
	int t = 1;
	while (t--) {
		solve();
	}
 	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];

    bitset<30> b(K);
    ll ans = 0;
    for(int i=0; i<N; i++){
        bool ok = true;
        for(int j=0; j<30; j++){
            if(!b[j] & (A[i]>>j) & 1){
                ok = false; break;
            }
        }
        if(ok) ans += B[i];
    }
    // cout << ans << endl;

    for(int i=0; i<30; i++){
        if(!b[i]) continue;

        ll sum = 0;
        for(int j=0; j<N; j++){
            bool ok = !((A[j]>>i) & 1);
            for(int k=i+1; k<30; k++){
                if(!b[k] & (A[j]>>k) & 1){
                    // cout << "\t" << i << " " << j << " " << k << endl;
                    ok = false; break;
                }
            }
            if(ok) sum += B[j];
        }
        // cout << i << " " << sum << endl;

        ans = max(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;
 	
 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;
 
	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;
 
	    	return this.s-p.s;
	    }
 	}
 // 	class Sort implements Comparator<String> 
	// { 
	//     public int compare(String a, String b) 
	//     { 
	//     	return (a+b).compareTo(b+a);
	//     } 
	// }
 
	String ns() {
        while (st == null || !st.hasMoreElements()) {
 
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }
 
    int nextInt() {
        return Integer.parseInt(ns());
    }
 
    long nextLong() {
        return Long.parseLong(ns());
    }
 
    double nextDouble() {
        return Double.parseDouble(ns());
    }
	
	int upperBound(long a[],long key)
	{
		int l=0,r=a.length-1;
		int i=-1;
 
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid]<key)
				l=mid+1;
 
			else{
				i=mid;	
				r=mid-1;
			}
			
		}
		return i;
	}
	int lowerBound(Pair[] a , long key)
	{
		int l = 0, r = a.length- 1;
		int i = -1;
 	
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid].f<key)
			{
				i=mid;
				l=mid+1;	
			}
 
			else
				r=mid-1;
			
		}
		return i;
	}
 
	long power(long x,long y)
	{
	    long ans=1;
	    
	    while(y!=0)
	    {
	        if(y%2==1) ans=(ans*x)%mod;
	        x=(x*x)%mod;
	        y/=2;
	    }
	    return ans%mod;
	}
	
 
	int mod= 1000000007;
	long gcd(long x ,long y)
	{
		if(y==0)
			return x;
		return gcd(y,x%y);
	}
 
	// ArrayList a[];
	// int vis[],cnt=0;
	// void dfs(int ver)
	// {
	// 	ArrayList<Integer> l=a[ver];
	// 	if(l.size()==1)
	// 		cnt++;
	// 	for(int v:l)
	// 	{
	// 		if(vis[v]==0){
	// 			vis[v]=vis[ver]+1;
	// 			dfs(v);
	// 		}
	// 	}
	// }
 
 	int countSetBits(long n) 
    { 
        int count = 0; 
        while (n > 0) { 
            n &= (n - 1); 
            count++; 
        } 
        return count; 
    }

	void solve() throws IOException{
		int n = nextInt();
		int a[] = new int[n];
		long dp[] = new long[n];
		
		for(int i = 0; i < n; i++)
			a[i] = nextInt();
		dp[1] = Math.abs(a[1] - a[0]);
		for(int i = 2; i < n; i++)	
			dp[i] = Math.min(dp[i - 1] + Math.abs(a[i] - a[i - 1]), dp[i - 2] + Math.abs(a[i] - a[i - 2]));
		
		out.println(dp[n -1]);
	}
 	
    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
 
		out.close();
	}
 
	public static void main(String args[]) throws IOException {
		new Main().run();
	}
  
}


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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var sl = new List<string>();
            for (int i = 0; i < S.Length; i++)
            {
                sl.Add(S[i].ToString());
            }
            var s2 = new string[sl.Count];
            Array.Copy(sl.ToArray(), s2, sl.Count);
            s2 = s2.Reverse().ToArray();
            for (int i = 0; i < sl.Count; i++)
            {
                var aa = sl[i];
                var aa2 = s2[i];
                if (aa != aa2)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            var N = sl.Count;
            var a = sl.GetRange(0, ((N - 1)/ 2));
            var a2 = new string[a.Count];
            Array.Copy(a.ToArray(), a2, a.Count);
            a2 = a2.Reverse().ToArray();
            for (int i = 0; i < a.Count; i++)
            {
                var aa = a[i];
                var aa2 = a2[i];
                if (aa != aa2)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            var b = sl.GetRange(((N + 3) / 2) - 1, N - (((N + 3) / 2) - 1));
            var b2 = new string[b.Count];
            Array.Copy(b.ToArray(), b2, b.Count);
            b2 = b2.Reverse().ToArray();
            for (int i = 0; i < a.Count; i++)
            {
                var aa = b[i];
                var aa2 = b2[i];
                if (aa != aa2)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
            Console.ReadLine();
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
n, m, d = map(int, input().split())
# n2cnt = [[i, 1] for i in range(1, n + 1)]
# beauty = 0

# for _ in range(m - 1):
#     beauty *= 2

#     for i, cnt in n2cnt:
#         if i - d > 0:
#             beauty += cnt
#         if i + d <= n:
#             beauty += cnt

#     n2cnt = [[i, cnt * n] for i, cnt in n2cnt]

# print(beauty / sum([cnt for i, cnt in n2cnt]))
if d == 0:
    p = n
else:
    p = (n - d) * 2
q = n ** 2 - p
print((1 * p + 0 * q) / n**2 * (m - 1))


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a_sum = 0;
    vector<P> a(n);
    REP(i, n) {
        cin >> a[i].first;
        a_sum += a[i].first;
        a[i].second = i;
    }

    REP(i, n) a[i].first = abs(a[i].first * n - a_sum);
    sort(ALL(a));
    cout << a.front().second << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
int comp( const void *c1, const void *c2 );

int main(void){
    int n, h, a[100000]={0}, b[100000]={0}, i, amax, bmax, dmg, c;
    
    scanf("%d %d", &n, &h);
	for(i = 0; i < n; i++){
		scanf("%d %d", &a[i], &b[i]);
	}
    
    amax = 0; bmax = 0;
    for(i = 0; i < n; i++){
        if(a[amax] < a[i]) amax = i;
    }
    qsort(b, n, sizeof(int), comp);
    bmax = 0;
    dmg = 0;
    c = 0;
    while(h > dmg){
        if(a[amax] >= b[bmax] || bmax == n ){
            c += (h - dmg) / a[amax];
            if((h - dmg) % a[amax] > 0) c++;
            break;
        }else{
            dmg += b[bmax];
            c++;
            bmax++;
        }
    }
    printf("%d\n", c);
    
    return 0;
}

int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;
 
  if( tmp1 > tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 < tmp2 )  return  1;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct ve{
        int num;
        int parent_num;
        int degree;
        int depth;
        char type[128];
        int *child;
};

int n;

int calc_depth(struct ve *, int, int);

int main(){
        int p, i, j, id, k, l, m, root;
        char f;
        struct ve *T;

        scanf("%d", &n);

        T = malloc(n * sizeof(struct ve));

        for(i = 0 ; i < n ;i++){
                T[i].parent_num = -1;
        }

        for(i = 0 ; i < n ; i++){
                m = 0;
                scanf("%d", &id);
                T[id].num = id;
                scanf("%d", &T[id].degree);
                if(T[id].degree == 0){
                        strcpy(T[id].type, "leaf");
                        continue;
                }
                T[id].child = malloc(T[id].degree * sizeof(int));
                for(j = 0 ; j < T[id].degree ; j++){
                        scanf("%d", &p);
                        T[id].child[m] = p;
                        T[p].parent_num = id;
                        m++;
                }
        }

        for(i = 0 ; i < n ; i++){
                if(n == 1)strcpy(T[i].type, "root");
                if(T[i].degree == 0)continue;
                if(T[i].parent_num == -1){
                        strcpy(T[i].type, "root");
                        root = i;                               
                }else strcpy(T[i].type, "internal node");
        }

        for(i = 0 ; i < n ; i++){
                T[i].depth = calc_depth(T, root, i);
        }
        
        for(i = 0 ; i < n ; i++){
                printf("node %d: parent = %d, depth = %d, %s, [", T[i].num, T[i].parent_num, T[i].depth, T[i].type);
                for(j = 0 ; j < T[i].degree ; j++){
                        printf("%d", T[i].child[j]);
                        if(j + 1 < T[i].degree)printf(", ");
                }
                printf("]\n");
        }

        for(i = 0 ; i < n ; i++){
                if(T[i].degree == 0)continue;
                else free(T[i].child);
        }
        free(T);
        return 0;
}

int calc_depth(struct ve *T, int root, int id){
        if(strcmp(T[id].type, "root") == 0)return 0;
        else{
                return 1 + calc_depth(T, root, T[id].parent_num);
        }
}



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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (A >= K) return cout << K << "\n", 0;
  if (A + B >= K) return cout << A << "\n", 0;
  K -= A;
  K -= B;
  cout << A - K << "\n";
}

Measured memory_bytes: 3620
import Data.Char  -- digitToInt

bottommost :: [Int] -> Int
bottommost [x] = x
bottommost xs  = bottommost (nextline xs)

nextline :: [Int] -> [Int]
nextline [x] = []
nextline (x : y : xs) = ((x + y) `mod` 10) : nextline (y : xs)

main = do
  s <- getContents
  putStr . unlines . map (show . bottommost . map digitToInt) . lines $ s

Measured memory_bytes: 3480
n = int(input())
s = input()

#分ける、xとyで文字の種類リストを作る、数える

def word_count(word):
    member = []
    for w in word:
        if not(w in member):
            member.append(w)
    return member

max_word = 0
for i in range(1,n):
    cut_place = i #i = 1なら0が左
    x = s[:i]
    y = s[i:]
    curr_word = 0
    x_s = word_count(x)
    y_s = word_count(y)
    for j in x_s:
        if j in y_s:
            curr_word += 1
    if max_word < curr_word:
        max_word = curr_word

print(max_word)


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
bool IsPrime(int n)
{
	int s = floor(sqrt(n)+0.5);
	for(int i = 2;i<=s;i++)
		if(n%i==0)return false;
	return true;
}
const int maxn = 1000000;
bool ar[maxn];
int dp[maxn];
int main()
{
	for(int i = 2;i<=maxn;i++)
		if(IsPrime(i))ar[i] = true;
	for(int i = 1;i<=maxn;i++)
		if(ar[i])dp[i] = dp[i-1]+1;
		else dp[i] = dp[i-1];
	int n;
	while(cin >> n)
		cout << dp[n] <<endl;
	return 0;
}

Measured memory_bytes: 6048
n = int(input())
A = list(map(int, input().split()))
A.sort()
sumA = sum(A)

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

def f(A, s, res):
  if res[0]:
    return
  if s == 0:
    res[0] = True
    return
  for i, a in enumerate(A):
    if a > s:
      break
    f(A[i+1:], s-a, res)

for mi in m:
  res = [False]

  if mi <= sumA:
    f(A, mi, res)

  if res[0]:
    print("yes")
  else:
    print("no")

Measured memory_bytes: 7720
import sys;sys.setrecursionlimit(int(1e7))
from collections import deque

N = int(input())
ABC = [tuple(map(int,input().split())) for _ in range(N-1)]
Qn,K = map(int,input().split())
XY = [tuple(map(int,input().split())) for _ in range(Qn)]

tree = [[] for _ in range(N+1)]
for abc in ABC:
    tree[abc[0]].append((abc[1],abc[2]))
    tree[abc[1]].append((abc[0],abc[2]))

dist = [-1]*(N+1)
dist[K] = 0
Q = deque()
Q.append(K)
while len(Q):
    p = Q.popleft()
    for q,c in tree[p]:
        if dist[q] != -1: continue
        dist[q] = dist[p]+c
        Q.append(q)

for i in range(Qn):
    print(dist[XY[i][0]] + dist[XY[i][1]])

Measured memory_bytes: 65100
N, C = [int(_) for _ in input().split()]
STC = [[int(_) for _ in input().split()] for _ in range(N)]
ST = [[set(), set()] for _ in range(C)]
for s, t, c in STC:
    c -= 1  #0-indexed
    ST[c][0].add(s)
    ST[c][1].add(t)
    if t in ST[c][0]:
        ST[c][0].discard(t)
        ST[c][1].discard(t)
    if s in ST[c][1]:
        ST[c][0].discard(s)
        ST[c][1].discard(s)
D = {}
for i in range(C):
    for s in ST[i][0]:
        D[s - 0.5] = D.get(s - 0.5, 0) + 1
    for t in ST[i][1]:
        D[t] = D.get(t, 0) - 1
times = sorted(D.keys())
count = 0
ans = 0
for time in times:
    count += D[time]
    ans = max(ans, count)
print(ans)


Measured memory_bytes: 39960
import sys,queue,math,copy
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]
_LI = lambda : [int(x)-1 for x in input().split()]

while True:
    N,W,D = LI()
    if N==0 and W==0 and D==0: break

    q = [(W*D,W,D)]
    for _ in range(N):
        p,s = LI()
        r = q.pop(p-1)
        w = r[1]
        d = r[2]
        s = s % (2*(w+d))
        if s < w:
            np1 = (s*d,s,d)
            np2 = ((w-s)*d,w-s,d)
        elif s < w + d:
            s -= w
            np1 = (w*s,w,s)
            np2 = (w*(d-s),w,d-s)
        elif s < w*2 + d:
            s -= w+d
            np1 = (s*d,s,d)
            np2 = ((w-s)*d,w-s,d)
        else:
            s -= w*2 + d
            np1 = (w*s,w,s)
            np2 = (w*(d-s),w,d-s)
        if np1 > np2: np1,np2 = np2,np1
        q.append(np1)
        q.append(np2)

    ans = ''
    q.sort()
    for s,w,d in q:
        ans += str(s) + ' '
    print (ans.rstrip())


Measured memory_bytes: 7096
#include<stdio.h>

int a[101][101];
int r,c;

void p() {
  int i, j;
  for(i = 0; i < c+1; i++){
    for(j = 0; j <= r; j++){
      if (j) printf(" ");
      printf("%d",a[j][i]);
    }
    printf("\n");
  }
}

int main()
{
  int i,j;
  scanf("%d %d",&c,&r);
  for(i = 0; i < c; i++){
    for(j= 0; j < r; j++){
      scanf("%d",&a[j][i]);
    }
  }
  a[r][c]=0;
  for(i = 0; i < c; i++){
    a[r][i]=0;
    for(j = 0; j < r; j++){
      a[r][i] += a[j][i];
      a[r][c] += a[j][i];
    }
  }
  for(j = 0; j < r; j++){
    a[j][c]=0;
    for(i = 0; i < c; i++){
      a[j][c] += a[j][i];
    }
  }

  p();
  
  return 0;
}



Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#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--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int)



int inv_mod(int a, int m)
{
	int b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	int N;
	vector<int> A;
	cin >> N;
	REP(i, N) {
		int tmp;
		cin >> tmp;
		A.PSB(tmp);
	}
	A.PSB(0);

	LL c = 0;
	LL ans = 0;
	REP(i, N + 1) {
		if (A[i] == 0) {
			ans += LL(c / 2);
			c = 0;
		}
		else c += (LL)A[i];
	}
	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
long long mod=998244353;
long long power(long long a,long long b)
{
	return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;
}
long long inv[1111];
long long comb[1111][1111];
long long Pow[1111];
int main()
{
	long long M,N;
	int K;
	cin>>M>>N>>K;
	for(int i=1;i<=K;i++)
	{
		inv[i]=power(i,mod-2);
		Pow[i]=power(i,N);
	}
	comb[0][0]=1;
	for(int i=1;i<=K;i++)
	{
		comb[i][0]=1;
		for(int j=1;j<i;j++)
		{
			comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%mod;
		}
		comb[i][i]=1;
	}
	long long ans=power(M%mod,N);
	for(int i=1;i<K;i++)
	{
		long long MCi=1;
		for(int j=1;j<=i;j++)
		{
			MCi=(M-j+1)%mod*MCi%mod*inv[j]%mod;
		}
		long long sum=0;
		for(int j=1;j<=i;j++)
		{
			long now=comb[i][j]*Pow[j]%mod;
			if((i-j)%2==1)now=(mod-now)%mod;
			(sum+=now)%=mod;
		}
		(MCi*=sum)%=mod;
		long now=MCi;
		//if((K-i+1)%2==1)now=(mod-now)%mod;
		//cout<<now<<endl;
		(ans-=now)%=mod;
	}
	cout<<(ans+mod)%mod<<endl;
}



Measured memory_bytes: 10312
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=300+3;
const int p=1e9+7;

int dp[N][N][N];
int n,m,l,r,x,res;
vector<pii> V[N];

void Upd(int n,int x,int y,int val){
	for (pii A:V[n]){
		if (1+(A.fi<=x)+(A.fi<=y)!=A.se) return;
	}
	dp[n][x][y]=(dp[n][x][y]+val)%p;
}

int main(){
	n=IN(),m=IN();
	For(i,1,m+1){
		l=IN(),r=IN(),x=IN();
		V[r].pb(mp(l,x));
	}
	dp[0][0][0]=1;
	For(i,0,n) For(j,0,i+1) For(k,0,j+1)
		if (dp[i][j][k]){
			Upd(i+1,j,k,dp[i][j][k]);
			if (i) Upd(i+1,i,k,dp[i][j][k]);
			if (j) Upd(i+1,i,j,dp[i][j][k]);
		}
	For(i,0,n+1) For(j,0,i+1)
		if (dp[n][i][j]){
			int tmp=1+(i!=0)+(j!=0),coef;
			coef=(tmp==1?3:6);
			res=(res+1ll*coef*dp[n][i][j])%p;
		}
	printf("%d\n",res);
}

Measured memory_bytes: 106752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s, a, b, c, d;
  cin >> s;
  a = s / 100;
  b = s % 100;
  c = b / 10;
  d = b % 10;
  cout << a + c + d << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
s=defaultdict(lambda: 0)
l=list([input() for i in range(n)])
f='Yes'
i=-1
for v in l:
  s[v]+=1
  if s[v] >= 2:
    f='No'
  if i!=-1 and l[i][-1] != v[0]:
    f='No'
  i+=1
print(f)

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

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

int main()
{
	int n;
	cin>>n;
	ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll lcm=a[0];
    for(int i=1;i<n;i++){
    	ll b;
    	b = findGCD(lcm,a[i]);
        lcm= lcm/b*a[i];
    }
    cout<<lcm;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {

  int H,W;
  cin >> H >> W;

  vector<vector<char>> S(H,vector<char>(W));
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      cin >> S.at(i).at(j);
    }
  }

  int ans = 0;
  int dx[] = {1,-1,0,0},dy[] = {0,0,1,-1};

  for(int sy = 0;sy < H;sy++) {
    for(int sx = 0;sx < W;sx++) {
      if(S.at(sy).at(sx) == '#') continue;

          vector<vector<int>> dis(H,vector<int>(W,0));
          vector<vector<bool>> check(H,vector<bool>(W,true));
          queue<pair<int,int>> Q;
          Q.push(make_pair(sy,sx));
          check.at(sy).at(sx) = false;

          while(!Q.empty()) {
            pair<int,int> q = Q.front();
            Q.pop();

            for(int i = 0;i < 4;i++) {
              int Y = q.first + dy[i];
              int X = q.second + dx[i];
              if(Y < 0 || Y >= H) continue;
              if(X < 0 || X >= W) continue;
              if(S.at(Y).at(X) == '#') continue;
              if(check.at(Y).at(X)){
                dis.at(Y).at(X) = dis.at(q.first).at(q.second)+1;
                Q.push(make_pair(Y,X));
                check.at(Y).at(X) = false;
              }
            }

          }
          
          for(int i = 0;i < H;i++) {
            for(int j = 0;j < W;j++) {
              ans = max(ans,dis.at(i).at(j));
            }
          }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
#define db double
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
const int maxn=2e5+7;
int n,a[maxn],p[maxn],T[maxn],f[maxn];

char cc;ll ff;
template<typename T>void read(T& aa) {
	aa=0;ff=1; cc=getchar();
	while(cc!='-'&&(cc<'0'||cc>'9')) cc=getchar();
	if(cc=='-') ff=-1,cc=getchar();
	while(cc>='0'&&cc<='9') aa=aa*10+cc-'0',cc=getchar();
	aa*=ff;
}

bool is_cyclic(int a,int b,int c) {
	return (a<b&&b<c)||(b<c&&c<a)||(c<a&&a<b);
}

int main() {
	read(n);
	For(i,1,n) read(a[i]);
	For(i,1,n) p[a[i]]=i;
	Rep(i,n-1,1) {
		if(T[i+1]==0) {
			if(p[i]>p[i+1]) T[i]=1,f[i]=i+1;
		}
		else {
			if(is_cyclic(p[f[i+1]],p[i],p[i+1])) T[i]=T[i+1],f[i]=f[i+1];
			else T[i]=T[i+1]+1,f[i]=i+1;
		}
	}
	printf("%d\n",T[1]);
	return 0;
}


Measured memory_bytes: 3456
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

// A - Poor
// https://atcoder.jp/contests/abc155/tasks/abc155_a
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = Integer.parseInt(scanner.next());
        int B = Integer.parseInt(scanner.next());
        int C = Integer.parseInt(scanner.next());
        scanner.close();

        Set<Integer> set = new HashSet<>();
        set.add(A);
        set.add(B);
        set.add(C);

        System.out.println(set.size() == 2 ? "Yes" : "No");
    }
}


Measured memory_bytes: 22740
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#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>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;  cin >> n >> k;
    rep(i, n) {
      if (k + (i - 1) * (k - 1) >= n) {
        cout << i << '\n';
        return 0;
      }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	for (int i = 0;i < S.size();i++) {
		S[i] = (S[i] - 65 + N) % 26 + 65;
	}
	cout << S << endl;
}


Measured memory_bytes: 256
import math

n = int(input())
c = [[0]*2 for i in range(n) ]
a = [0] * n
p = math.pi
for i in range(n):
    c[i][0], c[i][1] = map(float, input().split())

def f(ax, ay, bx, by, cx, cy):
    vx = ax - cx
    vy = ay - cy
    wx = bx - cx
    wy = by - cy
    s = 1
    if vx * wy - vy * wx < 0: s = -1
    p = vx * wx + vy * wy
    q = ( vx * vx + vy * vy ) ** 0.5
    r = ( wx * wx + wy * wy ) ** 0.5
    t = p / (q * r)
    t = max(-1, min(1, t))
    t = (math.acos( t )) * s
    return t

for i in range(n):
    k = (i+1)%n
    tax = 0
    tin = 0
    for j in range(n):
        if j != i and j != k:
            t = f(c[k][0], c[k][1], c[j][0], c[j][1], c[i][0], c[i][1])
            tax = max(tax, t)
            tin = min(tin, t)
    if tax - tin < p:
        a[i] = (p - tax + tin) / (p * 2)

for i in range(n):
    print(round(a[i], 6))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll  long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int,int>

#define PI  3.14159265358979323846
const int  N=2e5+10;

void solve(){
	
	string s;
	  cin>>s;
	
	 if(s<="2019/04/30"){
		    cout<<"Heisei";		 
		 }
	
	else{
		  cout<<"TBD";
		}  
	}
	
	
 


int main(){
  cool;
   int t=1;
   while(t--)   
     solve(); 

  return 0; 
}



  


  


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    string str; cin >> str;
    str[k-1] = tolower(str[k-1]);
    cout << str << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define a_len 1000

int main(){
  int i,j,N,key,r;
  int A[a_len];

  scanf("%d",&N);

  for(r=0; r<N; r++){
    scanf("%d",&A[r]);
    printf("%d",A[r]);
    if(r != N-1){
	printf(" ");
      }
  }

  printf("\n");


  for(i=1; i<N; i++){
    key = A[i];
    j = i - 1;
    while(j>=0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;

    for(r=0; r<N; r++){
      printf("%d",A[r]);
      if(r != N-1){
	printf(" ");
      }
    }
    printf("\n");
    
  }

  return 0;
  
}



Measured memory_bytes: 2124
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        int n, m;
        cin >> n >> m;
        int h[n], f[200005];
        for(int i = 0; i < n; i++) {
            cin >> h[i];
            f[i] = 1;
        }

        for (int i = 0; i < m; i++) {
            int a, b;
            cin >> a >> b;
            a--;
            b--;
            if(h[a] <= h[b]) 
                f[a] = 0;
            if(h[b] <= h[a]) 
                f[b] = 0;
        }

        int ans = 0;
        for(int i = 0; i < n; i++) {
            if(f[i]) 
                ans++;
        }

        cout << ans << '\n';
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 5388
#define mod 1000000007
    char buf[30];sz;
    char out[10];osz=10;
    int N,K;
    long I[4<<17];
    main()
    {
    	read(0,buf,30);
    	for(;;)
    	{
    		char c=buf[sz++];
    		if(c<'0')break;
    		N=N*10+c-'0';
    	}
    	for(;;)
    	{
    		char c=buf[sz++];
    		if(c<'0')break;
    		K=K*10+c-'0';
    	}
    	long ans=0;
    	long x=1,y=1,r;
    	for(long i=1;i<=N&&i<=K+1;i++)
    	{
    		ans+=x*y%mod;
    		I[i]=r=i<2?1:(mod-mod/i)*I[mod%i]%mod;
    		x=x*(N-i+1)%mod*r%mod;
    		y=y*(N-i)%mod*r%mod;
    	}
    	ans%=mod;
    	do{
    		out[--osz]=ans%10+'0';
    	}while(ans/=10);
    	write(1,out+osz,10-osz);
    }

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, k;
llong a[200005];
llong s[200005];
map<llong, llong> mp;

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        s[i] = s[i - 1] + a[i];
        s[i] %= k;
    }
    
    llong ans = 0;
    mp[0] = 1;
    for (int i = 1; i <= n; i++) {
        if (i - k >= 0) {
            mp[(s[i - k] - (i - k) % k + k) % k]--;
        }

        //if (mp[(s[i] - i % k + k) % k]) cout << i << ':' << mp[(s[i] - i % k + k) % k] << endl;
        ans += mp[(s[i] - i % k + k) % k];
        mp[(s[i] - i % k + k) % k]++;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;

    int ans = 0;
    rep(i,3005){
      rep(j,3005){
        if(n - r*i - g*j < 0)
          continue;
        if((n - r*i -g*j) % b == 0)
          ans++;
      }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3644
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<math.h>
//#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define ull unsigned long long
#define INF 1e9
#define eps 1e-6
#define PI acos(-1.0)
#define M 10010
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int, int>P;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;

char s[maxn], t[maxn];
int cnt1[26],cnt2[26];
vector<int>g1,g2;

int main() {
	IOS;
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
	//a = 999999866000004473;
	//b = 999999822000007597;
    cin >> s >> t;
    int len = strlen(s);
    for(int i = 0; i < len ; ++i){
        cnt1[s[i]-'a']++;
        cnt2[t[i]-'a']++;
    }
    for(int i = 0 ;i < 26;++i){
        g1.push_back(cnt1[i]);
        g2.push_back(cnt2[i]);
    }
    sort(g1.begin(),g1.end());
    sort(g2.begin(),g2.end());
    for(int i = 0 ;i < 26 ;i++)
    if(g1[i]!=g2[i]){
        cout <<"No";
        return 0;
    }
    cout << "Yes" ;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
//const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

const ll MOD = 1e6 + 3;

ll binpow(ll a, ll p) {
    p %= MOD - 1;
    ll res = 1;
    while (p) {
        if (p & 1) {
            (res *= a) %= MOD;
        }
        (a *= a) %= MOD;
        p >>= 1;
    }
    return res;
}

ll f[MOD];
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    f[0] = 1;
    for (int i = 1; i < MOD; i++) {
        f[i] = f[i - 1] * i % MOD;
    }
    int q;
    cin >> q;
    while (q--) {
        ll x, d, n;
        cin >> x >> d >> n;
        if (x == 0) {
            cout << "0\n";
            continue;
        }
        if (d == 0) {
            cout << binpow(x, n) << '\n';
            continue;
        }
        ll p = binpow(d, MOD - 2);
        ll ans = binpow(d, n);
        x = x * p % MOD;
        if (x + n - 1 >= MOD) {
            cout << "0\n";
            continue;
        }
        cout << ans * f[x + n - 1] % MOD * binpow(f[x - 1], MOD - 2) % MOD << '\n';
    }
    return 0;
}



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

int main(){
  int s;
  int h, m;
  
  cin >> s;
  h = s / 3600;
  m = (s % 3600) / 60;
  s = s % 60;
  
  cout << h << ":" << m << ":" << s << endl;

  return 0;
}



Measured memory_bytes: 3120
n,m=map(int,input().split())
s=list(input())
s.reverse()
ansl=[]
now=0
while now<n:
    f=1
    for i in range(m,0,-1):
        if now+i<n+1 and s[now+i]=="0":
            ansl.append(i)
            now+=i
            f=0
            break
    if f:
        print(-1)
        exit()


ansl.reverse()
print(*ansl)


Measured memory_bytes: 54920
var
  a,f,g:array[0..100000]of longint;
  p1,p2,q1,q2:array[0..100000]of longint;
  i,j,n,ans,n1,n2:longint;
Procedure max(x:longint);
begin
  if x>ans then ans:=x;
end;
Procedure ch(var x,y:longint);
var
  t:longint;
begin
  t:=x;x:=y;y:=t;
end;
Procedure qs1(l,r:longint);
var
  i,j,mid:longint;
begin
  i:=l;j:=r;mid:=p1[(l+r)div 2];
  repeat
    while p1[i]>mid do inc(i);
    while p1[j]<mid do dec(j);
    if i<=j then
      begin
        ch(p1[i],p1[j]);
        ch(p2[i],p2[j]);
        inc(i);dec(j);
      end;
  until i>j;
  if l<j then qs1(l,j);
  if i<r then qs1(i,r);
end;
Procedure qs2(l,r:longint);
var
  i,j,mid:longint;
begin
  i:=l;j:=r;mid:=q1[(l+r)div 2];
  repeat
    while q1[i]>mid do inc(i);
    while q1[j]<mid do dec(j);
    if i<=j then
      begin
        ch(q1[i],q1[j]);
        ch(q2[i],q2[j]);
        inc(i);dec(j);
      end;
  until i>j;
  if l<j then qs2(l,j);
  if i<r then qs2(i,r);
end;
begin
  readln(n);
  for i:=1 to n do
    read(a[i]);
  for i:=1 to n do
    begin
      if i mod 2=1 then inc(f[a[i]]) else inc(g[a[i]]);
    end;
  for i:=0 to 100000 do
    begin
      if f[i]<>0 then
        begin
          inc(n1);
          p1[n1]:=f[i];
          p2[n1]:=i;
        end;
      if g[i]<>0 then
        begin
          inc(n2);
          q1[n2]:=g[i];
          q2[n2]:=i;
        end;
    end;
  qs1(1,n1);
  qs2(1,n2);
  for i:=1 to n1 do
    begin
      if p2[i]<>q2[1] then max(p1[i]+q1[1]) else max(p1[i]+q1[2]);
    end;
  write(n-ans);
end.

Measured memory_bytes: 2048