akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <map>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 100005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;

int n,m;
int a[maxn];
char s[maxn];

int main()
{
    int a,b,c,d,e,f;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    int ans1,ans2;
    double rate=-1;
    for(int i=0;100*a*i<=f;i++)
    for(int j=0;100*a*i+100*b*j<=f;j++)
    {
        int sum1=100*a*i+100*b*j;
        if(sum1==0) continue;
        int res=f-sum1;
        for(int ii=0;ii*c<=res;ii++)
        for(int jj=0;ii*c+jj*d<=res;jj++)
        {
            int sum2=ii*c+jj*d;
            if(sum1/100*e>=sum2)
            {
                if(sum2*1.0/sum1>=rate)
                {
                    rate=sum2*1.0/sum1;
                    ans1=sum1;
                    ans2=sum2;
                }
            }
        }
    }
    printf("%d %d\n",ans1+ans2,ans2);
    return 0;
}


Measured memory_bytes: 256
N = [i for i in input()]
if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
  print('hon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9124
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    int n;
    cin>>n;
    cout<<(n-2)*180<<endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N+1);
  for(int i=1;i<N+1;i++){
    cin >> a[i];
  } 
  int b=1;
  
  for(int i=1;i<N+1;i++){
    b=a[b];
   
    if(b==2){
      cout << i << endl;
    
      return 0;
      
    }  
  }
  cout << -1 << endl;
}  
 


Measured memory_bytes: 640
from math import factorial as fc

S = int(input())

result = 0
for sep in range(S // 3):
    s = S - 3 * (sep + 1)
    result += fc(s + sep) // (fc(s) * fc(sep))
    result %= 10**9 + 7
print(result % (10**9 + 7))


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

int main(){
	int N;
	cin>>N;
	double tmp;
	string tmps;
	double ans=0;
	for(int i=0;i<N;++i){
		cin>>tmp>>tmps;
		if(tmps=="JPY"){
			ans+=tmp;
		}
		else{
			ans+=tmp*380000;
		}
	}
	cout<<fixed;
	cout<<setprecision(5)<<ans<<endl;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
p = float("inf")

for i in range(1, 2 ** n):
    s = [0] * m
    count = 0
    ps = 0
    for j in range(n):
        if (i >> j) & 1:
            ps += a[j][0]
            for k in range(m):
                s[k] += a[j][k + 1]

    for k in range(m):
        if s[k] >= x:
            count += 1

    if count == m:
        p = min(ps, p)

if p == float('inf'):
    print(-1)
else:
    print(p)

Measured memory_bytes: 9228
X,Y,A,B,C=map(int,input().split())
p=sorted([int(p) for p in input().split()])[-X:]
q=sorted([int(q) for q in input().split()])[-Y:]
r=[int(r) for r in input().split()]
lst=sorted(p+q+r)
print(sum(lst[-(X+Y):]))


Measured memory_bytes: 22416
import Control.Monad
import Control.Applicative
import Data.List


main :: IO()
main = do
  lst <- replicateM 5 readLn :: IO [Int]
  let list = (reverse . sortOn fst . map (\x -> ((10 - x `mod` 10) `mod` 10, x))) lst
  let (x:xs) = list
  print (snd x + (foldl (\acc -> \(a, b) -> acc + a + b) 0 xs))


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> S(N + 1);
  vector<i64> T(M + 1);
  rep(i,1,N + 1) cin >> S[i];
  rep(j,1,M + 1) cin >> T[j];

  vector<vector<i64>> dp(N + 1, vector<i64>(M + 1));
  vector<vector<i64>> sum(N + 1, vector<i64>(M + 1));

  const i64 mod = 1e9 + 7;
  sum[0][0] = 0;
  for(int i = 1;i <= N;i++) sum[i][0] = 0;
  for(int i = 1;i <= M;i++) sum[0][i] = 0;
  for(int i = 1;i <= N;i++) {
    for(int j = 1;j <= M;j++) {
      if(S[i] == T[j]) {
        dp[i][j] = sum[i - 1][j - 1] + 1;
        dp[i][j] %= mod;
      }
      else dp[i][j] = 0;
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + dp[i][j] + mod;
      sum[i][j] = sum[i][j] % mod;
    }
  }

  cout << (sum[N][M] + 1) % mod << endl;
}


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

int main() {
  int X, N;
  cin >> X >> N;
  if (N == 0) {
    cout << X << endl;
    return 0;
  }
  set<int> p;
  for (int i = 0; i < N; i++) {
    int e;
    cin >> e;
    p.insert(e);
  }
  for (int i = 0; i < 300; i++) {
    if (!p.count(X-i)) {
      cout << X-i << endl;
      return 0;
    }
    if (!p.count(X+i)) {
      cout << X+i << endl;
      return 0;
    }
  }
}

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

using namespace std;
long long n,a,b;
long long v[100001];
int exp(long long x){
    long long y=0;
    long long vn[100001];
    for (int i=0;i<100001;i++){
        vn[i]=v[i]-b*x;
        if (vn[i]>0) y+=(vn[i]+a-b-1)/(a-b);
            }
    if (y<=x) return 1;
    else return 0;
    
}

int main(){
  cin>>n>>a>>b;
  for (int i=0;i<n;i++){
    int tem;
    scanf("%d",&tem);
    v[i]=tem;
  }
    long long mi=0;
    long long ma=1000000001;
    while (ma-mi>1){
        long long c=(mi+ma)/2;
        if (exp(c)==1) ma=c;
        else mi=c;
            }
    cout<<ma;
    return 0;
}


Measured memory_bytes: 1024
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

int main(){
	vector <int> s;
	int N;
	cin>>N;
	FOR(i,0,N){
		int tmp;
		cin>>tmp;
		s.push_back(tmp);
	}
	sort(ALL(s));

	int result=0;
	FOR(i,0,N){
		result+=s[i];
	}

	if(result%10==0){
		FOR(i,0,N){
			if(s[i]%10){
				result-=s[i];
				break;
			}
		}
		if(result%10==0){
			result=0;
		}
	}

	cout<<result<<endl;

}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  if (N % 1000 == 0)
    cout << '0' << endl;
  else
    cout << 1000-N%1000 << endl;
}


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

