akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 100
#define INF 1<<21
int G[N][N], n, labels[N], d[N], p[N];

int min(int x, int y){
    return (x>=y) ? y: x;
}


void dijkstra(int s) {
    int i;
    for(i=0; i<n; i++) {
	d[i]=INF;
	labels[i]=0;
    }
    d[s]=0;
    while (1){
	int u,v=-1;
	for(u=0; u<n; u++){
	    if(labels[u]==0 && (v == -1 || d[u] < d[v])) v=u;
	}
	if (v==-1) break;
	labels[v]=1;
	for(u=0; u<n; u++){
	    if(labels[u]!=1) d[u] = min(d[u], d[v]+G[v][u]);
	}
    }

}

int main(){
    int i,j,k,v,c,u;
    scanf("%d",&n);

    for(i=0;i<n; i++){
	for(j=0;j<n;j++){
	    G[i][j]=INF;
	}
    }
    
    for(i=0;i<n;i++){
	scanf("%d %d",&u, &k);
	for(j=0;j<k;j++){
	    scanf("%d %d",&v, &c);
	    G[u][v]=c;
	}
    }
    
    dijkstra(0);
    for(i=0;i<n;i++){
	printf("%d %d\n",i, d[i]);
    }

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    
    ll n;
    ld d;
    cin >> n >> d;

    vector<ld> v;
    for (int i = 1; i <= n; i++)
    {
        ld a, b;
        cin >> a >> b;
        ld res = sqrt((a * a) + (b * b));

        v.push_back(res);
    }

    int c = 0;
    for (auto i : v)
        if (i <= d) c++;

    cout << c << endl;
    
    return 0;
}

Measured memory_bytes: 7056
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a==b)
    cout << c << endl;
  else if(b==c)
    cout << a << endl;
  else
    cout << b << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

bool IsPrime(int num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {

            return false;
        }
    }

    return true;
}

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int k = n;
    if (IsPrime(m)) {
        cout << 1 << endl;
        return 0;
    }
    while (m % k != 0) {
        k++;
    }
    cout << m / k << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#define M 1046527
#define NIL (-1)
#define L 14
using namespace std;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int INFTY = (1<<20);
static const int MAX =10000;

char H[M][L];

