akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i<n;++i)
using ll = long long;
using P = pair<int,int>;


int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(),p.end());
  int ans = 0;
  rep(i,k){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
	int n,k,x,y;
	cin >> n >> k >> x >> y;
	int ans = 0;
	rep(i, n) {
		if (i < k) ans += x;
		else ans += y;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
s = gets.chomp
first = s[0..1].to_i
second = s[2..3].to_i
if first<=12&&1<=first
  if second<=12&&1<=second
    puts "AMBIGUOUS"
  else
    puts "MMYY"
  end
else
  if second<=12&&1<=second
    puts "YYMM"
  else
    puts "NA"
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(a, b) for (a = 0; a < b; a++)


int sum(vector<int> array){
  int i, Sum = 0;
  rep(i, array.size()){
    Sum += array[i];
  }
  return Sum;
}

int main(){
  
  int H, N, i, Sum;
  cin >> H >> N;
  vector<int> A(N);
  
  rep(i, N){
    cin >> A[i];
  }
  Sum = sum(A);
  
  if (H - Sum <= 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getLine >>= putStrLn

solve :: String -> String
solve xs = f $ reverse xs
  where
    f "" = "YES"
    f ss | length ss >= 5 && take 5 ss == "maerd" = f (drop 5 ss)
         | length ss >= 5 && take 5 ss == "esare" = f (drop 5 ss)
         | length ss >= 6 && take 6 ss == "resare" = f (drop 6 ss)
         | length ss >= 7 && take 7 ss == "remaerd" = f (drop 7 ss)
         | otherwise = "NO"


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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] array = new int[n];
		int[] b = new int[n];
		for(int i=0;i<n;i++) {
			array[i] = in.nextInt();
			b[i] = array[i];
		}
		in.close();
		Arrays.sort(b);
		long m = (long)n*(n+1)/2;
		int l = 0;
		int r = n;
		int x = b[n/2];
		while(r-l>1) {
			x = b[(r+l)/2];
			int[] a = new int[n];
			for(int i=0;i<n;i++) {
				if(array[i]>=x) a[i] = 1;
				else a[i] = -1;
			}
			int[] sum = new int[n+1];
			int max = 0;
			int min = 0;
			for(int i=0;i<n;i++) {
				sum[i+1] = sum[i] + a[i];
				if(sum[i+1]>max) max = sum[i+1];
				if(sum[i+1]<min) min = sum[i+1];
			}
			long count = 0;
			int[] bit = new int[max-min+1];
			for(int i=0;i<n+1;i++) {
				count = count + bitGetSum(bit, sum[i]-min);
				bitAdd(bit, sum[i]-min, 1);
			}
			if(count>=(m+1)/2) l += (r-l)/2;
			else r -= (r-l)/2;
		}
		System.out.println(b[l]);
	}
	
	
	public static long bitGetSum(int[] bit,int idx) {
		idx++;
		long ans = 0;
		for(;idx>0;idx-=(idx&-idx)) {
			ans = ans + bit[idx-1];
		}
		return ans;
	}
	
	public static void bitAdd(int[] bit,int idx,int num) {
		idx++;
		for(;idx<=bit.length;idx+=(idx&-idx)) {
			bit[idx-1] += num;
		}
	}

}


Measured memory_bytes: 63868
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

int bit_count(int n) {
  int count = 0;
  for (int i = 0; i < 32; i++) {
    if ((n & (1 << i)) != 0) ++count;
  }
  return count;
}

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

  int n;
  cin >> n;
  int a[n], x[n][n], y[n][n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      --x[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    bool ok = true;
    for (int j = 0; j < n && ok; j++) {
      if ((i & (1 << j)) != 0) {
        for (int k = 0; k < a[j]; k++) {
          bool c1 = (i & (1 << x[j][k])) != 0;
          bool c2 = (y[j][k] == 1);
          if (c1 != c2) {
            ok = false;
            break;
          }
        }
      }
    }
    if (ok) ans = max(ans, bit_count(i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long K, long long A, long long B) {
  ll x = K;
  while (x <= B) {
    if (A <= x && x <= B) {
      cout << "OK" << endl;
      return;
    }
    x += K;
  }
  cout << "NG" << endl;
}

int main() {
  long long K;
  scanf("%lld", &K);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(K, A, B);
  return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <vector> 
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

struct Node
{
	bool bVisit;
	vector<int> linkedNode;
	
	Node() : bVisit(false) {}
};
vector<Node> node(0);
vector<int> path;

void checkPathRight( int nodeIdx )
{
	Node& current = node[nodeIdx];
	for( int i = 0;i < current.linkedNode.size();++i )
	{
		Node& linked = node[current.linkedNode[i]];
		if( !linked.bVisit )
		{
			linked.bVisit = true;
			path.insert( path.end(), current.linkedNode[i] );
			checkPathRight( current.linkedNode[i] );
			break;
		}
	}
}

void checkPathLeft( int nodeIdx )
{
	Node& current = node[nodeIdx];
	for( int i = 0;i < current.linkedNode.size();++i )
	{
		Node& linked = node[current.linkedNode[i]];
		if( !linked.bVisit )
		{
			linked.bVisit = true;
			path.insert( path.begin(), current.linkedNode[i] );
			checkPathLeft( current.linkedNode[i] );
			break;
		}
	}	
}

int main()
{
	// 要素数
	int n, m;
	cin >> n >> m;
	node.resize(n);

	for( int i = 0;i < m;++i )
	{
		int a, b;
		cin >> a >> b;
		a -= 1; b -= 1;
		node[a].linkedNode.push_back(b);
		node[b].linkedNode.push_back(a);
	}
	
	node[0].bVisit = true;
	path.push_back(0);
	checkPathRight(0);
	checkPathLeft(0);
	
	cout << path.size() << endl;	
	for( int i = 0;i < path.size();++i )
	{
		if( i > 0 )
			cout << " ";
		cout <<  (path[i] + 1);
	}
	cout << endl;
}


Measured memory_bytes: 7544
#include<stdio.h>
int main(){
  int n,m,i;
  scanf("%d%d",&n,&m);
  int a[n+1];
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
    n-=a[i];
  }
  if(n>=0)
    printf("%d\n",n);
  else
    printf("-1\n");
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
	
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
	
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
	
class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
	
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
	
bool solve() {
	int n; cin >> n;
	int a[n]; REP (i,n) cin >> a[i];
	multiset<int> se;
	int ans = 1; se.insert(a[n-1]);
	for (int i = n - 2; i >= 0; i--) {
		auto it = se.upper_bound(a[i]);
		if (it == se.end()) {
			ans++; se.insert(a[i]);
		} else {
			se.erase(it);
			se.insert(a[i]);
		}
	}
	cout << se.size() << endl;
}
	
signed main() {
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	solve();
}

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

long long lucas(int n){
  long long L1, L2, sum;
  L1 = 2LL, L2 = 1LL;
  if (n == 0){
    return L1;
  }
  if (n == 1){
    return L2;
  }
  for (int i = 2; i <= n; i++)
  {
    sum = L1 + L2;
    L1 = L2;
    L2 = sum;
  }
  return sum;  
}

int main(){
  int N;
  cin >> N;
  printf("%lld", lucas(N));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<math.h>
using namespace std;
#define MAX 1000005
#define MOD 1000000007
#define EPS 0.00000000001
#define INF 2000000000000000000
int main()
{
    int n,i;
    scanf("%d",&n);
    printf("%d",n*n*n+n*n+n);
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
    intc(n);
    intc(r);
    if(n>9) cout << r << endl;
    else cout << r+100*(10-n);
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

char S[2000];
ll Sn;

ll i, j, k;
int main(){
    scanf("%s", S);
    Sn = strlen(S);
    fornum(i,0,Sn/2){
        if(S[i]!=S[Sn-1-i])
            break;
        if(S[i]!=S[(Sn-1)/2-1-i])
            break;
        if(S[i+(Sn+3)/2-1]!=S[Sn-1-i])
            break;
    }
    if(i<Sn/2){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC087_B();
        }

        static void ABC087_B()
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());
            var ans = 0;
            for (var a = 0; a <= A; a++)
            {
                for (var b = 0; b <= B; b++)
                {
                    for (var c = 0; c <= C; c++)
                    {
                        if (X == (a * 500) + (b * 100) + (c * 50))
                            ans++;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

using namespace std;

int main()
{
	long long l,r;
	cin >> l >> r;
	if(r-l>10*2019)
	{
		cout << 0 << endl;
		return 0;
	}
	long long ans=(1<<30);
	for(long long i=l;i<=r;i++)
		for(long long j=i+1;j<=r;j++)
			ans=min(ans,(i*j)%2019);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long a, b, r, x, tmp;
 
 cin >> a >>b;
  
  x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最小公倍数を出力 */

 cout << x/b << endl;
  return 0;
}

  

Measured memory_bytes: 256
import sys
W = input()
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for num in alpha:
    if W.count(num) %2 != 0:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653

ll sa(ll a, ll b){
	return a*a*a*a*a-b*b*b*b*b;
}

int main(){
	ll x; cin >> x;
	bool jud = false;
	FOR(i,-1000,1000){
		FOR(j,-1000,1000){
			if (x==sa(i,j)){
				cout << i << " " << j << endl;
				jud = true;
				break;
			}
		}
		if (jud) break;
	}
}

Measured memory_bytes: 3556
import itertools

n, m = map(int, input().split())
p = [[0]*n for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    p[a-1][b-1] = 1
    p[b-1][a-1] = 1

c = list(itertools.permutations(range(n)))
cnt = 0
for i in range(len(c)):
    if c[i][0] == 0:
        for j in range(n-1):
            if p[c[i][j]][c[i][j+1]] != 1:
                break
        else:
            cnt += 1
print(cnt)

Measured memory_bytes: 13744
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

void print_arr(int* arr, int size) {
    for (int i = 0; i < size; i++) {
        cout << arr[i];
        if (i != size - 1) {
            cout << " ";
        }
    }
    cout << "\n";
}

void sort(int* arr, int size) {
    print_arr(arr, size);
    for (int i = 1; i < size; i++) {
        int v = arr[i];
        int j = i - 1;
        while (j >= 0 && arr[j] > v) {
            arr[j + 1] = arr[j];
            j--;
        }
        arr[j + 1] = v;
        print_arr(arr, size);
    }
}

int main() {

    int N = 0;
    cin >> N;
    int* arr = (int*)malloc(N * sizeof(int));

    int i = 0;
    while (i < N && scanf("%d", &arr[i]) == 1)
        i++;

    sort(arr, N);
    return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)

int rows[300005], cals[300005];



void solve(){
	
	int n ,m ,c ;
	cin >> n >> m >> c;

	
	map<pair<int,int>,bool> roca;
	int maxrows = 0;
	int maxcals = 0;
	vector<int> bestrows;
	vector<int> bestcals;

	for (int i = 0 ; i < c ; i++){
		int x , y;
		cin >> x >> y;
		rows[x]++;
		cals[y]++;
		roca[{x,y}] = true;
		maxcals = max(maxcals , cals[y]);
		maxrows = max(maxrows , rows[x]);

	}

	// cout << maxrows << " " << maxcals << endl;


	for (int i = 1 ; i <= n ; i++){
		
			if (rows[i] == maxrows){
				bestrows.push_back(i);
			}
		
	}


	for (int i = 1 ; i <= m ; i++){
		
			if (cals[i] == maxcals){
				bestcals.push_back(i);
			}
		
	}

	// cout << "bestcals " << endl;
	// for (int i = 0 ; i < bestcals.size() ; i++){
	// 	cout << bestcals[i] << " ";
	// }
	// cout << endl;
	// cout << "bestrows " << endl;
	// for (int i = 0 ; i < bestrows.size() ; i++){
	// 	cout << bestrows[i] << " ";
	// }cout << endl;



	for (int i = 0 ; i < bestrows.size() ; i++){
		for (int j = 0 ; j < bestcals.size() ; j++){
			// cout << bestrows[i] << " " << bestrows[j] << endl;
			if (roca.count({bestrows[i],bestcals[j]}) == 0){
				cout << maxrows + maxcals << endl;
				return;
			}
		}
	}

	


	cout << maxrows + maxcals - 1 << endl;

}



int main()
{
    FAST;
    int t;
   	t = 1;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 28464
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef double D;
typedef vector<ll> VL;
typedef set<ll> SL;
ll M= 1e9+7;	

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

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




Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[200005], pos[200005];
set<int> st;
set<int>::iterator its;
int main(){
	int n;
	scanf("%d", &n);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
		pos[a[i]] = i;
	}
	LL ans = 0;
	for(int i=1;i<=n;i++){
		int l = 1, r = n;
		int p = pos[i];
		its = st.lower_bound(p);
		if(its != st.end()) r = *its-1;
		if(its != st.begin()) its--, l = *its+1;
		int le = p-l+1, re = r-p+1;
		ans += (LL)re*le*i;
		st.insert(p);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 11136
#include<stdio.h>

int main (void){
	
	int left,right,mid,A[100000];
	int key = 100;
	int n,counter=0;
	int i;
	int q,B[50000];
	//n?????\???
	//s[0],...,s[n-1]?????§?????\???
	
	scanf("%d",&n);
	
	for(i=0;i<n;++i){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;++i){
		scanf("%d",&B[i]);
	}
		
	for(i=0;i<q;++i){		
		left = 0;
		right = n;
		while (left < right){
			mid = ( left + right ) / 2;
		
			if (A[mid] == B[i]){
				counter=counter+1;
				break;
			}else if(B[i] < A[mid]){
				right = mid;
			}else{
				left = mid +1;
			}
		}
		
	}
		
	printf("%d\n",counter);
	return 0;
}

Measured memory_bytes: 1184
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            int input = int.Parse(Console.ReadLine());
            for(int i = 1; i <= input; ++i){
                if (i % 3 == 0 || i.ToString().Contains("3")) {
                    Console.Write(" {0}", i);
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 6368
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math
import functools

n = int(input())
a = [int(input()) for i in range(n)]
c = collections.Counter(a)
ans = []
for key,value in c.items():
    ans.append([key,value])
cnt = 0
for i in range(len(ans)):
    if ans[i][1]%2 == 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 32712
#include<iostream>

using namespace std;

int n,m,num[4]= {0};
bool ans=1,used[4]= {0};

int main() {
	scanf("%d %d",&n,&m);
	for(int i=1,s,c; i<=m; ++i) {
		scanf("%d %d",&s,&c);
		if(used[s-1] && c!=num[s-1]) ans=0;
		else num[s-1]=c,used[s-1]=1;
	}
	if(ans && (num[0] || !used[0] || n==1)) {
		if(!num[0]) {
			if(n==1) puts("0");
			else {
				num[0]=1;
				for(int i=0; i<n; ++i) putchar(num[i]+48);
				putchar('\n');
			}
		} else {
			for(int i=0; i<n; ++i) putchar(num[i]+48);
			putchar('\n');
		}
	} else puts("-1");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX_N = 110;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

int dp[2][MAX_N];
int a[MAX_N], b[MAX_N];

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

    for (int i = 0; i < n; i++){
        dp[0][i + 1] = dp[0][i] + a[i];
        dp[1][i + 1] = b[i] + max(dp[0][i + 1], dp[1][i]);
    }

    cout << dp[1][n] << endl;

    return 0;
}

Measured memory_bytes: 256
s = input().split()
n = int(s[0])
k = int(s[1])
q = int(s[2])
ans = [k - q] * n
for i in range(q):
  a_n = int(input())
  ans[a_n - 1] += 1
for j in ans:
  if j > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 6596
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <ll>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(ll i=0;i<n;i++)
#define pb      push_back
const ll mod=1e9+7;
void fast();
int main()
{
    fast();
    int n,m,z=0;
    cin>>n>>m;
    vector<int>v(n+1,-1);   
    loop(m){
        int x,y;
        cin>>x>>y;
        if(y==0&&x==1&&n>1)
            z=-1;
        if(v[x]==-1||v[x]==y)
            v[x]=y;
        else
            z=-1;
    }
    if(z==-1)
        cout<<z;
    else{
        if(v[1]==-1&&n==1)
            v[1]=0;
        else if(v[1]==-1)
            v[1]=1;
        for(int i=1;i<=n;i++){
            cout<<max(v[i],0);
        }
    }
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 256
// ITP10_A
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    double ans,x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    ans=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3260
import sys
a, b, c = map(int, input().split())
if c == a + b:
    print('No')
    sys.exit()
if c > a + b:
    if a ** 2 + b ** 2 + c ** 2 - 2 * b * c - 2 * a * b - 2 * a * c > 0:
        print('Yes')
    else:
        print('No')
if c < a + b:
    print('No')

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


using ll = long long;
const int Mod = 1e9+7;
const int MaxN = 1e5+10;
ll fac[MaxN];
int N, K;
vector<int> A;


void exgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0) {x = 1, y = 0; return;}
    exgcd(b, a % b, y, x);
    y -= a / b * x;
}


ll invmod(ll a, ll m) {
    ll x, y;
    exgcd(a, m, x, y);
    return (x % m + m) % m;
}


ll binomial(int n, int m)
{
    ll ans = fac[n] * invmod(fac[m], Mod) % Mod * invmod(fac[n - m], Mod) % Mod;
    return ans;
}


void solve()
{
    fac[0] = 1;
    for (int i = 1; i <= N; i++) fac[i] = fac[i - 1] * i % Mod;

    sort(A.begin(), A.end());
    ll ans = 0;
    for (int i = 0; i <= N - K; i++) {        
        ans = (ans + A[i] * binomial(N - i - 1, K - 1) % Mod + Mod) % Mod;
    }
    ans = (Mod - ans) % Mod;
    reverse(A.begin(), A.end());
    for (int i = 0; i <= N - K; i++) {        
        ans = (ans + A[i] * binomial(N - i - 1, K - 1) % Mod + Mod) % Mod;
    }
    cout << ans << endl;
}


int main()
{
    cin >> N >> K;
    A.resize(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    solve();
    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
class Main
{
public static void main (String[] args)
{
Scanner sc =new Scanner(System.in);
String s= sc.next();
for(int i=0;i<3;i++)
System.out.print(s.charAt(i));
System.out.print('8');
for(int i=4;i<10;i++)
System.out.print(s.charAt(i));
}
}

Measured memory_bytes: 21844
let head str = str.[0]

let tail str =
    if String.length str = 1 then
        ""
    else
        String.sub str 1 (String.length str - 1)

let rec play a b c turn =
    match turn with
    | 'a' when a <> "" -> 
        play (tail a) b c (head a)
    | 'b' when b <> "" ->
        play a (tail b) c (head b)
    | 'c' when c <> "" ->
        play a b (tail c) (head c)
    | x ->
        x

let () =
    let a = read_line () in
    let b = read_line () in
    let c = read_line () in
    play a b c 'a'
    |> Char.uppercase
    |> print_char;
    print_newline ()


Measured memory_bytes: 384
#include <stdio.h>
#define large 1000000

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);

    int list[large]={};
    for(int i=1;i<large;i++)
    {
        if(a*i%b==c){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    int acc = 0;
    for (int i = 0; i < (int) S.size(); i++) {
        acc += S[i] - '0';
    }
    if (acc % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>
#include <iostream>
#include <vector>
#include <time.h>
#include <queue>
#include <utility>

#define INF (-1)


int solve( ) {

	using namespace std;

	int N, M, L, K, A, H;
	cin >> N >> M >> L >> K >> A >> H;
	if( !(N|M|L|K|A|H) ) return 1;
	vector< vector< int > > root( N, vector< int >( N, INF ) );
	vector< vector< int > > graph( N, vector< int >( M + 1, INF ) );
	vector< vector< int > > in( N, vector< int >( M+1, 0 ) );
	vector< int > fr( N, 0 );

	//冷凍可能な都市
	for( int i = 0; i < L; i++ ) {
		int j;
		cin >> j;
		fr[j] = 1;
	}
	//道の情報
	for( int i = 0; i < K; i++ ) {
		int x, y, t;
		cin >> x >> y >> t;
		root[x][y] = t;
		root[y][x] = t;
	}

	//ダイクストラ？
	//初期化
	for( int i = 0; i <= M; i++ ) {
		graph[A][i] = 0;
	}
	//pair<町、残り時間>
	queue< pair<int,int> > q;
	q.push( pair<int,int>(A,M) );
	in[A][M] = 1;

	while( !q.empty() ) {
		pair< int, int > p = q.front();
		q.pop();
		if( p.first == H ) continue;
		
		in[p.first][p.second] = 0;
		for( int i = 0; i < N; i++ ) {
			if( root[p.first][i] < 0 ) continue;
			int cost = graph[p.first][p.second] + root[p.first][i];
			int rest = p.second - root[p.first][i];
			if( rest < 0 ) continue;
			//j分間冷凍する
			for(int j = 0;rest+j<= M; j++ ){
				if( j > 0 && fr[i] == 0 ) break;
				if( graph[i][rest+j] == INF || graph[i][rest+j] > cost+j ) {
					graph[i][rest+j] = cost+j;
					if( in[i][rest+j] == 0 ) {
						q.push( pair<int,int>( i, rest+j) );
						in[i][rest+j] = 1;
					}
				}
			}
		}
	}

	int mincost = -1;
	for( int i = 0; i <= M; i++ ) {
		if( graph[H][i] != -1 ) {
			if( mincost == -1 || ( mincost >= 0 && mincost > graph[H][i] ) ) {
				mincost = graph[H][i];	
			}
		}
	}
	if( mincost == -1 ) {
		cout << "Help!" << endl;
	} else {
		cout << mincost << endl;
	}

	return 0;
}

int main(void){

	while( true ) {
		if( solve() ) break;
	}

	return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int L, R;
	cin >> L >> R;

	ll kotae = 2020;
	int ki = 2020;
	for (int i = L; i < R && ki; i++) {
		int kj = 2020;
		for (int j = i + 1; j <= R && kj; j++) {
			ll kari = (ll)i * j % 2019;
			kotae = min(kotae, kari);
			kj--;
		}
		ki--;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;
multiset < int > s;
int main()
{
    int n, k, price, sum;
    cin >> n;
    cin >> k;
    sum = 0;
    for ( int i = 0; i < n; i++){
        cin >> price;
        s.insert(price);
    }
    for ( int i = 0; i < k; i++) {
        sum += *s.begin();
        s.erase(s.begin());
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int hito[] = new int[N];
		int min = 0;
		int max = 0;

		for(int i=0; i < N; i++){
			hito[i] = scan.nextInt();
		}

		Arrays.sort(hito);
		min = hito[0];
		max = hito[N - 1];
		
		int minsum = 0;

		for(int i = min ; i <= max ; i++){
			int sum = 0;
			int P = i;
			for(int j=0; j < N; j++){
				sum = sum + (int)(Math.pow(hito[j] - P, 2));
			}
			if (i == min || sum < minsum) {
				minsum = sum;
			}
		}
		System.out.println(minsum);

	}
}

Measured memory_bytes: 21972
s1=list(map(int, input().split()))
s2=list(map(int, input().split()))
s3=list(map(int, input().split()))
n = int(input())
A=set()
for i in range(n):
	s=int(input())
	A.add(s)
c=[0]*9
for i in range(3):
	if s1[i] in A:
		c[i]+=1

for i in range(3):
	if s2[i] in A:
		c[i+3]+=1

for i in range(3):
	if s3[i] in A:
		c[i+6]+=1
p=0
#naname
if c[0]+c[4]+c[8]==3:
	print('Yes')
	p+=1
if p==0 and c[2]+c[4]+c[6]==3:
	print('Yes')
	p+=1

#yoko
if p==0 and c[0]+c[1]+c[2]==3:
	print('Yes')
	p+=1
if p==0 and c[3]+c[4]+c[5]==3:
	print('Yes')
	p+=1
if p==0 and c[6]+c[7]+c[8]==3:
	print('Yes')
	p+=1
#tate
for i in range(3):
	if p==0 and c[i]+c[3+i]+c[6+i]==3:
		print('Yes')
		p+=1

if p==0:
	print('No')


Measured memory_bytes: 3064
# include <bits/stdc++.h>
# define rr register
# define int long long
const int N=1000010,INF=0x3f3f3f3f;
int X,Y,A,B,C;
int a[N],b[N],c[N];
int d[N],cnt;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
inline bool cmp(int Flamire,int AKIOI){
	return Flamire>AKIOI;
}
signed main(void){
	X=read(),Y=read(),A=read(),B=read(),C=read();
	for(rr int i=1;i<=A;++i){
		a[i]=read();
	}
	for(rr int i=1;i<=B;++i){
		b[i]=read();
	}
	for(rr int i=1;i<=C;++i){
		c[i]=read();
	}
	std::sort(a+1,a+1+A);
	std::sort(b+1,b+1+B);
	std::sort(c+1,c+1+C,cmp);
	for(rr int i=A-X+1;i<=A;++i){
		d[++cnt]=a[i];
	}
	for(rr int i=B-Y+1;i<=B;++i){
		d[++cnt]=b[i];
	}
	std::sort(d+1,d+1+cnt);
	int pt=1;
	for(rr int i=1;i<=cnt;++i){
		if(pt>C){
			break;
		}
		if(c[pt]<d[i]){
			break;
		}
		++pt;
	}
	int ans=0;
	for(rr int i=1;i<=pt-1;++i){
		ans+=c[i];
	}
	for(rr int i=pt;i<=cnt;++i){
		ans+=d[i];
	}
	std::cout<<ans;
	return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll curr = 100;
    ll x;
    ll tme = 0;
    cin >> x;
    while(curr < x) {
        curr += curr / 100ll;
        tme ++;
    }
    cout << tme << endl;

    return 0;
}



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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> l(n);
    REP(i,n)cin >> l.at(i);
    sort(all(l));
    // REP(i,n)cout << l.at(i) << " ";
    // cout << endl;

    ll ans = 0;
    REP(i,n) {
        FOR(j,i+1,n) {
            // abs(b-c) < a < b+c
            auto iter1 = lower_bound(l.begin(), l.end(), abs(l.at(i)-l.at(j))+1);
            auto iter2 = lower_bound(l.begin(), l.end(), l.at(i)+l.at(j));
            // cout << l.at(i) << " " << l.at(j) << " : ";
            // cout << abs(l.at(i)-l.at(j))+1 << " " << l.at(i)+l.at(j) << " = ";
            // cout << distance(l.begin(),iter1) << " " << distance(l.begin(),iter2) << endl;
            // cout << max((ll)distance(l.begin(), iter1),(ll)j) << " " << distance(l.begin(),iter2)-1 << endl;
            ans += max((ll)distance(l.begin(),iter2)-1 - max((ll)distance(l.begin(), iter1),(ll)j),(ll)0);
            // if( distance(l.begin(),iter1)+1 < l.at(i) && l.at(i) < distance(l.begin(),iter2) )ans--;
            // if( distance(l.begin(),iter1)+1 < l.at(j) && l.at(j) < distance(l.begin(),iter2) )ans--;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
s=input()
t=input()
for i in range(len(t)-1,len(s))[::-1]:
    if s[i]==t[-1] or s[i]=="?":
        if all(s[i-j]==t[-1-j] or s[i-j]=="?" for j in range(len(t))):
            s=s.replace("?","a")
            print(s[:i-len(t)+1]+t+s[i+1:])
            exit()
print("UNRESTORABLE")

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void myout(Object text){System.out.println(text);}
	public static String getStr(){return sc.next();}
	public static int getInt(){return sc.nextInt();}
	public static Long getLong(){return sc.nextLong();}
	public static boolean isNext(){return sc.hasNext();}
	public static void main(String[] args){
		//String tmp = getStr();
		//int tmp = getInt();
		//Long tmp = getLong();
      int mod = 1000000007;
      int xLen = getInt();
      int yLen = getInt();
      Long output = new Long(0);
      Long[] xList = new Long[xLen];
      Long[] yList = new Long[yLen];
      Long xSum = new Long(0);
      Long ySum = new Long(0);
      
      for(int i = 0; i < xLen; i++){
        xList[i] = getLong();
      }
      for(int i = 0; i < yLen; i++){
        yList[i] = getLong();
      }
      for(int i = 1; i <= xLen; i++){
        xSum = (xSum + ((i - 1) * xList[i - 1]) - ((xLen - i) * xList[i - 1])) % mod;
        //myout(xSum);
      }
      for(int i = 1; i <= yLen; i++){
        ySum = (ySum + ((i - 1) * yList[i - 1]) - ((yLen - i) * yList[i - 1])) % mod;
      }
      
  //myout(ySum);
      myout((xSum * ySum) % mod);
	}
}


Measured memory_bytes: 97464
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
vector<int> v;
int j[50];
signed main(){
	int n,c,ans=0;
	cin>>n;
	f(i,n){
		cin>>c;
		v.push_back(c);
	}
	sort(v.begin(),v.end());
	j[0]=1;
	for(int i=1;i<31;i++)j[i]=j[i-1]*2;
	for(int i=n-1;i>=1;i--){
		f(k,31){
			if(j[k]>v[i]){
				if(binary_search(v.begin(),v.begin()+i,j[k]-v[i])){
					ans++;
					auto Itr=upper_bound(v.begin(),v.begin()+i,j[k]-v[i])-1;
					v.erase(v.begin()+(Itr-v.begin()));
					i--;
				}
				break;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long 
#define re register
using namespace std;
const int maxn=2e5+10;
int n;
deque<int> que;
ll f[maxn];
ll c;
ll h[maxn];
double calc(int a,int b){
	return (double) (f[a]+h[a]*h[a]-f[b]-h[b]*h[b])/(2*h[a]-2*h[b]);
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>c;
	for(re int i=1;i<=n;i++){
		cin>>h[i];
	}
	que.push_front(1);
	for(re int i=2;i<=n;i++){
		while(que.size()>1 && calc(que[0],que[1])<=h[i]){
			que.pop_front();
		}
		f[i]=f[que[0]]+(h[i]-h[que[0]])*(h[i]-h[que[0]])+c;
		while(calc(que.back(),que[que.size()-2])>calc(i,que.back())) que.pop_back();
		que.push_back(i);
	}
	cout<<f[n]<<endl;
	return 0;
} 

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
using ordered_set = tree<key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
#define F first
#define S second
#define T second.first
//#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(v) v.begin(),v.end()
#define OO 0x3f3f3f3fLL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll,pair<ll,ll>> piii;
const int N = 1e7+5, M= 20, mod = 1000000000;
const double EPS = 1e-10;


ll A[N];
void sieve(ll n){
    for (ll i = 1; i <= n; ++i)
     for (ll j = i; j <= n; j += i)
      ++A[j];
}

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ll n;
    cin>>n;
    sieve(n);
    ll ans = 0;
    for(ll i=1; i<=n; i++){
        ans+= A[i]*i;
    }
    cout<<ans;
}


Measured memory_bytes: 81696
#include <bits/stdc++.h>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    int N = 0;
    cin >> N;
    vector<int> A(N);
    long long sum = 0;
    long result = 0;
    long m = 1000000007;
    for (int i = 0 ; i < N; i++) {
        std::cin >> A[i];
        sum += A[i];
        sum %= m;
    }

    for (int j = 0 ; j < N; j++) {
        sum -= A[j];
        if (sum < 0) sum += m;

        result += A[j] * sum; 
        result %= m;
    }

    cout << result << endl;
}

Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int dx[] = { -1, 1, 0, 0  };
int dy[] = {  0, 0, 1, -1 };
vector< vector<char> > maze;

int h, w;
int bfs() {
  vector<vector<int>> dist(h, vector<int>(w, -1));
  dist[0][0] = 0;
  queue<pair<int, int>> q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    auto cur = q.front(); q.pop();
    int x = cur.first, y = cur.second;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || ny < 0 || nx >= w || ny >= h) { continue; }
      if (dist[ny][nx] != -1) { continue; }
      if (maze[ny][nx] == '#') { continue; }
      dist[ny][nx] = dist[y][x] + 1;
      q.push(make_pair(nx, ny));
    }
  }
  return dist[h-1][w-1];
}

int main() {
  cin >> h >> w;
  maze.assign(h, vector<char>(w, 0));

  int cnt_black = 0;
  for (int y = 0; y < h; y++) {
    string t; cin >> t;
    for (int x = 0; x < t.size(); x++) {
      maze[y][x] = t[x];
      if (t[x] == '#') { cnt_black++; }
    }
  }

  int dist = bfs();

  if (dist == -1) {
    cout << -1 << endl;
  } else {
    cout << h*w-(dist + 1)-cnt_black << endl;
  }
  return 0;
}

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

int main() {
	int M, K;

	cin >> M >> K;

	int x = 1;
	for( int i = 0; i < M; i++ ) {
		x *= 2;
	}
	string ans = "-1";
	if( K >= x || M == 0 && K != 0 || M == 1 && K != 0 ) {
	}
	else {
		if( M == 0 ) {
			ans = "0 0";
		}
		else if( M == 1 ) {
			ans = "0 0 1 1";
		}
		else {
			string a;
			for( int i = 0; i < x; i++ ) {
				if( i == K ) {
					continue;
				}
				a += to_string( i ) + " ";
			}
			string b = " ";
			for( int i = x - 1; i >= 0; i-- ) {
				if( i == K ) {
					continue;
				}
				b += to_string( i ) + " ";
			}
			string sk = to_string( K );
			ans = a + sk + b + sk;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using LL = long long;

struct LCA {
    int n, log2_n;
    vector<int> depth;
    vector<vector<int>> par;

    void dfs(const vector<vector<int>>& G, int v, int p, int d) {
        depth[v] = d;
        par[0][v] = p;
        for (auto to : G[v]) {
            if (to != p) dfs(G, to, v, d+1);
        }
    }

    LCA(const vector<vector<int>>& G, int root=0) :
        n(G.size()), log2_n(log2(n)), depth(n),
        par(log2_n+1, vector<int>(n,-1)) {

            dfs(G, root, -1, 0);
            for (int k = 0; k < log2_n; ++k) {
                for (int v = 0; v < n; ++v) {
                    if (par[k][v] != -1) {
                        par[k+1][v] = par[k][par[k][v]];
                    }
                }
            }
        }

    int query(int u, int v) {
        if (depth[u] > depth[v]) swap(u, v);

        // align the depth of u and v
        for (int k = 0; k <= log2_n; ++k) {
            if ((depth[v] - depth[u]) >> k & 1) {
                v = par[k][v];
            }
        }
        if (u == v) return u;

        // go back until u and v's parents do not match
        for (int k = log2_n; k >= 0; --k) {
            if (par[k][u] != par[k][v]) {
                u = par[k][u];
                v = par[k][v];
            }
        }
        return par[0][u];
    }
};

void dfs(const vector<vector<int>>& G, vector<int>& par, int v, int p) {
    par[v] = p;
    for (auto u : G[v]) {
        if (u == p) continue;
        dfs(G, par, u, v);
    }
}


int main()
{
    int n; cin >> n;
    vector<vector<int>> G(n);
    for (int i = 0; i < n-1; ++i) {
        int a,b; cin >> a >> b; --a,--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int m; cin >> m;
    vector<int> u(m), v(m);
    for (int i = 0; i < m; ++i) {
        cin >> u[i] >> v[i];
        --u[i], --v[i];
    }

    vector<int> par(n);
        // par[i] := 頂点0を根とする根つき木における,
        //           頂点i の親
    dfs(G, par, 0, -1);

    LCA lca(G);

    vector<LL> cover(m);
        // cover[i] := u[i],v[i] がカバーする辺の集合
    for (int i = 0; i < m; ++i) {
        int t = lca.query(u[i], v[i]);
        int U = u[i], V = v[i];
        while (U != t) {
            cover[i] |= 1LL<<U;
            U = par[U];
        }
        while (V != t) {
            cover[i] |= 1LL<<V;
            V = par[V];
        }
    }

    LL ans = 0;

    for (int s = 0; s < 1<<m; ++s) {
        LL used = 0;
            // used := u[i],v[i] (i in s) がカバーする辺の集合
        for (int i = 0; i < m; ++i) if (s & 1<<i) {
            used |= cover[i];
        }

        if (__builtin_popcountll(s) & 1) {
            ans -= 1LL<<(n-1-__builtin_popcountll(used));
        } else {
            ans += 1LL<<(n-1-__builtin_popcountll(used));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);

    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
        if (i != 0 && h[i] > 0) {
            swap(x[0], x[i]);
            swap(y[0], y[i]);
            swap(h[0], h[i]);
        }
    }


    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            int He = h[0] + abs(x[0]-cx) + abs(y[0]-cy);
            bool f = true;

            for (int i = 1; i < N; ++i) {
                if (h[i] == 0) {
                    if (He - abs(x[i]-cx) - abs(y[i]-cy) > 0) {
                        f = false;
                        break;
                    }
                } else if (He != h[i] + abs(x[i]-cx) + abs(y[i]-cy)) {
                    f = false; 
                    break;
                }
            }

            if (f) {
                cout << cx << " " << cy << " " << He;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String ans = "";
		for(int i = 0; i < 3; i++) {
			String s = sc.next();
			ans += s.charAt(i);
		}
		System.out.println(ans);
	}

}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
//最初の負の数が奇数個の時、操作により負の数を一つだけにできる
//最初の負の数が偶数この時、全て正にできる

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A[i];
  }
  int c = 0;//負の数
  rep(i,N){
    if(A[i] < 0) c++;
  }
  ll ans = 0;
  ll sum = 0;
  rep(i,N){
    sum += abs(A[i]);
  }

  if(c%2 == 1){
    //最も絶対値の小さいものを負にする
    ll m = 5000000000000;
    rep(i,N){
      m = min(m,abs(A[i]));
    }
    ans = sum - 2*m;
  }
  else ans = sum;
  cout << ans << endl;
}

Measured memory_bytes: 1024