bool isPalindrome(string s){
    string t = s;
    reverse(t.begin(), t.end());
    return (s == t);
}

int main(){
    int len;
    bool ans = true;
    string s,s2;
    cin >> s;
    if(!isPalindrome(s))  ans = false;
    if(!isPalindrome(s.substr(0,(s.size()-1)/2))) ans = false;

    cout << (ans ? "Yes": "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main(){
    int q; cin >> q;
    auto pt = prime_table(100005);
    vector<int> cnt(100005);
    for(int i = 3; i <= 100000; i += 2) if((pt[i]) && (pt[(i+1)/2])) cnt[i]++;
    for(int i = 3; i <= 100000; i++) cnt[i] += cnt[i-1];
    rep(i,q){
        int l,r; cin >> l >> r;
        cout << cnt[r] - cnt[l-1] << endl;
    }
}


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

int main() {
	string S;
	int Q, T, F;
	char C;
	cin >> S >> Q;
	int state = 0;
	while (Q--) {
		cin >> T;
		if (T == 1){
			state = 1 - state;
		}
		else {
			cin >> F >> C;
			if (F==1) {
				if (state==0) S.insert(S.begin(), C);
				else S.insert(S.end(), C);
			}
			else {
				if (state==1) S.insert(S.begin(), C);
				else S.insert(S.end(), C);
			}
		}
	}
	
	if (state == 1) {
		reverse(S.begin(), S.end());
		
	}
	cout << S;

}

Measured memory_bytes: 1020
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,a;
  vector<int>v(1,0);
  cin >> n;
  while(n--){
    cin >> a;
    v.push_back(a);
  }
  for(int j=1;j<v.size();j++){
    int key = v[j],i = j - 1;
    while(i > 0 && v[i] > key){
      v[i+1] = v[i];
      i--;
    }
    v[i+1] = key;
    for(int j=1;j<v.size();j++){
      cout << (j==1?"":" ") << v[j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3164
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	c=0;
	if(a>b){
		c=a-b;
		printf("%d\n",c);
	}
	else if(a<b){
		c=b-a;
		printf("%d\n",c);
	}
	else{
		printf("0\n");
	}
	return 0;
}


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

int main() {
    int city, road, a, b;
    cin >> city >> road;

    vector<int> cities(city);

    for (int i = 0; i < road; i++) {
        cin >> a >> b;
        cities.at(a - 1) += 1;
        cities.at(b - 1) += 1;
    }
    for (int i = 0; i < city; i++) {
        cout << cities.at(i) << endl;
    }
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            int i = 0;
            while (true)
            {
                string s = Console.ReadLine();
                int x = int.Parse(s);
                if (x == 0)
                {
                    break;
                }
                Console.WriteLine("Case " + (i + 1) + ": " + x);
                i++;
            }
        }
    }
}

Measured memory_bytes: 9272
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 1e6+1;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;

  if(n < 0){// n < 0 にも対応
    n *= -1;
    x = inv[x];
  }

  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n /= 2;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }

  return ret;
}