int getChar(char ch){
    if(ch == 'A')return 1;
    else if(ch == 'C')return 2;
    else if(ch == 'G')return 3;
    else if(ch == 'T')return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for(i = 0; i < strlen(str); i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1 + (key % (M -1));}

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h],str) == 0)return 1;
        else if(strlen(H[h]) == 0)return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key,i,h;
    key = getKey(str);
    for(i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h],str) == 0)return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i = 0; i < M; i++)H[i][0] = '\0';
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> com >> str;
        if(com[0] == 'i'){
            insert(str);
        }else{
            if(find(str)){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17416
#include<stdio.h>
#define  N 10000
int Height(int);
void print(int);
int Sibling(int);
void Depth(int,int);
struct Node{
  int parent;
  int left;
  int right;
};
struct Node T[N];
int n,D[N],H[N];

int main(){
  int p,l,r,root=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].parent=-1;
  for(i=0;i<n;i++){
    scanf("%d%d%d",&p,&l,&r);
    T[p].left=l;
    T[p].right=r;
    if(l!=-1)T[l].parent=p;
    if(r!=-1)T[r].parent=p;
  }
  for(i=0;i<n;i++)
    if(T[i].parent==-1)
      root=i;
  Depth(root,0);
  Height(root);
  
  for(i=0;i<n;i++)
    print(i);
  return 0;
}

int Sibling(int a){
  if(T[a].parent==-1)return -1;
  if(T[T[a].parent].left !=a && T[T[a].parent].left != -1)
    return T[T[a].parent].left;
  if(T[T[a].parent].right !=a && T[T[a].parent].right != -1)
    return T[T[a].parent].right;
  return -1;
}

void Depth(int a,int b){
  if(a==-1) return;
  D[a]=b;
  Depth(T[a].left,b+1);
  Depth(T[a].right,b+1);
}

int Height(int a){
  int h1=0,h2=0;
  if(T[a].left!=-1)
    h1=Height(T[a].left)+1;
  if(T[a].right!=-1)
    h2=Height(T[a].right)+1;
  return H[a]=(h1>h2?h1:h2);
}

void print(int a){
  int d=0;
  printf("node %d:",a);
  printf(" parent = %d,",T[a].parent);
  printf(" sibling = %d,",Sibling(a));
  if(T[a].left!=-1) d++;
  if(T[a].right!=-1) d++;
  printf(" degree = %d,",d);
  printf(" depth = %d,",D[a]);
  printf(" height = %d,",H[a]);
  if(T[a].parent==-1){
    printf(" root");
  }
  else if(T[a].left==-1 && T[a].right==-1){
    printf(" leaf");
  }
  else printf(" internal node");
  printf("\n");
}
  

Measured memory_bytes: 616
#include <iostream>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if(a > b){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }
    ans += max(a, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=5e5+5;
int n,l,r;
double ans,ll,v,d[N][2];
int read()
{
	char ch=getchar();
	int x=0;
	while (ch<'0' || ch>'9') ch=getchar();
	while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
void merge(int x)
{
	d[x][0]=(d[x][0]*d[x][1]+d[x+1][0]*d[x+1][1])/(d[x][1]+d[x+1][1]);
	d[x][1]+=d[x+1][1];
}
int main()
{
	n=read(),ll=read(),l=1;
	for (int i=1;i<=n;i++)
	{
		d[++r][0]=read(),d[r][1]=read();
		v+=d[r][1],ans+=d[r][0]*d[r][1];
		while (v>ll)
		{
			if (v-d[l][1]>=ll)
			{
				v-=d[l][1];
				ans-=d[l][0]*d[l][1];
				l++;
			}
			else
			{
				d[l][1]-=v-ll;
				ans-=(v-ll)*d[l][0];
				v=ll;
			}
		}
		while (r>l && d[r][0]<=d[r-1][0]) merge(--r);
		printf("%lf\n",ans/ll);
	}
	return 0;
}


Measured memory_bytes: 16256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def digsum(n):
    return n if  n//10 == 0 else n%10 + digsum(n//10)

def solve():
    n, a, b = f()

    ans = 0
    for i in range(1,n+1):
        if digsum(i)>= a and digsum(i)<= b:
            ans += i
    
    print(ans)

solve()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,N;
  cin >> A >> B >> N;
  if(N<B){
    cout << floor(A*N/B)-A*floor(N/B);
  }else {
    cout << floor(A*(B-1.0)/B)-A*floor((B-1.0)/B);
  }
}


Measured memory_bytes: 3764
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype>  // isupper, islower, isdigit, toupper, tolower
#include <cmath>   // abs, sin, cos, tan
#include <ctime>   // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  vll a(n); rep(i, n) { cin >> a[i]; a[i] *= 2;}
  vll b(n, 0);
  /*
    b[0] = a[0] - a[1] + a[2]
  */
  for(ll i = 1;i < n;i += 2)
  {
    a[i] *= -1;
  }
  rep(i, n)
  {
    b[0] += a[i] / 2;
  }
  for(ll i = 1;i < n;i += 2)
  {
    a[i] *= -1;
  }
  b[n - 1] = a[n - 1] - b[0];
  for(ll i = n - 2;1 <= i;i--)
  {
    b[i] = a[i] - b[i + 1];
  }
  rep(i, n)
  {
    cout << b[i] << (i != n - 1?" ":"\n");
  }
  return;
}

//前処理
int main()
{
  int ti = clock();
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 2944
#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

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

  string before, term; // 直前のterm
  before = S.front();
  int ans = 1;
  for (auto it = S.begin() + 1; it != S.end(); ++it) {
    if (term.length() == 0) {
      if (before.length() == 1 && before[0] == *it)
        term += *it;
      else {
        ++ans;
        before = term + *it;
        term = "";
      }
    } else {
      ++ans;
      before = term + *it;
      term = "";
    }
  }
  OUT(ans);

  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long

int main(void)
{
    ll n; cin>>n;
    vector<ll> v(1e7,0);
    ll ans=0;
    rep(i,n){
        ll a,b; cin>>a>>b;
        a--;
        v[a]++;
        v[b]--;
    }
    for(int i=1;i<=n;i++){
        v[i]+=v[i-1];
        if(v[i]>=i) ans=i;
    }
    cout<<ans<<endl;
    return 0;
} 


Measured memory_bytes: 80968
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
using namespace std;

int main()
{
  int N, T, L, B;
  while (cin >> N >> T >> L >> B && N != 0) {
    set<int> lose, back;
    for (int i = 0; i < L; i++) {
      int x;
      cin >> x;
      lose.insert(x);
    }
    for (int i = 0; i < B; i++) {
      int x;
      cin >> x;
      back.insert(x);
    }

    vector<vector<double> > prob(T+1, vector<double>(N, 0.0));
    prob[0][0] = 1.0;
    double ans = 0.0;
    for (int t = 0; t < T; t++) {
      for (int i = 0; i < N; i++) {
        for (int dice = 1; dice <= 6; dice++) {
          int next = i + dice;
          if (next == N) {
            ans += prob[t][i]/6.0;
          } else {
            if (next > N) {
              next = N-(next-N);
            }
            if (lose.count(next)) {
              if (t+2 < T+1) {
                prob[t+2][next] += prob[t][i]/6.0;
              }
            } else if (back.count(next)) {
              prob[t+1][0] += prob[t][i]/6.0;
            } else {
              prob[t+1][next] += prob[t][i]/6.0;
            }
          }
        }
      }
    }
    printf("%.6f\n", ans);
  }
  return 0;
}

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

int main(){
  int a,b;scanf("%d%d",&a,&b);
  double ret=0;
  for(int i=1;i<=a;i++){
double tmp=1.0/a; int now=i; while(now<b){
now*=2;
tmp/=2; }
ret+=tmp; }
printf("%.12f\n",ret); }

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,N,res=0,sum=0,ans=inf;
  cin>>N;
  vec v(N);
  rep(i,N){
    cin>>v[i];
    sum+=v[i];
  }
  rep(i,N){
    sum-=v[i];
    res+=v[i];
    chmin(ans,(ll)labs(sum-res));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		long[][][] map = new long[101][10][1001];
		for (int n = 0; n < map.length; n++) {
			for (int i = 0; i < map[0].length; i++) {
				for (int j = 0; j < map[0][0].length; j++) {
					map[n][i][j] = 0;
				}
			}
		}
		map[0][0][0] = 1;
		map[0][1][0] = 1;
		
		for (int n = 1; n < map.length; n++) {
			
			map[n][0] = map[n - 1][0];
			
			for (int i = 1; i < map[0].length; i++) {
				for (int j = 0; j < map[0][0].length; j++) {
					if (j < n) map[n][i][j] = map[n - 1][i][j];
					else map[n][i][j] = map[n - 1][i - 1][j - n] + map[n - 1][i][j];
				}
			}
		}
		
		while (sc.hasNextLine() == true) {
			String[] nico = sc.nextLine().split(" ");
			int n = Integer.parseInt(nico[0]);
			int s = Integer.parseInt(nico[1]);
			if ((n == 0) && (s == 0)) break;
			
			System.out.println(map[100][n][s]);
		}
	}
}

Measured memory_bytes: 36152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,sum;
  sum=0;
  cin >> N;
  for(int i=0;i<N;i++){
  	int a,b;
    cin >> a >> b;
    sum += (b-a+1);
  }
  cout << sum << endl;
}

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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string s;
  cin >> s;
  ll N = s.size();
  vector<ll> vec;
  ll flag = 0;
  REP(i,N){
    if(s.at(i)=='A'){
      if(flag==1){
        vec.push_back(2);
        flag=0;
      }
      vec.push_back(0);
    }else if(i!=N-1&&s.at(i)=='B'&&s.at(i+1)=='C'){
      if(flag==1){
        vec.push_back(2);
        flag=0;
      }
      vec.push_back(1);
      i++;
    }else{
      flag = 1;
    }
  }
  if(flag==1){
    vec.push_back(2);
  }

  vector<ll> vec2(vec.size(),0);
  ll sum = 0;
  REPR(i,vec.size()-1){
    if(vec.at(i)==1){
      sum++;
      vec2.at(i)=sum;
    }else if(vec.at(i)==2){
      sum=0;
    }else{
      vec2.at(i)=sum;
    }
  }

  ll ans = 0;
  REP(i,vec.size()){
    if(vec.at(i)==0){
      ans+=vec2.at(i);
    }
  }
  cout << ans << endl;
}

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

