akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[4000][4000];

ll topdown(ll *arr,ll l,ll r)
{
    if(l>r)
    {
        dp[l][r]=0;
        return 0;
    }
    if(dp[l][r]!=-1)
    {
        return dp[l][r];
    }
    ll op1=arr[l]+min(topdown(arr,l+1,r-1),topdown(arr,l+2,r));
    ll op2=arr[r]+min(topdown(arr,l,r-2),topdown(arr,l+1,r-1));
    dp[l][r]=max(op1,op2);
    return dp[l][r];
}

int main()
{
    ll n=0,sum=0;
    cin>>n;
    ll *arr= new ll[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    memset(dp,-1,sizeof dp);
    cout<<2*topdown(arr,0,n-1)-sum;
    return 0;
}

Measured memory_bytes: 128720
from functools import reduce
import sys


def dump(x):
    print(x, file=sys.stderr)


s = input()
t = input()

min_diff = 100000000000


for i in range(len(s)-len(t)+1):
    matches = [1 if s[i+j] != t[j] else 0 for j in range(len(t))]
    diffn = sum(matches)
    min_diff = min(diffn,min_diff)
    dump(min_diff)

print(min_diff)




Measured memory_bytes: 74312
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
  
int main() 
{ 
	int k; cin>> k;
	long long sum = 0;
	for(int a = 1; a <= k; a++){
		for(int b = 1; b <= k; b++){
			for(int  c = 1; c <= k; c++){
				sum += __gcd(__gcd(a,b),c);
			}
		}
	}
	cout<<sum;
	return 0;
} 




Measured memory_bytes: 3596
import java.util.*;

public class Main {

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

    public static void main(String args[]) {

        String s = sc.nextLine();

        int l = s.length();

        String ans1, ans2;

        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();

        for (int i=0; i < l; i++) {
            sb1.append(i % 2 == 0 ? "1" : "0");
            sb2.append(i % 2 != 0 ? "1" : "0");
        }

        ans1 = sb1.toString();
        ans2 = sb2.toString();

        int d1 = distance(s, ans1);
        int d2 = distance(s, ans2);

        System.out.println(d1 > d2 ? d2 : d1);

    }

    private static int distance(String s, String target) {
        int c = 0;
        char[] s1 = s.toCharArray();
        char[] s2 = target.toCharArray();
        for (int i=0; i < s.length(); i++) {
            if (s1[i] != s2[i])
                c++;
        }
        return c;
    }

}


Measured memory_bytes: 30120
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))
totalSatis = 0
lastItem = 0
for i in As:
    totalSatis += Bs[i-1]
    if lastItem == i-1 and lastItem != 0:
        totalSatis += Cs[lastItem-1]
    lastItem = i
print(totalSatis)

Measured memory_bytes: 3064
def dig_sum(n):
    rtn = 0
    while n > 0:
        rtn += n % 10
        n //= 10
    return rtn

def main():
    n = int(input())
    ans = 10**18
    for i in range(1, n//2+2):
        buf = dig_sum(i) + dig_sum(n-i)
        if buf < ans:
            ans = buf
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0001
  * List of Top 3 Hills
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(10).map(_.toInt).toSeq
      .sorted(Ordering[Int].reverse)
      .take(3)
      .foreach(println)
  }
}

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

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

            var a = Console.ReadLine().Select(c => (int)Char.GetNumericValue(c)).ToArray();
            if (a[0] + a[1] + a[2] + a[3] == 7) Console.WriteLine($"{a[0]}+{a[1]}+{a[2]}+{a[3]}=7");
            else if (a[0] + a[1] + a[2] - a[3] == 7) Console.WriteLine($"{a[0]}+{a[1]}+{a[2]}-{a[3]}=7");
            else if (a[0] + a[1] - a[2] + a[3] == 7) Console.WriteLine($"{a[0]}+{a[1]}-{a[2]}+{a[3]}=7");
            else if (a[0] + a[1] - a[2] - a[3] == 7) Console.WriteLine($"{a[0]}+{a[1]}-{a[2]}-{a[3]}=7");
            else if (a[0] - a[1] + a[2] + a[3] == 7) Console.WriteLine($"{a[0]}-{a[1]}+{a[2]}+{a[3]}=7");
            else if (a[0] - a[1] + a[2] - a[3] == 7) Console.WriteLine($"{a[0]}-{a[1]}+{a[2]}-{a[3]}=7");
            else if (a[0] - a[1] - a[2] + a[3] == 7) Console.WriteLine($"{a[0]}-{a[1]}-{a[2]}+{a[3]}=7");
            else if (a[0] - a[1] - a[2] - a[3] == 7) Console.WriteLine($"{a[0]}-{a[1]}-{a[2]}-{a[3]}=7");
        }
    }
}


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

