akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstdio>
#include <cctype>

using namespace std;

typedef long long LL;
typedef long double db;

inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) f=ch=='-'?-1:f,ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int buf[30];

inline void write(LL x)
{
	if (x<0) putchar('-'),x=-x;
	for (;x;x/=10) buf[++buf[0]]=x%10;
	if (!buf[0]) buf[++buf[0]]=0;
	for (;buf[0];putchar('0'+buf[buf[0]--]));
}

const int N=300005;
const int Q=300005;

LL f[N],g[N],F[N],G[N],s[N],h[N],t[N];
int a[N];
int n,n_,q,top;

inline LL max(LL x,LL y){return x>y?x:y;}
inline void update(LL &x,LL y){x=x>y?x:y;}

struct L
{
	LL k,b;

	inline L (LL k_=0,LL b_=0){k=k_,b=b_;}
}stack[N];

db ict(L l1,L l2){return ((db)(l2.b-l1.b))/((db)(l1.k-l2.k));}

LL query(int x)
{
	for (;top>1&&ict(stack[top],stack[top-1])<x;--top);
	return top?stack[top].k*x+stack[top].b:LLONG_MIN>>1;
}

void dp(LL *f)
{
	s[0]=0;
	for (int i=1;i<=n;++i) s[i]=s[i-1]+a[i];
	stack[top=1]=L(0,f[0]=0);
	for (int i=1;i<=n;++i)
	{
		f[i]=max(query(i)+(1ll*i*(i+1)>>1)-s[i],f[i-1]);
		L cur=L(-i,f[i]+(1ll*i*(i-1)>>1)+s[i]);
		for (;top>1&&ict(stack[top],stack[top-1])<ict(stack[top],cur);--top);
		stack[++top]=cur;
	}
}

void cdq(int l,int r,bool sig)
{
	if (l==r) return;
	int mid=l+r>>1;
	if (!((l+r)&1)&&sig) --mid;
	top=0;
	for (int i=r;i>mid;--i)
	{
		for (;top&&stack[top].b<=G[i];--top);
		stack[++top]=L(-i,G[i]);
	}
	reverse(stack+1,stack+1+top);
	for (int i=l;i<=mid;++i) t[i]=query(i+1)+F[i];
	for (int i=l+1;i<=mid;++i) update(t[i],t[i-1]),update(h[i],t[i-1]);
	cdq(l,mid,sig),cdq(mid+1,r,sig);
}

int main()
{
	//freopen("genocide.in","r",stdin),freopen("genocide.out","w",stdout);
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	dp(f),reverse(a+1,a+1+n),dp(g),reverse(g+1,g+1+n),reverse(a+1,a+1+n);
	for (int i=0;i<=n+1;++i) h[i]=LLONG_MIN>>1;
	s[0]=0;
	for (int i=1;i<=n;++i) s[i]=s[i-1]+a[i];
	for (int i=0;i<=n+1;++i) F[i]=f[i]+(1ll*(i+1)*i>>1)+s[i],G[i]=g[i]+(1ll*(i+1)*i>>1)-(i?s[i-1]:0);
	cdq(0,n+1,0),reverse(h+0,h+1+n+1),reverse(a+1,a+1+n),reverse(f+0,f+1+n+1),reverse(g+0,g+1+n+1);
	for (int i=0;i<=n+1;++i) swap(f[i],g[i]);
	s[0]=0;
	for (int i=1;i<=n;++i) s[i]=s[i-1]+a[i];
	for (int i=0;i<=n+1;++i) F[i]=f[i]+(1ll*(i+1)*i>>1)+s[i],G[i]=g[i]+(1ll*(i+1)*i>>1)-(i?s[i-1]:0);
	cdq(0,n+1,1),reverse(h+0,h+1+n+1),reverse(a+1,a+1+n),reverse(f+0,f+1+n+1),reverse(g+0,g+1+n+1);
	for (int i=0;i<=n+1;++i) swap(f[i],g[i]);
	q=read();
	for (int i=1,x,y;i<=q;++i) x=read(),y=read(),write(max(f[x-1]+g[x+1],h[x]+a[x]-y)),putchar('\n');
	//fclose(stdin),fclose(stdout);
	return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int a;
    char s[123];
    Scd(a);
    Scs(s);
    printf ("%s\n", a < 3200 ? "red" : s );

    return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
*A, = map(int, input().split())
# n, k = 6, 727202214173249351
# A = [6, 5, 2, 5, 3, 2]
# n, k = 2, 1
# A = [1, 3]
# n, k = 3, 3
# A = [2, 3, 3]
A = [a - 1 for a in A]
now = 0
V = [False for i in range(n)]
V[0] = 0
L = [now]
cnt = 0
while not V[A[now]]:
    cnt += 1
    now = A[now]
    L.append(now)
    V[now] = cnt
a = V[A[now]]
b = cnt - a + 1
if k < cnt:
    print(L[k] + 1)
    exit()
print(L[(k - a) % b + a] + 1)


Measured memory_bytes: 32380
n, t = gets.split.map(&:to_i)
ts = gets.split.map(&:to_i)
result = 0
ts.size.times do |i|
  break if i + 1 == ts.size
  if ts[i+1] - ts[i] >= t
    result += t
  else
    result += ts[i+1] - ts[i]
  end
end
result += t
puts result


Measured memory_bytes: 16008
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const int MAX_V = 310;  // デフォルトで頂点数の最大値は300

vvl dist1(MAX_V, vl(MAX_V));
vvl dist2(MAX_V, vl(MAX_V));

int main() {
    ll n, m, L;
    cin >> n >> m >> L;

    rep(i, n) {
        rep(j, n) {
            if(i != j) {
                dist1[i][j] = INF;
                dist2[i][j] = INF;
            }
        }
    }
    
    rep(i, m) {
        ll a, b, cost;
        cin >> a >> b >> cost;
        a--;  b--;
        if(dist1[a][b] > cost) {
            dist1[a][b] = dist1[b][a] = cost;
        }
    }

    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist1[i][j] = min(dist1[i][j], dist1[i][k] + dist1[k][j]);
            }
        }
    }

    rep(i, n) {
        rep(j, n) {
            if(i == j) {
                continue;
            }
            if(dist1[i][j] <= L) {
                dist2[i][j] = dist1[j][i] = 1;
            }
        }
    }

    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
            }
        }
    }

    ll Q;
    cin >> Q;
    vl ans(Q);
    rep(i, Q) {
        ll s, t;
        cin >> s >> t;
        s--;  t--;
        if(dist2[s][t] == INF) {
            ans[i] = -1;
        } 
        else {
            ans[i] = dist2[s][t] - 1;
        }
    }

    rep(i, Q) {
        out(ans[i]);
    }

    re0;
}

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

