akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll h,w;
  cin >> h >> w;
  ll ans = (h*w+1)/2;
  if(h == 1 || w == 1) cout << 1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s=input()


s=s[::-1]
l=[0]*2019
l[0]=1
prev=0
ans=0
mul=1

for i in range(len(s)):
  now=(int(s[i])*mul)%2019
  ans+=l[(prev+now)%2019]
  l[(prev+now)%2019]+=1
  prev=(prev+now)%2019
  mul=(mul*10)%2019

print(ans)

Measured memory_bytes: 9352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 100005
#define INF 9223372036854775807LL
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b){return ((a*b)/__gcd(a,b));}
int main()
{
     ll test=1,cas=1;
     while(test--)
     {
		ll i,j,k,l,x,n,m,r;
		ll arr[5];
		for(i=0;i<5;i++)
        {
            cin>>arr[i];
            if(!arr[i])
            {
                m=i+1;
            }
        }
        cout<<m;endl;
     }
}


Measured memory_bytes: 3592
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
d=[True]*(10**6+1)
a.sort()
ans=0
D={}
for i in a:
    if not i in D:
        D[i]=1
    else:
        D[i]+=1
for i in a:
    if not d[i]:
        continue
    if D[i]!=1:
        k=1
        while i*k<=10**6:
            d[i*k]=False
            k+=1
        continue
    ans+=1
    k = 1
    while i * k <=10 ** 6:
        d[i * k] = False
        k += 1
print(ans)






Measured memory_bytes: 121528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void delete_space(char *x)
{
	while (*x != '\0')
	{
		if (*x == '\n')
		{
			*x = '\0';
		}
		x++;
	}
}

int main()
{
	int n, i, len, tmp;
	char str[100000];

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

	fgets(str, 100000, stdin);
	delete_space(str);

	len = strlen(str);

	for (i = 0; i < len; i++)
	{
		str[i] = str[i] + n;
		if (str[i] > 'Z')
		{
			str[i] = 'A' + str[i] - 'Z' - 1;
		}
	}

	printf("%s\n", str);

	
	return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<long long> H(N);
  for(int i=0;i<N;i++) cin >> H[i];
  
  sort(H.begin(),H.end());
  
  long long count = 0;
  
  if(N<=K) cout << 0 << endl;
  else{
    for(int i=0;i<N-K;i++){
      count += H[i];
    }
    cout << count << endl;
  }
      
  
}

Measured memory_bytes: 1792
n=int(input())
x=list(map(int,input().split()))

