akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 5;
vector < int > G[maxn];
int N, K, x, ans;

int dfs(int u, int step){
    int max_dep = 0;
    for(int i = 0; i < G[u].size(); i++){
        int v = G[u][i];
        max_dep = max(max_dep, dfs(v, step + 1) + 1);
    }
    if(max_dep + 1 == K && step > 1){
        ans++;
        max_dep = -1;
    }
    return max_dep;
}

int main(){
    scanf("%d%d", &N, &K);
    ans = 0;
    for(int i = 1; i <= N; i++){
        scanf("%d", &x);
        if(i == 1){
            if(x != 1) ans ++;
            continue;
        }
        G[x].push_back(i);
    }
    dfs(1, 0);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 11904
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();
 
	public static void main(String[] args) {
 
		int X = in.nextInt();
		int Y = in.nextInt();
		int Z = in.nextInt();
 
		System.out.println(Z + " " + X + " " + Y);
	}

	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

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

void solve(){
  string a,b;
  int count=0;
  cin>>a>>b;
  for(int i=0;i<a.length();i++){
    if(a[i]!=b[i]) count++;
  }
  cout<<count<<'\n';
  return;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  solve();
}


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

inline void upmax(short &x,const short &y){if(y>x) x=y;}

const int N=105;
short f[N][N][N][N];
short sum1[N][N],sum2[N][N];
int n,m,tx,ty;

void gao()
{
    int limu=tx-1,limd=n-tx,liml=ty-1,limr=m-ty;
    for(int u=0;u<=limu;u++)
        for(int d=0;d<=limd;d++)
            for(int l=0;l<=liml;l++)
                for(int r=0;r<=limr;r++)
                {
                    int L=max(ty-l,r+1),R=min(ty+r,m-l);
                    if(L<=R)
                    {
                        upmax(f[u+1][d][l][r],f[u][d][l][r]+(tx-u-1>=d+1?sum1[tx-u-1][R]-sum1[tx-u-1][L-1]:0));
                        upmax(f[u][d+1][l][r],f[u][d][l][r]+(tx+d+1<=n-u?sum1[tx+d+1][R]-sum1[tx+d+1][L-1]:0));
                    }
                    L=max(tx-u,d+1),R=min(tx+d,n-u);
                    if(L<=R)
                    {
                        upmax(f[u][d][l+1][r],f[u][d][l][r]+(ty-l-1>=r+1?sum2[R][ty-l-1]-sum2[L-1][ty-l-1]:0));
                        upmax(f[u][d][l][r+1],f[u][d][l][r]+(ty+r+1<=m-l?sum2[R][ty+r+1]-sum2[L-1][ty+r+1]:0));
                    }
                }
    printf("%d\n",f[limu][limd][liml][limr]);
}

int main()
{
    static char s[105];
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
        {
            if(s[j]=='E') tx=i,ty=j;
            sum1[i][j]=sum1[i][j-1]+(s[j]=='o');
            sum2[i][j]=sum2[i-1][j]+(s[j]=='o');
        }
    }
    gao();
    return 0;
}

Measured memory_bytes: 207232
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int K, N; cin >> K >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  sort(all(A));
  A.push_back(K+A[0]);
  
  int maxdist = 0;
  rep(i,N) maxdist = max(A[i+1]-A[i],maxdist);
  
  cout << K - maxdist << endl;
  // rep(i,N) cout << A[i] << endl;


  return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;



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

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

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static int gcd(int a,int b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}
    
    static long p5[] = new long[2001];
    
    static void pC()
    {	
    	int base = -1000;
    	for(int i = 0; i < 2001; i++)
    	{
    		p5[i] = (long)Math.pow(base,5);
    		base++;
    	}
    	//System.out.println(p5[128]+" "+p5[0]);
    }
    
    public static void main(String[] args)
    {
        OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
       
        pC();
        
        long x = sc.nextLong();
        
        int a = 0;
        int b = 0;
        
        outer: for(int i = 0; i < 2001; i++)
        {
        	for(int j = i+1; j < 2001; j++)
        	{
        		long val2 = p5[j]-p5[i];
        		
        		
        		if(val2 == x)
        		{
        			a = j-1000;
        			b = i-1000;
        			break outer;
        		}
        	}
        }
        
        out.println(a+" "+b);
        out.close();
    }

}