immutable long inf = 10L^^15;

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

    auto h = new int[](n);
    auto p = new int[](n);
    auto hp = new int[](n);

    foreach (i ; 0 .. n) {
        scan(h[i], p[i]);
        hp[i] = h[i] + p[i];
    }

    sort(zip(hp, h, p));

    debug {
        writeln(hp);
        writeln(h);
        writeln(p);
    }

    auto dp = new long[][](n + 1, n + 1);
    fillAll(dp, inf);
    dp[0][0] = 0;

    foreach (i ; 1 .. n + 1) {
        foreach (j ; 0 .. n + 1) {
            dp[i][j] = dp[i-1][j];

            if (j-1 >= 0 && dp[i-1][j-1] <= h[i-1]) {
                dp[i][j] = min(dp[i][j], dp[i-1][j-1] + p[i-1]);
            }
        }
    }

    debug {
        writefln("%(%(%s %)\n%)", dp);
    }

    int ans;

    foreach (i ; 1 .. n + 1) {
        if (dp[n][i] < inf) ans = i;
    }

    writeln(ans);

}



struct UnionFind {
    private {
        int N;
        int[] p;
        int[] rank;
    }

    this (int n) {
        N = n;
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x) {
        if (p[x] != x) {
            p[x] = find_root(p[x]);
        }

        return p[x];
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        int u = find_root(x), v = find_root(y);

        if (u == v) return;

        if (rank[u] < rank[v]) {
            p[u] = v;
        }
        else {
            p[v] = u;

            if (rank[u] == rank[v]) {
                rank[u]++;
            }
        }
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    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);
        }
    }
}