p=sum(x)/n
if p-(sum(x)//n)<0.5:
    p=sum(x)//n
else:
    p=(sum(x)//n)+1

ans=[]
for i in range(n):
    ans.append((x[i]-p)**2)
print(sum(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int n; cin >> n;
    if(n==1) {
        print("Hello World");
    }else{
        int a, b;
        cin >> a >> b;
        print(a+b);
    }
}


Measured memory_bytes: 256
#include<cstdio>

int main() {
	while (1) {
		int m, nmin, nmax, p[201], maxg = 0, n;
		scanf("%d %d %d", &m, &nmin, &nmax);
		for (int i = 1; i <= m; i++) {
			scanf("%d", &p[i]);
		}
		for (int j = nmin; j <= nmax; j++) {
			if (p[j] - p[j+1] >= maxg) {
				maxg = p[j] - p[j+1];
				n = j;
			}
		}
		if (m == 0 && nmin == 0 && nmax == 0) {
			return 0;
		}
		else {
			printf("%d\n", n);
		}
	}
}


Measured memory_bytes: 2680
n = int(input())

a = input()
b = input()
c = input()

ans = 0

for count in range(n):
    tmp = 0
    if a[count] == b[count]:
        if a[count] != c[count]:
            tmp += 1
    else:
        tmp += 1
        if (a[count] != c[count]) & (b[count] != c[count]):
            tmp += 1
    ans += tmp
    
print(ans)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG //提出時に消す
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

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

  int n;
  string s;
  cin >> n >> s;
  vector<int> reds, whites;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') reds.emplace_back(i);
    else whites.emplace_back(i);
  }
  reverse(reds.begin(), reds.end());

  int cnt = 0;
  auto rindex = reds.begin(), windex = whites.begin();
  if ((rindex == reds.end()) || (windex == whites.end())) {
    cout << 0 << endl;
    return 0;
  }
  while((*rindex) > (*windex)) {
    //cout << *rindex << " " << *windex << endl;
    cnt++;
    rindex++;
    windex++;
    if ((rindex == reds.end()) || (windex == whites.end())) break;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        ll a=s.size();
        cout<<s[0]<<a-2<<s[a-1];
    
    
    } 
    return 0;
}


Measured memory_bytes: 3548
#include<stdio.h>
#include<math.h>
#define ll long long



int main()
{
    ll x;
    scanf("%lld",&x);
    for(int a=0;a<=4000;a++)
    {
        for(int b=0;b<a;b++)
        {
            ll a5 = pow(a,5), b5 = pow(b,5);
            if(a5-b5==x)
            {
                printf("%d %d\n",a,b);
                return 0;
            }
            if(a5+b5==x)
            {
                printf("%d %d\n",a,-b);
                return 0;
            }
        }
    }

}


Measured memory_bytes: 2532
N,M = [int(i) for i in input().split()]

list_list = []
for i in range(N) :
    line = input().split()
    del line[0]
    list_list.append(line)

s = set(list_list[0])
for i in range(1,N) :
    s = s & set(list_list[i])

print(len(s))

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

int main(){
  int A, B, C;
  cin >> A >> B>> C;
  if (A==B && B==C){
    cout << 1 << endl;
  }
  else if (A!=B && B!=C && C!=A){
    cout << 3 << endl;
  }
  else {
    cout << 2 << endl;
  }
}




Measured memory_bytes: 256
N, M = map(int, input().split())
lamps = []
for i in range(M):
    row = [int(e) for e in input().split()]
    lamps.append(row[1:])
p = [int(e) for e in input().split()]

ans = 0
for i in range(1 << N):
    ok = True
    for j in range(M):
        c = 0
        for id in lamps[j]:
            if (i >> (id - 1)) & 1:
                c += 1
        c %= 2
        if c != p[j]:
            ok = False
    if ok:
        ans += 1

print(ans)

Measured memory_bytes: 40688
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//below here

int func(){
	int n,d;
	cin >> n >> d;
	d = d * 2 + 1;
	return (n + d - 1) / d;
}
int main(){
	cout << func() << endl;
	return 0;
}


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

int main()
{
    int n;
    int ans;
    // 整数の入力
    scanf("%d", &n);

    int ind;

    // process1
    int hundred = n / 100;
    ind = hundred == 9 ? 1 : hundred == 1 ? 9 : hundred;
    ans += ind * 100;

    // process2
    int ten = (n / 10) % 10;
    ind = ten == 9 ? 1: ten == 1 ? 9 : ten;
    ans += ind * 10;

    // process3
    int one = n % 10;
    ind = one == 9 ? 1 : one == 1 ? 9 : one;
    ans += ind;

    // 出力
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int m, d, ans=0;
  cin >> m >> d;
  for(int i = 1; i <= m; i++) {
    for(int j = 1; j <= d; j++) {
      if((j / 10) * (j - (j / 10) * 10) == i && j / 10 >= 2 && (j - (j / 10) * 10) >= 2) ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //String[] vals = sc.nextLine().split(" ");
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A * B * 1 % 2 == 1 || A * B * 3 % 2 == 1) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();
    }
    static int getInt(String val) {return Integer.parseInt(val);}
    static long getLong(String val) {return Long.parseLong(val);}
}

Measured memory_bytes: 22996
#include<stdio.h>

int main(void){
  int n;
  int a,b;
  int i;
  int x,y;

  while(1){
    scanf("%d",&n);
    if(!n)break;
    a = 0;
    b = 0;
    for(i=0;i<n;i++){
      scanf("%d %d",&x,&y);
      if(x>y)a += x+y;
      else if(x<y)b += x+y;
      else {
	a += x;
	b += y;
      }
    }

    printf("%d %d\n",a,b);
  }

  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

// Finds the minimal pair {x, y} such that x, y >= 0 and ax - by = gcd(a, b).
pair<int64_t, int64_t> extended_euclidean(int64_t a, int64_t b) {
    // https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Example
    int64_t g = b, r = a, x = 0, y = 1;

    while (r != 0) {
        int64_t q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }

    // g == gcd(a, b)
    // x * a == g (mod b)
    x = x <= 0 ? x + b : x;
    y = (x * a - g) / b;
    assert(x >= 0 && y >= 0);
    int64_t take = min(x / (b / g), y / (a / g));
    x -= take * (b / g);
    y -= take * (a / g);
    assert(x >= 0 && y >= 0);
    return {x, y};
}


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int64_t N;
    cin >> N;
    N *= 2;
    int64_t best = 2 * N;

    auto consider_candidate = [&](int64_t candidate) {
        if (candidate > 0)
            best = min(best, candidate);
    };

    for (int64_t a = 1; a * a <= N; a++)
        if (N % a == 0) {
            int64_t b = N / a;

            if (__gcd(a, b) == 1) {
                consider_candidate(b * extended_euclidean(a, b).second);
                consider_candidate(a * extended_euclidean(b, a).second);
            }
        }

    cout << best << '\n';
}


Measured memory_bytes: 3624
//長方形⇔直角三角形、ひし形⇔2等辺三角形
//長方形かつひし形の物は、両方カウント
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	int a,b,c;
	int cnt1 = 0,cnt2 = 0;
	
	while( scanf("%d,%d,%d",&a,&b,&c) != -1 ){
		
		if( a*a + b*b == c*c )
			cnt1++;
		if( a == b )
			cnt2++;
	}
	cout << cnt1 << endl << cnt2 << endl;
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n, m; cin >> n >> m;
	bool ac[n] = {};
	int wa[n] = {};
	rep(i,m) {
		int p; cin >> p;
		--p;
		string s; cin >> s;
		if(s == "AC") {
			ac[p] = true;
		}
		if(s == "WA") {
			if(not ac[p]) wa[p]++;
		}
	}
	int ans = 0, ans1 = 0;
	rep(i,n) {
		if(ac[i]) {
			ans++;
			ans1 += wa[i];
		}
	}
	cout << ans << " " << ans1 << '\n';
	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
int main(){
  char s[100001];
  int c[26]={0},i;
  scanf("%s",s);
  for(i=0;s[i];i++)c[s[i]-'a']=1;
  for(i=0;i<26;i++)if(!c[i]){printf("%c",'a'+i);return 0;}
  printf("None");
}


Measured memory_bytes: 1712
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int n,nmin,nmax;
    cin>>n>>nmin>>nmax;
    if(!n&&!nmin&&!nmax)return 0;
    vector<int> p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    int diff=-1;
    int id;
    for(int i=nmin-1;i<nmax;i++){
      if(abs(p[i]-p[i+1])>=diff){
        diff=abs(p[i]-p[i+1]);
        id=i;
      }
    }
    cout<<id+1<<endl;
  }
}



