akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

ll nC2(ll n){
  return n*(n-1)/2;
}

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  vector<ll> sums(N+1);
  sums[0]=0;
  ll sum = 0;
  rep(i,N){
    sum += A[i];
    sums[i+1]=sum;
  }
  sort(sums.begin(), sums.end());
  //rep(i,N+1)cout << sums[i]<< endl;
  vector<int> v;
  int cnt=0;
  ll last=sums[0];
  rep(i,N+1){
    if(sums[i]==last){
      cnt++;
    }
    else{
      last = sums[i];
      v.pb(cnt);
      cnt=1;
    }
    if(i==N)v.pb(cnt);
  }
  //for(auto x:v){cout << x << endl;}
  ll ans = 0;
  for(auto x:v) ans += nC2(x);
  cout << ans << endl;
  return 0;
}


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

int main() {
  ll a;
  long double b;
  cin >> a >> b;
  ll ans = a * b;
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int a,b,i;
	string s;
	cin >> a >> b >> s;
	for(i=0;i<a;i++)
		if(!(s[i]>='0' && s[i]<='9'))
		{
			cout << "No\n";
			return 0;
		}
	if(s[a]!='-')
	{
		cout << "No\n";
		return 0;
	}
	for(i=a+1;i<a+b+1;i++)
		if(!(s[i]>='0' && s[i]<='9'))
		{
			cout << "No\n";
			return 0;
		}
	cout << "Yes\n";
 } 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a + b == c + d) {
        cout << "Balanced" << endl;
        quick_exit(0);
    }

    cout << (a + b < c + d ? "Right" : "Left") << endl;

    return 0;
}

Measured memory_bytes: 256
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(3
cbaa
daacc
acacac
)");
#endif
    int n;
    in >> n;
    vector<string> S(n);
    for (int i = 0; i < n; ++i) in >> S[i];

    vector<int> whole_counter(26);
    for (int& c : whole_counter) c = 100;

    for (int j = 0; j < n; ++j) {
        vector<int> counter(26);
        for (int k = 0; k < S[j].length(); ++k) {
            counter[S[j][k] - 'a']++;
        }

        for (int i = 0; i < 26; ++i) {
            whole_counter[i] = min(whole_counter[i], counter[i]);
        }
    }

//    for (auto c : whole_counter) cout << c << " ";
//    cout << endl;

    for (int i = 0; i < 26; ++i) {
        cout << string(whole_counter[i], 'a' + i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    YES="Yes"
    NO="No"
    S=input()
    if S=='hi' or S=='hihi' or S=='hihihi' or S=='hihihihi' or S=='hihihihihi':
        print(YES)
    else:
        print(NO)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int a[6];
    For(i, 1, 6){
        cin>>a[i];
        if(a[i]==0){
            cout<<i;
            return;
        }
    }
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;




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

	    public MyScanner() {
	       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;
	    }
	}
		
	
		 public static void main(String[] args) throws IOException {
			 	PrintWriter out = new PrintWriter(System.out);
			    MyScanner sc = new MyScanner();
			 	Main solver = new Main();
				solver.solve(out, sc);
				out.flush();
				out.close();
			
		 }
	
		
		 
		 
		
 		void solve(PrintWriter out, MyScanner sc) throws IOException{	
 			
 			int n = sc.nextInt();
 			int k = sc.nextInt();
 			List<Integer> c = new ArrayList<>();
  			for(int i = 0 ; i < k ; ++i) c.add(sc.nextInt());
 			
 			String s;
 			
 			outer:
 			while(true) {
 				s = Integer.toString(n);
 				for(char cc : s.toCharArray()) {
 					if(c.contains(Integer.parseInt(cc + ""))) {
 						++n;
 						continue outer;
 					}
 				}
 				break;
 			}
 			out.print(s);
 					
 			
 			
 			
 		
 		}
 		
 		

 	
		
	
			
		
		
		
		
		
		
		
		
	
	
}



Measured memory_bytes: 36308
N,M,C = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for _ in range(N):
    A = list(map(int, input().split()))

    score = 0
    for a,b in zip(A,B):
        score += a*b
    
    if score + C > 0:
        ans += 1

print(ans)

