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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

ll mod;
const int maxn = 1e6 + 5;

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}


ll inv(ll x) {
    assert(x);
    return pw(x,mod-2);
}


int n;
vector<int> g[maxn];


ll dp[maxn];
ll ans[maxn];

map<int,ll> par[maxn];//child->stuff

void dfs0(int at, int p=-1) {
    ll &res = dp[at] = 1;
    for (int to: g[at]) {
	if (to == p) continue;
	dfs0(to, at);
	res=res*(1+dp[to])%mod;
    }

    ll prefix=1;
    vector<int> ch = g[at];
    for (int to: ch) {
	if (to == p) continue;
	par[at][to] = 1;
    }
    
    for (int to: ch) {
	if (to == p) continue;
	par[at][to]=par[at][to]*prefix%mod;
	prefix=prefix*(1+dp[to])%mod;
    }

    reverse(ch.begin(), ch.end());
    ll suffix=1;
    for (int to: ch) {
	if (to == p) continue;
	par[at][to]=par[at][to]*suffix%mod;
	suffix=suffix*(1+dp[to])%mod;
    }


   
}

// pass down parent stuff to children
void dfs2(int at, int p=-1) {
    if (p != -1) {
	for (int to: g[at]) {
	    if (to == p) continue;
	    par[at][to]=par[at][to]*(1+par[p][at])%mod;
	}
    }
    for (int to: g[at]) {
	if (to == p) continue;
	dfs2(to, at);
    }
}


void dfs(int at, int p=-1) {
    ans[at]=dp[at];
    if (p != -1) {
	ans[at]=ans[at]*(1+par[p][at])%mod;
    }
    
    for (int to: g[at]) {
	if (to == p) continue;
	dfs(to, at);
    }
}

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

    cin>>n>>mod;
    for (int i=0; i<n-1; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }


    dfs0(1);
    dfs2(1);
    dfs(1);

    for (int i=1; i<=n; i++) {
	cout<<ans[i]<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 101760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			//String tmp = br.readLine();
			int sum = 0;
			int firstIndex = -1;
			StringBuffer str = new StringBuffer();
			for(int i = 0; i < 8; i++){
				str.append(br.readLine());
			}
			//System.out.println(str);
			for(int i = 0; i < 64; i++){
				if(str.charAt(i) == '1'){
					sum += i;
					if(firstIndex < 0){
						firstIndex = i;
					}
				}
			}
			//System.out.println(sum);
			char type;
			if(sum == firstIndex*4 + 1 + 8 + 9){
				type = 'A';
			}
			else if(sum == firstIndex*4 + 8 + 16 + 24){
				type = 'B';
			}
			else if(sum == firstIndex*4 + 1 + 2 + 3){
				type = 'C';
			}
			else if(sum == firstIndex*4 + 7 + 8 + 15){
				type = 'D';
			}
			else if(sum == firstIndex*4 + 1 + 9 + 10){
				type = 'E';
			}
			else if(sum == firstIndex*4 + 8 + 9 + 17){
				type = 'F';
			}
			else {
				type = 'G';
			}
			
			System.out.println(type);
			String tmp = br.readLine();
			if(tmp == null){
				break;
			}
		}
	}

}

