akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int a,b,c;
    cin >> a >> b >> c;
    bool flag = false;
    if(a != b && b != c && a != c){
        flag = true;
    }else if(a == b && b == c && c == a){
        flag = true;
    }

    if(flag == true){
        cout << "No" << endl;
    }else{
        cout <<"Yes"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int dist[100005];
vector< pair<int,int> >grp[100005];
void calc(int s){
	priority_queue< pair<int,int>,vector< pair<int,int> >,greater< pair<int,int> > >q;
	q.push(make_pair(0,s));
	while(!q.empty()){
		int node =q.top().second;
		q.pop();
		for(int i=0;i<grp[node].size();i++){
			if(dist[grp[node][i].first]>dist[node]+grp[node][i].second){
				dist[grp[node][i].first]=dist[node]+grp[node][i].second;
				q.push(make_pair(dist[grp[node][i].first],grp[node][i].first));
			}
		}
	}
}
int main(){
	cin>>n;
	m=n-1;
	for(int i=1;i<=n;i++){
		dist[i]=INT_MAX;
	}
	for(int i=0;i<m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		grp[u].push_back(make_pair(v,w));
		grp[v].push_back(make_pair(u,w));
	}
	int source=1;
	dist[source]=0;
	calc(source);
	for(int i=1;i<=n;i++){
		if(i==1){
			cout<<0<<endl;
			continue;
		}
		if(dist[i]%2==0){
			cout<<0<<endl;
		}
		else{
			cout<<1<<endl;
		}
	}

}

Measured memory_bytes: 6912
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

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

  int len=s.size();
  int e=0,w=0,n=0,S=0;
  rep(i,len){
    if(s.at(i)=='N') n=1;
    else if(s.at(i)=='S') S=1;
    else if(s.at(i)=='E') e=1;
    else w=1;
  }

  if((n==S) &&(w==e)) cout<<"Yes";
  else cout<<"No";
  cout<<endl;
}

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

int bubbleSort(int a[], int n) {
    int total_swap = 0;
    int swap_;
    int i = 0;

    do {
        swap_ = 0;

        for (int j = n - 1; j > i; j--) {
            if (a[j -1] > a[j]) {
                swap(a[j -1], a[j]);
                swap_++;
            }
        }

        total_swap += swap_;
        i++;
    } while (swap_ > 0);

    return total_swap;
}

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

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

    int count = bubbleSort(a, n);

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << a[i];
    }

    cout << endl << count << endl;

    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int W, a, b;  cin >> W >> a >> b;

    if (a+W < b) {
        print(b - (a+W));
    } else if (b+W < a) {
        print(a - (b+W));
    } else {
        print(0);
    }
}




Measured memory_bytes: 256
n=int(input())
hoge=[]
huga=[]
for i in range(n):
  x=int(input())
  hoge.append(x)
  huga.append(x)
huga.sort(reverse=True)
x=huga[0]
y=huga[1]
if(huga[0]==huga[1]):
  for i in range(n):
    print(x)
else:
  for i in range(n):
    if(hoge[i]==huga[0]):
      print(y)
    else:
      print(x)

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

int a[200005], b[200005];
int ca[200005], cb[200005];
int n;
int ans = 0;

void init(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    init();
    vector<int> Z, O;
    Z.reserve(n); O.reserve(n);
    for(int j = 0; j <= 28; j++){
        Z.clear(); O.clear();
        for(int i = 1; i <= n; i++){
            if(a[i] >> j & 1) O.push_back(a[i]);
            else Z.push_back(a[i]);
        }
        copy(Z.begin(), Z.end(), a + 1);
        copy(O.begin(), O.end(), a + Z.size() + 1);
        copy(a + 1, a + n + 1, ca + 1);
        for(int i = 1; i <= n; i++) ca[i] &= (1 << j + 1) - 1;
        Z.clear(); O.clear();
        for(int i = 1; i <= n; i++){
            if(b[i] >> j & 1) O.push_back(b[i]);
            else Z.push_back(b[i]);
        }
        copy(Z.begin(), Z.end(), b + 1);
        copy(O.begin(), O.end(), b + Z.size() + 1);
        copy(b + 1, b + n + 1, cb + 1);
        for(int i = 1; i <= n; i++) cb[i] &= (1 << j + 1) - 1;
        int p1 = n, p2 = n, p3 = n;
        int bit = 0;
        for(int i = 1; i <= n; i++){
            while(p1 && ca[i] + cb[p1] >= 1 << j) --p1;
            while(p2 && ca[i] + cb[p2] >= 2 << j) --p2;
            while(p3 && ca[i] + cb[p3] >= 3 << j) --p3;
            bit ^= (p2 - p1) + (n - p3);
        }
        if(bit & 1) ans |= 1 << j;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}
int main()
{
    boost;
    ll n,i,j,x,t,y;
	cin>>n;
	ll ans=0;
	ans+=1000*(n/500);
	n=n-500*(n/500);
	ans+=5*(n/5);
	cout<<ans;
}

Measured memory_bytes: 256
from collections import defaultdict

n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9 + 7
d = defaultdict(int)

inner = 0
for i in range(n):
    d[a[i]] += 1
    for j in range(i+1,n):
        if a[i] > a[j]:
            inner += 1

t = 0
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            t += 1

x = (t*k*(k-1))//2
y = inner*k
print(int((x+y)%mod))


Measured memory_bytes: 9588
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);
  int ans;
  ans = n / 1.08;
  if ((int)(ans * 1.08) == n)
    printf("%d\n", ans);
  else if ((int) ((ans + 1) * 1.08) == n)
    printf("%d\n", ans + 1);
  else
    printf(":(\n");
  return 0;
}