Measured memory_bytes: 3100
from collections import deque
C=[list(map(int,input().split())) for _ in range(3)]

for i in range(C[0][0]+1):
    q=deque([C[0][0]-i,C[0][1]-i,C[0][2]-i,C[0][0]-i,C[0][1]-i,C[0][2]-i])
    flag=0
    for j in range(1,3):
        d=set()
        for k in range(3):
            d.add(C[j][k]-q.popleft())
        if len(d)==1:
            flag+=1
    if flag==2:
        print('Yes')
        exit()

print('No')

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

#define MAXN 51
int mutton[MAXN];
int plate[MAXN];

int main()
{
    int N,K,res=0;
    cin>>N>>K;
	for(int i=0;i<N;i++)
		cin>>mutton[i];
	//l+r+k<=K,l+r<=N
	int bound=min(N,K);
	for(int l=0;l<=bound;l++)
	{
		for(int r=0;r<=bound-l;r++)
		{
			int i,j;
			for(i=0;i<l;i++)
				plate[i]=mutton[i];
			for(j=0;j<r;j++)
				plate[i+j]=mutton[N-j-1];

			sort(plate,plate+l+r);

			int k=0,temp=0;
			while(k+l+r<K&&plate[k]<0)
				k++;
			while(k<l+r)
			{
				temp+=plate[k];
				k++;
			}
			res=max(res,temp);
		}
	}
	cout<<res<<endl;
    return 0;
}

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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  if(a <= b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }
  else if(a > b){
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }
  
  
}