struct Queue(T) {
    private {
        int N, head, tail;
        T[] data;
    }

    this(int n) {
        N = n + 1;
        data = new T[](N);
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return (tail + 1) % N == head;
    }

    T front() {
        return data[head];
    }

    void push(T x) {
        assert(!full);
        data[tail++] = x;
        tail %= N;
    }

    void pop() {
        assert(!empty);
        head = (head + 1) % N;
    }

    void clear() {
        head = tail = 0;
    }
}

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

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define btoe(x) x.begin(), x.end()
#define trim_chains(x) (x).resize(unique(btoe(x)) - (x).begin())
#define remove_dups(x) sort(btoe(x)); trim_chains(x);
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<long>;
using vll = vector<ll>;
using vb  = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vector<int> >;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

int main()
{
    FASTIO;
    ll n, m, k;
    cin >> n >> m >> k;
    vll a(n), b(m);
    rep(i, 0, n-1) cin >> a[i];
    rep(i, 0, m-1) cin >> b[i];

    vll ca(n), cb(m);
    ca[0] = a[0], cb[0] = b[0];

    rep(i, 1, n-1) ca[i] = a[i] + ca[i-1];
    rep(i, 1, m-1) cb[i] = b[i] + cb[i-1];

    int ans = 0;
    rep(i, 0, n) {
        ll asum = (i > 0 ? ca[i-1] : 0);
        ll rem = k - asum;
        if(rem == 0) ans = max(ans, i);
        else if(rem < 0) break;
        else {
            auto bidx = upper_bound(btoe(cb), rem);
            int bcnt = 0;
            if(bidx != cb.begin() && bidx != cb.end())
                bcnt = bidx - cb.begin();
            if(bidx == cb.end())
                bcnt = cb.size();

            ans = max(ans, i + bcnt);
        }
    }

    cout << ans << nl;
    return 0;
}


Measured memory_bytes: 9480
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  string s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  int x[26]={};
  for(int i=0;i<(int)s[0].size();i++)
    x[s[0][i]-'a']++;
  
  for(int i=0;i<n;i++){
    int y[26]={};
    for(int j=0;j<(int)s[i].size();j++)
      y[s[i][j]-'a']++;
    for(int j=0;j<26;j++) x[j]=min(x[j],y[j]);
  }
  string ans;
  for(int i=0;i<26;i++){
    for(int j=0;j<x[i];j++){
      ans+=(char)('a'+i);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

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

d = {}
for i in a:
    if i not in d.keys():
        d[i] = 1 
    else:
        d[i] += 1

org = 0 
for i in d.keys():
    org += d[i]*(d[i]-1)//2

for i in a:
    ans = org - d[i]*(d[i]-1)//2 + (d[i]-1)*(d[i]-2)//2
    print(ans)


Measured memory_bytes: 24996
n = gets.chomp.to_i
k = gets.chomp.to_i
x = gets.split().map(&:to_i)
ans = 0
x.each do |r|
  a1 = r * 2
  b1 = (r - k).abs * 2
  if a1 > b1
    ans += b1
  else
    ans += a1
  end
end

puts ans

Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>
int main(void){
	int i,j,n;
	int taro=0,hana=0;
	char t[101],h[101];

	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%s %s",&t,&h);
		j=strcmp(t,h);
		if (j>0) taro+=3;
		else if (j<0) hana+=3;
		else {taro++;hana++;}
	}
	printf("%d %d\n",taro,hana);
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n; cin >> n;
        vector<int> a(n); cin >> a;
        for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1]) {
                        a[i]++;
                        if (a[i] < a[i - 1]) {
                                cout << "No";
                                return;
                        }
                }
        }

        cout << "Yes";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3704
