akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,k = map(int,readline().split())
ans = 0
if k == 0:
    print(n**2)
    exit()
for b in range(1,n+1):
    if b <= k:
        continue
    #a=nとして考えて良い。
    ans += n//b*(b-k)
    ans += max(0,n%b-(k-1))

print(ans)




Measured memory_bytes: 39152
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define XMAX 10000

int main(void)
{
  unsigned short *X, *Y;
  
  int Z[XMAX+1];
  int h, i, j;
  scanf("%d",&h);
  
  X = malloc(sizeof(short)*h+1);
  Y = malloc(sizeof(short)*h+1);
  
  for(i=0;i<=XMAX;i++) Z[i] = 0;
  
  for(i=0;i<h;i++) {
    scanf("%hu",&X[i+1]);
    Z[X[i+1]]++;
  }
  
  for(i=1;i<=XMAX;i++) Z[i] = Z[i] + Z[i-1];
  
  for(j=1;j<=h;j++) {
    Y[Z[X[j]]] = X[j];
    Z[X[j]]--;
  }
  
  for(i=1;i<=h;i++) {
    if(i>1) printf(" ");
    printf("%d",Y[i]);
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
int n;
double a[3001],mem[3001][3001];
double dp(int i ,int s){
    if(i==n && s>n-s) return 1;
    else if(i==n && s<=n-s) return 0;

    if(mem[i][s]!=-1) return mem[i][s];

    return mem[i][s]=a[i]*dp(i+1,s+1)+(1-a[i])*dp(i+1,s);


}

int main(){
    for(int i=0;i<3001;i++)
        for (int j=0;j<3001;j++)
        mem[i][j]=-1;
    cin>>n;
    for (int i=0;i<n;i++)
        cin>>a[i];
    cout<<fixed<<setprecision(10)<<dp(0,0);

}



Measured memory_bytes: 70912
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  string ans1 = "", ans2 = "";
  rep(i,ty-sy){
    ans1 += "U";
    ans2 += "D";
  }
  rep(i,tx-sx){
    ans1 += "R";
    ans2 += "L";
  }
  cout << ans1+ans2+"LU"+ans1+"RDRD"+ans2+"LU";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3680
def lcm(a):
    import math
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // math.gcd(x, a[i])
    return x


def resolve():
    N = int(input())
    T = [int(input()) for _ in range(N)]
    print(lcm(T))


resolve()


Measured memory_bytes: 9052
using System;
using System.Collections.Generic;
using static System.Math;

class D
{
	static void Main()
	{
		var l = int.Parse(Console.ReadLine());

		int p = (int)Log(l, 2), q = (int)Pow(2, p);
		var r = new List<string>();

		for (int i = 1; i <= p; i++)
		{
			r.Add($"{i} {i + 1} 0");
			r.Add($"{i} {i + 1} {Pow(2, i - 1)}");
		}
		for (int q2 = q / 2, t = l - q, d = q; t > 0; q2 /= 2)
		{
			if (t < q2) continue;
			var pt = (int)Log(t, 2);
			r.Add($"{pt + 1} {p + 1} {d}");
			t -= q2;
			d += q2;
		}
		Console.WriteLine($"{p + 1} {r.Count}");
		Console.WriteLine(string.Join("\n", r));
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <queue>
 
using namespace std;
 
struct range_edge_graph {
    int n;
    struct edge { int to; long long weight;};
    vector<vector<edge>> g;
    
    range_edge_graph(int n_) {
        n = 1;
        while (n < n_) n <<= 1;
        g.resize(n<<2);
        for (int i = 1; i < n; ++i) {
            int c1 = i<<1|0, c2 = i<<1|1;
            g[i].push_back({c1, 0});
            g[i].push_back({c2, 0});
            g[c1+2*n].push_back({i+2*n, 0});
            g[c2+2*n].push_back({i+2*n, 0});
        }
        for (int i = n; i < 2*n; ++i)
            g[i].push_back({i+2*n, 0});
    }
 
    // from [l1, r1) to [l2, r2)
    void add_edge(int l1, int r1, int l2, int r2, int w) {
        int id = g.size();
        l1 += n, r1 += n;
        while (l1 < r1) {
            if (l1 & 1) g[l1+2*n].push_back({id, 0}), l1++;
            if (r1 & 1) --r1, g[r1+2*n].push_back({id, 0});
            l1 >>= 1, r1 >>= 1;
        }
        vector<edge> node;
        l2 += n, r2 += n;
        while (l2 < r2) {
            if (l2 & 1) node.push_back({l2++, w});
            if (r2 & 1) node.push_back({--r2, w});
            l2 >>= 1, r2 >>= 1;
        }
        g.push_back(node);
    }
 
    vector<long long> dijkstra(int s) {
        s += n;
        vector<long long> dist(g.size(), numeric_limits<long long>::max());
        dist[s] = 0;
        using P = pair<long long, long long>;
        priority_queue<P, vector<P>, greater<P>> que;
        que.emplace(0, s);
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (edge& e : g[v]) {
                if (dist[e.to] > dist[v] + e.weight) {
                    dist[e.to] = dist[v] + e.weight;
                    que.emplace(dist[e.to], e.to);
                }
            }
        }
        vector<long long> res(dist.begin() + n, dist.begin() + 2*n);
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int n, m;
    cin >> n >> m;
    range_edge_graph g(n);
 
    for (int i = 0; i < m; ++i) {
        int l, r, c;
        cin >> l >> r >> c;
        l--; r--;
        g.add_edge(l, r+1, l, r+1, c);
    }
    auto dist = g.dijkstra(0);
    long long ans = dist[n-1];
    cout << (ans == numeric_limits<long long>::max() ? -1 : ans) << endl;
}

Measured memory_bytes: 99524
n,k = map(int,input().split())
a = list(map(int,input().split()))
from collections import Counter
ca = dict(Counter(a))
ca=sorted(ca.items(), key=lambda x:x[1])
cnt = len(ca)-k
res = 0
for i in range(cnt):
    res += ca[i][1]
print(res)

Measured memory_bytes: 40568
#include<stdio.h>

int main(void){

int W, H, x, y, r;

scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){

printf("Yes\n");

}

else{

printf("No\n");

} 

return 0;

} 

Measured memory_bytes: 584
#include<iostream>

using namespace std;

int main(void){
  int n,a,b,c;

  cin >> n;
  while(n--){
    cin >> a >> b >> c;
    if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
    #define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
    #define dofloat cout<<fixed<<setprecision(8)
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define bitcount __builtin_popcount
    #define all(vec) vec.begin(),vec.end()
    #define rall(vec) vec.rbegin(),vec.rend()
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef vector<long long> vl;
    typedef pair<long long,long long> pll;
    typedef vector<pair<long long,long long> > vll;
    typedef vector<pair<int,int> > vii;
    typedef vector<int> vi;
    typedef pair<int,int> ii;
    const long long MOD=1000000007;
    const long long MAX=100005;
    const long double PI=3.14159265359;
    const long double G=9.807;
    const long long INF=1e18;
    const long double EPS=1e-6;
    ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
    bool isprime(ll a){
      if(a==2)return 1;
      if(!(a&1))return 0;
      for(ll i=3;i*i<=a;i+=2)
        if(a%i==0)return 0;
      return 1;
    }
    ll mpow(ll base,ll exponent,ll modulus){
      if(modulus==1)return 0;
      long long result = 1;
      base=base%modulus;
      while(exponent){
        if(exponent%2 == 1)
        result=(result*base)%modulus;
        exponent=exponent>>1;
        base=(base*base)%modulus;
      }
      return result;
    }
    ll minv(ll a,ll mod){
      ll _gcd=gcd(a,mod);
      assert(_gcd==1);
      return mpow(a,mod-2,mod);
    }
     
     
    /*
    ll ncr(ll N,ll K){
      if(N<K)return 0;
      if(K==0)return 1;
      if(N==0)return 0;
     
      ll den=1;
      for(ll i=1;i<=K;i++)den*=i;
      ll num=1;
      while(K--){
        num*=N;
        if(num%den==0){
          num/=den;
          den=1;
        }
        N--;
      }
     
      return num;
    }
    */
    ll x;
    int main(){FAST;
    cin>>x;
    ll ok = 0;
    while(x){
      if(x%10 == 7)ok = 1;
      x/=10;
    }
    if(ok)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
    }
     
    /*
     WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
     Read the question again and see what you might have missed.
     Consider changing your solution or find more cases.
     */

Measured memory_bytes: 3608
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int n, ans;
char c[100010];

int main(){

	scanf("%d%s", &n, c + 1);
	for(int i = 1; i <= n; i++)
		if(c[i] != c[i - 1])
			ans++;
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
for i in range(2, n, 2):
    head = s[:-i]
    is_ok = True
    for j in range(len(head)//2):
        if head[j] != head[j + len(head)//2]:
            is_ok = False
    if is_ok:
        print(len(head))
        break

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

int main() {
	int n,k,m;
	bool nu[100001]={};
	while(1){
		cin >> n >> k;
		if(n==0){return 0;}
		for(int i=0;i<=n;i++){
			nu[i]=false;
		}
		for(int i=0;i<k;i++){
			cin >> m;
			nu[m]=true;
		}
		int s=0,ws=0,ms=0,mws=0;
		for(int i=1;i<=n;i++){
			if(nu[i]){
				s++;
				ws++;
			}else{
				if(s>ms){ms=s;}
				if(ws>mws){mws=ws;}
				ws=s+1;
				s=0;
			}
		}
		if(s>ms){ms=s;}
		if(ws>mws){mws=ws;}
		if(nu[0]){
			cout << mws << endl;
		}else{
			cout << ms << endl;
		}
	}
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	bool flag[8] = {false};
	int ans_min = 0;
	int ans_max = 0;
	for(int i = 0; i < n; i++)
	{
		if(flag[0] == false && a[i] >= 1 && a[i] <= 399)
		{
			flag[0] = true;
			ans_min++;
			ans_max++;
		}
		else if(flag[1] == false && a[i] >= 400 && a[i] <= 799)
		{
			flag[1] = true;
			ans_min++;
			ans_max++;
		}
		else if(flag[2] == false && a[i] >= 800 && a[i] <= 1199)
			{
			flag[2] = true;
			ans_min++;
			ans_max++;
		}
		else if(flag[3] == false && a[i] >= 1200 && a[i] <= 1599)
			{
			flag[3] = true;
			ans_min++;
			ans_max++;
		}
		else if(flag[4] == false && a[i] >= 1600 && a[i] <= 1999)
			{
			flag[4] = true;
			ans_min++;
			ans_max++;
		}
		else if(flag[5] == false && a[i] >= 2000 && a[i] <= 2399)
			{
			flag[5] = true;
			ans_min++;
			ans_max++;
		}
		else if(flag[6] == false && a[i] >= 2400 && a[i] <= 2799)
			{
			flag[6] = true;
			ans_min++;
			ans_max++;
		}
		else if(flag[7] == false && a[i] >= 2800 && a[i] <= 3199)
			{
			flag[7] = true;
			ans_min++;
			ans_max++;
		}
		else if(a[i] >= 3200)
		{
			ans_max++;
		}
	}
	
	if(*min_element(a.begin(), a.end()) >= 3200)
	{
		ans_min++;
	}
	
	cout << ans_min << " " << ans_max << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    int cntodd=0, n, a, i;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a;
        if(a%2!=0) cntodd++;
    }

    if(cntodd%2==0) cout <<"YES" << endl;
    else  cout << "NO" << endl;

    return 0;
}
    


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{

	int N,i,p=1,ans=0;
	int a[200001];
	scanf("%d", &N);

	for (i = 0;i < N;i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0;i < N;i++) {
		if (a[i] == p) {
			p++;
		}
	}
	

	if (p == 1)
		printf("%d", p - 2);
	else
		printf("%d", N - p+1);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

static long long sum (long long min, long long max) {
    return (min + max) * (max - min + 1) / 2;
}

int main (void) {
    int N, K;
    cin >> N >> K;

    long long ans = 0;
    long long min, max;

    for ( int i=K; i<=N+1; i++ ) {
        min = sum(0, i-1);
        max = sum(N-i+1, N);
        ans += (max - min + 1);
        ans %= 1000000007;
    }

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


Measured memory_bytes: 3592
using System;

class Program {
    static void Main( string[] args )
    {
        while ( true ) {
            string[] input = Console.ReadLine().Split();

            int h = int.Parse( input[ 0 ] );
            int w = int.Parse( input[ 1 ] );

            if ( 0 == h + w ) {
                break;
            }

            string b = new string( '#', w );

            if ( h > 0 && h < 3 ) {
                for ( int i = 0; i < h; ++i ) {
                    Console.WriteLine( b );
                }

            } else if ( h > 2 ) {
                string m;

                if ( w > 0 && w < 3 ) {
                    m = b;

                } else if ( w > 2 ) {
                    m = string.Concat( '#', new string( '.', w - 2 ), '#' );

                } else {
                    continue;
                }

                Console.WriteLine( b );

                for ( int i = 0; i < h - 2; ++i ) {
                    Console.WriteLine( m );
                }

                Console.WriteLine( b );

            } else {
                continue;
            }

            Console.WriteLine();
        }
    }
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int N;
    cin >> N;
    if(N == 1) PRINT("Hello World");
    else{
        int A, B;
        cin >> A >> B;
        PRINT(A + B);
    }
    return 0;
}

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

int main(){
    while (1){
        int H,W,i,j;
        cin>>H>>W;
        if (H==0 and W==0){
            break;
        }else{
        i=0;
        j=0;
            while ( i < H ){
                while ( j < W ){
                 cout<<"#" ;  
                 j++;
                }
                j=0;
                cout<<endl;
                i++;
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3100
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll a , b ;
	cin>> a>> b ;
	for(ll i=b-a+1 ; i<a+b ; i++)cout<<i<<" ";


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    sort(a.begin(), a.end(), greater<int>());
    int alice = 0, bob = 0;
    for(int i=0; i<n; i++){
        if(i%2 == 0) alice += a[i];
        else bob += a[i];
    }

    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define PI 3.14159265358979323846
const int MOD = 1e9 + 7 ;
const int EPS = 1e-9;
const int N=5*1e6;

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

      int a,b,c;
      cin>>a>>b>>c;
      if(a==b&&b==c) cout<<"Yes\n";
      else cout<<"No\n";      
}


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


int main(){
int N,M,X;
int count = 0;

int A[110];

cin >> N >> M >> X;
for(int i = 0; i < M; ++i){
cin >>A[i];
}

for(int i = 0; i < M; ++i){
if(A[i] < X){
++count;
}
}
if(count < M - count){
cout << count << endl;
}
else{
cout << M-count << endl;
}
}

Measured memory_bytes: 256
import itertools

n, m, q = map(int, input().split())

nums = []
for i in range(q):
    line = [int(s) for s in input().split()]
    line[0] -= 1
    line[1] -= 1
    nums.append(line)

candidate = []
for line in list(itertools.combinations_with_replacement(range(1, m + 1), n)):
    a = 0
    for num in nums:
        if line[num[1]] - line[num[0]] == num[2]:
            a += num[3]
    
    candidate.append(a)

print(max(candidate))


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

long long int pow(long long int n, long long int k) {
    if (k <= 0) return 1;
    else return n*pow(n, k-1);
}

int main() {
    long long int N, K;
    cin >> N >> K;

    long long int temp = pow(K-1, N-1);

    cout << K*temp << endl;
}

Measured memory_bytes: 256
Public Class Main
    Public Shared Sub Main(ByVal args() As String)
        Dim a, b As Char
        Dim arr(2) As String
        arr = Split(Console.ReadLine())
        a = arr(0) : b = arr(1)
        If a < b Then
            Console.WriteLine(New String(a, Integer.Parse(b)))
        Else
            Console.WriteLine(New String(b, Integer.Parse(a)))
        End If
    End Sub
End Class

Measured memory_bytes: 13532
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))

int main() {

	int n, i, max;
	scanf("%d", &n);

	unsigned short A[n+1];
	unsigned short B[n+1];

	max = (1<<30)*-1;
	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
		max = MAX(max, A[i+1]);
	}
	int C[max+1];
	memset(C, 0, sizeof(C));

	for (i = 0; i < n; i++) C[A[i+1]]++;
	for (i = 1; i <= max; i++) C[i] += C[i-1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

	ll sum = 0;
	vector<ll> a(n);
	for (auto& v : a) {
		cin >> v;
		sum += v;
	}

	vector<ll> memo = a;
	for (int i = 0; i < n - 1; i++) {
		memo[i + 1] += memo[i];
	}

	ll ans = 0;
	map<ll, ll> mp;
	mp[0]++;

	for (auto& v : memo) {
		if (mp.count(v) != 0 && mp[v] == 1) {
			ans++;
		} else if (mp.count(v) != 0 && mp[v] > 1) {
			ans += mp[v];
		}

		mp[v]++;
	}

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


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long d, t, s;
  cin >> d >> t >> s;
  
  if((float)d/t <= (float)s){
	  cout << "Yes" << endl;
  }else{
	  cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=a*b;
	y=c*d;
	if(x>=y){
			printf("%d\n",x);
	}
	else{
			printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = []
flag = 0
m = 0

for i in range(n):
    x = a.index(min(a))
    if a[0] > a[x]:
      a[0], a[x] = a[x], a[0]
      flag = flag + 1
    b.append(a[0]) 
    del a[0]
      
for k in range(n):
    print(b[k], end="")
    if k == n-1:
        print("")
    else:
        print(" ", end="")
print(flag)


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

const int maxn = 1e5 + 7 ;
vector < int > parent( maxn ) ;
vector < int > rnk ( maxn );


int find_parent ( int x )
{
    if ( parent[x] != x ) return find_parent (parent[x] ) ;
    return x ;
}

void dsu ( int u , int v )
{
     u = find_parent( u ) ;
     v = find_parent ( v ) ;
    
    if ( u != v ) 
    {
         if ( rnk [u] == rnk [v] )
         {
           parent [ u ] = v ;
           rnk [ v ] ++ ;
         }
        else if ( rnk [u] > rnk [v] )
        {
            parent [ v ] =  u ;
        }
        else 
        {
            parent [ u ] = v ;
        }
    }
}

int main ( )
{
    int n , m ;
    cin >> n >> m ;
    vector < int > a(n) ;
    for ( int i = 0 ; i < n ; i++ )
    {
         cin >> a[i] ;
         parent [ i +1 ] = i + 1 ;
    }
    
    for ( int i = 0 ; i < m ; i++ )
    {
         int x , y ;
         cin >> x >> y ;
         dsu ( x , y ) ;
    }
    
    int ans = 0 ;
    
    for ( int i = 0 ; i < n ; i++ )
    {
        if ( find_parent ( i+1 ) == find_parent ( a[ i ] ) ) ans ++ ;
    }
    cout << ans << endl ;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
struct bridge{
	vector<int>ord,low;
	vector<bool>art;
	vector<pair<int,int> >bridges;
	vector<vector<int> >G;
	bridge(int n_=0):ord(n_,-1),low(n_),art(n_,false),G(n_){}
	void add_edge(int u,int v)
	{
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bool operator[](int a){return art[a];}
	void dfs(int u,int p,int&cnt)
	{
		low[u]=ord[u]=cnt++;
		for(int&v:G[u])
		{
			if(ord[v]==-1)
			{
				dfs(v,u,cnt);
				low[u]=min(low[u],low[v]);
				art[u]=art[u]|ord[u]<=low[v];
				if(ord[u]<low[v])bridges.push_back(make_pair(u,v));
			}
			else if(v!=p)
			{
				low[u]=min(low[u],ord[v]);
			}
		}
	}
	void build()
	{
		int k=1,cnt=0;
		low[0]=ord[0]=0;
		for(int&v:G[0])if(ord[v]==-1)dfs(v,0,k),cnt++;
		if(cnt>=2)art[0]=true;
	}
};

main()
{
	int n,m;cin>>n>>m;
	bridge P(n);
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		P.add_edge(a,b);
	}
	P.build();
	for(int i=0;i<n;i++)if(P[i])cout<<i<<endl;
}



Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct TopologicalSort{
  int n;
  vector<set<int> > G;
  vector<bool> used;
  vector<int> indeg,p;
  
  TopologicalSort(){}
  TopologicalSort(int sz):n(sz),G(n),used(n),indeg(n),p(0){}

  void add_edge(int s,int t){
    G[s].insert(t);
  }
  
  void bfs(int s){
    queue<int> q;
    q.push(s);
    used[s]=1;
    while(!q.empty()){
      int v=q.front();q.pop();
      p.push_back(v);
      for(int u:G[v]){
	indeg[u]--;
	if(indeg[u]==0&&!used[u]){
	  used[u]=1;
	  q.push(u);
	}
      }
    }
  }
  
  vector<int>  build(){
    fill(used.begin(),used.end(),0);
    fill(indeg.begin(),indeg.end(),0);
    
    for(int i=0;i<n;i++)
      for(int v:G[i]) indeg[v]++;
    
    for(int i=0;i<n;i++)
      if(indeg[i]==0&&!used[i]) bfs(i);
    
    return p;
  }
};
//END CUT HERE

signed main(){
  int n,e;
  cin>>n>>e;
  TopologicalSort ts(n);
  for(int i=0;i<e;i++){
    int s,t;
    cin>>s>>t;
    ts.add_edge(s,t);
  }
  auto p=ts.build();
  for(int i:p) cout<<i<<endl;
  return 0;
}

/*
verified on 2017/12/09
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B&lang=jp
*/

Measured memory_bytes: 5740
#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>;
const int INF = 1000000007;
long long MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  int ma = (n - 1) * (n - 2) / 2;
  if (ma < k)
    cout << -1 << endl;
  else {
    vector<P> res;
    for (int i = 1; i <= n - 1; i++) res.push_back({i, n});
    int ci = 1, cj = 2;
    for (int w = 0; w < ma - k; ++w) {
      res.push_back({ci, cj});
      ++cj;
      if (cj == n) {
        ++ci;
        cj = ci + 1;
      }
    }
    cout << res.size() << endl;
    for (auto p : res) cout << p.first << " " << p.second << endl;
  }
}


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

bool x[300000]={};//false is prime
int y[100000]={};

int main(){
	int a;
	for (int i=2;i<260000;i++){
		for (int j=2;j<260000/i;j++){
			x[i*j]=1;
		}
	}
	x[0]=1;
	x[1]=1;
	int k=0;
	for (int i=2;i<260000;i++){
		if (x[i]==0){
			y[k]=i;
			k++;
		}
	}
		while(1){
		cin>>a;
		if (a==0) return 0;
		else {
			cout<<(upper_bound(y,y+k,a*2)-y)-(upper_bound(y,y+k,a)-y)<<endl;
			
		}
	}
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> masu(H, vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> masu.at(i).at(j);
    }
  }
  
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(masu.at(i).at(j)=='#'){
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for(int i=0; i<H; i++){
    if(row.at(i)){
      for(int j=0; j<W; j++){
        if(col.at(j)){
          cout << masu.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
<?php
$a = trim(fgets(STDIN)); //500
$b = trim(fgets(STDIN)); //100
$c = trim(fgets(STDIN)); //50
$x = trim(fgets(STDIN)); //6000とか
$ans = 0;
$a_s = $x/500;
for($i=0; $i<=$a_s; $i++){
	$x_1 = $x-500*$i;
	$b_s = $x_1/100;
	for($j=0; $j<=$b_s; $j++){
		$x_2 = $x_1-100*$j;
		$c_3=$x_2/50;
		if($c_3<=$c && $j<=$b && $i<=$a){
			$ans+=1;
		}
	}
}
echo $ans . "\n";
?>

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	int cost[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>cost[i];
	}
	int dp[n+1];
	dp[1] = 0;
	dp[2] = abs(cost[2]-cost[1])+dp[1];
	for(int i=3;i<=n;i++)
	{
//		cout<<"cost["<<i<<"]-cost["<<i-1<<"]: "<<cost[i]-cost[i-1]<<endl;
		int a = abs(cost[i]-cost[i-1]);
		int b = abs(cost[i] - cost[i-2]);
		dp[i] = min(a + dp[i-1], b + dp[i-2]);
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    sort(all(s));
    string t = "None";
    for(char c = 'a'; c != 'z' + 1; c++){
        bool flag = true;
        rep(i,s.length()){
            if(c == s[i]){
                flag =false;
                break;
            }
        }
        if(flag){
            t = c;
            break;
        }
    }
    cout << t << endl;
    return 0;
}

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

int main() {
    int x , y;
    cin >> x >> y;
    if ( x < y ) {
    cout << "a" << " < " << "b" << endl;
} else if ( x > y ) {
    cout << "a" << " > " << "b" << endl;
} else if ( x == y ) {
    cout << "a" << " == " << "b" << endl;
}
    return 0;
}


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

V = 0

if X == 1:
    V += 300000
elif X == 2:
    V += 200000
elif X == 3:
    V += 100000

if Y == 1:
    V += 300000
elif Y == 2:
    V += 200000
elif Y == 3:
    V += 100000

if X == 1 and Y == 1:
    V += 400000

print(V)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

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

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

int main() {
  string N;
  cin >> N;
  int count = 0;
  
  for(int i = 0; i < 3; i++) {
    if (N.at(i) == '7') {
      count++;
    }
  }
  
  if(count == 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
char a[100][100], b[100][100];
int main()
{
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i ++)
		scanf("%s", a[i] + 1);
	for(int i = 0; i < m; i ++)
		scanf("%s", b[i]);
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++)
		{
			int flag = 0;
			for(int x = 0; x < m; x ++)
				for(int y = 0; y < m; y ++)
					if(a[i + x][j + y] != b[x][y]) flag = 1;
			if(flag == 0) {cout << "Yes"; return 0;}
		}

	cout << "No";

	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = read().toCharArray()
    if (s[0].isUpperCase()) println("A") else println("a")



}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 34432
/*
 ***
 Question Name:
 ***
 Question Link:
 
 ***
 Idea:
 */

#include <memory.h>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef unordered_set<int> ui;
typedef pair<LL,LL> pLL;

class TransitTreePath{
    int N,K,Q;
    vector<vector<ii>> E;
    vL ans;
    void init(){
        cin>>N;
        E.resize(N);
        ans = vL(N,-1);
        for(int i=0;i<N-1;++i){
            int a,b,c;
            cin>>a>>b>>c;
            E[a-1].push_back(ii(b-1, c));
            E[b-1].push_back(ii(a-1, c));
        }
    }
    void constructTree(){
        --K;
        assert(K>=0 && K<N);
        queue<int> que;
        que.push(K);
        ans[K] = (LL)0;
        while (!que.empty()) {
            int i = que.front();
            que.pop();
            for(auto p:E[i]) if(ans[p.first]==-1){
                ans[p.first] = ans[i] + (LL)p.second;
                que.push(p.first);
            }
        }
        return ;
    }
public:
    void solve(){
        init();
        cin>>Q>>K;
        constructTree();
        for(int q=0;q<Q;++q){
            int x, y;
            cin>>x>>y;
            cout<< ans[x-1] + ans[y-1] <<endl;
        }
        return ;
    }
};



int main(){
    TransitTreePath().solve();
    return 0;
}

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

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


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

bool f(vector<ll> &a) {
  int N = (int)a.size();
  if (*max_element(ALL(a)) < N)
    return false;
  REP(i, N) a[i]++;
  *max_element(ALL(a)) -= (N+1);
  return true;
}

void print(const vector<ll> &a) {
  int N = (int)a.size();
  cout << N << endl;
  REP(i, N) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

int main2() {
  int N; cin >> N;
  vector<ll> a;
  REP(i, N) { ll x; cin >> x; a.push_back(x); }
  ll ans = 0;
  for (;;) {
    bool change = false;
    REP(i, N) {
      ll k = a[i] / N;
      if (k >= 1) {
        REP(j, N) {
          if (i == j) {
            a[j] -= k*N;
          } else {
            a[j] += k;
          }
        }
        ans += k;
        change = true;
      }
    }
    if (!change)
      break;
  }
  cout << ans << endl;
  return 0;
}

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


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
            int i, j;
            string nm = Console.ReadLine();
            string[] nmm = nm.Split(' ');
            int n = int.Parse(nmm[0]);
            int m = int.Parse(nmm[1]);
            int[,] men = new int[n, m];
            for (i = 0; i < n; i++)
            {
                string inp = Console.ReadLine();
                string[] data = inp.Split(' ');
                for (j = 0; j < m; j++)
                {
                    men[i, j] = int.Parse(data[j]);
                }
            }
            int[] b = new int[m];
            int[] c = new int[n];
            for (i = 0; i < n; i++)
            {
                c[i] = 0;
            }
            for (j = 0; j < m; j++)
            {
                b[j] = int.Parse(Console.ReadLine());
            }
            for (i = 0; i < n; i++)
            {
                for (j = 0; j < m; j++)
                {
                    c[i] += men[i, j] * b[j];
                }
            }
            for (i = 0; i < n; i++)
            {
                Console.WriteLine("{0}", c[i]);
            }
    }
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> vv;
    vector<int> c;
    int result = 0;
    for (int i = 0; i < n; i++)
    {
        int v;
        cin >> v;
        vv.push_back(v);
    }
    for (int i = 0; i < n; i++)
    {
        int v;
        cin >> v;
        c.push_back(v);
    }
    for (int i = 0; i < n; i++)
    {
        int x = vv[i] - c[i];
        if (x > 0)
        {
            result += x;
        }
    }

    cout << result << "\n";
}

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

using namespace std;
using ll = long long;

const long long inf = 1e9;
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;
typedef priority_queue<int> Pqi;
typedef priority_queue<ll> Pql;

ll n, m, k;
bool used[101];
int main () {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> k >> n;
	fr(i,0,n) {
		int x;
		cin >> x;
		used[x] = 1;
	}
	int dif = 1e9,b = -1;
	fr(i,0,101) {
		if (used[i])
			continue;
		if (abs(k - i) < dif) {
			b = i;
			dif = abs(k - i);
		}
	}
	if (abs(101 - k) < dif) {
		b = 101;
	}
	cout << b << endl;
	return 0; 
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(){
  
    int A, B, C;
  
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
  
    if (A >= B && A >= C) {
      printf("%d\n", 10*A + B + C);
    }
    else if (B >= A && B >= C) {
      printf("%d\n", 10*B + A + C);
    }
    else {
      printf("%d\n", 10*C + A + B);
    }
  
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio

	int n,ans=0;
	cin>>n;
	if(n>=1800)
		ans = 1;
	else if(n>=1600)
		ans = 2;
	else if(n>=1400)
		ans = 3;
	else if(n>=1200)
		ans = 4;
	else if(n>=1000)
		ans = 5;
	else if(n>=800)
		ans = 6;
	else if(n>=600)
		ans = 7;
	else if(n>=400)
		ans = 8;

	cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

void Main() {
    // input
    int N;
    cin >> N;
    long L[N];
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    // process
    int count = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if ((L[i] - L[j]) * (L[j] - L[k]) * (L[k] - L[i]) == 0) {
                    continue;
                }
                if ((abs(L[i] - L[j]) < L[k]) && (L[k] < L[i] + L[j])) {
                    count++;
                }
            }
        }
    }


    // output
    cout << count << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main() {
  int n, m;
  map<string, int> p;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    p[s]++;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    p[s]--;
  }
  int best = 0;
  for (auto x : p) {
    best = max(best, x.second);
  }
  cout << best << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    map<char, bool> m;
    for(char c = 'a'; c != '{'; c++){
        m[c] = false;
    }
    
    for(int i = 0; i < S.size(); i++){
        m[S[i]] = true;
    }
    
    for(auto a : m){
        auto ans_C = a.first;
        auto ans_Cnt = a.second;
        if(ans_Cnt == 0){
            cout << ans_C << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	string S; cin >> S;

	vector<int> W_sum(N+1,0);
	vector<int> E_sum(N+1,0);

	FOR(i,1,N+1){
		int isW = (S[i-1] == 'W' ? 1 : 0);
		int isE = (S[i-1] == 'E' ? 1 : 0);

		W_sum[i] = W_sum[i-1] + isW;
		E_sum[i] = E_sum[i-1] + isE;

	}

	int ans = E_sum[N] - E_sum[1];
	FOR(i,1,N-1){
		int w_cnt = W_sum[i] - W_sum[0];
		int e_cnt = E_sum[N] - E_sum[i+1];
		ans = min(ans, w_cnt + e_cnt);
	}
	ans = min(ans, W_sum[N-1]);

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool neg=c=='-';
	neg?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return neg?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
template<class T>inline void mset(T a,int v,int n){memset(a,v,n*sizeof(a[0]));}
inline void Main(){
	const int a=ni,b=ni;
	const int m=(a+b)/(min(a,b)+1);
	if(m==1){
		bool isA=a>=b;
		const int l=ni,r=ni;
		for(int i=l;i<=r;i++){
			putchar((i&1)==isA?'A':'B');
		}
		putchar('\n');
		return;
	}
	const int c1=((lint)(m+1)*a-a-b)/((lint)m*m-1);
	const int c4=((lint)(m+1)*b-a-b)/((lint)m*m-1);
	const int c2=a-m*c1-c4;
	const int c3=b-c1-m*c4;
	assert(c2<=m);
	assert(c3<=m);
	const int l=ni,r=ni;
	for(int i=l;i<=r;i++){
		int t=i;
		if(t<=c1*(m+1)){
			putchar(t%(m+1)?'A':'B');
		}else if(t-=c1*(m+1),t<=c2){
			putchar('A');
		}else if(t-=c2,t<=c3){
			putchar('B');
		}else if(t-=c3,t<=c4*(m+1)){
			putchar(t%(m+1)==1?'A':'B');
		}else{
			assert(false);
		}
	}
	putchar('\n');
}
int main(){
	for(int tot=ni;tot--;Main());
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <utility>
#include <map>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<string, PII> PSI;
typedef pair<vector<int>, vector<int>> PVV;
const int INF = 1 << 29;	// 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策

void solve()
{
	int P, Q, R;
	cin >> P >> Q >> R;

	int PQ, QR, RP;
	PQ = P + Q;
	QR = Q + R;
	RP = R + P;

	int ans;
	ans = min(min(PQ, QR), RP);

	cout << ans << endl;
}

int main(void)
{
	solve();

	return 0;
}


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


intl modpow(intl a, intl n, intl p){
  intl res = 1;
  while (n > 0){
    if (n&1){res = (res * a) % p;}
	a = (a * a) % p;
    n >>= 1;
  }
  return res;
}

intl modinv(intl a, intl p){
  if (a==0){
    cout << "/0 at modinv"<<endl;
    exit(0);
  }
  if (a < 0){
    cout << "/- at modinv" <<endl;
    exit(0);
  }
  if (a==1){return 1;}
  if (a > p){return modinv(a%p, p);}

  return p - ( modinv(p%a,p) * (p/a) ) % p;
}

intl modcomb(intl n, intl k, intl p){
  if (k > n || k < 0 || n < 0){
    cout << "error at modcomb"<<endl;
    exit(0);
  }
  if (2*k > n){ k = n-k;}
  if (k ==0){return 1;}
  intl c=1;
  for (intl i = 0; i < k; i++){
    c =( c * ( (n-i) % p ) % p ) * modinv(i+1,p) % p;
  }
  return c;
}

int main(){
  intl K;
  cin >> K;
  intl sum = 0;
  Rep(i,K){
    Rep(j,K){
      Rep(k,K){
        sum += __gcd( __gcd(j+1,k+1),i+1);
      }
    }
  }
  cout << sum;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    sort(ALL(a));
    reverse(ALL(a));
    ll ans = 0;
    for(int i = 0; i < n-1; i++){
        ans += a[(i+1)/2];
    }
    cout << ans;
    return 0;
}

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

using namespace std;

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		set<string> ss;
		for (int i = 0; i < n; i++) {
			string s;
			cin >> s;
			ss.insert(s);
		}
		cout << ss.size() << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 19224
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;

// bool 0 false, 1 true


int main() {
    string s;
    cin >> s;
    if(s == "SUN"){
        cout << 7 << endl;
    }
    if(s == "MON"){
        cout << 6 << endl;
    }
    if(s == "TUE"){
        cout << 5 << endl;
    }
    if(s == "WED"){
        cout << 4 << endl;
    }
    if(s == "THU"){
        cout << 3 << endl;
    }
    if(s == "FRI"){
        cout << 2 << endl;
    }
    if(s == "SAT"){
        cout << 1 << endl;
    }



}


Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()
    G = [[] for _ in range(N)]
    E = []
    for i in range(M):
        a,b = mi()
        a-=1; b -= 1 # 0-index

        G[a].append(b)
        G[b].append(a)
        E.append((a,b))
    
    deg1_v = -1
    for i in range(N):
        deg = len(G[i])
        if deg == 1:
            deg1_v = i
            break
    
    if deg1_v == -1:
        print(0)
        exit()

    ans = 0
    for i in range(M):
        a,b = E[i]
        G[a].remove(b)
        G[b].remove(a)

        visited_count = 0
        stack = deque([deg1_v])
        seen = set()
        visited = set()
        while stack:
            visited_count += 1
            current_e = stack.popleft()

            visited.add(current_e)
            for next in G[current_e]:
                if (current_e,next) in seen: continue
                stack.append(next)
                seen.add((current_e,next))
    
        if len(visited) != N:
            # print(a+1,b+1)
            ans += 1
    
        G[a].append(b)
        G[b].append(a)
    
    print(ans)





    


if __name__ == "__main__":
    main()

Measured memory_bytes: 73836
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(a*b)
    elif op=='/':
        print(a//b)
    else:
        break


Measured memory_bytes: 5592