Measured memory_bytes: 3508
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math
import datetime
N = int(input())
A = [int(x) for x in input().split()]

cnt = {}

kind = 0
for a in A:
    if not a in cnt:
        kind += 1
        cnt[a] = 0
    if kind > 3:
        break
    cnt[a] += 1

nums = list(cnt.keys())

if kind == 2:
    cnt0 = 0
    cnt_not0 = 0
    for n in [nums[0], nums[1]]:
        if n == 0:
            cnt0 += cnt[n]
        else:
            cnt_not0 = cnt[n]
    if cnt0 * 2 == cnt_not0:
        print("Yes")
    else:
        print("No")
elif kind == 3 and cnt[nums[0]] == cnt[nums[1]] == cnt[nums[2]] and nums[0] ^ nums[1] == nums[2]:
    print("Yes")
elif kind == 1 and nums[0] == 0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 14480
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000
int N,L;
int K[MAX_N];
int A[100000];
int M[100000];
int ans;
vector<char> C;
bool bool_ans;

void solve(void) {
  int i,j;
  i = 0;
  M[0] = 0;
  while(1) {
    //M1からA1へはiリットル
    rep(j,0,N-1) {
      M[j+1] = A[j] - M[j];
    }
    if (A[N-1] == M[N-1] + M[0]) {
      return;
    } else {
      M[0] = (A[N-1] - M[N-1]) / 2;
      rep(j,0,N-1) {
        M[j+1] = A[j] - M[j];
      }
      return;
    }
  }

}

int main (void)
{
  cin >> N;
  rep(i,0,N) {
    cin >> A[i];
  }

  solve();

  rep(i,0,N-1) {
    cout << 2*M[i] << " ";
  }
  cout << 2*M[N-1] << endl;

  return 0;
}


Measured memory_bytes: 2048
import math
a,b,c,d = map(int,input().split())

aug = 6*d - (30*c + (30*(d/60)))

if aug == 0:
    len = a - b
else:
    len = a**2 + b**2 - (2 * a* b *(math.cos(math.radians(aug))))
    len = len**0.5

print(len)

Measured memory_bytes: 9512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 998244353;
const int MAXN = (int)3e5 + 10;
int64_t fac[MAXN];

int64_t poww(int64_t a, int64_t b) {
    int64_t res = 1;
    while (b) {
        if (b % 2 == 0) {
            a *= a;
            a %= MOD;
            b /= 2;
        } else {
            res *= a;
            res %= MOD;
            b--;
        }
    }
    return res;
}


int64_t C(int64_t n, int64_t k) {
    if (n < k) {
        return 0;
    }
    return fac[n] * poww(fac[k] * fac[n - k] % MOD, MOD - 2) % MOD;
}


int main() {
    int64_t n, a, b, k;
    cin >> n >> a >> b >> k;
    int64_t ans = 0;
    for (int i = 0; i <= n; i++) {
        fac[i] = i == 0 ? 1 : fac[i - 1] * i % MOD;
    }
    for (int i = 0; i <= n; i++) {
        auto ref = (k - i * a);
        if (ref < 0) {
            continue;
        }
        if (ref % b != 0) {
            continue;
        }
        int64_t t_a = i;
        int64_t t_b = ref / b;
        if (t_b > n) {
            continue;
        }
        ans += C(n, t_a) * C(n, t_b);
        ans %= MOD;
    }
    cout << ans << std::endl;


}

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

