akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
tupple = []
check_dic = {}
for i in range(M):
    x, y = map(int, input().split())
    li = [i + 1, x, y, 0]
    tupple.append(li)

def int_to_str(num):
    num = str(num)
    text = ""
    for i in range(6 - len(num)):
        text = "0" + text
    return text + num

tupple = sorted(tupple, key=lambda x:x[2])

for i in tupple:
    if i[1] not in check_dic:
        check_dic[i[1]] = 1
    else:
        check_dic[i[1]] += 1
    i[3] = int_to_str(i[1]) + int_to_str(check_dic[i[1]])

tupple = sorted(tupple, key=lambda x:x[0])

for i in tupple:
    print(i[3])

Measured memory_bytes: 39580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long.parseLong(in.next());
            }
            long mx1 = 0;
            long mx2 = 0;
            Arrays.sort(a);
            for (int i = a.length - 1; i > 0; i--) {
                if (a[i] == a[i - 1]) {
                    if (mx1 == 0) {
                        mx1 = a[i];
                        i--;
                    } else {
                        mx2 = a[i];
                        break;
                    }
                }
            }
            out.println(mx1 * mx2);
        }

    }
}



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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define req(i,f,N) for(int i = f; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T, class Q> inline bool chmin(T& a, Q b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class Q> inline bool chmax(T& a, Q b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //

queue<int> que;
vi par;
vb ispushed;

void bfs(vvi &graph, int n = 0){
    
    
    for (auto x : graph[n]) {
        if (par[x] != -1) continue;
        que.push(x); 
        par[x] = n;
    }
    if (que.size()) {
        int v = que.front(); que.pop();
        bfs(graph, v);
    }
    return;
}

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N , M;
    cin >> N >> M;
    par.assign(N, -1);
    ispushed.assign(N, false);
    ispushed[0] = 0;
    vvi graph(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }
    bfs(graph);
    y();
    req(i, 1, N) {
        cou(par[i] + 1);
    }

}

Measured memory_bytes: 10164
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
mod = 10 ** 9 + 7
d = [list(map(int, input().split())) for _ in range(N)]
ln = K.bit_length()

def ArrayMultiple(a, b, mod):
  n = len(a)
  c = [[0] * n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      for k in range(n):
        c[i][j] += a[i][k] * b[k][j]
        c[i][j] %= mod
  return c

bn = list(bin(K)[2: ])
bn.reverse()
res = [[int(i == x) for i in range(N)] for x in range(N)]
for i in range(ln):
  if int(bn[i]):
    res = ArrayMultiple(res, d, mod)
  d = ArrayMultiple(d, d, mod)
rres = 0
for r in res:
  for x in r:
    rres += x
    rres %= mod
print(rres)

Measured memory_bytes: 43116
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}


const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    string s;
    cin >> s;

    int ans = 0;
    int tmp = 0;
    rep(i,s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            ++tmp;
        }
        else {
            tmp = 0;
        }

        ans = max(tmp, ans);
    }





    cout << ans << endl;




}





//              g++ -std=c++1z


Measured memory_bytes: 256
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
**************************
Time to solve: 
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         long[] dp = new long[N];
         Arrays.fill(dp, Integer.MAX_VALUE);
         dp[0] = 0;
         for(int i=0; i < N; i++)
         {
            if(dp[i] == Integer.MAX_VALUE)
               continue;
            for(int j=1; j <= K; j++)
               if(i+j < N)
                  dp[i+j] = Math.min(dp[i+j], dp[i]+Math.abs(arr[i]-arr[i+j]));
         }
         System.out.println(dp[N-1]);
      }
   }

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

int sumDigits(int num) { return num / 10000 + num % 10000 / 1000 + num % 1000 / 100 + num % 100 / 10 + num % 10; }
int main() {
    int N, M;

    cin >> N;
    vector<int> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    long sum = accumulate(T.begin(), T.end(), 0);

    cin >> M;
    for (int i = 0; i < M; i++) {
        int P, X;
        cin >> P >> X;
        cout << sum - T[P - 1] + X << endl;
    }

    return 0;
}

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