Measured memory_bytes: 128
l, r = map(int,input().split())

ans = 2019
flag = False
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans = min(ans,(i*j)%2019)
        #print(i,j)
        if ans == 0:
            flag = True
            break
    if flag:
        break
print(ans)

Measured memory_bytes: 38896
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <int,int>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

vector <int> v[N];
bool vis[N];
void dfs(int s)
{
	vis[s] = true;
	for (auto g : v[s])
	{
		if(!vis[g])
		{
			dfs(g);
		}
	}
}
int main()
{
	int n, x, y, ans = 0, m, w;
	memset(vis, false, sizeof(vis));
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> x >> y >> w;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for (int i = 1; i <= n; ++i)
	{
		if(!vis[i])
		{
			dfs(i);
			ans++;
		}
	}
	cout << ans;
}	

Measured memory_bytes: 8960
def main():
    n = int(input())
    a1lis = list(map(int, input().split()))
    a2lis = list(map(int, input().split()))

    a1sum = sum(a1lis)
    a2sum = sum(a2lis)

    tmp = a1lis[0]

    #i = 0
    total = a1lis[0] + a2sum
    ans = total

    for i in range(1, n):
        tmp += a1lis[i]
        a2sum -= a2lis[i-1]
        total = tmp + a2sum
        if total > ans:
            ans = total
    
    print(ans)

        
    



    

if __name__ == "__main__":
    main()

Measured memory_bytes: 62060
import numpy as np
def main():
    import sys
    input = sys.stdin.readline

    # N = int(input())
    N,X,T = map(int,input().split())
    # p = list(map(int, input().split()))
    # print(p)
    print(-(-N//X)*T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27112
import sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
L = [int(input()) for _ in range(3)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip

print((L[0] - L[1]) % L[2])

Measured memory_bytes: 38256
from collections import Counter

N = int(input())

# check = []
# ans = {}
# answer = 0
# for _ in range(N):
#     s = Counter(input())
#     if s not in check:
#         check.append(s)
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] = 0
#
#     else:
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] += 1
#         answer += ans[str(sorted(s.items(), key=lambda x:x[0]))]
#
# print(answer)

ans = {}
answer = 0
for _ in range(N):
    s = "".join(sorted(input()))

    if s not in ans:
        ans[s] = 0

    else:
        ans[s] += 1
        answer += ans[s]

print(answer)




Measured memory_bytes: 18236
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    
    int n;
    cin>>n;
    
    vector<int> a(n);
    
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    
    unsigned int sum=0;
    for(int i=0; i<n; i++){
        sum+=a[i]-1;
    }
    
    cout<<sum<<endl;
    
    
}


Measured memory_bytes: 256
package main
import (
    "fmt"
)

func main(){
  array := []int{0,0,0,0}
  var N int
  for i := 0 ; i < 6 ; i++{
    fmt.Scan(&N)
    array[N-1] = array[N-1]+1;
  }
  for i := 0;i<4;i++{
    if 3 <= array[i]{
      fmt.Println("NO")
      return
    }
  }
  fmt.Println("YES")
  return
}


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