using i64 = std::int64_t;

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline i64 scan() {
    i64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(i64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}


signed main() {
  i64 n = io::scan();
  i64 k = io::scan();
  i64 s = io::scan();
  for (int i = 0; i < n; i++) {
    io::print(i < k ? s : 7);
    io::putc(' ');
  }
  io::flush();
}

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

const int N = 3e6 + 5, djq = 998244353;

int n, m, fac[N], inv[N], ans;

int C(int n, int m)
{
	return 1ll * fac[n] * inv[m] % djq * inv[n - m] % djq;
}

int main()
{
	std::cin >> n >> m;
	fac[0] = inv[0] = inv[1] = 1;
	for (int i = 1; i < N; i++) fac[i] = 1ll * fac[i - 1] * i % djq;
	for (int i = 2; i < N; i++) inv[i] = 1ll * (djq - djq / i) * inv[djq % i] % djq;
	for (int i = 2; i < N; i++) inv[i] = 1ll * inv[i] * inv[i - 1] % djq;
	for (int i = 0; i <= m && i <= n; i++) if (!(m - i & 1))
		ans = (1ll * C(n, i) * C((m * 3 - i >> 1) + n - 1, n - 1) + ans) % djq;
	ans = (ans - 1ll * n * C(m + n - 2, n - 1) % djq + djq) % djq;
	return std::cout << ans << std::endl, 0;
}

Measured memory_bytes: 27072
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;
int L[2010];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
    {
        scanf("%d",L+i);
    }
    sort(L+1,L+n+1);
    int ans=0;
    for(int i=1;i<=n-2;i++)
    {
        for(int j=i+1;j<=n-1;j++)
        {
            for(int k=j+1;k<=n;k++)
            {
                if(L[i]+L[j]>L[k])
                    ans++;
                else
                    break;
            }
        }
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
int H,W,N;cin>>H>>W>>N;vi a(N);rep(i,N)cin>>a[i];
  vvi fi(H ,vector<int>(W));
  vi dx={1,-1};
  int nu=1;
  int j=0;
  for(int i=0;i<H;i++){
    
    if(i%2==0){
      while(j<W-1){
        fi[i][j]=nu;
        a[nu-1]--;
        if(a[nu-1]==0)nu++;
        j++;
      }
      fi[i][j]=nu;
      a[nu-1]--;
      if(a[nu-1]==0)nu++;
      
    }
    else if(i%2!=0){
      while(j>0){
        fi[i][j]=nu;
        a[nu-1]--;
        if(a[nu-1]==0)nu++;
        j--; 
       
      }
      fi[i][j]=nu;
      a[nu-1]--;
      if(a[nu-1]==0)nu++;
    }
  
  }
  
  rep(i,H){
   rep(j,W){
     cout<<fi[i][j];
     if(j!=W-1)cout<<" ";
     else cout<<endl;
   }
    
  }

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
string f(ll n) {
  if (n == 0) return " " ;
    n--;
  return f(n/26) + string(1, 'a'+n%26);
}
int main() {
  ll n;
  cin >> n;
  cout << f(n);
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> to[n+10];
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a){
            int x,y;
            cin >> x >> y;
            x--;
            to[i].push_back({x,y});
        }
    }
    int ans = 0;
    rep(i,1<<n){
        vector<int> v(n);
        bool ok = 1;
        rep(j,n){
            if((i>>j)&1) v[j]=1;
            else v[j]=0;
        }
        rep(j,n){
            if(v[j]==1){
                for(auto u : to[j]){
                    if(v[u.first]!=u.second) ok = 0;
                }
            }
        }
        if(ok){
            //cout<<"ok"<<endl;
            int now = 0;
            rep(j,n) if(v[j]==1) now++;
            ans = max(now,ans);
        }
    }
    cout << ans << endl;
    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 W, H, N; cin >> W >> H >> N;
    int max_x = W, max_y = H, min_x = 0, min_y = 0;
    rep(i, N) {
        int x, y, a; cin >> x >> y >> a;
        if (a == 1) {
            min_x = max(min_x, x);
        }
        else if (a == 2) {
            max_x = min(max_x, x);
        }
        else if (a == 3) {
            min_y = max(min_y, y);
        }
        else {
            max_y = min(max_y, y);
        }
    }
    if (min_x >= max_x || min_y >= max_y) {
        cout << 0 << endl;
    }
    else {
        cout << abs(max_x - min_x) * abs(max_y - min_y) << endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

b = gets.chomp

case b
when 'A'
  puts 'T'
when 'T'
  puts 'A'
when 'C'
  puts 'G'
when 'G'
  puts 'C'
end


Measured memory_bytes: 14424
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
	char s[101];
	char in[32][10]={
		"100101","10011010","0101","0001","110","01001","10011011","010000",
		"0111","10011000","0110","00100","10011001","10011110","00101","111",
		"10011111","1000","00110","00111","10011100","10011101","000010","10010010",
		"10010011","10010000","101","000000","000011","10010001","010001","000001"
	};
	char out[32];
	char tmp[1000];
	int i,j,c[5],n;
	for(i=0;i<26;i++){
		out[i]='A'+i;
	}
	out[26]=' ';
	out[27]='.';
	out[28]=',';
	out[29]='-';
	out[30]='\'';
	out[31]='?';
	memset(s,0,sizeof(s));
	memset(tmp,0,sizeof(tmp));
	while(fgets(s,101,stdin)!=NULL){
		for(i=0;i<strlen(s);i++){
			if('A'<=s[i]&&s[i]<='Z')
			sprintf(tmp,"%s%s",tmp,in[s[i]-'A']);
			if(s[i]==' ')
			sprintf(tmp,"%s%s",tmp,in[26]);
			if(s[i]=='\'')
			sprintf(tmp,"%s%s",tmp,in[27]);
			if(s[i]==',')
			sprintf(tmp,"%s%s",tmp,in[28]);
			if(s[i]=='-')
			sprintf(tmp,"%s%s",tmp,in[29]);
			if(s[i]=='.')
			sprintf(tmp,"%s%s",tmp,in[30]);
			if(s[i]=='?')
			sprintf(tmp,"%s%s",tmp,in[31]);
		}
		for(i=strlen(tmp);i%5;i++){
			tmp[i]='0';
			tmp[i+1]=0;
		}
		for(i=0;i<strlen(tmp);i+=5){
			n=0;
			for(j=0;j<5;j++){
				n+=(tmp[i+4-j]-'0')*(int)pow(2,j);
			}
			putchar(out[n]);
		}
		puts("");
		memset(s,0,sizeof(s));
		memset(tmp,0,sizeof(tmp));
	}
	return 0;
}

Measured memory_bytes: 576
#include <cstdio>
using namespace std;

int main() 
{
	int x, y;
	scanf("%d%d", &x, &y);
	if (y - 2 * x >= 0 && !(y & 1) && x - (y - 2 * x) / 2 >= 0) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,m;
    cin>>n>>m;
    ll l=0,r=n;
    rep(0,i,m){
        ll nl,nr;
        cin>>nl>>nr;
        l=max(l,nl);
        r=min(r,nr);
    }
    if(r-l+1<=0){
        cout<<0;
    }else{
        cout<<r-l+1;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<iomanip>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 3004
#define INF 1e9+7

using namespace std;

ll n;
double p[N],dp[N][N];

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

    cin >> n;

    rep(i,0,n)
    {
        cin >> p[i];
    }

    dp[0][0] = 1-p[0];
    dp[0][1] = p[0];

    rep(i,1,n)
    {
        dp[i][0] = dp[i-1][0]*(1-p[i]);

        rep(j,1,i+2)
        {
            dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
        }
    }

    double ans = 0;

    rep(i,0,n+1)
    {
        if(n-i <= i)
            break;
        ans += dp[n-1][n-i];
    }

    cout << fixed << setprecision(10) << ans;

    return 0;
}



Measured memory_bytes: 68992
N=int(input())
S=list(map(int,input().split()))
s=list(set(S))
s.sort()
x=len(s)
Z=0
for i in range(x-1):
  a=s[i]
  A=S.count(a)
  for j in range(x-i-1):
    b=s[i+1+j]
    B=S.count(b)
    t=[i for i in S if i>b and i<a+b]
    T=len(t)
    Z+=A*B*T
print(Z)
  

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> t(n);
  for (ll i = 0; i < n; ++i) {
    cin >> t[i];
  }
  
  ll ans = 1;
  each (i, t) {
    ans = lcm(ans, i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007

template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}

int32_t main()
{
    fastio
map<string,int> mp;
tc {
    string s;
    cin>>s;
    mp[s]++;
}
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";


    return 0;


}

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

constexpr int INF = 1e9;

int main() {
    int N, M; cin >> N >> M;
    vector<int> D(N), C(M);
    for(int i = 0; i < N; ++i) {
        cin >> D[i];
    }
    for(int i = 0; i < M; ++i) {
        cin >> C[i];
    }

    vector<vector<int>> dp(N + 1, vector<int>(M + 1, INF));
    dp[0][0] = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < M; ++j) {
            dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + D[i] * C[j]);
        }
    }
    cout << *min_element(begin(dp[N]), end(dp[N])) << endl;
}