Measured memory_bytes: 62136
import sys
import numpy as np
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
PY = [[int(x) for x in input().split()] for _ in range(M)]
for j in range(M):
    PY[j].append(j)
PY.sort()
A = [1] * (N+1)
ans = ["s"] * M
for i in range(M):
    temp = PY[i]
    P, Y = temp[0], temp[1]
    a = str(P).zfill(6)
    b = str(A[P]).zfill(6)
    A[P] += 1
    ans[temp[2]] = a + b
for k in ans:
    print(k)

Measured memory_bytes: 43564
/*
 * Click `Run` to execute the snippet below!
 */
 
import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    //Intializing array and input
    int N = sc.nextInt();
    int arr[] = new int[N+2];
    arr[0] = 0;
    arr[N+1] = 0;
    for(int i = 1; i<=N; i++){
      arr[i] = sc.nextInt();
    }
    //Expression 1
    int total = 0;
    for(int i = 1; i<=N+1; i++){
      total += Math.abs(arr[i-1] - arr[i]);
    }
    //Outputing answers
    for(int i = 1; i<=N; i++){
      System.out.println(total - Math.abs(arr[i] - arr[i-1]) - Math.abs(arr[i+1] - arr[i]) + Math.abs(arr[i+1] - arr[i-1])); 
    }
  }
}


Measured memory_bytes: 60312
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))

min = 10**6

result = 0

for i in range(len(H)):

    h = H[i]
    
    temp = T - (h*0.006)
    
    if min > abs(A-temp):
        min = abs(A-temp) 
        result = i+1
    
    
print(result)
    

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	double a[11]={},sum;
	while(cin>>a[1]){
		sum=a[1];
		rer(i,2,10){
			if(i%2) a[i]=a[i-1]/3;
			else a[i]=2*a[i-1];
			sum+=a[i];
		}
		printf("%.8lf\n",sum);
	}
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstring>
using namespace std;
char a[4005];
int main() {
    int N, cnt = 0;
    long long sum = 0;
    cin >> N >> a;
    for(int i = 0; i < N; i++)
        if(a[i] == 'B')
            cnt ++;
    for(int i = 0; i < N; i++)
        if(a[i] != 'R')
            continue;
        else for(int j = 0; j < N; j++) {
            if(j == i || a[j] != 'G')
                continue;
            else if(i < j) {
                sum += cnt - (2 * i - j  > 0 && a[2 * i - j] == 'B') - (2 * j - i  < N && a[2 * j - i] == 'B');
                if(i != j - 1)
                    sum -= ((i + j) % 2 == 0 && a[(i + j) / 2] == 'B');
            } else if(i > j) {
                sum += cnt - (2 * j - i  > 0 && a[2 * j - i] == 'B') - (2 * i - j  < N && a[2 * i - j] == 'B');
                if(i != j + 1)
                    sum -= ((i + j) % 2 == 0 && a[(i + j) / 2] == 'B');
            }
           // cout << i << " " << j << " " << sum << endl;
        }
    cout << sum << endl;
}


Measured memory_bytes: 3636
// --------------
// Tejas Pandey  |
// 19 - 01 - 20  |
// ABC #152      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n,m;
		cin >> n >> m;
		cout << (n == m? "Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 256
def hantei(x,y):
  for Z in range(-100,100+1):
    flag=True
    for i in x:
      if i>=Z:
        flag=False
        break
    for i in y:
      if i<Z:
        flag=False
        break
    if flag==True:
      return False
  return True

N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.append(X)
y.append(Y)
print("War" if hantei(x,y)==True else "No War")


Measured memory_bytes: 3064
import java.io.*;
class Main {
    public static void main(String[] args) {
        try {
           BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
           String[] s = reader.readLine().split(" ");
           int[] a = new int[5];
           for(int i = 0;i < a.length;i++) {
        	   a[i] = Integer.parseInt(s[i]);
           }
           for(int i = 0;i < a.length;i++) {
        	   int m = i;
        	   for(int j = i+1;j < a.length;j++) {
        		   if(a[m] < a[j])
        			   m = j;
        	   }
        	   int tmp = a[i];
        	   a[i] = a[m];
        	   a[m] = tmp;
           }
           for(int i = 0;i < a.length;i++) {
                   System.out.print(a[i]);
            	   if(i < a.length-1)
            		   System.out.print(" ");
           }
           System.out.println("");

         }
         catch(IOException e) {
          System.out.println(e);
         }
    }
}

Measured memory_bytes: 16896
while True:
        n =int (input())
        if n == 0:
            break
        data = [int(input()) for _ in range(n)]
        #print(data)
        i = 0
        for i in range(10):
            #print(i,data.count(i))
            if data.count(i) == 0:
                print('-')
            else:
                A = data.count(i)
                #print(A)
                for _ in range(A):
                    print('*', end="")
                print("")
            i = i + 1


Measured memory_bytes: 7684
using System;
namespace _163abc
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int[] syain = new int[N];
            for(int i = 0; i<A.Length;i++){
                syain[A[i]-1]++;
            }
            for(int i = 0; i<syain.Length;i++){
                Console.WriteLine(syain[i]);
            }
        }
    }
}