void trace(int A[100],int n){
    for ( int i = 0;i < n; i++ ){
        if ( i ) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

/*void insertionSort(int A[100],int n){
    int v,j;
    for ( int i = 0; i < n; i++){
        v=A[i];
        j = i - 1;
        while ((j >= 0) && (A[j] > v)){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        if(i>0)trace(A,n);
    }
}*/

int bubbleSort(int A[100],int n){
    int v;
    int x = 0;
    int flag = 1;
    while (flag){
        flag = 0;
        for (int j = n-1;j>0;j--){
            if ( A[j] < A[j-1] ){
                v = A[j];
                A[j] = A[j-1];
                A[j-1] = v;
                flag = 1;
                x++;
            }
        }
    }
    trace(A,n);
    
    return x;
}

int main(){
    int n,A[100];
    cin >> n;
    for ( int i = 0; i < n; i++)cin >>A[i];
   
    //trace(A,n);
    //insertionSort(A,n);
    cout << bubbleSort(A,n) << endl;
    
    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<float> value(n);
    vector<string> kind(n);
    float sum = 0.0;
    for(int i=0;i<n;i++){
        cin >> value[i] >> kind[i];
        if(kind[i] == "BTC"){
            value[i] = 380000.0 * value[i];
        }
        sum += value[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
// By Shreehari Bodas

#include <bits/stdc++.h>

using namespace std;

const int MOD=1e9+7;

int search(int b[], int m, int s){
	int start=0,end=m-1;
	bool flag=false;
	while(start<=end){
		int mid=(start+end)/2;
		if(b[mid]==s){
			flag=true;
			return mid;
		}
		else if(b[mid]>s) end=mid-1;
		else if(b[mid]<s) start=mid+1;
	}
	if(flag==false) return m;
}

long long int pow(long long int a, long long int b){
	if(b==0) return 1;
	long long int res=pow(a,b/2);
	if(b%2 ==1) return res*res*a;
	else if(b%2 ==0) return res*res;
}

int main(){

	string s; cin>>s;
	if(s=="ABC") cout<<"ARC";
	else if(s=="ARC") cout<<"ABC";

	return 0;
} 

Measured memory_bytes: 3628
s=(input())
t=(input())
a=[chr(ord("a")+i)for i in range(26)]
b=[chr(ord("a")+i)for i in range(26)]
for i in range(0,len(s)):
    p=ord(s[i])-ord("a")
    q=ord(t[i])-ord("a")
    if len(a[p])==1:
        a[p]=t[i]+"1"
    else:
        if a[p]!=t[i]+"1":
            print("No")
            break
    if len(b[q])==1:
        b[q]=s[i]+"1"
    else:
        if b[q]!=s[i]+"1":
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 3632
import math

a, b, c = map(int, input().split())
S = 0.0
L = 0
h = 0.0
if c <= 90:
    h = b * math.sin(math.radians(c))
else:
    h = b * math.sin(math.radians(180 - c))
S = a * h * 0.5
L = (a**2.0 + b**2.0 - 2*a*b*math.cos(math.radians(c)) )**0.5
L = L + a + b
print(S)
print(L)
print(h)



Measured memory_bytes: 5724
#include <iostream>

using namespace std;

int main() {

	int W, H, x, y, r;

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

	if (x - r < 0 || y - r < 0) {
		cout << "No" << endl;
		return 0;
	}

	if (x + r > W || y + r > H) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	return 0;

}

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

vector<int> v;

signed main()
{
	int n,k;
	cin>>n>>k;
	v.push_back(-10000);
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	
	int ans=0;
	for(int i=1;i<=max(0ll,n-k);i++)ans+=v[i];
	cout<<ans<<endl;

	


	getchar();getchar();
	
}

Measured memory_bytes: 2548
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := intScanner(), intScanner()
	if a <= 9 && b <= 9 {
		fmt.Println(a * b)
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 1776
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
        Arrays.sort(s);
        for (String str : s) {
            System.out.print(str);
        }
        System.out.println();
    }    
}


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

typedef long long ll;

const int mod = 1e9 + 7;

struct mat {
    int T[2][2];
    void O() {
        memset(T, 0, sizeof(T));
    }
    void I() {
        O();
        for(int i = 0; i < 2; i++) T[i][i] = 1;
    }
};

mat mult(mat a, mat b) {
    mat ret;
    ret.O();
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            for(int k = 0; k < 2; k++) {
                ret.T[i][j] += 1LL * a.T[i][k] * b.T[k][j] % mod;
                ret.T[i][j] %= mod;
            }
        }
    }
    return ret;
}

mat exp(mat x, ll n) {
    mat ret;
    ret.I();
    while(n) {
        if(n & 1) ret = mult(ret, x);
        x = mult(x, x);
        n >>= 1;
    }
    return ret;
}

int H, W;
ll K;
char G[1010][1010];
int Meet[2];

int A, B, C;
mat X, Y;

int main() {
    scanf("%d %d %lld", &H, &W, &K);

    for(int i = 0; i < H; i++) {
        scanf("\n");
        for(int j = 0; j < W; j++) {
            scanf("%c", &G[i][j]);
        }
    }

    for(int i = 0; i < W; i++) if(G[0][i] == '#' && G[H - 1][i] == '#') {
        Meet[0]++;
    }
    for(int i = 0; i < H; i++) if(G[i][0] == '#' && G[i][W - 1] == '#') {
        Meet[1]++;
    }

    if(K == 0) {
        printf("1");
        return 0;
    }
    if(Meet[0] && Meet[1]) {
        printf("1");
        return 0;
    }
    if(Meet[0]) {
        for(int i = 0; i < max(H, W); i++) {
            for(int j = i + 1; j < max(H, W); j++) {
                swap(G[i][j], G[j][i]);
            }
        }
        swap(Meet[0], Meet[1]);
        swap(H, W);
    }

    for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) if(G[i][j] == '#') A++;
    for(int i = 0; i < H; i++) for(int j = 0; j < W - 1; j++) if(G[i][j] == '#' && G[i][j + 1] == '#') B++;
    C = Meet[1];

    if(!Meet[0] && !Meet[1]) B = 0;
    
    X.O();
    X.T[0][0] = A;
    X.T[0][1] = (mod - B) % mod;
    X.T[1][1] = C;

    Y.O();
    Y.T[0][0] = 1;
    Y.T[1][0] = 1;

    Y = mult(exp(X, K - 1), Y);
    printf("%d", Y.T[0][0]);
}


Measured memory_bytes: 1280
N = int(input())
p = [-1] + list(map(int, input().split())) + [0]

cnt = 0
ans = 0
for i in range(len(p)):
  if p[i] == i:
    cnt += 1
  else:
    if cnt != 0:
      ans += cnt // 2 + cnt % 2
      cnt = 0

print(ans)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

ll dp[87];

ll apple(int n){
    int i;
    dp[0] = 2;
    dp[1] = 1;
    
    for(i = 2 ; i <= n ; i++)
        dp[i] = dp[i-1] + dp[i-2];
    
    return dp[n];
}

int main(){
    int n; scanf("%d",&n);
    
    printf("%lld\n",apple(n));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int search(vector<int>& v,vector<int>& w,vector<vector<int> >& x,int id)
{
  if(id == v.size()) return x[id][0];
  if(v[id] != -1){
    int num = v[id];
    if(id % 2 != 0) num *= 2; 
    if(num > 9) num = (num/10) + (num%10);
    for(int i=0; i<10; i++){
      x[id+1][(i+num)%10] += x[id][i];
    }
    return search(v,w,x,id+1);
  }
  for(int i=0; i<w.size(); i++){
    int num = w[i];
    if(id % 2 != 0) num *= 2; 
    if(num > 9) num = (num/10) + (num%10);
    for(int j=0; j<10; j++){
      x[id+1][(j+num)%10] += x[id][j];
    }
  }
  return search(v,w,x,id+1);
}
int main()
{
  int n;
  cin >> n;
  string str;
  cin >> str;
  vector<int> v(n);
  for(int i=0; i<n; i++){
    char c = str[i];
    if(c == '*') v[n-1-i] = -1;
    else v[n-1-i] = c - '0';
  }
  int m;
  cin >> m;
  vector<int> w(m);
  for(int i=0; i<m; i++){
    cin >> w[i];
  }
  vector<vector<int> > x(n+1,vector<int>(10,0));
  x[0][0] = 1;
  int ret = search(v,w,x,0);
  cout << ret << endl;
  return 0;
}

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

const ll MOD = 998244353;

int D[100005];
int C[100005];

int main() {
  int N;
  cin >> N;
  int dmax = 0;
  REP(i,N) {
    cin >> D[i];
    C[D[i]]++;
    dmax = max( dmax, D[i]);
  }
  ll ans = 1;
  if ( (C[0] != 1) || (D[0] != 0)) { cout << "0" << endl; return 0;}
  for (int i=1; i<dmax+1 ;++i ) {
    if ( C[i] == 0 ) { cout << "0" << endl; return 0;}
    REP( j, C[i] ) {
      ans = (ans * C[i-1]) % MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
const int P = 1000000007;
void add(int &x, int y)
{
	x = (x + y) % P;
}
int n, m, F[100005];
bool del[100005];
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1, x; i <= m; ++i)
		scanf("%d", &x), del[x] = true;
	F[0] = 1;
	for (int i = 0; i <= n; ++i)
	{
		if (del[i]) F[i] = 0;
		add(F[i + 1], F[i]);
		add(F[i + 2], F[i]);
	}
	printf("%d\n", F[n]);
	return 0;
}


Measured memory_bytes: 640
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        a: u8,
        mut b: u8,
        mut c: u8,
        k: u8,
    }

    let mut cnt = 0;
    while cnt < k {
        if a >= b {
            b *= 2;
            cnt += 1;
        } else if b >= c {
            c *= 2;
            cnt += 1;
        } else {
            break;
        }
    }

    if a < b && b < c{
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2152
import java.util.Scanner;
import java.util.Arrays;

public class Main { 
	public static void main(String[] args) { 
		
		Scanner sc = new Scanner(System.in); 
			
		int rows = sc.nextInt(); 
		int columns = sc.nextInt(); 
		int[][] data = new int[rows][columns];
		
		for (int i=0; i<rows; i++) {
			for (int j=0; j<columns; j++) {
				data[i][j]=sc.nextInt();
			}
		}
		
		int[] rowSums = new int[rows];
		int[] colSums = new int[columns];
		int sum = 0;
		Arrays.fill(rowSums, 0);
		Arrays.fill(colSums, 0);
		for (int i = 0; i<rows; i++) {
			for (int j = 0; j<columns; j++ ) {
				rowSums[i]+= data[i][j];
				colSums[j]+= data[i][j];
				sum+= data[i][j];
			}
		}
		
		for(int i=0; i<rows; i++){
			for(int j=0; j<columns; j++){
				System.out.print(""+data[i][j]+" ");
			}
			System.out.println(""+ rowSums[i]);
		}
		for(int j=0; j<columns; j++){
			System.out.print(""+colSums[j]+" ");
		}
		System.out.println(sum);

		 
	} 
}





Measured memory_bytes: 42136
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;

typedef long long int64;

int main()
{
	while(true) {
		
		int n;
		char buf[1024];
		string str;
		
		scanf("%d", &n);
		if(n == 0)
			break;
		
		scanf("%s", buf);
		str = buf;
		
		for(int i = 0; i < n; ++i) {
			
			string next;
			
			for(int it = 0; it < str.size(); ++it) {
				
				int l = it, r = it;
				
				while(r < str.size() && str[l] == str[r])
					++r;
				
				char temp[1024];
				
				sprintf(temp, "%d%c", r - l, str[l]);
				next.append(temp);
				
				it = r - 1;
			}
			
			//printf("[debug] %d -> %s\n", i, next.c_str());
			str = next;
		}
		
		printf("%s\n", str.c_str());
	}
	
	return 0;
}

/* はやく人間になりたい */
/* 人権を得たい */
/* nullmineralが書きましたが */
/* 責任はまったくとりません */

Measured memory_bytes: 1368
N=int(input())

def eratos(end):
  is_prime = [True]*end

  is_prime[0] = is_prime[1] = False

  primes=[]

  for i in range(2, end):
    if is_prime[i]:
      primes.append(i)
      for j in range(2*i, end, i):
        is_prime[j] = False

  return primes


primes=eratos(55555)

r=[]
i=0
while(len(r)<N):
  if primes[i]%5 == 1:
    r.append(primes[i])
  i+=1



print(' '.join(map(str, r)))


Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;

class Program
{
	private static int n, m;
	public static int Main()
	{
		Scanner cin = new Scanner();
		while (true)
		{
			n = cin.nextInt();
			m = cin.nextInt();
			if (n == 0 && m == 0)
			{
				break;
			}
			Console.WriteLine(dfs(0, 0, 0));
		}
		return 0;
	}

	public static int dfs(int now, int cnt, int many)
	{
		if (now == 10)
		{
			return many == m && cnt == n ? 1 : 0;
		}
		if (many > m || cnt > n)
		{
			return 0;
		}
		return dfs(now + 1, cnt + 1,many + now) + dfs(now + 1, cnt, many);
	}
}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 5616
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
using ll = long long;
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);

}

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

//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	llint ans = 0, n = 0, m = 0, count = 0, sum = 0,old=0;
	llint  a, b, c, k;
	bool check = false;
	string ss, sss;
	vector<llint> array;
	vector<bool> bo;
	cin >> k>>ss;
	vector<llint> counter,rust;
	if (ss.size() <= k)cout << ss << endl;
	else cout << ss.substr(0, k) <<"..."<< endl;
	    
	please AC;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int cnt[5000000];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			for(int k=1;k<=100;k++){
				int ans=i*i+j*j+k*k+i*j+j*k+k*i;
				cnt[ans]++;
			}
		}
	}
	for(int i=1;i<=n;i++) cout<<cnt[i]<<"\n";
}

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