int main() {
  int n; cin>>n;
  vector<ll> a(n);
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a.begin(), a.end(), greater<ll>());
  ll ans=0;
  if (n%2==0) {
    for (int i=0; i<n/2-1; i++) ans+=2*a[i];
    ans+=a[n/2-1];
    ans-=a[n/2];
    for (int i=n/2+1; i<n; i++) ans-=2*a[i];
  }
  else {
    ll tmp1=a[n/2-1]+a[n/2], tmp2=-a[n/2]-a[n/2+1];
    for (int i=0; i<n/2-1; ++i) tmp1+=a[i]*2;
    for (int i=n/2+1; i<n; ++i) tmp1-=a[i]*2; 
    for (int i=0; i<n/2; ++i) tmp2+=a[i]*2;
    for (int i=n/2+2; i<n; ++i) tmp2-=a[i]*2;
    ans=max(tmp1, tmp2);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException {
        Scanner s = new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
       int n=s.nextInt(),m=s.nextInt(),l=s.nextInt();
       long[][] g1=new long[n+1][n+1];
       for(int i=1;i<=n;i++){
       	Arrays.fill(g1[i],(long)1e13);
       }
       for(int i=0;i<m;i++){
       	int x=s.nextInt(),y=s.nextInt(),c=s.nextInt();
       	g1[x][y]=c;  
       	g1[y][x]=c;  
       }

       for(int i=0;i<n;i++){
       	g1[i][i]=0;
       }

       	for(int k=1;k<=n;k++){
       		for(int i=1;i<=n;i++){
       			for(int j=1;j<=n;j++){
       				g1[i][j]=Math.min(g1[i][j],g1[i][k]+g1[k][j]);
       			}
       		}
       	} 
        long[][] g2=g1.clone();
        for(int i=1;i<=n;i++){
        	for(int j=1;j<=n;j++){
        		g2[i][j]=g1[i][j]<=l? 1:(long)1e13;
        	}
        }

        for(int k=1;k<=n;k++){
       		for(int i=1;i<=n;i++){
       			for(int j=1;j<=n;j++){
       				g2[i][j]=Math.min(g2[i][j],g2[i][k]+g2[k][j]);
       			}
       		}
       	} 

        BufferedWriter out1 = new BufferedWriter(new OutputStreamWriter(System.out));
        List<Integer>l1=new ArrayList<>();
        int q=s.nextInt();
        for(int i=0;i<q;i++){
        	int start=s.nextInt(),end=s.nextInt();
        	if(g2[start][end]==(long)1e13){
        		l1.add(-1);
        	}
        	else{
        		l1.add((int)g2[start][end]-1);        	
        	}
        }
        for(int i=0;i<l1.size();i++){
        	System.out.println(l1.get(i));
        }
    }
}
    
  












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

int main(){
	int n;
	cin>>n;
	double arr[n];
	double s=0;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin>>arr[i];
	}
	sort(arr,arr+n);
	s=(arr[0]+arr[1])/2;
	for (int i = 2; i < n; ++i)
	{
		/* code */
		s=(s+arr[i])/2;
	}
	cout<<s<<endl;
	return 0;
}

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

int main(void){
    // Your code here!
    int K, S;
    cin >> K >> S;
    int res = 0;
    int z = 0;
    for (int i = 0; i <= K; ++i){
        for (int j = 0; j <= K; ++j){
            z = S - i - j;
            if (0 <= z && z <= K) ++res;
        }
    }
    cout << res << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define LC(x) ((x)<<1)
#define RC(x) ((x)<<1|1)


int main(){
    int n;
    scanf("%d",&n);
    printf("%d",n*n*n);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	n = n%10;
	switch(n) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
		cout << "hon";
		break;
		case 0:
		case 6:
		case 8:
		case 1:
		cout << "pon";
		break;
		default:
		cout << "bon";
	}
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <exception>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
void File()
{
	#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

int main()
{
	fast();
	//File();
	int n,m;
	cin>>n>>m;
	vector<int> vec(n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>vec[i];
		sum+=vec[i];
	}
	int lo=((sum+4*m-1)/(4*m));
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(vec[i]>=lo)
		cnt++;
	}
	if(cnt>=m)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
// #include <vector>

using namespace std;

int bubbleSort(int A[], const int N) {
    // 1 for i = 0 to A.length-1
    // 2     for j = A.length-1 downto i+1
    // 3         if A[j] < A[j-1]
    // 4             swap A[j] and A[j-1]
    int c = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = N-1; j > i; --j) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                c++;
            }
        }
    }
    return c;
}

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

    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int c = bubbleSort(a, n);
    for (int i = 0; i < n-1; ++i) {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    cout << c << endl;

    return 0;
}

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

int p[200005];
int pos[200005];

struct mintree
{
    int tree[524288];

    void init()
    {
        for (int i = 262143; i >= 1; i--) tree[i] = min(tree[i << 1], tree[i << 1 | 1]);
    }

    int get(int l, int r)
    {
        l += 262144; r += 262144;
        int ret = INT_MAX;
        while (l <= r)
        {
            if (l & 1) ret = min(ret, tree[l++]);
            if (!(r & 1)) ret = min(ret, tree[r--]);
            l >>= 1; r >>= 1;
        }
        return ret;
    }
} odd, even;

