akhauriyash/Code-Regression huggingface dataset:
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 8000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

string s;
int x, y;
vector<int> X, Y;
bitset<2 * N> dp, dp2, dp3;
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	s += "T";
	cin >> x >> y;
	int cnt = 0;
	int ted = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'T'){
			if (ted % 2 == 0) X.pb(cnt);
			else Y.pb(cnt);
			ted++;
			cnt = 0;
		}else{
			cnt ++;
		}
	}
	int c = 8010;
	dp[c] = 1;
	bool f = 0;
	for (auto u:X){
		//cout << u << ' ';
		if (!f) dp3 = (dp << u), f = 1;
		else dp3 = ((dp >> u) | (dp << u));
		dp = dp3;
	}
	//cout << '\n';
	dp3 = 0;
	dp2[c] = 1;
	for (auto u:Y){
		//cout << u << ' ';
		dp3 = ((dp2 >> u) | (dp2 << u));
		dp2 = dp3;
	}
	//cout << '\n';
	if (dp2[y + c] && dp[x + c]) return cout << "Yes", 0;
	cout << "No";








	return 0;
}


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

int main() {

	int N, L;
	cin >> N >> L;
	vector<int> scores(N);
	
	for (int i = 0; i < N; i++) {
		scores[i] = L + i;
	}

	int select_idx = 0;
	int select_abs = abs(scores[0]);
	for (int i = 0; i < N; i++) {
		if (select_abs > abs(scores[i])) {
			select_idx = i;
			select_abs = abs(scores[i]);
		}
	}

	int result = 0;
	for (int i = 0; i < N; i++) {
		if (i != select_idx) {
			result += scores[i];
		}
	}

	cout << result;
}

Measured memory_bytes: 256
N = int(input())
Ai = list(map(int,input().split()))

flag = True
for a in Ai:
  if a%2 == 0:
    if not (a%3 ==0 or a%5 == 0):
      flag = False
      break
    

if flag is True:
  print('APPROVED')
else:
  print("DENIED")

Measured memory_bytes: 2940
#!/usr/bin/env python3
import sys
import math

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, x = map(int, readline().split())


def solve():
    if 2 * x > a * a * b:
        return math.atan(2.0 * (b / a - x / (a * a * a)))
    else:
        return math.atan(0.5 * a * b * b / x)


if __name__ == "__main__":
    print(solve() / math.pi * 180.0)


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

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

		for(int i=0; i<5;i++)ans[i] = sc.nextInt();
			Arrays.sort(ans); 
			for(int j=4; j>=0; j--) {
				if(j !=0) { //jが0でないならば
					System.out.print(ans[j]+" "); 
				}else {
					System.out.println(ans[j]);
				}
			}
	}
}



Measured memory_bytes: 26196
#include<bits/stdc++.h>
using namespace std ;
int main()
{
  string s, t, u ;
  cin >> s >> t ;

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

  cin >> u ;

  if ( s == u ){
    a-- ;
  }else{
    b-- ;
  }

  cout << a << " " << b << endl ;
  return 0 ;
}


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

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> x(n + 1);

  for (int i = 1; i <= n; ++i)
    (s[i - 1] == 'A' && s[i] == 'C') ? x[i] = x[i - 1] + 1 : x[i] = x[i - 1];

  int l, r;
  for (int i = 0; i < q; ++i) {
    cin >> l >> r;
    l--, r--;
    cout << x[r] - x[l] << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
N, L = map(int, input().split())

summer = []
for i in range(L, L+N):
    summer.append(i)

absol = []
for i in range(len(summer)):
    absol.append(abs(sum(summer) - sum(summer[0:i]) - sum(summer[i+1:len(summer)])))

s = absol.index(min(absol))

print(sum(summer) - summer[s])

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt(), l = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        int best = Integer.MAX_VALUE;
        int ans = 0;
        for(int i=0;i<n;i++) {
            a[i] = l + i;
            sum += a[i];
        }

        //pw.println(Arrays.toString(a));

        for(int i=0;i<n;i++) {
            int b = Math.abs(sum - (sum - a[i]));
            //pw.println(b);
            if(b < best) {
                best = b;
                ans = sum - a[i];
            }
        }

        pw.println(ans);
        pw.close();
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#include<sys/mman.h>
#define read() Read<int>()
#define lowbit(i) i&(-i)
using namespace std;
typedef long long ll;
const int N=1e5+5;
char s[N];
int n,ans;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;++i)
		ans+=s[i]-'0';
	ans=max(ans,(s[1]-'0'-1)+9*(n-1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7  ))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
#define endl '\n'
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi;