int main(){

  int N; cin >> N;

  int L[10];

  for(int i = 0;i < N;i++) cin >> L[i];

  int index = 0;

  int max = L[0];

  int sum = 0;

  for(int i = 0;i < N;i++){

    sum += L[i];

    if(max < L[i]){
      max = L[i];
      index = i;
    }

  }


  if((sum - L[index]) > L[index]) cout << "Yes\n";
  else cout << "No\n";



}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<ll> sum(n);
  sum[0] = a[0];
  for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + a[i];
  ll b = 0;

  ll ans1 = 0, ans2 = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      ll c = max(1 - (sum[i] + b), 0LL);
      ans1 += c;
      b += c;
    } else {
      ll c = max((sum[i] + b) + 1, 0LL);
      ans1 += c;
      b -= c;
    }
  }
  b = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 1) {
      ll c = max(1 - (sum[i] + b), 0LL);
      ans2 += c;
      b += c;
    } else {
      ll c = max((sum[i] + b) + 1, 0LL);
      ans2 += c;
      b -= c;
    }
  }
  cout << min(ans1, ans2) << endl;

  return 0;
}


Measured memory_bytes: 1792
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define fast_cin ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define pb push_back
#define all(con) (con).begin(), (con).end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fr(i,n) fre(i,1,n)
#define ff(i,a,b) for(int i=a;i<=b;i++)
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
 
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
 
int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
		res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}
 
const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
 
const int N = 1e5 + 10 ;
 
void solve() {
        string s,t;
        cin>>s>>t;
        int a,b;
        cin>>a>>b;
        map<string,int> m;
        m[s]=a;
        m[t]=b;
        string d;
        cin>>d;
        m[d]--;
        cout<<m[s]<<" "<<m[t]<<endl;
}
 
signed main() {
        fast_cin;
	
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
        #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    	#endif
	
	int tests=1;
	// cin>>tests;
	while(tests--) {
		solve();
	}
 
return 0 ;
}
 

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,s;
  cin>>n>>s;
  int x=-1,y=-1,z=-1;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      int ans=10000*i+5000*j+1000*(n-j-i);
        if(ans==s){
          x=n-i-j;
          y=j;
          z=i;
          break;
        }      
    }
  }
  cout<<z<<" "<<y<<" "<<x<<endl;
}

  


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

bool ok(const long long k, const int A, const int B, const vector<long long>& hs) {
    long long r = k;
    for (int i=0; i<hs.size(); i++) {
        if (hs.at(i) > B * k) {
            long long d = A - B;
            r -= (hs.at(i) - (B * k) + (d-1)) / d;
            if (r < 0) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    vector<long long> hs(N);
    for (int i=0; i<N; i++) {
        cin >> hs.at(i);
    }

    // (lb, ub]
    long long lb = 0;
    long long ub = 1000000000;
    while (ub - lb > 1) {
        long long mid = (lb + ub) / 2;
        if (ok(mid, A, B, hs)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }

    cout << ub << endl;

    return 0;
}

Measured memory_bytes: 1024
/*Lucky_Glass*/
#include<map>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=10;
int n,d;
int pos[N+5][N+5];
int main(){
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++)
			scanf("%d",&pos[i][j]);
	}
	int ans=0;
	for(int u=1;u<=n;u++)
		for(int v=u+1;v<=n;v++){
			int tot=0;
			for(int i=1;i<=d;i++)
				tot+=(pos[u][i]-pos[v][i])*(pos[u][i]-pos[v][i]);
			double _tot=sqrt(tot);
			long long A=(long long)ceil(_tot),B=(long long)floor(_tot);
			if(A*A==tot || B*B==tot)
				ans++;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
int a[1000],n,max=-10000000,min=10000000;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];}
cout<<max-min;

return 0;
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;



int n,m,q; 
vector<int> a,b,c,d;
   int ans=0;
void dfs(vector<int> A){
    if(A.size()==n+1){
        int now=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]] == c[i]) now += d[i];
        }
        ans=max(ans,now);
        return;
    }
    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
}

