akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner


object Main {

  def isYYMM(a: Int, b: Int) = (0 <= a && a <= 99) && (1 <= b && b <= 12)

  def isMMYY(a: Int, b: Int) = isYYMM(b, a)

  def charToInt(c: Char) = c - '0'

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val s = sc.next()
    val a = charToInt(s(0)) * 10 + charToInt(s(1))
    val b = charToInt(s(2)) * 10 + charToInt(s(3))
    val result = (isYYMM(a, b), isMMYY(a, b)) match {
      case (true, true) => "AMBIGUOUS"
      case (true, false) => "YYMM"
      case (false, true) => "MMYY"
      case (false, false) => "NA"
    }
    println(result)
  }
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >>c>>d;
  if (a+b<c+d){
    cout << "Right"<<endl;
  }
  else if(a+b>c+d)
    cout <<"Left"<<endl;
  else
    cout << "Balanced"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

int main() {
	string S; cin >> S;
	int N = S.size();

	ll ans = 0;
	rep(i, N/2) {
		if (S[i] != S[N-1-i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
 
public class Main {
     
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         
         
        int sum = 0;
        for(int i = 0; i < 5; i++){
            sum += Math.max(40, sc.nextInt());
        }
         
        System.out.println(sum / 5);
         
    }
 
}


Measured memory_bytes: 26204
N,K=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(N-1)]
graph=[[] for _ in [0]*N]
[graph[a-1].append(b-1) for a,b in ab]
[graph[b-1].append(a-1) for a,b in ab]
q=[[-1,0]]
cnt=0
ans=K
mod=10**9+7
while(q):
    q1=[]
    if cnt<2:
        cnt+=1
    for i,j in q:
        g=graph[j]
        if i!=-1:
            g.remove(i)
        for cnt2,k in enumerate(g):
            q1.append([j,k])
            ans=(ans*(K-cnt-cnt2))%mod
    q=q1
print(ans)

Measured memory_bytes: 52076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    ll ret = 0;
    REP(i, w-1) {
        // 列i,i+1に着目
        // cnt[i][j] = (左がi段，右がj段残っていて左右で同じ色になってる個数)
        vector<vector<int>> cnt(h+1, vector<int>(h+1));
        REP(j, h) REP(k, h) {
            if(s[j][i] != s[k][i+1]) continue;
            cnt[j+1][k+1]++;
        }
        FOR(sx, 1, h+1) {
            ll x = sx+1, y = 2;
            while(x<=h && y<=h) {
                cnt[y][x] += cnt[y-1][x-1];
                x++, y++;
            }
        }
        FOR(sy, 2, h+1) {
            ll x = 2, y = sy+1;
            while(x<=h && y<=h) {
                cnt[y][x] += cnt[y-1][x-1];
                x++, y++;
            }
        }

        // dp[i][j] = (i段,j段残っている状態から全部消すコスト)
        vector<vector<int>> dp(h+1, vector<int>(h+1));
        FOR(j, 1, h+1) FOR(k, 1, h+1) dp[j][k] = min(dp[j-1][k], dp[j][k-1]) + cnt[j][k];
        ret += dp[h][h];
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int t;
long long a,b,c,d,gg,tmp,x;
void solve(){
	cin>>a>>b>>c>>d;
	if(b>a){
		cout<<"No"<<endl;
		return;
	}
	if(b>d){
		cout<<"No"<<endl;
		return;
	}
	gg=__gcd(b,d);
	tmp=(c-b+1)/gg;
	if((c-b+1)<0)
		tmp--;
	x=tmp*gg+a%gg;
	if(x<(c-b+1))
		x+=gg;
	if(x>=0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 256
# 折れ線グラフで考えると
# ( : +1
# ) : -1
# 0で終わる
# 0未満にならない → 各文字列で最下点と和を利用
# 和がマイナスの部分と分けて、マイナス部分は反転して考える

n = int(input())
s = [input() for _ in range(n)]
plus = []
minus = []
for i in s:
    min_v = 0
    sum_v = 0
    for j in i:
        sum_v += 1 if j == '(' else -1
        min_v = min(min_v, sum_v)
    if sum_v > 0:
        plus.append((min_v, sum_v))
    else:
        minus.append((min_v-sum_v, -sum_v))

plus.sort(key=lambda x:x[0], reverse=True)
minus.sort(key=lambda x:x[0], reverse=True)

sum_plus = 0
for min_v, sum_v in plus:
    if sum_plus + min_v < 0:
        print("No")
        exit()
    sum_plus += sum_v

sum_minus = 0
for min_v, sum_v in minus:
    if sum_minus + min_v < 0:
        print("No")
        exit()
    sum_minus += sum_v

if sum_plus == sum_minus:
    print("Yes")
else:
    print("No")





Measured memory_bytes: 91980
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2333&lang=jp
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60
#define MAXW 10050
int dp[MAXW];
const ll mod = 1000000007;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int> w(N + 1);
	for (int i = 0; i < N;i++) cin >> w[i];
	w[N] = INF;
	int ans = 0;
	sort(w.begin(), w.end());
	for (int i = 0;i <= N;i++) {
		int sum = 0;
		for (int j = 0; j < i;j++) {
			sum += w[j];
		}
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		for (int j = i+1; j < N;j++) {
			for (int k = MAXW-1; k >= 0;k--) {
				if (dp[k] == 0)continue;
				if (W - sum < w[j] + k)continue;
				(dp[k + w[j]] += dp[k])%=mod;
				
			}
		}

		for (int j = max(0,W-sum-w[i]+1); j <= W - sum;j++) {
			if (dp[j] == 0)continue;
			(ans += dp[j]) %= mod;
		}
	}
	cout << ans << endl;

	return 0;
}

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

lft = 0
rgt = 1
ret = [(0, 0, 0), (0, 1, 0)]
for i in range(1, 32):
    if i % 2 != 0:
        lft -= 2**i
        ret.append((lft, rgt, i))
    else:
        rgt += 2**i
        ret.append((lft, rgt, i))

ret.reverse()
s = [0 for i in range(32)]
for i in range(len(ret) - 1):
    if ret[i][0] <= n <= ret[i][1] and not(ret[i+1][0] <= n <= ret[i+1][1]):
        n -= (-2) ** ret[i][2]
        s[i] = 1

for i in range(len(s)):
    if s[i] == 1:
        break

for j in range(i, len(s)):
    print(s[j], end='')
print()

Measured memory_bytes: 3064
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion

char con(char c, int n)
{
	c = c + n;

	if ('Z' < c)
	{
		c = c - 26;
	}
	return c;
}

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

	int N;
	string S;
	cin >> N >> S;
	rep(i, sz(S))
	{
		S[i] = con(S[i], N);
	}
	cout << S << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

int cnt[256];
string s;

int main(){
  cin >> s;

  YYS( w , s ){
    cnt[w]++;
  }

  REP( i , 256 ){
    if( cnt[i] % 2 == 1 ){
      puts( "No" );
      return 0;
    }
  }

  puts( "Yes" );
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int flag,j,k,count,swap,N;
  int A[100];

  count=0;

  scanf("%d",&N);
  for(j=0;j<N;j++){
    scanf("%d",&A[j]);
  }
  
  flag=1;
  while(flag==1){
    flag=0;  
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	  swap=A[j];
	  A[j]=A[j-1];
	  A[j-1]=swap;
	  flag=1;
	  count++;
      }
    }
  }
  printf("%d",A[0]);
  for(j=1;j<N;j++){
    printf("% d",A[j]);
  }
  printf("\n%d\n",count);

  return 0;
}



Measured memory_bytes: 2128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
vector<int> a;
int b[100000];
int c;
int k;
long long s;
int p, q;
int n, m;
int x, y, z;
c = 0;
	s = 0;
	q = 0;
	z = 0;

	for (int i = 0; i < 100000; i++){
		b[i] = 0;
	}

	scanf("%d %d %d", &n,&x,&y);
	for (int i = 0; i < n; i++){
		scanf("%d", &k);
		a.push_back(k);
	}
	sort(a.begin(), a.end());
	c = 1;
	p = 1;
	s = a[0] + y;
	for (int i = 1; i < n; i++){
		if (p == x){
			s = a[i] + y;
			p = 1;
			c++;
		}
		else if (s < a[i]){
			s = a[i] + y;
			p = 1;
			c++;
		}
		else {
			p++;
		}
	}


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

	return 0;
}


Measured memory_bytes: 892
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>

using namespace std;

int main(void) {

	int x, a, b;

	cin >> x >> a >> b;

	if (abs(a - x) < abs(b - x))cout << "A\n";
	else cout << "B\n";
	
	return 0;
}

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

def is_prime(n):
  if n == 2 or n == 3: return True
  if n < 2 or n%2 == 0: return False
  if n < 9: return True
  if n%3 == 0: return False
  r = int(n**0.5)
  f = 5
  while f <= r:
    if n%f == 0: return False
    if n%(f+2) == 0: return False
    f +=6
  return True  

def solve(N: int):

    cnt = 0
    for i in range(1,55556):
        if is_prime(i) and i % 5 == 1:
            print(i)
            cnt += 1
            if cnt == N:
                return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

int main(){
    int N,M;
    while(cin >> N >> M && N){
        vector<int> A(N+1,(int)1e9),B(N+1,(int)1e9);
        for(int i=1;i<=N;i++){
            cin >> A[i];
        }
        for(int i=1;i<=N;i++){
            cin >> B[i];
        }
        vector<vector<int>> dp(N+1,vector<int>(1010,(int) 1e9));
        vector<vector<int>> mi(N+1,vector<int>(1010,(int) 1e9));
        dp[0][0] = 0;
        for(int i=1;i<=N;i++){
            for(int j=0;j<=N;j++){
                int now = B[i]-A[i]+j*M;
                if(now<0) continue;
                int pre = B[i-1]-A[i-1]+j*M;
                if(pre>=0) dp[i][j] = min(dp[i][j],dp[i-1][j]+max(now-pre,0));
                if(j>=1){
                    for(int k=1;k<=2;k++){
                        pre = B[i-1]-A[i-1]+(j-k)*M;
                        if(pre>=0) dp[i][j] = min(dp[i][j],dp[i-1][j-k]+max(now-pre,0));
                    }
                }
                dp[i][j] = min(dp[i][j],mi[i-1][j+2]);
                pre = B[i-1]-A[i-1]+(j+1)*M;
                if(pre>=0) dp[i][j] = min(dp[i][j],dp[i-1][j+1]+max(now-pre,0));
            }
            for(int j=1000;j>=0;j--) mi[i][j] = min(mi[i][j+1],dp[i][j]);
        }
        cout << mi[N][0] << endl;
    }
}


Measured memory_bytes: 10792
X, Y, Z, K = map(int, input().split())
A = [int(aaa) for aaa in input().split()]
B = [int(bbb) for bbb in input().split()]
C = [int(ccc) for ccc in input().split()]
kari = []
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
for i in range(X):
    for j in range(Y):
        kari.append(A[i] + B[j])
karisize = len(kari)
kari = sorted(kari, reverse=True)
kouho_list = [0] * Z
index_list = [0] * Z
for k in range(Z):
    kouho_list[k] = kari[0] + C[k]
print(kouho_list[0])
if karisize == 1:
    kouho_list[0] = -10**9
else:
    index_list[0] += 1
    kouho_list[0] = kari[1] + C[0]
for p in range(K - 1):
    ans = max(kouho_list)
    max_index = kouho_list.index(ans)
    print(ans)
    if index_list[max_index] == karisize - 1:
        kouho_list[max_index] = -10 ** 9
    else:
        index_list[max_index] += 1
        kouho_list[max_index] = C[max_index] + kari[index_list[max_index]]
    # print(kouho_list)
# print(kari)


Measured memory_bytes: 62640
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 3; i++) {
			sb.append(sc.next().substring(0, 1).toUpperCase());
		}

		System.out.println(sb.toString());
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b, int[] c) throws IOException {
			if (a.length != b.length || b.length != c.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
				c[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 23124
// Problem : C - Together
// Contest : AtCoder - AtCoder Beginner Contest 072
// URL : https://atcoder.jp/contests/abc072/tasks/arc082_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int ans=0;
int n;cin>>n;vi v(n);cin>>v;
map<int,int> mp;
for(int i:v)
mp[i-1]++,mp[i]++,mp[i+1]++;
int mx=0,no=-1;
for(pii p:mp)
{
	if(p.se>mx)
	mx=p.se;
}
cout<<mx;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

int main() {
    int N ,K ,d;
    cin >> N >> K;
    vector <int> S(N);
    for (int i=0; i<K; i++) {
        cin >> d;
        int tmp = 0;
        for (int i=0; i<d; i++) {
            cin >> tmp;
            S.at(tmp-1)=1;
        }
    }
    int ans=0;
    for (int i=0; i<N; i++) {
        if (S.at(i)!=1) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using  namespace std;

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

        int m = p[0]; 
        q[0] = p[0]; 
        for(int i = 1; i < n; i++) {
                q[i] = min(m, p[i]);
                m = q[i];
        }

        int ans = 0;
        for(int i = 0; i < n; i++) {
                if(p[i] <= q[i]) ans++;                
        }

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


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

int F(long long A, long long B){
int countA = 0;
int countB = 0;
while(A > 0){
A /=10;
countA++;}
while(B > 0){
B /=10;
countB++;}
if(countA >= countB){
return countA;}
else return countB;}

int main() {
double N;
cin >> N;
long long X;
X = N;
for(int i = sqrt(N);i > 0; i--){
if(floor(N/i) == N/i){
cout << F(i, X/i) << endl;
break;}}}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

vector<int>v[20];
int p[20];

int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		int a;scanf("%d",&a);
		rep(j,a){
			int b;scanf("%d",&b);b--;
			v[i].push_back(b);
		}
	}
	rep(i,m){
		scanf("%d",&p[i]);
	}
	int ans=0;
	rep(i,1<<n){
		bool ok=true;
		rep(j,m){
			int cnt=0;
			for(int k:v[j]){
				if(i>>k&1)cnt^=1;
			}
			if(cnt!=p[j])ok=false;
		}
		ans+=ok;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
Lists = [list(map(int, input().split())) for i in range(m)]
ans_list = [1] * n
for i in range(m):
    if h[Lists[i][0] - 1] > h[Lists[i][1] - 1]:
        ans_list[Lists[i][1] - 1] = 0
    elif h[Lists[i][0] - 1] < h[Lists[i][1] - 1]:
        ans_list[Lists[i][0] - 1] = 0
    else:
        ans_list[Lists[i][0] - 1] = 0
        ans_list[Lists[i][1] - 1] = 0
print(sum(ans_list))

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

int main()
{
  int n,k;
  cin >> n >> k;

  vector<int> a(n);
  for(int i=0; i<n; i++)a.push_back(0);

  for(int i=0; i<k; i++){
    int d;
    cin >> d;
    for(int j=0; j<d; j++){
      int s;
      cin >> s;
      a[s-1]++;
    }
  }

  int ans=0;
  for(int i=0; i<n; i++){
    if(a[i]==0)ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3604
INF = 1e12
n,m,p = map(int,input().split())

grafo = []

for x in range(m):
    a,b,c = map(int,input().split())
    grafo.append((a-1,b-1,c-p))

def bellman_ford(v):
    distancia = [float("inf")] * n
    distancia[v] = 0
    for i in range(2 * n):
        for a,b,c in grafo:
            if distancia[b] > distancia[a] - c:
                distancia[b] = distancia[a] - c
                if i == n - 1:
                    distancia[b] = -float("inf")
    return distancia

distancia = bellman_ford(0)

if distancia[-1] ==  -float("inf"):
    print(-1)
else:
    if distancia[-1] > 0:
        print(0)
    else:
        print(-1 * distancia[-1])


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

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

	string s; cin >> s;
	if (sz(s) < 26) {
		char c = 'a';
		while (find(all(s),c) != end(s)) c++;
		cout << s << c << endl;
	} else {
		string t = s;
		if (next_permutation(all(t))) {
			while (s < t.substr(0,sz(t)-1)) t.pop_back();
			cout << t << endl;
		} else {
			cout << -1 << endl;
		}
	}
}



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

namespace Algorithm
{
    class Program
    {
        const int Inf = int.MaxValue/2;
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int h = l[0], n = l[1];
            
            var dp = Enumerable.Repeat(Inf, h + 1).ToArray();
            
            dp[0] = 0;
            
            for (var i = 0; i < n; i++) {
                var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int dm = t[0], ct = t[1];
                for (var j = 0; j <= h; j++) {
                    if (dp[j] == Inf) continue;
                    var min = Math.Min(j+dm, h);
                    dp[min] = Math.Min(dp[min], dp[j] + ct);
                }
            }
            
            Console.WriteLine(dp[h]);
        }
    }
}


Measured memory_bytes: 13340
package main

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

func main() {
	A, B := ReadInt(), ReadString()
	b1, _ := strconv.Atoi(B[:len(B)-3])
	b2, _ := strconv.Atoi(B[len(B)-2:])
	fmt.Println(A*b1 + A*b2/100)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
from operator import itemgetter


def main():
    N, K = map(int, input().split())
    arr = [None] * N
    for i in range(N):
        a, b = map(int, input().split())
        arr[i] = (a, b)
    arr.sort(key=itemgetter(0))
    for i in range(N):
        a, b = arr[i]
        K -= b
        if K <= 0:
            print(a)
            break


if __name__ == "__main__":
    main()


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

using namespace std;

struct Sushi
{
    int64_t x, v;
};

int main()
{
    int N;
    int64_t C;
    cin >> N >> C;

    vector<Sushi> s(N);

    for (int i = 0; i < N; ++i) {
        cin >> s[i].x >> s[i].v;
    }

    // Reflect `s` straight the circle's circumference.
    // Note that `s` must be sorted in increasing order.
    auto reflect = [C] (vector<Sushi> vs)
    {
        for (Sushi & s : vs) {
            s.x = C - s.x;
        }
        reverse(vs.begin(), vs.end());
        return vs;
    };

    // sbest[i] = if we are free to take any prefix of length i from s, what is the most we can gain?
    auto make_best = [N] (const vector<Sushi>& s)
    {
        assert (static_cast<int>(s.size()) == N);

        int64_t sum = 0;
        vector<int64_t> sbest(N);
        for (int i = 0; i < N; ++i) {
            sum += s[i].v;
            const int64_t now = sum - s[i].x;

            if (i > 0) {
                sbest[i] = max(now, sbest[i - 1]);
            } else {
                sbest[i] = now;
            }
        }
        return sbest;
    };

    // Case 1, he chooses a clockwise prefix and then walks out.
    auto straight = [&make_best] (const vector<Sushi>& s)
    {
        return make_best(s).back();
    };

    // Case 2, when he takes a prefix, walks back and then takes a suffix.
    auto around = [N, &make_best] (const vector<Sushi>& s, const vector<Sushi>& sref)
    {
        auto srefbest = make_best(sref);

        assert (static_cast<int>(s.size()) == N);
        assert (static_cast<int>(sref.size()) == N);
        assert (static_cast<int>(srefbest.size()) == N);

        int64_t best = 0;
        int64_t sum = 0;
        for (int i = 0; i + 1 < N; ++i) {
            sum += s[i].v;

            // Since the sref is ordered backward. we can take a prefix of `sref`
            // with a length at most N - i - 1.
            // That way, we avoid taking a sushi piece twice.
            const int64_t now = sum - 2 * s[i].x + srefbest[N - i - 2];
            if (now > best) {
                best = now;
            }
        }
        return best;
    };

    vector<Sushi> sref = reflect(s);

    int64_t best_case1 = max(
            straight(s), straight(sref));

    int64_t best_case2 = max(
            around(s, sref), around(sref, s));

    int64_t best = max(best_case1, best_case2);

    assert (best >= 0);
    cout << best << "\n";
    return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct LazySegmentTree {
private:
    int n;
    vector<T> node, lazy;
    vector<bool> updated;
    T def;
    function<T(T,T)> cmp;
    
    void init(const vector<T> &v, T _def, function<T(T,T)> _cmp) {
        def = _def; cmp = _cmp;
        int vl = (int)v.size();
        n = 1; while(n < vl) n *= 2;
        node.resize(2 * n - 1);
        lazy.resize(2 * n - 1, _def);
        updated.resize(2 * n - 1, false);
        for(int i = 0; i < vl; i++) node[i + n - 1] = v[i];
        for(int i = n - 2; i >= 0; i--) node[i] = cmp(node[i * 2 + 1], node[i * 2 + 2]);
    }
    
    void eval(int k, int l, int r) {
        if (updated[k]) {
            node[k] += lazy[k];
            if ((r - l) > 1) {
                lazy[k * 2 + 1] += lazy[k] / 2;
                lazy[k * 2 + 2] += lazy[k] / 2;
                updated[k * 2 + 1] = updated[k * 2 + 2] = true;
            }
            lazy[k] = 0;
            updated[k] = false;
        }
    }
    
public:
    LazySegmentTree() {}
    LazySegmentTree(int _n, T _def, function<T(T,T)> _cmp) {
        init(vector<T>(_n, _def), _def, _cmp);
    }
    LazySegmentTree(const vector<T> &v, T _def, function<T(T,T)> _cmp) {
        init(v, _def, _cmp);
    }
    
    void update(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if((b <= l) || (r <= a)) return;
        if((a <= l) && (r <= b)) {
            lazy[k] += (r - l) * x;
            updated[k] = true;
            eval(k, l, r);
        }
        else {
            update(a, b, x, 2 * k + 1, l, (l + r) / 2);
            update(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = cmp(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if ((b <= l) || (r <= a)) return def;
        if ((a <= l) && (r <= b)) return node[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return cmp(vl, vr);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, q;
    cin >> n >> q;
    LazySegmentTree<ll> lst(n, 0, [](ll a, ll b){ return a + b; });
    rep(i, q) {
        ll com;
        cin >> com;
        if (com == 0) {
            ll s, t, x;
            cin >> s >> t >> x;
            s--; t--;
            lst.update(s, t + 1, x);
        }
        else {
            ll s, t;
            cin >> s >> t;
            s--; t--;
            cout << lst.query(s, t + 1) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{

    string s, t;
    cin >> s >> t;
    int len = t.length(), ans = 999999999, flag = 0, cnt = 0;
    for (int i = 0; i <= s.length() - len; i++)
    {
        cnt = 0;
        flag = 0;
        for (int j = 0; j < t.length(); j++)
         {
             if(s[i+j] != t[j] ) cnt++;
         }
         ans = min(ans,cnt);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define NL '\n'
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

//#define LOCAL
vector<string>vec_spltr(string s){s+=',';vector<string>res;while(!s.empty())
res.push_back(s.substr(0, s.find(','))),s=s.substr(s.find(',')+1);return res;}
void dbg_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,
__attribute__((unused))int LINE_NUM){cerr<<endl;}template<typename Head,typename... Tail>
void dbg_out ( vector <string> args, int idx, int LINE_NUM, Head H, Tail... T)
{if(idx>0)cerr<<", ";else cerr << "Line(" << LINE_NUM << ") ";stringstream ss;ss<<H;
cerr<<args[idx]<<" = "<<ss.str();dbg_out(args,idx+1,LINE_NUM, T...);}
#ifdef LOCAL
#define debug(...) dbg_out(vec_spltr(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 6660999
#endif

void absinthe() {
    ll n, m, q, l, r; 
    cin >> n >> m >> q;
    vector<vector<ll>>a(n+3, vector<ll>(n+3));
    rep(i, 0, m) { cin >> l >> r; a[l][r]++; }
    rep(i, 1, n+1) rep(j, 1, n+1) a[i][j] += a[i][j-1];
    rep(j, 1, n+1) rep(i, 1, n+1) a[i][j] += a[i-1][j];
    while(q--) { cin >> l >> r; cout << a[r][r] + a[l-1][l-1] - a[l-1][r] - a[r][l-1] << NL; }
}
 
int main(){
  _fastIO();
  int tx = 1; 
  //cin >> tx;
  while(tx--) absinthe();
}  

Measured memory_bytes: 2944
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
cnts = [0] * (N + 1)
cnts[0] = 3
ans = 1
for a in A:
    ans *= cnts[a]
    cnts[a] -= 1
    cnts[a+1] += 1
print(ans % mod)

Measured memory_bytes: 13964
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    pair<ll,ll> p[1010];
    ll T[1010],A[1010];
    for(int i=1;i<=N;i++){
        cin>>T[i]>>A[i];
    }
    p[1]={T[1],A[1]};
    for(int i=2;i<=N;i++){
        ll t,a;
        t=p[i-1].first/T[i];
        a=p[i-1].second/A[i];
        ll m=max(t,a);
        ll x,y;
        x=(ll)m*(ll)T[i];
        y=(ll)m*(ll)A[i];
        if(x>=p[i-1].first && y>=p[i-1].second){
            p[i]={x,y};
        }
        else{
            x+=(ll)T[i];y+=(ll)A[i];
            p[i]={x,y};
        }
    }
    cout<<p[N].first+p[N].second<<endl;
    return 0;
}

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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

//幅優先　ツリー　木　無効グラフ　重み付き　二部グラフ

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;
int N;
Graph G;

vector<int> res;

// v は現在見ている頂点, p は v の親
void dfs(int v, int p ,int c) {
    res[v]=c;
  for (auto e : G[v]) {
    if (e.first == p) continue;  // これがツリー探索で一般的な書き方
    if(e.second&1) dfs(e.first,v,1-c);
    else dfs(e.first, v,c);
  }
}

int main() {
  cin >> N;
  G.assign(N,vector<Edge>()); //GをN個のエッジで初期化
  for(int i=0;i<N-1;i++){
      int u,v,w;
      cin >> u >> v >> w;
      --u,--v;
      G[u].push_back(Edge(v,w));
      G[v].push_back(Edge(u,w));
  }
  res.assign(N,0);
  dfs(0,-1,1);
  for(auto v:res)cout<< v << endl;

}

Measured memory_bytes: 8960
#include <iostream>

int main(){
int t, a, b;
std::cin >> t;
    a = t / 100;
    b = t % 100;

    if(13 > a && a > 0){
        if(13 > b && b > 0){
            std::cout << "AMBIGUOUS" << std::endl;
        }else{
            std::cout << "MMYY" << std::endl;
        }
    }else if(13 > b && b > 0){
        std::cout << "YYMM" << std::endl;
    }else{
        std::cout << "NA" << std::endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc002_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

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

  string ans;
  if (a > 0 && b > 0) {
    ans = "Positive";
  } else if (a <= 0 && b >= 0) {
    ans = "Zero";
  } else {
    if ((a - b) % 2 == 0) {
      ans = "Negative";
    } else {
      ans = "Positive";
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
name = ['light fly', 'fly', 'bantam', 'feather', 'light', 'light welter',
        'welter', 'light middle', 'middle', 'light heavy', 'heavy']
ws = [48, 51, 54, 57, 60, 64, 69, 75, 81, 91]
while True:
    try:
        w = float(input())
    except:
        break
    for i in range(10):
        if w <= ws[i]:
            print(name[i])
            break
    else:
        print(name[10])

Measured memory_bytes: 7324
import math
n,k=map(int,input().split()) 

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

mod_num = 10 ** 9 + 7
for i in range(1, k+1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(n-k+1, i) * comb(k-i+(i-1), i-1) % mod_num)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long

using namespace std;

#define row     vector < ll >
#define matrix  vector < row >
#define sz(v) v.size()
ll mod = 1e9+7;

matrix newZero(int n, int m)
{
    return matrix(n,row(m,0));
}

matrix newIdentity(int n)
{
    matrix v = newZero(n,n);
    for(int i = 0 ; i < n ; i++)v[i][i] = 1;
    return v;
}

matrix add(matrix a , matrix b)
{
    for(int i = 0 ; i < sz(a) ; i++)
        for(int j = 0 ; j < sz(a[0]) ; j++)
            a[i][j] += b[i][j];
    return a;
}
matrix reflect(matrix a)
{
    matrix v = newZero(sz(a),sz(a[0]));
    for(int i = 0 ; i < sz(a) ; i++)
        for(int j = 0 ; j < sz(a[0]) ; j++)
            v[i][sz(a[0])-1-j] = a[i][j];
    return v;
}
matrix rotateMatrix(matrix a)
{
    matrix v = newZero(sz(a[0]) , sz(a));
    for(int i = 0 ; i < sz(a) ; i++)
        for(int j = 0 ; j < sz(a[0]) ; j++)
            v[j][sz(a)-1-i] = a[i][j];
    return v;
}
matrix addIdentity(matrix a)
{
    for(int i = 0 ; i < sz(a) ; i++)a[i][i] ++;
    return a;
}
/// Matrix Multiplication
matrix multiply(matrix a , matrix b)
{
    matrix v = newZero(sz(a) , sz(b[0]));
    for(int i = 0 ; i < sz(a) ; i++)
        for(int j = 0 ; j < sz(b[0]) ; j++)
            for(int k = 0 ; k < sz(b) ; k++)
                    v[i][j] = ((v[i][j]%mod) + ((a[i][k]%mod)*(b[k][j])%mod)%mod)%mod;
                //v[i][j] += a[i][k]*b[k][j];
    return v;
}
/// Fast Matrix Power
matrix fp(matrix a , ll p)
{
    if(!p)return newIdentity(sz(a));
    if(p&1)return multiply(a,fp(a,p-1));
    return fp(multiply(a,a),p>>1);
}
/// Sum Power
matrix sumPower(matrix a, ll k)
{
    if(!k)return newZero(sz(a),sz(a));
    if(k&1)return multiply(a , addIdentity(sumPower(a,k-1)));
    return multiply( sumPower(a,k>>1) , addIdentity(fp(a,k>>1)));
}
void displayMatrix(matrix a)
{
    for(int i = 0 ; i < sz(a) ; i++)
    {
        for(int j = 0 ; j < sz(a[0]) ; j++)printf("%d ",a[i][j]);
        printf("\n");
    }
}
ll n,k;
int main()
{
    cin >> n >> k;
    matrix a = newZero(52,52);
    for(int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            cin >> a[i][j];
        }
    }
    matrix res = fp(a,k);
    ll ans = 0;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            ans += res[i][j];
            ans %= mod;
        }
    }
    cout << ans << endl;
   // cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int l1,l2,r1,r2;
int main()
{
    cin>>l1>>r1>>l2>>r2;

    int levo=max(l1,l2);
    int desno=min(r1,r2);

    cout<<max(0,desno-levo);


return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> p;

int main(){
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < 2 * n; i++)
  {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(all(v));
  int res = 0;

  for (int i = 0; i < 2 * n; i+=2)
  {
    res += v[i];
  }

  cout << res << endl;


}


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

const int N = 100000;
const int mo = 998244353;

int n;
char s[3*N + 5];
int cnt[6], tot[6];

int idx(char c) {
  if (c == 'R') return 0;
  if (c == 'G') return 1;
  if (c == 'B') return 2;
  exit(-1);
}

// B, G, R 
int idx(char c, char d) {
  if (c > d) swap(c, d);
  if (c == 'G' && d == 'R') return 3;
  if (c == 'B' && d == 'R') return 4;
  if (c == 'B' && d == 'G') return 5;
  exit(-1);
}

int main() { 
  scanf("%d", &n);
  scanf("%s", s);

  int ans = 1;
  for (int i = 1; i <= n; ++i) ans = 1ll * ans * i % mo;

  n *= 3;
  for (int i = 0; i < n; ++i) {
    if (cnt[5 - idx(s[i])]) {
      ans = 1ll * ans * cnt[5 - idx(s[i])] % mo;
      -- cnt[5 - idx(s[i])];
    } else {
      int p = -1;
      for (int j = 0; j < 3; ++j) if (cnt[j]) p = j;

      if (p == -1 || "RGB"[p] == s[i]) 
        ++ cnt[idx(s[i])]; 
      else {
        ++ cnt[idx(s[i], "RGB"[p])];
        ans = 1ll * ans * cnt[p] % mo;
        -- cnt[p];
      }
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		int[] h = new int[N];
		int max = 0;
		int height = 0;
		for (int i = 0; i < N; i++) {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		}
		while (height < max) {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		}
		System.out.print(ans);
		reader.close();

	}

}

Measured memory_bytes: 23636
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N,i;
inline void solve(){
  IN(N);
  DW(i,N,1){
    if((int)sqrt(i)*(int)sqrt(i)==i){
      OUT(i);
      return;
    }
  }
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
# coding: utf-8
N=int(input())
AB=[]

for i in range(N):
    A,B=map(int,input().split())
    AB.append([A+B,A,B])

AB.sort(reverse=True)
Ta=0
Ao=0

for i in range(N):
    if i%2==0:
        Ta+=AB[i][1]
    else:
        Ao+=AB[i][2]

print(Ta-Ao)




Measured memory_bytes: 23260
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,C;cin>>A>>B>>C;
  cout << (A==B? C:A==C?B:A)<<endl;
  return 0;
}


Measured memory_bytes: 256
let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> (n, m)) in
  let arr = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
  let sum = float_of_int @@ Array.fold_left ( + ) 0 @@ Array.copy arr in
  let fltr = ceil (sum /. (float_of_int m *. 4.)) and count = ref 0 in
  Array.iter (fun i -> if i >= int_of_float fltr then count := !count + 1) arr ;
  if !count >= m then print_endline "Yes" else print_endline "No"


Measured memory_bytes: 384
from collections import defaultdict
N = int(input())
tmp = [int(input()) for _ in range(N)]
mod = 10 ** 9 + 7
C = []
for c in tmp:
    if not C:
        C.append(c)
        continue
    if C[-1] != c:
        C.append(c)
N = len(C)

last = defaultdict(int)
ans = 1

for c in C:
    ans += last[c]
    ans %= mod
    last[c] = ans

print(ans)


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

int K;
ll dp[13][10];
vector<ll> acc(14, 0);
vector<ll> dacc(14, 0);

    

int main(){
  cin >> K;
  ll sup = K;

  for(int i = 0; i < 10; i++) dp[1][i] = 1;  //初期条件


  for(int i = 1; i < 13; i++){
    for(int k = 0; k < 10; k++){
      if(k == 0) dp[i+1][k] = dp[i][k] + dp[i][k+1];
      else if(k == 9) dp[i+1][k] = dp[i][k-1] + dp[i][k];
      else dp[i+1][k] = dp[i][k-1] + dp[i][k] + dp[i][k+1];
    }
  }

  for(int i = 1; i < 14; i++){
    for(int j = 1; j < 10; j++){
      acc[i] += dp[i][j];
    }
    dacc[i] += acc[i] + dacc[i-1];
  }

  int i = 1;
  while(sup > dacc[i]) ++i;


    int j = 1;
    bool cn = true;
    ll tmp = sup;
    tmp -= dacc[i-1];  //i桁目に答えあり
    while(i > 0){
      if(cn){
        while(tmp > dp[i][j]){ tmp -= dp[i][j]; ++j; }
        cn = false;
      }else{
        if(j == 0){
          while(j < 2 && tmp > dp[i][j]){ tmp -= dp[i][j]; ++j; }
        }else if(j == 9){ j = 8;
          while(j <= 9 && tmp > dp[i][j]){ tmp -= dp[i][j]; --j; }
        }else { j -= 1;
          while(j <= j+2 && tmp > dp[i][j]){ tmp -= dp[i][j]; ++j; }
        }
      }
      cout << j;
      i -= 1;
    }
  return 0;

}



Measured memory_bytes: 256