Measured memory_bytes: 39144
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
t = [0] * (N)
for i in range(1, N):
  t[i] = t[i-1] + (1 if (S[i-1] == "A" and S[i] == "C") else 0)
for _ in " " * Q:
  l, r = [int(lr) for lr in input().split(" ")]
  print(t[r-1]-t[l-1])

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

using namespace std;

int n;
stack<bool> a;
bool ans[200000];
int co = 0;

int main()
{
  	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        a.push(t);
    }

    for (int i = n; i > 0; i--)
    {
        int v = a.top();
        a.pop();

        int c = i;
        bool ne = 0;
        while (c + i <= n)
        {
            c += i;
            if (ans[c - 1])
                ne = !ne;
        }

        if (ne != v)
        {
            ans[i - 1] = 1;
            co++;
        }
        else
            ans[i - 1] = 0;
    }

    cout << co << "\n";
    for (int i = 0; i < n; i++)
    {
        if (ans[i] == 1)
            cout << i + 1 << " ";
    }

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









ll n,t,a,t2,a2,x,y;





void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t>>a;
		if(i==1)
		{
			t2=t;
			a2=a;
		}
		else
		{
			x=t2/t;
			if(x*t<t2)x++;
			y=a2/a;
			if(y*a<a2)y++;
			x=max(x,y);
			t2=t*x;
			a2=a*x;
		}
	}
	cout<<t2+a2<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int map[105][105];
bool mark1[105][105];
bool mark2[105][105];
int e[100005];
int main()
{
	int MIN,MAX;
	int i,j,k,n,sum;
	int cas = 1;
	//freopen("a.txt","r",stdin);
	while(scanf("%d",&n)!=EOF)
	{
	//	v.clear();
		sum = 0;
		if(n==0)break;
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				cin>>map[i][j];
				mark1[i][j] = 0;
				mark2[i][j] = 0;
			}
		}
		for(i=0;i<n;i++)
		{
			MIN = 0x7fffffff;
			for(j=0;j<n;j++)
			{
				if(map[i][j] < MIN)MIN = map[i][j];
			}
			for(j=0;j<n;j++)
			{
				if(map[i][j] == MIN)mark1[i][j] = 1;
			}
		}
		for(j=0;j<n;j++)
		{
			MAX = -0x7fffff;
			for(i=0;i<n;i++)
			{
				if(map[i][j]>MAX)MAX = map[i][j];
			}
			for(i=0;i<n;i++)
			{
				if(map[i][j] == MAX && mark1[i][j] == 1) 
				{
					e[sum ++]=map[i][j];
				}
			}
			
		}
		sort(e,e+sum);
		if(sum==0){cout<<0<<endl;continue;}
		j=0;
		for(i=1;i<sum;i++)
		{
			if(e[i]!=e[j])e[++j] = e[i];
		}
		
		
			for(i=0;i<=j;i++)cout<<e[i];
			if(i<j)cout<<' ';
			else cout<<endl;
		

	}
	return 0;

}

Measured memory_bytes: 0
// 頭いいコード
#include <bits/stdc++.h>
using namespace std;

const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
char land[20][20];

// 始点から地続きになっている部分を全部消す
void dfs(int y, int x) {
   land[y][x] = '0';
   for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny >= 0 && ny < 12 && nx >= 0 && nx < 12 && land[ny][nx] == '1') {
         dfs(ny, nx);
      }
   }
   return;
}