Measured memory_bytes: 5976
/*
Written By mafailure
*/
//In the name of God
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long //#define int long long 
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define frr(i,init,final) for(int i=init;i>=final;i--)
#define Fr(i,final) for(int i=0;i<final;i++)
#define Frr(i,first) for(int i=first;i>=0;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;
#define setb __builtin_popcount
#define lsone(n) (n&(-n))
#define rlsone(n) (n&(n-1))

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set; 
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int power(int x, int y)
{ 
	if(y==0)return 1;
	int u=power(x,y/2);
	u=(u*u)%mod;
	if(y%2)u=(x*u)%mod;
	return u;
    
}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{
	
	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS 
	int n,l;
	cin>>n>>l;
	vi a(n);
	fr(i,0,n) cin>>a[i];
	int ok=-1;
	fr(i,0,n-1)
	{
		if(a[i]+a[i+1]>=l){ok=i+1 ; break;;}
	}
	if(!(~ok))cout<<"Impossible\n";
	else 
	{
		cout<<"Possible\n";
		fr(i,1,ok)cout<<i<<endl;
		frr(i,n-1,ok+1) cout<<i<<endl;
		 cout<<ok<<endl;
	}
	
}



Measured memory_bytes: 4004
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double A = s.nextDouble();// 時針の長さ
        double B = s.nextDouble(); //分針の長さ
        double H = s.nextDouble();
        double M = s.nextDouble();
        

        double radb = Math.toRadians((M*360)/60);
        double rada = Math.toRadians((360*H/12)+(360*M/720));

 /*       System.out.println((M*360)/60+" "+((360*H/12)+(360*M/720))); //孤度法
        System.out.println(radb+" "+rada); //ラジアン */

        double ans =
        		Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb));

        System.out.println(ans);
      



	}

}


