akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 2);
    a[0] = a[n + 1] = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
    }
    int sumx = 0;
    for (int i = 1; i < n + 2; i++) {
        sumx += abs(a[i] - a[i - 1]);
    }

    for (int i = 1; i <= n; i++) {
        int toadd = abs(a[i + 1] - a[i - 1]);
        int tosub = abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
        cout << sumx - tosub + toadd << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<iomanip>
#include <cmath>
using namespace std;

using std::cout;
using std::cin;
using std::endl;

int main(void){
  string S;
  int i;
  cin >> S;
  if (S == "SUN"){
   	 i = 7;
  }
  else if(S == "MON"){
   	 i = 6;
  }
  else if(S == "TUE"){
   	 i = 5;
  }
  else if(S == "WED"){
   	 i = 4;
  }
  else if(S == "THU"){
   	 i = 3;
  }
  else if(S == "FRI"){
   	 i = 2;
  }
  else{
    i = 1;
  }
  cout << i;
}
  

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(N == i * j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

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

int main(){
	int N;
	string S;
	cin>>N>>S;
	vector<char> ans(S.size());
	for(int i=0;i<S.size();i++){
		ans.at(i)=S.at(i);
		for(int k=0;k<N;k++){
			ans.at(i)++;
			if(ans.at(i)=='['){
				ans.at(i)='A';
			}
		}
		
	}
	string A;
	for(int i=0;i<S.size();i++){
		A+=ans.at(i);
	}
	cout<<A<<endl;
	
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc120/tasks/abc120_d
from collections import Counter
n, m = map(int, input().split())

brides = []
for _ in range(m):
    a, b = map(int, input().split())
    brides.append((a, b))


class Union:
    def __init__(self, val):
        self.val = val
        self.parent = self
        self.rank = 0
        self.size = 1

    def get_root(self):
        n = self
        while n.parent != n:
            n = n.parent
        return n

    def find_set(self):
        return self.get_root().val

unions = []
for i in range(n):
    unions.append(Union(i))

ans = []
ans.append(n * (n - 1) // 2)

for a, b in brides[::-1]:
    x, y = unions[a - 1], unions[b - 1]
    x_root = x.get_root()
    y_root = y.get_root()
    if x_root.find_set() == y_root.find_set():
        ans.append(ans[-1])
        continue
    ans.append(ans[-1] - x_root.size * y_root.size)
    if x_root.rank == y_root.rank:
        y_root.parent = x_root
        x_root.rank += 1
        size = x_root.size + y_root.size
    elif x_root.rank > y_root.rank:
        y_root.parent = x_root
    else:
        x_root.parent = y_root
    size = x_root.size + y_root.size
    x_root.size = size
    y_root.size = size
ans.pop()
for a in ans[::-1]:
    print(a)

Measured memory_bytes: 83672
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int N, i, j, k, ans = 0;
	scanf("%lld", &N);
	vector<int> L(N);
	for(i = 0; i < N; i++){
		scanf("%lld", &L[i]);
	}
	for(i = 0; i < N; i++){
		for(j = i + 1; j < N; j++){
			for(k = j + 1; k < N; k++){
				if(L[i] == L[j] || L[i] == L[k] || L[j] == L[k]){
					continue;
				}
				if(2 * max({L[i], L[j], L[k]}) < L[i] + L[j] + L[k]){
					ans++;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3792
#include <iostream>


using namespace std;
using ll = long long;
using ull = unsigned long long;
int main()
{
	ull n = 0;
	cin >> n;
	ull count = 0;
	ull money = 100;
	while (1)
	{
		count++;
		money = ull(double(money)*1.01);

		if (money >= n)break;
	}

	cout << count;

	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<ll, ll>
#define nyan "(=^･ω･^=)"
#define read_input         freopen("in.txt","r", stdin)
#define print_output       freopen("out.txt","w", stdout)
typedef long long ll;
typedef long double ld;
using namespace std;

const ll maxn = 4e3+10;
ll pre[4][maxn], a[maxn];

ll other(ll a, ll b) {
    if(a > b) swap(a, b);
    if(a == 1 && b == 2) return 3;
    if(a == 1 && b == 3) return 2;
    if(a == 2 && b == 3) return 1;
}

int main() 
{
    ll n; string s;
    cin >> n >> s;

    for(ll i = 1; i <= n; i++) {
        if(s[i-1] == 'R') pre[1][i]++, a[i] = 1;
        if(s[i-1] == 'G') pre[2][i]++, a[i] = 2;
        if(s[i-1] == 'B') pre[3][i]++, a[i] = 3;
    }

    for(ll i = 1; i <= n; i++) {
        for(ll j = 1; j <= 3; j++)
            pre[j][i] += pre[j][i-1];
    }

    ll ans = 0;
    for(ll i = 1; i <= n; i++) {
        for(ll j = i+1; j <= n; j++) {
            if(a[i] == a[j]) continue;

            ll c = other(a[i], a[j]);

            ans += pre[c][i-1];
            if(2*i-j >= 1 && 2*i-j <= n) ans -= a[2*i-j] == c;
        }
    }

    cout << ans << endl;

    return 0;  
}

Measured memory_bytes: 3748
<?php


for($i = 1; $i <= 100000; $i++){
  $map[$i] = 1;
}
$map[1] = 0;
for($i = 1; $i <= 3200; $i++){
  if($map[$i] == 1){
    for($j = 2; $i * $j < 100000; $j++){
      $map[$i*$j] = 0;
    }
  }
}
$sum[-1] = 0;
for($i = 1; $i < 100000; $i+=2){
  $sum[$i] = $sum[$i-2] + $map[$i]*$map[($i+1)/2];
}
$Q = intval(fgets(STDIN));
for($i = 0; $i < $Q; $i++){
  fscanf(STDIN, "%d%d", $l, $r);
  echo $sum[$r]-$sum[$l-2],"\n";
}



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

int main(){
  vector<int> abc(3);
  cin >> abc[0] >> abc[1] >> abc[2];
  sort(abc.begin(), abc.end());
  
  int diff = (abc[2] - abc[1]) + (abc[2] - abc[0]);
  int ans = diff / 2;
  if(diff % 2){ 
    ans += 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,L;std::cin>>n>>L;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    for(lint i=0;i<n-1;i++){
        if(L<=a.at(i)+a.at(i+1)){
            std::cout<<"Possible"<<'\n';
            for(lint j=n-1;j>=i+2;j--){
                std::cout<<j<<'\n';
            }
            for(lint j=1;j<=i+1;j++){
                std::cout<<j<<'\n';
            }
            return 0;
        }
    }
    std::cout<<"Impossible\n";
}


Measured memory_bytes: 1664
package main

import "fmt"

func max(a []int) int {
	max := 0

	for i := 0; i < len(a); i++ {
		if a[i] > max {
			max = a[i]
		}
	}
	return max
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	ans := -1
	mx := max([]int{a, b, c})
	ans = a + b + c + mx*9
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, M, K;
    cin >> N >> M >> K;
    bool ans = false;
    REP(i,N+1) {
        int count = M*i;
        int md = N - i*2;
        REP(j,M+1) if (count + md*j == K) {
            ans = true;
            break;
        }
        if (ans) break;
    }
    ATYN(ans)

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void){
	long a, b, c;
	scanf("%ld", &a);
	scanf("%ld", &b);
	scanf("%ld", &c);
	if(a+b < c && 4*a*b < (c-a-b)*(c-a-b)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int a=sc.nextInt();
				int b=sc.nextInt();
				int c=sc.nextInt();
				if(a==0) break;
				int P=0, Q=0, R=0, S=0;
				for(int p=1; p<=a; p++) {
					if(a%p==0 && a/p<p) {
						int r=a/p;
						if(c==0) {
							int q=0;
							if(b%p==0) {
								P=p;
								S=b/q;
								Q=q;
								R=r;
								break;
							}
							int s=0;
							if(b%r==0) {
								P=p;
								S=s;
								Q=b/r;
								R=r;
								break;
							}
						}
						else {
							for(int q=Math.min(-1*c, c); q<=Math.max(-1*c, c); q++) {
								if(q==0) continue;
								if(c%q==0) {
									int s=c/q;
									if(p*s+q*r==b) {
										P=p;
										S=s;
										Q=q;
										R=r;
										break;
									}
								}
							}
						}
					}
					if(p*p==a) {
						int r=p;
						if(c==0) {
							int q=0;
							if(b%p==0 && q>=b/p) {
								P=p;
								S=b/p;
								Q=q;
								R=r;
								break;
							}
							int s=0;
							if(b%r==0 && b/r>=s) {
								P=p;
								S=s;
								Q=b/r;
								R=r;
								break;
							}
						}
						else {
							for(int q=Math.min(-1*c, c); q<=Math.max(-1*c, c); q++) {
								if(q==0) continue;
								if(c%q==0 && c/q<=q) {
									int s=c/q;
									if(p*s+q*r==b) {
										P=p;
										S=s;
										Q=q;
										R=r;
										break;
									}
								}
							}
						}
					}
					if(P!=0) {
						break;
					}
				}
				if(P==0) System.out.println("Impossible");
				else System.out.println(P+" "+Q+" "+R+" "+S);


			}

		}
	}
}


Measured memory_bytes: 39200
import java.util.*;

public class Main {
    public static void main(String[] args) {
        solve();
        return;
    }

    private static void solve() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[20];
        int[][] x = new int[20][20];
        int[][] y = new int[20][20];

        for (int i = 1; i <= N; i++) {
            A[i] = sc.nextInt();
            for (int j = 1; j <= A[i]; j++) {
                x[i][j] = sc.nextInt();
                y[i][j] = sc.nextInt();
            }
        }
        int ans = 0;
        for (int bits = 1; bits < (1 << N); bits++) {
            boolean ok = true;
            for (int i = 1; i <= N; i++) {
                if ((bits & (1 << (i - 1))) == 0) continue;
                for (int j = 1; j <= A[i]; j++) {
                    if ((((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) == 1) ok = false;
                }
            }
            if (ok) ans = Math.max(ans, counter(bits));
        }
        System.out.println(ans);
        return;
    }

    private static int counter(int x) {
        if (x == 0) return 0;
        return counter(x >> 1) + (x & 1);
    }
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M



void solve() {
	int x,n,ans,t,i;
	cin>>x>>n;
	int a[n];
	set<int> s;
	rep(i,0,n){
		cin>>t;
		s.insert(t);
	}
	int l=-1,r=101;
	for(int i=-1;i<=x;i++){
		if(s.find(i)==s.end()) l=i;
	}
	for(int i=101;i>=x;i--){
		if(s.find(i)==s.end()) r=i;
	}
	if(abs(l-x)<=abs(r-x)) cout<<l;
	else cout<<r;
	//cout<<endl;
}


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}





Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

ll n, x;
ll p[mnx];
ll ans = mod, cnt = 1;

int main(){

cin>>n;

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

reverse(p, p + n);

for(int i=1; i<n; i++){
    if(p[i-1] > p[i]){
        cnt++;
    } else {
        ans = min(ans, n - cnt);
        cnt = 1;
    }
}

ans = min(ans, n - cnt);

cout<<ans<<'\n';

return 0;

}














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

int a;

int main(void){
    string ss;
    vector<ll> s;
    ll K;
    cin >> ss >> K;
    s.resize(ss.size());
    for(int i = 0; i < ss.size(); i++){
        s[i] = ss[i];
    }
    for(int i = 0;  i < s.size() - 1; i++){
        if(s[i] == 'a') continue;
        if( s[i] + K > (ll)'z' ){
            K -= ('z' + 1 - s[i]);
            s[i] = 'a';
        }
    }
    //K = K % ('z' - 'a' + 1);
    s[s.size() - 1] += K;
    //a = s[s.size() - 1];
    while(s[s.size() - 1] > 'z'){
        s[s.size() - 1] = 'a' + s[s.size() - 1] - 'z' - 1;
    }

    for(int i = 0; i < s.size(); i++){
        printf("%c", s[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1408
package main

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

var (
	BufferSize = 100
)

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	a := scanInt(sc)
	b := scanInt(sc)

	ans := a + b
	if ans < a-b {
		ans = a - b
	}
	if ans < a*b {
		ans = a * b
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String getLine = sc.nextLine();
    String[] array = getLine.split(" ");
    
    System.out.println(array[0].substring(0,1)+array[1].substring(0,1)+array[2].substring(0,1));
  }
}

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

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> T(n), V(n);
    for (int i = 0; i < n; ++i) cin >> T[i];
    for (int j = 0; j < n; ++j) cin >> V[j];
    vector<vector<double>> dp(105, vector<double>(120, 0.0));
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= V[i]; ++j) {
            if(dp[i][j]){
                for (int k = 0; k <= V[i]; ++k) {
                    int a = V[i] - j;
                    int b = V[i] - k;
                    if (a + b <= T[i]) {
                        dp[i + 1][k] = max(dp[i + 1][k],
                                dp[i][j] + 1.0*(j+V[i])*a/2 + V[i] * (T[i]-a-b) + 1.0 * (k+V[i])* b / 2);
                    } else if (T[i] < abs(k - j)) {
                    } else {
                        double x = 1.0 * (k - j + T[i]) / 2;
                        double y = 1.0 * (T[i] - k + j) / 2;
                        double vvv = j + x;
                        dp[i + 1][k] = max(dp[i + 1][k],
                                dp[i][j] + 1.0*(j+vvv)*x/2+1.0*(k+vvv)*y/2);
                    }
                }
            }
        }
    }
    printf("%.10f\n", dp[n][0] - 1);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
vector<int>v[11];
int n,m,x,y,a[11];
int dfs(int x,int d){//cout<<v[x].size()<<endl;
  if(d==n)return 1;
  int res=0;
  a[x]=1;
  r(i,v[x].size()){
    if(!a[v[x][i]]){
      a[v[x][i]]=1;
      res+=dfs(v[x][i],d+1);
      a[v[x][i]]=0;
    }
  }
  return res;
}
main(){
  cin>>n>>m;
  r(i,m){
    cin>>x>>y;
    x--,y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cout<<dfs(0,1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long fa[1000005],ans;
bool used[1000005];
long long find(long long x) {
	if (fa[x]==x) return x;
	else return fa[x]=find(fa[x]);
}
int main() {
	long long n,m;
	cin>>n>>m;
	for (long long i(1);i<=n;++i) fa[i]=i;
	for (long long i(1);i<=m;++i) {
		long long x,y,z;
		cin>>x>>y>>z;
		fa[find(x)]=find(y);
	}
	for (int i(1);i<=n;++i) {
		int fa=find(i);
		if (!used[fa]) {
			used[fa]=true;
			++ans;
		}
	}
	cout<<ans<<'\n';
	return 0;
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 3000000;
const int MOD = 1000000007;
 
ll 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;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll s,cnt = 0;
  cin >> s;
  COMinit();
  ll ans = 0;
  while(true){
    ll v = s-(cnt+1)*3;
    if(v < 0){
      cout << ans%MOD << endl;
      return 0;
    }
    //cout << COM(v+cnt,cnt) << endl;
    ans += COM(v+cnt,cnt);
    ans %= MOD;
    cnt++;
  }
}

Measured memory_bytes: 73904
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
using ull = unsigned long long;
ull dp[15];
void init() {
	dp[0] = 1;
	for(int i=1;i<12;i++) {
		dp[i] = dp[i-1] * 26;
		//assert(dp[i] > 0);
	}
}
int main() {
	ll n;
	cin >> n;
	string m;
	while(n) {
		n--;
		int rem = n%26;
		char ins = rem+'a';
		m+=ins;
		n/=26;
	}
	reverse(m.begin(),m.end());
	cout<<m<<"\n";
}


Measured memory_bytes: 3592
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
  int i;
  char S[200000 + 2];
  char T[200000 + 2];
  int d;
  long cnt = 0;
  scanf("%s", S);
  scanf("%s", T);
  int len = strlen(S);
  for (i = 0; i < len;i++){
	if(S[i] != T[i])
		cnt++;
  }
  printf("%ld\n", cnt);
  return 0;
}


Measured memory_bytes: 2544
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    priority_queue<ll> pq;
    rep(i,n)pq.push(a[i]);
    while(m--){
        ll x = pq.top();
        pq.pop();
        x /= 2;
        pq.push(x);
    }
    ll ans = 0;
    rep(i,n)ans += pq.top(), pq.pop();
    cout << ans << endl;
}

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

const int N=2e5+10;

struct asd{
    LL pre;
    LL num;
    LL next;
    LL k;
};
stack<asd>q;

LL t[N];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&t[i]);
    LL ans=0;
    asd tmp;
    tmp.num=t[1];
    tmp.pre=tmp.next=1;
    tmp.k=1;
    q.push(tmp);
    LL x=0,y=0;
    for(LL i=2;i<=n;i++)
    {
        asd tmp1;
        tmp1.num=t[i];
        tmp1.pre=tmp1.next=1;
        tmp1.k=i;
        while(!q.empty()&&tmp1.num<=q.top().num)//如果说这个元素是小于栈顶的，那么它里面的栈就要被更新，这个元素的pre也要被更新
        {
            tmp=q.top();
            q.pop();
            if(!q.empty())
                q.top().next+=tmp.next;
            tmp1.pre+=tmp.pre;
            ans+=tmp.pre*tmp.next*tmp.num;
        }
        q.push(tmp1);
    }
    while(!q.empty())
    {
        tmp=q.top();
        q.pop();
        if(!q.empty())
            q.top().next+=tmp.next;
        ans+=tmp.num*tmp.next*tmp.pre;
    }
    printf("%lld\n",ans);
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int k, s;
	cin >> k >> s;

	int ans = 0;
	for(int x = 0; x <= k; x++){
		for(int y = 0; y <= k; y++){
			int z = s - x - y;
			if(z < 0 || z > k) continue;
			ans++;
		}
	}

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

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

int arr[200000];
int main()
{
    int n,l;
    cin>>n>>l;

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

    for(int i=0;i<n-1;i++)
    {
        if(arr[i]+arr[i+1]>=l)
        {
            cout<<"Possible\n";
            for(int j=0;j<i;j++)
            {
                cout<<j+1<<"\n";
            }
            for(int j=n-1;j>=i+1;j--)
            {
                cout<<j<<"\n";
            }
            return 0;
        }
    }
    cout<<"Impossible";
    return 0;
}


Measured memory_bytes: 1152
/*
    Author: Aryan Yadav
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b) for (long long i = a; i > b; i--)
#define repm(i, a, b) for (long long i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define pqmaxi priority_queue<int>
#define pqmaxl priority_queue<ll>
#define pqmini priority_queue<int, vi, greater<int>>
#define pqminl priority_queue<ll, vl, greater<ll>>
#define t     \
    ll t;     \
    cin >> t; \
    while (t--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)
double pi = 3.1415926535897;
int main()
{
    ll n1, n2;
    cin >> n1 >> n2;
    vl v(4);
    if (n1 % 2 == 0)
    {
        v = {n2, 1, n2 ^ 1, 0};
    }
    else
    {
        v = {n1, n1 ^ n2, n1 - 1, (n1 - 1) ^ n2};
    }
    cout << v[(n2 - n1) % 4];
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <list>
using namespace std;
  
int main() {
  int n, q; scanf("%d %d", &n, &q);
  list<int> ls[n];
  
  while (q--) {
    int command, t, x, s; scanf("%d", &command);
      
    switch (command) {
      case 0:
        scanf("%d %d", &t, &x);
        ls[t].push_back(x);
        break;
        
      case 1:
        scanf("%d", &t);
        if (!ls[t].empty()) {
          list<int>::iterator it = ls[t].begin();
          printf("%d", *it);
          it++;
          for (it; it != ls[t].end(); it++) printf(" %d", *it);
        }
        printf("\n");
        break;
        
      case 2:
        scanf("%d %d", &s, &t);
        ls[t].splice(ls[t].end(), ls[s]);
        break;
    }
  }
}


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

using namespace std;


int main() {
    int n; cin >> n;
    int a[n];
    int sofar = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sofar = max(a[i], sofar);
        if(sofar - a[i] >= 2) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;

}



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

typedef long long llint;
llint inf = 1000000007;

llint a = 0;
llint b = 0;
llint c = 0;
llint r = 1;

string s;

int main() {
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        switch (s[i]) {
        case 'A':
            a = (a + r) % inf;
            break;
        case 'B':
            b = (b + a) % inf;
            break;
        case 'C':
            c = (c + b) % inf;
            break;
        default:
            c = (c * 3 + b) % inf;
            b = (b * 3 + a) % inf;
            a = (a * 3 + r) % inf;
            r = (r * 3) % inf;
        }
    }
    cout << c << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=1)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    if(a>8||b>8)
        cout<<":(";
    else 
        cout<<"Yay!";
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;
#define PI 3.14159265358979323846

using namespace std;
int MOD = 1000000007;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  vector<int> a(5);
  for(int i = 0; i < 5; ++i) {
    cin >> a[i];
  }
  for(int i = 0; i < 5; ++i) if( a[i] == 0 ){
    cout << i+1 << '\n';
    break;
  }

  return 0;
}



Measured memory_bytes: 3232
using System;

class Plogram
{
    static void Main()
    {

        var array = Console.ReadLine().Split();
        int A = int.Parse(array[0]);
        int B = int.Parse(array[1]);

        string str = ":(";
        if(A<=8 && B<=8)
        {
            str = "Yay!";
        }
        Console.WriteLine(str);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

using namespace std;

#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = 998244353;




int a, b, c, k;

void solve() {
    cin >> a >> b >> c >> k;
    bool done = false;
    for (int i = 0; i <= k; ++i) {
        int j = k - i;
        int nb = b, nc = c;
        for (int q = 0; q < i; ++q) nb *= 2;
        for (int q = 0; q < j; ++q) nc *= 2;
        if (a < nb && nb < nc) {
            cout << "Yes\n";
            done = true;
            break;
        }
    }

    if (!done) cout << "No\n";
}


int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

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

  int A [N], h;
  for(int i = 0; i < N; i++) {
    cin >> h;
     A[h - 1] = i + 1;
  }

  for(int i = 0; i < N; i++) {
    cout << A[i] << ' ';
  }

  return 0;
}


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

int main() {
  long n,m,ans;
  cin >> n >> m;
  vector<long> a(m);
  ans=n;
  for(long i=0;i<m;i++) cin >> a[i];
  for(long i=0;i<m;i++) ans-=a[i];
  if(ans<0) ans=-1;
  cout << ans << endl;
}

Measured memory_bytes: 3668
a,b = map(int,input().split())

def calc(x):
    l = len(format(x,'b'))
    s = '1' if x%4==1 or x%4==2 else '0'
    for i in range(1,l):
        x_ = x
        x_ -= 2**i-1
        mod = x_ % (2**(i+1))
        if mod >= 2**i:
            s += '0'
        else:
            if mod%2==0:
                s += '0'
            else:
                s += '1'
    s = s[::-1]
    return s

suma = int(calc(a-1),2)
sumb = int(calc(b),2)
print(int(suma^sumb))

Measured memory_bytes: 62060
N = gets.to_i

s,k,n = 0,1,N
while k<=n
	m = N/k
	s += (k-1)*k*(n-m)*(n+m+1)/2
	s += k*m*(m+1)
	k,n = k+1,m
end
s -= (k-1)*m*(m+1) if m<k-1
p s/2


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

int main(void) {
    while (true) {
        int R0, W0, C, R;
        cin >> R0 >> W0 >> C >> R;
        if (R0 == 0 && W0 == 0 && C == 0 && R == 0) break;
        int r_want = (C * W0);
        if (r_want <= R0) cout << 0 << endl;
        else {
            if ((r_want - R0) % R == 0) cout << (r_want - R0) / R << endl;
            else cout << ((r_want - R0) / R) + 1 << endl;
        }
    }
}


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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
        int N,m = 0,n = 0; 
        cin >> N;
        int arr[N];
        for (int i=1; i<=N; i++) {
            cin >> arr[N];
            if(arr[N]>N)
            {
                std::cout << "NO" << std::endl;
                return 0;
            }
            if (i == arr[N])
            m = m+1;
            else if (i!=arr[N])
            n = n+1;
            
        }
        if((m==N)||(n == 2))
        cout << "YES" << endl;
        else  
        cout << "NO" << endl;
        
        
        return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int max = 0;
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			int count = 0;
			for (int j = i; j % 2 == 0; j /= 2) {
				count++;
			}
			if (max <= count) {
				max = count;
				ans = i;
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var k = sc.nextInt();
		var q = sc.nextInt();
		var a = IntStream.range(0, q).map(i -> sc.nextInt()).toArray();
		sc.close();

		var c = new int[n];
		for (var i = 0; i < q; i++) {
			c[a[i] - 1]++;
		}

		for (var i = 0; i < n; i++) {
			System.out.println(k - q + c[i] > 0 ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 60504
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i = 0; i<n; i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        Object ans = averageLength(n, x, y);
        System.out.println(ans);
    }


    private static double averageLength(int n, int[] x, int[] y){
        double distance = 0;
        int fac = 0;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j<n; j++){
                fac++;
                distance += Math.sqrt(Math.pow((x[i]-x[j]), 2) +Math.pow((y[i]-y[j]), 2));
            }
        }
        return distance*(n - 1)/fac;
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <map>
#include <set>

using namespace std;

void fail() {
    cout << "No" << endl;
    exit(0);
}

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

    map<string, set<int>> liq;
    for (int i = 0; i < N; ++i) {
        string C;
        int D;
        cin >> C >> D;
        liq[C].insert(D);
    }

    int M;
    cin >> M;
    int pre = 0;
    for (int q = 0; q < M; ++q) {
        string S;
        cin >> S;
        if (!liq.count(S)) fail();
        auto itr = liq[S].upper_bound(pre);
        if (itr == liq[S].end()) fail();
        pre = *itr;
    }

    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 25040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
#include <cmath>
int main() {
    static const double pi = acos(-1);
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double th = 2 * pi * (H * 60 + M) / 720;
    double tm = 2 * pi * M / 60;
    double theta  = th - tm;
    double ans;
    ans = sqrt(A * A + B * B - 2 * A * B * cos(theta));

    printf("%.10f\n",ans);
      
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll A;
    ll B1,B2;
    char S;
    cin >> A >>B1>>S>> B2;

    ll A1 = A * B1;
    ll A2 = A * B2;

    ll tmp = A2 % 100;
    ll ans = (A2 - tmp) / 100;
    ans += A1;
    cout << ans << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N; cin >> N;
  vector<int> W(N); REP(i, N) cin >> W[i];
  int ALL = accumulate(all(W), 0);
  int f = 0;
  int ans = 1000000;
  for(int i = 0; i < N; ++i) {
    f += W[i];
    ALL -= W[i];
    if(ans > abs(f - ALL)) ans = abs(f - ALL);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>

int main() {
    int n;
    scanf("%d", &n);
    char tc[1000][101], hc[1000][101];
    for (int i = 0; i < n; i++) {
        scanf("%s %s", tc[i], hc[i]);
    }
    int tp = 0, hp = 0;
    for (int i = 0; i < n; i++) {
        if (strcmp(tc[i], hc[i]) > 0) {
            tp += 3;
        } else if (strcmp(tc[i], hc[i]) < 0) {
            hp += 3;
        } else {
            tp += 1;
            hp += 1;
        }
    }
    printf("%d %d\n", tp, hp);
    return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ans=0;
    ans=n/3;
    n-=ans*3;
    while(n)
    {
        ans+=n/3;
        n/=3;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll x;
    cin >> x;
    rep(i, x+1) {
        if ((i*(i+1))/2 >= x) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;
  int sum = 0;
  int temp = n;
  while(temp){
    sum += temp%10;
    temp /= 10;
  }
  if(n%sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "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 so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  int c[n],a[n][m];
  rep(i,n){
    cin>>c[i];
    rep(j,m){
      cin>>a[i][j];
    }
  }
  
  rep(j,m){
    int v=0;
    rep(i,n){
      v+=a[i][j];
    }
    if(v<x){
      cout<<-1<<endl;return 0;
    }
  }
  ll mini=10000000;
  rep(bit,1<<n){
    ll sum=0;
    vector<int> data(m,0);
    rep(i,n){
      if(bit&1<<i){
        rep(j,m){data[j]+=a[i][j];}
        sum+=c[i];
      }
    }
    int vmini=data[0];
    rep(j,m){
      vmini=min(vmini,data[j]);
    }
    if(vmini>=x)mini=min(mini,sum);
  }
  cout<<mini<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
   int n;
   cin >> n;
   ll ans = 0;
   int cnt = 0;
   ll absmin = 1LL << 60;
   rep(i,n){
      ll x;
      cin >> x;
      if (x < 0) cnt++;
      ans += abs(x);
      absmin = min(absmin,abs(x));
   }
   if (cnt%2 == 0) cout << ans << endl;
   else cout << ans-2*absmin << endl;
   //cout << absmin << endl;
   //cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3572
# -*- coding: utf-8 -*-
"""
D - Megalomania
https://atcoder.jp/contests/abc131/tasks/abc131_d

"""
import sys


def solve(N, tasks):
    ct = 0
    tasks.sort(key=lambda x: x[1], reverse=True)

    while tasks:
        a, b = tasks.pop()
        ct += a
        if ct > b:
            return 'No'
    return 'Yes'


def main(args):
    N = int(input())
    tasks = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, tasks)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main() {

    int h, w;

    cin >> h >> w;

    vector<string> tile(h);

    for(int i = 0; i < h; ++i)
        cin >> tile[i];


    vector<vector<int>> up(h, vector<int>(w, 0));
    vector<vector<int>> down(h, vector<int>(w, 0));
    vector<vector<int>> left(h, vector<int>(w, 0));
    vector<vector<int>> right(h, vector<int>(w, 0));

    int count = 0;

    for(int i = 0; i < h; ++i) {
        count = 0;
        for(int j = 0; j < w; ++j) {
            if(tile[i][j] == '#')
                count = 0;
            else
                count++;
            
            left[i][j] = count;
        }
    }

    for(int i = 0; i < h; ++i) {
        count = 0;
        for(int j = w - 1; j >= 0; --j) {
            if(tile[i][j] == '#')
                count = 0;
            else 
                count++;

            right[i][j] = count;
        }
    }



    for(int j = 0; j < w; ++j) {
        count = 0;
        for(int i = 0; i < h; ++i) {
            if(tile[i][j] == '#')
                count = 0;
            else 
                count++;
            up[i][j] = count;
        }


    }

    for(int j = 0; j < w; ++j) {
        count = 0;
        for(int i = h - 1; i >= 0; --i) {
            if(tile[i][j] == '#')
                count = 0;
            else 
                count++;
            down[i][j] = count;
        }

    }


    int answer = 0;

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(tile[i][j] == '#')
                continue;
            int sum = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3;
            answer = max(answer, sum);
        }

    }


    cout << answer << endl;

    return 0;

}

Measured memory_bytes: 73648
main = do
  s <- getContents
  let v = takeWhile(\x-> x /= [0,0]) $ (map (map (read :: String->Int) . words)) $ lines s
  mapM_ (putStrLn . show . calc)  v

calc :: [Int] -> Int
calc [n,x] = length $ filter ((== x) . sum) $ [[x,y,z]|x<-[1..n],y<-[1..(x-1)],z<-[1..(y-1)]] 

Measured memory_bytes: 5412
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 6;
int X, Y, A, B, C;
int a[N], b[N], c[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> X >> Y >> A >> B >> C;
    priority_queue<int, vector<int>, greater<int>> ha, hb;
    for (int i = 0; i < A; ++i) {
        cin >> a[i];
        ha.push(a[i]);
        if (ha.size() > X)
            ha.pop();
    }
    for (int i = 0; i < B; ++i) {
        cin >> b[i];
        hb.push(b[i]);
        if (hb.size() > Y)
            hb.pop();
    }
    for (int i = 0; i < C; ++i)
        cin >> c[i];
    sort(c, c + C);
    for (int i = 0; i < C; ++i) {
        if (ha.top() > hb.top())
            swap(ha, hb);
        if (c[i] > ha.top()) {
            ha.push(c[i]);
            ha.pop();
        }
    }
    long long ans = 0;
    for (;ha.size();ans += ha.top(), ha.pop());
    for (;hb.size();ans += hb.top(), hb.pop());
    cout << ans << endl;
}


Measured memory_bytes: 2296
import sys

lines = [int(input()) for i in range(5)]

time = 0
count = 0

for i,item in enumerate(lines):
	if item%10 == 0:
		time += item
		lines[i] = 0
		count += 1
		#print(item)

for i in reversed(range(9)):
	#print("#",i)
	for j,item in enumerate(lines):
		if item%10 == i+1:
			time += item
			lines[j] = 0
			count += 1
			if count != 5:
				time += (10 - (i+1))
			#print(item,time)

print(time)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;


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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int q;
	cin>>q;
	vector<ll>cnt_m(n+1);
	rep(i,n){
		cnt_m[i+1]=cnt_m[i]+ll(s[i]=='M');
	}
	while(q--){
		int k;
		cin>>k;
		ll d=0,m=0,ans=0;
		rep(i,n){
			if(i>=k){
				if(s[i-k]=='D'){
					m-=cnt_m[i]-cnt_m[i-k+1];//(i-k,i-1]
					--d;
				}
			}
			if(s[i]=='D'){
				++d;
			}
			else if(s[i]=='M'){
				m+=d;
			}
			else if(s[i]=='C'){
				ans+=m;
			}
		}
		cout<<ans<<"\n";
	}
	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 12188
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, m, c, ans =0;
	cin >> n >> m >> c;
	vector<int> b(m);
	rep(i,m) cin >> b[i];
	rep(i,n){
		int sum = 0;
		rep(j,m){
			int a; cin >> a;
			sum += a*b[j];
		}
		if(sum+c > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	string str;
	int k;
	vector<string> v;
	cin >> str >> k;
	int len = min(k, (int)str.size());
	for (int i = 1; i <= len; i++) {
		for (int j = 0; j <= str.length()-i; j++) {
			v.push_back(str.substr(j, i));
		}
	}
	sort(v.begin(), v.end());
	if (k == 1) {
		cout << v[0] << endl;
		return 0;
	}
	else {
		for (int i = 1, j=1; i < v.size(); i++) {
			if (v[i] != v[i - 1]) {
				j++;
			}
			if (k == j) {
				cout << v[i] << endl;
				return 0;
			}
		}
	}
}


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

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

int main(void)
{
    long long A, B, C, D;
    cin >> A >> B >> C >> D;

    long long S = B - A + 1;
    long long lcm = (C*D)/gcd(C,D);
    // cout << "lcm = " << lcm << endl;

    long long cDivided = B / C - (A-1) / C;
    long long dDivided = B / D - (A-1) / D;
    long long lcmDivided = B / lcm - (A-1) / lcm;

    cout << S - ((cDivided + dDivided) - lcmDivided) << endl;
}

Measured memory_bytes: 256