akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]-=i+1;
    }
    sort(All(a));
    int M = a[n/2];
    long long res=0;
    for(int i=0;i<n;i++){
        res+=abs(a[i]-M);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define rep(i,x) for(int (i)=1;(i)<=(x);(i)++)
#define repp(i,x,y) for(int (i)=(x);(i)<=(y);(i)++)
#define forn(i,x) for(int (i)=0;(i)<(x);(i)++)
#define foreach(i,x) for(auto (i):(x))
using namespace std;
typedef pair<LL,int>pii;
int n;
pii a[200010];
int ans;
signed main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i].first;
	sort(a,a+n);
	for(int i=n;i--;){
		if(a[i].second)continue;
		LL t=2LL<<__lg(a[i].first);
		int k=upper_bound(a,a+i,mp(t-a[i].first,0))-a;
		if(0<k&&k<=i&&a[i].first+a[k-1].first==t)ans++,a[k-1].second=1;
	}
	cout<<ans<<endl;
	return 0;
}


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

const int maxn=1e7+5;

char s[maxn];

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

    cin>>s+1;
    int len=strlen(s+1);
    int ans=0,pos=0;
    for(int i=1;i<=len;i++)
    {
        if(s[i]=='R' && !pos) pos=i;
        if(s[i]=='S' && pos) ans=max(ans,i-pos),pos=0;
    }
    if(pos) ans=max(ans,len-pos+1);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int count[4][3][10];
    int b=0,f=0,r=0,v=0;  //b = 棟, f = 階, r = 部屋, v = 人数
    int n;  //情報数
    for(int i = 0; i < 4;i++){
        for(int j = 0; j < 3;j++){
            for(int k = 0; k < 10; k++){
                count[i][j][k] = 0;   //0で初期化
            }
        }
    }
    scanf("%d",&n);
    for(int i = 0; i < n ;i++){
        scanf("%d %d %d %d\n",&b, &f, &r, &v);
        count[b-1][f-1][r-1] += v;     //要素番号は0から始まっているので入力した数に-1
    }
    
    for(int i = 0; i < 4;i++){
           for(int j = 0; j < 3;j++){
               for(int k = 0; k < 10; k++){
                   printf(" %d",count[i][j][k]);
                   if(k == 9){     //部屋数が10になったら開業
                       printf("\n");
                   }if(k == 9 && j == 2 && i < 3){
                       printf("####################\n");
                   }
               }
           }
       }
    return 0;
}




Measured memory_bytes: 2100
use proconio::input;
use std::f64::consts::PI;

fn main() {
    input! {
        a:f64,
        b:f64,
        h:f64,
        m:f64,
    }
    let kakua = (60.0 * h + m) / (12.0 * 60.0) * 2.0 * PI;
    let kakub = m / 60.0 * 2.0 * PI;

    let sina = kakua.sin() * a;
    let sinb = kakub.sin() * b;

    let cosa = kakua.cos() * a;
    let cosb = kakub.cos() * b;

    let ret = ((sina - sinb).abs().powi(2) + (cosa - cosb).abs().powi(2)).sqrt();

    println!("{}", ret);
}


Measured memory_bytes: 2956
n = int(input())
sp1 = [input().split() for i in range(n)]
sp = []
for i in range(len(sp1)):
  sp.append([i, sp1[i][0], int(sp1[i][1])])

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

for i in range(len(sp)):
  print(sp[i][0] + 1)


Measured memory_bytes: 3060
#include <cstdio>
 
using namespace std;
 