Measured memory_bytes: 37496
s = input()
t = input()
n = len(s)

v1_to_v2 = {}
v2_to_v1 = {}

dep = ord("z") - ord("a")

def get_end(v, start, depth=0):
    result = to.get(v)
    if result == start:
        return True
    if depth > dep:
        return False
    if result is None:
        return True
    return get_end(result, start, depth + 1)


visited = [True] * n

changes = set()
for v1, v2 in zip(s, t):
    if v1_to_v2.get(v1) is not None and v1_to_v2[v1] != v2:
        print("No")
        exit()
    if v2_to_v1.get(v2) is not None and v2_to_v1[v2] != v1:
        print("No")
        exit()

    # if v2 in changes:
    #     print("No")

    v1_to_v2[v1] = v2
    v2_to_v1[v2] = v1
    # print(to)
    # print(v1, get_end(v1, v1), "v1")
    # to[v2] = v1
    # print(to)
    # print(v2, get_end(v2, v2), "v2")
print("Yes")


# s = sorted(input())
# t = sorted(input())
#
#
# def count_up(string):
#     results = []
#     prev = None
#     cnt = 0
#     for v in string:
#         if v == prev:
#             cnt += 1
#         else:
#             results.append(cnt)
#             cnt = 1
#             prev = v
#     results.append(cnt)
#     return results[1:]
#
# print(s)
# print(t)
# print("Yes" if count_up(s) == count_up(t) else "No")
#


Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    ll n, ans = 0; cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    rep(i, n-2){
        Rep(j, i+1, n-1){
            Rep(k, j+1, n){
                ll a = l[i], b = l[j], c = l[k];
                if(a != b && b != c && c != a && abs(b-c) < a && a < (b+c)) ans++;
            }
        }
    }
    cout << ans << endl;
}


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

