akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main(){
	fast;
	ll n,k,dis=0;
	cin>>n>>k;
	ll arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	for(int i=0;i<n;i++){
		dis+=2*min( arr[i],abs(k-arr[i]) );
	}
	cout<<dis;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
		using namespace std;
		typedef long long ll;
		#define PI 3.14159265358979
		#define EPS 1e-8
		#define mod 
		#define fi first
		#define se second
		#define mp make_pair
		#define pb push_back
		#define endl "\n"
			 
		const ll INF=1e15;	
		const int N=2e5+50;
		 

		 
		long long binpow(long long a, long long b, long long m) {
			a %= m;
			long long res = 1;
			while (b > 0) {
				if (b & 1)
					res = res * a % m;
				a = a * a % m;
				b >>= 1;
			}
			return res;
		}
		
		
		int main()
		{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);cout.tie(0);
			
			ll n;
			cin>>n;
			
			vector<ll> a(n+1),b(n+1);
			vector<ll> v1,v2;
			for(ll i=1;i<=n;i++)
			{
				cin>>a[i]>>b[i];
				v1.pb(a[i]);
				v2.pb(b[i]);
			}
			
			sort(v1.begin(),v1.end());
			
			sort(v2.begin(),v2.end());
			
			if(n%2==1)
			{
				ll lo=v1[n/2];
				ll hi=v2[n/2];
				
				cout<<(hi-lo+1);
			}
			else
			{
				long double lo=v1[n/2-1];
				long double hi=v1[n/2];
				
				long double l1=lo+(hi-lo)/2;
				
				lo=v2[n/2];
				hi = v2[n/2-1];
				
				long double l2=hi+(lo-hi)/2;
				
		
				cout<<(ll)(((abs(l2-l1))/0.5)+1);
				
			}
			
			
			
		}
			
			
		


Measured memory_bytes: 9800
N = int(input())
numbers = [int(input()) for i in range(N)]

# 最大値を取得
max_num = max(numbers)

# 最大値を同じ値がいくつ在るかを確認
max_nums = numbers.count(max_num)

if max_nums >= 2:
    for i in range(len(numbers)):
        print(max_num)
else :
    max_index = numbers.index(max(numbers))
    for i in range(len(numbers)):
        if i == max_index:
            second_max = sorted(numbers)[-2]
            print(second_max)
        else :
            print(max_num)

Measured memory_bytes: 14224
package main

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

func main() {
        sc := bufio.NewScanner(os.Stdin)
        sc.Scan()

        var linkedList = make([]string, 1000000)
        var length int

        for sc.Scan() {
                // fmt.Println(linkedList[:length])
                inputs := strings.Split(sc.Text(), " ")

                switch inputs[0] {
                case "insert":
                        linkedList[length] = inputs[1]
                        length++
                case "delete":
                        for i := length - 1; i >= 0; i-- {
                         if linkedList[i] == inputs[1] {
                                linkedList = append(linkedList[:i], linkedList[i+1:]...)
                                length--
                                break
                         }
                        }
                case "deleteFirst":
                        linkedList[length-1] = ""
                        length--
                case "deleteLast":
                        linkedList = linkedList[1:]
                        length--
                }
        }

        fmt.Printf("%s", linkedList[length-1])
        for i := length - 2; i >= 0; i-- {
                fmt.Printf(" %s", linkedList[i])
        }
        fmt.Println("")
}



Measured memory_bytes: 66136
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k - 1] -= 'A' - 'a';
  cout << s << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n,Y; cin >> n >> Y;
  ll sum;
  REP(i,n+1){
    REP(j,n-i+1){
      int k = n - i - j;
      sum = 10000 * i + 5000 * j + 1000 * k;
      if(sum == Y){
        printf("%d %d %d",i,j,k);
        return 0;
      }
    }
  }
  printf("-1 -1 -1");
}

Measured memory_bytes: 3740
#0174
while True:
    A = 0
    B = 0
    r = input()
    if r == '0':
        break
    for i in range(1,len(r)):
        if r[i] == 'A':
            A += 1
        else:
            B += 1
    if A > B:
        A += 1
    elif B > A:
        B += 1

    print(A,B)


Measured memory_bytes: 5556
# -*- coding: utf-8 -*-
from math import sqrt
n = int(input())

selected = set()
res = 0
for w in range(1,int(sqrt(n))+10):
    if n%w==0:
        m = (n-w)//w
        if m>0 and m not in selected and n//m == n%m:
            res += m
            selected.add(m)

        w2 = n//w
        m2 = (n-w2)//w2
        if m2>0 and m2 not in selected and n//m2 == n%m2:
            res += m2
            selected.add(m2)
print(res)


Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double a,b,sum=0,av,count=0,tmp=0;
		while(sc.hasNext()){
			String str[]=sc.next().split(",");
			count++;
			a=Integer.parseInt(str[0]);
			b=Integer.parseInt(str[1]);
			sum+=(a*b);
			tmp+=b;
		}
		av=tmp/count;
		long ans1=(long)Math.round(av);
		System.out.println((int)sum);
		System.out.println(ans1);
	}
}