int main() {
   while (scanf("%s", land[0]) != EOF) {
      for  (int i = 1; i < 12; i++) {
         scanf("%s", land[i]);
      }

      int cnt = 0;
      for (int i = 0; i < 12; i++) {
         for (int j = 0; j < 12; j++) {
            // 黒ならそこに島があるのでカウントをプラス
            if (land[i][j] == '1') {
               cnt++;
               dfs(i, j);
            }
         }
      }

      printf("%d\n", cnt);
   }

   return 0;
}


Measured memory_bytes: 3128
X, Y = map(int, input().split())

def prize(a) :
    if a == 1 :
        return 300000
    elif a == 2 :
        return 200000
    elif a == 3 :
        return 100000
    else :
        return 0
        
ret = prize(X) + prize(Y)
if X == Y == 1 :
    ret += 400000
    
print(ret)

Measured memory_bytes: 38256
let [| K; X |] = stdin.ReadLine().Split() |> Array.map int

let rec resolver i =
    if i = X + K then ()
    elif i < -1000000 || 1000000 < i then resolver (i + 1)
    else
        printf "%d" i
        printf " "
        resolver (i + 1)

resolver (X - K + 1)


Measured memory_bytes: 11996
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
int main() {
	ll i, len, ans = 0, p2[111111], p3[111111],t;
	char s[111111];
	cin >> s;
	p2[0] = 1;
	p3[0] = 1;
	for (i = 1; i <= 100100; i++) {
		p2[i] = p2[i - 1] * 2 % M;
		p3[i] = p3[i - 1] * 3 % M;
	}
	len = 0;
	while (s[len] != '\0')
		len++;
	t = 1;
	for (i = 0; i < len; i++) {
		if (s[i] == '1') {
			ans = (ans + t * p3[len - i - 1] % M) % M;
			t = t * 2 % M;
		}
	}
	ans =(ans+t)%M;
	cout << ans << endl;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++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 irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

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;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );

  int n,d;cin>>n>>d;
  vvi x(n,vi(d));
  rep(i,n){
    rep(j,d) cin>>x[i][j];
  }
  int ans=0;
  rep(i,n-1){
    irep(ki,i+1,n){
      int total=0;
      rep(j,d){
        total+=(x[i][j]-x[ki][j])*(x[i][j]-x[ki][j]);
      }
      int sd=sqrt(total);
      if(sd*sd==total){
        ans++;
        // cout<<i<<" "<<ki<<" "<<total<<" "<<sd<<endl;
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
int n,m;
cin >> n >> m;
vector<int> s(m+1),c(m+1);
for (int i = 0;i < m;i++) cin >> s[i] >> c[i],--s[i];

for (int i = 0;i <= 2000;i++){
    string t = to_string(i);
    if(t.size()==n){
        bool can = true;
        for (int j = 0;j < m;j++){
            if(t[s[j]]-'0'!= c[j]){
                can = false;
            }
        }
        if(can) {
            cout << i << endl;
            return 0;
        }
    }
}
    cout << -1 << endl; 
}




Measured memory_bytes: 256
s=input()
n=len(s)
ans=0
p=s[0]
q=""
i=0
while i<n-1:
    if p==s[i+1]:
        ans+=1
        q=p
        p=s[i+1:i+3]
        i+=1
    else:
        ans+=1
        q=p
        p=s[i+1]
    i+=1
if i==n-1:
    if len(p)==1:
        if q!=p:
            ans+=1
    else:
        ans+=1

print(ans)


Measured memory_bytes: 3500
#include <iostream>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	
	for (int i = 0; i < N; i++)
	{
		int A;
		cin >> A;
	}
	
	int answer = 0;
	// K-1個ずつ選択する、i + (K - 1)ずつ変更する
	for (int i = 0; i < N; i = i + (K - 1))
	{
		answer++;
		// 最大値になった場合
		if (i + (K - 1) == N - 1)
		{
			break;
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

#include <atcoder/math>

int main() {
	int T;
	cin >> T;
	
	while (T--) {
		int N, M, A, B;
		scanf("%d %d %d %d", &N, &M, &A, &B);
		printf("%lld\n", atcoder::floor_sum(N, M, A, B));
	}
	return 0;
}


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


int main() {
    int N,K; cin >> N >> K;
    vector<vector<int>> M(K,vector<int>(102));
    
    rep(i,K){
        cin >> M.at(i).at(0);
        for(int j=1;j<M.at(i).at(0)+1;j++){
            cin >> M.at(i).at(j);
        }
    }


    vector<bool> ans(N,1); // いたずら受けるひとが1。もらったら0
    for(int i=0;i<K;i++){
        for(int j=1;j<M.at(i).at(0)+1;j++){
            int now=M.at(i).at(j)-1;
            if(ans.at(now)==1) ans.at(now)=0;
        }
    }

    int cnt=0;
    rep(i,N) if(ans.at(i)) cnt++;

    cout << cnt << endl;
}

Measured memory_bytes: 3636
def cal(n): return n*(n+1)//2

x=int(input())
ans=[1,cal(x)]
a=0
while 1:
    a+=1
    tmp=cal(sum(ans)//2)
    if tmp>x:
        ans[1]=sum(ans)//2
    elif tmp<x:
        ans[0]=sum(ans)//2
    elif tmp==x:
        print(sum(ans)//2)
        break
    if ans[1]-ans[0]==1:
        print(ans[1])
        break

Measured memory_bytes: 38384
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.IO
import qualified Data.Vector.Unboxed.Mutable as UM

main = do
  [h,w] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- h, w <= 400
  ss <- V.replicateM h BS.getLine
  -- forall s in ss. BS.length s == w
  arr <- newArray ((0,0),(h-1,w-1)) (-1) :: IO (IOUArray (Int,Int) Int)
  !black_and_white <- UM.new 2 :: IO (UM.IOVector Int)
  let search :: Int -> Int -> Int -> Int -> IO Int
      search !acc !k !i !j
        | i >= h = return acc
        | j >= w = search acc k (i+1) 0
        | otherwise = do
            v <- readArray arr (i,j)
            UM.write black_and_white 0 0
            UM.write black_and_white 1 0
            when (v == -1) $
              if (ss V.! i) `BS.index` j == '#'
              then search_black k i j -- black
              else search_white k i j
            nb <- UM.read black_and_white 0
            nw <- UM.read black_and_white 1
            search (acc + nb * nw) (k+1) i (j+1)
      search_black :: Int -> Int -> Int -> IO ()
      search_black !k !i !j
        | i < 0 || j < 0 || i >= h || j >= w = return ()
        | (ss V.! i) `BS.index` j == '#' = do
            v <- readArray arr (i,j)
            when (v == -1) $ do
              writeArray arr (i,j) k
              UM.modify black_and_white (+1) 0
              search_white k (i-1) j
              search_white k i (j-1)
              search_white k (i+1) j
              search_white k i (j+1)
        | otherwise = return ()
      search_white :: Int -> Int -> Int -> IO ()
      search_white !k !i !j
        | i < 0 || j < 0 || i >= h || j >= w = return ()
        | (ss V.! i) `BS.index` j == '.' = do
            v <- readArray arr (i,j)
            when (v == -1) $ do
              writeArray arr (i,j) k
              UM.modify black_and_white (+1) 1
              search_black k (i-1) j
              search_black k i (j-1)
              search_black k (i+1) j
              search_black k i (j+1)
        | otherwise = return ()
  result <- search 0 0 0 0
  {-
  arr' <- freeze arr :: IO (UArray (Int,Int) Int)
  forM_ [0..h-1] $ \i -> do
    print [arr' ! (i,j) | j <- [0..w-1]]
  -}
  print result


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

void output(){
int h,n,ans=0,a[100000];
  cin>>h>>n;
  for(int i=0;i<n;i++){
  cin>>a[i];
  ans=ans+a[i];
  }
  if(ans>=h){
  cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
    }
}
int main(){
output();
return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

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

    int dist = 0;
    int num = 0;
    for(num = 0; num < n; num++){
        dist += l[num];
        if(dist > x) break;
    }
    cout << num+1 << endl;
}

Measured memory_bytes: 3580
#include<iostream>


using namespace std;
 
int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;

    int k;
    cin >> k;

    if( (e-a) > k ){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#define max_n
using namespace std;
typedef long long ll;
int a[100000+20];

int main ()
{
	int n,i,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==i+1)
			ans++;
	}
	for(i=0;i<n-1;i++)
	{
		if(a[i]==i+1&&i+2==a[i+1])
		{
			ans--;
			i++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m1 = sc.nextInt();
		int d1 = sc.nextInt();
		int m2 = sc.nextInt();
		int d2 = sc.nextInt();
		
		int ans = m2 - m1;
		System.out.println(ans);
		
		sc.close();
		
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
		printf("hon");
	} 
	else if(N%10==0||N%10==1||N%10==6||N%10==8){
		printf("pon");
	}
	else{
		printf("bon");
	}
	return 0;
}

Measured memory_bytes: 1692
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
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;}
// clang-format on

map<int64_t, int> prime_factor(int64_t n) {
  map<int64_t, int> ret;
  for (int64_t i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

void solve(long long N) {
  ll ans = 0;
  for (auto p : prime_factor(N)) {
    ll dim = p.second;
    for (ll div = 1; div <= dim; div++) {
      ans++;
      dim -= div;
    }
  }
  ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


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

int main() {
    long n, ans = 0;
    cin >> n;
    vector<long> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(), a.end(), greater<long>());
    queue<long> que;
    rep(i, n - 1) {
        if(que.size() == 2) break;
        if(a.at(i) == a.at(i + 1)) {
            que.push(a.at(i));
            a.at(i) = a.at(i + 1) = -1;
        }
    }
    if(que.size() == 2) {
        ans = que.front();
        que.pop();
        ans *= que.front();
    }
    cout << ans << endl;
}

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


def main():
    from collections import deque

    h, w = map(int, input().split())
    a = [input() for _ in range(h)]
    dx = [0, 0, -1, 1]
    dy = [1, -1, 0, 0]
    dist = [[-1 for __ in range(w)] for _ in range(h)]
    blacks = deque()

    # See:
    # http://drken1215.hatenablog.com/entry/2019/05/05/223200?_ga=2.177845805.987014750.1556545680-1855989383.1556545680
    # https://blog.kichi2004.jp/2019/05/agc033/
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                dist[i][j] = 0
                blacks.append((i, j))

    while blacks:
        current = blacks.popleft()
        cur_x = current[1]
        cur_y = current[0]

        for i in range(4):
            next_x = cur_x + dx[i]
            next_y = cur_y + dy[i]

            if next_x < 0 or next_x >= w or next_y < 0 or next_y >= h:
                continue

            if dist[next_y][next_x] == -1:
                dist[next_y][next_x] = dist[cur_y][cur_x] + 1
                blacks.append((next_y, next_x))

    ans = 0

    for i in range(h):
        for j in range(w):
            ans = max(ans, dist[i][j])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88668
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


//for(i=0; i<N; i++) cin >> a[i];

ll D;
ll c[26];
ll s[366][26];

ll calcScore(vector<ll> sche) {
  ll score=0;
  ll i, j, k;
  ll p[26];
  for(i=0; i<26; i++) p[i]=-1;
  
  for(ll d=0; d<sche.size(); d++) {
    score+=s[d][sche[d]];
    
    p[sche[d]]=d;
    for(i=0; i<26; i++) score-=c[i]*(d-p[i]);
    
  }
  
  return score;
}

int main(void) {
  ll i, j, k;
  
  cin >> D;
  for(i=0; i<26; i++) cin >> c[i];
  for(i=0; i<D; i++) {
    for(j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  
  ll width=3;
  priority_queue<pair<ll, vector<ll>>> candidates;
  vector<vector<ll>> tops; tops.push_back({});
  
  for(ll d=0; d<D; d++) {
    
    for(k=0; k<tops.size(); k++) {
      for(i=0; i<26; i++) {
        tops[k].push_back(i);
        candidates.push({calcScore(tops[k]), tops[k]});
        tops[k].pop_back();
      }
    }
    
    tops.clear();
    for(i=0; i<min(width, (ll)candidates.size()); i++) {
      tops.push_back(candidates.top().sc);
      candidates.pop();
    }
    
    
  }
  
  for(i=0; i<D; i++) {
    ll t=tops[0][i]+1;
    if(1<=t&&t<=26) pt(t);
    else pt(1);
    
    
  }
  
  
}



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<ll> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];;

    int cnt = 0, ans = 0;
    for(int i = 0; i < n - 1; i++){
        if(h[i + 1] <= h[i]) cnt++;
        else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);

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


Measured memory_bytes: 4024
let a, b, c = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let rec f n a b c = if a mod 2 + b mod 2 + c mod 2 > 0 then n else if a = b && b = c then -1 else f (n + 1) (b / 2 + c / 2) (c / 2 + a / 2) (a / 2 + b / 2)
let _ = Printf.printf "%d\n" @@ f 0 a b c

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

long long f(long long x){
  if (x == 1){
    return 1;
  }
  
  else{
    x /= 2;
    long long c = 2*f(x) + 1;
    return c;
  }
}

int main() {
  long long H;
  cin >> H;
  long long ans = f(H);
  cout << ans << endl;
}



Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));   
   let candy = xs.sort((a, b) => b - a);
   //console.log(candy);
   let result = 0;                                    
     for(let i =1; i<xs.length; i++){
   	    result +=candy[i];
      }
  //console.log(result);
   //console.log(candy[0]);
   if(result==candy[0]){
     console.log("Yes");
   }else{
   	 console.log("No");
   }
     
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h,a;
    cin>>h>>a;
    if(h%a)h+=a;
    cout << h/a<<endl;
    return 0;
}


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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
    ll n; cin >> n;
    ll ans = 0;
    rep(i,1,n){
        if(i % 3 == 0 || i % 5 == 0) continue;
        else ans += i;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3644
N = int(input())
s = list(map(int , input().split()))
list.sort(s , reverse = True)
L = [10**10]
for p in range(min(s) , max(s) + 1):
  a = 0
  b = L[0]
  for i in range(N):
    if a < b:
      a += (s[i] - p) ** 2
  if a < b:
    L[0] = a
print(L[0])

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define rep(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define rrep(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    vector<map<char,int>> alf(N);

    rep(i,0,N){
        string s;
        cin>>s;
        rep(j,0,s.size()){
            ++alf[i][s[j]];
        }
    }
    string ans = "",abc = "abcdefghijklmnopqrstuvwxyz";
    
    rep(i,0,abc.size()){
        int cnt = INF;
        rep(j,0,N){
            cnt = min(alf[j][abc[i]],cnt);
        }
        rep(j,0,cnt) ans += abc[i];
    }

    put(ans);
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  if(a>c){
    cout << "NO";
    return 0;
  }

  if(b>= c-a){
    cout << "YES";
  }
  else
  {
    cout << "NO";
  }

}


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

int main() {
	string s; cin >> s;
	string ans = "";

	int a = 0, b = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') { a = i; break; }
	}
	for (int i = s.size() - 1; i > 0; i--) {
		if (s[i] == 'Z') { b = i; break; }
	}

	cout << b - a + 1 << endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  int i,j,n,a[100],mn,tmp,cnt=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }

  for(i=0;i<n;i++)
    {
      mn = i;
      for(j=i;j<n;j++)
	{
	  if(a[j]<a[mn])mn = j;
	}
      if(a[mn]!=a[i])
	{
	  tmp = a[mn];
	  a[mn] = a[i];
	  a[i] = tmp;
	  cnt++;
	}
    }
  for(i=0;i<n;i++)
    {
      if(i!=0)printf(" ");
      printf("%d",a[i]);
    }
  printf("\n%d\n",cnt);

  return 0;
}



Measured memory_bytes: 2044
import re

str = input()
k = int(input())

strl = list(set([c for c in str]))
strl.sort()

substring = []
for h in strl:
	compiled = re.compile(h)
	st = 0
	m = compiled.search(str, st)
	while m:
		sub = m.start()
		for i in range(sub, min(len(str), sub+5)):
			t = str[sub:i+1]
			if(not (t in substring)):
				substring.append(t)
		st = sub + 1
		m = compiled.search(str, st)
	
	if(len(substring)-len(strl) >= k-1):
		break


substring.sort()
print(substring[k-1])

Measured memory_bytes: 3444
n = int(input())
num = list(map(int,input().split()))

str = "APPROVED"

for i in range(n):
    if num[i] % 2 == 0:
        if num[i] % 6 != 0 and num[i] % 10 != 0:
            str = "DENIED"
            break

print(str)

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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define all(x) x.begin(),x.end()
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
const int N=2e6+10, mod=998244353;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	ll n,a,b;
	cin>>n>>a>>b;
	if( (b-a+1)&1 ){
		cout<<(b-a+1)/2;
	}else {
		cout<<min( min( a,n-b+1 )+(b-a)/2, min(n-a,b-1));
	}
	
    yogeshk972();
}


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

using namespace std;
using ll = long long;
vector<vector<int>> v(100001);
vector<int> dp(100001, -1);

int solve(int a)
{
    if (dp[a] != -1)
        return dp[a];
    int ans = 0;
    for (int i = 0; i < v[a].size(); i++)
    {
        ans = max(ans, solve(v[a][i]) + 1);
    }

    return dp[a] = ans;
}

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans = max(ans, solve(i));
    }
    cout << ans << "\n";
}


Measured memory_bytes: 11056
#include<bits/stdc++.h>
using namespace std;
#define fastIO() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"

int main()
{
    fastIO();

    string x;
    cin>>x;
    int sz=x.size();
    if(x[sz-1]=='s')
        x+="es";
    else
        x+="s";
    cout<<x<<endl;

    return 0;
}



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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int n, m; cin >> n >> m;
    vector<int> rows[n + 2];
    vector<int> cols[m + 2];
    int lastOR[n + 2];
    int lastOC[m + 2];
    mm(lastOR); mm(lastOC);
    string mat[n + 2];
    string s = " ";
    for(int i = 0; i < m + 2; i++){
        s += '#';
    }
    mat[0] = s;
    mat[n + 1] = s;
    for(int i = 1; i <= n; i++){
        cin >> mat[i];
        mat[i] = '#' + mat[i];
        mat[i] += '#';
    }
    for(int i = 0; i <= n + 1; i++){
        for(int j = 0; j <= m + 1; j++){
            if(mat[i][j] == '#'){
                rows[i].pb(j);
                cols[j].pb(i);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i <= n + 1; i++){
        for(int j = 0; j <= m + 1; j++){
            if(mat[i][j] == '.'){
                int curr = j - lastOR[i] + i - lastOC[j] - 1;
                int ind = lower_bound(rows[i].begin(), rows[i].end(), j) - rows[i].begin();
                if(rows[i].size() == ind){
                    curr += m - j - 1;
                }
                else{
                    ind = rows[i][ind];
                    curr += ind - j - 1;
                }
                ind = lower_bound(cols[j].begin(), cols[j].end(), i) - cols[j].begin();
                if(ind == cols[j].size()){
                    curr += n - i - 1;
                }
                else{
                    ind = cols[j][ind];
                    curr += ind - i - 1;
                }
                ans = max(ans, curr);
            }
            else{
                lastOR[i] = j;
                lastOC[j] = i;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 45708
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n;
int main(){
cin>>n;
cout<<n*32<<endl;
	return 0;
}









Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> d(n);
	for(int i = 0; i < n; i++) scanf("%d", &d[i]);

	std::vector<int> vec(13); vec[0]++;
	for(auto e: d) vec[e]++;

	if(vec[0] > 1) {
		printf("0\n");
		return 0;
	}
	for(auto e: vec) {
		if(e < 3) continue;
		printf("0\n");
		return 0;
	}

	std::vector<int> free;
	std::vector<int> latte(1, 0);
	for(int i = 1; i < 13; i++) {
		if(!vec[i]) continue;
		if(vec[i] == 1) free.push_back(i);
		if(vec[i] == 2) {
			latte.push_back(i);
			latte.push_back(24 - i);
		}
	}

	int ans = 0;
	for(int i = 0; i < (1 << free.size()); i++) {
		std::vector<int> malta = latte;

		for(int j = 0; j < free.size(); j++) {
			if(i >> j & 1) malta.push_back(free[j]);
			else malta.push_back(24 - free[j]);
		}

		int tmp = 1 << 30;
		for(int j = 0; j < malta.size(); j++)
			for(int k = j + 1; k < malta.size(); k++)
				tmp = std::min(tmp, std::min(std::abs(malta[j] - malta[k]) % 24
											, 24 - std::abs(malta[j] - malta[k]) % 24));
		ans = std::max(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256