int n; string s;

bool check(int len){
  map<string,int> C;
  for(int l2 = 0; l2+len <= n; l2++) {
    string t = s.substr(l2,len);
    if(!C.count(t)){
      C[t] = l2;
    }
    else{
      int l1 = C[t];
      if(l1+len <= l2) return true;
    }
  }
  return false;
}

int main(){
  cin >> n >> s;
  int ok = 0, ng = n/2+1;
  while (abs(ng-ok)>1){
    int mid = (ok+ng)/2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}


Measured memory_bytes: 6668
// WA確認用の提出

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();

		List<Long> alist = new ArrayList<>();

		for (int i = 0; i < N; i++) {
			alist.add(scanner.nextLong());
		}

		if (alist.get(0) != 0) {
			System.out.println("-1");
			return;
		}

		long count = 0;

		for(int i = 0; i < N-1; i++) {
			long a_i = alist.get(i);
			long a_i_1 = alist.get(i+1);
			if (a_i_1 == a_i + 1) { // 1, 2
				count = count + 1;
			} else if (a_i_1 - a_i > 1) { // 1, 3
				System.out.println("-1");
				return;
			} else {
				count = count + a_i_1;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 87688
let n = Int(readLine()!)!
var dArray = [[Int]]()
for _ in 0..<n {
  dArray.append(readLine()!.split(separator: " ").map {Int($0)!})
}

var sameCount = 0
var answer = "No"
var i = 0

while i < dArray.count {
  if dArray[i][0] == dArray[i][1] {
    sameCount += 1
  } else {
    sameCount = 0
  }
  i += 1
  if sameCount == 3 {
    answer = "Yes"
    break
  }
}

print(answer)

Measured memory_bytes: 8264
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll h,w,a,b;
  bool f0,f1,is_z;
  cin >> h >> w >> a >> b;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      f0=f1=false;
      if(j>=a){
        f0=true;
      }
      if(i>=b){
        f1=true;
      }
      is_z = !(f0^f1);
      if(is_z){
        cout << "0";
      }else{
        cout << "1";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
	int an = N%K;
      if(an ==0){
    System.out.println("0");
    }else{
    System.out.println("1");      
    }
}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int n;
string s[100], ta[100] = {};

int main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (s[j] == s[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		if (i >= 1 && s[i - 1][s[i - 1].size() - 1] != s[i][0]) {
			cout << "No" << endl;
			return 0;
		}
		ta[i] = s[i];
	}
	cout << "Yes" << endl;
	return 0;
}

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

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

    int k, x;
    cin >> k >> x;
    for(int i =  x - k + 1; i < x + k; i++) {
        cout << i << " ";
    }
    return 0;
}


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

bool ee(int a,int b)
{
	return(a<b);
}

int main()
{
	int n;
	double s=0;
	cin>>n;
	int v[n];
	for(int i=0;i<n;i++)
		cin>>v[i];
	sort(v,v+n,ee);
	s=s+(v[0]+v[1])/2.0;
	for(int i=2;i<n;i++)
	{
		s=(s+v[i])/2;
	}
	printf("%f",s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i, n) {
    cin >> a.at(i);
    a.at(i) = 1 / a.at(i);
  }
  cout << setprecision(10) << 1 / accumulate(a.begin(), a.end(), 0.0);
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)(n); i++)
#define Loop1(i, n) for(int i = 1; i <= (int)(n); i++)
#define Loopr(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
bool inrange(vi xs, int t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	int n; cin >> n;
	vi a(n * 2); Loop(i, n * 2) cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	int ans = 0;
	Loop(i, n) {
		ans += min(a[i * 2], a[i * 2 + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int a[3][3];
    rep(i,3)rep(j,3)cin>>a[i][j];
    int x[3];
    for(x[0]=0;x[0]<=100;++x[0])for(x[1]=0;x[1]<=100;++x[1])for(x[2]=0;x[2]<=100;++x[2]){
        int y[3];
        rep(i,3)y[i]=a[0][i]-x[0];
        bool ok=true;
        rep(i,3)rep(j,3)ok&=(x[i]+y[j]==a[i][j]);
        if(ok){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int m,k;
    cin>>m>>k;
    int val=(1LL<<m)-1;
    if(k>val)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    if(k==0)
    {
        f(i,0,val)
        {
            cout<<i<<" ";
            if(i==val)cout<<i;
            else cout<<i<<" ";
        }
        cout<<endl;
        return 0;
    }
    if(m==1)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    f(i,0,val)
    {
        if(i!=k)cout<<i<<" ";
    }
    cout<<k;
    rf(i,val,0)
    {
        if(i!=k)cout<<" "<<i;
    }
    cout<<" "<<k<<endl;
    return 0;

}





































Measured memory_bytes: 3632
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  vector<ll> nums;
  nums.pb(A);
  nums.pb(B);
  nums.pb(C);
  sort(all(nums));
  int maxNum = nums[2];
  rep(i, K) {
    maxNum *= 2;
  }
  cout << (nums[0] + nums[1] + maxNum) << endl;
}


Measured memory_bytes: 256
// 問題URL
// https://atcoder.jp/contests/abc133/tasks/abc133_a

import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        Integer a = Integer.parseInt(scanner.next());
        Integer b = Integer.parseInt(scanner.next());

        int train = n * a;
        if(train < b) {
            System.out.println(train);
        } else {
            System.out.println(b);
        }

    }
}

Measured memory_bytes: 21844
use std::io::{Read, stdin};
use std::str::FromStr;
use std::cmp::max;

fn main() {
    let n: i64 = read();
    let rn: i64 = (n as f64).sqrt().floor() as i64;
    let mut v: Vec<i64> = Vec::new();
    for i in 1..rn+1 {
        if n % i == 0 {
            v.push(i);
            v.push(n / i);
        }
    }
    v.sort();
    let mut ans = 1000;
    for i in 0.. v.len()/2 +1 {
        let u = max(((n / v[i] as i64) as f64).log10().floor() as i64 ,
                    (v[i] as f64).log10().floor() as i64) + 1;
        if ans > u {ans = u;}
    }

    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4604
n = int(input())
dp = [0 for _ in range(10**5)]
a = list(map(int, input().split()))
Sum = sum(a)
for i in a:
  dp[i-1] += 1
  
q = int(input())
for i in range(q):
  sa, sb = map(int, input().split())
  x = dp[sa-1]
  dp[sa-1] = 0
  Sum -= x*sa
  dp[sb-1] += x
  Sum += x*sb
  print(Sum)

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

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    for(int i = 0; i < N; i++) {
        cin >> s[i];
    }
    
    int in = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 1; j < s[i].size(); j++) {
            if(s[i][j - 1] == 'A') {
                if(s[i][j] == 'B') {
                    in++;
                }
            }
        }
    }
    
    int XA = 0, BA = 0, BX = 0;
    for(int i = 0; i < N; i++) {
        int M = s[i].size();
        if(s[i][0] == 'B') BX++;
        if(s[i][M - 1] == 'A') XA++;
        if(s[i][0] == 'B' && s[i][M - 1] == 'A') {
            BA++;
            BX--;
            XA--;
        }
    }
    
    int si = 0, de = 0;
    if(BA != 0) {
        si = BA - 1;
        if(BX != 0) {
            si++;
            BX--;
        }
        if(XA != 0) {
            si++;
            XA--;
        }
    }
    de = min(BX, XA);
        
    cout << in + si + de << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,s.size()){
        s[i]=s[i]+n;
        while(1){
            if(s[i]>90){
                s[i]=s[i]-26;
            }
            else{
                break;
            }
        }
    }
    cout<<s<<endl;
}


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