int main(){
   cin>>n >>m >>q;
   a=b=c=d= vector<int>(q);
   rep(i,q) cin>>a[i] >>b[i] >>c[i] >>d[i];
   dfs(vector<int>(1,1));
   cout<<ans<<endl;
}


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

long long x, y, ans = 2e9;

int main() {
	cin >> x >> y;
	if (abs(x) <= abs(y))
		ans = (x < 0) + (y < 0) + (long long)abs(y) - (long long)abs(x);
	if (-(long long)abs(x) <= -(long long)abs(y))
		ans = min(ans, (x > 0) + (y > 0) + -(long long)abs(y) + (long long)abs(x));
	ans = min(ans, (x > 0) + (y < 0) + abs(y) + abs(x));
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;
  for (ll i = 1; i <= n; i++){
    string s = to_string(i);
    ll total = 0;
    rep(j, sz(s)){
      total += s[j]-'0';
    }
    if(total>=a&&total<=b){
      ans+=i;
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#create date: 2020-09-13 21:03

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def pow(a, n, p):
    bi = str(format(n, "b"))
    res = 1
    for i in range(len(bi)):
        res = (res * res) % p
        if bi[i] == "1":
            res = (res * a) % p
    return res

def main():
    n = ni()
    mod = 10**9 + 7
    
    print((pow(10, n, mod) - 2*pow(9, n, mod) + pow(8, n, mod))%mod)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9204
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[4];
    Arrays.fill(a,0);
    for(int i=0;i<n;i++)
    {
      String s=sc.next();
      if(s.equals("AC"))
        a[0]++;
      else if(s.equals("WA"))
        a[1]++;
      else if(s.equals("TLE"))
        a[2]++;
      else 
        a[3]++;
    }
    System.out.println("AC x "+a[0]);
     System.out.println("WA x "+a[1]);
     System.out.println("TLE x "+a[2]);
     System.out.println("RE x "+a[3]);
    
  }
}

Measured memory_bytes: 58788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    ll n; scll(n);
    ll ans = n * (n-1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
  s = 0
  for j in range(2, N // i + 1):
    s += B[i * j]
  if s % 2 != A[i]:
    B[i] = 1

print(sum(B))
for i in range(1, N + 1):
  if B[i] == 1:
    print(i)

Measured memory_bytes: 7148
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<string> s(n);
    int ab = 0;
    REP(i,n) {
        cin >> s[i];
        REP(j,s[i].length()-1) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') ab++;
        }
    }
    int a = 0;
    int b = 0;
    int ba = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i][0] == 'B' && s[i].back() == 'A') ba++;
        else if (s[i][0] == 'B') b++;
        else if (s[i].back() == 'A') a++;
    }
    int ans = 0;
    if (ba > 0) {
        ans = ba-1;
        if (a > 0) ++ans, --a;
        if (b > 0) ++ans, --b;
    }
    // cout << ans << " " << a << " " << b << endl;
    ans += min(a, b);
    cout << ab+ans << endl;
    return 0;
}

Measured memory_bytes: 768
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