int main(){
    long double a,b,h,m;
    cin >> a >> b >> h >> m;
    long double PI = M_PI;

    long double hrad = 30.0000*h + 0.50000*m;
    long double mrad = 6.0000*m;

    long double angle = max(hrad,mrad) - min(hrad,mrad);

    while(angle > 360.0000){
        angle -= 360.0000;
    }

    if(angle == 360.0000){
        cout << fixed << abs(a-b) <<setprecision(30) << endl;
        return 0;
    }

    while(angle > 180.0000){
        angle = 360.0000 - angle;
    }

    angle = angle * PI / 180.0000;
    long double c = cos(angle);
    long double c2 = a*a + b*b - 2 * a * b * c;
    long double ans = pow(c2,0.5000000);

    cout << fixed << setprecision(30);
    cout << ans << endl;

}


Measured memory_bytes: 4164
#include<stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int p[n], miss=0;
    for(int i=0; i<n; i++){
        scanf("%d", &p[i]);
        if(p[i] != i+1){
            miss++;
        }
    }
    if(miss > 2){
        printf("NO\n");
    }else {
        printf("YES\n");
    }


    return 0;
}

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

#define INT_MAX 2147483647
#define INT_MIN -2147483648

int max(int a, int b);
int min(int a, int b);
int abs(int a);

int n, a, b;

int main() {
	scanf("%d %d %d", &n, &a, &b);
	int total = 0;
	for(int i = 1; i <= n; i++) {
		int temp = i;
		int temp2 = 0;

		while(temp) {
			temp2 += temp % 10;
			temp /= 10;
		}

		if(a <= temp2 && temp2 <= b) {
			total += i;
		}
	}

	printf("%d\n", total);
	return 0;
}

void swap(int *a, int *b) {
	int temp = *a;
	*a = *b;
	*b = temp;	
}

int max(int a, int b) {
	return (a > b) ? a : b;
}

int min(int a, int b) {
	return (a < b) ? a : b;
}

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


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
int n,a[60];
  cin>>n;
a[0]=11;
a[1]=31;
a[2]=	41	;
a[3]	=	61	;
a[4]	=	71	;
a[5]	=	101	;
a[6]	=	131	;
a[7]	=	151	;
a[8]	=	181	;
a[9]	=	191	;
a[10]	=	211	;
a[11]	=	241	;
a[12]	=	251	;
a[13]	=	271	;
a[14]	=	281	;
a[15]	=	311	;
a[16]	=	331	;
a[17]	=	401	;
a[18]	=	421	;
a[19]	=	431	;
a[20]	=	461	;
a[21]	=	491	;
a[22]	=	521	;
a[23]	=	541	;
a[24]	=	571	;
a[25]	=	601	;
a[26]	=	631	;
a[27]	=	641	;
a[28]	=	661	;
a[29]	=	691	;
a[30]	=	701	;
a[31]	=	751	;
a[32]	=	761	;
a[33]	=	811	;
a[34]	=	821	;
a[35]	=	881	;
a[36]	=	911	;
a[37]	=	941	;
a[38]	=	971	;
a[39]	=	991	;
a[40]	=	1021	;
a[41]	=	1031	;
a[42]	=	1051	;
a[43]	=	1061	;
a[44]	=	1091	;
a[45]	=	1151	;
a[46]	=	1171	;
a[47]	=	1181	;
a[48]	=	1201	;
a[49]	=	1231	;
a[50]	=	1291	;
a[51]	=	1301	;
a[52]	=	1321	;
a[53]	=	1361	;
a[54]	=	1381	;
  rep(i,n-1){
    printf("%d ",a[i]);
  }
  printf("%d",a[n-1]);
}

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

struct P{
	int a,b,c;
};

P p[100010];

int cmp(P x,P y){
	return x.a<y.a;
}

int cmp1(P x,P y){
	return x.b<y.b;
}