Measured memory_bytes: 36724
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception {
     	Scanner file = new Scanner(System.in);
      	int a = file.nextInt(), b = file.nextInt();
      	String aa = "";
      	String bb = "";
        for (int i = 0; i < b; i++) aa += a;
      	for (int i = 0; i < a; i++) bb += b;
      	if (aa.compareTo(bb) <= 0) System.out.println(aa);
      	else System.out.println(bb);
      	file.close();
    }
}


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

int main()
{
	long long n;
	cin>>n;
	long long a=n%10;
	if(a==2 || a==4 || a==5 || a==7 || a==9) 
	{
		cout<<"hon";
		}
		if(a==0 || a==1 || a== 6 || a==8)
		{
			cout<<"pon";
			}
			if(a==3 )
			{
				cout<<"bon";
				}
				return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <stack>

using namespace std;

typedef pair<int, int> P;

int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};

struct status{
	int count, to;
	int p[10][10];
	status(){
		count = 0;
		to = 1;
		fill(p[0], p[0]+10*10, 0);
	}
};

int main(){
	int h, w, c;
	while(cin>>h>>w>>c, h|w|c){
		stack<status> st;
		status in;
		int ans = 0;
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				cin >> in.p[i][j];
			}
		}
		in.to = in.p[1][1];
		in.p[1][1] = 8;
		st.push( in );
		while( !st.empty() ){
			status s = st.top();
			st.pop();
			// to??????????????´
			stack< P > check;
			for(int i=1; i<=h; i++){
				for(int j=1; j<=w; j++){
					if( s.p[i][j] == 8 )
						check.push( make_pair(i, j) );
				}
			}
			while( !check.empty() ){	// ?????????
				P p = check.top(); check.pop();
				int y = p.first, x = p.second;
				for(int k=0; k<4; k++){
					if( s.p[ y+vy[k] ][ x+vx[k] ] == s.to ){
						s.p[ y+vy[k] ][ x+vx[k] ] = 8;
						check.push( make_pair( y+vy[k], x+vx[k] ) );
					}
				}
			}
			if( s.count == 5 ){
				int sum=0;
				for(int i=1; i<=h; i++){
					for(int j=1; j<=w; j++){
						if( s.p[i][j] == 8 )
							sum++;
					}
				}
				ans = max( ans, sum );
			}else if( s.count == 4 ){
				s.count++;
				s.to = c;
				st.push( s );
			}else{
				s.count++;
				for(int i=1; i<=6; i++){
					if( i != s.to ){
						status sn = s;
						sn.to = i;
						st.push( sn );
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
N = int(input())
S = list(input())
Out =  S[:]
while len(S) > 0:
	if S[0] == ")":
		Out.insert(0,"(")
		del S[0]
	elif S[0] == "(":
		i = 0
		for j in range(len(S)):
			if S[j] == ")":
				del S[j]
				del S[0]
				i += 1
				break
			elif j == len(S) - 1 :
				Out.append(")")
				del S[0]
print(''.join(Out))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef map<ll,ll> M;

#define REP(i,n) for(ll (i) = 0; (i) < (n); ++(i))


int main(){
    V v(9);
    for(auto& x : v)
        cin >> x;

    int flag = 0;
    for(auto& x : v)
        if(x != -1)
            flag |= (1<<x);
    V nouse;
    REP(i,10)
        if(i != 0 && (flag & (1<<i)) == 0)
            nouse.push_back(i);


    V nouse2;
    REP(i,9)if(v[i] == -1)nouse2.push_back(i);

    ll ans = 0;

    V iot(nouse.size());
    iota(iot.begin(), iot.end(), 0);
    do{
        V values(9);
        REP(i,9)
            if(v[i] != -1)
                values[i] = v[i];

        REP(i, nouse.size()){
            values[nouse2[i]] = nouse[iot[i]];
        }

        int val = values[0] + values[2] + values[5] - values[8];
        val += 10 * (values[1] + values[4] - values[7]);
        val += 100 * (values[3] - values[6]);

        if(!val)
            ++ans;

    }while(next_permutation(iot.begin(), iot.end()));

    cout << ans << endl;
}



Measured memory_bytes: 3148
import java.util.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int n = scan.nextInt();

        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            int a = scan.nextInt();
            list.add(a);
        }

        Collections.sort(list);//System.out.println(list);
        
        int ans = 110;
        int def = 110;

        for (int i = 0; i <= 101; i++) {
            boolean flag = false;
            for (int val : list) {
                if (i == val) {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                continue;
            }
            int a = Math.abs(i - x);
            if ( def > a) {
                def = a;
                ans = i;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 36088
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

ans = 0
a = ""
b = ""

for i in range(len(s)):
    a += s[i]
    if a == b:
        continue
    ans += 1
    b = a
    a = ""

print(ans)

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

using namespace std;

template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

struct UnionFindTree{
  vector<int> par,rank,size;
  UnionFindTree(int N){
    par = rank = vector<int>(N,0);
    size = vector<int>(N,1);
    for(int i = 0; i < N; i++) par[i] = i;
  }
  int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y)  return ;
    if(rank[x] < rank[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(rank[x] == rank[y]) ++rank[x];
    }
    size[x] = size[y] = size[x] + size[y];
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M; cin >> N >> M;
  ll X; cin >> X;
  priority_queue<Pl,vector<Pl>,greater<Pl>> que1,que2;
  vi u(M),v(M); vl w(M),a(M);
  rep(i,M){
    cin >> u[i] >> v[i] >> w[i];
    u[i]--; v[i]--;
    que1.push(Pl(w[i],i));
  }
  rep(i,M){
    // 辺i を必ず使う MST のコスト
    ll temp = w[i];
    UnionFindTree uft(N);
    uft.unite(u[i],v[i]);
    que2 = que1;
    while(!que2.empty()){
      ll j; ll c;
      tie(c,j) = que2.top(); que2.pop();
      if(!uft.same(u[j],v[j])){
        temp += c;
        uft.unite(u[j],v[j]);
      }
    }
    a[i] = temp;
  }
  sort(ALL(a));
  // rep(i,M) cout << a[i] << " "; cout << endl;
  function<ll(ll)> f = [&](ll x){
    // aがx以下の辺が全て同じ色である場合の数
    int num = int(upper_bound(a.begin(),a.end(),x) - a.begin());
    ll res = 2;
    if(num==0) res >>= 1;
    rep(i,M-num) (res <<= 1) %= lmod;
    // cout << "res " << res << "  num " << num << endl;
    return res;
  };
  cout << (f(X-1) - f(X) + lmod) % lmod << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  vector<pair<int,int> > ans;

  int maxx = *max_element(all(a)), minn = *min_element(all(a));
  int maxx_pos = 0,minn_pos = 0;

  for(int i = 0; i < n; i++){
    if(a[i] == maxx) maxx_pos = i;
    if(a[i] == minn) minn_pos = i;
  }


  if(abs(maxx) > abs(minn)){
    for(int i = 0; i < n; i++){
      ans.push_back(pair<int,int>(maxx_pos+1,i+1));
    }
    for(int i = 0; i < n-1; i++){
      ans.push_back(pair<int,int>(i+1,i+2));
    }
  }else{
    for(int i = 0; i < n; i++){
      ans.push_back(pair<int,int>(minn_pos+1,i+1));
    }
    for(int i = n-1; i >= 1; i--){
      ans.push_back(pair<int,int>(i+1,i));
    }
  }

  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++){
    cout << ans[i].first << " " << ans[i].second << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n, d;
	cin>>n>>d;
	int a[n][d];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < d; j++)cin>>a[i][j];
	}	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		for(int k = i+1; k < n; k++){
			int s = 0;
			for(int j = 0; j < d; j++)s+=pow(a[i][j]-a[k][j], 2);
			if((int)sqrt(s)==sqrt(s))cnt++;
		}
	}
	cout<<cnt;
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 3684
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var X = Sarray()[0];
            if (X == 7 || X == 5 || X == 3)
                WriteLine("YES");
            else
                WriteLine("NO");
        }

        static long Mod = (long)1e9 + 7;
        private static int pl;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28168
import bisect

N = int(input())
L = input().split()
for i in range(0, N):
  L[i] = int(L[i])
L.sort()
ans = 0
for i in range(0, N-1):
  for j in range(i+1, N):
    a = L[i] + L[j]
    b = bisect.bisect_left(L, a)
    ans += b-j-1
print(ans)

Measured memory_bytes: 3188
N = int(input())
S = input()
s = list(S)

count = 0

for i in range(1000):
  ss = s[:]
  st = str(i).rjust(3, '0')
  if st[0] in ss:
    del ss[0:(ss.index(st[0])+1)]
    if st[1] in ss:
      del ss[0:(ss.index(st[1])+1)]
      if st[2] in ss:
        count += 1
else:
  print(count)
    

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
vector<int>v;
int ans;
int main() 
{
    string n;cin>>n;
    for(int i=0;i<n.size();i++)
    {
        v.push_back((int)(n[i]-'0'));
    }
    for(int i=0;i<v.size();i++)
    {
        if(v[i]==2||v[i]==4||v[i]==5||v[i]==7||v[i]==9)
        {
            ans=1;
        }
        else if(v[i]==0||v[i]==1||v[i]==6||v[i]==8)
        {
            ans=2;
        }
        if(v[i]==3)
        {
            ans=3;
        }
    }
    if(ans==1)
    {
        cout<<"hon";return 0;
    }
    else if(ans==2)
    {
        cout<<"pon";return 0;
    }
    else if(ans==3)
    {
        cout<<"bon";return 0;
    }
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

vector<vector<int>> G;  //グラフ
int dp[100100];  // dp[i]はノードiを始点にしたときの最大長

int rec(int v) {
  if (dp[v] != -1) return dp[v];
  int res = 0;
  for (auto nv : G[v]) {
    res = max(res, rec(nv) + 1);
  }
  return dp[v] = res;
}

int main(void) {
  int N, M;
  cin >> N >> M;
  G.assign(N, vector<int>());
  for (int i = 0; i < M; i++) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    G[s].push_back(t);
  }
  for (int i = 0; i < N; i++) dp[i] = -1;
  int res = 0;
  for (int i = 0; i < N; i++) res = max(res, rec(i));
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 8192
gets                      
s = gets.chomp.chars      
                          
ans = 0                   
x = 0                     
s.each do |c|             
  x += 1 if c == 'I'      
  x -= 1 if c == 'D'      
  ans = [x, ans].max      
end                       
                          
puts ans                  


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-

class Card:
    def __init__(self, str):
        self.suit  = str[0]
        self.value = int(str[1])

    def __str__(self):
        return self.suit + str(self.value)

def swap(A, i, j):
    tmp  = A[i]
    A[i] = A[j]
    A[j] = tmp

def BubbleSort(C, N):
    for i in range(N):
        for j in range(N-1, i, -1):
            if C[j].value < C[j-1].value:
                swap(C, j, j-1)  # C[j] と C[j-1] を交換

def SelectionSort(C, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if C[j].value < C[minj].value:
                minj = j
        swap(C, i, minj)  # C[i] と C[minj] を交換

def isStable(A, B):
    for i in range(1, len(B)):
        if B[i-1].value == B[i].value:
            for j in range(len(A)):
                if A[j] == B[i-1]: break
                if A[j] == B[i]:   return False
    return True

N = int(input())
A = [Card(t) for t in input().split()]
if len(A) != N: raise

B = A[:]
S = A[:]
BubbleSort(B, N)
SelectionSort(S, N)
print(' '.join(map(str, B)))
print('Stable' if isStable(A, B) else 'Not stable')
print(' '.join(map(str, S)))
print('Stable' if isStable(A, S) else 'Not stable')


Measured memory_bytes: 5616
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	A, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	B, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	C, _ := strconv.Atoi(sc.Text())

	if C-(A-B) > 0 {
		fmt.Println(C - (A - B))
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

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() {
  ll H, W, C1, C2, D1, D2;
  string S;
  
  cin >> S;
  
  if(S[0]=='R' && S[1]=='R' && S[2]=='R'){
    cout << 3 << endl;
  }else if((S[0]=='R' && S[1]=='R') || (S[1]=='R' && S[2]=='R')){
    cout << 2 << endl;
  }else if(S[0]=='R' || S[1]=='R' || S[2]=='R'){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  
  
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define x first
#define y second
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const long long INF = 1e18;
const int mod = 100003;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
int a[105][2],n;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i][0] >> a[i][1];
	for(int i = 1;i <= n-2;i++) {
		if(a[i][0] == a[i][1]&&a[i+1][0] == a[i+1][1]&&a[i+2][0] == a[i+2][1]) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3636
def valid?(a, b, c)
  a <= b + c && b <= c + a + 1 && c <= a + b + 1
end
 
def calc(rear, front, west, east, north, south, limit, best)
  path = Array.new(limit, 0)
  i = 0
  while i < limit
    a = rear + front
    b = west + east
    c = north + south
 
    if east > 0 && valid?(b - 1, c, a)
      rear, front, west, east = east - 1, west, rear, front
      y = 69
    elsif north > 0 && valid?(c - 1, a, b)
      rear, front, north, south = north - 1, south, front, rear
      y = 78
    elsif south > 0 && valid?(c - 1, a, b)
      rear, front, north, south = south - 1, north, rear, front
      y = 83
    #elsif west > 0 && valid?(b - 1, c, a)
    else
      rear, front, west, east = west - 1, east, front, rear
      y = 87
    end
     
    if best
      x = best[i]
      return best if x < y
      best = nil if x > y
    end
    path[i] = y
    i += 1
  end
  path
end
 
def find(target, limit)
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if valid?(a, b, c)
      best = calc(rear, front, west, east, north, south, limit, best)
    end
  end
  best
end
 
loop do
  target = gets.split.map!(&:to_i)
  break if target.all?(&:zero?)
  p, q = gets.split.map!(&:to_i)
  result = find(target, q)
  puts result ? result[p-1..-1].pack('C*') : 'impossible'
end

Measured memory_bytes: 87884
a,b,k=map(int,input().split())
if(b-a<300):
  for i in range(b-a+1):
    if(a+i<=a+(k-1)):
      print(a+i)
    elif(a+i>=b-(k-1)):
      print(a+i)
else:
  for i in range(k):
    print(a+i)
  for i in range(k):
    print(b-(k-1)+i)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] L = new int[N];
		for(int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
		sc.close();
		int r = 1;
		int d = 0;
		for(int i = 0; i < N; i++) {
			d += L[i];
			if(d <= X) r++;
			// System.out.println((i + 1) + " d = " + d + " r = " + r);
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<char>>;
using P =pair<int,int>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const ll mod=1000000007;

int main(){
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0){
        cout<<(n/x)*t<<endl;
    }else{
        cout<<((n/x)+1)*t<<endl;
    }
    
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

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

	int r = x % 100;
	int q = x / 100;

	if (r <= q * 5) {
		cout << "1" << endl;
	}
	else {
		cout << "0";
	}

}

Measured memory_bytes: 256
import sys
from itertools import permutations, combinations

N=input()
d=[ [ float("inf") for j in range(N+1) ] for i in range(N+1) ] 

KOUHO=[]
for i in range(N):
	L=map(int, sys.stdin.readline().split())
	d[i][i]=0
	for j in range(i+1,N):
		length=L[j]
		d[i+1][j+1]=length
		d[j+1][i+1]=length
		KOUHO.append( (length,i+1,j+1))


ans=0
for c,i,j in KOUHO:
	for k in range(1,N+1):
		if k==i or k==j: continue
		a=d[i][k]
		b=d[j][k]
		if a+b==c:
			break
		elif a+b<c:
			print -1
			quit()
	else:
		ans+=c

print ans


Measured memory_bytes: 40732
#include<iostream>
#include<string>
#include<utility>
#include<queue>
using namespace std;
typedef pair<string,int> book;
int main(){
  string word,com="";
  int page;
  priority_queue<book,vector<book>,greater<book> > index;
  while(cin >> word){
    cin >> page;
    index.push(book(word,page));
  }
  while(!index.empty()){
    com = index.top().first;
    cout << com << endl << index.top().second;
    index.pop();
    while(index.top().first == com){
      cout << " " << index.top().second;
      index.pop();
      if(index.empty()) break;
    }
    cout << endl;
  }
}

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int s, w;
    cin >> s >> w;
    if(w >= s)
        cout <<"unsafe\n";
    else
        cout <<"safe\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a, b, c, k, s;
  cin >> a >> b >> c >> k;
  
  if(k <= a+b ){
    s = min(k, a);}
  else s = 2*a+b-k;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3600
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int a, b; cin >> a >> b;

    int ans = (a + b + 1) / 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int N;
  cin >> N;
  vector<int> l; l.resize(N);
  for (int i = 0; i < N; ++i) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int sm = 0;
  for (int i = 0; i < N - 1; ++i) {
    sm += l[i];
  }
  if (sm > l.back()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();

    mat dp(n + 1, vec(m + 1, 0));
    vector<vector<char>> c(n + 1, vector<char>(m + 1, '.'));

    int mm = 0;
    REP(i, n){
        REP(j, m){
            if(s[i] == t[j]){
                dp[i + 1][j + 1] = dp[i][j] + 1;
                c[i + 1][j + 1] = s[i];
                mm = max(mm, dp[i + 1][j + 1]);
            }else{
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }
    int i0 = n + 1, j0 = m + 1;
    string ans = "";
    while(mm > 0){
        bool f = false;
        IREP(i, i0){
            IREP(j, j0){
                if(dp[i][j] == mm && c[i][j] != '.'){
                    ans += c[i][j];
                    i0 = i;
                    j0 = j;
                    f = true;
                    mm--;
                    break;
                }
            }
            if(f) break;
        }
    }
    REVERSE(ans);
    cout << ans;

    return 0;
}

Measured memory_bytes: 81664
#include "stdio.h"

int main(){
    char l[101];
  	long k;
    scanf("%s%d",l,&k);
  	if(k>100) k=100;
    for(int i=0;i<k;i++){
        if(l[i]!='1'){
            printf("%c\n",l[i]);
            return 0;
        }
    }
    printf("1\n");
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds; 

#define ff              first
#define ss              second
#define ll              int64_t
#define ld              long double
#define nl              cout<<"\n"
#define all(v)          v.begin(),v.end()
#define mset(a,v)       memset((a),(v),sizeof(a))
#define forn(i,a,b)     for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b)     for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)        {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                 {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                   {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)         {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

void dbg_out() {cerr<<"]\n";}
template<typename Head,typename... Tail> 
void dbg_out(Head H,Tail... T) {cerr<<H;if(sizeof...(Tail))cerr<<", ";dbg_out(T...);}
#ifdef LOCAL
	#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"] = [",dbg_out(__VA_ARGS__)
#else
	#define dbg(...)
#endif

ll count_digits(ll n)   {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p) {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;} 
ll mod_inv(ll a,ll m)   {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;} 
/* const ll MAXN=1000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>n>>k>>t;
	cout<<((n+k-1)/k)*t<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

const ll MX = 1e18;

int main() {
	ll a, bb;
	cin >> a;
	string b;
	cin >> b;
	bb = 100 * (b[0] - '0') + 10 * (b[2] - '0') + (b[3] - '0');
	a *= bb;
	a /= 100;
	cout << a << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  int a,b;
  cin>>a>>b;

  if(b%a==0) cout << a+b << endl;
  else cout << b-a << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    ll H,W,K;
    cin >> H >> W >> K;
    vector<vector<char>> c(H, vector<char>(W));
    for (long long i = 0; i < H; i++) {
        for (long long j = 0; j < W; j++) {
            cin >> c[i][j];
        }
    }
    // mout(c);

    ll ret=0;
    ll n = H;
    for (ll bit = 0; bit < (1<<n); bit++) {
        // V v;
        // for (ll i = 0; i < n; i++) {
        //     if(bit & (1<<i)) {
        //         v.push_back(i);
        //     }
        // }

        ll m = W;
        for (ll bitw = 0; bitw < (1<<m); bitw++) {
            // V w;
            // for (ll i = 0; i < m; i++) {
            //     if(bit & (1<<i)) {
            //         w.push_back(i);
            //     }
            // }

            ll cnt=0;
            for (long long i = 0; i < H; i++) {
                if(bit & (1<<i)) continue;
                for (long long j = 0; j < W; j++) {
                    if(bitw & (1<<j)) continue;
                    if(c[i][j]=='#') cnt++;
                }
            }

            if(cnt==K) ret++;

        }

    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3592
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if p[i]==i+1:
        p[i],p[i+1]=p[i+1],p[i]
        ans += 1
if p[-1]==n:
    ans += 1
print(ans)


Measured memory_bytes: 14008
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int n;
long long int a[200000];
map<pair<int, int>, long long int> res;

long long int solve(int i, int rest) {
	if ((n - i + 1) / 2 + (n - i + 1) % 2 < rest)
		return (long long int)-mod * 200000;
	if (rest == 0) return 0;
	// cout << i << " " << rest << endl;
	if (res.find(make_pair(i, rest)) != res.end())
		return res[make_pair(i, rest)];
	long long int ans = a[i] + solve(i + 2, rest - 1);
	if ((n - i) / 2 + (n - i) % 2 >= rest) ans = max(ans, solve(i + 1, rest));
	return res[make_pair(i, rest)] = ans;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cout << solve(0, n / 2) << endl;
}

Measured memory_bytes: 38008
#include <iostream>
#include <cmath>
#include <cfloat>

using namespace std;

int main() {
  int N, T, A;

  cin >> N >> T >> A;

  float min_diff = FLT_MAX;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int h;
    cin >> h;
    float temp = T - h * 0.006f;
    float diff = abs(A - temp);
    if (diff < min_diff) {
      min_diff = diff;
      ans = i + 1;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int r, c;
  cin >> r >> c;
  vector<vector<int>> table(r+1, vector<int>(c+1, 0));
  rep(i,r){
    rep(j,c){
      cin >> table.at(i).at(j);
      table.at(i).at(c) += table.at(i).at(j);
      table.at(r).at(j) += table.at(i).at(j);
      table.at(r).at(c) += table.at(i).at(j);
    }
  }
  rep(i,r+1){
    rep(j, c+1){
      cout << table.at(i).at(j);
      if(j!=c) cout << " ";
    }
    cout << endl;
  }


  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;
#define A

#ifdef A
int main(void)
{
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a %b << " ";
	printf("%f\n", static_cast<double>(a) / b);
	return 0;
}


#endif // A

#ifdef B
{

	return 0;
}
#endif // B


#ifdef C
int main(void)
{

	return 0;
}
#endif // C

#ifdef D
int main(void)
{
	return 0;
}

#endif // D

Measured memory_bytes: 3228
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &_a, T _b){
    if(_a < _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

template<typename T>
bool chmin(T &_a, T _b){
    if(_a > _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

int max_rectangle(const vector<int> &v){
    int res = 0;
    rep(left, v.size()){
        int mini = v[left];
        REP(right, left, v.size()){
            chmin(mini, v[right]);
            chmax(res, (right - left + 1) * mini);
        }
    }

    return res;
}

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

    int h, w;
    while(cin >> h >> w, h){
        vector<string> v(h);
        rep(i, h){
            cin >> v[i];
        }

        vector< vector<int> > t(h, vector<int>(w));
        rep(j, w){
            int cnt = 0;
            rep(i, h){
                if(v[i][j] == '.'){
                    t[i][j] = ++cnt;
                }else{
                    t[i][j] = 0;
                    cnt = 0;
                }
            }
        }

        int ans = 0;
        rep(i, h){
            chmax(ans, max_rectangle(t[i]));
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4272
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string
 
#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair
 
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>
 
#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >
 
#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>
 
 
#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
 
const int md = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);
 
ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}
 
ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}
 
int main()
{
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    ll pref[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(i==0)
         pref[i]=arr[i]+1;
         else
          pref[i]=pref[i-1]+arr[i]+1;
       
    }
    double res=0;
    for(int i=0;i<=(n-k);i++)
    {
        int l=i,r=i+k-1;
       if(i==0)
       {
           ll sum=pref[r];
        double tmp=(double)((double)sum/(double)2);
        if(tmp>res)
         res=tmp;
       }
       else
       {
           ll sum=pref[r]-pref[l-1];
            double tmp=(double)((double)sum/(double)2);
        if(tmp>res)
         res=tmp;
       }
    }
    cout.precision(17);
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 3328
n, m = map(int, input().split())
sub = [list(input().split()) for _ in range(m)]

ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]

for s in sub:
    if s[1] == 'AC':
        ac[int(s[0])-1] += 1
    elif ac[int(s[0])-1] == 0:
            wa[int(s[0])-1] += 1

ac_sum = 0
wa_sum = 0
for i in range(n):
    if ac[i] != 0:
        wa_sum += wa[i]
        ac_sum += 1
print(ac_sum, wa_sum)


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	sort(v.begin(), v.end());

	for (int i = 0; i < n - 1; i++) {
		if (v[i] == v[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#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 Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 999999999999

int main(){
  int A,B,count=0;
  cin>>A>>B;
  if(B==1) cout<<"0"<<endl;
  else if(A>=B) cout<<"1"<<endl;
  else{
    int i=0;
    do{
        count++; i++;
    }while((A-1)*(i-1)+A<B);
    cout<<count<<endl;
  }
  return 0;
}


Measured memory_bytes: 256