int32_t main()
{
	IOS
	int n;cin>>n;cout<<n*n<<endl;

	
	
	
	
	
}



Measured memory_bytes: 256
import math

a, b, c = map(int, input().split())

S = a * b * math.sin(c/180*math.pi) / 2
L = a + b + math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(c/180*math.pi))
h = b * math.sin(c/180*math.pi)

print(S)
print(L)
print(h)


Measured memory_bytes: 5708
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
//#include <ext/numeric>
//using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>a>>b;
    cin>>n;

    for(int i=a; i<=b; i++) {

        if(i%n == 0)
            count++;
    }

    cout<<count<<endl;
      
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*(b/__gcd(a,b))
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define test ll t;cin>>t;while(t--)
#define check(a) cout<<#a<<" = "<<a<<endl;
#define rep(i,a,b) for(ll i=a; (a<=b)?i<=b:i>=b; (a<=b)?i++:i--)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fileio freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

const ll Mod = 1000000007LL;
const ll Inf = 2242545357980376863LL;
const int maxn = 1e5;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> omset;


//////////////////////// Template Ends ///////////////////////////////////


int main(){
	string s, t; cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans;
	return 0;
}





Measured memory_bytes: 3912
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[n];
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
		}
		int sum = 0;
		for(;;){
			int t = 0;
			for(int i=0;i<n;i++){
				if(x[i]%2==0){
					x[i]/=2;
					t++;
				}
			}
			if(t==n)
				sum++;
			else
				break;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 25172
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N,M; cin>>N>>M;
  vector<int>A(M);
  vector<char>B(M);
  vector<int>AC(N+1);
  vector<int>WA(N+1);
  rep(i,M){
    string C;
    cin>>A[i]>>C;
    B[i]=C.at(0);
    if(AC[A[i]]==1)continue;
    if(B[i]=='A'){
      AC[A[i]]++;
    }
    else{
      WA[A[i]]++;
    }
  }
  int ac=0;
  int wa=0;
  rep(i,N+1){
    ac+=AC[i];
    if(AC[i]==1)wa+=WA[i];
  }
  cout<<ac<<" "<<wa<<endl;
}

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