int main()
{
    memset(odd.tree, 0x7F, sizeof(odd.tree));
    memset(even.tree, 0x7F, sizeof(even.tree));

    int n;
    scanf("%d",&n);

    for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
    for (int i = 1; i <= n; i++) pos[p[i]] = i;
    for (int i = 1; i <= n; i += 2) odd.tree[i + 262144] = p[i];
    for (int i = 2; i <= n; i += 2) even.tree[i + 262144] = p[i];

    odd.init();
    even.init();

    priority_queue<tuple<int, int, int, int>> st;
    int X = odd.get(1, n); int Y = even.get(pos[X] + 1, n);
    st.emplace(-X, -Y, 1, n);

    while (st.empty() == false)
    {
        int v1, v2, lo, hi;
        tie(v1, v2, lo, hi) = st.top();
        v1 = -v1; v2 = -v2;
        st.pop();

        printf("%d %d ", v1, v2);

        v1 = pos[v1]; v2 = pos[v2];

        // lo ~ v1 ~ v2 ~ hi
        // lo ~ v1 - 1, v1 + 1 ~ v2 - 1, v2 + 1 ~ hi

#define F auto &a = (L & 1) ? odd : even; auto &b = (L & 1) ? even : odd; \
    int X = a.get(L, R); int Y = b.get(pos[X], R); st.emplace(-X, -Y, L, R);

        int L, R;

        if (lo < v1 - 1)
        {
            L = lo; R = v1 - 1; F
        }

        if (v1 + 1 < v2 - 1)
        {
            L = v1 + 1; R = v2 - 1; F
        }

        if (v2 + 1 < hi)
        {
            L = v2 + 1; R = hi; F
        }
    }

    printf("\n");
}



Measured memory_bytes: 7924
open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let l_lst = Array.to_list @@ Array.init (n*2) (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let len = List.length l_lst in
  List.sort compare l_lst |> 
  List.filteri (fun i x -> i mod 2 = 0 && i <> len-1) |>
  List.fold_left (+) 0 |>
  Printf.printf "%d\n" 
  





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

int main() {
    char s;
    cin >> s;
    if(s == 'A'){
        cout << 'T' << endl;
    }else if(s == 'G'){
        cout << 'C' << endl;
    }else if(s == 'C'){
        cout << 'G' << endl;
    }else{
        cout << 'A' << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int H, W;
   cin >> H >> W;
   int c[10][10];
   /*
   memset(c, 10000, sizeof(c));
   for (int i = 0; i < 10; i++) {
      c[i][i] = 0;
   }
   */
   for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
         cin >> c[i][j];
      }
   }
   for (int k = 0; k < 10; k++) {
      for (int i = 0; i < 10; i++) {
         for (int j = 0; j < 10; j++) {
            c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
         }
      }
   }

   int A[H][W];
   map<int, int> log;
   for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
         cin >> A[h][w];
         log[A[h][w]]++;
      }
   }

   ll ans = 0;
   for (auto& it : log) {
      if (it.second == 0) continue;
      if (it.first == -1) continue;
      ans += c[it.first][1] * it.second; 
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int num = 1;
		int ans = 0;
		
		while (true) {
			if(b == 1) break;
			ans++;
			num = num - 1 + a;
			if (num >= b) break; 
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 23636
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a<c+e||b<d+e||0>c-e||0>d-e){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  return(0);
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005
#define PI 3.14159265358979323846
using namespace std;




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll N;
        cin>>N;
        cout<<fixed<<setprecision(7)<<(PI)*2*N;




    }



    return 0;
}

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

int main() {
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  long L = -2e18, R = 2e18;
  while (R - L > 1) {
    long M = (L + R) / 2, cnt = 0;
    for (int i = 0; i < N; i++) {
      if (A.at(i) < 0) {
        int l = -1, r = N;
        while (r - l > 1) {
          int m = (l + r) / 2;
          (A.at(i) * A.at(m) < M) ? r = m : l = m;
        }
        cnt += N - r;
      } else {
        int l = -1, r = N;
        while (r - l > 1) {
          int m = (l + r) / 2;
          (A.at(i) * A.at(m) < M) ? l = m : r = m;
        }
        cnt += r;
      }
      if (A.at(i) * A.at(i) < M) cnt--;
    }
    (cnt / 2 < K) ? L = M : R = M;
  }
  cout << L << "\n";
}

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