int main()
{
    long K, S;
 
    scanf("%ld %ld", &K, &S);
 
    long i, j, k, n;
    long long counter = 0;
  
    for (i = 0; i <= K; i++) {
        for (j = 0; j <= K; j++) {
            n = S - (i + j);
 
            if (0<= n && n <= K) counter++;
        }
    }
 
    printf("%lld\n", counter);
 
    return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
total_prob = 0
for i in range(1, n+1):
  dice_count = 0
  while (i << dice_count) < k:
    dice_count += 1
  
  total_prob += (1 / n) * (0.5 ** dice_count)
  
print(round(total_prob, 12))

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

class Program
{
    static void Main(string[] args)
    {
        int[] n = Read.Ints();
        string[] s = new string[n[0]];
        for(int i = 0; i < s.Length; i++)
        {
            s[i] = Console.ReadLine();
        }
        string[,] a = new string[n[0],n[1]];
        for(int i = 0; i < n[1] + 2; i++)
        {
            Console.Write("#");
        }Console.WriteLine();
        for(int i = 0; i < n[0]; i++)
        {
            Console.Write("#");Console.WriteLine(s[i]+"#");
        }
        for (int i = 0; i < n[1] + 2; i++)
        {
            Console.Write("#");
        }
        Console.WriteLine();
    }
    public static Boolean uso() { return false; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (int i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] Ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
	int a;
	while(cin>>a){
		while(a>39)a-=39;
		cout<<'3'<<'C';
		if(a<10)cout<<'0';
		cout<<a<<endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  map<int,int> mode;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    mode[x] += 1;
  }
  
  int count = 0;
  for (auto m : mode) {
    if (m.second >= m.first) count += m.second-m.first;
    else count += m.second;
  }
  cout << count << endl;
}

Measured memory_bytes: 4736
n, k = map(int, input().split())
st = input()
num = 0
state = 0
cumsum = []
for s in st:
    if int(s) == state:
        num += 1
    else:
        cumsum.append(num)
        state = [1, 0][state]
        num = 1
cumsum.append(num)
cumsum = [0] + cumsum + [0, 0]
if (len(cumsum) % 2) == 0:
    cumsum += [0]
l = min(k * 2, len(cumsum) - 1 - (len(cumsum) % 2))
sumsum = sum(cumsum[:l + 1])
max_sum = sumsum
start_idx = 0
end_idx = l + 1
if len(cumsum) - l + 1 > 3:
    for n in range(2, len(cumsum) - l + 1, 2):
        sumsum = (
            sumsum - sum(cumsum[start_idx: start_idx + 2])
            + sum(cumsum[end_idx: end_idx + 2])
        )
        start_idx += 2
        end_idx += 2
        max_sum = max(max_sum, sumsum)

print(max_sum)

Measured memory_bytes: 5748
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int c(int a){return a/100*60+a%100;}
int K[4000];
int main(){
  int n,s,g;
  while(cin>>n>>s>>g,n){
    memset(K,0,sizeof(K));
    s=c(s);
    g=c(g);
    r(i,n){
      int t;
      cin>>t;
      while(t--){
        int a,b;
        cin>>a>>b;
        a=c(a);
        b=c(b);
        K[a]++;
        K[b]--;
      }
    }
    int ans=0;
    int sum=0;
    int ch=0;
    for(int i=s;i<g;i++){
      sum+=K[i];
      if(sum!=n)ans++;
      else ans=0;
      ch=max(ch,ans);
    }
    cout<<ch<<endl;
  }
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i;
    cin>>n;
    long long a[n],c[3],x=0;
    for(i=0;i<n;++i)
        cin>>a[i];
    sort(a,a+n);
    for(i=n-1;i>0;--i)
    {
        if(a[i]==a[i-1])
        {
            c[x]=a[i];
            --i;
            ++x;
        }
        if(x==2)
        {
            cout<<c[0]*c[1]<<endl;
            return 0;
        }
    }
      cout<<"0"<<endl;
      return 0;
}


Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int d1,d2;
    cin >> N;
    int count=0;
    bool f=false;
    for(int i=0; i<N; i++) {
        cin >> d1 >> d2;
        if(d1 == d2) {
            count++;
        } else {
            count = 0;
        }
        if(count >= 3) {
            f=true;
            break;
        }

    }
    if(f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int x;
    cin >> x;

    ll ans = 0;
    ans += (x/500) * 1000;
    ans += ((x%500)/5) * 5;

    cout << ans << endl;

    return 0;
}


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

int main() {
    int n,k;
    string s;
    cin >> n >> k >> s;
    if(s.at(k-1) == 'A')s.at(k-1) = 'a';
    if(s.at(k-1) == 'B')s.at(k-1) = 'b';
    if(s.at(k-1) == 'C')s.at(k-1) = 'c';
    cout << s << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    int n, k; cin >> n >> k;
    int ans = 0;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    for(int i=0;i<n;i++){
        if(h[i]>=k){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String n = scan.next();

        if (n.charAt(0) == n.charAt(2)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21972
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int AC[100005];
int WA[100005];
int p[100005];
string s[100005];

int main(){
    int n,m;
    cin >> n>> m;
    int cor=0,pen=0;
    rep(i,m){
        cin >> p[i]>>s[i];
        if(s[i]=="AC"){
            if(AC[p[i]]==0){
                AC[p[i]]=1;
                cor++;
            }
        }else{
            if(AC[p[i]]==0){
                WA[p[i]]++;
            }
        }
    }
    rep(i,100005){
        if(AC[i]){
            pen+=WA[i];
        }
    }
    cout<<cor<<' '<<pen<<endl;
    return 0;
}



Measured memory_bytes: 6912
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

n, y = list(map(int, input().split()))


for i in range(max(n+1, y//10000)):
    y_new = y-10000*i
    n_new = n-i

    if (5000*n_new-y_new) % 4000 == 0:
        x = (5000*n_new-y_new) // 4000

        if n_new-x >= 0 and x >= 0:
            # print(y, i*10000+(n_new-x)*5000+x*1000)
            # print(n, i + n_new-x + x)
            print(i, n_new-x, x)
            exit()


print(-1, -1, -1)


Measured memory_bytes: 9120
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;




void Main(){
    ll N, D, A, x, h;
    cin >> N >> D >> A;
    vector<ll> xs(N);
    map<ll,ll> xhs;
    ll max_x = x;
    rep(i, N){
        sll(x);
        sll(h);
        xs[i] = x;
        xhs[x] = h;
        max_x = max(x, max_x);
    }

    vector<ll> cs;
    rep(i, N){
        x = xs[i];
        cs.emplace_back(x);
        if(x==max_x){
            continue;
        }
        cs.emplace_back(x+2*D+1);
    }
    sort(cs.begin(), cs.end());
    cs.erase(unique(cs.begin(), cs.end()), cs.end());

    map<ll,ll> a2c;
    rep(i, cs.size()){
        x = cs[i];
        a2c[x] = i;
    }
    // cout << cs <<endl;
    // cout << a2c << endl;

    ll prev_x = -1;
    ll next_x = -1;
    ll now_num = 0, st_c, ed_c, now_dm,left_h, this_n;
    ll ans = 0;
    vector<ll> imos(cs.size(), 0);
    rep(i, cs.size()){
        x = cs[i];
        // cout << "i=" <<i << ", cs[i]=" << x  << " imos[i] = " << imos[i];
        if(xhs.find(x)==xhs.end()){
            // cout << " only end, now_num=" << now_num <<endl;
            now_num += imos[i];
            continue;
        }
        now_num += imos[i];
        // cout << " now num=" << now_num <<endl;
        h = xhs[x];
        now_dm = now_num * A;
        left_h = h - now_dm;
        if(left_h <= 0){
            // cout << "h=" << left_h << " < 0, continue" <<endl;
            continue;
        }
        this_n = (left_h-1) / A + 1;
        imos[i] += this_n;
        ans += this_n;
        now_num += this_n;
        if(x == max_x){
            break;
        }
        ed_c = a2c[x+2*D+1];
        imos[ed_c] -= this_n;
        
    }
    cout << ans <<endl;
}

int main(){
    Main();
}

Measured memory_bytes: 48320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	ll n;
	cin >> n;
	ll x = sqrt(n);
	for(int i=x; i>=1; i--){
		if(n % i == 0){
			x = i;
			break;
		}
		if(i == 1) x = 1;
	}
	ll y = n/x;
	ll ans = x+y-2;
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll r,d,x,i;
	ll ans[11];
	cin >> r >> d >> x;
	ans[0] = x;
	fr(i,1,11)
	{
		ans[i] = r*ans[i-1] - d;
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 256
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n, k;
    scn(n); scn(k);

    set<int> dislikes;
    set<int> aval = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

    rep(i, 0, k) {
        int val; 
        scn(val);
        dislikes.insert(val);
        aval.erase(val);
    }

    vector<char> digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    bool used = 0;
    string s = to_string(n);

    rep(i, 0, s.size()) {
        int here = s[i] - '0';
        if(used) {
            auto j = aval.begin();
            if(*j < here) {
                s[i] = digit[*j];
            }
            continue;
        }
        if(dislikes.count(here)) {
            auto j = aval.upper_bound(here);
            if(j == aval.end()) {
                j = aval.begin();
                s[i] = digit[*j];
                for(int j=i-1; j>=0; j--) {
                    auto it = aval.upper_bound(s[j]);
                    if(it == aval.end()) 
                        s[i] = digit[*aval.begin()];
                    else {
                        s[i] = digit[*it]; 
                        break;
                    }
                }
            } else {
                s[i] = digit[*j];
                used = 1;
            }
        }
    }

    string org = to_string(n);

    if(s < org) {
        auto it = aval.begin();
        s += digit[*it];
    }

    cout << s << '\n';
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007

int main(){
  ll N, K, i, count1 = 0, count2 = 0;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N){
    cin >> A[i];
  }

  rep(i, N){
    for(int j = i + 1; j < N; j++){
      if(A[i] > A[j]){
        count1++;
      } else if(A[j] > A[i]){
        count2++;
      }
    }
  }
  ll each = count1*K % MOD;
  ll other = (count1 + count2)*(K*(K-1)/2 % MOD) % MOD;

  cout << (each + other) % MOD << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s>>s;
    int cnt=0,ans=0;
    for(char c:s){
        if(c=='I')cnt++;
        else cnt--;
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s,t; cin >> s >> t;
  vector<vector<int>> inds(26);
  REP(i,s.size()){
    inds[s[i]-'a'].push_back(i);
  }
  int ind = 0;
  int cnt = 0;
  bool flag = true;
  for(auto c: t){
    if(inds[c-'a'].size()==0){
      flag = false;
      break;
    }
    auto itr = lower_bound(ALL(inds[c-'a']), ind);
    if(itr==inds[c-'a'].end()){
      cnt++;
      ind = inds[c-'a'][0]+1;
    }else{
      ind = (*itr) + 1;
    }
  }
  if(flag) cout << cnt*s.size() + ind << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 4176
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b % a == 0) {
			System.out.println(a+b);
		}else {
			System.out.println(b-a);
		}
	}
	
}

Measured memory_bytes: 23760
object Main extends App {
  val n = io.StdIn.readLine.toInt
  val ans = Iterator.continually(io.StdIn.readLine.split(" "))
    .take(n)
    .map(in => {
      val c = in(0).toInt - in(1).toInt - in(2).toInt
      if (c < 0 || (c & 1) == 1) false else true
    })
    .forall(_ == true)
//    .takeWhile(_ == true)
//    .size

  println(if(ans) "Yes" else "No")
}

Measured memory_bytes: 43236
#include <stdio.h>

int main() {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b && b<=c){
    printf("%d %d %d\n",a,b,c);
    }else if(a<=c && c<=b){
            printf("%d %d %d\n",a,c,b);
    }else if(b<=a && a<=c){
       printf("%d %d %d\n",b,a,c);
    }else if(b<=c && c<=a){
        printf("%d %d %d\n",b,c,a);
    }else if(c<=a && a<=b){
        printf("%d %d %d\n",c,a,b);
    }else if(c<=a && b<=a){
        printf("%d %d %d\n",c,b,a);
    }
    return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(),a.end());
    vector<ll> sum(n+1);
    sum[0]=0;
    for(int i=0; i<n; i++) sum[i+1] = sum[i] + a[i];
    int cnt=n;
    for(int i=0; i<n; i++){
        if(2*sum[i]<a[i]){
            cnt=n-i;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int h,w;cin>>h>>w;
  vector<string> a(h);
  for(int i=0;i<h;i++){
    cin>>a[i];
  }
  string wall(w+2,'#');
  cout<<wall<<endl;
  for(int i=0;i<h;i++){
    cout<<"#"<<a[i]<<"#"<<endl;
  }
  cout<<wall<<endl;
  return 0;
}


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

namespace ABC159A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);
            int ans = N * (N - 1) / 2 + M * (M - 1) / 2;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27532
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

R, G, B, N = MAP()
ans = 0
for i in range(N//R+1):
	r = i
	for j in range((N-R*r)//G + 1):
		g = j
		b = (N - R*r - G*g) / B
		if b == b//1 and 0 <= b:
			ans += 1

print(ans)

Measured memory_bytes: 61800
fun main(args: Array<String>) = yorukatsu19c()

fun yorukatsu19c() {
    val n = readLine()!!.toInt()
    val sList = (1..n).map { readLine()!!.toCharArray().sorted() }

    val answer = sList.groupBy { it }.map { it.value.size.toLong() }
        .fold(0L) { acc, l -> acc + (l - 1) * l / 2 }

    println(answer)
}


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

int main()
{
  int a,b,c;
  cin >> a>> b>> c;
  c += b * 10 + a * 100;
  if(c % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3536
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()
#define x first
#define y second
 
const int inf = 2e9 + 100;
const int maxn = 2e5 + 100;
 
int a[maxn], ans[maxn], d[maxn];
vector<int> g[maxn];
int n;
 
void dfs(int v, int p = -1) {
    int j = lower_bound(d + 1, d + n, a[v]) - d;
    int f = 0;
    int was = 0;
    int id = -1;
    if (a[v] < d[j]) {
        f = 1;
        was = d[j];
        id = j;
        d[j] = a[v];
        ans[v] = j;
    }
    ans[v] = max(ans[v], (p != -1 ? ans[p] : 1));
    for (auto u : g[v]) {
        if (u == p) {
            continue;
        }
        dfs(u, v);
    }
    if (f) {
        d[id] = was;
    }
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
 
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        d[i] = inf;
    }
    d[0] = -inf;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }
 
    return 0;
}

Measured memory_bytes: 33564
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
void Yay(bool condition){

    if(condition){
        p("Yay!");
    }else{
        p(":(");
    }
    return;
}

//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[500005],y[500005],z[500005];
long double l[5000];
char s[500005],t[500005];
ll ans;

bool flag,dame;
ll timesize = 0;
ll xmin = INF,xmax = -INF,ymin = INF,ymax = -INF;
ll flag_num = 0;
bool float_flag = false;

int main(){
	cin >> n >> m >> a >> b;
	ps((long double)n*m/2);
	if(a == n / 2 && b == m / 2 && n % 2 == 0 && m % 2 == 0){
		p(1);
	}else{
		p(0);
	}
	
	return 0;
}


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

int main(int argc, char **argv) {
  double W, H;
  double x, y;
  double a;
  double ans = 0;
  int ans2 = 0;

  cin >> W >> H;
  cin >> x >> y;

  ans = (((long double)(W * H)) / 2);

  if (x == W / 2 && y == H / 2)
    ans2 = 1;


  printf("%.9lf %d\n", ans, ans2);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int xp1,yp1,xp2,yp2;
int q;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>xp1>>yp1>>xp2>>yp2;
    cin>>q;
    auto va = P(xp2-xp1,yp2-yp1);
    for(int i=0; i<q; i++){
        int x,y; cin>>x>>y;
        auto vb=P(x-xp1,y-yp1);
        Int vab=va.first*vb.first+va.second*vb.second;
        Int vaa=va.first*va.first+va.second*va.second;
        pair<double,double> oh;
        oh.first=(double)va.first*vab/vaa;
        oh.second=(double)va.second*vab/vaa;
        double xans=oh.first+xp1/1.000000000;
        double yans=oh.second+yp1/1.000000000;
        cout<<fixed<<setprecision(10)<<(double)(xans*2.0-x/1.0)<<" "<<fixed<<setprecision(10)<<(double)(yans*2.0-y/1.0)<<endl;
    }


    return 0;
}


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

#define ll long long int 
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i)) 
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main()
{
	_fastio
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<en;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(void){
    int c[6];
    for(int i=0;i<6;i++){
        cin >> c[i];
    }
    if(1*c[0]+5*c[1]+10*c[2]+50*c[3]+100*c[4]+500*c[5]>=1000){
        cout << '1';
    }else{
        cout << '0';
    }
    cout << endl;
}



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

int N, L;

int main(int argc, char const* argv[])
{
    std::cin >> N >> L;
    int sum = 0;
    if (L > 0) {
        for (int i = 1; i < N; i++) {
            sum += L + i;
        }
    }
    else if (L <= 0 && L+N-1 >= 0) {
        for (int i = 0; i < N; i++) {
            sum += L + i;
        }
    }
    else {
        for (int i = 0; i < N-1; i++) {
            sum += L + i;
        }
    }
    std::cout << sum << std::endl;
    return 0;
}


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


using namespace std;


int main()
{
	int x, y;
	string op;

	while(1){
		cin >> x >> op >> y;

		if(op == "+")
			cout << x + y << endl;
		else if(op == "-")
			cout << x - y << endl;
		else if(op == "*")
			cout << x * y << endl;
		else if(op == "/")
			cout << x / y << endl;
		else
			break;
	}

	return 0;
}


Measured memory_bytes: 3156
# UnionFind木
class UnionFind():
    def __init__(self, n):
        # その節の根、その節を含む木の高さ、その節が根の時の木のノード数
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    # 根を検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 木のノード数を得る
    def getSize(self, x):
        return self.size[self.find(x)]

def main():
    N,M,K = map(int, input().split())
    # 広義の友達 - 直接の友達 - ブロック
    # UnionFind木
    uftree = UnionFind(N)
    count = [0] * N
    for i in range(M):
        A,B = map(lambda x:x-1, map(int, input().split()))
        uftree.union(A,B)
        count[A] += 1
        count[B] += 1
    for i in range(K):
        C,D = map(lambda x:x-1, map(int, input().split()))
        if uftree.same_check(C,D):
            count[C] += 1
            count[D] += 1
    ans = [0] * N
    for i in range(N):
        ans[i] = uftree.getSize(i) - 1 - count[i] # 真ん中の-1は自分自身
    print(*ans)

main()


Measured memory_bytes: 15696
N = int(input())
L = list(map(int, input().split()))

L.sort()
count = 0

for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
        for k in range(j+1, len(L)):
            if L[i] + L[j] > L[k] and L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                count += 1

print(count)


Measured memory_bytes: 73472
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
signed main(){
    int h,w,cnt=0;
    cin>>h>>w;
    rep(i,h)
        rep(i,w){
            char c;
            cin>>c;
            if(c=='#')cnt++;
        };
    if(cnt==h+w-1)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

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

int main(){
    int a,b;
    cin >>a>>b;
    if(a<=9&&b<=9) cout<<a*b<<endl;
    else cout<<-1<<endl;
}

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


using namespace std;

const int inf = 100000;

int dis[10][10];
int m;

void floyd()
{
	for (int k = 0; k < m; k++)
		for (int i = 0; i < m; i++)
			for (int j = 0; j < m; j++)
				if (dis[i][k] + dis[k][j] < dis[i][j])
					dis[i][j] = dis[i][k] + dis[k][j];
}

int main()
{
	int n, a, b, c;
	int tmp, ans, p;
	
	while (cin >> n && n)
	{
		for (int i = 0; i < 10; i++)
			for (int j = 0; j < 10; j++)
				dis[i][j] = inf;
		m = 0;
		ans = inf;
		while (n--)
		{
			cin >> a >> b >> c;
			dis[a][b] = c;
			dis[b][a] = c;
			m = max(m, max(a + 1, b + 1));
		}
		
		floyd();
		for (int i = 0; i < m; i++)
		{
			tmp = 0;
			for (int j = 0; j < m; j++)
			{
				if (i == j)
					continue;
				tmp += dis[i][j];
				if (tmp > inf)
					break;
			}
			if (tmp < ans)
			{
				ans = tmp;
				p = i;
			}
		}
		cout << p << ' ' << ans << endl;
	}
	

	return 0;
}


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


int selectionSort(int A[], int N){
    int cnt = 0;
    int minj;
    for(int i = 0; i < N; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(A[j] < A[minj]) minj = j;
        }
        if(A[i] != A[minj]){
            swap(A[i], A[minj]);
            cnt++;
        }
    }
    return cnt;
}

int main(){
    int A[100], N, sw;
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];

    sw = selectionSort(A, N);

    for(int i=0; i<N; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << sw << endl;

    return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>
int main(){
  int i,j;
  char a[200001];
  scanf("%s",a);
  int m=strlen(a);
  for(i=0;i<m;i++)if(a[i]=='A')break;
  for(j=m-1;j>i;j--)if(a[j]=='Z')break;
  printf("%d",j-i+1);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    /*string S;
    cin >> S;
    if(S[2]==S[3]&&S[4]==S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;*/

    /*int x;
    int happy = 0,temp;
    //bool b = true;
    cin >> x;
    happy += (x/500)*1000;
    x = x%500;
    happy += (x/5)*5;
    cout << happy << endl;
    return 0;*/

    /*int k,n;
    int flag = 0;
    int a[n]={};
    cin >> k >> n;
    rep(i,n) cin >> a[i];
    rep(i,n){
        if()
    }*/

    /*int A,B;
    cin >> A >> B;
    for(int i=1; i<=B; i++){
        if((A*i)%B==0){
            cout << A*i << endl;
            break;
        }
    }
    return 0;*/

    int X,Y,Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y;
}

Measured memory_bytes: 256
N,K = gets.split.map(&:to_i)
s = gets.chomp
d = []
prev = "1"
cnt = 0
s.each_char do |c|
  if prev != c
    d << cnt
    cnt = 1
    prev = c
  else
    cnt += 1
  end
end
d << cnt
#p d
ans = 0
if d.length/2 <= K
  p d.reduce(:+)
  exit
end
ans = d[0,K*2+1].reduce(:+)
t = ans
(d.length/2-K).times do |i|
  t = t - d[i*2] - d[i*2+1] + d[K*2+i*2+1]
  t += d[K*2+i*2+2] if K*2+i*2+2 < d.length
  ans = t if t > ans
  #p t
end
p ans


Measured memory_bytes: 3068
R,C,n=map(int,raw_input().split())
pair=[map(int,raw_input().split()) for _ in xrange(n)]
u=[]
r=[]
d=[]
l=[]
for i in xrange(n):
    x1,y1,x2,y2=pair[i]
    if 0<x1<R and 0<y1<C:continue
    if 0<x2<R and 0<y2<C:continue
    if x1==0:
        u.append([y1,i])
    if x1==R:
        d.append([y1,i])
    if y1==0:
        if x1!=0 and x1!=R:
            l.append([x1,i])
    if y1==C:
        if x1!=0 and x1!=R:
            r.append([x1,i])
    if x2==0:
        u.append([y2,i])
    if x2==R:
        d.append([y2,i])
    if y2==0:
        if x2!=0 and x2!=R:
            l.append([x2,i])
    if y2==C:
        if x2!=0 and x2!=R:
            r.append([x2,i])
u.sort()
r.sort()
d.sort(reverse=True)
l.sort(reverse=True)
urdl=u+r+d+l
stack=[]
for i in xrange(len(urdl)):
    if len(stack)==0:
        stack.append(urdl[i][1])
    elif stack[-1]==urdl[i][1]:
        stack.pop()
    else:
        stack.append(urdl[i][1])
print "YES" if len(stack)==0 else "NO"


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  string n;
  cin >> n;
  // sort(n.begin(), n.end());
  rep(i, n.length() - 1)
  {
    if (n[i] == n[i + 1])
    {
      pr("Bad");
      return 0;
    }
  }
  pr("Good");
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
main() {
    int res = 0, last = 0;
    string s, t;
    vector<int> m[30];
    cin >> s >> t;
    rep(i, s.size()) {
        m[s[i] - 'a'].push_back(i + 1);
    }
    rep(i, t.size()) {
        int c = t[i] - 'a';
        if(!m[c].size()) {
            cout << -1;
            return 0;
        }
        if(m[c][m[c].size() - 1] <= last) res++, last = 0;
        last = *upper_bound(all(m[c]), last);
    }
    cout << res * s.size() + last;
}


Measured memory_bytes: 1216
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9) cout << "hon";
    else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) cout << "pon";
    else cout << "bon";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3688
n, m = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a] = 1 if a not in d else d[a] + 1
for _ in range(m):
    b, c = map(int, input().split())
    d[c] = b if c not in d else d[c] + b
ans = 0
cnt = 0
L = sorted(d, reverse=True)
for k in L:
    if d[k] + cnt < n:
        ans += k * d[k]
        cnt += d[k]
    else:
        ans += k * (n - cnt)
        break
print(ans)


Measured memory_bytes: 32064