#include<iostream>
using namespace std;
int main()
{
	int n,ans=1e9;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<=100;i++)
	{
		int sum=0;
		for(int j=0;j<n;j++)
		{
			sum+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

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;
typedef pair<int,int> P;

int main(void){
  int n; cin >> n;
  pair<pair<string, int>, int> s[110];
  rep(i,n){
    string st;
    cin >> st;
    int p; cin >> p;
    s[i] = make_pair(make_pair(st,-p), i+1);
  }
  sort(s,s+n);
  for(int i = 0; i < n; i++){
    cout << s[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;

int n,m;
char s[105][105];
int dp[105][105];

signed main(){
	memset(dp,127,sizeof dp);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	dp[1][1] = s[1][1] == '#';
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i == j && i == 1)continue;
			if(j >= 2){
				if(s[i][j] == '#' && s[i][j-1] == '.' && j>=2)
					dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
				else dp[i][j] = min(dp[i][j], dp[i][j-1]);
			}
			if(i >= 2){
				if(s[i][j] == '#' && s[i-1][j] == '.' && i>=2)
					dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
				else dp[i][j] = min(dp[i][j], dp[i-1][j]);
			}
		}
	}
	printf("%d\n",dp[n][m]);

	return 0;
}



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

typedef long long ll;
ll n, mod = 1e9+7, dp[61][3];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	dp[0][0] = 1;
	for(int i=1; i<=60; ++i){
		int t = 60 - i;
		if(((n >> t) & 1) == 0){
			dp[i][0] = dp[i-1][0] + dp[i-1][1];
			dp[i][1] = dp[i-1][1];
			dp[i][2] = dp[i-1][1] + 3 * dp[i-1][2];
			for(int j=0; j<3; ++j)
				dp[i][j] %= mod;
		}else{
			dp[i][0] = dp[i-1][0];
			dp[i][1] = dp[i-1][0] + dp[i-1][1];
			dp[i][2] = 2 * dp[i-1][1] + 3 * dp[i-1][2];
			for(int j=0; j<3; ++j)
				dp[i][j] %= mod;
		}
	}
//	for(int i=0; i<61; ++i)
//		cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << "\n";
	cout << (dp[60][0] + dp[60][1] + dp[60][2]) % mod << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define setbit(s, i) (s|=(1LL<<(i)))
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "A"
int n, a, b;
int main(){
    #ifdef Kanikou
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Kanikou
    read(n);
    read(a);
    read(b);
    if((b-a)%2) puts("Borys");
    else puts("Alice");
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  string s; cin >> s;
  if (s.size() < 26) {
    bool used[26] = {0};
    for (char c : s) used[c-'a'] = true;
    for (int i = 0; i < 26; i++) {
      if (!used[i]) {
        s += (char)('a' + i);
        break;
      }
    }
    cout << s << endl;
    return 0;
  }
  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
    return 0;
  }
  
  string ans;
  string t = s;
  next_permutation(ALL(t));
  REP(i, s.size()) if (s[i] != t[i]) {
    ans = t.substr(0, i + 1);
    break;
  }

  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int d;
	cin >> d;
	if (d == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	if (d == 25) {
		cout << "Christmas" << endl;
	}
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];
    vector<double> cusum(n + 1, 0);
    rep(i, 0, n) cusum[i + 1] = cusum[i] + (p[i] + 1) / (double)2;
    double ans = 0;
    rep(i, 0, n - k + 1) ans = max(ans, cusum[i + k] - cusum[i]);
    cout << fixed << setprecision(15);
    cout << ans << endl;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
     　int n,m;
            // = int.Parse(Console.ReadLine()); //標準入力
            string[] str = Console.ReadLine().Split(' ');
            n=int.Parse(str[0]);
            m=int.Parse(str[1]);
            string[] ans=new String[m];//ac or wa
            int[] p=new int[m]; //question
            
            bool[] an=new bool[n];//
            int[] penaNum=new int[n];//pena
            
            for(int i=0;i<n;i++){
                penaNum[i]=0;
                an[i]=false;
            }
            for(int i=0;i<m;i++){
              string[] s = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
              p[i]=int.Parse(s[0]);
              ans[i]=s[1];
              if(ans[i].Equals("AC"))an[p[i]-1]=true;
              else if(ans[i].Equals("WA")&&!an[p[i]-1])penaNum[p[i]-1]++;
              
            }
            for(int i=0;i<n;i++){
                if(!an[i])penaNum[i]=0;
            }
           int acNum=0;
           int penanumTotal=0;
           foreach(bool t in an)if(t)acNum++;
　　　　　 foreach(int t in penaNum)penanumTotal+=t;
           Console.WriteLine(acNum+" "+penanumTotal);//改行付き出力
    }
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, k;
string s;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  cin >> s;

  int cnt = 0;
  int diff = 0;
  
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] != s[i + 1]) diff += 1;
    else cnt += 1;
  }

  int ans = cnt + min(2 * k, diff);

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 512
/*
ABC119-D
問題
A社の神社とB軒の寺がある。
西からi社目の神社はsiメートル、i軒目の寺はtiメートルの地点
があります。
以下Q個の問いに答える。
問i:道路のxiメートルの地点から出発して自由に移動したとき、
神社1社と寺1軒に訪れるのに必要な最小の移動距離は何メートルか。
制約
1<=A,B<=10^5
1<=Q<=10^5
1<=si,ti,xi<=10^10
方針
単純にxiに一番近い神社と寺に行くのが最短距離なのはわかる。
ただし、パターンとしては以下があるので、全パターン試す。
・最初に前方最寄りの神社に行き、前方最寄りの寺にいく
・最初に前方最寄りの神社に行き、後方最寄りの寺にいく
・最初に後方最寄りの神社に行き、前方最寄りの寺にいく
・最初に後方最寄りの神社に行き、後方最寄りの寺にいく
・最初に前方最寄りの寺に行き、前方最寄りの神社にいく
・最初に前方最寄りの寺に行き、後方最寄りの神社にいく
・最初に後方最寄りの寺に行き、前方最寄りの神社にいく
・最初に後方最寄りの寺に行き、後方最寄りの神社にいく
最寄りを調べるためには以下の二分探索を用いる(O(logN))
lower_bound
・探索したい値以上が現れる最初の位置のイテレータ
v ={1,2,3,4,5} x = 3だったら、index:2の位置のイテレータ
upper_bound
・探索したい値より大きい値が現れる最初の位置のイテレータ
v ={1,2,3,4,5} x = 3だったら、index:3の位置のイテレータ
・前方のindex(自分自身を含む)
upper_bound(v.begin(), v.end(), x) - v.begin() - 1
・前方のindex(自分自身を含まない)
lower_bound(v.begin(), v.end(), x) - v.begin() - 1
・後方のindex(自分自身を含む)
lower_bound(v.begin(), v.end(), x) - v.begin()
・後方のindex(自分自身を含まない)
upper_bound(v.begin(), v.end(), x) - v.begin()
*/