using namespace std;

int main() {
	string S;
	int N, K;
	cin >> N >> K;
	cin >> S;
	char tmp = S[K - 1];
	string tmp2;
	if (tmp == 'A') {
		tmp2 = "a";
	} else if (tmp == 'B') {
		tmp2 = "b";
	} else {
		tmp2 = "c";
	}
	S.replace(K - 1, 1, tmp2);

	cout << S << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll a, b, n, c1, c2, ans = 0;

ll f(ll x) { return floor(a * x / b) - a * floor(x / b); }

ll g(ll x) {
  ll l = 0, r = n + 1;
  rep(i, 100) {
    c1 = (l * 2 + r) / 3;
    c2 = (r * 2 + l) / 3;
    f(c1) < f(c2) ? l = c1 : r = c2;
  }
  return f(l);
}

int main() {
  cin >> a >> b >> n;

  ll l = 0, r = n + 1;
  rep(i, 100) {
    c1 = (l * 2 + r) / 3;
    c2 = (r * 2 + l) / 3;
    g(c1) < g(c2) ? l = c1 : r = c2;
  }
  if (f(0) > f(r)) r = 0;
  else if (f(n) > f(r)) r = n;
  cout <<  f(r) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<iostream>
#include<queue>
using namespace std;

priority_queue<int>QD;
priority_queue<int,vector<int>,greater<int> >QU;

typedef long long ll;
int n;
int a[310000];
ll pmx[310000],qmn[310000],smx,smn,ans=-(1ll<<60);

int main(){
	scanf("%d",&n);
	for(int i=1;i<=3*n;i++){
		scanf("%d",&a[i]);
	}for(int i=1;i<=n;i++){
		smx+=a[i];
		QU.push(a[i]);
	}pmx[n]=smx;
	for(int i=n+1;i<=3*n;i++){
		if(a[i]>QU.top()){
			smx-=QU.top();
			QU.pop();
			smx+=a[i];
			QU.push(a[i]);
		}pmx[i]=smx;
	}for(int i=3*n;i>2*n;i--){
		smn+=a[i];
		QD.push(a[i]);
	}qmn[2*n+1]=smn;
	for(int i=2*n;i;i--){
		if(a[i]<QD.top()){
			smn-=QD.top();
			QD.pop();
			smn+=a[i];
			QD.push(a[i]);
		}qmn[i]=smn;
	}for(int i=n;i<=2*n;i++){
		ans=max(ans,pmx[i]-qmn[i+1]);
	}printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m, Q;
  cin >> n >> m >> Q;
  vector<vector<ll>> a(n + 1, vector<ll>(n + 1, 0));
  REP(i, m) {
    ll l, r;
    cin >> l >> r;
    a[l][r]++;
  }
  REP(i, n + 1) {
    REP(j, n) { a[i][j + 1] += a[i][j]; }
  }
  REP(j, n + 1) {
    REP(i, n) { a[i + 1][j] += a[i][j]; }
  }

  // REP(i, n + 1) {
  //   REP(j, n + 1) { cout << a[i][j] << " \n"[j == n]; }
  // }

  while (Q--) {
    ll p, q;
    cin >> p >> q;
    cout << a[n][q] - a[p - 1][q] << endl;
  }
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main{
    public static int minCostDp(int a[],int n){
        int dp[] = new int[n+1];
        dp[1] = 0;
        dp[2] = Math.abs(a[2]-a[1]);
        for(int i=3;i<=n;i++){
            dp[i] = Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]),dp[i-2]+Math.abs(a[i]-a[i-2]));
        }
        return dp[n];
    }
    public static int minCostRecursive(int a[],int n,int i,int j,int minSum){
        if(j==n)
            return minSum+Math.abs(a[j]-a[i]);

        if(j>n)
            return Integer.MAX_VALUE;

        minSum = minSum+Math.abs(a[i]-a[j]);
        i=j;
        int ans1 = minCostRecursive(a,n,i,j+1,minSum);
        int ans2 = minCostRecursive(a,n,i,j+2,minSum);
        return Math.min(ans1,ans2);
    }
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n+1];
        for(int i=1;i<=n;i++){
            a[i] = sc.nextInt();
        }
        System.out.println(minCostDp(a,n));

    }
}

