akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;

struct Node{
    string name;
    vector<int> edge,rev,eq;
};

std::vector<string> splitAll(string s,string t){
  std::vector<string> v;
  for(int p=0; (p = s.find(t)) != s.npos; ){
    v.push_back(s.substr(0,p));
    s=s.substr(p+t.size());
  }
  v.push_back(s);
  return v;
}

int dist[201][201];

void make_graph(vector<Node> &g) {
    for(int i=0; i<g.size(); ++i)
        for(int j=i+1; j<g.size(); ++j) {
            bool ok = false;
            for(int k=0; k<g.size(); ++k) {
                int c1 = count(g[i].edge.begin(), g[i].edge.end(), k);
                int c2 = count(g[i].rev.begin(), g[i].rev.end(), k);
                int d1 = count(g[j].edge.begin(), g[j].edge.end(), k);
                int d2 = count(g[j].rev.begin(), g[j].rev.end(), k);
                if((c1 > 0 && d2 > 0) || (c2 > 0 && d1 > 0)) goto NEXT;
                if((c1 > 0 && d1 > 0) || (c2 > 0 && d2 > 0)) ok = true;
            }
            if(ok) g[i].eq.push_back(j),g[j].eq.push_back(i);
        NEXT:;
        }

    for(int i=0; i<201; ++i) for(int j=0; j<201; ++j) dist[i][j] = 1<<29;
    for(int i=0; i<g.size(); ++i) dist[i][i] = 0;
    for(int i=0; i<g.size(); ++i) {
        for(int j=0; j<g[i].eq.size(); ++j)
            dist[i][g[i].eq[j]] = dist[g[i].eq[j]][i] = 0;
        for(int j=0; j<g[i].edge.size(); ++j)
            dist[i][g[i].edge[j]] = 1;
    }

    for(int k=0; k<g.size(); ++k)
        for(int i=0; i<g.size(); ++i)
            for(int j=0; j<g.size(); ++j)
                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
}

int main() {
    int n,m;
    string in;
    while(cin>>n) {
        if(n == 0) break;
        map<string, int> idx;
        vector<Node> g;
        for(int i=0; i<n; ++i) {
            cin>>in;
            vector<string> vs = splitAll(in, "-");
            string name1 = vs[0],name2 = vs[1];
            if(idx.find(name1) == idx.end()) {
                idx[name1] = g.size();
                Node no; no.name = name1;
                g.push_back(no);
            }
            if(idx.find(name2) == idx.end()) {
                idx[name2] = g.size();
                Node no; no.name = name2;
                g.push_back(no);
            }
            g[idx[name1]].edge.push_back(idx[name2]);
            g[idx[name2]].rev.push_back(idx[name1]);
        }

        make_graph(g);
        cout<<g.size()<<endl;
        // for(int i=0; i<g.size(); ++i)
        //     cout<<i<<" : "<<g[i].name<<endl;

        cin>>m;
        for(int i=0; i<m; ++i) {
            cin>>in;
            vector<string> vs = splitAll(in, "-");
            string name1 = vs[0], name2 = vs[1];
            if(idx.find(name1) == idx.end() || idx.find(name2) == idx.end()) {
                cout<<"NO"<<endl;
                continue;
            }

            if(dist[idx[name1]][idx[name2]] < 1<<29
               && dist[idx[name1]][idx[name2]]%2) {
                cout<<"YES"<<endl;
            }else{
                cout<<"NO"<<endl;
            }
        }
    }
}