#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    int H,W; cin >> H >> W;
    vector<string> a(H);
    rep(i,H) cin >> a[i];

    rep(i,W+2){
        cout << "#";
    }
    cout << endl;

    rep(i,H){
        cout << "#";
        rep(j,W){
            cout << a[i][j];
        }
        cout << "#" << endl;
    }

    rep(i,W+2){
        cout << "#";
    }
    cout << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=305;
char s[N][N];
int ans[N][N],tot;
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int h=read(),w=read(),k=read();
	For(i,1,h)scanf("%s",s[i]+1);
	For(i,1,h){
		For(j,1,w)if(s[i][j]=='#')ans[i][j]=++tot;
	}
	For(i,1,h)For(j,1,w)if(!ans[i][j])ans[i][j]=ans[i][j-1];
	For(i,1,h)Rep(j,w,1)if(!ans[i][j])ans[i][j]=ans[i][j+1];
	For(i,1,h)For(j,1,w)if(!ans[i][j])ans[i][j]=ans[i-1][j];
	Rep(i,h,1)For(j,1,w)if(!ans[i][j])ans[i][j]=ans[i+1][j];
	For(i,1,h){
		For(j,1,w)wri(ans[i][j]); puts("");
	}
}


Measured memory_bytes: 4192
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

typedef long long lli;