Measured memory_bytes: 24276
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Coffee
            var S = Console.ReadLine();

            if (S[2] == S[3] && S[4] == S[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
// https://atcoder.jp/contests/abc135/tasks/abc135_c

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main (int argc, char* argv[]) {
	long long n;
	cin >> n;
	vector<long long> cities(n + 1);
	for (long long i = 0; i < n + 1; i++) {
		cin >> cities[i];
	}
	vector<long long> savers(n);
	for (long long i = 0; i < n; i++) {
		cin >> savers[i];
	}
	long long total = 0;
	for (long long i = 0; i < n; i++) {
		long long reduction = min(cities[i], savers[i]);
		cities[i] -= reduction;
		savers[i] -= reduction;
		total += reduction;

		reduction = min(cities[i + 1], savers[i]);
		cities[i + 1] -= reduction;
		savers[i] -= reduction;
		total += reduction;
	}
	cout << total << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n,a;
string s;
char c;
int main()
{
    cin >> n >> s;
    for(int i=0;i<s.length();i++){
        if(static_cast<char>(s[i] + n)<'A'||static_cast<char>(s[i] + n)>'Z') cout << static_cast<char>(s[i] -26+ n);
       else cout << static_cast<char>(s[i] + n);
    }
    return 0;
}


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

void solve()
{
    int k,n;
    cin>>n>>k;
    int price[n];
    FOR(i,n) cin>>price[i];
    sort(price,price+n);
    int sum=0;
    FOR(i,k) sum+=price[i];
    cout<<sum<<endl;
}


int main()
{
    solve();
}


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

int main() {
	int A, B, C, K;
	bool flag = false;
	cin >> A >> B >> C >> K;

	for (int i = 0; i <= K; i++)
		for (int j = 0; j <= K; j++)
			for (int k = 0; k <= K; k++) {
				int x = A * (1 << i), y = B * (1 << j), z = C * (1 << k);
				if (i + j + k <= K && x < y && y < z) flag = true;
			}

	if (flag == true) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    double h, a;
    cin >> h >> a;
    cout << ceil(h/a) << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int N, M, Q;
int A[50], B[50], C[50], D[50];

int DFS(vector<int>& Array)
{
    if (Array.size() == N) {
        int Ret = 0;
        for (int q = 0; q < Q; ++q) {
            if (Array[B[q]-1] - Array[A[q]-1] == C[q]) {
                Ret += D[q];
            }
        }
        return Ret;
    } else {
        int i = Array.empty() ? 1 : Array.back();
        int Max = 0;
        for (; i <= M; ++i) {
            Array.push_back(i);
            Max = max(Max, DFS(Array));
            Array.pop_back();
        }
        return Max;
    }
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> N >> M >> Q;
    for (int n = 0; n < Q; ++n) {
        cin >> A[n] >> B[n] >> C[n] >> D[n];
    }
    
    vector<int> Array;
    cout << DFS(Array) << endl;

    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int
main()
{
  int N; cin >> N;
  vector<ll> arr(N);
  rep(i, 0, N) cin >> arr[i];
  ll ans = 0;

  for(int i = 0; i < 60; i++){
    ll one = 0;
    ll zero = 0;
    rep(k, 0, N){
      if((arr[k] & (1LL << i))) ++one;
      else ++zero;
    }
    ll add = (one * zero) % MOD;
    repe(k, 1, i){
      add = (add * 2) % MOD;
    }
    //ll add = ((one * zero) * ((ll)pow(2, i)) % MOD) % MOD;
    ans += add;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5608
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    cnt = 0

    for a in range(1, x // 3):
        for b in range(a + 1, x // 2):
            c = x - a - b
            if b < c <= n:
                cnt += 1

    print(cnt)

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

string s;

bool palin(int a, int b) {
	while (a < b) {
		if (s[a] != s[b]) return false;
		a++;
		b--;
	}
	return true;
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	cin >> s;
	int n = s.length();
	if (palin(0, n-1) && palin(0, (n-1)/2 - 1) && palin((n+3)/2 - 1, n-1))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var s = Console.ReadLine();
    var t = Console.ReadLine();
    bool aho = false;
    for(var i = 0;i < s.Length;i++){
      if(s[i] == t[i]){
        aho = true;
      } 
      else {
        Console.WriteLine("No");
        return;
      }
    }
    var nagasa = s.Length+1;
    if(aho = true&&t.Length == nagasa){Console.WriteLine("Yes");}
  }
}

Measured memory_bytes: 17372
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int D, N; cin >> D >> N;
  if (N==100) N++;
  int result = pow(100, D) * N;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

int run(istream& in, ostream& out) {
    ll N;
    in >> N;
    if (N % 10 == 7 || N/10%10 == 7 || N/100%10 ==7) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

#define MOD 998244353

long sum(long a, long b) { return (a + b) % MOD; }
long mult(long a, long b) { return (a * b) % MOD; }

long pow(long a, long b) {
    long res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mult(res, a);
        }
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

long inv(long a) {
    return pow(a, MOD - 2);
}

vector<long> fact_precalc(1, 1);
vector<long> inv_fact_precalc(1, 1);

void ensure_fact(int n) {
    while (n >= fact_precalc.size()) {
        fact_precalc.push_back(mult(fact_precalc.back(), fact_precalc.size()));
        inv_fact_precalc.push_back(inv(fact_precalc.back()));
    }
}

long fact(int n) {
    ensure_fact(n);
    return fact_precalc[n];
}

long inv_fact(int n) {
    ensure_fact(n);
    return inv_fact_precalc[n];
}

long calc_c(int n, int k) {
    long res = fact(n);
    res = mult(res, inv_fact(k));
    res = mult(res, inv_fact(n - k));
    return res;
}


int main() {
    std::ios::sync_with_stdio(false);

    long n, a, b, k;
    cin >> n >> a >> b >> k;

    long res = 0;
    for (int i = 0; i <= n; i++) {
        long da = a * i;
        long r = k - da;
        if (r >= 0 && r % b == 0 && r / b <= n) {
            int j = (int) (r / b);
            long q = mult(calc_c(n, i), calc_c(n, j));
            res = sum(res, q);
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 10336
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func is753(n int) bool {
	m := map[int]bool{}
	for n > 0 {
		m[n%10] = true
		n /= 10
	}
	return m[3] && m[5] && m[7]
}

func dfs(max, n int) int {
	if n > max {
		return 0
	}
	if is753(n) {
		return 1 + dfs(max, n*10+3) + dfs(max, n*10+5) + dfs(max, n*10+7)
	} else {
		return dfs(max, n*10+3) + dfs(max, n*10+5) + dfs(max, n*10+7)
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	puts(dfs(n, 0))
}


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

int main()
{
   int a,b,c,k;
   scanf("%d%d%d%d",&a,&b,&c,&k);
   int max=a;
   if(b>=max)
    max=b;
   if(c>=max)
     max=c;
   int i,sum=a+b+c;

        for(i=1;i<=k;i++)
       {
           sum=sum-max;
           max=max*2;
           sum=sum+max;
       }
       printf("%d",sum);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
namespace OoO
{
	const int N=105;
	int c[N];
	int n,L;
	bool check()
	{
		if(L==1 && n>2)return 0;
		if(n==1)return 0;
		if(c[L]==1)return 0;

		c[L]=0;
		int hl=L/2;
		for(int i=L-1;i>hl;i--)
			if(c[i]<2)return 0;
			else c[i]-=2;
		if(L%2==0){if(!c[hl])return 0;c[hl]--;}
		for(int i=1;i<=hl+(L%2);i++)
			if(c[i])return 0;
		return 1;
	}
	void solve()
	{
		scanf("%d",&n);
		for(int i=1,x;i<=n;i++)
			scanf("%d",&x),c[x]++;
		for(int i=n;i;i--)if(c[i]){L=i;break;}
		printf("%s\n",check()?"Possible":"Impossible");
	}
}
int main()
{
	OoO::solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int  LL;
typedef vector<int> ivec;
typedef vector<string> svec;

//int a[100010];
int main(){
	int n=0;
	LL ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
	    if(i%3!=0 && i%5!=0)ans+=i;
	}
	cout<<ans<<endl;
} 


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    map<int, int> mp;
    REP(i,N){
        cin >> p[i];
        mp[p[i]]++;
    }
    int ans = 0;
    int sa = INF;
    for(int i=-200;i<=200;i++){
        if(mp[i] > 0) continue;
        if(chmin(sa, abs(i - X))){
            ans = i;
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll dp[n+1];
  dp[0]=2;
  dp[1]=1;
  REP(i,2,n+1) dp[i]=dp[i-1]+dp[i-2];
  pr(dp[n]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> grid(h, vector<int>(w, 0));
    vector<string> f(h);
    rep(i,h) cin >> f[i];
    //よこ
    rep(i,h) {
        vector<int> seen(w, 0);
        rep(j,w) {
            if(f[i][j]=='#') continue;
            if(seen[j]) continue;
            int cnt = 0;
            while(j+cnt<w) {
                if(f[i][j+cnt]=='#') break;
                cnt++;
            }

            rep(k,cnt) {
                grid[i][j+k]+=cnt;
                seen[j+k] = 1;
            }
        }
     
    }
    //たて
    rep(i,w) {
        vector<int> seen(h, 0);
        rep(j,h) {
            if(f[j][i]=='#') continue;
            if(seen[j]) continue;
            int cnt = 0;
            while(j+cnt<h) {
                if(f[j+cnt][i]=='#')break;
                cnt++;
            }

            rep(k,cnt) {
                grid[j+k][i]+=cnt;
                seen[j+k] = 1;
            }
        }
     
    }
    int ans = 0;
    rep(i,h)rep(j,w){
        ans = max(ans, grid[i][j]);
    }
    cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 20096
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, K;
    string S;
    cin >> N >> K >> S;
    S[K-1] = S[K-1] + 'a' - 'A';
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string s, t; cin >> s >> t;

    int ans = 0;
    REP(k, 2) {
        string u;
        REP(i, s.size()) if (i % 2 == k) u += s[i];
        int idx = 0;
        REP(i, t.size()) {
            if (t[i] == u[idx] and ++idx == u.size()) break;
        }
        if (idx == u.size()) ans = 1;
    }
    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}



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

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; }
#define rep(i, n) for(int i = 0; i < n; i++)

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

const int INF = 1 << 29;
const ll LINF = 1LL << 60;

vector<vector<int> > G;

vector<int> dp;
int rec(int v)
{
	if (dp[v] != -1)  return dp[v];

	int res = 0;
	for (int nv : G[v]) {
		chmax(res, rec(nv) + 1);
	}
	return dp[v] = res;
}

int main()
{
	int n, m;
	cin >> n >> m;
	G.resize(n);
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		G[u].push_back(v);
	}

	dp.resize(n, -1);
	int ans = 0;
	rep(i, n) {
		ans = max(ans, rec(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 8192
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b;
	cout << a + b / 2 << "\n";
	
	std::cin >> e;
}

Measured memory_bytes: 256
D = int(input())
C = [*map(int, input().split())]
S = [[*map(int, input().split())] for _ in range(D)]

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

score = 0
t = 0
for d in range(D):
    print(1)


Measured memory_bytes: 9660
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,l[2000],a=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>l[i];
	sort(l,l+n);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++){
			long long k=j,r=n;
			while(r-k>1){
				long long m=(k+r)/2;
				if(l[m]<l[i]+l[j])
					k=m;
				else
					r=m;
			}
			a+=k-j;
		}
	cout<<a<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int w,h,n ;
    scanf ("%d%d%d",&w,&h,&n) ;
    int minx=0,miny=0,maxx=w,maxy=h ;
    for (int i=0; i<n; i++){
        int x,y,a ;
        scanf ("%d%d%d",&x,&y,&a) ;
        if (a==1){
            if(minx<x){
                minx=x;
            }
        } else if (a==2){
            if (maxx>x){
                maxx=x;
            }
        } else if (a==3){
            if (miny<y){
                miny=y;
            }
        } else {
            if (maxy>y){
                maxy=y;
            }
        }    
    }
    if ((maxx-minx)<=0 || (maxy-miny)<=0){
        printf ("0\n");
    } else {
        printf ("%d\n",(maxx-minx)*(maxy-miny));
    }
    return 0 ;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
			int n = Integer.parseInt(br.readLine());
			String[] s = br.readLine().split(" ");
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = Integer.parseInt(s[i]);
			}
			int cnt = 0;
			for (int i = 1; i < n; i++) {
				if (a[i - 1] == a[i]) {
					a[i] = (i < n - 1) ? (a[i - 1] + a[i + 1]) % 10000 + 1 : a[i]+1;
					cnt++;
				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
		}

	}

}


Measured memory_bytes: 21332
#include <iostream>
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=2e6+5;
int n;

ll dp[N], dp2[N];
ll fx(int x)    {
    if(x>n)    return 1;
    else if(x==n)   {
        return n;
    }
    ll ans=fx(x+1);
    for (int i=2; i<=n; i++) {
        ans+=fx(x+i+1)+n-1;
    }
    return ans;
    
}



int main() {
    scanf("%d",&n);
    int l,r;
    for (int i=n+1; i>=1; i--) {
        if(i>n)     dp[i]=1;
        else if(i==n)   dp[i]=n;
        else    {
            dp[i]=dp[i+1];
            dp[i]+=(1LL*(n-1)*(n-1))%mod;dp[i]%=mod;
            l=i+3;
            r=i+n+1;
//            cout<<i<<"  "<<l<<"  "<<r<<endl;
//            cout<<l<<"  : "<<r<<"  "<<dp[i]<<endl;
            if(r>n) {
                if(l<=n) {
                    dp[i]+=dp2[l]-dp2[n+1];dp[i]%=mod;
                    if(i==1)    {
//                        cout<<"woo: "<<dp2[l]<<"  "<<dp2[n+1]<<"  "<<dp[i]<<endl;
                    }
                    dp[i]+=r-n;
                    dp[i]%=mod;
                }
                else    {
                    dp[i]+=r-l+1;
                    dp[i]%=mod;

                }
                
            }
            else    {
                dp[i]=(dp2[l]-dp2[r+1]);dp[i]%=mod;

            }
            
        }
        dp2[i]=dp[i]+dp2[i+1];dp2[i]%=mod;

    }
    if(dp[1]<0) dp[1]+=mod;
    cout<<dp[1]<<endl;


    return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b;
    cin >> a >> b;
    if (a % 2 == 0 || b % 2 == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
import numpy as np
A=np.array([list(input()) for _ in range(N)])
B=np.array([list(input()) for _ in range(M)])
ans='No'
for i in range(N-M+1):
  for j in range(N-M+1):
    if (A[i:i+M,j:j+M]==B).all():
      ans='Yes'
      break
  else:continue
  break
    
    
print(ans)

Measured memory_bytes: 12452
<?php
fscanf(STDIN, "%d %d", $n, $k);
$h = explode(' ', trim(fgets(STDIN)));

$n = $n - $k;
if ($n > 0) {
    sort($h);
    for ($i = 0; $i < $n; $i++) { 
        $ans += $h[$i];
    }
    echo $ans;
} else {
    echo '0';
}

Measured memory_bytes: 23284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

struct UnionFind
{
    vector<int> par;

    UnionFind(int N) : par(N)
    {
        for (int i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> p(n+1);
    rep(i, n) cin >> p[i+1];
    UnionFind u(n+1);
    rep(i,m){
        int x, y;
        cin >> x >> y;
        u.unite(x, y);
    }
    int ans = 0;
    rep1(i, n+1)
    {
        if(i==p[i] || u.same(i,p[i])){
            ++ans;
            continue;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

long long n, k, p[5555], c[5555], ans;

int main(){
    n = read(), k = read(), ans = -0x7f7f7f7f;
    for (int i = 1; i <= n; i++)
        p[i] = read();
    for (int i = 1; i <= n; i++)
        c[i] = read();
    for (int i = 1; i <= n; i++){
        long long last = i, sum = 0, cnt = 0;
        for (int j = 1; j <= k; j++){
            sum += c[p[last]];
            ans = max(sum, ans);
            last = p[last];
            cnt++;
            if (last == i && sum <= 0) break;
            if (last == i){
                sum = (k / cnt - 1) * sum;
                ans = max(sum, ans);
                int k_k = k % cnt + cnt;
                while (k_k--){
                    sum += c[p[last]];
                    ans = max(sum, ans);
                    last = p[last];
                }
                break;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,ans = 1;
    cin >> n;
    int a[n];
    rep(i, n)cin >> a[i];
    qsort(a, n, sizeof(int), desc);
    nfor(i, 1, n){
        if (a[i - 1] > a[i]) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

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

  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());
  long long sum = 0;
 
  for (int i = k; i < n; ++i)
    sum += a[i];

  cout << sum << '\n';
}

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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long


	
void solve(){
	int n, k = 0, ans = 0;
	cin >> n;
	int a[n];
	for(int i = 0 ; i < n ; i++){
		cin >> a[i];	
	}
	sort(a, a + n, greater<int>());
	n -= 2;
	ans += a[k++];
	while(n){
		ans += a[k];
		n--;
		if(n > 0){
			ans += a[k++];
			n--;
		}
	}
	cout << ans;
}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int ans = 0;
  if(N % 2 == 0)ans = N / 2 - 1;
  else ans = (N - 1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var result = new int[N];
        for (int i = 0; i < N; i++)
        {
            result[A[i] - 1] = i + 1;
        }
        for (int i = 0; i < N - 1; i++)
        {
            Console.Write($"{result[i]} ");
        }
        Console.WriteLine(result[N - 1]);
    }
}


Measured memory_bytes: 28376
N = int(input())
A = list(map(int, input().split()))
 
# 各社員i(=1,...,N)についてそれぞれ、部下の人数を数えればよい
l = [0]*N
for i in A:
  l[i-1] += 1

for i in l:
  print(i) 

Measured memory_bytes: 32112
s = input()
a = ['R', 'U', 'D']
b = ['L', 'U', 'D']

for i in range(len(s)):
    if (i + 1) % 2 == 0:
        if s[i] not in b:
            print('No')
            exit(0)
    else:
        if s[i] not in a:
            print('No')
            exit(0)

print('Yes')


Measured memory_bytes: 40208
import java.util.*;

class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),k=s.nextInt();
		long[]a=new long[n+1];
		for(int i=1;i<=n;++i)
			a[i]=s.nextInt();
		Arrays.parallelPrefix(a,Long::sum);
		Map<Long,Long>m=new HashMap<>();
		for(long i:a)
			m.merge(i%k,1L,Long::sum);
		System.out.println(m.values().stream().mapToLong(i->i*(i-1)/2).sum());
	}
}

Measured memory_bytes: 59232
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 2e5;
int arr[N + 5];

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 0;i < n;i++) cin>>arr[i];
	for(int i = 0;i < n;i++) {
		if(arr[i] > i) {
			cout<<-1<<endl;
			return ;
		}
	}
	LL tot = 0;
	int red = 0;
	for(int i = n - 1;i >= 0;i--) {
		if(red > arr[i]) {
			cout<<-1<<endl;
			return ;
		}
		if(red != arr[i]) {
			tot += arr[i];
			red = arr[i];
		}
		red--;
	}
	cout<<tot<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 1152
# https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_a

M, D = gets.split.map(&:to_i)

ans = 0
for m in 1..M
    for d in 1..D
        d1 = (d%10) 
        d2 = (d/10) 
        if d1 >= 2 && d2 >= 2 && (d%10) * (d/10) == m
            ans += 1
        end
    end
end

puts ans

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main(void){
    int a=0;
    int b=0;
    int c=0;
    int d=0;

    int num=0;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    if(a>=b)num+=b;
    else num+=a;

    if(c>=d)num+=d;
    else num+=c;
    
    cout << num << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		int k = sc.nextInt();
		int x = sc.nextInt();

		int left = 0;
		int right = 0;

		if(1000000 < x+k-1){
			right = 1000000;
			left = 1000000-k;
		}else if (-1000000 > x-k+1){
			right = -1000000 + k ;
			left = -1000000;
		}else{
			right = x+k-1 ;
			left = x-k+1;			
		}
		

		for (int i = left; i <= right; i++) {
			System.out.println(i);
		}
	}
}


Measured memory_bytes: 22996
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
ll n,x,y;
int main(){
    in(n);in(x);in(y);
    if((y-x)%2==0){
        printf("%lld\n",(y-x)/2);
        return 0;
    }
    ll ans=min(y-1,n-x);
    ll ny=y-x;
    ll nx=1;
    ans=min(ans,(ny-nx)/2+x);
    nx=x+n-y+1;
    ny=n;
    ans=min(ans,(ny-nx)/2+n-y+1);
    cout<<ans<<endl;
    return 0;
}
//电风扇电风扇

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a,ll b){
	return a%b==0?b:gcd(b,a%b);
}
int main(){
	ll a,b,c,d,e;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	e=c*d/gcd(c,d);
	a--;
	printf("%lld\n",b-a-(b/d-a/d+b/c-a/c)-a/e+b/e);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,cnt,ans;
string s;
vector<int> v;
int f(int a){
    int t[5]={5,7,5,7,7};
    cnt=0;
    while(1){
        t[cnt]-=v[a];
        if(t[cnt]==0)cnt++;
        else if(t[cnt]<0)return 0;
        a++;
        if(cnt==5)return a+1;
    }
}
int main(void){
    while(1){
    cin>>n;
    v={};
    if(n==0)return 0;
    for(int i=0;i<n;i++){
        cin>>s;
        v.push_back(s.size());
    }
    for(int i=0;i<n;i++){
        ans=f(i);
        if(ans!=0){
            cout<<i+1<<endl;
            break;
        }
    }
    }
}



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

int main(){
	int a[5];
  	for(int i=0;i<5;i++){
    	cin>>a[i];
    }
  for(int i=0;i<5;i++){
  	if(a[i]==0){
    	cout<<i+1<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3540
#include <vector>
#include <iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> B(N - 1);
	for (auto &x : B) cin >> x;
	int sum = B[0] + B[N - 2];
	for (int i = 1; i < N - 1; i++) {
		sum += ((B[i - 1] < B[i]) ? B[i - 1] : B[i]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
moves = ((1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1))

def dfs(y, x):
  c[y][x] = 0

  for dy, dx in moves:
    ny = y + dy
    nx = x + dx 
    if 0 <= ny < h and 0 <= nx < w and c[ny][nx] == 1:
      dfs(ny, nx)

while True:
  w, h = map(int, input().split())
  if w == 0 and h == 0:
    break
  c = [list(map(int, input().split())) for _ in range(h)]
  ans = 0
  for i in range(h):
    for j in range(w):
      if c[i][j] == 1:
        dfs(i, j)
        ans += 1
  print(ans)
  



Measured memory_bytes: 7956
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[])
{

	string n;

	cin >> n;

	for(int i=0;i<n.length();i++){
		if(n[i]=='1'){
			cout << "9";
		}else{
			cout << "1";
		}
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            var num = int.Parse(Console.ReadLine());
            var input = Console.ReadLine();
            string[] strinputArray = input.Split(' ');
            int[] intinputArray = Array.ConvertAll<string, int>(strinputArray, delegate (string value) { return int.Parse(value); });
            int mh = intinputArray[0];
            int cnt = 1;

            for (int i = 1; i < num; i++)
            {
                if(mh <= intinputArray[i])
                {
                    cnt++;
                    mh = intinputArray[i];
                }
            }
            Console.WriteLine(cnt);
            Console.ReadLine();
        }
    }


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

ll n,m;
int mp[111111];
int tmp[111111];
int ans[111111];
vector<vector<int>> v(111111);

void seica(int a){
	queue<int> q;
	q.push(a);
	
	while(!q.empty()){
		int now = q.front();q.pop();
		REP(i,v[now].size()){
			int mel = v[now][i];
			ans[mel] = now + 1;
			tmp[mel]++;
			if(tmp[mel] == mp[mel])q.push(mel);
		}
	}
}

int main(){
	
	cin >> n >> m;
	REP(i,m+n-1){
		int a,b;cin >> a >> b;
		a--;b--;
		mp[b]++;
		v[a].PB(b);
	}
	
	REP(i,n)if(mp[i] == 0)seica(i);
		
	REP(i,n)cout << ans[i] << endl;
	
	return 0;
}


Measured memory_bytes: 7680
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/08/20 03:55:25
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/segtree.hpp>

using namespace std;
using ll = long long;

int op(int a, int b) {return max(a,b);}
int e() {return -1;}
using Rmq = atcoder::segtree<int, op, e>;

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

  int n,q; cin>>n>>q;
  vector<int> A(n); for (auto& a:A) cin>>a;
  Rmq rmq(A);
  while (q--) {
    int t; cin>>t;
    if (t == 1) {
      int x,v; cin>>x>>v; x--;
      rmq.set(x, v);
    } else if (t == 2) {
      int l,r; cin>>l>>r; l--;
      cout << rmq.prod(l, r) << endl;
    } else {
      int x,v; cin>>x>>v; x--;
      auto res = rmq.max_right(x, [v](int a) {
        return a < v;
      });
      cout << res + 1 << endl;
    }
  }

  return 0;
}


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

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

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			s[i] = '9';
		}
		else {
			s[i] = '1';
		}
	}
	
	cout << s << endl;
		
	return 0;
}

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

typedef long long ll;
using namespace std;

int main(int argc, char *argv[])
{
	int N;
	pair<ll, ll> ab[200005];
	ll s = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		ll A, B;
		cin >> A >> B;
		s += A;
		ab[i] = make_pair(B, A);
	}

	sort(ab, ab + N);
	string ans = "Yes";
	for (int i = N - 1; i >= 0; i--) {
		if (ab[i].first >= s) {

		} else {
			ans = "No";
			break;
		}
		s -= ab[i].second;
	}

	cout << ans << endl;

	return 0;
}

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

#define all(vec)                vec.begin(),vec.end()
#define rall(vec)               vec.rbegin(),vec.rend()
#define sz(r)                    r.size()
#define rem1(v, i)             (v.erase(v.begin()+i))
#define rem2(v, i, j)          (v.erase(v.begin()+i, v.begin()+j+1))
#define rev(v, i, j)             (reverse(v.begin()+i, v.begin()+j+1))
#define digits(i)               (int)((log(i)/log(10))+1)
#define dround(num)       (int)floor(num+0.5)  // Rounds num to int (int)num+(<.5 to 0, > .5 to 1)
#define first_bit_index(num) __builtin_ctz(num) // count trailing zeros
#define last_bit_index(num)  __builtin_clz(num) // count leading zeros
#define UNDEFINED_BIT       32
#define test_bit(num, bit)   ((num & 1 << bit) != 0)
#define num_bits(num)       __builtin_popcount(num)
#define pb push_back
#define pf push_front
#define ins insert

#define inf   INT_MAX
#define mn_inf  INT_MIN
#define endl '\n'
using namespace std;
#define init ios_base::sync_with_stdio(false); cin.tie(nullptr);
typedef long long ll;

int main()
{
	init
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin);
	// //    freopen("output.txt", "w", stdout);
	// #endif
	int n; cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
	{
		int x;cin >> x;
		if(x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)){
			cout << "DENIED" <<"\n";
			return 0;
		}
	}
	cout << "APPROVED" <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define maxn 100005
#define LL long long
using namespace std;
int n,a[maxn];
int gcd(int a,int b)
{
	if(!b) return a;
	return gcd(b,a%b);
}
bool dfs(int a[])
{
	if(n==1) return false;
	int cnte=0,cnto=0,poso=-1;
	for(int i=1;i<=n;i++)
		if(a[i]%2) cnto++,poso=i;
		else cnte++;
	if(cnte%2) return true;
	else if(cnto>1) return false;
	else
	{
		if(a[poso]==1)
		{
			LL tmp=0;
			for(int i=1;i<=n;i++) tmp+=1ll*(a[i]-1);
			return tmp%2;
		}
		a[poso]--;
		int g=a[1];
		for(int i=2;i<=n;i++) g=gcd(g,a[i]);
		for(int i=1;i<=n;i++) a[i]/=g;
		return dfs(a)^1;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	printf("%s\n",dfs(a)?"First":"Second");
}

Measured memory_bytes: 512
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

H, W, N = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

hist = set()

count = defaultdict(int)
for dx, dy in itertools.product([0, 1, 2], repeat=2):
    for a, b in AB:
        count[(a + dx, b + dy)] += 1
ans = [0] * 10
for [a, b], cnt in count.items():
    if 3 <= a <= H and 3 <= b <= W:
        ans[cnt] += 1
print((H - 2) * (W - 2) - sum(ans[1:]))
print('\n'.join(map(str, ans[1:])))


Measured memory_bytes: 200832
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        double x[] = new double[100];
        double y[] = new double[100];
        double p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
 
        int N = scanner.nextInt();
 
        for(int i = 0; i < N; i++)x[i] = scanner.nextDouble();
        for(int i = 0; i < N; i++)y[i] = scanner.nextDouble();
 
        for(int i = 0; i < N; i++){
            p_1 += Math.abs(x[i]-y[i]);
            p_2 += (x[i]-y[i])*(x[i]-y[i]);
            p_3 += Math.abs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
            p_infinity = Math.max(p_infinity, Math.abs(x[i]-y[i]));
        }
 
        System.out.printf("%.10f\n", p_1);
        System.out.printf("%.10f\n", Math.sqrt(p_2));
        System.out.printf("%.10f\n", Math.cbrt(p_3));
        System.out.printf("%.10f\n", p_infinity);
    }
}


Measured memory_bytes: 29236