int main() {
	string S;
	cin >> S;
	if(S == "AKIHABARA") cout << "YES" << endl;
	else if(S == "AKIHABARA") cout << "YES" << endl;
	else if(S == "KIHABARA") cout << "YES" << endl;
	else if(S == "AKIHBARA") cout << "YES" << endl;
	else if(S == "AKIHABRA") cout << "YES" << endl;
	else if(S == "AKIHABAR") cout << "YES" << endl;
	else if(S == "KIHBARA") cout << "YES" << endl;
	else if(S == "KIHABRA") cout << "YES" << endl;
	else if(S == "KIHABAR") cout << "YES" << endl;
	else if(S == "AKIHBRA") cout << "YES" << endl;
	else if(S == "AKIHBAR") cout << "YES" << endl;
	else if(S == "AKIHABR") cout << "YES" << endl;
	else if(S == "KIHBRA") cout << "YES" << endl;
	else if(S == "KIHBAR") cout << "YES" << endl;
	else if(S == "KIHABR") cout << "YES" << endl;
	else if(S == "AKIHBR") cout << "YES" << endl;
	else if(S == "KIHBR") cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a[26]={0};
    char b[2000]={0};
    int i, j, n;
    i=0;
    while(scanf("%c", &b[i])!=EOF){
        if(b[i]>='A'&&'Z'>=b[i]){
            n=b[i]-'A';
            a[n]+=1;
        }else if(b[i]>='a'&&b[i]<='z'){
            n=b[i]-'a';
            a[n]+=1;
        }
        i=i+1;
    }
    for(j=97; j<=122; j++){
        n=j-'a';
        printf("%c : %d\n", j, a[n]);
    }
    return 0;
}


Measured memory_bytes: 2048
dp = [0 for i in range(10**5 + 10)]
dp[0] = 1
n, m = map(int, raw_input().split())
dont = [0 for i in range(10**5 + 10)]
l = [input() for i in range(m)]
for i in l:
	dont[i] = 1
mod = 10**9 + 7
for i in range(1, n+1):
	if dont[i]:
		continue
	dp[i] = dp[i-1] + dp[i-2]
	dp[i] %= mod
print dp[n]

Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;cin>>n;
	int a[n];
	rep(i,n) cin>>a[i];

	vector<int> gl,bw,gr,se,bl,y,o,r,w;

	rep(i,n){
		if(a[i]<400) gl.push_back(a[i]);
		else if(a[i]<800) bw.push_back(a[i]);
		else if(a[i]<1200) gr.push_back(a[i]);
		else if(a[i]<1600) se.push_back(a[i]);
		else if(a[i]<2000) bl.push_back(a[i]);
		else if(a[i]<2400) y.push_back(a[i]);
		else if(a[i]<2800) o.push_back(a[i]);
		else if(a[i]<3200) r.push_back(a[i]);
		else w.push_back(a[i]);
	}

	int cnt=0;
	if(gl.size()>0) cnt++;
	if(bw.size()>0) cnt++;
	if(gr.size()>0) cnt++;
	if(se.size()>0) cnt++;
	if(bl.size()>0) cnt++;
	if(y.size()>0) cnt++;
	if(o.size()>0) cnt++;
	if(r.size()>0) cnt++;

	if(cnt!=0) cout<<cnt<<" ";
	else cout<<1<<" ";

	cout<<cnt+w.size()<<"\n";

}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long k=sc.nextLong();
        int q=sc.nextInt();
        int a[]=new int[q];
        for (int i=0;i<q;++i)
        {
            a[i]=sc.nextInt();
        }

        String ans[]=new String[n];
        for (int i=0;i<n;++i) ans[i]="Yes";

        long point[]=new long[n];
        for (int i=0;i<n;++i) point[i]=k-q;

        for (int i=0;i<q;++i)
        {
            point[a[i]-1]+=1;
        }

        for (int i=0;i<n;++i)
        {
            if (point[i]<=0) ans[i]="No";
        }

        for (int i=0;i<n;++i) System.out.println(ans[i]);
    }
}

Measured memory_bytes: 56860
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
//#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 1000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;

int main(){
    int n,a;
    std::cin >> n>>a;
    VEC(int,x,n);
    rep(i,n)x[i]-=a;
    std::vector<std::map<int, ll> > dp(n+1);
    dp[0][0]=1;
    rep(i,n){
        rrep(j,-2500,2501){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j+x[i]]+=dp[i][j];
        }
    }
    std::cout << dp[n][0]-1 << std::endl;
}

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