main(){
  lli n;
  while(cin >> n && n){
    string ans;
    lli r = 10;
    lli c = 0;
    for(lli p=0;n||c;p++){
      lli tmp = n % 10;
      if(r < 10) tmp *= -1;
      if(tmp < 0){
        n += (p % 2? 1 : -1) * 10;
        ans += (char)(10 + tmp + '0');
      }else{
        ans += (char)(tmp + '0');
      }
      n /= 10;
      r *= -1;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
int main() {
  int a; cin >> a;
  int ans =0;
  ans += a + a*a +a*a*a;
  
  cout << ans << endl;
}


Measured memory_bytes: 3628
N = int(input())
S = list(input())
ans_S = []

l = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(len(S)):
  if l.index(S[i]) + N <= 25:
    ans_S.append(l[l.index(S[i]) + N])
  else:
    ans_S.append(l[l.index(S[i]) + N - 26])
    
print(str(''.join(ans_S)))

Measured memory_bytes: 3316
n,m = map(int,input().split())
pref_year = [[] for _ in range(n+1)]
for i in range(1,m+1):
    p,y = map(int,input().split())
    pref_year[p].append((y,i))
ans = []
for p,li in enumerate(pref_year):
    if li:
        li.sort()
        for num,j in enumerate(li):
            ans.append((j[1],str(p).zfill(6)+str(num+1).zfill(6)))
ans.sort()
for i in ans:
    print(i[1])

Measured memory_bytes: 42324
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import heapq
N=int(input())
l=[]
pf={}
m=N
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
#print(pf)
keys=list(pf.keys())
values=list(pf.values())
for i in range(len(keys)):
    l.append([keys[i],values[i]])
#print(l)	#これでlistになった
num=[i*(i+1)//2 for i in range(40)]
#print(num)
ans=0
for i in range(len(l)):
    for j in range(39):
        if num[j]<=l[i][1]<num[j+1]:
            ans=ans+j
print(ans)


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


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, s, N = 100000;
    while(cin >> n >> m >> s, n && m && s){
    	n *= n;
    	vector<vector<ll> > dp(n+1, vector<ll> (s+1, 0));
    	dp[0][0] = 1;
    	for(int i=1;i<=n;i++){
    		for(int j=0;j<=s;j++){
    			if(i<=j) dp[i][j] += dp[i][j-i] + dp[i-1][j-i];
    			if(j - m - 1 >= 0) dp[i][j] -= dp[i-1][j-m-1];
    			dp[i][j] %= N;
    		}
    	}
    	cout << (dp[n][s]+N)%N << endl; 
    }
    return 0;
}



Measured memory_bytes: 4088
#include<stdio.h>
int main()
{
	int a,b,c;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		c=a+b;
	if(c%3==0||a%3==0||b%3==0)  printf("Possible\n");
	else printf("Impossible\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define  mxn  200000
int arr[mxn];
int cum[mxn];
int main()
{
    int n;
    cin >> n;

    for(int i = 1;i <= n;i++){
        cin >> arr[i];
    }
    int mx = 0;
    for(int i = n-1;i >= 1;i--){

        if(arr[i] >= arr[i+1]){
            cum[i] = cum[i+1] + 1;
        }
        mx = max(mx,cum[i]);
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	if (a>=b&&a>=c){
		for (int i=0;i<k;i++) a=a*2;
		cout<<a+b+c<<endl;
	}
	if (b>=a&&b>=c){
		for (int i=0;i<k;i++) b=b*2;
		cout<<a+b+c<<endl;
	}
	if (c>=b&&c>=a){
		for (int i=0;i<k;i++) c=c*2;
		cout<<a+b+c<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
a = [int(x) for x in list(input())]
op = 3
ops = [0] * op
for i in range(2 ** op):
    result = a[0]
    bry = list(format(i, "0{}b".format(op)))
    for index, value in enumerate(bry):
        if value == "1":
            result += a[index + 1]
            ops[index] = "+"
        else:
            result -= a[index + 1]
            ops[index] = "-"
    if result == 7:
        ans = str(a[0])
        for j in range(3):
            ans += "{}{}".format(ops[j], a[j+1])
        ans += "=7"
        print(ans)
        break

Measured memory_bytes: 3064
N, S = map(int, input().split())
As = list(map(int, input().split()))
mod = 998244353
dp = [[0]*(S+1) for i in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    a = As[i-1]
    for s in range(S+1):
        if s-a>=0:
            dp[i][s] += dp[i-1][s-a] + dp[i-1][s]*2
        else:
            dp[i][s] += dp[i-1][s]*2
        dp[i][s] %= mod
print(dp[-1][-1]%mod)

Measured memory_bytes: 132440
#include <stdio.h>
#include <string.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)

void char_to_int(char Xchar[19], int X[19]){
    int i;
    int len = strlen(Xchar);
    REP(i, len){
        X[i] = Xchar[len - 1 - i] - '0';
    }
}

void multiple(int X[19], int k){
    int i;
    REP(i, 19){
        X[i] *= k;
    }
    REP(i, 18){
        X[i + 1] += (X[i] / 10);
        X[i] %= 10;
    }
}

int comp(int X[19], int Y[19]){
    int i;
    REP(i, 19){
        if(X[18 - i] < Y[18 - i]){
            return 1;
        }else if(X[18 - i] > Y[18 - i]){
            return -1;
        }
    }
    return 0;
}

int main(){
    char Xchar[19], Ychar[19];
    int X[19] = {}, Y[19] = {};
    int ans = 0;
    int i;

    scanf("%s %s", Xchar, Ychar);

    char_to_int(Xchar, X);
    char_to_int(Ychar, Y);

    int ret = 0;
    while(ret == 1 || ret == 0){
        ans++;
        multiple(X, 2);
        ret = comp(X, Y);
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 3003

using namespace std;

struct edge{
	int to, nxt;
}e[N << 1];

int n, cnt;
int a[N], fir[N];
bool vis[N];

void dfs(int ,int);
void add(int ,int);

int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i) scanf("%d", a + i);
	for(int i = 1; i < n; ++i){
		int x, y;
		scanf("%d%d",&x, &y);
		add(x, y);add(y, x);
	}
	for(int i = 1; i <= n; ++i){
		dfs(i, 0);
		if(vis[i]) printf("%d ",i);
	}
	return 0;
}

void add(int u,int v){
	e[++cnt].to = v;e[cnt].nxt = fir[u];fir[u] = cnt;
	return ;
}

void dfs(int u,int f){
	vis[u] = false;
	for(int i = fir[u]; i; i = e[i].nxt){
		int v = e[i].to;
		if(v == f) continue;
		dfs(v, u);
		if(a[v] < a[u] && !vis[v]){
			vis[u] = true;
			break;
		}
	}
	return ;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k, x;
  cin >> k >> x;
  if (500 * k >= x) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
// D - Friend Suggestions
// UnionFinde version (with rank)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

class UnionFind{//union-find class (rank)
	vector<int> parent_or_rank;// <0: root&-(rank), >=0: parent number
	vector<int> sz;//size
	public:
	// initialize
	// parent_or_rank: all root -> -(rank)=-(1). range of rank = [1,n]
	// sz: all root -> self size = 1
	UnionFind(int n):parent_or_rank(n, -1), sz(n, 1) {}
	bool unite(int p, int c){
		p = root(p); c = root(c);//get root
		if(p == c) return false;
		int rankp = -parent_or_rank[p], rankc = -parent_or_rank[c];//get rank
		if(rankp < rankc) swap(p, c);
		if(rankp == rankc) parent_or_rank[p]--;//-(rank++)
		parent_or_rank[c] = p;
		sz[p] += sz[c]; sz[c] = 0;//size update
		return true;
	}
	int root(int v){return parent_or_rank[v] < 0? v: parent_or_rank[v] = root(parent_or_rank[v]);}
	bool same(int v, int u){return root(v) == root(u);}
	int size(int v){return sz[root(v)];}
};

int main(){
	int N,M,K; scanf("%d%d%d",&N,&M,&K);
	UnionFind uf(N);
	vi C(N);
	int s,t;
	rp(i,0,M){
		scanf("%d%d",&s,&t); s--; t--;
		uf.unite(s,t);
		C[s]++; C[t]++;
	}
	rp(i,0,K){
		scanf("%d%d",&s,&t); s--; t--;
		if(uf.same(s,t)) C[s]++, C[t]++;
	}
	rp(i,0,N) printf("%d ",uf.size(i)-C[i]-1);
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int mx = 0;
  rep(i, N) {
    vector<bool> X(26, false);
    vector<bool> Y(26, false);
    for(int j = 0; j < i; j++) {
      X[S[j]-'a'] = true;
    }
    for(int j = i; j < N; j++) {
      Y[S[j]-'a'] = true;
    }

    int count = 0;
    rep(j, X.size()) {
      if (X[j] && Y[j]) count++;
    }
    if (mx < count) mx = count;
  }

  cout << mx << endl;

  return 0;
}


Measured memory_bytes: 256