Measured memory_bytes: 12000
N,M,L = list(map(int, input().split()))

A=[[0 for i in range(M)] for j in range(N)];
B=[[0 for i in range(L)] for j in range(M)];
C=[[0 for i in range(L)] for j in range(N)];

for i in range(N):
	A[i]=list(map(int, input().split()));

for i in range(M):
	B[i]=list(map(int, input().split()));

for i in range(N):
	for j in range(L):
		for k in range(M):
			C[i][j]+=(A[i][k]*B[k][j]);


for i in C:
	for j in range(L):
		print(i[j],end="");
		if(j!=L-1):
			print(" ",end="")
	print();



Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
 
int collatz(int x) {
  if (x%2==0) {
    return x/2;
  }
  else {
    return 3*x+1;
  }
}

int main() {
  int s;
  cin >> s;
  vector<int> a(1000000);
  a.at(0)=s;
  
  bool finished = false;
  long m;
  
  for (long i=1;i<=1000000;i++) {
    a.at(i)=collatz(a.at(i-1));
    for (long j=0;j<i;j++) {
      if (a.at(j) == a.at(i)) {
        m = i;
        finished = true;
        break;
      }
    }
    if (finished) {
      break;
    }
  }
  
  cout << m+1 << endl;
}

Measured memory_bytes: 4096
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200010


int main() {
	char a[N];
	char b[N];
	f(i, N) {
		a[i] = 0;
		b[i] = 0;
	}
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &n, &k);
	scanf("%s", a);
	f(i, n) {
		a[(2 * n - i - 1)] = a[i];
		b[i] = a[i];
	}
	for (int i = 1; i <= n; i++) {
		f(j, n) {
			if (a[i + j] < b[j]) {
				f(ii, n)b[ii] = a[i + ii];
				break;
			}
			else if (a[i + j] > b[j])break;
		}
	}
	k = min(k - 1, 20);
	f(kk, k) {
		x = 0;
		f(i, n) {
			if (b[i] == b[0])x++;
			else break;
		}
		for (int i = n - 1; i >= x; i--) {
			b[i] = b[i - x];
		}
		f(i, x)b[i] = b[0];

	}
	printf("%s\n", b);


	return 0;
}

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

using namespace std;

int main(){


	int n,a,b;
	string s;
	cin>>n>>a>>b;
	cin>>s;
	
	int pass=0;
	int os=0;

	for(int i=0;i<n;i++){
	
		if(s[i]=='a'){
		
			if(pass<a+b){
			
				cout<<"Yes"<<"\n";
				pass++;
			}
			else{
			
				cout<<"No"<<"\n";
			}
		}
	     else	if(s[i]=='b'){
		
			os++;
			
			if(pass<a+b&&os<=b){

				cout<<"Yes"<<"\n";
				pass++;

			}
			else{
			
				cout<<"No"<<"\n";
			}
		}
		else{
		
			cout<<"No"<<"\n";
		}
	}
	return 0;
}


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

class Vec2
{
public:
	double x, y;
	Vec2(double x = 0, double y = 0) : x(x), y(y){}
	Vec2(const Vec2& v) : x(v.x), y(v.y){}
	Vec2 operator+(const Vec2& other) const
	{
		return Vec2(x + other.x, y + other.y);
	}
	Vec2 operator-(const Vec2& other) const
	{
		return Vec2(x - other.x, y - other.y);
	}
	double dot(const Vec2& other) const
	{
		return x * other.x + y * other.y;
	}
	double cross(const Vec2& other) const
	{
		return x * other.y - y * other.x;
	}
};

istream& operator>>(istream& stream, Vec2& v)
{
	stream >> v.x >> v.y;
	return stream;
}

class Triangle
{
public:
	Vec2 p1, p2, p3;
	Triangle(Vec2 p1, Vec2 p2, Vec2 p3) : p1(p1), p2(p2), p3(p3){}
	Triangle() : p1(0, 0), p2(0, 0), p3(0, 0){}
	Triangle(const Triangle&  other) : p1(other.p1), p2(other.p2), p3(other.p3){}
	bool isHit(const Vec2& pos) const
	{
		Vec2 a = p2 - p1;
		Vec2 b = p3 - p2;
		Vec2 c = p1 - p3;
		Vec2 A = pos - p1;
		Vec2 B = pos - p2;
		Vec2 C = pos - p3;
		double x = a.cross(A);
		double y = b.cross(B);
		double z = c.cross(C);

		if (x >= 0 && y >= 0 && z >= 0) return true;
		if (x <= 0 && y <= 0 && z <= 0) return true;
		return false;
	}
};