int main(){
  int N;
  int64_t ans=0;
  cin>>N;
  vector<int64_t> a(3*N);
  for(int i=0;i<3*N;i++)
    cin >> a.at(i);
  sort(a.begin(), a.end(), greater< int >());
  for(int i=0;i<2*N;i++){
    if(i%2==1)
      ans+=a.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2560
N, M = map(int, input().split())
MOD = 1000000007
a = [0] * (N+1)
can_pass = True
for i in range(M):
    ai = int(input())
    if a[ai-1] == 1:
        can_pass = False
        break
    a[ai] = 1

if not can_pass:
    print(0)
else:
    c = [0] * (N+1)
    c[0] = 1
    for i in range(1, N+1):
        if a[i] == 0:
            if i > 1:
                c[i] = (c[i-1] + c[i-2]) % MOD
            else:
                c[i] = c[i-1]
        else:
            c[i] = 0
    print(c[N])

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

vector<int> a(5);

bool dec(int a){
	int cnt=0;
	for(int i=0;i<5;++i){
		if(a>>i&1) cnt++;
	}
	if(cnt==3) return true;
	else return false;
}

long long calc(int n){
	long long ans=1;
	for(int i=0;i<5;++i){
		if(n>>i&1) ans*=a.at(i);
	}
	return ans;
}

int main(){
	int n;cin >> n;
	for(int i=0;i<n;++i){
		string s;
		cin >> s;
		if(s.at(0)=='M') a.at(0)++;
		else if(s.at(0)=='A') a.at(1)++;
		else if(s.at(0)=='R') a.at(2)++;
		else if(s.at(0)=='C') a.at(3)++;
		else if(s.at(0)=='H') a.at(4)++;
	}
	long long ans=0;
	for(int i=0;i<(1<<5);++i){
		if(dec(i)){
			ans+=calc(i);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

const int N = 1e5 + 10;

int a[N], b[N], c[N];

int main() {
  int x, y, na, nb, nc;
  scanf("%d %d %d %d %d", &x, &y, &na, &nb, &nc);
  for (int i = 0; i < na; i++) scanf("%d", a + i);
  for (int i = 0; i < nb; i++) scanf("%d", b + i);
  for (int i = 0; i < nc; i++) scanf("%d", c + i);
  sort(a, a + na); sort(b, b + nb); sort(c, c + nc);
  reverse(a, a + na); reverse(b, b + nb); reverse(c, c + nc);
  long long sum = 0;
  //for (int i = 0; i < x; i++) sum += 1LL * a[i];
  //for (int i = 0; i < y; i++) sum += 1Ll * b[i];
  int pi, pj, pk;
  pi = pj = pk = 0;
  int cnt = x + y;
  while (cnt--) {
    long long qi, qj, qk;
    if (pi < x) qi = a[pi];
    else qi = -1;
    if (pj < y) qj = b[pj];
    else qj = -1;
    if (pk < nc) qk = c[pk];
    else qk = -1;
    if (qi >= qj && qi >= qk) {
      sum += qi;pi++;
      continue;
    }
    if (qj >= qi && qj >= qk) {
      sum += qj;pj++;
      continue;
    }
    if (qk >= qj && qk >= qi) {
      sum += qk;pk++;
      continue;
    }
  }
  printf("%lld\n", sum);
  return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

ll gcd(ll a, ll b){
  ll temp;
	while (a % b != 0){
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

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

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    int N;
    cin >> N;
    int cnt=0;
    int a;
    for(int i=0;i<N;i++){
        cin >> a;
        while(a%2==0){
            cnt ++;
            a /= 2;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for i in range(M)]

PYI=[PY[i]+[i] for i in range(M)]

PYI.sort(key=lambda x:x[1])

Nu=[1]*(N+1)
ANS=[None]*M

for p,y,i in PYI:
    ANS[i]=(p,Nu[p])
    Nu[p]+=1

#print(ANS)

def numb(x,y):
    x=str(x)
    y=str(y)
    l=len(x)
    m=len(y)

    return (6-l)*"0"+x+(6-m)*"0"+y

for a,b in ANS:
    print(numb(a,b))

Measured memory_bytes: 50268
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll inf = 1e9;

int solve(int *a,int n,int k){
  if(n==2)
    return abs(a[0]-a[1]);
  vector<int>dp(n);
  dp[0]=0;
  for(int i=1;i<n;i++){
    dp[i] = inf;
    for(int j=i-1;j>=0 && (i-j)<=k;j--){
      int opt = abs(a[i]-a[j]) + dp[j];
      dp[i] = min(dp[i],opt);
    }
  }
  return dp[n-1];
}

int main(){
  int n,k; cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  cout<<solve(a,n,k)<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << /*#X <<":" <<*/X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
// typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 100000

ll N,K,ans=0;
ll X[100010],Y[100010];
ll W[3001][3001],B[3001][3001];
char C[100010];
//yxyx
ll imos(int a,int b,int c,int d,int mode){
    int res=0;
    if(a>c||b>d)return 0;
        if(mode==0){
             if((0<=c&&c<2*K)&&(0<=d&&d<2*K))res+=W[c][d];
             if((0<=c&&c<2*K)&&(0<=b-1&&b-1<2*K))res-=W[c][b-1];
             if((0<=a-1&&a-1<2*K)&&(0<=d&&d<2*K))res-=W[a-1][d];
             if((0<=a-1&&a-1<2*K)&&(0<=b-1&&b-1<2*K))res+=W[a-1][b-1];
        }else{
            if((0<=c&&c<2*K)&&(0<=d&&d<2*K))res+=B[c][d];
            if((0<=c&&c<2*K)&&(0<=b-1&&b-1<2*K))res-=B[c][b-1];
            if((0<=a-1&&a-1<2*K)&&(0<=d&&d<2*K))res-=B[a-1][d];
            if((0<=a-1&&a-1<2*K)&&(0<=b-1&&b-1<2*K))res+=B[a-1][b-1];
        }
        return res;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>K;
    REP(i,N){
        cin>>X[i]>>Y[i]>>C[i];
        X[i]%=2*K,Y[i]%=2*K;
        if(C[i]=='W')W[Y[i]][X[i]]++;
        else B[Y[i]][X[i]]++;
    }
    REP(i,2*K)REP(j,2*K){
        W[i][j+1]+=W[i][j];
        B[i][j+1]+=B[i][j];
    }
    REP(i,2*K)REP(j,2*K){
        W[i+1][j]+=W[i][j];
        B[i+1][j]+=B[i][j];
    }
    REP(i,2*K){REP(j,2*K){
        DEB(B[K-1-i][j])
    }END}
    REP(i,K)REP(j,K)REP(k,2){
      ll tans=0;
        tans+=imos(0,0,i-1,j-1,(k==0?0:1));
        tans+=imos(0,j,i-1,j+K-1,(k!=0?0:1));
        tans+=imos(0,j+K,i-1,2*K-1,(k==0?0:1));
        tans+=imos(i,0,i+K-1,j-1,(k!=0?0:1));
        tans+=imos(i,j,i+K-1,j+K-1,(k==0?0:1));
        tans+=imos(i,j+K,i+K-1,2*K-1,(k!=0?0:1));
        tans+=imos(K+i,0,2*K-1,j-1,(k==0?0:1));
        tans+=imos(K+i,j,2*K-1,j+K-1,(k!=0?0:1));
        tans+=imos(K+i,j+K,2*K-1,2*K-1,(k==0?0:1));
        ans=max(tans,ans);
    }

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


Measured memory_bytes: 99328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main() {
  int MAX=101010;
  vector<int> is_prime(MAX,1);
  is_prime[0]=0,is_prime[1]=0;
  for(int i=2;i<MAX;i++){
      if(!is_prime[i]) continue;
      for(int j=i*2;j<MAX;j+=i) is_prime[j]=0;
  }
  
  vector<int> a(MAX,0);
  for(int i=0;i<MAX;i++){
      if(i%2==0) continue;
      if(is_prime[i] && is_prime[(i+1)/2]) a[i]=1;
  }
  
  vector<int> S(MAX+1,0);
  for(int i=0;i<MAX;i++) S[i+1]=S[i]+a[i];
  
  int Q; cin>>Q;
  for(int i=0;i<Q;i++){
      int l,r;
      cin>>l>>r;
      r++;
      cout<<S[r]-S[l]<<endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    int val2 = val % 100;
    int val1 = val / 100;

    if(val1 > 12 || val1 == 0)
    {
    	if(val2 > 12 || val2 == 0)
    		cout << "NA" << endl;
    	else
    		cout << "YYMM" << endl;
    }
    else if(val2 > 12 || val2 == 0)
    {
    	if(val1 > 12 || val1 == 0)
    		cout << "NA" << endl;
    	else
    		cout << "MMYY" << endl;
    }
    else
    	cout << "AMBIGUOUS" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,dp[1<<26],ans;
bool t[100][100];
long long f(int i,int mask)
{
    if(i==n)return 1;
    if(dp[mask]!=-1)return dp[mask];
    long long best=0;
    for(int j=0;j<n;j++)
    {
        if((mask&1<<j)==0&&t[i][j]==true)
        {
            best+=f(i+1,(mask|1<<j));
        }
    }
    dp[mask]=(best%mod);
    return dp[mask];
}
int main()
{
    for(int i=0;i<=1<<23;i++)dp[i]=-1;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>t[i][j];
        }
    }
    cout<<f(0,1<<22)%mod;
}


Measured memory_bytes: 67840
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int D,N;
    cin >> D >> N;
    if(N==100) cout << (int)(101*pow(100,D)) << endl;
    else cout << (int)(N*pow(100,D)) << endl;
}

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

int main() {
    int n, d, ans = 0;
    cin >> n >> d;
    int x[n][d];
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < d; ++j) cin >> x[i][j];
    }
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            int dist = 0;
            for(int k = 0; k < d; ++k) dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            for(int k = 1; k <= dist*dist; ++k) {
                if(dist%k == 0 && dist/k == k) {
                    ans++;
                }
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


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


const int MAXN = 1005;

int main() {
  string s;
  cin>>s;
  string ans="Yes";
  if (s[2]!=s[3]) ans="No";
    if (s[4]!=s[5]) ans="No";
    cout<<ans;

}


Measured memory_bytes: 256
def main():
    x = input()
    ret = 10000
    for i in range(len(x)-2):
        if abs(int(x[i:i+3])-753) < ret:
            ret = abs(int(x[i:i+3])-753)
            
    print(ret)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n,d = map(int, input().split(' '))
dot = [list(map(int, input().split(' '))) for i in range(n)]
def dist(Y, Z):
  temp = 0
  for y,z in zip(Y,Z):
    temp += abs(y-z)**2
  return temp**0.5

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    ret = dist(dot[i], dot[j])
    if int(ret) == ret:
      ans += 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int t[100005],x[100005],y[100005];
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>t[i]>>x[i]>>y[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(int(fabs(x[i]-x[i-1])+fabs(y[i]-y[i-1]))>int(fabs(t[i]-t[i-1])))
		{
			cout<<"No";
			return 0;
		}
		if(int(fabs(x[i]-x[i-1])+fabs(y[i]-y[i-1]))%2!=int(fabs(t[i]-t[i-1]))%2)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int A, B, C, D;

void solve() {
    const int N = A + B;
    const int K = [&] {
        int ng = 0, ok = N;
        while (ok - ng > 1) {
            int mid = (ok + ng) / 2;
            (A <= (B + 1ll)*mid && B <= (A + 1ll)*mid ? ok : ng) = mid;
        }
        return ok;
    }();
    
    const int M = [&] {
        int ok = 0, ng = N + 1;
        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            int x = mid - !(mid % (K + 1));
            int a = A - x / (K + 1) * K - x % (K + 1);
            int b = B - x / (K + 1);
            (b <= (a + 1ll)*K ? ok : ng) = mid;
        }
        return ok;
    }();

    for (int i = C; i <= D; ++i) {
        if (i <= M) {
            int a = (i - 1) % (K + 1);
            if (a < K)cout << 'A';
            else cout << 'B';
        } else {
            int b = (N - i) % (K + 1);
            if (b < K)cout << 'B';
            else cout << 'A';
        }
    }
    cout << endl;
}

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

    int Q;
    cin >> Q;
    rep(ITER, Q) {
        cin >> A >> B >> C >> D;
        solve();
    }
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),a = sc.nextInt(),b = sc.nextInt();
    int ans = a * n;
    if(ans > b){
      ans = b;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
import collections
S = input()
T = input()

s = collections.Counter(S)
t = collections.Counter(T)

ss = s.most_common()
tt = t.most_common()

if len(ss) != len(tt):
    print("No")
    exit()

for i in range(len(ss)):
    if ss[i][1] != tt[i][1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 4144
n,m,c=map(int,input().split())
b=list(map(int, input().split()))
count=0
for _ in range(n):
    a=[int(i) for i in input().split()]
    sum1=[i*j for i,j in zip(a,b)]
    if sum(sum1)+c>0:count+=1
print(count)

Measured memory_bytes: 3064
N = int(input())
d = {}
for _ in range(N):
    s = list(input())
    s.sort()
    s = "".join(s)
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

ans = 0
for k, v in d.items():
    ans += v * (v - 1) // 2

print(ans)


Measured memory_bytes: 17804
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e5+10;
const int P=1e9+7;
int n;
LL dp[N][2];
char s[N];

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	dp[0][0]=1;
	for (int i=1;i<=n;i++) {
		if (s[i]=='0') dp[i][0]=(dp[i][0]+dp[i-1][0])%P;
			else dp[i][0]=(dp[i][0]+dp[i-1][0]*2%P)%P;
		
		dp[i][1]=(dp[i][1]+dp[i-1][1]*3%P)%P;
		if (s[i]=='1') dp[i][1]=(dp[i][1]+dp[i-1][0])%P;	 
	}
	printf("%lld\n",(dp[n][0]+dp[n][1])%P);
	return 0;
}

Measured memory_bytes: 1920