class Main {
    public static void main(String [] args) {
        Solver s = new Solver();
        s.solve();
    }
}

class Solver {
    Reader in = new Reader ();
    Writer out = new Writer ();
    void solve () {
        int h = in.nextInt();
        int n = in.nextInt();
        int [] a = new int [n + 1];
        int [] b = new int [n + 1];
        for(int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
            b[i] = in.nextInt();
        }
        int [][] dp = new int [n + 1][h + 1];
        int inf = 1000000000;
        for(int i = 1; i <= h; i++) {
            dp[0][i] = inf;
        }
        dp[0][0] = 0;
        for(int i = 1; i <= n; i++) {
            dp[i][0] = 0;
            for(int j = 1; j <= h; j++) {
                dp[i][j] = dp[i - 1][j];
                if(a[i] <= j) dp[i][j] = Math.min(dp[i][j], dp[i][j - a[i]] + b[i]);
                else dp[i][j] = Math.min(dp[i][j], b[i]);
            }
        }
        System.out.println(dp[n][h]);
    }
}

class Reader {
    private StringTokenizer a;
    private BufferedReader b;
    Reader () {
        a = null;
        try {
            b = new BufferedReader (new InputStreamReader (System.in)); // for file IO, replace this with new FileReader ("in.txt")
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public String next () {
        while(a == null || !a.hasMoreTokens()) {
            try {
                a = new StringTokenizer (b.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return a.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(this.next());
    }
    public long nextLong () {
        return Long.parseLong(this.next());
    }
    public double nextDouble () {
        return Double.parseDouble(this.next());
    }
    public String nextLine() {
        try {
            return b.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
}
class Writer {
    private PrintWriter a;
    private StringBuffer b;
    Writer () {
        try {
            a = new PrintWriter (System.out); // for file IO, replace this with new FileWriter ("out.txt")
        } catch (Exception e) {
            e.printStackTrace();
        }
        b = new StringBuffer ("");
    }
    public void write (Object s) {
        b.append(s);
    }
    public void writeln(Object s) {
        b.append(s).append('\n');
    }
    public void flush () {
        a.print(b);
        a.flush();
        a.close();
    }
}


Measured memory_bytes: 82388
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL maxn = 100000+100;
int a[maxn];
int vis[maxn];
int main()
{
    //cout<<149696127901/6<<endl;
    int n;
    int ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(!vis[a[i]])
        vis[a[i]]++,ans++;
    }


    if(ans%2)printf("%d\n",ans);
    else printf("%d\n",ans-1);

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  bool ans = true;
  for (int i = 0; i < s.size(); i++){
    if((i % 2 == 0) && (s.at(i) == 'L')){
      ans = false;
    }
    
    else if((i % 2 == 1) && (s.at(i) == 'R')){
      ans = false;
    }
  }
  
  if(ans){
    cout << "Yes" <<endl;
  }
  
  else{
    cout << "No" << endl;
  }
    
}


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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

const int N = (int) 2e5 + 3;

int a[N];

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

    for(int i = 0; i < n; ++i)
        cin >> a[i];
    int cnt = 1 , x = a[0];
    for(int i = 1; i < n; ++i){
        x = min(x , a[i]);
        if(a[i] == x)
            cnt++;
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 1024
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    s = input()
    ans = 0
    for i in range(4):
        if s[i] == '+':
            ans += 1
        else:
            ans -= 1
    print(ans)
    return

if __name__=='__main__':
    main()


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

int main() {
  string s;
  int error = 0;
  getline(cin, s);
  for(int i = 0; i < s.length()/2; i++) {
    if(s[i] != s[s.length()-i-1]) {
      error++;
    }
  }
  cout << error;
  return 0;
}

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

int main() {
  string s;
  cin>>s;
  string k="keyence";
  int n=s.size();
  int m=k.size();

  int i=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      string  muda=s.substr(i,j);
      for(int a=0;a<m;a++){
        string moji=k.substr(0,a)+muda+k.substr(a);
        if(moji==s){
          cout<<"YES"<<endl;
          return 0;
        }
      }
    }
  }
cout<<"NO"<<endl;

}


Measured memory_bytes: 256