int main()
{
	Triangle t;
	Vec2 p;
	while (cin >> t.p1 >> t.p2 >> t.p3 >> p)
	{
		if (t.isHit(p)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

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

using namespace std;

int main(void)
{
    int N;

    cin >> N;

    vector<int> a(N);

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

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int Alice = 0;
    int Bob = 0;

    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            Alice += a[i];
        }
        else {
            Bob += a[i];
        }
    }

    cout << Alice - Bob << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    int ans = 0;
    if(s == "RRR") ans = 3;
    else if(s == "RRS" || s == "SRR") ans = 2;
    else if(s == "SSS") ans = 0;
    else ans = 1;
    cout << ans <<endl;

    
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
typedef long long ll;

int main(void)
{
    ll h, w, ans=1;
    cin >> h >> w;

    if (h != 1 && w != 1)
    {
        ans = h * w / 2+(h % 2 == 1 && w % 2 == 1);
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(){
    string s;
    int count = 0;
    cin >> s;
    if (s[0] == '2') ++count;
    if (s[1] == '2') ++count;
    if (s[2] == '2') ++count;
    if (s[3] == '2') ++count;
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#define INF 100000000

using namespace std;

int main(void) {
	int N,M;
	while (cin >> N >> M, N) {
		vector<int> C(M);
		for (int i = 0; i < M; ++i) {
			cin >> C[i];
		}
		vector<int> x(N);
		for (int i = 0; i < N; ++i) {
			cin >> x[i];
		}

		vector< vector<int> > dp(256,vector<int>(N+1));
		for (int i = 0; i < 256; ++i) {
			for (int j = 0; j < N+1; ++j) {
				dp[i][j] = INF;
			}
		}
		dp[128][0] = 0;

		for (int j = 0; j < N; ++j) {
			for (int i = 0; i < 256; ++i) {
				if (dp[i][j] != INF) {
					for (int k = 0; k < M; ++k) {
						if (C[k]+i > 255) {
							dp[255][j+1] = min(dp[255][j+1],dp[i][j]+(int)pow(x[j]-255,2));
						}
						else if (C[k]+i < 0) {
							dp[0][j+1] = min(dp[0][j+1],dp[i][j]+(int)pow(x[j]-0,2));
						}
						else {
							dp[C[k]+i][j+1] = min(dp[C[k]+i][j+1],dp[i][j]+(int)pow(x[j]-C[k]-i,2));
						}
					}
				}
			}
		}

		int res = INF;
		for (int i = 0; i < 256; ++i) {
			if (dp[i][N] < res) {
				res = dp[i][N];
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 22828
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
V<string> dp(10005,"");
int main(){
 V<int> match={0,2,5,5,4,5,6,3,7,6};
 int n,m;
 cin>>n>>m;
 V<int> a(m);
 for(int i=0;i<m;i++)cin>>a[i];
 sort(all(a),greater<int>());
 for(int i=0;i<m;i++){
      for(int j=n;j>=0;j--){
          if(j-match[a[i]]>=0){
              if(j!=n&&dp[j].size()==0)continue;
              string tmp=dp[j];
              tmp+=(char)a[i]+'0';
              if(tmp.size()>dp[j-match[a[i]]].size())dp[j-match[a[i]]]=tmp;
              else if(tmp.size()==dp[j-match[a[i]]].size()){
                  int k=tmp.size();
                  while(--k>=0){
                      if(tmp[k]>dp[j-match[a[i]]][k]){
                          dp[j-match[a[i]]]=tmp;
                          break;
                      }
                  }
              }
          }
      }
 }
 cout<<dp[0]<<endl;
}

Measured memory_bytes: 43520
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cassert>

using namespace std;


int main()
{
	string a, b;
	
	cin >> a >> b;
	int as = a.length();
	int bs = b.length();
	vector <vector<pair<int,pair<int,int>>>> dp(as + 1, vector<pair<int, pair<int, int>>>(bs + 1));
	for (int i = 0; i < as; i++) {
		for (int j = 0; j < bs; j++) {
			if (a[i] == b[j]) {
				if (dp[i + 1][j + 1].first < dp[i][j].first + 1) {
					dp[i + 1][j + 1].first = dp[i][j].first + 1;
					dp[i + 1][j + 1].second = { i,j };
				}

			}
			
			if (dp[i + 1][j].first < dp[i][j].first) {
				dp[i + 1][j].first = dp[i][j].first;
				dp[i + 1][j].second = { i,j };
			}
			if (dp[i][j + 1].first < dp[i][j].first) {
				dp[i][j + 1].first = dp[i][j].first;
				dp[i][j + 1].second = { i,j };
			}
		}
		
	}
	int ans = 0;
	pair<int, int> cell = { 0,0 };
	for (int i = 0; i <= as; i++) {
		for (int j = 0; j <= bs; j++) {
			if (ans < dp[i][j].first) {
				ans = dp[i][j].first;
				cell = {i,j};
			}
		}
	}
	string str = "";
	pair<int, int> prev = {0,0};
	for (int i = 0; i < ans; ) {
		prev = cell;
		cell = dp[cell.first][cell.second].second;
		if (prev.first == cell.first+1 && prev.second == cell.second +1 ) {
			str += a[cell.first]; i++;
		}
		
	
	}
	reverse(str.begin(), str.end());
	cout << str;

}




Measured memory_bytes: 108860
#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(){
    string s; cin >> s;
    for(int i=0; i<s.size(); i++){
        if(i == 4) cout << " ";
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_8-B
 
Character - Sum of Numbers
Time Limit : 1 sec, Memory Limit : 65536 KB
??°?????????

?????????????????°???????????????????¨??????????????????°?????????????????????????????????
Input

?????°??????????????????????????\?????¨??????????????????????????????????????????????????????????????´??° x ?????????????????§?????????????????????

x ??? 1000 ?????\????????´??°??§??????

x ??? 0 ?????¨?????\?????????????????¨??????????????????????????????????????????????????????????????£????????????????????????
Output

????????????????????????????????????x ???????????????????????????????????????????????????
Sample Input

123
55
1000
0

Sample Output

6
10
1

=end
fh=STDIN
#fh=open("IPT1_8_A.txt")
while s = fh.gets
  break if s =~ /^0$/
  puts s.split(//).map{|x| x.to_i}.inject(0) {|acc,item| acc + item}
end

Measured memory_bytes: 8776
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long t = 1L;
        for (int i = 1; i <= n; i++) {
            t *= i;
            t %= (Math.pow(10, 9) + 7);
        }
        System.out.println((int)(t % (Math.pow(10, 9) + 7)));
    }
}


Measured memory_bytes: 23636
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <limits>
#include <numeric>
#include <iterator>

using namespace std;



int main(){
  ios::sync_with_stdio(false);
  const int ub_a = 10000;
  int n;
  vector<int> a; // 1 .. 10000
  cin >> n;
  for(int i = 0; i<n; ++i){int a_i; cin >> a_i; a.push_back(a_i);}


  //compute
  vector<int> c(ub_a+1, 0);
  vector<int> b(n);

  for(int a_i : a){
    c[a_i] += 1;
  }
  for(auto itr = c.begin()+1; itr!=c.end(); ++itr){
    *itr += *(itr-1);
  }

  for(auto a_i : a){
    b[--(c[a_i])] = a_i;
  }

  //output
  for(int i=0; i<n; ++i){
    cout << (i==0?"":" ") << b[i];
  }
  cout << endl;
  return 0;
}

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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,g;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i==0){
            g=a[0];
        }
        if(i>0){
            g=__gcd(g,a[i]);
        }
        if(a[i]==k){
            cout <<"POSSIBLE"<<endl;
            return 0;
        }
    }
    sort(a,a+n);
    if(a[n-1]<k){
        cout <<"IMPOSSIBLE"<<endl;
        return 0;
    }
    if(k%g==0){
        cout <<"POSSIBLE"<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
// #include<unordered_map>
using namespace std;
int bin[40],lg[1<<21];
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	#define vc vector
	inline void chmax(int &x,const int y) {x=x>y?x:y;}
	inline void chmin(int &x,const int y) {x=x<y?x:y;}
	const int MAX_N=2e5+10;
	const int MOD=1e9+7;
	void add(int &x,int y) {x+=y;if(x>=MOD) x-=MOD;if(x<0) x+=MOD;}

	int a[MAX_N];
	void main()
	{
		int n=qread();
		for(int i=1;i<=2*n;i++) a[i]=qread();
		sort(a+1,a+2*n+1);
		int ans=0;for(int i=1;i<=2*n;i+=2) ans+=a[i];
		write(ans);
	}
};
int main()
{
	srand(time(0));
	bin[0]=1;for(int i=1;i<=30;i++) bin[i]=bin[i-1]<<1;
	lg[1]=0;for(int i=2;i<(1<<21);i++) lg[i]=lg[i>>1]+1;
	mine::main();
}


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

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    int matrix1[n][m] = {};
    int matrix2[m][p] = {};
    double matrix3[n][p] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> matrix1[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < p; j++) {
            cin >> matrix2[i][j];
        }
    }
    int sum = 0;

    for (int i = 0; i < n; i++) {
        for (int k = 0; k < m; k++) {
            for (int j = 0; j < p; j++) {
                matrix3[i][j] += matrix1[i][k] * matrix2[k][j];
            }
        }
    }
    cout << fixed << setprecision(0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < p; j++) {
            if (j == p - 1) {
                cout << matrix3[i][j] << endl;
            } else {
                cout << matrix3[i][j] << " ";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <map>
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef pair<int, int> pp;
const int maxn = 200100;
int s[maxn];
int n;
map<int, int> v;
bool can(int x)
{
	v.clear();
	for(int i = 2; i <= n; i ++)
		if(s[i] <= s[i - 1])
		{
			v[s[i]] ++;
			int now = s[i];
			while(v[now] == x)
			{
				v.erase(now);
				now --;
				if(now < 1)
					return 0;
				v[now] ++;
			}
			map<int, int>::iterator nxt, it;
			for(it = v.lower_bound(now + 1); it != v.end(); nxt = it, it ++, v.erase(nxt));
		}
	return 1;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	bool asd = 0;
	s[0] = 0;
	for(int i = 1; i <= n; i ++)
	{
		cin >> s[i];
		if(s[i] <= s[i - 1])
			asd = 1;
	}
	if(!asd)
	{
		cout << 1 << endl;
		return 0;
	}
	//cout << can(3) << endl;
	int l = 2, r = n;
	while(l < r)
	{
		int mid = (l + r) >> 1;
		if(can(mid))
			r = mid;
		else
			l = mid + 1;
	}
	cout << l << endl;
	return 0;
}
/*
10
1 7 4 1 10 8 1 1 3 3 
*/

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

const int S = 4;
int operation_table[10][10];

int check_digit(const char* s) {
  int r = 0;
  for (int i = 0; i < S; i++) {
    r = operation_table[r][s[i] - '0'];
  }
  return r;
}

bool correct(const char* s) {
  int e = check_digit(s);
  return operation_table[e][s[S] - '0'] == 0;
}

int main() {
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", operation_table[i] + j);
    }
  }
  int cnt = 0;
  for (int n = 0; n < 10000; n++) {
    char s[5];
    sprintf(s, "%04d", n);
    s[S] = check_digit(s) + '0';
    bool ng = [&]() {
      for (int i = 0; i < S; i++) {
        if (s[i] == s[i + 1]) continue;
        swap(s[i], s[i + 1]);
        if (correct(s)) return true;
        swap(s[i], s[i + 1]);
      }
      for (int i = 0; i < S + 1; i++) {
        for (char j = '0'; j <= '9'; j++) {
          if (s[i] == j) continue;
          swap(s[i], j);
          if (correct(s)) return true;
          swap(s[i], j);
        }
      }
      return false;
    }();
    if (ng) cnt++;
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll N = 1e5 + 10, inf = 1e18 + 10, mod = 1e9 + 7;
ll d[110][N], dp[N], a[110];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    ll n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)cin >> a[i];
    for(int i = 1; i <= k + 1; i++)
    {
        if(i <= a[1] + 1)d[1][i] = 1;
        dp[i] = dp[i - 1] + d[1][i];
    }
    for(int i = 2; i <= n; i++)
    {
        for(int j = 1; j <= k + 1; j++)
        {
            d[i][j] = (dp[j] - dp[max(0ll, j - a[i] - 1)] + mod) % mod;
        }
        dp[1] = 1;
        for(int j = 2; j <= k + 1; j++)
        {
            dp[j] = (dp[j - 1] + d[i][j]) % mod;
        }

    }
    cout << d[n][k + 1];
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int a,b,c,d;

int main()
{
	cin>>a>>b>>c>>d;
	while(true)
	{
		c-=b;
		if(c<=0)
		{
			puts("Yes");
			return 0;
		}
		a-=d;
		if(a<=0)
		{
			puts("No");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){

  int n,i,max,min;

  scanf("%d",&n);

  int R[n];

  for(i = 0; i<n ; i++){
    scanf("%d",&R[i]);
  }
  
  min = R[0];
  max = R[1] - R[0];
  
  for(i=1 ; i<n; i++){
    if(max > R[i] - min) max = max;
    else if(max < R[i] - min) max = R[i]-min;

    if(min < R[i]) min = min;
    else if(min > R[i]) min = R[i];
  }

  printf("%d\n",max);

  return 0;

}

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

using namespace std;

int main(){
    int n;
    string color;
    cin>>n;

    for(int i=0; i<n; i++){
        cin>>color;

        if(color == "Y") {
            cout << "Four" << endl;
            return 0;
        }
    };
    cout<<"Three"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin >> n;
    int a[n];
    int b = 0;
    int c = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            b += a[i];
        }else {
            c += a[i];
        }
    }
    cout << abs(b -c) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
  long long int n,k;
  scanf("%lld %lld",&n,&k);
  long long int max = n%k; 
  long long int ans = max>=(k-max)?(k-max):max;
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
numSwap = 0

for i in range(n):
    for j in range(n-1, i, -1):
        if a[j-1] > a[j]:
            a[j-1], a[j] = a[j], a[j-1]
            numSwap += 1
        # print('i = '+str(i)+': '+':::j = '+str(j)+': '+ str(a))
a = [str(s) for s in a]
print(' '.join(a))
print(numSwap)


Measured memory_bytes: 5604
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

using namespace std;

void solveC()
{
  string s;
  cin >> s;

  char ch = s[0];
  int num = 0;
  for(int i = 1; i < s.length(); i++) {
    if(ch != s[i]) {
      num++;
      ch = s[i];
    }
  }
  cout << num << endl;
}
void solveD()
{

}

void solveE()
{

}
void solveF()
{

}

int main()
{
  solveC();
  //solveD();
  //solbeE();
  //solveF();
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    string s; cin >> s;
    ll r[n+1],w[n+1];
    r[0] = 0, w[0] = 0;
    if(s.at(0)=='R') r[0]++; else w[0]++;
    for(int i=1;i<n;i++){
        if(s.at(i)=='R'){
            r[i] = r[i-1] + 1;
          	w[i] = w[i-1];
        }else{
          	r[i] = r[i-1];
            w[i] = w[i-1] + 1;
        }
    }
  	r[n] = r[n-1], w[n] = w[n-1];
    ll ans = INF;
    rep(i,n+1){//i番目の左側に仕切りがある
        //仕切りより左側にあるwの数と仕切りより右側にあるrの数
        if(i==0){
          ans = min(ans,r[n-1]);
          //cout << ans << endl;
          continue;
        }
      	ans = min(ans,max(w[i-1],r[n-1]-r[i-1]));
      	//cout << i << " " << ans << endl;
      	//cout << w[i-1] << r[n-1] << r[i-1] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6856
s = list(input())
t = list(input())
count = 0
ans = 0
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j] == t[j]:
      count += 1
  if count >= ans:
    ans = count
  count=0
print(len(t)-ans)
    
    

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

ans = [0 for _ in range(n+1)]
m = int(n**0.5) + 1
for x in range(1, m):
    for y in range(1, m):
        for z in range(1, m):
            t = x*x + y*y + z*z + x*y + y*z + z*x
            if t < n + 1:
                ans[t] += 1

for i in range(1, n+1):
    print(ans[i])


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	int ans;
	if(a <= b && b <= a+w)
		ans = 0;
	else if(a <= b+w && b+w <= a+w)
		ans = 0;
	else if(a+w < b)
		ans = b-a-w;
	else
		ans = a-b-w;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}


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

string s = "#abcdefghijklmnopqrstuvwxyz";
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    long long n;
    cin >> n;
    string ans;
    while (n > 0) {
        if (n % 26 != 0) ans += s[n % 26];
        else {
            ans += 'z'; n--;
        }
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
bool comp(string s1,string s2){
    return s1.length()<s2.length();
}
int main(){
	FIO;
	int n;cin>>n;
	vl vec(64);
	rep(i,0,n){
		ll x;cin>>x;
		for(int bit=0;bit<=63;bit++){
			if(x&(1ll<<bit)) vec[bit]++;
		}
	}
	ll ans=0;
	for(int bit=0;bit<=63;bit++){
		ans=ans+((vec[bit]*(n-vec[bit])%mod)*((1ll<<bit)%mod))%mod;
		ans%=mod;
	}
	cout<<ans;
} 
 

Measured memory_bytes: 256
import itertools


def get_sieve_of_eratosthenes(n):
    prime = [2]
    limit = int(n ** 0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


def main():
    Q = int(input())
    LR = [list(map(int, input().split())) for _ in range(Q)]
    N = 10 ** 5

    primes = set(get_sieve_of_eratosthenes(N))

    t = [0 for _ in range(N + 1)]
    for p in primes:
        a, b = divmod(p + 1, 2)
        if b == 0 and a in primes:
            t[p] += 1

    t = list(itertools.accumulate(t))

    for l, r in LR:
        print(t[r + 1] - t[l - 1])


main()



Measured memory_bytes: 32612
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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


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

  cout << c << " " << a << " " << b;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
char s[200000];
int ans[4][200000];
signed main(){
  int n;
  cin >> n;
  REP(i,n) cin >> s[i];
  ans[0][0] = 1;
  ans[0][1] = 1;
  ans[1][0] = 1;
  ans[1][1] = -1;
  ans[2][0] = -1;
  ans[2][1] = 1;
  ans[3][0] = -1;
  ans[3][1] = -1;
  REP(i,4){
    REP(j,n-2){
      if(s[j+1]=='o'){
        ans[i][j+2] = ans[i][j] * ans[i][j+1];
      }
      else ans[i][j+2] = ans[i][j] * ans[i][j+1] * -1;
    }
    int f = 0;
    if(s[n-1]=='o'){
      if(ans[i][n-1] !=  ans[i][n-2]*ans[i][0]) f = 1;
    }
    else{
      if(ans[i][n-1] ==  ans[i][n-2]*ans[i][0]) f = 1;
    }
    if(s[0]=='o'){
      if(ans[i][0] !=  ans[i][n-1]*ans[i][1]) f = 1;
    }
    else{
      if(ans[i][0] ==  ans[i][n-1]*ans[i][1]) f = 1;

    }
    if(f==0){
      REP(j,n){
        if(ans[i][j]==1) cout << 'S';
        else cout << 'W';
      }
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 5760
import itertools

while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    y = [0] * n
    for i in range(n):
        y[i] = i + 1
    kumiawase = list(itertools.combinations(y,3))
    count = 0
    for i in kumiawase:
        if i[0] + i[1] + i[2] == x:
            count += 1
    print(count)


Measured memory_bytes: 31420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

const int mod = 1e9 + 7;

ll powmod(ll x, ll y) {
    ll ans = 1;
    rep(i, y){
        ans = (ans * x) % mod;
    }
    ans %= mod;
    return ans;
}

int main() {
    int n;
    cin >> n;
    ll ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    /*if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    if(n == 2){
        cout << 2 << endl;
        return 0;
    }
    ll ans = 0;
    int now_n = n - 2;
    ans = now_n * 9;
    ans *= fact(n);
    cout << ans << endl;*/
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;
int main(){
    int a,b;
    string op;
    while(cin >> a >> op >> b && op!="?"){
        if (op=="+"){
            cout << a+b << endl;
        } else if (op=="-"){
            cout << a-b << endl;
        } else if (op=="*"){
            cout << a*b << endl;
        } else {
            cout << a/b << endl;
        }
    }
    return 0;
    
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> p(n+1);
    rep(i, n) cin >> p[i+1];

    vector<int> ans;

    for(int i = 1; i<=n; ++i) {
        if(i == p[i]){
            ans.push_back(i);
        }
    }
    ll rep = ans.size();
    int cnt = 0;
    rep(i, ans.size()) {
        if(ans[i]+1==ans[i+1]) {
            cnt++;
        }else {
            rep -= (cnt + 1)/2;
            cnt = 0;
        }
    }
    cout << rep << endl;
    return 0;
}


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

int main(void){
    int a[2];
    cin >> a[0] >> a[1];
    sort(a,a+2,greater<int>());
    int ans = a[0];
    if((a[0]-1) > a[1])ans += a[0]-1;
    else ans += a[1];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int cou[26] = {0};
        for (int j = 0; j < 10000; j++){
    string s;
    getline(cin, s);
    if (s.size() == 0)
        break;
    int i;
    int n = s.size();
    int N;
        for (i = 0; i < n; i++){
        if (s[i] >= 65 && s[i] <= 90)
            s[i] +=32;
        if (s[i] >= 97 && s[i] <= 122){
            N = s[i] - 97;
            cou[N]++;
        }
    }
    }
    for (int i = 0; i < 26; i++){
        char a = 'a' + i;
        cout << a << " : " << cou[i] << endl;
    }
}



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

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned uint;

int N, M;

int func(vector<int> A, vector<int> B) {
	int ans = 0;
	
	vector<int> cntA(2, 0), cntB(2, 0);

	for (int i = 0; i < A.size(); i++) {
		cntA[A[i]] += 1;
	}
	for (int i = 0; i < B.size(); i++) {
		cntB[B[i]] += 1;
	}

	if (cntA[0] != cntB[0] || cntA[1] != cntB[1]) {
		return 100101010;
	}

	for (int i = 0; i < B.size(); i++) {
		if (A[i] != B[i]) {
			for (int j = i + 1; j < B.size(); j++) {
				if (A[i] == B[j]) {
					while (j != i) {
						swap(B[j], B[j - 1]);
						j -= 1;
						ans += 1;
					}
					break;
				}
			}
		}
	}

	return ans;
}

int main(void) {
	cin >> N >> M;

	vector<int> P(N), A, B;

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

		for (int j = 0; j < c; j++) {
			A.push_back(i % 2);
		}
	}
	for (int i = 0; i < A.size(); i++) {
		B.push_back(A[i] ^ 1);
	}

	int ans = min(func(P, A), func(P, B));

	cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1224
//ALDS1_4_B Search - Binary Search
#include <iostream>
#include <vector>
using namespace std;

int binaryceach(vector<int>& V, int key)
{
    int left = 0;
    int right = V.size();
    while (left < right)
    {
        int mid = (left + right) / 2;
        if (V[mid] == key)
            return 1;
        else if (key < V[mid])
            right = mid;
        else
            left = mid+1;
    }
    return 0;
}

int main()
{
    vector<int> S, T;
    int n, q, t;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        S.push_back(t);
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> t;
        T.push_back(t);
    }
    
    int sum = 0;
    for (auto a : T)
    {
        sum += binaryceach(S, a);
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3540
#include <stdio.h>
 
int main(){
    int n;
    scanf("%d", &n);

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

    for (int i=n-1; i>0; i--) {
        printf("%d ", a[i]);
    }
    printf("%d\n", a[0]);
}


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

int main() {
	const int MOD = 1000000007;
	int n, m;
	cin >> n >> m;
	vector<int> a(m), dp(n);
	for(int i = 0; i < m; i++){
		int in;
		cin >> in;
		a[i] = in - 1;
	}
	dp[0] = 1;
	dp[1] = 2;
	if(find(a.begin(), a.end(), 0) != a.end()){
		dp[0] = 0;
		dp[1] = 1;
	}
	if(find(a.begin(), a.end(), 1) != a.end()) dp[1] = 0;
	for(int i = 2; i < n; i++){
		dp[i] = dp[i - 1] + dp[i - 2];
		if(find(a.begin(), a.end(), i) != a.end()) dp[i] = 0;
		if(dp[i] > MOD) dp[i] %= MOD;
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}

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

using ll = long long;

const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];

void solve() {
    ll n, k;
    cin >> n >> k;
    std::map<ll, set<ll>> mp;
    for (int i = 1; i <= k; ++i) {
        ll xx;
        cin >> xx;
        for (int j = 1; j <= xx; ++j) {
            cin >> res, mp[res].insert(i);
        }
    }
    res = 0;
    for (int i = 1; i <= n ; ++i) {
        if (!mp.count(i)) res++;
    }
    cout << res;
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}// smf

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

const int MAX_PRIME = 32 * 1e6;
int divisors[MAX_PRIME] = { 0 }, primes[MAX_PRIME] = { 0 }, nPrimes = 0;
void generatePrimes() {
	for (int i = 2; i < MAX_PRIME; i++) {
		if (divisors[i] == 0) divisors[i] = primes[nPrimes++] = i;
		for (int j = 0; j < nPrimes && i * primes[j] < MAX_PRIME; j++)
			divisors[i * primes[j]] = min(divisors[i], primes[j]);
	}
}

long long gcdex(long long a, long long b, long long &x, long long &y) {
	if (!b) return x = 1, y = 0, a;
	long long px, py, res = gcdex(b, a % b, px, py);
	return x = py, y = px - a / b * py, res;
}

map<long long, int> factorize(long long x) { 
    // max prime should be greater than or equal to the square root of x
	map<long long, int> res;
	for (int i = 0; 1ll * primes[i] * primes[i] <= x; i++) {
		if (x % primes[i] == 0) {
			int c = 0;
			while (x % primes[i] == 0) c++, x /= primes[i];
			res[primes[i]] = c;
		}
	}
	if (x != 1) res[x] = 1;
	return res;
}

int main () {
    generatePrimes();
    long long n;
    while (scanf("%lld", &n) == 1) {
        auto f = factorize(2 * n);
        vector<long long> p;
        for (auto [div, c] : f) {
            long long x = 1;
            while (c--) x *= div;
            p.push_back(x);
        }
        
        long long res = n == 1 ? 1 : n & 1 ? n - 1 : 2 * n;
        int psz = p.size();
        for (int m = 0; m < (1 << psz); m++) {
            long long a, b, x = 1, y = 1;
            for (int b = 0; b < psz; b++)
                if (m >> b & 1) x *= p[b];
                else y *= p[b];
            if (x == 1) continue;
            if (y == 1) a = 1, b = x - 1;
            else gcdex(x, y, a, b);
            res = min(res, min(x * abs(a), y * abs(b)));
        }
        printf("%lld\n", res);
    }
}




Measured memory_bytes: 136504
import sys
N = int(input().strip())

n_list = [[] for i in range(N)]
d = [0] * N

for i in range(N-1):
    a, b = map(int, input().strip().split())
    a -= 1
    b -= 1
    n_list[a].append([b,i])
    n_list[b].append([a,i])
    d[a] += 1
    d[b] += 1


#print(n_list)
#print(d)

d_dict = {}
for i in range(N):
    d_dict[i] = d[i]
tmp = sorted(d_dict.items(), key = lambda x:x[1], reverse = True)

colors = [0] * (N)

root = tmp[0][0]

def paint(node, parent_edge_id):
    #print(node, parent_edge_id)
    tmp_color = 1
    for edge in n_list[node]:
        #print("ege:", edge)
        if edge[1] != parent_edge_id:
            if parent_edge_id != -1 and tmp_color == colors[parent_edge_id]:
                tmp_color += 1
            colors[edge[1]] = tmp_color
            paint(edge[0], edge[1])
            tmp_color += 1

    
sys.setrecursionlimit(10**7)
paint(tmp[0][0], -1)
print(tmp[0][1]) # color num 
for i in range(N-1):
    print(colors[i])

Measured memory_bytes: 87840
Signal.trap(:INT){
  exit(0)
}

def small(x,y,area)
	if(y >= 1)
		area[x][y-1] += 1
	end
	if(x >= 1)	
		area[x-1][y] += 1
	end

	area[x][y] += 1
	
	if(x <= 8)
		area[x+1][y] += 1
	end
	if(y <= 8)
		area[x][y+1] += 1
 	end
	return area
end

def middle(x,y,area)
	if(y >= 1)
		if(x >= 1)
		area[x-1][y-1] += 1
		end

		area[x][y-1] += 1

		if(x <= 8)
		area[x+1][y-1] += 1
		end
	end

	if(x >= 1)
		area[x-1][y] += 1
	end
	area[x][y] += 1
	if(x <= 8)
	area[x+1][y] += 1
	end

	if(y <= 8)
		if(x >= 1)
		area[x-1][y+1] += 1
		end

		area[x][y+1] += 1

		if(x <= 8)
		area[x+1][y+1] += 1
		end
	end
	return area
end

def large(x,y,area)
	if (y >= 2)
		area[x][y-2] += 1
	end
	if (y <= 7)
		area[x][y+2] += 1
	end
	if (x >= 2)
		area[x-2][y] += 1
	end
	if (x <= 7)
		area[x+2][y] += 1
	end

	middle(x,y,area)

	return area
end

area = Array.new(10).map{Array.new(10,0)}
	
while where = gets

	spl = where.split(",")
	x = spl[0].to_i
	y = spl[1].to_i
	size = spl[2].to_i
	if (size == 1)
		area = small(x,y,area)
	elsif (size == 2)
		area = middle(x,y,area)
	elsif (size == 3)
		area = large(x,y,area)
	end

end

# search
max = 0
spaces = 0

10.times do |i|
	10.times do |j|
		if max < area[i][j] 
			max = area [i][j]
		end
		if area[i][j] == 0
			spaces += 1
		end
		#print area[i][j]
	end
	#print "\n"
end 

puts spaces
puts max

Measured memory_bytes: 6088
eval"N,*A="+`dd`.split*?,
c,d=[0,N].map{|i|y=A[i+N-1];A[i,N].map{|i|y^y=i}}
m=[k=-1]
f=->t{k=m[k]until k<0||d[k]==t;k+=1}
d.map{|x|m<<f[x]}
k=0
(2*N-1).times{|i|p i+=1-N,A[N]^A[i]if f[c[i%N]]==N}

Measured memory_bytes: 95416