ans = 0
prevs = [''] * k
for i in range(n//k+1):
  #print(i)
  #print(prevs)
  for j in range(i*k, (i+1)*k):
    if j >= n:
      break
    prevs_i = j%k
    prev = prevs[prevs_i]
    #print(prev)
    
    if t[j] == 'r':
      if prev == 'p':
        prevs[prevs_i] = ''
      else:
        prevs[prevs_i] = 'p'
        ans += p
    elif t[j] == 's':
      if prev == 'r':
        prevs[prevs_i] = ''
      else:
        prevs[prevs_i] = 'r'
        ans += r
    elif t[j] == 'p':
      if prev == 's':
        prevs[prevs_i] = ''
      else:
        prevs[prevs_i] = 's'
        ans += s
print(ans)

Measured memory_bytes: 74392
# -*- coding: utf-8 -*-
N = int(input())

if N <= 12:
    print(N)
else:
    str_ans = "12"
    counter = 12
    while counter < N:
        len_ans = len(str_ans)
        low_nine_num = 0
        for i in range(len_ans):
            if str_ans[len_ans - i - 1] == "9":
                low_nine_num += 1
            else:
                break
        if low_nine_num == len_ans:
            str_ans = "1" + "0" * len_ans
        else:
            chenged_top_num = -1
            low_digit_num = -1
            if low_nine_num == len_ans - 1:
                chenged_top_num = int(str_ans[len_ans - low_nine_num - 1])
                low_digit_num = len_ans - 1
            else:
                for i in range(len_ans - low_nine_num):
                    if i == len_ans - low_nine_num - 1 :
                        if chenged_top_num == -1:
                            chenged_top_num = int(str_ans[0])
                            low_digit_num = len_ans - 1
                    else:
                        compare_high_num = int(str_ans[-1 * (i + 2 + low_nine_num)])
                        compare_low_num = int(str_ans[-1 * (i + 1 + low_nine_num)])
                        if compare_high_num - compare_low_num != 0 and compare_high_num - compare_low_num != 1:
                            chenged_top_num = compare_high_num
                            low_digit_num = i + 1 + low_nine_num
    #                         print("A", str_ans, compare_high_num, low_digit_num)
                        else:
                            chenged_top_num = compare_low_num
                            low_digit_num = i + low_nine_num
    #                         print("B", str_ans, compare_high_num, low_digit_num)
                            break

                            
            temp_str_ans = str_ans[:len_ans - low_digit_num - 1] # not chenged
            temp_str_ans += str(chenged_top_num + 1)
            for i in range(low_digit_num):
                temp_str_ans += str(max(chenged_top_num - i, 0))
            str_ans = temp_str_ans
        
        counter += 1
#         print(counter, str_ans, low_nine_num, low_digit_num)
    
    print(int(str_ans))


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll h, w, n, sr, sc;
  cin >> h >> w >> n >> sr >> sc;
  string s, t;
  cin >> s >> t;

  // それぞれの方向に何回動かせば良いか
  ll u = sr, l = sc, d = h - sr + 1, r = w - sc + 1;

  ll now = 0;
  bool can = true;

  // 上向きを考える
  now = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'U') now++;
    if (now >= u) can = false;
    if (t[i] == 'D' && -now < d - 1) now--;
  }

  // 下向きを考える
  now = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'D') now++;
    if (now >= d) can = false;
    if (t[i] == 'U' && -now < u - 1) now--;
  }

  // 左向きを考える
  now = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L') now++;
    if (now >= l) can = false;
    if (t[i] == 'R' && -now < r - 1) now--;
  }

  // 右向きを考える
  now = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') now++;
    if (now >= r) can = false;
    if (t[i] == 'L' && -now < l - 1) now--;
  }

  cout << ((can) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 776
n, x, y = map(int, input().split())
li = [0]*(n-1)
# print(li)
for i in range(1, n+1):
    for j in range(i+1, n+1):
        num = min(j-i, abs(i-x)+abs(j-y)+1)
        li[num-1] += 1
for i in li:
    print(i)

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

ll help(ll h)
{
	if (!h)
		return 0;
	if (h == 1)
		return 1;
	return 2 * help(h / 2) + 1;
}

int main()
{
	fast;
	ll h;
	cin >> h;
	cout << help(h);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC128C
// bit全探索

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  vector<vector<int> > L(M, vector<int>(N, 0)); // 隣接行列形式
  REP(i, M){
    int k; cin >> k;
    REP(j, k){
      int s; cin >> s; s--;
      L[i][s] = 1; // 繋がっているスイッチを1にする
    }
  }
  vector<int> p(M, 0);
  REP(i, M){
    cin >> p[i];
  }
  int ans = 0;
  // スイッチのON/OFFをbit全探索。1がON
  REP(i, 1<<N){
    bool flag = true;
    REP(j, M){ // j番目の電球
      int cnt = 0; // 繋がっていて、かつ、onのスイッチの個数
      REP(k, N){ // k番目のスイッチ
        if(((i >> k) & 1) && L[j][k] == 1) cnt++;
      }
      if(cnt%2 != p[j]){
        flag = false;
        break;
      }
    }
    if(flag) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

using namespace std;

void input(int& N, set<int>& R_INDEX, set<int>& G_INDEX, set<int>& B_INDEX)
{
  char c;
  for (int i= 0; i < N; i++){
    cin >> c;
    switch(c){
    case 'R':
      R_INDEX.insert(i);
      break;
    case 'G':
      G_INDEX.insert(i);
      break;
    case 'B':
      B_INDEX.insert(i);
      break;
    }
  }
}

long long int findsetnum(set<int>& R_INDEX, set<int>& G_INDEX, set<int>& B_INDEX)
{
  long long int sum = 0;
  int a, b, c;
  set<int>::iterator R_iter, G_iter;
  for (R_iter = R_INDEX.begin(); R_iter != R_INDEX.end(); R_iter++)
    for (G_iter = G_INDEX.begin(); G_iter != G_INDEX.end(); G_iter++){
      a = (B_INDEX.find(2 * (*G_iter) - *R_iter) == B_INDEX.end())? 0 : 1;
      b = (B_INDEX.find(2 * (*R_iter) - *G_iter) == B_INDEX.end())? 0 : 1;
      c = (B_INDEX.find((*G_iter + *R_iter) / 2) == B_INDEX.end() || (*G_iter + *R_iter) % 2 != 0)? 0 : 1;
      sum += (B_INDEX.size() - a - b - c);
    }
  return sum;
}

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  set<int> R_INDEX, G_INDEX, B_INDEX;
  input(N, R_INDEX, G_INDEX, B_INDEX);
  cout << findsetnum(R_INDEX, G_INDEX, B_INDEX) << '\n';
  return 0;
}

Measured memory_bytes: 3812
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

alias Seg = Tuple!(int, "l", int, "r");

void main() {
    int n, m;
    scan(n, m);

    auto ss = new Seg[](m);

    foreach (i ; 0 .. m) {
        int ai, bi;
        scan(ai, bi);
        ss[i] = Seg(ai, bi);
    }

    ss.sort!"a.r < b.r"();

    int ans;
    int x = -1000000;

    foreach (i ; 0 .. m) {
        if (ss[i].l < x) {
            continue;
        }
        else {
            ans++;
            x = ss[i].r;
        }
    }

    writeln(ans);
}









































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4092
#define MOD_TYPE 2

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
#pragma endregion

inline ll gcd(ll a, ll b)
{
  if (a < b)
    swap(a, b);
  return b == 0 ? a : gcd(b, a % b);
}

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

ll f(ll x, ll c, ll d)
{
  return (x + 1) - (x / c + 1) - (x / d + 1) + (x / lcm(c, d) + 1);
}

int main()
{
  init_main();

  int h, w;
  cin >> h >> w;
  vector<pii> v;
  rep(i, h)
  {
    if (i % 2)
    {
      rep(j, w) v.push_back(MP(i, j));
    }
    else
    {
      for (int j = w - 1; j >= 0; j--)
        v.push_back(MP(i, j));
    }
  }

  int n;
  cin >> n;
  int a[10100];
  rep(i, n) cin >> a[i];
  int i = 0;
  int ans[100][100];
  rep(ai, n)
  {
    rep(j, a[ai])
    {
      ans[v[i].first][v[i].second] = ai + 1;
      i++;
    }
  }
  assert(i == h * w);
  rep(i, h)
  {
    rep(j, w) cout << ans[i][j] << (j == w - 1 ? "\n" : " ");
  }
  return 0;
}


Measured memory_bytes: 640
s = input()
nums = []
for n in s:
  nums.append(int(n))
a = nums[0]
b = nums[1]
c = nums[2]
d = nums[3]
while True:
  if a + b + c + d == 7:
    od1 = "+"
    od2 = "+"
    od3 = "+"
    break
  if a + b + c - d == 7:
    od1 = "+"
    od2 = "+"
    od3 = "-"
    break
  if a + b - c + d == 7:
    od1 = "+"
    od2 = "-"
    od3 = "+"
    break
  if a + b - c - d == 7:
    od1 = "+"
    od2 = "-"
    od3 = "-"
    break
  if a - b + c + d == 7:
    od1 = "-"
    od2 = "+"
    od3 = "+"
    break
  if a - b - c + d == 7:
    od1 = "-"
    od2 = "-"
    od3 = "+"
    break
  if a - b - c - d == 7:
    od1 = "-"
    od2 = "-"
    od3 = "-"
    break
  if a - b + c - d == 7:
    od1 = "-"
    od2 = "+"
    od3 = "-"
    break
print("{}{}{}{}{}{}{}=7".format(a, od1, b, od2, c, od3, d))

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

int N;
char S[114514];
int M[3];
int remed[3];
int big[3];
map<int, int> num;
map<char, int> cnt;

int main() {
  scanf("%s", S);
  N = strlen(S);
  for (int i=0; i<N; i++) {
    cnt[S[i]]++;
  }

  M[0] = cnt['a'];
  M[1] = cnt['b'];
  M[2] = cnt['c'];
  for (int i=0; i<3; i++) {
    num[M[i]]++;
  }

  if (num.size() == 1 || (num.size() == 2 && num.begin()->first+1 == num.rbegin()->first)) {
    puts("YES");
    return 0;
  }

  /*num.clear();
  int rem = 0;
  for (int i=0; i<3; i++) {
    num[M[i]/2]++;
    rem += M[i]%2;
    remed[i] = M[i]%2;
  }

  if (rem >= 2) {
    puts("NO");
    return 0;
  }
  
  if (!(num.size() == 1 || (num.size() == 2 && num.begin()->first+1 == num.rbegin()->first))) {
    puts("NO");
    return 0;
  }

  if (rem == 0) {
    puts("YES");
    return 0;
  }

  for (int i=0; i<3; i++) {
    big[i] = (M[i]/2 == num.rbegin()->first);
    if (big[i] && remed[i]) {
      puts("NO");
      return 0;
    }
  }*/

  puts("NO");
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

LL a, b, a1, b1, r1, r2, n;

int main() {
scanf("%lld %lld %lld", &n, &a, &b);
if (a > b) swap(a, b);
if (a % 2 == b % 2) {
	printf("%lld\n", (b - a) / 2);
	return 0;
}
a1 = a;
b1 = b;
r1 = n - b;
a1 += r1;
b1 += r1;
a1++;
r1++;
r1 += (b - a) / 2;

a1 = a;
b1 = b;
r2 = a - 1;
a1 -= r2;
b1 -= r2;
b1--;
r2++;
r2 += (b - a) / 2;
printf("%lld\n", min(r1, r2));
}





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

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    
    vector<int> coordinate(n);
    for (int  i = 0; i < n; i++) {
        cin >> coordinate.at(i);
    }

    sort(coordinate.begin(),coordinate.end());
    int mindistance =100000000;
    for (int p = coordinate.at(0); p <= coordinate.at(n - 1); p++) {
        int distance = 0;
        for (int i = 0; i < n; i++) {
            distance += (coordinate.at(i) - p) * (coordinate.at(i) - p);
        }
        mindistance = min(mindistance, distance);
    }
    
    cout << mindistance << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Reader in = new Reader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, Reader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            int[] dp = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            dp[1] = Math.abs(a[1] - a[0]);
            for (int i = 2; i < n; ++i) {
                int x = Math.abs(a[i] - a[i - 1]) + dp[i - 1];
                int y = Math.abs(a[i] - a[i - 2]) + dp[i - 2];
                dp[i] = Math.min(x, y);
            }
            out.println(dp[n - 1]);
        }

    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public Reader(InputStream in) {
            din = new DataInputStream(in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) {
            try {
                din = new DataInputStream(new FileInputStream(file_name));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public int nextInt() {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg) {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg) {
                return -ret;
            }
            return ret;
        }

        private void fillBuffer() {
            try {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }
}



Measured memory_bytes: 21972
S=input()
N=len(S)
d=[[0]*4001 for _ in range(4001)]
d[0][0]=1
x=0
y=0
for i in range(2*N):
	if i<N:
		x+=int(S[i])
		y=2*i+2-x
	for j in range(i+1):
		for k in range(2):
			if j+1-k<=x and i-j+k<=y:
				d[j+1-k][i-j+k]+=d[j][i-j]
				d[j+1-k][i-j+k]%=998244353
print(d[x][y])


Measured memory_bytes: 167388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 1e6 + 10;
char s[N], t[N];
int main() {
	scanf("%s%s", s, t);
	int ans = 0;
	for (int i = 0; s[i]; i++) {
		if (s[i] != t[i])ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4148
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,a;
  in oc=0;
  cin>>n;
  forn(z,n){
    cin>>a;
    oc+=a%2;
  }
  if(oc%2==1){
    cout<<"NO"<<endl;
  }
  else
    cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 384
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import shortest_path, csgraph_from_dense, floyd_warshall
def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    m = [[0] * (W * H) for _ in range(W * H)]
    def loc(h, w):
        return h * W + w
    def con(h1, w1, h2, w2):
        m[loc(h1, w1)][loc(h2, w2)] = 1
        m[loc(h2, w2)][loc(h1, w1)] = 1

    for h in range(H):
        for w in range(W):
            if S[h][w] == '#':
                continue
            if h > 0:
                if S[h - 1][w] == '.':
                    con(h, w, h - 1, w)
            if h < H - 1:
                if S[h + 1][w] == '.':
                    con(h, w, h + 1, w)
            if w > 0:
                if S[h][w - 1] == '.':
                    con(h, w, h, w - 1)
            if w < W - 1 and S[h][w + 1] == '.':
                con(h, w, h, w + 1)
    g = csgraph_from_dense(m)
    EE = floyd_warshall(g)
    print(int(np.max(EE[~np.isinf(EE)])))


main()


Measured memory_bytes: 17820
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <chrono>
#include<map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef unsigned int ui;
typedef unsigned short us;
typedef unsigned long long ull;

using namespace std;


int inputValue() {
  int a;
  scanf("%d", &a);
  return a;
};
void inputVector(vector<int>* v) {
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  p->clear();
  p->shrink_to_fit();
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, ui r, ui c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}

template<template <class...> class Map, typename T_0, typename T_1, typename... Args>
void inputMap(Map<T_0, T_1, Args...>& mp) {
  T_0 a;
  T_1 b;
  while (cin >> a && a != -1) {
    cin >> b;
    mp.insert(make_pair(a, b));
  }
}
template<template <class...> class Vec1, template <class...> class Vec2, typename T, typename... Args1, typename... Args2>
void input2dPairVector(Vec1<Vec2<T, Args2...>, Args1...>& vec) {
  T a;
  T b;
  while (cin >> a && a != -1) {
    cin >> b;
    vec.push_back(vector<T>({ a - 1, b - 1 }));
  }
}
template<template <class...> class Vec1, template <class...> class Vec2, typename T, typename... Args1, typename... Args2>
void input2dPairVector(Vec1<Vec2<T, Args2...>, Args1...>& vec, ull size) {
  T a;
  T b;
  for (size_t i = 0; i < size; i++) {
    scanf("%d %d", &a, &b);
    vec.push_back(vector<T>({ a - 1, b - 1 }));
  }
}

template<template <class...> class Vec, typename T, typename U, typename... Args>
void numberToBoolenVector(Vec<T, Args...>& vec, U a) {
  ui i = 0;
  T amari;
  do {
    if (a % (ull)pow(2, i + 1)) {
      amari = 1;
      vec.push_back(amari);
      a -= (ull)pow(2, i);
    }
    else {
      amari = 0;
      vec.push_back(amari);
    }
    i++;
  } while (a);
}

template<template <class...> class Vec, typename T, typename... Args>
ull boolenVectorToNumber(Vec<T, Args...>& vec) {
  ull r = 0;
  for (size_t i = 0; i < vec.size(); i++)
  {
    r += vec[i] * (ull)pow(2, i);
  }
  return r;
}

int main(int argc, const char * argv[]) {
  ll r, d, x;
  scanf("%lld %lld %lld", &r, &d, &x);
  ll xp, xm;
  xm = x;

  for (size_t i = 0; i < 10; i++)
  {
    xp = r * xm - d;
    printf("%lld\n", xp);
    xm = xp;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	string s; cin >> s;
	int K; cin >> K;
	char ch = s[K - 1];
	rep(i, 0, N) {
		if (s[i] != ch)s[i] = '*';
	}
	cout << s << "\n";

	return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 300005
using namespace std;
int cnt11(string s){
    int cnt = 0;
    int n = s.size();
    for(int i = 0; i < n; i++){
        cnt += (s[i] == 'R');
    }
    return cnt;
}

int main()
{
    FLASH
    int ans = 0,ans1 = 0,n;
    string s;
    cin >> n >> s;
    int ok = cnt11(s);
    if(ok == 0){
        cout << "0";
        return 0;
    }
    int c = ok;
    int i = 0,j = 0;
    string temp = s;
    for(i = n - 1;i >= 0; i--){
        if(c <= 0)break;
        if(s[i] == 'R'){
            while(j < n && s[j] == 'R'){
                c--;
                j++;
            }
            if(j < n && c > 0 && s[j] == 'W'){
                swap(s[i],s[j]);
                ans++;
                c--;
                j++;
            }
        }
    }
    s = temp;
    for(i = 0; i < n;){
        if(s[i] == 'W'){
            int cnt = 0;
            i++;
            while(i < n && s[i] == 'R'){
                i++,cnt++;
            }
            ans1 += cnt;
        }
        else{
            i++;
        }
    }
    // cout << ans << " " << ans1 << '\n' ;
    cout << min(ans,ans1);
    return 0;
}


Measured memory_bytes: 3864
#include <iostream>

using namespace std;

int main(void)
{
	int N = 0;
  	cin >> N;
  switch (N % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
}

Measured memory_bytes: 3632
import java.io.*;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/6/23 11:55
 * @see meituan.n2018.Bturn
 */
public class Main {


    private static BufferedReader br;
    private static StreamTokenizer st;
    private static PrintWriter pw;


    private static void solve() throws IOException {
        int N = nextInt();
        int K = nextInt();

        int x[] = new int[N];
        int mid = 0;
        for (int i = 0; i < N; i++) {
            x[i] = nextInt();
            if (x[i] <= 0) {
                mid = i;
            }
        }

        int min = Integer.MAX_VALUE;
        for (int i = Math.max(0, mid - K + 1); i <= mid && (i + K - 1 < N); i++) {
            min = Math.min(min, Math.abs(x[i + K - 1] - x[i]) + Math.min(Math.abs(x[i + K - 1]), Math.abs(x[i])));
        }
        if (x[mid] < 0 && (mid + K) < N) {
            min = Math.min(min, x[mid + K]);
        }
        pw.print(min);
    }

    public static void main(String args[]) throws IOException {
//        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
//        if (!oj) {
//            System.setIn(new FileInputStream("src/in.txt"));
//        }
        br = new BufferedReader(new InputStreamReader(System.in));
        st = new StreamTokenizer(br);
        pw = new PrintWriter(new OutputStreamWriter(System.out));
        st.ordinaryChar('\''); //指定单引号、双引号和注释符号是普通字符
        st.ordinaryChar('\"');
        st.ordinaryChar('/');

        long t = System.currentTimeMillis();
        solve();
//        if (!oj) {
//            pw.println("[" + (System.currentTimeMillis() - t) + "ms]");
//        }
        pw.flush();
    }


    private static int nextInt() throws IOException {
        st.nextToken();
        return (int) st.nval;
    }

    private static long nextLong() throws IOException {
        st.nextToken();
        return (long) st.nval;
    }

    private static double nextDouble() throws IOException {
        st.nextToken();
        return st.nval;
    }

    private static String[] nextSS(String reg) throws IOException {
        return br.readLine().split(reg);
    }

    private static String nextLine() throws IOException {
        return br.readLine();
    }
}

Measured memory_bytes: 26180