int main(){
	int n,m,i,j,s=0;
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> p[i].a;
	}
	sort(p,p+m,cmp);
	for(i=0;i<m-1;i++){
		p[i].b=p[i+1].a-p[i].a;
	}
	p[m-1].b=0;
	sort(p,p+m,cmp1);
	for(i=0;i<=m-n;i++){
		s+=p[i].b;
	}
	if(n>=m)
		cout << 0 << endl;
	else
		cout << s << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;

    int x;
    cin >> x;

    if (x == 2 && n == 2) { 
        cout << "Yes" << endl;
        cout << 1 << ' ' << 2 << ' ' << 3 << endl;
    }   
    else if (x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
    }   
    else {
        vector <int> ans(2 * n - 1), l, r;
        for (int i = 1; i < x; ++i)
            l.app(i);
        for (int i = x + 1; i <= 2 * n - 1; ++i)
            r.app(i);
        ans[n - 1] = x;

        if (l.size() >= 2) {
            ans[n - 2] = l.back(); l.pop_back();
            ans[n] = r.back(); r.pop_back();
            ans[n + 1] = l.back(); l.pop_back();
        }   
        else if (r.size() >= 2) {
            ans[n - 2] = l.back(); l.pop_back();
            ans[n - 3] = r.back(); r.pop_back();
            ans[n] = r.back(); r.pop_back();
        }   

        for (int &e : ans) {
            if (e == 0) {
                if (l.size()) {
                    e = l.back();
                    l.pop_back();
                }   
                else {
                    e = r.back();
                    r.pop_back();
                }   
            }   
        }   
        cout << "Yes" << endl;
        for (int e : ans)
            cout << e << ' ';
        cout << endl;
    }   
}

Measured memory_bytes: 4724
#include<stdio.h>
int main(){
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<b) printf("a < b\n");
	if(a>b) printf("a > b\n");
	if(a==b) printf("a == b\n");

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=3123;
int d,a,b,i2,kmax,pos;
ll dp[102],res,tmp[102];
char k[10002];

int main()
{
    scanf("%s",&k);
    for(; k[kmax]!=0; ++kmax) a+=k[kmax]-'0';
    scanf("%d",&d);
    pos=kmax-1;
    dp[0]=1;
    a%=d;
    if(a==0) ++res;
    while(pos>=0)
    {
        if(k[pos]!='0')
        {
            b=k[pos]-'0';
            a-=b;
            while(a<0) a+=d;
            i2=(d-a)%d;
            for(int i=0; i<b; ++i)
            {
                res+=dp[i2--];
                if(i2<0) i2+=d;
            }
            res%=MOD;
        }
        tmp[0]=0;
        i2=d-1;
        for(int i=0; i<9; ++i)
        {
            tmp[0]+=dp[i2--];
            if(i2<0) i2+=d;
        }
        for(int i=1; i<d; ++i)
        {
            ++i2;
            tmp[i]=tmp[i-1]+dp[i-1]-dp[i2%d];
        }
        for(int i=0; i<d; ++i)
            dp[i]=(dp[i]+tmp[i])%MOD;
        --pos;
    }
    if(--res<0)
        res+=MOD;
    printf("%lld",res);
    return 0;
}

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

int main() {
    int N, K;
    int x;
    int ans = 0;
    cin >> N >> K;

    rep(i, N) {
        cin >> x;
        if (x < K - x) {
            ans += x * 2;
        }
        else {
            ans += (K - x) * 2;
        }
    }
    cout << ans << endl;
}


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

int main(){
    int n,m;
    int h[N],ma[N];
    cin >>n>>m;
    for(int i=1;i<=n;i++){
        cin >> h[i];
        ma[i] = 0;
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        ma[a] = max(ma[a],h[b]);
        ma[b] = max(ma[b],h[a]);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(h[i] > ma[i]){
            ans += 1;
        }
    }
    cout << ans << endl;
}



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

