akhauriyash/Code-Regression huggingface dataset:
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 50010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''

def nc2(n):
    return (n*(n-1))//2

n = int(input())
a = arrIN()
c = Counter(a)
ans = 0
for i in set(a):
    ans+=nc2(c[i])


for i in range(n):
    print(ans-nc2(c[a[i]])+nc2(c[a[i]]-1))


Measured memory_bytes: 29872
#include<stdio.h>

int main(void){
    int A,B,C,K,ans=0;
    scanf("%d %d %d %d",&A,&B,&C,&K);
    if(K>A){
        ans=A;
        K-=A;
        if(K>B){
            ans=ans-(K-B);
        }
    }else{
        ans=K;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1732
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var a = NextInt;
        var b = NextInt;
        int current = 1;
        int res = 0;
        while (current < b)
        {
            current--;
            current += a;
            res++;
        }
        Console.WriteLine(res);
    }

    static readonly TextReader In = Console.In;
    static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0;
            int next = In.Read();
            int rev = 1;
            while (45 > next || next > 57) next = In.Read();
            if (next == 45) { next = In.Read(); rev = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = In.Read();
            }
            return res * rev;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main()
{
	int i;
	int n;
	int o,p;
	int on,pn;
	int sum ,nsum;
	cin >> n;
	for(i=0;i<n;i++)
	{
		sum=0;
		cin >> o >> p >> on >> pn;
		if( on >=5 && pn >= 2 )
		{
			sum = (o*on+p*pn)*0.8 ;
		}
		else
		{
			sum = (o*on+p*pn);
			if( on<5 ) on=5;
			if( pn<2 ) pn=2;
			if(sum > (o*on+p*pn)*0.8 ) sum=(o*on+p*pn)*0.8;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    long long a,b,c,d,v,q;
    cin >> a >> b ;
    c = a * b ;
    d = a - b ;
    v = a + b ;
    q = max({c,d,v}) ;
    cout << q ;

    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  string x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x <<" " << y;
  
  
  return 0;
}

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

#define int long long

using namespace std;



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

    int X;
    cin >> X;

    if(X >= 30)cout << "Yes" << '\n';
    else cout << "No" << '\n';

    return 0;
}

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


def solve(S: str):
    print(S[:3])
    return


# Generated by 1.1.7.1 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()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9056
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int n;
int q;
int a[100010]; 
long long cnt=0;
map<long long,long long> mp;
int main(){
	cin>>n;
	for(int i=0;i<=100000;i++)mp[a[i]]=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt+=a[i];
		mp[a[i]]++;
	}
	cin>>q;
	while(q--){
		int k,j;
		cin>>k>>j;
		cnt-=k*mp[k];
		cnt+=j*mp[k];
		mp[j]+=mp[k];
		mp[k]=0;
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 9840
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int calc(int n){
	int cnt=0;
	while(n>0 && n%2==0){
		n/=2;
		cnt++;
	}
	return cnt;
}

int main(){
	int n;
	cin>>n;
	int a[n];
	REP(i,n)cin>>a[i];
	int cnt=0;
	REP(i,n)cnt+=calc(a[i]);
	cout<<cnt<<endl;
	return 0;
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a-b>=c)
    cout << 0 <<endl;
  else
    cout<<c-a+b<<endl;
}

Measured memory_bytes: 3624
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         ·ð×æ±£ÓÓ       ÓÀÎÞBUG
*/
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
using namespace std;
const int INF=1e9;
int a[200005],n;
int b[200005];
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n;
	int i,j;
	for(i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	int a1,a2;
	a1=b[n/2-1];
	a2=b[n/2];
	for(i=0;i<n;i++){
		if(a[i]<=a1) cout<<a2<<endl;
		else cout<<a1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
  string S;
  cin>>S;
  int a=S.size();
  bool b=false;
  rep(i,a){
      if(i!=0){
          if(S[i]=='C'&&S[i-1]=='A'){
              b=true;
              break;
          }
      }
  }
  if(b==true){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }
}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> p(N+2);
    for(int i=1; i<=N; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for(int i=1; i<=N; i++) {
        if(p[i] == i) {
            swap(p[i], p[i+1]);
            ++ans;
        }
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
using namespace std;
int n,i,x;
string s,t;
long long ans;
int main(){
	cin>>s;
	for(i=0;i<s.size();i++){
		if(i<s.size()&&s[i]=='B'&&s[i+1]=='C'){
			t.push_back('D');
			i++;
		}
		else{
			t.push_back(s[i]);
		}
	}
	for(i=0;i<t.size();i++){
		if(t[i]=='A') x++;
		else if(t[i]=='D') ans+=x;
		else x=0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3832
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

using ll = long long ;

class BCardGameForTwo {
public:
	void solve(std::istream& cin, std::ostream& cout) {
	    int n ;
	    cin >> n ;
	    vector<int> a(n) ;
	    for(int i = 0 ; i < n ; ++i){
	        cin >> a[i];
	    }
	    sort(a.rbegin() , a.rend());
	    int ans = 0 ;
	    for(int i = 0 ; i < n ; ++i){
	        if(i % 2 == 0){
	            ans += a[i] ;
	        }else{
	            ans -= a[i] ;
	        }
	    }
	    cout << ans ;

	}
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	BCardGameForTwo solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll n,d;
    cin >> n >> d;
    double x,y;
    int c = 0;
    while(n--){
        cin >> x >> y;
        if(x*x + y*y <= d * d){
            ++c;
        }
    }
    cout << c << endl;
	
	return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 1000005
typedef long long int ll;
int main()
{
    int i,j,k,a,b,n,m,f,p;
    string str;
    vi v(5);
    read(v,i,5);
    in(k);
    f=1;
    rep(i,5)
    {
        lp(j,i+1,5)
            if(v[j]-v[i]>k)
                f=0;
    }
    if(f)
        cout << "Yay! ";
    else
        cout << ":(";



}


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

int p;
string str;

int Term();
int Factor();
int Elem();
int Digit();

int Term() {
  int a = Factor();
  while (str[p] == '+' || str[p] == '-') {
    char c = str[p];
    p++; // read [+-]
    int b = Factor();
    if (c == '+') {
      a = a + b;
    } else {
      a = a - b;
    }
  }
  return a;
}

int Factor() {
  int a = Elem();
  while (str[p] == '*' || str[p] == '/') {
    char c = str[p];
    p++; // read [*/]
    int b = Elem();
    if (c == '*') {
      a = a * b;
    } else {
      a = a / b;
    }
  }
  return a;
}

int Elem() {
  if (str[p] == '(') {
    p++; // read (
    int a = Term();
    p++; // read )
    return a;
  } else {
    int a = 0;
    while (isdigit(str[p])) {
      int b = Digit();
      a = 10 * a + b;
    }
    return a;
  }
}

int Digit() {
  int a = str[p] - '0';
  p++; // read [0-9]
  return a;
};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str;
    p = 0;
    cout << Term() << endl;
  }
}

Measured memory_bytes: 1204
n, m = map(int, input().split())
a = list(map(int, input().split()))
c = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010
f[0] = 0
for i in range(1, n+1):
	for x in a:
		if i-c[x] >= 0:
			f[i] = max(f[i], f[i-c[x]]*10+x)
print(f[n])


Measured memory_bytes: 14388
# C - Next Prime
import math

def is_prime(n):
	# 対象の数(n)が素数かどうかを判定する	
	
	if n < 2:
		# 0,1 は素数ではない
		return False
	else:
		# nの平方根以下の数ですべて試し割りする
		sqrt_ = math.floor(math.sqrt(n))
		
		for i in range(2, sqrt_ + 1):
			if n % i == 0:
				return False
		
	return True


x = int(input())

while True:
	if is_prime(x):
		print(x)
		break
	else:
		x += 1

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<vector<int>> table(10, vector<int>(10, 0));
    rrep(i, n) {
        string s = to_string(i);
        int a = s[0] - '0', b = s.back() - '0';
        table[a][b]++;
    }

    ll ans = 0;
    rrep(i, n) {
        string s = to_string(i);
        int a = s[0] - '0', b = s.back() - '0';
        ans += table[b][a];
    }
    cout << ans << endl;
  
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll q,w,e,r; cin >>q>>w>>e>>r;
  if(q>w){
    cout << e*w+(q-w)*r;
  }
  else{
    cout << q*e;
  }
}

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int count = 0;
		int keep = i;
		while (keep != 0) {
			count += keep % 10;
			keep /= 10;
		}
		if (a <= count && count <= b)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int N,K;
long long int num[100001];

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		long long int a, b;
		cin >> a >> b;
		num[a] += b;
	}
	long long int box = 0;
	for (int i = 0; i <= 100000; i++) {
		box += num[i];
		if (box >= K) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll h, w;
    cin >> h >> w;
    
    string s[h];
    rep(i, h)cin >> s[i];

    ll high[h][w] = {};
    ll low[h][w] = {};
    ll left[h][w] = {};
    ll right[h][w] = {};

    rep(i, h)rep(j, w){
        if(i != 0){
            if(s[i-1][j] == '.')high[i][j] = high[i-1][j] + 1;
            if(s[h-i][j] == '.')low[h-i-1][j] = low[h-i][j] + 1;
        }
        if(j != 0){
            if(s[i][j-1] == '.')left[i][j] = left[i][j-1] + 1;
            if(s[i][w-j] == '.')right[i][w-j-1] = right[i][w-j] + 1; 
        }

        if(s[i][j] == '#'){
            high[i][j] = 0;
            left[i][j] = 0;
        }
        if(s[h-i-1][j] == '#')low[h-i-1][j] = 0;
        if(s[i][w-j-1] == '#')right[i][w-j-1] = 0;
    }

    ll ans = 0;
    rep(i, h)rep(j, w){
        if(s[i][j] == '#')continue;

        ans = max(ans, high[i][j] + low[i][j] + left[i][j] + right[i][j] + 1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 136196
import java.io.PrintWriter
import java.math.BigDecimal
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val L = BigDecimal(sc.nextInt())
    val div = BigDecimal(27)
    val L3 = L*L*L
    val result = L3.divide(div, 10, BigDecimal.ROUND_HALF_UP)
    println(result)
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 31268
#include <stdio.h>
#include <string.h>
int main(){
    int tc;
    scanf("%d", &tc);
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    int i;
    for( i = 0; i < tc ; i++){
        char verdict[100];
        scanf("%s", verdict);
        int length = strlen(verdict);
        if(verdict[0] == 'A'){
            ac++;
        }
        else if(verdict[0] == 'W'){
            wa++;
        }
        else if(verdict[0] == 'T'){
            tle++;
        }
        else if (verdict[0] == 'R'){
            re++;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  string t1, t2;
  vector<int> vec;
  int count = 0;
  rep(i, n) {
    if(s[i] == 'x') ++count;
    else {
      vec.push_back(count);
      count = 0;
      t1 += s[i];
      t2 += s[i];
    }
  }
  vec.push_back(count);
  reverse(ALL(t2));

  if(t1 != t2) cout << -1 << endl;
  else {
    int ans = 0;
    int m = vec.size();
    rep(i, m) ans += abs(vec[i]-vec[m-1-i]);
    cout << ans/2 << endl;
  }
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int x,y;
    cin >> x >> y;
    if(y%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    else if(x*4 < y){
        cout << "No" << endl;
        return 0;
    }
    else if(x*2 > y){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	str s;
	cin >> s;
	int ans = 0;
	rep(i, s.size())
	{
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
		{
			int start = i;
			for (; (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') && i < s.size(); i++)
			{
			}
			ans = max(ans, i - start);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};
ll dp[3001][3001];
ll score(vector<ll>&arr,int i,int j, int type){
    if(i>j)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(type){
        ll op1 = arr[i] + score(arr,i+1,j,1-type);
        ll op2 = arr[j] + score(arr,i,j-1,1-type);
        return dp[i][j] = max(op1,op2);
    }
    else{
        ll op1 = score(arr,i+1,j,1-type);
        ll op2 = score(arr,i,j-1,1-type);
        return dp[i][j] = min(op1,op2);
    }
    return 0;
}

void solve(){

    ll n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    vector<ll>arr(n);
    ll sum = 0;
    rep(i,n)
    cin>>arr[i],sum+=arr[i];

    ll scoreX = score(arr,0,arr.size()-1,1);
    ll scoreY = sum-scoreX;

    db1(scoreX-scoreY);

}
int main(){ 

int t=1;
//cin>>t;
while(t--){
 solve();
}
  return 0; 
}


Measured memory_bytes: 70912
def cur(x):

    if len(x)<n+1:
        ans=0
        for i in range(x[-1],m+1):
            ans=max(ans,cur(x+[i]))
    else:
        ans=0
        for i in range(q):
            [a,b,c,d]=l[i]
            if x[b]-x[a]==c: ans+=d
    return ans

n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
print(cur([1]))

Measured memory_bytes: 73928
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

vector<string> split_native(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main(){
    int N;

    while(cin >> N){
        if(N ==0) break;

        UnionFind<int> UF(200);
        map<string, int> m;
        int idx = 0;
        bool flag = true;

        for(int i=0; i<N; ++i){
            string one, unit1, equal, val, unit2;
            cin >> one >> unit1 >> equal >> val >> unit2;
            if(m.count(unit1) == 0){
                m[unit1] = idx;
                ++idx;
            }
            int id1 = m[unit1];

            if(m.count(unit2) == 0){
                m[unit2] = idx;
                ++idx;
            }
            int id2 = m[unit2]; 

            int w;
            vector<string> vec;
            vec = split_native(val, '^');
            w = stoi(vec[1]);

            if(UF.issame(id1, id2)){
                int diff = UF.diff(id1, id2);
                if(diff != w) flag = false;
            }else{
                UF.merge(id1, id2, w);
            }                 
        }
        if(flag){
            puts("Yes");
        }else{
            puts("No");
        }
    }    
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

int main()
{
	int A, B;

	std::cin >> A >> B;

	int ret = 0;
	if (A > B) {
		ret += A;
		--A;
	} else {
		ret += B;
		--B;
	}
	if (A > B) {
		ret += A;
		--A;
	} else {
		ret += B;
		--B;
	}
	std::cout << ret << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		Double x1=sc.nextDouble(),y1=sc.nextDouble(),x2=sc.nextDouble(),y2=sc.nextDouble();
		Double q;
		q=Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
		System.out.println(q);
	}
}



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

int main()
{
    string s;
    long sum = 0;
    cin>>s;
    int i,x=s.size();
    for (i=0; i<x;i++) sum += s[i] - '0';

    if((sum % 9) == 0) cout <<"Yes"<< endl;
    else cout<<"No"<< endl;

    return 0;
}



Measured memory_bytes: 3744
# C - Otoshidama(https://atcoder.jp/contests/abc085/tasks/abc085_c)
n, y = map(int, input().split())
end = 0
for i in range(n + 1):
    if n < i:
        break
    for j in range(n + 1):
        if n - i - j < 0:
            break
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            print(i, j, n - i - j)
            end += 1
    if end:
        break
if end == 0:
    print(-1, -1, -1)

Measured memory_bytes: 3064
import bisect

raw_input = input()
input_number = int(raw_input)
counts = 0

top_lane = input().split()
mid_lane = input().split()
bot_lane = input().split()

for i in range(input_number):
    top_lane[i] = int(top_lane[i])
    mid_lane[i] = int(mid_lane[i])
    bot_lane[i] = int(bot_lane[i])

top_lane.sort()
mid_lane.sort()
bot_lane.sort()

for mid in mid_lane:
    top_index = bisect.bisect_left(top_lane, mid)
    bot_index = input_number - bisect.bisect_right(bot_lane, mid)
    counts += top_index * bot_index

print(counts)


Measured memory_bytes: 26576
a,b,m = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
M = []
for _ in range(m):
  M.append(list(map(int,input().split())))
  
min_price = min(A) + min(B)
for s in M:
  price = A[s[0]-1] + B[s[1]-1] - s[2]
  if min_price > price:
    min_price = price
    
print(min_price)

Measured memory_bytes: 38500
#include <iostream>

using namespace std;

int main(){

    int a,b,c,d,e,na,nb,nc;
    while(cin>>a>>b>>c>>d>>e,a&&b&&c&&d&&e){
    cin>>na>>nb>>nc;
        if(na+nb+nc>=d){
            if(nc>=d){
                cout<<min(a*na+b*nb+(nc)*e,a*na+b*nb+c*nc)<<endl;
            }else if(nc+nb>=d){
                cout<<min(a*na+b*(nb-(d-nc))+(nc+(d-nc))*e,a*na+b*nb+c*nc)<<endl;
            }else if(nc+nb+na>=d){
                cout<<min(a*(na-(d-nc-nb))+(nc+nb+(d-nc-nb))*e,a*na+b*nb+c*nc)<<endl;
            }
            
        }else{
            cout<<min(d*e,a*na+b*nb+c*nc)<<endl;
        }
    }

}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;
vector<int> t[202020];
int res[202020];

void dfs(int v,int p=-1){
    for(auto to:t[v]){
        if(to==p)continue;
        res[to] += res[v];
        dfs(to,v);
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q; cin>>n>>q;
    
    rep(i,0,n-1){
        int a,b; cin>>a>>b;
        a--,b--;
        t[a].push_back(b);
        t[b].push_back(a);
    }
    rep(ii,0,q){
        int p,x; cin>>p>>x;
        p--;
        res[p]+=x;
    }
    dfs(0);
    rep(i,0,n)cout<<res[i]<<endl;
}

Measured memory_bytes: 23552
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	char c;
	cin>>c;
	if(c>=65 && c<=90) cout<<"A"<<en;
	else cout<<"a"<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


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

typedef long long ll;

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> P(N * N), d(N * N);
    rep(i, N) {
        rep(j, N) {
            int k = i * N + j;
            cin >> P[k];
            P[k]--;
            d[k] = min({i, j, N - 1 - i, N - 1 - j});
        }
    }
    vector<bool> done(N * N, false);
    rep(k, N * N) {
        ans += d[P[k]];
        done[P[k]] = true;
        stack<pair<int, int>> q;
        q.push(make_pair(P[k], d[P[k]]));
        while (!q.empty()) {
            auto p = q.top();
            q.pop();
            int k0 = p.first, i0 = k0 / N, j0 = k0 % N, d0 = p.second;
            d[k0] = d0;
            int di[4] = {1, 0, -1, 0}, dj[4] = {0, 1, 0, -1};
            rep(l, 4) {
                int ni = i0 + di[l], nj = j0 + dj[l], nk = ni * N + nj;
                if (ni < 0 || ni >= N || nj < 0 || nj >= N) continue;
                if (done[k0]) {
                    if (d[nk] > d0) {
                        q.push(make_pair(nk, d0));
                    }
                } else {
                    if (d[nk] > d0 + 1) {
                        q.push(make_pair(nk, d0 + 1));
                    }
                }
            }
        }
    }
    cout << ans << "\n";
}


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


int main(){
    ll N;
    cin >> N;
    if(N >= 64) cout << 64 << endl;
    else if(N >= 32) cout << 32 << endl;
    else if(N >= 16) cout << 16 << endl;
    else if(N >= 8) cout << 8 << endl;
    else if(N >= 4) cout << 4 << endl;
    else if(N >= 2) cout << 2 << endl;
    else if(N >= 1) cout << 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int f=1;
    while(a>0&&c>0){
        if(f)c-=b;
        else a-=d;
        f^=1;
    }
    if(a<=0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int year, money;

	static int calc() {
		int type = sc.nextInt();
		double ratio = sc.nextDouble();
		int fee = sc.nextInt();
		if (type == 0) {
			int v = money;
			int add = 0;
			for (int i = 0; i < year; ++i) {
				add += (int) (v * ratio);
				v -= fee;
			}
			return v + add;
		} else {
			int v = money;
			for (int i = 0; i < year; ++i) {
				v += (int) (v * ratio);
				v -= fee;
			}
			return v;
		}
	}

	public static void main(String[] args) {
		int M = sc.nextInt();
		for (int i = 0; i < M; ++i) {
			money = sc.nextInt();
			year = sc.nextInt();
			int N = sc.nextInt();
			int ans = 0;
			for (int j = 0; j < N; ++j) {
				ans = Math.max(ans, calc());
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 42448
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]), k = int.Parse(input[1]);
            
            string[] input2 = Console.ReadLine().Split(' ');
            long[] x = new long[n];

            for (int i=0; i<n; i++)
            {
                x[i] = long.Parse(input2[i]);
            }

            
            long ans = 999999999;

            
            
            for (int i=0; i<=n - k; i++)
            {
                long buf = x[i + k - 1] - x[i] + Math.Min(Math.Abs(x[i]), Math.Abs(x[i + k - 1]));
                if (buf < ans) ans = buf;
            }


            Console.WriteLine(ans);
            
            


            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 20448
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int r; cin >> r;
	cout << r*r << endl;
	return 0;
}


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

/*
    A: 65, Z: 90
    a: 97, z: 122
*/
void transform(string str) {
    for (int i = 0; i < str.length(); i++) {
        int code = (int)str[i];

        if (65 <= code && code <= 90) {
            cout << (char)(code + 32);
        } else if (97 <= code && code <= 122) {
            cout << (char)(code - 32);
        } else {
            cout << (char)code;
        }
    }
    cout << endl;
}

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

    string input;
    getline(cin, input);
    transform(input);
}


Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll MOD = (ll)1e9 + 7;

ll fact(int n){
    ll res = 1;
    for (int i = 0; i < n; ++i) {
        (res *= (i + 1)) %= MOD;
    }

    return res;
}

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

    if (abs(n - m) > 1) cout << 0 << endl;
    else if (n == m) cout << 2 * fact(n) * fact(m) % MOD << endl;
    else cout << fact(n) * fact(m) % MOD << endl;
}

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

int main() {
	int i,n,c=0,j=0;
	string x;
	cin>>n;
	vector<string> s(n);
	vector<int> t(n);
	for(i=0;i<n;i++){
		cin>> s.at(i);
		cin>> t.at(i);
	}
	cin>>x;
	for(i=0;i<n;i++){
		if(j)c+=t.at(i);
		if(x==s.at(i))j=1;
		
	}
	cout<<c;
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

static const int MOD = 1e9 + 7;

bool f(int x, int a, int b) {
    return x < (a + b);
}

int main() {

    int N, K;
    cin >> N >> K;

    int ans = 0;
    for (int i = 0; i <N ; i++){
        int h;
        cin >> h;
        ans += (h >= K);
    }
    cout << ans;
}

Measured memory_bytes: 256
N=int(input())
A=N//100
B=(N-A*100)//10
C=N-A*100-B*10
if A==1:
    A=9
elif A==9:
    A=1
if B==1:
    B=9
elif B==9:
    B=1
if C==1:
    C=9
elif C==9:
    C=1
ans=A*100+B*10+C
print(ans)


Measured memory_bytes: 3060
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
vector<complex<double>>  DFT(vector<complex<double>> a) {
	int n = a.size();
	if (n == 1) return a;
	vector<complex<double>> a0(n / 2), a1(n / 2);
	REP(i, n) {
		if (i % 2 == 0) {
			a0[i / 2] = a[i];
		}
		else {
			a1[i / 2] = a[i];
		}
	}
	vector<complex<double>> inversed_a0 = DFT(a0), inversed_a1 = DFT(a1);
	vector<complex<double>> inversed_a(n);
	for (int i = 0; i < n; ++i) {
		complex<double> zeta = complex<double>(cos(2 * Ma_PI * i / n), sin(2 * Ma_PI * i / n));
		inversed_a[i] = inversed_a0[i % (n / 2)] + zeta * inversed_a1[i % (n / 2)];
	}
	return inversed_a;
}
vector<complex<double>> IDFT(vector<complex<double>> inversed_a) {
	int n = inversed_a.size();
	vector<complex<double>> now = DFT(inversed_a);
	reverse(now.begin(), now.end());
	for (int q = now.size() - 1; q >= 1; --q) {
		swap(now[q], now[q - 1]);
	}
	REP(i, n) {
		now[i] /= complex<double>(n, 0);
	}
	return now;
}
vector<complex<double>> conv(vector<complex<double>> a, vector<complex<double>> b) {
	int deg = a.size() + b.size() - 1;
	int n = 1;
	while (n < deg) n <<= 1;
	a.resize(n);
	b.resize(n);
	vector<complex<double>> inversed_a = DFT(a), inversed_b = DFT(b);
	vector<complex<double>> inversed_c(n);
	REP(i, n) {
		inversed_c[i] = inversed_a[i] * inversed_b[i];
	}
	return IDFT(inversed_c);
}
long long powing(long long now, long long hoge) {
	long long ans = 1;
	while (hoge != 0) {
		if (hoge % 2 == 1) {
			ans *= now;
			ans %= MOD;
		}
		hoge /= 2;
		now *= now;
		now %= MOD;
	}
	return ans;
}
long long inv(long long now) {
	return powing(now, MAX_MOD - 2LL);
}
unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x^(x << 11));
	x = y; y = z; z = w;
	return (w = (w^(w >> 19))^(t^(t >> 8)));
}
long long dp[30] = {};
int main() {
	string s;
	cin >> s;
	dp[0] = 1;
	long long now = 1;
	for (int i = s.length() - 1; i >= 0; --i) {
		long long tmp[14] = {};
		for (long long q = 0; q < 10; ++q) {
			if (s[i] - '0' == q || s[i] == '?') {
				for (long long j = 0; j < 13; ++j) {
					long long next = j + q * now;
					next %= 13;
					tmp[next] += dp[j];
					tmp[next] %= MAX_MOD;
				}
			}
		}
		REP(i, 13) {
			dp[i] = tmp[i];
		}
		now *= 10;
		now %= 13;
	}
	cout << dp[5] << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int day;
    cin>>day;
    if(day==25){
        cout<<"Christmas"<<endl;
    }
    else if(day==24){
        cout<<"Christmas Eve"<<endl;
    }
    else if(day==23){
        cout<<"Christmas Eve Eve"<<endl;
    }
    else if(day==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, m; cin>>n>>m;
    for(int i=0; i<n; i++){
        if(i <= n / 2) cout << 0 << " \n"[i == n-1];
        else cout << m << " \n"[i == n-1];
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b);
int lcm(int a, int b);

void solve_A(){
    
}

void solve_C(){
    int n;
    cin >> n;

    /*
    int a[n];
    int* num;
    num = (int*)calloc(1000000010, sizeof(int));
    if(num == NULL) exit(1);

    int flag = 0;
    REP(i,n){
        cin >> a[i];
        num[a[i]] ++;
        if(num[a[i]] == 2){
            flag ++;
            break;
        }
    }

    if(flag == 0) cout << "YES";
    else cout << "NO";
    */

    int a[n];
    REP(i,n) cin >> a[i];

    bool flag = false;
    sort(a, a+n);
    REP(i,n-1){
        if(a[i] == a[i+1]) flag = true;
    }

    if(flag) cout << "NO";
    else cout << "YES";

    // free(num);
}

double Expect(int n){
    return (double) (n + 1) / 2;
}

void solve_D(){
    int n, k;
    cin >> n >> k;

    int p[n];
    double e[n];
    double sum = 0.0;
    REP(i,n){
        cin >> p[i];
        sum += Expect(p[i]);
        e[i] = sum;
    }

    double ans = 0;

    if(k != n){
        REP(i, n-k){
            if(ans <= e[i+k] - e[i]) ans = e[i+k] - e[i];
        }
    } else{
        ans = e[n-1];
    }
    
    printf("%.10f", ans);
}

int main(void){
    solve_C();
    return 0;
}

int gcd(int a, int b){
    if(a < b) swap(a, b);

    int r = a % b;
    while(r != 0){
        a = b;  b = r;  r = a % b;
    }
    return b;
}

int lcm(int a, int b){
    return a * b / gcd(a, b);
}

Measured memory_bytes: 1024
#include <cstdio>

typedef long long LL;
const int Mod = 1000000007, Phi = Mod - 1, Inv2 = (Mod + 1) / 2;
const int MN = 105;

inline LL pw(LL e) {
	e = (e % Phi + Phi) % Phi;
	LL b = 2, a = 1;
	for (; e; e >>= 1, b = b * b % Mod)
		if (e & 1) a = a * b % Mod;
	return a;
}

int N, A[MN];
int stk[MN], tp;
LL B[MN], dp[MN];

inline void Add(int i, LL x) {
	dp[i] = (dp[i] + x) % Mod;
}

int main() {
	scanf("%d", &N), A[0] = A[N + 1] = 1, B[0] = 1;
	for (int i = 1; i <= N; ++i) {
		scanf("%d", &A[i]);
		B[i] = B[i - 1] + (A[i] > A[i - 1] ? A[i] - A[i - 1] : 0);
	}
	dp[0] = 1, stk[tp = 1] = 0;
	for (int i = 1; i <= N + 1; ++i) {
		while (tp && A[stk[tp]] >= A[i]) {
			int j = stk[tp];
			if (j != i - 1) {
				int k = stk[tp + 1];
				LL num2 = B[i - 1] - B[j];
				LL num1 = num2 - (A[k] - A[j]);
				Add(i, 4 * (pw(num2) - pw(num1)) * dp[j]);
			} else Add(i, 2 * dp[j]);
			--tp;
		}
		if (tp) {
			int j = stk[tp];
			if (j != i - 1) {
				int k = stk[tp + 1];
				if (A[k] != A[i]) {
					LL num2 = B[i - 1] - B[j] - (A[i] - A[j]);
					LL num1 = num2 - (A[k] - A[i]);
					Add(i, 4 * (pw(num2) - pw(num1)) * dp[j]);
				}
			} else Add(i, 2 * dp[j]);
		}
		stk[++tp] = i;
	}
	printf("%lld\n", (dp[N + 1] + Mod) * Inv2 % Mod);
	return 0;
}

Measured memory_bytes: 128
/*
Owner: dxxrk
Problem: BBQ Easy
Date: 20/11/2019
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n; cin >> n;
	
	vector<int> a(n * 2, 0);
	for(auto &i : a) cin >> i;
	
	sort(a.begin(), a.end());
	
	int ans = 0;
	for(int i = 0; i < n * 2; i += 2){
		ans += min(a[i], a[i + 1]);	
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC044A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d,e,f;
            a=int. Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c = int.Parse(Console.ReadLine());
            d = int.Parse(Console.ReadLine());
            if (a > b)
            {
                e = b * c;
                f = (a - b) * d + e;
            }
            else if (a == b)
            {
                f = a * c;
            }
            else
            {
                f = a * c;
            }
            Console.WriteLine(f);
            Console.
                ReadKey();
        }
    }
}


Measured memory_bytes: 13140