Measured memory_bytes: 1152
#include<iostream>
int main(void){
  int H,W;
  std::cin >> H >> W;
  char space[H+2][W+2];
  for (int i=1;i<H+1;i++){
    for (int j=1;j<W+1;j++){
      std::cin >> space[i][j];
    }
  }
  for(int i=0;i<H+2;i++){
    for (int j=0; j<W+2;j++){
      if (i==0 || i == H+1 || j == 0 || j == W+1){
        space[i][j] = '#';
      }
    }
  }
  std::cout << std::endl;
  for (int i=0;i<H+2;i++){
    for (int j= 0;j<W+2;j++){
      std::cout << space[i][j];
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    if(n/100==n%10){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> a;
int main() {
  cin >> n; read_n(a, n);
  sort(begin(a), end(a));
  lli ans = 0, count = 1;
  for (lli i=1; i<n; ++i) {
    if (a[i] == a[i-1]) {
      ++count;
    } else {
      ans += count < a[i-1] ? count : count - a[i-1];
      count = 1;
    }
  }
  ans += count < a[n-1] ? count : count - a[n-1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int y=0;
  rep(i,n){
    int u;
    cin >> u;
    if(u-1==y){
      y++;
    }
  }
  if(y==0) cout << -1 << endl;
  else cout << n-y << endl;
}

Measured memory_bytes: 256
N = input()
if N[len(N) - 1] == '2' or N[len(N) - 1] == '4' or N[len(N) - 1] == '5' or N[len(N) - 1] == '7' or N[len(N) - 1] == '9':
    print('hon')
if N[len(N) - 1] == '0' or N[len(N) - 1] == '1' or N[len(N) - 1] == '6' or N[len(N) - 1] == '8':
    print('pon')
if N[len(N) - 1] == '3':
    print('bon')

Measured memory_bytes: 9076
#include <bits/stdc++.h>
    using namespace std;
    #define pb push_back
    #define mp make_pair
    #define mod 1000000007
    #define f(i,n) for(int i=0;i<(int)n;i++)
    #define Fre(i,a,b) for(int i = a; i < b; i++)
    #define sf(n) scanf("%d", &n)
    #define sff(a,b) scanf("%d %d", &a, &b)
    #define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
    #define pfn(n) printf("%d\n", n)
    #define pfs(n) printf("%d ", n)
    #define ff first
    #define ss second
    #define mem(a,b) memset(a,b,sizeof(a))
    #define READ freopen("in.txt", "r", stdin)
    #define WRITE freopen("out.txt", "w", stdout)
    #define sz size()
    #define number_of_digit(n) __builtin_ffs(n);
    #define ll long long
    #define T int
    #define ld long double
    #define endl "\n"

    bool sortbyf(const pair <int,int> a,const pair <int,int> b)
    {   
        if(a.ff==b.ff){
            return (a.ss<b.ss);
        }
        // return (a.ss< b.ss); 
        return (a.ff < b.ff);
    } 

    // int cnt;
    // bool sortbyabs(const pair <ll,ll> a, const pair <ll,ll> b){
    // // {   if(abs(a.ss)==abs(b.ss)){
    // //         return (abs(a.ff)<abs(b.ff));
    // //     }

    //     return (abs(abs(a.ss)-abs(a.ff)) > abs(abs(b.ss)-abs(b.ff))); 
    // } 


    
    
    int main(){   
        ios_base::sync_with_stdio(false); cin.tie(NULL);
        int n,k;
        cin>>n>>k;
        int a[n];
        f(i,n)cin>>a[i];
        ll dp[n];
        f(i,n)dp[i]=INT_MAX;
        dp[0]=0;

        for(int i=1;i<n;i++){
            ll m=INT_MAX;
            // dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
            for(int j=max(i-k, 0);j<i;j++){
                // if(j>=0;)
                m=min(m,dp[j]+abs(a[i]-a[j]));
            }
            dp[i]=m;

        }
        // f(i,n)
         cout<<dp[n-1];
    } 

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt();
        String s = obj.next();
        if(s.length()<=n) System.out.println(s);
        else
        {
            for(int i=0;i<n;i++)
            System.out.print(s.charAt(i));
            System.out.print("...");
        }
    }
}


Measured memory_bytes: 32732
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;
vector<int> ch[30];

int A[MAXN];
char S[MAXN];

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

	static ll dp[51][1251][51]={0};
	int n,K,h,i,j;cin>>n>>K;
	if(K%2){cout<<0<<endl;return 0;}
	dp[1][0][0]=1;
	dp[1][0][1]=1;
	for(h=1;h<n;h++){
		for(i=0;i<=h*h/2;i++){
			for(j=0;j<=h;j++){

				dp[h][i][j]%=MOD;
				if(j>0){dp[h+1][i+j][j-1]+=dp[h][i][j]*j*j;}
				dp[h+1][i+j][j]+=dp[h][i][j]*(1+j+j);
				dp[h+1][i+j][j+1]+=dp[h][i][j];
			}
		}
	}
	cout<<dp[n][K/2][0]%MOD<<endl;

	return 0;
}


Measured memory_bytes: 24576
// ABC 157-B
// 2020.3.1 bal4u

#include <stdio.h>

int A[3][3];
char f[3][3];

int main()
{
	int i, r, c, b, N;

	for (r = 0; r < 3; ++r) for (c = 0; c < 3; ++c) {
		scanf("%d", &A[r][c]);
	}
	scanf("%d", &N);
	for (i = 0; i < N; ++i) {
		scanf("%d", &b);
		for (r = 0; r < 3; ++r) for (c = 0; c < 3; ++c) {
			if (A[r][c] == b) { f[r][c] = 1; goto NEXT; }
		}
NEXT:;
	}
	for (r = 0; r < 3; ++r) {
		b = 0; for (c = 0; c < 3; ++c) b += f[r][c];
		if (b == 3) goto OK;
	}
	for (c = 0; c < 3; ++c) {
		b = 0; for (r = 0; r < 3; ++r) b += f[r][c];
		if (b == 3) goto OK;
	}
	b = 0; for (i = 0; i < 3; ++i) b += f[i][i];
	if (b == 3) goto OK;
	b = 0; for (i = 0; i < 3; ++i) b += f[i][2-i];
	if (b == 3) {
OK:		puts("Yes");
	} else puts("No");
	return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
sa = sum(a)
x1 = sa
for i in range((n-1)//2):
  x1 -= 2*a[2*i+1]
print(x1,end=" ")
nextx = x1
for i in range(n-1):
  nextx = 2*a[i] - nextx
  print(nextx,end=" ")
  

Measured memory_bytes: 14092
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    long long X, K, D;
    cin >> X >> K >> D;
    if(X < 0){
        X = -X;
    }
    if (X / D >= K)
    {
        cout << abs(X - K * D);
        return 0;
    }
    long long M = (long long)((K - (1.0*X) / (1.0*D)) / 2);
    long long A = 9223372036854775807;
    for (long long m = M - 10; m <= M + 10; m++)
    {
        if (m < 0 || m > K)
        {
            continue;
        }
        long long n = K - m;
        long long B = abs(X + (m - n) * D);
        if (B < A)
        {
            A = B;
        }
    }
    cout << abs(A);

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	double data,high=0,low=1000000;
	while(cin>>data){
		if(high<data){
			high=data;
		}
		if(low>data){
			low=data;
		}
	}
	printf("%.1lf\n",high-low);
}

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


int main(){
    ll  n, k;   cin >> n >> k;
    vector<ll> cnt(n+2, 0);

    ll mod = 1'000'000'007, sum=0;
    for(ll i=k; i<=n+1; i++){
        ll a = i*(i-1)/2;
        ll b = i*(2*n-i+1)/2;
        sum = (sum+b-a+1)%mod;
    }
    cout << sum << endl;

}

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

int main() {
  int H , W;
  cin >> H >> W;
  vector<string> M(H);
  for (int i = 0; i < H; i++) {
    cin >> M.at(i);
  }
  
  vector<bool> G(H,false) , R(W,false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (M.at(i).at(j) == '#') {
        G.at(i) = true;
        R.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (G.at(i)) {
      for (int j = 0; j < W; j++) {
        if (R.at(j)) {
          cout << M.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}


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

using namespace std;
using ll = long long;

const ll MOD = 998244353;

int main() {
  ll N, x, m{}, ans{1};
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i != N; ++i) {
    cin >> x;
    if ((!i && x) || (i && !x)) {
      cout << 0 << endl;
      return 0;
    }
    m = max(m,x);
    ++D[x];
  }

  for (int i = 1; i <= m; ++i) {
    if (!D[i]) {
      ans = 0;
      break;
    }
    for (int j = 0; j != D[i]; ++j) {
      ans = ans * D[i-1] % MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int r = 0, s = 0;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;

        r += d * s;
        s += d;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
red = []
n.times do |i|
  red[i] = gets.chomp.split.map(&:to_i)
end
blue = []
n.times do |i|
  blue[i] = gets.chomp.split.map(&:to_i)
end

red.sort!
blue.sort!

ans = 0
blue.each do |c, d|
  tmp = []
  red.size.times do |i|
    a, b = red[i]
    if a < c && b < d
      tmp.push([b, i])
    end
  end
  if !tmp.empty?
    ans += 1
    tmp.sort!.reverse!
    index = tmp.first[1]
    red.delete_at(index)
  end
end
p ans


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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=1e5+5,mod=1e9+7,bit=61;

int dp[2][N];
int a[101];
int n,k;

int solve(int who,int stones)
{
    if(stones < a[1])
    {
        return (who^1);
    }
    assert(stones >= 0);
    int &ans=dp[who][stones];
    if(ans!=-1)
    {
        return ans;
    }
    ans=who^1;
    for(int i=1;i<=n;i++)
    {
        if(stones < a[i])
        {
            continue;
        }
        if(solve(who^1,stones-a[i])==who)
        {
            ans=who;
            break;
        }
    }
    return ans;
}

signed main()
{
    fast;

    int t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n>>k;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        memset(dp,-1,sizeof(dp));
        if(solve(1,k))
        {
            cout<<"First"<<endl;
        }
        else
        {
            cout<<"Second"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 11404
// ooooo      ooo                     
// `888b.     `8'                     
//  8 `88b.    8   .ooooo.   .oooo.   
//  8   `88b.  8  d88' `88b `P  )88b  
//  8     `88b.8  888   888  .oP"888  
//  8       `888  888   888 d8(  888  
// o8o        `8  `Y8bod8P' `Y888""8o 
// C++ Conpetitive Programming Template 
// Ver 2.0 (codename: Noa)
// Last Modified : 2019-06-07
// Created       : 2019-05-25
// Auther        : shirataki3
#include <bits/stdc++.h>
using namespace std;
// typename alias
template <class T> using vec = vector<T>;
template <class T, class U> using vep = vec<pair<T,U> >;
template <class T> using PQ = priority_queue<T>;
using ll = long long;
using vll = vec<ll>;
using pll = pair<ll, ll>;
using vpll = vec<pll>;
using str = string;
// あくまのちから
//#define int ll

// const
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;
static const double PI = 3.14159265358979323846;

// accelerate stdin, stdout
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
// repeat macro
#define FOR(i, a, b) for(ll (i)=(a);(i)<=(b);i++)
#define rFOR(i, a, b) for(ll (i)=(b);(i)>=(a);i--)
#define REP(i, n) for(ll i=0;i<n;i++)
// vector macro
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort(WHOLE(v))
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse(WHOLE(v))
#define FOLDL(src, dst, lambda) partial_sum(WHOLE(src), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum(WHOLE(src), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate(WHOLE(v), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

// io helper
template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}
template <typename T>istream& operator>>(istream &is, vec<T> &v) {for(auto &a:v) is >> a; return is;}
template <typename T>ostream& operator<<(ostream &os, vec<T> &v) {os << "[";REP(i, v.size() - 1) os << v[i] <<", "; os << v[v.size()-1]<<"]";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, map<T, U> &mp) {os << "{ ";for(auto &p:mp) os << p.first << ": " << p.second << ", "; os << "}";return os;}

void solve() {
    ll N;
    cin >> N;
    vll a(N);
    cin >> a;
    out(SUM(a, 0) - N);
}

signed main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
sys.setrecursionlimit(3000)
n = int(input())
f = np.array([list(map(int, input().split())) for _ in range(n)])
p = np.array([list(map(int, input().split())) for _ in range(n)])


def dfs(a):
    if len(a) == 10:
        if sum(a) == 0:
            return -10**9
        else:
            profit = 0
            for i in range(n):
                c = int(np.dot(a, f[i]))
                profit += p[i][c]
            return profit

    ret1 = dfs(np.append(a, 1))
    ret2 = dfs(np.append(a, 0))
    return max(ret1, ret2)


start = np.array([])
print(dfs(start))




Measured memory_bytes: 12496
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
        int n,i;
    cin>>n;
    pair<int,int> arr[n];
    fr(i,0,n)
    {
        cin>>arr[i].fi;
        arr[i].se=i;
    }
    int ans[n];
    sort(arr,arr+n);
    fr(i,0,n)
    {
        int left=i;
        int req=(n-1)/2+1;
        if(left<req)
        req-=left;
        else
        {
            ans[arr[i].se]=arr[req-1].fi;
            continue;
        }
        ans[arr[i].se]=arr[req+i].fi;
            
    }
    fr(i,0,n)
    cout<<ans[i]<<"\n";
    

    }
  return 0;
  }



Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll p = 1000000007;

ll powmod(ll x, ll y) {
    ll res = 1;
    for (ll i = 0; i < y; i++) {
        res = (res * x) % p;
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = powmod(10, n) - 2 * powmod(9, n) + powmod(8, n);
    ans %= p;
    ans = (ans + p) % p;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

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

	cin >> H >> N;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		H -= A;
		if (H <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int dp[50];

int fib(int n) {
  if( n ==0 || n == 1) return dp[n] = 1;
  if( dp[n] != -1 ) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main() {
  int n, i;
  for( i = 0; i < 50; i++ ) dp[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fib(n));

  return 0;
}

Measured memory_bytes: 596
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<18)
#define MODULO (1000000007)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;

int n;
int a[N];
int b[N];

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d", &a[i]);
	}
	if (n & 1)
	{
		b[(n >> 1)] = a[0];
		for (int i = 1;i <= (n >> 1);i++)
		{
			b[(n >> 1) + i] = a[((i - 1) << 1) + 1];
			b[(n >> 1) - i] = a[((i - 1) << 1) + 2];
		}
	}
	else
	{
		for (int i = 0;i < (n >> 1);i++)
		{
			b[(n >> 1) + i] = a[(i << 1)];
			b[(n >> 1) - i - 1] = a[(i << 1) + 1];
		}
	}
	for (int i = 0;i < n;i++)
	{
		printf("%d ", b[i]);
	}
	printf("\n");
//	system("pause");
	return 0;
}



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

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

	int A = 0;
	if (N >= 64) {
		A = 64;
	}
	else if (N >= 32) {
		A = 32;
	}
	else if (N >= 16) {
		A = 16;
	}
	else if (N >= 8) {
		A = 8;
	}
	else if (N >= 4) {
		A = 4;
	}
	else if (N >= 2) {
		A = 2;
	}
	else {
		A = 1;
	}
	cout << A << endl;

	return 0;
}

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

typedef long long ll;

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

    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> p(m);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        p[i] = make_pair(b,a);
    }
    sort(p.begin(),p.end());
    int t=0,ans=0;
    for(int i=0;i<m;i++){
        if(t <= p[i].second){
            ans++;
            t = p[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

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

void toLowerCase(string& str) {
    for (int i = 0; i < str.length(); ++i) {
        str[i] = (char) tolower(str[i]);
    }
}

// if Taro wins, return -1
// if Hanako wins, return 1
// if draw, return 0
int compareCard(string tCard, string hCard) {
    if (tCard == hCard) {return 0;}

    int min_len = tCard.length() > hCard.length() ? tCard.length() : hCard.length();
    for (int i = 0; i < min_len; ++i) {
        if (tCard[i] != hCard[i]) {
            return tCard[i] < hCard[i] ? 1 : -1;
        }
        if (i == min_len - 1) {
            return min_len == tCard.length() ? 1 : -1;
        }
    }
}

int main() {
//    freopen("in.txt", "r", stdin);

    int n, result, tSum = 0, hSum = 0;
    string ta, ha;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> ta >> ha;
        result = compareCard(ta, ha);
        switch(result) {
        case -1:
            tSum += 3;
            break;
        case 0:
            ++tSum;
            ++hSum;
            break;
        case 1:
            hSum += 3;
            break;
        }
    }
    cout << tSum << " " << hSum << endl;
}

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

int main() {
	ll n, d, ans = 0;
	cin >> n >> d;
	vector<ll> x(n), y(n);
	rep(i,n) cin >> x[i] >> y[i];
	rep(i,n) {
		if (d*d >= x[i]*x[i] + y[i]*y[i]) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 6424
#include <stdio.h>

int main(){
    
  
    int a,b;
    scanf("%d %d",&a,&b);

    if(a%3==0||b%3==0||(a+b)%3==0){
        printf("Possible");
    }
    else
    {
        printf("Impossible");
    }

    return 0;
    
}

Measured memory_bytes: 128
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    N, X = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    ret = 0
    cnt = 0
    if sum(A)<X:
        print(N-1)
    elif sum(A)==X:
        print(N)
    else:
        for i in range(N):
            X-=A[i]
            if X<0:
                break
        print(i)

if __name__ == '__main__':
    main()

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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int input;
    cin >> input;
    
    if(input == 1) cout << "Hello World";
    else{
        int A, B;
        cin >> A >> B;
        
        cout << A + B;
    }
    
	return 0;
}


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

using namespace std;

int n,q;
int a[100005];
int f[100005],t[100005];
int s,g;


int main(void){
	scanf("%d%d",&n,&q);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	s=a[0];
	g=a[n-1];
	for(int i=0;i+1<n;i++){
		t[a[i]]=a[i+1];
	}
	for(int i=0;i+1<n;i++){
		f[a[i+1]]=a[i];
		//printf("%d %d\n",a[i+1],a[i]);
	}
	for(int i=0;i<q;i++){
		int b;
		scanf("%d",&b);
		int ns=t[b];
		int ng=f[b];
		if(ns==0){
			t[b]=s;
			//printf("%d %d\n",f[b],t[b]);
			f[s]=b;
			t[f[b]]=0;
			g=f[b];
			f[b]=0;
			s=b;
			continue;
		}
		if(ng==0){
			f[t[b]]=0;
			t[g]=b;
			f[b]=g;
			s=t[b];
			t[b]=0;
			g=b;
			continue;
		}
		//printf("%d %d\n",ns,ng);
		f[t[b]]=0;
		t[f[b]]=0;
		f[b]=g;
		t[g]=b;
		t[b]=s;
		f[s]=b;
		s=ns;
		g=ng;
	}
	int res=s;
	for(int i=0;i<n;i++){
		printf("%d%c",res,i+1==n?'\n':' ');
		res=t[res];
	}
	return 0;
}



Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 N,M;

i64 A[101010];
i64 sum[101010];


int main(){
  cin >> N >> M;
  rep(i,1,N){
    cin >> A[i];
    sum[i] = sum[i - 1] + A[i];
    sum[i] %= M;
  }
  map<i64,int> mp;
  i64 ans = 0;
  mp[0] = 1;

  rep(i,1,N){
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << ans << endl;
}



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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> void chmax(T& a,const T& b){if(a < b) a = b;}
template<typename T> void chmin(T& a,const T& b){if(b < a) a = b;}
typedef long long ll;

int R,C,N;
ll diff [100001] [2];
struct edge{
	int to;
	ll cost;
};
list<edge> grid [100001] [2];
const ll INF = 1e17;

bool dfs(int curr,bool b,ll v,ll *mn)
{
	if(diff [curr] [b] != INF && diff [curr] [b] != v){
		return false;
	}
	if(diff [curr] [b] == v){
		return true;
	}
	diff [curr] [b] = v;
	chmin(mn [b],v);

	int res = true;
	for(auto&& it : grid [curr] [b]){
		if(dfs(it.to,!b,it.cost - v,mn) == false){
			return false;
		}
	}

	return true;
}

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

	cin >> R >> C >> N;
	FOR(i,0,N){
		int r,c;
		ll a;
		cin >> r >> c >> a;
		grid [r] [0].push_back(edge{c,a});
		grid [c] [1].push_back(edge{r,a});
	}

	fill(diff [0],diff [100001],INF);
	for(int i = 1;i <= R;i++){
		if(grid [i] [0].empty() == true) continue;
		ll mn [2] = {INF,INF};
		if(diff [i] [0] == INF && (dfs(i,0,0,mn) == false || mn [0] + mn [1] < 0)){
			cout << "No" << endl;
			return 0;
		}
	}
	for(int i = 1;i <= C;i++){
		if(grid [i] [1].empty() == true) continue;
		ll mn [2] = {INF,INF};
		if(diff [i] [1] == INF && (dfs(i,1,0,mn) == false || mn [0] + mn [1] < 0)){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 19072
#include<stdio.h>

int main(void) {
  int n, x;
  scanf("%d %d", &n, &x);

  int m[1100], min = 1100;

  for (int i = 0; i < n; i++) {
    scanf("%d", &m[i]);
    if (min > m[i]) min = m[i];
    x -= m[i];
  }

  printf("%d\n", n + x / min);

  return 0;
}


Measured memory_bytes: 128
mod = (10**9)+7

H, W = map(int, input().split())
a = ["#"+input().strip()+"#" for _ in range(H)]
a = ["#"*(W+2)] + a + ["#"*(W+2)]
a[1] = "."+a[1][1:]

dp = [[0]*(W+2) for _ in range(H+2)]
dp[1][0] = 1

for y in range(1, H+1):
    for x in range(1, W+1):
        if a[y][x] == '.':
            t = 0
            if a[y][x-1] == '.':
                t += dp[y][x-1]
            if a[y-1][x] == '.':
                t += dp[y-1][x]
            dp[y][x] = t % mod
print(dp[H][W])


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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

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

    int n;
    cin >> n;

    vector<int> nums(n);
    rep(i, n) cin >> nums[i];

    if(accumulate(all(nums), 0) - *max_element(all(nums)) > *max_element(all(nums))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main()
{
    const int N = 10000;
    vector<int> x(N);
    for (size_t i = 0; i < N; i++)
    {
        int temp = 0;
        cin >> temp;

        if (temp)
        {
            x[i] = temp;
        }
        else
        {
            break;
        }
    }

    for (size_t i = 0; i < N; i++)
    {
        if (x[i])
        {
            cout << "Case " << i + 1 << ": " << x[i] << endl;
        }
        else
        {
            break;
        }
    }
}



Measured memory_bytes: 3140
#include<stdio.h>

int main(void){


        long int h,w,cnt;
    

        cnt = 0 ; 

        scanf("%ld %ld",&h ,&w);

        if(h == 1 || w == 1)
                printf("1\n");

        else if( h % 2 == 0  ){  
                cnt = (h / 2) * w;
                printf("%ld\n",cnt);

        }else if( w % 2 == 0 ){
                cnt =(w / 2) * h;
                printf("%ld\n",cnt);

        }else{
                cnt =( h * w + 1) / 2;
                printf("%ld\n",cnt);
        }   

        return 0;

}


Measured memory_bytes: 1728
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())


"""
"""

#solution:


        
#input
def resolve():
    N,=pin()
    P=tuple(pin())
    Q=tuple(pin())
    
    from itertools import permutations as pm
    a=list(range(1,N+1))
    for k,item in enumerate(pm(a)):
        
        if item==P:
            p=k
            
        if item==Q:
            q=k
    print(abs(p-q))    
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
1 3 2
3 1 2"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1"""
        output = """17517"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3
1 2 3
1 2 3"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 85356
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	double ans;
	cin >> ans;
	ans *= M_PI * 2.0;
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, m, c, b[30], a, ans;

int main()
{
	cin >> n >> m >> c;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n; i++)
	{
		ll test = c;
		for (int j = 0; j < m; j++)
		{
			cin >> a;
			test += a * b[j];
		}
		if (test > 0) ans++;
	}
	cout << ans << endl;
	int www;
	cin >> www;
}

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

using namespace std;

int main()
{
  int64_t n, k, q;
  cin >> n >> k >> q;
  vector<int64_t> a(n, 0);

  for(int64_t i = 0;
      i < q;
      ++i)
    {
      int64_t j;
      cin >> j;
      ++a[j - 1];
    }

  for(int64_t i = 0;
      i < n;
      ++i)
    {
      if(a[i] + k - q <= 0)
        {
          cout << "No" << endl;
        }
      else
        {
          cout << "Yes" << endl;
        }
    }


  return 0;
}


Measured memory_bytes: 1408
//#ifdef JUDGE
//#include <fstream>
//std::ifstream cin("input.txt");
//std::ofstream cout("output.txt");
//#else
#include <iostream>
#include <bits/stdc++.h>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
ll sd(ll n)
{
    ll a=0;
    while (n>0)
    {
        a+=n%10;
        n/=10;
    }
    return a;
}
void solve()
{
   int n,x;
   cin>>n;
   int a=0,b=0,c=0;
   rep(i,0,n)
   {
     cin>>x;
     if(x%2==0 && x%4!=0)
       a++;
     else if(x%4==0)
       b++;
     else if(x%2!=0)
       c++;
   }
  if(a==0 && b>=c-1)
    cout<<"Yes";
  else
  {
    if(b>=c)
      cout<<"Yes";
    else
      cout<<"No";
  }
  return;
}
int main()
{
    ll t=1;
    //cin >>t;
    while(t--)
        solve();

}


Measured memory_bytes: 256
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=3005;

int n;
double ans;
double p[maxn];
double dp[maxn][maxn<<1];

inline int f(int x){return (x+maxn);}

int main(){
	scanf("%d",&n);
	REP(i,1,n) scanf("%lf",p+i);
	dp[0][f(0)]=1;
	REP(i,1,n){
		REP(j,-n,n){
//			printf("i=%d j=%d %lf %lf\n",i,j,dp[i-1][f(j-1)],dp[i-1][f(j+1)]);
			if(j-1>=-n) dp[i][f(j)]+=dp[i-1][f(j-1)]*p[i];
			if(j+1<=n) dp[i][f(j)]+=dp[i-1][f(j+1)]*(1-p[i]);
			if(i==n&&j>0) ans+=dp[i][f(j)];
		}
	}
	printf("%.10lf\n",ans);
	return 0;
}


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

int main(){
  //int a,b,c;
  string s;
  //cin >> a >> b >> c;
  cin >> s;
  //if((a+b)%2==1)cout << 1 + (a+b)/2 << endl;
  //else cout << (a+b)/2 << endl;
  cout << 2018 << s.substr(4,6) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int  N=100000 +10, M=(ll)1e9+1 ;
 const int mod =998244353 ,sz=5 ;
vl a(N);

// bool check(ll x){
//   ll n=a.size();
//   for(ll i=0;i<n;i++){
    
//   }
  
// }

void work(){
  ll n;
  cin >> n;
  for(ll i=0;i<n;i++)
    cin >> a[i];
  multiset<ll> s;
  for(ll i=0;i<n;i++){
    auto it=s.lower_bound(a[i]);
    if(it==s.begin()){
      s.insert(a[i]);
    }
    else{
      it--;
      s.erase(it);
      s.insert(a[i]);
    }
  }
  cout << s.size();
}
int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



int h,w;
string s[12];
ll c =0;

bool rev(char l[], char t[]){
  REP(i,w){
    if(l[i] != t[w-1-i]){
      return false;
    }
  }
  return true;
}

bool ok(vector<pii> p){
  char t[12][13];
  c++;
  REP(i,p.size()){
    int f = p[i].first;
    int b = p[i].second;
    REP(j,h){
      t[j][i] = s[j][f];
      t[j][w-1-i] = s[j][b];
    }
  }
  bool used[12];
  REP(i,h) used[i] = false;
  int cnt = 0;
  REP(i,h){
    FOR(j,i+1,h){
      if(used[i]) break;
      if(rev(t[i],t[j])){
        used[i] = true;
        used[j] = true;
        cnt += 2;
      }
    }
  }
  if(h-cnt>1) return false;
  if(h-cnt==0) return true;
  REP(i,h){
    if(used[i]) continue;
    return rev(t[i],t[i]);
  }
}

bool dfs(vector<bool> used, vector<pii> p){
  if(p.size()*2 == w){
    return ok(p);
  }
  if(p.size()*2+1==w){
    vector<pii> tmp = p;
    REP(i,w){
      if(used[i]) continue;
      tmp.push_back(pii(i,i));
      break;
    }
    return ok(tmp);
  }
  REP(i,w){
    if(used[i]) continue;
    vector<bool> tmp_u = used;
    tmp_u[i] = true;
    FOR(j,i+1,w){
      if(tmp_u[j]) continue;
      vector<pii> tmp = p;
      vector<bool> tmp_uu = tmp_u;
      tmp_uu[j] = true;
      tmp.push_back(pii(i,j));
      if(dfs(tmp_uu,tmp)){
        return true;
      }
    }
    if(w >= 12)break;
  }
  return false;
}


int main(){
  cin >> h >> w;
  REP(i,h) cin >> s[i];
  vector<bool> used;
  REP(i,w) used.push_back(false);
  vector<pii> p;
  if(dfs(used, p)){
    cout << "YES" <<endl;
  }else{
    cout << "NO" << endl;
  }
  //cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a;
int b[100002];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        b[a]=i;
    }
    for(int i=1;i<=n;i++){
        cout<<b[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
/*
         ########     ########   ########   #########   ##       #######   ##       #######
         #      #     #      #   #      #       #       # #      #     #   # #      #     #
         #      #     #      #   #      #       #       #  #     #     #   #  #     #     #
         ########     #      #   #      #       #       #   #    #     #   #   #    #     #
         ###          #      #   #      #       #       #    #   #######   #    #   #######
         #  #         #      #   #      #       #       #   #    #     #   #   #    #     #
         #   #        #      #   #      #       #       #  #     #     #   #  #     #     #
         #    #       #      #   #      #       #       # #      #     #   # #      #     #
         #     #      ########   ########       #       ##       #     #   ##       #     #
*/

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcountll //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define int long long
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
    rootdada;
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
    string s;
    cin >> s;
    int a = 0;
    rep(i, 0, s.length())
    a += (s[i] - '0');
    if (a % 9 == 0)
    {
        cout << "Yes\n";
    }
    else
        cout << "No\n";
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
signed main(){
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int x[m],y[m];
  for(int i=0;i<m;i++) cin>>x[i]>>y[i];
  int c[n+1],d[n+1];
  memset(c,0,sizeof(c));
  memset(d,0,sizeof(d));
  for(int i=0;i<n;i++) c[a[i]]++;
  for(int i=1;i<=n;i++)
    for(int j=0;j<c[i];j++)
      if(i-j>0) d[i-j]++;

  int ans=0;
  for(int i=1;i<=n;i++)
    if(d[i]==0) ans++;

  //cout<<ans<<endl;
  //for(int i=1;i<=n;i++) cout<<i<<" "<<d[i]<<endl;
    
  for(int i=0;i<m;i++){
    x[i]--;
    
    c[a[x[i]]]--;
    if(a[x[i]]-c[a[x[i]]]>0){
      d[a[x[i]]-c[a[x[i]]]]--;
      //cout<<a[x[i]]-c[a[x[i]]]<<" "<<d[a[x[i]]-c[a[x[i]]]]<<endl;
      if(d[a[x[i]]-c[a[x[i]]]]==0) ans++;
    }
    
    a[x[i]]=y[i];

    if(a[x[i]]-c[a[x[i]]]>0){
      d[a[x[i]]-c[a[x[i]]]]++;
      //cout<<a[x[i]]-c[a[x[i]]]<<" "<<d[a[x[i]]-c[a[x[i]]]]<<endl;
      if(d[a[x[i]]-c[a[x[i]]]]==1) ans--;
    }
    c[a[x[i]]]++;

    //for(int j=1;j<=n;j++) cout<<j<<" "<<d[j]<<endl;
    
    cout<<ans<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 9344
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
temp = []
for i in range(N):
    t = T - H[i] * 0.006
    t = abs(t - A)
    temp.append(t)

best_index = temp.index(min(temp))
print(best_index + 1)  


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);



void solve(int T){
   int n,k;
   cin>>n>>k;
   string s;
   cin>>s;
   k--;
   s[k]=tolower(s[k]);
   cout<<s<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





Measured memory_bytes: 3548