int main(){
    int N;cin >> N;
    int sum=0;
    int max=0;
    vector<int> L(N);
    for(int i=0;i<N;i++){
        cin >> L[i];
        sum += L[i];
        if(max < L[i]){
            max = L[i];
        }
    }
    
    if(sum-max > max){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	set<int> st;
	int j;
	for(j=-500;j<=500;j++)
	  st.insert(j);
	int answer=100000000;
	int x,n;
	cin>>x>>n;
	for(j=0;j<n;j++)
	{
		int y;
		cin>>y;
		auto it=st.find(y);
		if(it!=st.end())
		  st.erase(it);
	}
	int index;
	for(int y:st)
	{
		int here=abs(x-y);
		if(here<answer)
		{
			answer=here;
			index=y;
		}
	}
	cout<<index<<endl;
}


Measured memory_bytes: 3704
open Batteries
module Myset = Set.Make(Int)

let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let x,y = Scanf.scanf "%d %d " (fun a b -> a,b) in

  let c_lst = String.to_list s in

  let rec re_x cnt = function
      [] -> x-cnt, []
    | 'F'::tl -> re_x (cnt+1) tl
    | 'T'::tl -> (x-cnt), tl
  in

  let x,c_lst = re_x 0 c_lst in

  let rec aux xl yl cnt is_x = function
      [] -> if is_x then (cnt::xl),yl else xl,(cnt::yl)
    | 'F'::tl -> aux xl yl (cnt+1) is_x tl
    | 'T'::tl -> 
      if is_x = true then aux (cnt::xl) yl 0 (not is_x) tl else
        aux xl (cnt::yl) 0 (not is_x) tl
  in
  let xl,yl = aux [] [] 0 false c_lst in

  let xset = (Myset.add 0 Myset.empty) in
  let x_ans = List.fold_left (fun set1 dy -> 
      Myset.fold (fun el set2 -> 
          let retset = Myset.add (el-dy) (Myset.add (el+dy) set2) in retset
        ) set1 (Myset.empty)
    ) xset xl in

  let yset = (Myset.add 0 Myset.empty) in
  let y_ans = List.fold_left (fun set1 dy -> 
      Myset.fold (fun el set2 -> 
          let retset = Myset.add (el-dy) (Myset.add (el+dy) set2) in retset
        ) set1 (Myset.empty)
    ) yset yl in

  Printf.printf "%s\n" @@
  if (Myset.mem x x_ans) && (Myset.mem y y_ans) then "Yes" else "No"


Measured memory_bytes: 6784
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
def main():
    n=I()
    h=L()
    ans=1
    maxi=h[0]
    for i in range(1,n):
        if h[i]>=maxi:
            maxi=h[i]
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
import io


def run(input: io.TextIOBase, output: io.TextIOBase):
    abc = input.readline().split()

    count_5 = 0
    count_7 = 0
    for x in abc:
        x = int(x)
        if x == 5:
            count_5 += 1
        if x == 7:
            count_7 += 1
    if count_5 == 2 and count_7 == 1:
        result = "YES"
    else:
        result = "NO"

    output.write(result + '\n')


if __name__ == '__main__':
    run(sys.stdin, sys.stdout)


Measured memory_bytes: 3060
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 1006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m , k;
int A[MAXN][MAXN] , bel[MAXN] , cn , cur[11] , now[11];
char str[MAXN];
void solve( ) {
    cin >> n >> m >> k;
    for( int i = 1 ; i <= n ; ++ i ) {
        scanf("%s",str + 1);
        for( int j = 1 ; j <= m ; ++ j ) A[i][j] = str[j] - '0';
    }
    int re , ans; ans = 0x3f3f3f3f ,  re = 0;
    for( int sta = 0 ; sta < ( 1 << n - 1 ) ; ++ sta ) {
        cn = 0 , re = 0;
        bel[1] = ++ cn;
        for( int i = 0 ; i < n - 1 ; ++ i ) if( sta & ( 1 << i ) ) {
            bel[i + 2] = ++ cn;
        } else bel[i + 2] = bel[i + 1];
        mem( cur );
        for( int i = 1 ; i <= m ; ++ i ) {
            for( int j = 1 ; j <= cn ; ++ j ) now[j] = cur[j];
            for( int j = 1 ; j <= n ; ++ j ) if( A[j][i] )
                now[bel[j]] ++;
            int flg = 0;
            for( int j = 1 ; j <= cn ; ++ j ) if( now[j] > k ) { flg = 1; }
            if( i == 1 && flg ) { re = 0x3f3f3f3f; break; }
            if( flg ) {
                mem( cur ); for( int j = 1 ; j <= n ; ++ j ) if( A[j][i] ) cur[bel[j]] ++;
                for( int j = 1 ; j <= cn ; ++ j ) if( cur[j] > k ) { re = 0x3f3f3f3f; break; }
                if( re == 0x3f3f3f3f ) break;
                ++ re;
            }
            else for( int j = 1 ; j <= cn ; ++ j ) cur[j] = now[j];
        }
        ans = min( ans , re + cn - 1 );
    }
    cout << ans << endl;
}
signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  string s, t;
  string ans;
  
  cin >> s >> t;
    
  cout << t << s << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

bool in_ac(){
	string str;
	cin >> str;
	return str == "AC";
}

int main(){
	int n,m;
	cin >> n >> m;
	int ac = 0;
	int wa = 0;
	vector<int> used(n+1,false);
	vector<int> wacnt(n+1,0);
	rep(i,m){
		int d;
		cin >> d;
		bool a = in_ac();
		if(used[d])continue;
		if(a){
			used[d] = true;
			++ac;
			wa += wacnt[d];
		}else{
			++wacnt[d];
		}
	}
	cout << ac << " " << wa << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#define N 200005
int n, m, a[N], b[N], v[N];
int main() {
	int i;
	scanf("%d%d", &n, &m);
	for(i=0; i<m; i++) {
		scanf("%d%d", &a[i], &b[i]);
		if(b[i]==n) v[a[i]] = 1;
	}
	for(i=0; i<m; i++) if(a[i]==1 && v[b[i]]) break;
	printf("%sPOSSIBLE", i<m ? "":"IM");
	return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  bool ansis = true;
  vector<int> keta(n);
  vector<bool> ketah(3);
  for(int i=0; i<m; ++i){
    int s, c;
    cin >> s >> c;
    if(c == 0) ketah.at(s-1) = true;
    else if(ketah.at(s-1) && c) ansis = false; 
    if(keta.at(s-1) && keta.at(s-1) != c) ansis = false;
    else keta.at(s-1) = c;
  }
  if(n>1 && keta.at(0) ==0){
    if(ketah.at(0)) ansis=false;
    else keta.at(0) = 1;
  }
  
  int ans=0;
  for(int i=0; i<n; ++i){
    ans += pow(10,i)*keta.at(n-1-i);
  }
  if(ansis) cout << ans << endl;
  else cout << -1 << endl;
}

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

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/************* Utils *************/
ll search(const vector<ll> &A, ll k, ll x){
    if(k == 0){
        if(x == 0) return 1;
        else return 0;
    }
    ll cnt = 0;
    cnt += search(A, k-1, x);
    cnt += search(A, k-1, x-A[k-1]);
    return cnt;
}

/*********** Variables ***********/
ll N, Q;
vector<ll> A;
vector<ll> M;
vector<bool> W;

/*********** Functions ***********/
bool init() {
    cin >> N; A.resize(N);
    for (auto &item : A) cin >> item;
    W = vector<bool>(accumulate(A.begin(), A.end(), 1ll), false);
    cin >> Q; M.resize(Q);
    for (auto &item : M) cin >> item;
    return true;
}

void solve() {
    for (uint32_t i = 0; i < (1 << N); i++) {
        ll w = 0;
        for (ll j = 0; j < N; j++) {
            if (i & (1 << j)) w += A[j];
        }
        W[w] = true;
    }
}

void output() {
    for (const auto& item : M) {
        if (item < W.size() && W[item]) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
}

int main() {
    init();
    solve();
    output();
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define INF 1e15
#define mod 1000000007
#define eps 1e-6
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=100000;
ll n,m,a[N+10],x[N+10],y[N+10],ans,p[N+10],r[N+10];
ll fin(ll a)
{
	if(a==p[a])
		return a;
	return p[a]=fin(p[a]);
}
void uni(ll a, ll b)
{
	a=fin(a),b=fin(b);
	if(a==b)
		return;
	if(r[a]>r[b])
		r[a]+=r[b],p[b]=a;
	else
		r[b]+=r[a],p[a]=b;
}
int main()
{
	//freopen("c.cpp","r",stdin);
 
	cin>>n>>m;
	for(ll i=1;i<=n;i++)
		read(a[i]),p[i]=i,r[i]=1;
	for(ll i=1;i<=m;i++)
		read(x[i],y[i]),uni(x[i],y[i]);
	for(ll i=1;i<=n;i++)
		if(fin(i)==fin(a[i]))
			ans++;
	cout<<ans;
}

Measured memory_bytes: 4096
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=0;i<n;i++){
		sum=sum+a[i]-1;
	}
	cout<<sum;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
#define PB push_back

#define N 105
#define W 100'005
int n, w;
int u[N], v[N];
ll p[N][W];

int main(){
	REP(i, N) REP(j, W) p[i][j]=0;
	p[0][0]=0;
	scanf("%d%d", &n, &w);
	REP(i, n) scanf("%d%d", u+i, v+i);
	REP(i, n){
		REP(j, W){
			LAR(p[i+1][j], p[i][j]);
			int x = j + u[i];
			if(x < W){
				LAR(p[i+1][x], p[i][j] + v[i]);
			}
		}
	}
	ll ans=0;
	REP(i, w+1) LAR(ans, p[n][i]);
	printf("%lld\n", ans);
}


Measured memory_bytes: 82304
n,k = map(int,input().split())
if k>(n-1)*(n-2)//2:
    print(-1)
else:
    print((n-1) + ((n-1)*(n-2)//2-k))
    for i in range(2, n+1):
        print(1, i)
    rem = (n-1)*(n-2)//2 - k
    cnt = 0
    for i in range(2, n+1):
        if cnt == rem:
            break
        for j in range(i+1, n+1):
            cnt += 1
            print(i, j)
            if cnt == rem:
                break

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> k(n, 0);
  rep(i,n){
    cin >> a[i];
    if(a[i] % 4 == 0){
      k[i] = 2;
    }else if(a[i] % 2 == 0){
      k[i] = 1;
    }
  }
  int cnt = 0;
  int t = 0;
  rep(i,n){
    if(!k[i]) cnt++;
    if(k[i]==1) t++;;
  }
  cnt = (t > 0) ? cnt+1 : cnt;
  n -= max(t - 1, 0);
  if(n%2==0 && cnt > n/2){
    cout << "No" << endl;
    return 0;
  }else if(n%2==1 && cnt > (int)n/2+1){
    cout << "No" << endl;
    return 0;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> p(n);
  for(int i = 0; i < n; i++){
    string a;
    int b;
    cin >> a >> b;
    p.at(i) = make_tuple(a, -1 * b ,i);
  }
  sort(p.begin(), p.end());
  for(auto q : p){
    cout << get<2>(q) + 1 << endl;
  }
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
if a == b == c:
  if a%2 == b%2 == c%2 == 0:
    print(-1)
  else:
    print(0)
else:
  t = 0
  while t > -1:
    if a%2 == 1 or b%2 == 1 or c%2 == 1:
      break
    (a,b,c) = ((b+c)//2,(a+c)//2,(a+b)//2)
    t += 1
  print(t)


Measured memory_bytes: 3060
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =998244353;
const int maxn = 300005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
typedef long double dbl;
#define pw(x) (1LL << (x))
#define forn(i, n) for (int i = 0; i < (n); i++)

set<int> row[maxn];
int32_t main()
{ 
  IOS

  
  int h, w, M;
  cin >> h >> w >> M;
  int col[w+1] = {0};
  int r[M+1], c[M+1];
  for(int i = 1;i<=M;i++){
    cin >> r[i] >> c[i];
    row[r[i]].insert(c[i]);
    col[c[i]]++;
  }
  multiset<pair<int,int>> m;
  for(int i = 1;i<=w;i++){
    m.insert({col[i],i});
  }
  int ans = 0;
  for(int i = 1;i<=h;i++){
    for(auto q:row[i]){
      m.erase(m.find({col[q],q}));
    }
    if(!m.empty())
      ans = max(ans, (int)row[i].size() + (*m.rbegin()).first);
    for(auto q:row[i]){
      ans = max(ans, (int)row[i].size() + col[q] - 1);
      m.insert({col[q],q});
    }
  }

  cout << ans << endl;

  
  

  










  
    
} 
 

Measured memory_bytes: 57512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
  bool chk[26];
  rep(i,26) chk[i]=false;
  string s;
  cin>>s;
  rep(i,s.size()){
    if(chk[(int)s[i]-'a']) {cout<<"no"<<endl; return 0;}
    else chk[(int)s[i]-'a'] =true;
  }
  cout<<"yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
//Meri hr baat bs yaad hai tumhari , mera apna koi kissa nhi!!
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
#define fat 998244353 
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);
using namespace std;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
double dp[3005][3005];

int main()
{   
    boost;
	int n;
	cin>>n;
	double p[n];
	for(int i=0; i < n ; i++)
	{
        cin>>p[i];
	}
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
    	for(int j=0;j<=n;j++)
    	{
    		if(j==0)
    		{
    			dp[i][j]=(1-p[i-1])*dp[i-1][j];
    		}
    		else
    		{
    			dp[i][j]=((1-p[i-1])*dp[i-1][j])+(p[i-1]*dp[i-1][j-1]);
    		}
    	}
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++)
    {
    	ans+=dp[n][i];
    }
    cout<<setprecision(9)<<ans<<endl;
 	return 0;

}

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

using namespace std;

int main(){
  long int w,a,b,ans;
  cin >> w >> a >> b;
  
  if(a+w < b){
    ans = b-(a+w);
    cout << ans << endl;
  }
  else if ((a<=b && b<=a+w) ||(a<=b+w && b+w<=a+w)){
    cout << 0 << endl;
  }
  else {
    ans = a-(b+w);
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
def calculate(n, m, condition_list):
    if [1, 0] in condition_list and n > 1:
        return '-1'
    # こたえは1桁ごとに区切ったリストにする
    # 最後にjoinして回答する
    result = ['null']*n
    for condition in condition_list:
        if result[condition[0]-1] != 'null':
            if not result[condition[0]-1] == condition[1]:
                return '-1'
        result[condition[0]-1] = condition[1]
    # 指定がない桁はまだnullのままなのでそれを埋める
    for i in range(len(result)):
        if result[i] == 'null':
            # 一番左の桁が空いていたら1にする
            if i == 0 and n != 1:
                result[i] = 1
            # それ以外の桁が空いていたら0にする
            else:
                result[i] = 0
    return ''.join([str(each) for each in result])

n, m = (int(each) for each in input().split(' '))

# 条件をリストに入れる
condition_list = []
for i in range(m):
    condition_list.append([int(each) for each in input().split(' ')])

print(calculate(n, m, condition_list))

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    int h, w;
    while (1)
    {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0)
        {
            break;
        }
        for (int i = 1; i <= h; i++)
        {
            for (int j = 1; j <= w; j++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}




int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;
	ll p = n/11 * 2;
	if(n%11) p += (n%11 <= 6)? 1: 2;
	cout << p <<"\n";
	
	return 0;
}


Measured memory_bytes: 256
var
    s:string;
    tc,tf,i,l:longint;
begin
    readln(s);
    l:=length(s);
    tc:=300; tf:=0;
    for i:=1 to l do
    begin
        if s[i]='C' then
            if tc=300 then tc:=i;
        if s[i]='F' then tf:=i;
    end;
    if tc<tf then write('Yes')
    else write('No');
end.

Measured memory_bytes: 128
A, B, M = map(int, input().split())
a_price = list(map(int, input().split()))
b_price = list(map(int, input().split()))
coupon = [list(map(int, input().split())) for i in range(M)]



min = min(a_price) + min(b_price)


for cpn in coupon:
    idx_a = cpn[0]-1
    idx_b = cpn[1]-1
    total = a_price[idx_a] + b_price[idx_b] - cpn[2]
    if min > total:
        min = total

print(min)


Measured memory_bytes: 38568
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int n = Integer.parseInt(line);
        int[] num = new int[n];
        String line1 = sc.nextLine();
        String[] line1sp = line1.split(" ");
        for(int i = 0; i< n; i++) {
            num[i] = Integer.parseInt(line1sp[i]);
        }
        int flag = 1;
        int count = 0;
        while(flag == 1) {
            flag = 0;
            for(int j = n - 1; j > 0; j--) {
                if(num[j] < num[j-1]) {
                    int a = num[j-1];
                    num[j - 1] = num[j];
                    num[j] = a;
                    flag = 1;
                    count++;
                }
            }
        } 
        for(int i = 0; i < n; i++) {
            System.out.print(num[i]);
            if(i < n-1) {
                System.out.print(" ");
            }else {
                System.out.println("");
            }
        }
        System.out.println(count);
            
            
    }
 }
 


Measured memory_bytes: 26192
#include <cstdio>
#include <numeric>
#include <algorithm>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int b[500]={};
		rep(i,n) scanf("%d",b+n-i-1);
		n=500;

		int bsum=accumulate(b,b+n,0);
		int m;
		for(m=0;m<7777;m++) if(m*(m+1)/2==bsum) break;
		if(m>=7777){
			puts("-1");
			continue;
		}

		int ans;
		for(ans=0;ans<=10000;ans++){
			bool ok=true;
			rep(i,m) if(b[i]!=m-i) ok=false;
			if(ok) break;

			int cnt=0;
			rep(i,n) if(b[i]>0) b[i]--, cnt++;
			{
				int j=0,tmp[500]={};
				rep(i,n) if(b[i]>0) tmp[j++]=b[i];
				copy(tmp,tmp+n,b);
			}
			for(int i=n-1;i>0;i--) b[i]=b[i-1];
			b[0]=cnt;
		}

		printf("%d\n",ans<=10000?ans:-1);
	}

	return 0;
}

Measured memory_bytes: 1056
#include <stdio.h>
#include <string.h>

int main() {

    char s[101];
    scanf("%s", s);

    int cnt = 0;
    int l = strlen(s);

    for (int i = 0; i < l / 2; i++) {
        //printf("%c %c\n", s[i], s[l - i - 1]);
        if (s[i] != s[l - i - 1]) {
            cnt++;
        }
    }

    printf("%d", cnt);

    return 0;
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt=0;
  rep(i,n)if(s[i]=='R')cnt++;
  int c=0;
  rep(i,n){
    if(s[i]=='R')c++;
    else break;
  }
  cnt-=c;
  int ans=0;
  while(cnt>0){
    if(s[c]=='W'){
      ans++;
      c++;
      cnt--;
    }
    else{
      c++;
      cnt--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3748
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 3e2+5;
const int MOD = 1e9+7;

double dp[MSIZE][MSIZE][MSIZE];


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

    int x,y,z; x=y=z=0;
    
    f(i,1,n)  {
        int val; cin>>val;
        switch(val)  {
            case 1: x++; break;
            case 2: y++; break;
            case 3: z++; break;
        }  
    }

    f(k,0,z) f(j,0,y+z) f(i,0,x+y+z) {
        if(i==0 && j==0 && k==0) {dp[0][0][0] =  0; continue;}

        dp[i][j][k] = ( n + (i!=0?i*dp[i-1][j][k]:0)
                            + (j!=0?j*dp[i+1][j-1][k]:0)
                            + (k!=0?k*dp[i][j+1][k-1]:0))
                            /(double)(i+j+k);
    }

    cout<<fixed<<setprecision(10)<<dp[x][y][z]<<endl;

    return 0;

}
    


Measured memory_bytes: 219392