int main() {
  string s;
  
  int count = 0;
  
  cin >> s;
  
  for (int i = 0; i < s.size()/2; i++) {
    if (s.at(i) != s.at(s.size()-i-1)) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<ll> a(n); 
    rep(i,n) cin >> a.at(i);

    auto div2 = [&](ll x){
        ll cnt = 0;
        while(x%2==0){
            cnt++;
            x/=2;
        }
        return cnt;
    };

    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += div2(a.at(i));
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    string s; cin >> s;
    int ans = 642; //差の最大値
    for(int i=0;i<s.size();i++){
        int num = atoi(s.substr(i, 3).c_str());
        ans = min(ans, abs(num - 753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
for i in range(len(s)):
    for j in range(65, 91):
        if s[i] == chr(j):
            if j + n >= 91:
                s[i] = chr(65 + n - (91 - j))
                break
            else:
                s[i] = chr(j + n)
                break
print(''.join(s))

Measured memory_bytes: 3060
n, m=map(int, input().split())
a=list(map(int, input().split()))
target=[]
for i in range(len(a)):
    target.append([a[i], 1])

for i in range(m):
    b, c=map(int, input().split())
    target.append([c, b])

target.sort(reverse=True)
result=0
index=0
for i in range(n):
    if target[index][1]==0:
        index=index+1
    if target[index][1]>0:
        result=result+target[index][0]
        target[index][1]=target[index][1]-1
print(result)


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

int main() {

  int N;
  cin >> N;
  int nmax=1000;
  int a;
  for (int k=0;k<N;k++){
    int count=0;
    cin >> a;
     while(a%2==0){
       a/=2;
       count++;
    }
    nmax=min(nmax,count);
  }
  cout << nmax << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test;
    test=1;
    // cin>>test;
    while(test--)
    {
        long long i,j,n,m,q,a=0,t,b,c,temp,k,maxpeak=0,peak,d;
        string s;
        cin>>n;
        if(n<=6)
        {
            cout<<1;
            return 0;
        }
        else if(n<=11)
        {
            cout<<2;
            return 0;
            
        }
        a=n/11;
        b=n%11;
        if(b<=6 && b!=0)
        cout<<a*2+1;
        else if(b>6)cout<<a*2+2;
        else cout<<a*2;
        
    }
}

Measured memory_bytes: 256
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[100005];

int n, lim, k;

int ans;

void solve() {                   
	scanf("%d %d %d", &n, &lim, &k);

    for (int i = 1; i <= n; ++i) {
    	scanf("%d", &arr[i]);
    }

    sort(arr + 1, arr + n + 1);

    for (int l = 1, r; l <= n; l = r) {
		r = l;

	    while (r <= n && r - l + 1 <= lim && arr[r] - arr[l] <= k) {
	    	++r;
	    }

	    ++ans;
    }

    printf("%d\n", ans);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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

int main(){
  int n,m,x;
  cin >>n>>m>>x;
  int a;
  int hidari=0,migi=0;
  for(int i=0;i<m;i++){
    cin >>a;
    if(a<x) hidari++;
    else migi++;
  }
  cout <<min(migi,hidari)<<endl;
}
    
  


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

using namespace std;

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

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

	vector<int> b(m);
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	if (x >= y)
	{
		cout << "War" << endl;
		return 0;
	}

	for (int i = min(x, y) + 1; i <= max(x, y); i++)
	{
		bool isPossible = true;

		for (int j = 0; j < n; j++)
		{
			if (a[j] >= i)
			{
				isPossible = false;
			}
		}

		for (int j = 0; j < m; j++)
		{
			if (b[j] < i)
			{
				isPossible = false;
			}
		}

		if (isPossible)
		{
			cout << "No War" << endl;
			return 0;
		}
	}

	cout << "War" << endl;
}

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

/*
2^15 = 32768で全探索？
*/

int main() {

    int N;
    cin >> N;

    vector<vector<pair<int, int>>> P(N);

    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        for (int j = 0; j < A; j++)
        {
            pair<int, int> p;
            cin >> p.first;
            cin >> p.second;
            p.first--;
            P[i].push_back(p);
        }
    }

    // cout << "----------------------------------------------------------------" << endl;
    // for (int i = 0; i < N; i++)
    // {
    //     cout << i << endl;
    //     for (auto p : P[i]) {
    //         cout << p.first << " " << p.second << endl;
    //     }
    // }
    

    int ans = 0;
    for (int tmp = 0; tmp < (1 << 15); tmp++)
    {
        bitset<15> s(tmp);
        bool consistent = true;
        int cnt = 0;
        for (int i = 0; i < N; i++)
        {
            if (s.test(i))
            {
                cnt++;
                for (auto p : P[i])
                {
                    if (p.second == 1 && !s.test(p.first)) {
                        consistent = false;
                    }

                    if (p.second == 0 && s.test(p.first)) {
                        consistent = false;
                    }
                }
            }
        }
        if (consistent) {
            // for (int i = 0; i < N; i++)
            // {
            //     cout << s[i];
            // }
            // cout << endl;
            // cout << "cnt " << cnt << endl;
            
            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    int64_t ans = 0;
    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, i)) {
            if (a[i] > a[j]) {
                ans += (k - 1) * k / 2;
                ans %= 1000000007;
            }
        }
        for (auto j : irange(i + 1, n)) {
            if (a[i] > a[j]) {
                ans += (k + 1) * k / 2;
                ans %= 1000000007;
            }
        }
    }

    cout << ans << endl;
}

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

int main(){
  int n , sum=0; cin>> n;
  vector<int>d(n);
  rep(i,n) cin >> d[i];
  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      sum+=d[i]*d[j];
    }
  }
  cout<<sum<<endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int mod = 1000000007;
int esum(vec x){
    int N = x.size();
    int s = 0;
    vec c(N + 1, 0);
    REP(i, N) c[i + 1] = c[i] + x[i];
    REP(i, N){
        s += c[N] - c[i] - (N - i) * x[i];
        s %= mod; 
    }
    return s;
}

signed main(){

    int n, m; cin >> n >> m;
    vec x(n), y(m);
    readvec(x); readvec(y);

    cout << (esum(x) * esum(y)) % mod;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 4208
S = input()
ans = 0
signal = ['']*3

for i in range(2**3):
    if bin(i & 1) == bin(1):
        ans += int(S[3])
        signal[2] = '+' 
    else:
        ans -= int(S[3])
        signal[2] = '-'
    
    if bin(i>>1 & 1) == bin(1):
        ans += int(S[2])
        signal[1] = '+' 
    else:
        ans -= int(S[2])
        signal[1] = '-' 
    
    if bin(i>>2 & 1) == bin(1):
        ans += int(S[0])+int(S[1])
        signal[0] = '+'
    else:
        ans += int(S[0])-int(S[1])
        signal[0] = '-' 

    if ans == 7:
        print('%s%s%s%s%s%s%s=7' % (S[0], signal[0], S[1], signal[1], S[2], signal[2], S[3]))
        break
    else:
        ans = 0


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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		int[] A = nextInts();

		long g = A[0];
		for(int i=1;i<N;i++){
			g = gcd(g,(long)A[i]);
		}

		System.out.println(g);
	}

public static long gcd(long a, long b) {
	long x, y;
	if (a < b) {
		x = b;
		y = a;
	} else {
		x = a;
		y = b;
	}
	long r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 39124
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
    string n;
    cin >> n;
    for(int i = 0; i < 3; i++){
        n[i] = (int)n[i] - 48;
    }
    if(n[0] < n[1]){
        n[0] = n[0] + 1;
    }else if(n[0] == n[1] && n[1] < n[2]){
        n[0] = n[0] + 1;
    }        
    n[1] = n[0];
    n[2] = n[0];
    cout << to_string(n[0]) + to_string(n[1]) + to_string(n[2]) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int primes[200];
int prime[1000000];
int pr[100000];
int el[314514],wl[314514];
int er[314514],wr[314514];
int a[114514];
string s[114514];
int ans[114514];
signed main(){
	ic(a) ic(b) ic(c)
	int ma=max({a,b,c});
	int mi=min({a,b,c});
	int man=a+b+c-ma-mi;
	if((man==ma&&ma!=mi)||(man==mi&&man!=ma)){
		c("Yes")
	}
	else c("No")	
}	


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n;
ll a[111];

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n)cin>>a[i];
  ll res=0;
  while(1){
    int idx=0;
    rep(j,n){
      if(a[idx]<a[j])idx=j;
    }
    if(a[idx]<n)break;
    ll rest=a[idx]%n;
    ll add=a[idx]/n;
    res+=add;
    rep(j,n){
      if(idx==j)continue;
      a[j]+=add;
    }
    a[idx]=rest;
  }
  cout<<res<<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++)

int solve(string s, int p, int q, int r){
    s=regex_replace(s,regex("P"),to_string(p));
    s=regex_replace(s,regex("Q"),to_string(q));
    s=regex_replace(s,regex("R"),to_string(r));
    string a="";
    for(auto c:s){
        int n="012"s.find(c);
        if(n!=-1 and a.back()=='-'){
            a.back()="210"[n];
        }else{
            a+=c;
        }
        if(c==')'){
            auto f=a.substr(0,a.size()-5);
            auto p=a.substr(a.size()-5);
            if(f.back()=='-'){
                if(p[2]=='+'){
                    a=f.substr(0,f.size()-1)+"210"["012"s.find(max(p[1],p[3]))];
                }else{
                    a=f.substr(0,f.size()-1)+"210"["012"s.find(min(p[1],p[3]))];
                }
            }else{
                if(p[2]=='+'){
                    a=f+max(p[1],p[3]);
                }else{
                    a=f+min(p[1],p[3]);
                }
            }
        }
    }
    return a=="2"?1:0;
}

int main(void){
    string s;
    while(cin>>s,s!="."){
        auto cp=regex_replace(s,regex("--"),"");
        int ans=0;
        rep(p,3)rep(q,3)rep(r,3){
            ans+=solve(cp,p,q,r);
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3220
import math
 
K = int(input())
 
ans = 0
 
for a in range(1, K+1):
	for b in range(1, K+1):
		tmp = math.gcd(a,b)
		for c in range(1, K+1):
			ans += math.gcd(tmp,c)
 
print(ans)

Measured memory_bytes: 9184
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
bool dp[1000000];
string s;
int main() 
{
	while(cin>>s)
	{
		memset(dp,0,sizeof(dp));
		dp[0]=1;
		for(int i=0;i<s.size();i++)
		{
			if(dp[i]==0)continue;
			if(i+5<=s.size()&&s.substr(i,5)=="dream")dp[i+5]=1;
			if(i+7<=s.size()&&s.substr(i,7)=="dreamer")dp[i+7]=1;
			if(i+5<=s.size()&&s.substr(i,5)=="erase")dp[i+5]=1;
			if(i+6<=s.size()&&s.substr(i,6)=="eraser")dp[i+6]=1;
		}
		if(dp[s.size()]==1)
		cout<<"YES"<<"\n";
		else
		cout<<"NO"<<"\n"; 
	}	
	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    double sm = 0;
    rep(i, N) {
        cin >> A[i];
        sm += A[i];
    }
    double bd = sm/(4*M);
    int m = 0;
    rep(i,N){
        if(A[i] < bd) continue;
        else ++m;
    }
    cout << ((M<=m)?"Yes":"No") << endl;
}


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

int main()
{
    ll K,N;
    cin >> K >> N;
    ll A[N];
    for(ll i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    ll diffMax = K - A[N-1] + A[0];

    for(ll i = 1; i < N; i++)
    {
        ll diff = A[i] - A[i-1];
        if(diffMax < diff)
        {
            diffMax = diff;
        }   
    }

    cout << K - diffMax << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define all(a) a.begin(),a.end()
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//sort 降順
//reverse 逆順
 
int main() {
  ll a,b;
  ci(a>>b);
  string s;
  ci(s);
  vec c(b),d(b);
  vec e(a);
  
  ll f=0;
  for(i,1,a){
    if(s[i-1]=='A'&&s[i]=='C')
      e[i]+=e[i-1]+1;
    
    else
      e[i]=e[i-1];
    //こういう遷移をすると累積和っぽく見える
  }
  
  for(i,0,b){
    ll l,r;
    ci(l>>r);
    co(e[r-1]-e[l-1]);
    //配列を作る必要は無くて,こんな感じで使い捨てすればいい
  }
}


Measured memory_bytes: 3456
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

void solve()
{
  double d,t,s;
  cin>>d>>t>>s;
  if(d/s<=t)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios::sync_with_stdio(false);
  cin.tie(0);

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

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    map<pair<int, int>, int> mp;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            int p = x[i] - x[j];
            int q = y[i] - y[j];
            mp[make_pair(p, q)]++;
        }
    }
    int ma = 0;
    for (auto e : mp) ma = max(ma, e.second);
    cout << n - ma << endl;
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<string> B(N);
  for (int i = 0; i < N; i++) {
      string b;
      cin >> b;
      B.at(i) = b;
  }
  int M;
  cin >> M;
  vector<string> R(M);
  for (int i = 0; i < M; i++) {
      string r;
      cin >> r;
      R.at(i) = r;
  }
  int high = 0;
  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      if (B.at(j) == B.at(i)) {
        sum +=1;
      }
    }
    for (int j = 0; j < M; j++) {
      if (R.at(j) == B.at(i)) {
        sum -=1;
      }
    }
    if (sum > high) {
      high = sum;
    }
  }
  cout << high << endl;
}

Measured memory_bytes: 256
//a.c A-Right Triangle
#include<stdio.h>

int max3(int a,int b,int c){
    int max = a;
    if(b>max){
        max = b;
    }
    if(c>max){
        max = c;
    }
    return max;
}

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

    int max = max3(a,b,c);
    if(max == a){
        printf("%d\n",b*c/2);
    }else if(max == b){
        printf("%d\n",a*c/2);
    }else{
        printf("%d\n",a*b/2);
    }
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    double r;
    cin >> r;
    OP(2 * 3.141592 * r);
    return 0;
}

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

int main() {
	long long int n, red,blue;

	cin >> n >> blue >> red;

    long long int k = blue + red;

    if(blue == 0) {
    	cout << 0 << endl;
    	return 0;
    }
	if(n % k < blue)
		cout << blue * (n / k) + n % k << endl;
	else
		cout << blue * (n / k + 1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[1000001],c[1000001];
int b,d;
int main()
{
    cin>>a;
    b=strlen(a);
    for(int i=b-1;i>=0;i--)
	{
        c[d]=a[i];
        if(c[d]=='b') c[d]='d';
        else if(c[d]=='d') c[d]='b';
        else if(c[d]=='p') c[d]='q';
        else if(c[d]=='q') c[d]='p';
        d++;
    }
    for(int i=0;i<=b-1;i++) 
	{
        if(a[i]!=c[i])
		{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int>());
    int Alice = 0, Bob = 0;
    for (int i = 0; i < N; i++)
    {
        if (i % 2)
        {
            Bob += A[i];
        }
        else
        {
            Alice += A[i];
        }
    }
    cout << Alice - Bob << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int calc(int*,int,int);
int main(){
  while(true){
    int n,k;
    cin>>n>>k;
    if(n==0)return 0;
    int c[100];
    for(int i=0;i<n;i++)
      cin>>c[i];
    int nowc=calc(c,k,n);
    int cmax=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j)continue;
	swap(c[i],c[j]);
	int cprime=calc(c,k,n);
	cmax=max(cprime,cmax);
	swap(c[i],c[j]);
      }
    }
      if(cmax<nowc)
	cout<<"NO GAME"<<endl;
      else
	cout<<cmax-nowc<<endl;
  }
  return 0;
}
int calc(int* c,int k,int n){
  int m=0;
  for(int i=0;i<n-k+1;i++){
    int v=1;
    for(int j=0;j<k;j++){
      v*=c[i+j];
    }
    m=max(v,m);
  }
  return m;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

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

    int ans = 1000;
    for (int i = 0; i < S.size() - 2; i++) {
        int A = S[i] - '0';
        int B = S[i + 1] - '0';
        int C = S[i + 2] - '0';
        int N = 100 * A + 10 * B + C;
        ans = min(ans, abs(N - 753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		Point2D.Double a = getPoint(scanner);
		Point2D.Double b = getPoint(scanner);
		double sum = 0;
		while (scanner.hasNext()) {
			Point2D.Double c = getPoint(scanner);
			sum += getArea(b.x - a.x, b.y - a.y, c.x - a.x, c.y - a.y);
			b.x = c.x;
			b.y = c.y;

		}
		System.out.println(sum);
	}

	private static double getArea(double a, double b, double c, double d) {
		return Math.abs(a * d - b * c) / 2;
	}

	public static Point2D.Double getPoint(Scanner scanner) {
		StringTokenizer tokenizer = new StringTokenizer(scanner.nextLine(), ",");
		return new Point2D.Double(Double.parseDouble(tokenizer.nextToken()),
				Double.parseDouble(tokenizer.nextToken()));
	}
}

Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//繰り返し二乗法
ll mod_pow(ll x,ll n,ll p){
	ll res = 1;
	while(n > 0){
		if(n & 1){
			res = res * x % p;
		}
		x = x * x % p;
		n >>= 1;
	}
	return res;
}

int main(){
	ll n;cin>>n;
	string x;cin>>x;
	ll bit = 0;
	for(ll i = 0; i < n; i++) {
		if (x[i] == '1'){
			bit++;
		}
	}
	vector<ll> pow1(n + 1,1);
	vector<ll> pow2(n + 1,1);
	if(x[n - 1] == '0'){
		pow1[0] = 0;
		pow2[0] = 0;
	}
	for(ll i = 1; i < n; i++) {
		if (x[n - 1- i] == '1'){
			pow1[i] = (mod_pow(2,i,bit + 1) + pow1[i - 1]) % (bit + 1);
			if(bit - 1 != 0){
				pow2[i] = (mod_pow(2,i,bit - 1) + pow2[i - 1]) % (bit - 1);
			}
			else{
				pow2[i] = 0;
			}
		}
		else{
			pow1[i] = pow1[i - 1];
			pow2[i] = pow2[i - 1];
		}
		
	}
	// for(int i = 0; i < n; i++) {
	// 	cout << pow1[i] << endl;
	// }
	// cout << "bit" << bit << endl;
	for(ll i = 0; i < n; i++) {
		if (x[i] == '1'){
			if(bit - 1 == 0){
				cout << 0 << endl;
			}
			else{
				ll tmp = (pow2[n - 1] - (mod_pow(2,n - 1 - i,bit - 1))) % (bit - 1);
				ll ans = 1;
				if(tmp < 0){
					tmp +=(bit - 1);
				}
				// cout << "tmp" << tmp << endl;
				while(tmp != 0){
					ans++;
					ll div = __builtin_popcount(tmp);
					// cout << "div" << div << endl;
					// cout << "tmp" << tmp << endl;
					tmp %= div;
				}
				cout << ans << endl;
			}
			
		}
		else{
			ll tmp = (pow1[n - 1] + (mod_pow(2,n - 1 - i,bit + 1))) % (bit + 1);
			ll ans = 1;
			// cout << "tmp" << tmp << endl;
			while(tmp != 0){
				ans++;
				ll div = __builtin_popcount(tmp);
				// cout << "div" << div << endl;
				// cout << "tmp" << tmp << endl;
				tmp %= div;
			}
			cout << ans << endl;

		}
		
	}
	return 0;
}

Measured memory_bytes: 6828
N=int(input())

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

a.sort(reverse=True)
TATE=0
count=0

for i in range(N):
  if i!=N-1 and a[i]==a[i+1] and count!=1:
    if TATE==0:
      TATE=a[i]
      i+=1
      count=1
    else:
      YOKO=a[i]
      print(TATE*YOKO)
      exit()
  else:
    count=0

print(0)

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

int main()
{
    int a, b;
    cin >> a >> b;
    
    if(a > 0 && b > 0){ cout << "Positive\n";}
    else if(a <= 0 && b >= 0){ cout << "Zero\n";}
    else {
        
        if((abs(a - b) + 1) % 2 == 0) cout << "Positive\n";
        else cout << "Negative\n";
    
    
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 K, A, B;

int main()
{
	scanf("%lld%lld%lld", &K, &A, &B);
	
	i64 ret = 1 + K;
	{
		K -= A - 1;
		i64 cnt = A;
		if (K >= 0) {
			if (K % 2 == 1) ++cnt;
			cnt += (B - A) * (K / 2);
		}
		ret = max(ret, cnt);
	}

	printf("%lld\n", ret);
	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    string S = "";

    for (int i = 0; i < s.size(); ++i){
        if(s[i] == '0'){
            S = S + "0";
        }
        else if (s[i] == '1')
        {
            S = S + "1";
        }
        else if (s[i] == 'B')
        {
            if(!S.empty())
                S.erase(S.size()-1);
        }
    }
    cout << S << endl;
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  
  if (U == S) {
    cout << A - 1 << " " << B << endl;
  }
  else {
    cout << A << " " << B - 1 << endl;
  }
}


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

main(){
	int x,y,z;
	cin >> x >> y >> z;
	int a = x / y;
	int i;
	for(i=a; i>=0 && x-(y*i) < z*(i+1); --i);
	printf("%d\n", i);
}


Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=100005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

vector <int> v[N];
int dp[N];
int dfs(int u)
{
    if(dp[u]!=0)
    return dp[u];
    for(auto to:v[u])
    {
        dp[u]=max(dp[u], dfs(to));
    }
    dp[u]++;
    //cout<<u<<" "<<dp[u]<<"\n";
    return dp[u];
}
int32_t main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans, dfs(i));
    }
    cout<<ans-1;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   string s,t,a;
   ll i,x;
   cin>>s>>t;
   x=s.size();
   a=t.substr(0,x);
   if(s==a)
   {
       cout<<"Yes"<<endl;
   } else
   {
       cout<<"No"<<endl;
   }
    return 0;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int,int>P;

#define INF 2<<29;
#define F first
#define S second
  
int main(){
  ll x;
  scanf("%lld",&x);

  if(x%11==0){
    printf("%lld\n",(x/11)*2);
  }else if(x%11<=6){
    printf("%lld\n",(x/11)*2+1);
  }else{
    printf("%lld\n",(x/11)*2+2);
  }
  
  
  return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# M, D = map(int, input().split())
# A = list(map(int, input().split()))
# S = input()
memo = 10 ** 100
for i in range(1, int(math.sqrt(N)) + 1):
    if N % i == 0 and memo > (N // i) + i:
        memo = i + (N // i)

print(memo - 2)


Measured memory_bytes: 9164
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  long x[N];
  for (int i=0;i<N;i++){
    cin>>x[i];
  }
  sort(x,x+N,greater<long>());
  long takasa=10000000000;
  long tempt;
  for (int i=0;i<N-K+1;i++){
    tempt=x[i]-x[i+K-1];
    if (tempt<takasa){
      takasa=tempt;
    }
  }
  cout<<takasa;
  return 0;
}

Measured memory_bytes: 1024
def binary_search(c1, c2):
    m = (c1 + c2 + 1) // 2
    if abs(c1 - c2) <= 1:
        return m
    else:
        s = list(h)
        c = 0
        for j in s:
            j -= b * m
            if j > 0:
                c += (a + j - b - 1) // (a - b)
            if c > m:
                break
        if c > m:
            c1 = m
        else:
            c2 = m
        return binary_search(c1, c2)

n, a, b = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
print(binary_search(0, h[n - 1] + 1))

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

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

    int n;
    cin>>n;
    map<int,int> cnt;
    int sum=0;
    while(n--)
    {
        int a;
        cin>>a;
        sum+=a;
        cnt[a]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        sum-=b*cnt[b];
        sum+=c*cnt[b];
        cnt[c]+=cnt[b];
        cnt.erase(b);
        cout<<sum<<"\n";
    }
}


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

int main()
{
	int ans = 0;
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '0' && s[i + 1] == '0')
		{
			ans++;
			s[i + 1] = '1';
		}
		else if (s[i] == '1' && s[i + 1] == '1')
		{
			ans++;
			s[i + 1] = '0';
		}
	}
	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 512
from collections import deque

n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    x, y, z = map(int, input().split())
    edge[x - 1].append(y - 1)
    edge[y - 1].append(x - 1)

queue = deque()
check = [False for _ in range(n)]
ans = 0
for i in range(n):
    if check[i]:
        continue
    ans += 1
    queue.append(i)
    while queue:
        pos = queue.popleft()
        for next_pos in edge[pos]:
            if check[next_pos]:
                continue
            check[next_pos] = True
            queue.append(next_pos)
print(ans)
        

Measured memory_bytes: 23872