Measured memory_bytes: 49124
import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        int N = nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; ++i) arr[i] = nextInt();
        Arrays.sort(arr);
        int s = 0;
        for(int i : arr) s += i;
        if(s % 10 != 0) {
            writer.println(s);
        } else {
            for(int i = 0; i < arr.length; ++i) {
                if((arr[i] % 10 != 0)) {
                    writer.println((s - arr[i]));
                    return;
                }
            }
            writer.println(0);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("input.txt"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("output.txt");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;

    int ans = 0;
    while((int) N != 0) {
        N /= K;
        ans++;
    }
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>

int N;
double p[3001];

double dp[3001][3001];
double f(int i, int h) {
  if (i == N) return (h == 0? 1.0 : 0.0);
  if (h < 0) return 0.0;
  if (h > N - i) return 0.0;
  if (dp[i][h] > -0.5) return dp[i][h];
  return dp[i][h] = p[i]*f(i + 1, h - 1) + (1 - p[i])*f(i + 1, h);
}

int main() {
  for (int i = 0; i < 3001; ++i)
    for (int j = 0; j < 3001; ++j)
      dp[i][j] = -1;
  std::cin >> N;
  for (int i = 0; i < N; ++i) std::cin >> p[i];

  double total = 0.0;
  for (int h = (1 + N/2); h <= N; ++h)
    total += f(0, h);
  std::cout << std::setprecision(20) << std::fixed;
  std::cout << total << '\n';
}


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

int main() {
  uint64_t a;
  cin >> a;
  char b, c, d;
  char e;
  cin >> b >> e >> c >> d;
  string B;
  string C;
  string D;
  B += b;
  C += c;
  D += d;
  int i = stoi(B);
  int j = stoi(C);
  int k = stoi(D);
  int f = i * 100 + j * 10 + k;
  a *= f;
  a /= 100;
  cout << a << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
int n,m,x;
int a;
int cnt1,cnt2;
int main()
{
  cin>>n>>m>>x;
  for(int i=0;i<m;i++)
  {
    cin>>a;
    if(a<x)
      cnt1++;
    else
      cnt2++;
  }
  cout<<min(cnt1,cnt2)<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] order = new int[N+1];
        int[] satisfaction = new int[N+1];
        int[] combo = new int[N];
        for (int i = 1; i <= N; i++) {
        	order[i] = sc.nextInt();
        }
        for (int i = 1; i <= N; i++) {
        	satisfaction[i] = sc.nextInt();
        }
        for (int i = 1; i < N; i++) {
        	combo[i] = sc.nextInt();
        }
        int total = 0;
        int tmp = 0;
        for (int i = 1; i <= N; i++) {
        	total += satisfaction[order[i]];
        	if (tmp == order[i] - 1) {
        		total += combo[tmp];
        	}
        	tmp = order[i];
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 21972
import itertools
n, m, q = map(int, input().split())
A = itertools.combinations_with_replacement(range(1, m+1), n)
quads = [[int(i) for i in input().split()] for j in range(q)]
max_p = 0
for a in A:
    p = 0
    for quad in quads:
        if a[quad[1] - 1] - a[quad[0] - 1] == quad[2]:
            p += quad[3]
    if max_p < p:
        max_p = p
print(max_p)

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

#define all(p) p.begin(), p.end()
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define ll long long
#define llu unsigned long long
#define ld long double
#define vll vector<long long int>
#define vi vector<int>
#define pii pair <int, int>
#define pll pair <long long int, long long int>
#define vpii vector<pair<int,int> >
#define nl cout<<"\n"
#define sp cout<<" "
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

const  int  INF = 0x7f7f7f7f;

//int ans[200005];
int par1[200005], par2[200005];

int fp1(int i)
{
    while(par1[par1[i]]!=par1[i])
        par1[i]=fp1(par1[i]);
    return par1[i];
}

int fp2(int i)
{
    while(par2[par2[i]]!=par2[i])
        par2[i]=fp2(par2[i]);
    return par2[i];
}

void dsu1(int a, int b)
{
    int pa=fp1(a), pb=fp1(b);
    if(pa==pb) return;

    par1[pa] = min(pa,pb);
    par1[pb] = min(pa,pb);
}

void dsu2(int a, int b)
{
    int pa=fp2(a), pb=fp2(b);
    if(pa==pb) return;

    par2[pa] = min(pa,pb);
    par2[pb] = min(pa,pb);
}

int  main ()
{
	ios_base::sync_with_stdio(false);
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    int n,k,l;
    cin>>n>>k>>l;
    rep(i,1,n) par2[i]=par1[i]=i;

    int x,y;

    rep(i,1,k)
    {
        cin>>x>>y;
        dsu1(x,y);
    }
    //rep(i,1,n) cout<<fp(i),sp;nl;
    rep(i,1,l)
    {
        cin>>x>>y;
        dsu2(x,y);
    }
    map <pii, int> m;
    rep(i,1,n)
    {
        x=fp1(i);
        y=fp2(i);
        m[mp(x,y)]++;
    }
    rep(i,1,n)
    {
        cout<<m[mp(fp1(i),fp2(i))];sp;
    }
    nl;
    return  0;
}


Measured memory_bytes: 13568
MOD = 10**9 + 7

n = int(input())

a = list(map(int,input().split()))

sum = [0 for i in range(n+1)]
dp = [0 for i in range(n+1)]

fac = [1 for i in range(n+1)]
finv = [1 for i in range(n+1)]
inv = [1 for i in range(n+1)]

for i in range(2,n+1):
    fac[i] = fac[i-1]*i%MOD
    inv[i] = MOD - inv[MOD%i]*(MOD // i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

for i in range(1,n+1):
    sum[i] = (sum[i-1]+inv[i]) % MOD
sum[0] = 1
for i in range(1,n+1):
    dp[i] = (sum[i]+sum[n+1-i]-1) % MOD

ans = 0
for i in range(1,n+1):
    ans = (ans + dp[i]*a[i-1])% MOD

print((ans * fac[n]) % MOD)


Measured memory_bytes: 67096
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
//#include <cmath>
//#include <functional>

inline int32_t num_both_open(const std::vector<int32_t>& joison, const std::vector<int32_t>& F) {
    int32_t c = 0;
    for (int32_t i = 0; i < (int32_t)joison.size(); i++) {
        if (joison[i] == 1 && F[i] == 1) c++;
    }
    return c;
}

inline void make_bitarray(int32_t val, std::vector<int32_t>& bitarray) {
    for (int32_t i = 0; i < (int32_t)bitarray.size(); i++) {
        if ((val & 1) == 1) {
            bitarray[i] = 1;
        }
        val = val >> 1;
    }
}

int main(){
    int32_t N;
    std::cin >> N;
    std::vector<std::vector<int32_t>> F(N, std::vector<int32_t>(10,0));
    std::vector<std::vector<int32_t>> P(N, std::vector<int32_t>(11,0));
    for(auto& i : F) {
        for (auto& j : i) {
            std::cin >> j;
        }
    }
    for(auto& i : P) {
        for (auto& j : i) {
            std::cin >> j;
        }
    }

    constexpr int64_t MIN = -1 * (1LL << 60);
    int64_t res = MIN;
    for (int32_t i = 1; i < 1024; i++) {
        std::vector<int32_t> joison_bp(10,0);
        make_bitarray(i, joison_bp);
        int64_t sum = 0;
        for (int32_t j = 0; j < N; j++) {
            int32_t c = num_both_open(joison_bp, F[j]);
            sum += P[j][c];
            //std::cout << "i,j,c,sum = " << i << j << c << sum <<std::endl;
        }
        res = std::max(res, sum);
    }

    std::cout << res;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine()),a[]=new int[n],i,c[]=new int[100001],k;
        long sum=0;
        String s[]=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        {
            k=Integer.parseInt(s[i]);
            c[k]++;
            sum+=k;
        }
        int q=Integer.parseInt(bu.readLine());
        while(q-->0)
        {
            s=bu.readLine().split(" ");
            int l=Integer.parseInt(s[0]),r=Integer.parseInt(s[1]);
            sum-=1l*c[l]*l;
            sum+=1l*c[l]*r;
            c[r]+=c[l];
            c[l]=0;
            sb.append(sum+"\n");
        }
        System.out.print(sb);
    }
}


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

int main(){
    string s,t;
    int a=0;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i)){
            a++;
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 3844
#include <stdio.h>

int abs(int a){ return (a<0)? -a :a ;}

int N;
long long total=0;

int pos[100003]; //1-based
int main(void){
    // Your code here!
    int N;
    scanf("%d",&N);
    
    pos[0] = 0;
    for(int i = 1; i <= N; i++){
        scanf("%d", pos+i);
    }
    pos[N+1] = 0;
    
    for(int i = 0; i <= N ;i++){
        total += abs(pos[i+1]-pos[i]);
    }
    
    for(int i = 1; i <= N; i++){
        long long ret = total;
        
        long long diff = abs(pos[i+1]-pos[i-1]) - ( abs(pos[i]-pos[i-1]) + abs(pos[i+1]-pos[i]) );
        ret += diff;
      
        printf("%lld\n",ret);
    }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,b) for(int i=(a);i<=(b);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define blc boost::lexical_cast<long long>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
const int MOD = 1e9+7;
ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}

ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}

ll mul(ll x, ll y) {ll res=0;x%=MOD; 
while(y){ if(y&1)res=(res+x)%MOD; 
x=(2*x)%MOD;y>>=1;}return res;} 

ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}

ll power(ll x, ll y) {ll res=1; x%=MOD; while(y){if(y&1)res=mul(res,x); y>>=1; x=mul(x,x);} return res;}

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

void solve()
{
    ll n;
  	cin>>n;
    unordered_map<string, ll> mapp;
    while(n--)
    {
      string s;
      cin>>s;
      mapp[s]++;
    }
    cout<<"AC x "<<mapp["AC"]<<endl;
  	cout<<"WA x "<<mapp["WA"]<<endl;
  	cout<<"TLE x "<<mapp["TLE"]<<endl;
  	cout<<"RE x "<<mapp["RE"]<<endl;
}
signed main()
{
    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0; 
}


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

int main(){
  int64_t N;
  cin >> N;
  if(N==0){
    cout << 0 << endl;
  }
  vector<int64_t> A(20000001, 0);
  for(int64_t i=1; i<=20000000; i++){
    if(N%(int64_t)pow(2, i)!=0){
      A.at(i)=1;
      N-=(int64_t)pow(2, i-1)*(int64_t)pow(-1, i-1);
    }
  }
  int64_t P=0;
  for(int64_t i=20000000; i>0; i--){
    if(A.at(i)==1){
      P=1;
      cout << 1;
    }
    else if(P==1){
      cout << 0;
    }
  }
  cout << endl;
}


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

int main(){
    long int N,C,me;
    cin >> N >>C;
    long int x[C];
    int sum=0;

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

    for(int i=0;i<C;i++){
        sum =sum+x[i];
    }

    if(sum%(N+1)==0){
        me=sum/(N+1);
        cout<<me<<endl;
    }
    else{
        me=sum/(N+1)+1;
        cout<<me<<endl;
    }
    
    return 0;

}


Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll l = 0, r = n - 1;
    ll ans = 0;
    while(true) {
        while(l < n && s[l] == 'R') ++l;
        if(l == n) break;
        while(r >= 0 && s[r] == 'W') --r;
        if(r == -1) break;
        if(l >= r) break;
        ++ans;
        ++l;
        --r;
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    int res = 1;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<int> X(3, -1);

    for (int i = 0; i < N; i++) {
        int cnt = 0;
        for (int j = 0; j < 3; j++) {
            if (X[j] == A[i] - 1) {
                cnt++;
            }
        }
        res = (res * cnt) % MOD;
        if (res == 0) break;
        for (int j = 0; j < 3; j++) {
            if (X[j] == A[i] - 1) {
                X[j] = A[i];
                break;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef pair<int, int> P;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};
const int INF = 1001001001;
const int MOD = 1000000007;

int N, W;
vector<P> vec;
vector<vector<int>> dp;

int main() {
  cin >> N >> W;
  vec.resize(N);
  dp.assign(N + 1, vector<int>(W + 1, 0));

  rep(i, N) {
    int v, w;
    cin >> v >> w;
    vec[i] = P(v, w);
  }

  rep(i, N) {
    int v, w;
    tie(v, w) = vec[i];

    rep(j, W + 1) {
      if (j < w) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w] + v);
      }
    }
  }

  printf("%d\n", dp[N][W]);
}



Measured memory_bytes: 6784