int main(){
    int S = 3;
    int a[S];
    for(int i = 0; i < S; i++){
        cin >> a[i];
    }
    
    sort(a, a+S);
    
    for(int i = 0; i < S; i++){
        cout << a[i];
        if(i < (S-1)){
            cout << " ";
        }else{
            cout << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int time(string s){
  return (s[0] - '0') * 36000 + (s[1] - '0') * 3600 + (s[3] - '0') * 600 + (s[4] - '0') * 60 + (s[6] - '0') * 10 + (s[7] - '0');
}
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<string> s(n), t(n);
    for (int i = 0; i < n; i++){
      cin >> s[i] >> t[i];
    }
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++){
      a[i] = time(s[i]);
      b[i] = time(t[i]);
    }
    vector<int> d(86400, 0);
    for (int i = 0; i < n; i++){
      d[a[i]]++;
      d[b[i]]--;
    }
    for (int i = 1; i < 86400; i++){
      d[i] += d[i - 1];
    }
    int ans = 0;
    for (int i = 0; i < 86400; i++){
      ans = max(ans, d[i]);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 4452
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;

int ch[27] = { 0 };
string s;

int main(){
	int p;
	while (cin >> s) {
		for (int i = 0; i < s.size(); i++) {
			p = tolower(s[i]) - 'a';
			if (p >= 0 && p < 26)
				ch[p]++;
		}
	}
	for (int i = 0; i < 26; i++) {
		cout << (char)('a' + i) << " : " << ch[i] << endl;
	}

	return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2==1){
    cout << "No";
    return 0;
  }
  for(int i=0; i<n/2; i++){
    if(s[i]!=s[i+n/2]){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))

const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);


int main(){
  int n,input;
  ll tot=0;
  cin>>n;
  vi a;
  REP(i,n){
    cin>>input;
    a.push_back(input-i-1);
  }
  sort(a.begin(),a.end());
  REP(i,n){
    tot+=a[i]-a[0];
  }
  int pt=0,tg=a[0];
  ll ret=tot;
  ll ret_tmp=tot;
  while(tg<=a[n-1]){
    tg+=1;
    while(pt<n&&tg>a[pt]) pt++;
    ret_tmp=ret_tmp+pt-(n-pt);
    ret=min(ret,ret_tmp);
  }
  cout<<ret<<"\n";
}


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

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

    if(S.at(5) == '1'){
        cout << "TBD" << endl;
    }

    else if(S.at(5) == '0'){
        if(S.at(6) == '1' || S.at(6) == '2' || S.at(6) == '3' || S.at(6) == '4'){
            cout << "Heisei" << endl;
        }
        else{
            cout << "TBD" << endl;
        }
    }

    
}

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

using ll = long long;

// その幼児の移動方向が決まれば，もともと並んでいた位置に関わらず，最適な移動後の位置が決定する
// 移動方向が右なら，最も列の先頭に近い位置だし，移動方向が左なら，最も列の末尾に近い位置になる

const ll INF = 1e18;
const int MX = 2005;
ll dp[MX][MX];
inline void chmax(ll &a, ll b)
{
    a = max(a, b);
}

// dp[i][l]: 大きい順に並べたときの上位i個を対象に，l個を左に詰めていき，i-l個を右に詰めていくときの嬉しさの最大値

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n + 1; i++)
        for (int j = 0; j < n + 1; j++)
            dp[i][j] = -INF;
    dp[0][0] = 0;

    vector<pair<int, int>> p;
    for (int i = 0; i < n; i++)
    {
        p.emplace_back(a[i], i);
    }

    sort(p.rbegin(), p.rend()); // 幼児を大きい順に並べる

    for (int i = 0; i < n; i++)
    {
        int pi = p[i].second; // i番目の幼児の元の位置
        for (int l = 0; l <= i; l++)
        {
            int r = i - l;
            chmax(dp[i + 1][l + 1], dp[i][l] + ll(pi - l) * a[pi]);       // 左に詰めた時
            chmax(dp[i + 1][l], dp[i][l] + ll((n - r - 1) - pi) * a[pi]); // 右に詰めた時
        }
    }

    ll ans = 0;
    for (int i = 0; i <= n; i++)
        chmax(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35016
N = int(input())
A = sorted(map(int, input().split(" ")), reverse=True)
result = A[0]
current_comfortest = A[1]
for i in range(2, N):
    if i == 2:
        result += current_comfortest
        continue
    else:
        result += A[i // 2]
        continue
print(result)

Measured memory_bytes: 93100
#include<bits/stdc++.h>
using namespace std;
int magic_min(int h,int n,vector<int >& health, vector<int >& magic,vector<int >& dp){
    //cout<<h<<'\n';
    if(h<=0)return 0;
    if(dp[h]!=-1)return dp[h];
    else{
        int min_magic = 1000000000;
        for(int i=0;i<n;i++){
           // cout<<i+1<<" \n";
            min_magic = min(min_magic,magic_min(h-health[i],n,health,magic,dp)+magic[i]);
        }
        dp[h]=min_magic;
        return dp[h];
    }
}
int main(){
    int h,n;cin>>h>>n;
    vector<int >health(n),magic(n),dp(h+1,-1);
    for(int i=0;i<n;i++){
        cin>>health[i]>>magic[i];
    }
    cout<<magic_min(h,n,health,magic,dp)<<'\n';
}

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

using namespace std;

#define U unsigned
#define L long
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define swap(a, b, tip) tip tempswap = a;a = b;b = tempswap;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);
	
int main(){
	int n;
	unsigned long long int sum = 0, rcount = 0, gcount = 0, bcount = 0;

	cin >> n;
	char c;

	char arr[n + 1];
	int count[n][3];

	for(int i = 0; i < n; i++){
		cin >> c;
		if(c == 'R'){
			rcount++;
		}
		else if(c == 'G'){
			gcount++;
		}
		else{
			bcount++;
		}
		arr[i] = c;
		count[i][0] = rcount;
		count[i][1] = gcount;
		count[i][2] = bcount;
	}

	for(int i = 0; i < n - 2; i++){
		for(int j = i + 1; j < n - 1; j++){
			if(arr[j] != arr[i]){
				if(arr[i] == 'R' && arr[j] == 'G'){
					sum += bcount - count[j][2];
					if(j + j - i < n && arr[j + j - i] == 'B'){
						sum--;
					}
				}
				else if(arr[i] == 'R' && arr[j] == 'B'){
					sum += gcount - count[j][1];
					if(j + j - i < n && arr[j + j - i] == 'G'){
						sum--;
					}
				}
				else if(arr[i] == 'G' && arr[j] == 'R'){
					sum += bcount - count[j][2];
					if(j + j - i < n && arr[j + j - i] == 'B'){
						sum--;
					}
				}
				else if(arr[i] == 'G' && arr[j] == 'B'){
					sum += rcount - count[j][0];
					if(j + j - i < n && arr[j + j - i] == 'R'){
						sum--;
					}
				}
				else if(arr[i] == 'B' && arr[j] == 'R'){
					sum += gcount - count[j][1];
					if(j + j - i < n && arr[j + j - i] == 'G'){
						sum--;
					}
				}
				else if(arr[i] == 'B' && arr[j] == 'G'){
					sum += rcount - count[j][0];
					if(j + j - i < n && arr[j + j - i] == 'R'){
						sum--;
					}
				}
			}
		}
	}

	cout << sum;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int x[16][16],y[16][16];

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N){
		cin >> A[i];
		rep(j,A[i]){
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
			y[i][j];
		}
	}
	int ans = 0;
	rep(i,(1<<N)){
		//00101のとき0人めと2人目は正直 あとは不親切
		int cnt = 0;
		bool ok = 1;
		vector<bool> t(N);
		for(int j=0;j<N;j++){
			if((i>>j)&1){
				t[j] = 1;
				cnt++;
			}
		}
		for(int j=0;j<N;j++){
			if(t[j]){
				rep(a,A[j]){
					int now = x[j][a];
					int tf  = y[j][a];
					if(t[now]!= tf)ok = 0;
				}
			}
		}
		if(ok)ans = max(ans,cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#|
------------------------------------
|               Body               |
------------------------------------
|#


(defun solve (a)
  (if (some #'oddp a)
      0
      (1+ (solve (mapcar (lambda (x)
                           (floor x 2))
                         a)))))


(defun main ()
  (let ((n (read)))
    (let ((a (loop repeat n collect (read))))
      (format t "~a~&" (solve a)))))

#-swank (main)


Measured memory_bytes: 24488
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int ans =700;
	if (s[0]=='o') ans+=100;
	if (s[1]=='o') ans+=100;
	if (s[2]=='o') ans+=100;
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;

//Village
public class Main{

	class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
	
	double[] x, y;
	
	void run(){
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		double R = sc.nextDouble(), EPS = 1e-8;
		double cos1 = Math.cos(1*Math.PI/180), sin1 = Math.sin(1*Math.PI/180);
		x = new double[n]; y = new double[n];
		for(int i=0;i<n;i++){
			double X = sc.nextDouble(), Y = sc.nextDouble();
			x[i] = cos1*X-sin1*Y;
			y[i] = sin1*X+cos1*Y;
		}
		Integer[] V = new Integer[n];
		for(int i=0;i<n;i++)V[i]=i;
		Arrays.sort(V, new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				return (int)Math.signum(x[o1]-x[o2]);
			}
		});
		int[] v = new int[n];
		for(int i=0;i<n;i++)v[i]=V[i];
		int res = 0;
		boolean[] u = new boolean[n];
		for(int i=0;i<n;i++){
			int idx = v[i];
			if(u[idx])continue;
			u[idx] = true;
			res++;
			double lx = x[idx]-R-EPS, rx = x[idx]+R+EPS;
			int l = 0, r = n;
			while(r-l>1){
				int m = (l+r)/2;
				if(lx<=x[v[m]])r=m;
				else l=m;
			}
			int k1 = l;
			l = 0; r = n;
			while(r-l>1){
				int m = (l+r)/2;
				if(rx<x[v[m]])r=m;
				else l=m;
			}
			int k2 = r;
			if(k2==r)k2--;
			for(int j=k1;j<=k2;j++){
				int k = v[j];
				if(u[k])continue;
				if((x[idx]-x[k])*(x[idx]-x[k]) + (y[idx]-y[k])*(y[idx]-y[k]) < R*R + EPS){
					u[k] = true;
				}
			}
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
	int N,i,n,a[100001]={0},b[100001]={0},t;
    cin>>N;
    for(i=1;i<=N;i++){
        cin>>n;
        a[i]=n;
    }
    
    for(i=1;i<=N;i++){
        t=a[i];//t=2
        b[a[t]]=t;//b[a[2]]=2
       // cout<<a[i]<<endl;
    }
 
    for(i=1;i<=N;i++){
        cout<<b[i]<<" ";
    }
}


Measured memory_bytes: 4428
#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <string>
using namespace std;
typedef int64_t I;
typedef vector<I> vI;
typedef pair<I, I> II;
typedef vector<II> vII;
typedef vector<vII> vvII;
typedef set<I> sI;

template<typename T>
ostream& operator<<(ostream& os, vector<T> const& v) {
  os << "[";
  for (size_t i = 0; i < v.size(); i++) {
    os << (i == 0 ? "" : ",") << v[i];
  }
  return os << "]";
}

template<typename T>
ostream& operator<<(ostream& os, set<T> const& v) {
  os << "{";
  for (auto x : v) {
    os << x << ",";
  }
  return os << "}";
}

template<typename S, typename T>
ostream& operator<<(ostream& os, tuple<S, T> const& v) {
  return os << "<" << get<0>(v) << "," << get<1>(v) << ">";
}

template<typename S, typename T, typename U>
  ostream& operator<<(ostream& os, tuple<S, T, U> const& v) {
  return os << "<" << get<0>(v) << "," << get<1>(v) << "," << get<2>(v) << ">";
}


I solve(I n, string const& s) {
  vI rs, gs;
  sI bs;
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i] == 'R') rs.push_back(i);
    else if (s[i] == 'G') gs.push_back(i);
    else {
      bs.insert(i);
    }
  }
  I r = 0;
  for (size_t i = 0; i < rs.size(); i++) {
    for (size_t j = 0; j < gs.size(); j++) {
      r += bs.size();
      I min_rg = min(rs[i], gs[j]), max_rg = max(rs[i], gs[j]);
      if (bs.find(min_rg - (max_rg - min_rg)) != bs.end()) {
        r--;
      }
      if (bs.find(max_rg + (max_rg - min_rg)) != bs.end()) {
        r--;
      }
      I mid2 = max_rg + min_rg;
      if (mid2 % 2 == 0) {
        if (bs.find(mid2 / 2) != bs.end()) {
          r--;
        }
      }
    }
  }
  return r;
}

int main() {
  I n; cin >> n;
  string s; cin >> s;
  cout << solve(n, s) << endl;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, i, a = 0, w = 0, t = 0, r = 0;
	cin >> n;
	string s;
	rep(i, 0, n)
	{
		cin >> s;
		if(s == "AC")
			a++;
		else if(s == "WA")
			w++;
		else if(s == "TLE")
			t++;
		else
			r++;
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << w << endl;
	cout << "TLE x " << t << endl;
	cout << "RE x " << r << endl;
}

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

#define COUT(x) cout << #x << " = " << (x) << ", "
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
typedef long long ll;
const int MOD = 1000000007;

int main(){
  ll X, A, B;
  cin >> X >> A >> B;
  if(A >= B){
    cout << "delicious" << endl;
  }else if(B - A <= X){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
vector<vector<ll>> DP;

int main(void) {
  ios::sync_with_stdio(false);
  int X, Y;
  cin >> X >> Y;
  ll Ans = 0;
  if (X == 3)
    Ans += 100000;
  else if (X == 2)
    Ans += 200000;
  else if (X == 1)
    Ans += 300000;
  if (Y == 3)
    Ans += 100000;
  else if (Y == 2)
    Ans += 200000;
  else if (Y == 1)
    Ans += 300000;

  if (X == 1 && Y == 1) Ans += 400000;

  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {

        Scanner scan=new Scanner(System.in);

        int w=scan.nextInt();
        int h=scan.nextInt();
        int n=scan.nextInt();
        boolean [][]color=new boolean[w][h];
        int x,y,a;
        for(int i=0;i<n;i++){
            x=scan.nextInt();
            y=scan.nextInt();
            a=scan.nextInt();
            if(a==1){
                for(int j=x-1;j>=0;j--){
                    for(int k=0;k<h;k++)
                    color[j][k]=true;
                }
            }
            if(a==2){
                for(int j=x;j<w;j++){
                    for(int k=0;k<h;k++)
                        color[j][k]=true;
                }
            }
            if(a==3){
                for(int j=y-1;j>=0;j--){
                    for(int k=0;k<w;k++)
                        color[k][j]=true;
                }
            }
            if(a==4){
                for(int j=y;j<h;j++){
                    for(int k=0;k<w;k++)
                        color[k][j]=true;
                }
            }
        }
        int ans=0;
        for(int i=0;i<w;i++){
            for(int j=0;j<h;j++){
                if(!color[i][j])
                    ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	bool ans=false;
	cin >> n;
	for (int i = 1; i <= 9;i++){
		if(n%i==0){
			if(n/i <=9){
				ans = true;
			}
		}
	}
	cout<<solve(ans)<<endl;
}

Measured memory_bytes: 3616
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

const int V = 111;
int cost[V][V];

void main(){
	int n, r, t, s, d, v, p, ans;
	string[] str;
	readf("%d\n", &n);
	for (int i = 0; i < V; i++) {
		cost[i][] = 999999999;
		cost[i][i] = 0;
	}
	for (int i = 0; i < n; i++) {
		str = split(readln());
		r = to!int(str[0]);
		for (int j = 2; j < str.length; j++) {
			t = to!int(str[j]);
			cost[r][t] = 1;
		}
	}

	warshall_floyd();

	readf("%d\n", &p);
	for (int i = 0; i < p; i++) {
		readf("%d %d %d\n", &s, &d, &v);
		ans = cost[s][d] + 1;
		if (ans > v) writeln("NA");
		else writeln(ans);
	}
}

void warshall_floyd(){
	for (int k = 0; k < V; k++)
		for (int i = 0; i < V; i++)
			for (int j = 0; j < V; j++)
				cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
}

Measured memory_bytes: 1080
n = int(input())
if n == 10**5:
    print(9+900+90000)
elif 10**4<=n<10**5:
    print(909+(n-9999))
elif 10**3<=n<10**4:
    print(909)
elif 10**2<=n<10**3:
    print(9+(n-99))
elif 10<=n<10**2:
    print(9)
else:
    print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SIZE 200005
#define INF 1000000000
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
typedef pair <P,int> PP;

vector <P> vec[4];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char str[5];

int ctoi(char c)
{
	if(c=='R') return 0;
	if(c=='U') return 1;
	if(c=='L') return 2;
	return 3;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d %d %s",&x,&y,&str);
		vec[ctoi(str[0])].push_back(P(x,y));
	}
	int ret=INF;
	for(int i=0;i<4;i++)
	{
		for(int j=i+1;j<4;j++)
		{
			int vx=dx[i]-dx[j],vy=dy[i]-dy[j];
			vector <PP> all;
			for(int k=0;k<vec[i].size();k++)
			{
				P p=vec[i][k];
				all.push_back(PP(P(-vy*p.first+vx*p.second,vx*p.first+vy*p.second),0));
			}
			for(int k=0;k<vec[j].size();k++)
			{
				P p=vec[j][k];
				all.push_back(PP(P(-vy*p.first+vx*p.second,vx*p.first+vy*p.second),1));
			}
			sort(all.begin(),all.end());
			for(int k=0;k<all.size();)
			{
				int f=k;
				for(;k<all.size()&&all[k].first.first==all[f].first.first;k++);
				int l0=INF;
				for(int t=f;t<k;t++)
				{
					if(all[t].second==0)
					{
						l0=all[t].first.second;
					}
					else if(l0!=INF)
					{
						ret=min(ret,(all[t].first.second-l0)*10/(vx*vx+vy*vy));
					}
				}
			}
		}
	}
	if(ret==INF) puts("SAFE");
	else printf("%d\n",ret);
}

Measured memory_bytes: 10084
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer([]byte{}, 1000000000)
	sc.Scan()
	line := sc.Text()
	sped := strings.Split(line, " ")
	a := mustAtoi(sped[0])
	b := mustAtoi(sped[1])

	faca := factorize(math.Sqrt(float64(a)), a, 2)
	facb := factorize(math.Sqrt(float64(b)), b, 2)
	res := []int{}
	for i := range faca {
		_, ok := facb[i]
		if ok {
			res = append(res, i)
		}
	}
	fmt.Printf("%v", len(res))
}

func factorize(maxDivide float64, num int, divide int) map[int]struct{} {
	var nums = map[int]struct{}{1: struct{}{}}
	for float64(divide) < maxDivide {
		mod := num % divide
		if mod == 0 {
			nums[divide] = struct{}{}
			num = num / divide
			continue
		}
		divide++
	}
	if num > 1 {
		nums[num] = struct{}{}
	}
	return nums
}

func mustAtoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}


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

int main() {
    int n;
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    int b[n];
    for (int i = 0; i < n; i++) scanf("%d", &b[i]);
    bool x[30] = {0};
    for (int i = 29; i >= 0; i--) {
        if (n % 2) {
            for (int j = 0; j < n; j++) {
                x[i] ^= (a[j] >> i) % 2;
                x[i] ^= (b[j] >> i) % 2;
            }
        }
        for (int j = 0; j < n; j++) {
            a[j] %= 1 << i;
            b[j] %= 1 << i;
        }
        sort(b, b + n);
        for (int j = 0; j < n; j++) {
            x[i] ^= (b + n - lower_bound(b, b + n, (1 << i) - a[j])) % 2;
        }
    }
    int res = 0;
    for (int i = 0; i < 30; i++) {
        res += x[i] << i;
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  int h,w;
  cin >> h >> w;
  char c[h][w];
  REP(i,h) {
    REP(j,w) {
      cin >> c[i][j];
    }
  }
  REP(i,h) {
    REP(j,w) {
      cout << c[i][j];
    }
    cout << endl;
    REP(j,w) {
      cout << c[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3584
n = int(input())

cnt = 0
for i in range(n):
    d_1, d_2 = list(map(int, input().split()))
    if d_1 == d_2:
        cnt += 1
    else:
        cnt = 0

    if cnt == 3:
        print('Yes')
        exit()

print('No')


Measured memory_bytes: 9168
#include <stdio.h>

int main(){
  int arr[100],n,i,j,k,key;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
    if(i>0) printf(" ");
    printf("%-d",arr[i]);
  }
  printf("\n");

  for(i=1;i<n;i++){
    
    key = arr[i];
    j = i-1;

    
    for(k=0;k<n;k++){
     
      while(j >= 0 && arr[j] > key){
	arr[j+1] = arr[j];
	j--;
      }
      arr[j+1] = key;
      
      if(k>0) printf(" ");
      
      printf("%-d",arr[k]);

    }
    
    printf("\n"); 
  }

  
  return 0;
}



Measured memory_bytes: 2128
import math
n, l = map(int, input().split())
a_l = [l + i for i in range(n)]
 
min1 = 100
min2 = 10000
 
for j in a_l:
    if j ** 2 <= min2:
        min2 = j **2
        min1 = j
print(sum(a_l) - min1)

Measured memory_bytes: 9156
N,M=map(int,input().split())
 
if N==1:
  if M==1:
    print(1)
  else:
    print(M-2)
elif N==2:
  print(0)
else:
  if M==1:
    print(N-2)
  elif M==2:
    print(0)
  else:
    print((N-2)*(M-2))

Measured memory_bytes: 9184
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            mod = i * j % 2019
            ans = min(ans, mod)
    print(ans)


Measured memory_bytes: 9116
def selection_sort(a, n):
    switch = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j

        if i != minj:
            temp = a[i]
            a[i] = a[minj]
            a[minj] = temp
            switch += 1
    print(' '.join(map(str, a)))
    print(switch)


def main():
    n = int(input())
    nums = input()
    nums = list(map(int, nums.split(' ')))
    selection_sort(nums, n)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    long long int h[n];
    for(int i = 0;i < n;i++)
    {
        cin >> h[i];
    }
    sort(h,h + n);
    long long int min = LLONG_MAX;
    for(int i = 0;i + k - 1 < n;i++)
    {
        if(h[i + k - 1] - h[i] < min)
        {
            min = h[i + k - 1] - h[i];
        }
    }
    cout << min;

    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            int d = int.Parse(str[3]);

            int taka = (c ) / b;
            int ao = (a ) / d;

            if (c % b != 0) taka++;
            if (a % d != 0) ao++;

            if (taka > ao) Console.WriteLine("No");
            else Console.WriteLine("Yes");

            //ここまで
        }



        static long Max(long a, long b)
        {
            if (a > b) return a;
            else return b;
        }
    }

}


Measured memory_bytes: 27468
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string s;
	cin>>s;
	set<char>st;
	r(i,s.size())st.insert(s[i]);
	if(st.size()==s.size())cout<<"yes"<<endl;
	else cout<<"no"<<endl;
}

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

int main(){
    string s;
    cin >> s;
    int n = 0;
    for(int i=0; i<s.size(); i++){
        n += (int)(s[i] - '0');
    }
    if((stoi(s))%n == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
from collections import defaultdict
D = defaultdict(int)
for i in range(N):
    a = int(input())
    A.append(a)
    D[a] += 1

ans = 0
for i in D:
    if D[i]%2==1:
        ans += 1
print(ans)
    

Measured memory_bytes: 61528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void eratosthenes(vector<bool> &u,int N){//０もとってある
    for(int i=2;i < N+1;i++){
        if(u.at(i)==true){
            for(int j=2*i;j < N+1;j += i){//Nを宣言してなかった、注意
                u.at(j) = false;
            }
        }
    }
}//エラトステネスの篩 添え字が素数ならtrue

int main(){
    int N,n;
    ll ans=1;
    cin >> N;//vectorの前に出してsize N+1で持っておく？
    vector<int> v(1001,1);//素因数iの数＋１
    vector<bool> u(1001,true);//素数かどうか
    eratosthenes(u,N);
    
    for(int j=2;j<=N;j++){
        if(u.at(j)==true){//素数なら素因数の数をカウントする
            int k=1;
            while(pow(j,k)<=N){
                v.at(j) += N/pow(j,k);//素因数の数を数える どうやるか
                k++;
            }
        }
    }
    //N=1000,のときの素因数２の個数は 1000/2 + 1000+4 +...+1000/512

    for(int k=2;k <= N;k++){
        ans *= v.at(k);
        ans %= 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>

#define ll long long

using namespace std;

const int MINN = 2001;
const int maxn = (int) 2e7 + 100;
const int inf = 1e9 + 7;

vector < int > g[maxn], give, can;
vector < int > v;
pair < int, int > p[maxn];
ll a[7010];

int u[maxn], b[7010];

string s, t;

int z[maxn];

int main(){
    cin >> s >> t;
    string q = s;
    while(s.size() < (int)1e7){
        s += q;
    }
    string st = t + '#' + s;
    int n = (int)st.size();
    int l = 0, r = 0;
    for(int i = 1; i < n; i++){
        if(i <= r){
            z[i] = min(r - i + 1, z[i - l]);
        }
        while(i + z[i] < n && st[z[i]] == st[z[i] + i])
            z[i]++;
        if(i + z[i] - 1 > r){
            l = i, r = i + z[i] - 1;
        }
    }
    for(int i = t.size() + 1; i < t.size() + 1 + q.size(); i++){
        if(z[i] == t.size()){
            can.push_back(i - t.size() - 1);
            u[i - t.size() - 1] = 1;
            //cout << i - t.size() - 1 << " ";
        }
    }
    if(can.empty()){
    	cout << 0;
    	return 0;
    }
    int now = can[0];
    v.push_back(now);
    now += t.size();
    now %= q.size(); 
    bool qwe = 0;
    while(1){
        v.push_back(now);
        now += t.size();
        now %= q.size();
    	if(now == can[0]){
    		if(!qwe)
    			qwe = 1;
    		else
    			break;
    	}
    }
    int cnt = 0, res = 0;
    for(int i = 0; i < v.size(); i++){
        if(u[v[i]] == 1){
            cnt++;
            res = max(cnt, res);
        }
        else{
            cnt = 0;
        }
    }
    if(res == v.size()){
        cout << -1;
    }
    else{
        cout << res;
    }
    return 0;
}



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)

template<class S, class T> inline
ostream& operator<<(ostream&os, pair<S,T> p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template<class S, class T, class U> inline
ostream& operator<<(ostream&os, tuple<S,T,U> t) {
  return os << '('
    << get<0>(t) << ", "
    << get<1>(t) << ", "
    << get<2>(t) << ')';
}

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) { return os << "(empty)"; }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

template<class T> inline
istream& operator>>(istream&is, vector<T>&v) {
  rep (i, v.size()) is >> v[i];
  return is;
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;

int ok(vi& xs) {
  int n = xs.size();
  if (n % 3 > 0) return 0;
  vi s(9, 0);
  for (int x: xs) s[x-1]++;
  // trace(xs); trace(s);
  for (int i = 0; i < 9; ) {
    if (s[i] == 0) {
      ++i;
    }
    else if (s[i] >= 3) {
      s[i] -= 3;
    }
    else if (i+2 < 9 and (s[i] > 0 and s[i+1] > 0 and s[i+2] > 0)) {
      s[i]--; s[i+1]--; s[i+2]--;
    }
    else {
      return 0;
    }
  }
  return 1;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.setf(ios::fixed);
  cout.precision(10);
  random_device dev;
  mt19937 rand(dev());

  int n; cin >> n;
  rep (_, n) {
    vi xs(9);
    vector<char> ys(9);
    cin >> xs;
    cin >> ys;
    vi as, bs, cs;
    rep (i, 9) {
      if (ys[i] == 'R') as.push_back(xs[i]);
      else if (ys[i] == 'G') bs.push_back(xs[i]);
      else cs.push_back(xs[i]);
    }
    cout << (ok(as) * ok(bs) * ok(cs)) << endl;
  }

  return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
	

fast;

ll n;
cin>>n;

ll a[n];
for(ll i=0;i<n;i++)cin>>a[i];

ll ans=1000;

ll stocks=ans/a[0],cost=a[0];

for(ll i=1;i<n;i++)
{
	if(a[i]>cost)
	{
		ans=ans+(stocks)*(a[i]-cost);
		stocks=ans/a[i];
		cost=a[i];
	}
	else 
	{
		stocks=ans/a[i];
		cost=a[i];
	}
}
cout<<ans;

}


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

int main() {
    int N, M, ans = 0;
    cin >> N >> M;
    vector<pair<int, int>> p(M);
    for(int i = 0; i < M; ++i)
        cin >> p[i].second >> p[i].first;
    sort(p.begin(), p.end());
    set<int> st;
    for(int i = 0; i < M; ++i) {
        auto itr = lower_bound(st.begin(), st.end(), p[i].second);
        if(itr == st.end()) {
            st.insert(p[i].first - 1);
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024