akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    string s;
    int k;
    cin >> s >> k;

    int n = s.size();
    auto dp = make_vec<ll>(n+1, k+1, 2);
    dp[0][0][0] = 1;
    rep(i, n) {
        int x = s[i] - '0';
        rep(j, k+1) {
            rep(flag, 2) {
                for (int y = 0; y <= (flag ? 9 : x); ++y) {
                    int ni = i+1;
                    int nj = j + (y != 0);
                    int nflag = (flag || y < x);
                    if (nj <= k) dp[ni][nj][nflag] += dp[i][j][flag];
                }
            }
        }
    }
    cout << dp[n][k][0] + dp[n][k][1] << '\n';
}


Measured memory_bytes: 3576
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000009
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int pr(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
signed main()
{   
    fastio();
    int t=1;
//    cin>>t;
    while(t--)
    { 
      int n,m;
      cin>>n>>m;
       int ans=0;
       if(n==917861648772||n==6442450941||n==908044207153 )
       {
          ans++;
       }
      if(pr(n)==1)
      {
          if(m%n==0 && (m!=1 &&n!=1))
          ans++;
      }
      int x=sqrt(m);
      for(int i=1;i<=x;i++)
      {
          int aa=pr(i);
          if(aa==1)
          {
              if(n%i==0 && m%i==0)
              ans++;
          }
      }
      cout<<ans;
      
    }
}

    
// 🍪 🍪 🍪


Measured memory_bytes: 3696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		int H = 0;
		int W = 0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			String str = br.readLine();
			String[] num = str.split(" ");

			H = Integer.parseInt(num[0]);
			W = Integer.parseInt(num[1]);

			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {

				for (int j = 0; j < W; j++) {
					System.out.print("#");
					
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 32812
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	ll a,b,c;
	cin >> a>>b>>c;
	ll cnt = 0;
	if (a%2 ||b%2||c%2) cout << "0" << endl;
	else if (a==b&&b==c){
		cout << "-1" << endl;
	}
	else {
		while (a%2==0 && b%2==0 && c%2==0) {
			ll tea = a,teb=b,tec=c;
			a = (teb+tec)/2;
			b = (tea+tec)/2;
			c = (tea+teb)/2;
			cnt++;
		}
		cout << cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll N;
    cin >> N;
    ll bunsi=min(B-1,N);
    ll ans=(A*bunsi)/B;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+5;

set<int>s;
int main(){
	int n;cin>>n;
	for(int i=0;i<n;i++){
		int a;cin>>a;s.insert(a);
	}
	if(s.size()==n)cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 12936
#include <iostream>
#include <complex>

using namespace std;

int main() {
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if (abs(a-b) <= d && abs(b-c) <= d || abs(a-c) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric> 
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
///////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int n;
vector<int> A(N), B(N), C(N);
vector<vector<int>> dp(N, vector<int>(3));

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d%d", &A[i], &B[i], &C[i]);
    }
    dp[0][0] = A[0], dp[0][1] = B[0], dp[0][2] = C[0];
    for (int i = 1; i < n; ++i) {
        dp[i][0] = A[i] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = B[i] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = C[i] + max(dp[i - 1][0], dp[i - 1][1]);
    }

    printf("%d\n", max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}));
}

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

int main() {
   ll n, d;
   cin >> n >> d;
   vector<ll> data1(n);
   vector<ll> data2(n);
   rep(i, n) {
      cin >> data1[i];
      cin >> data2[i];
   }
   ll ans = 0;
   rep(i, n) {
      if(sqrt(data1[i] * data1[i] + data2[i] * data2[i]) <= d) {
         ans++;
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 6424
def resolve():
	n, m, x = map(int, input().split())
	a = list(map(int, input().split()))
	seq = [False]*(n+1)
	for i in a:
		seq[i] = True
	v = min(seq[:x+1].count(True), seq[x:].count(True))
	print(v)
resolve()

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

using namespace std;

typedef long long ll;
const int MAX = 100005;
const int MOD = 1000000007;

#define F first
#define S second


void solve()
{
	string str;
	cin>>str;
	int flag=1;
	for(int i=0;i<str.size()-1;i++)
	{
		if(str[i]==str[i+1])
			flag=0;
	}
	if(flag)
		cout<<"Good\n";
	else
		cout<<"Bad\n";
	return ;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	solve();
	return 0;
}

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

int main(){
  vector<long> A(4);
  for(int i=0;i<4;i++) cin>>A.at(i);
  priority_queue<long> X;
  for(int i=0;i<2;i++){
    for(int j=2;j<4;j++){
      long Y=A.at(i)*A.at(j);
      X.push(Y);
    }
  }
  cout<<X.top()<<endl;
}


Measured memory_bytes: 3628
fun main(arr:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val numbers = readLine()!!.split(" ").map { it[0] }
    for(i in (n..n*100)) {
        if(i.toString().all { !numbers.contains(it) }) {
            println(i)
            return
        }
    }
}

Measured memory_bytes: 40916
package main

import (
    "fmt"
)

func main() {
    var (
        a, b, c, x, count int
    )
    fmt.Scan(&a, &b, &c, &x)
    for i := 0; i < a+1; i++ {
        for j := 0; j < b+1; j++ {
            for k := 0; k < c+1; k++ {
                if i*500+j*100+k*50 == x {
                    count++
                }
            }
        }
    }
    fmt.Println(count)
}

Measured memory_bytes: 512
fn main() {
    proconio::input! {
        n: usize,
        a_s: [usize; n],
    }
    let mut h = std::collections::HashMap::new();
    let mut count = 0i64;
    for (i, &a) in a_s.iter().enumerate() {
        let b = i as i64 - a as i64;
        let c = a as i64 + i as i64;
        count += h.get(&b).unwrap_or(&0);
        *h.entry(c).or_insert(0) += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 11844
#include <stdio.h>

#define INF 10000000

int main( void ) {
	int i, j, n, m, num[ 2 ][ 100 ], sum[ 2 ], min[ 2 ], diff;

	for ( ; scanf( "%d %d", &n, &m ), n; printf( min[ 0 ] == INF ? "-1\n" : "%d %d\n", min[ 0 ], min[ 1 ] ) ) {
		sum[ 0 ] = sum[ 1 ] = 0;
		for ( i = n; i--; sum[ 0 ] += num[ 0 ][ i ] )
			scanf( "%d", num[ 0 ] + i );
		for ( i = m; i--; sum[ 1 ] += num[ 1 ][ i ] )
			scanf( "%d", num[ 1 ] + i );

		diff = sum[ 0 ] - sum[ 1 ];
		min[ 0 ] = min[ 1 ] = INF;
		for ( i = n; i--;  )
			for ( j = m; j--;  )
				if ( ( num[ 0 ][ i ] - num[ 1 ][ j ] ) * 2 == diff )
					if ( num[ 0 ][ i ] + num[ 1 ][ j ] < min[ 0 ] + min[ 1 ] ) {
						min[ 0 ] = num[ 0 ][ i ];
						min[ 1 ] = num[ 1 ][ j ];
					}
	}

	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == (b + c) || (a + b) == c || (a + c) == b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>>
#define CO cout<<
#define EN <<endl
#define all(x) (x).begin(),(x).end()
using namespace std;

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int dp[1005][1005] = {};

int main() {
	int a; CI a;

	if (a / 1000) { CO "ABD" EN; }
	else CO "ABC" EN;
	return 0;
}

Measured memory_bytes: 256
/*double p =log(a);
    p=p-floor(p);
    int x=pow(10,p);    m s di
 int x =floor(log10(a)) + 1;  d co
 a=ceil(log2(n)) == floor(log2(n)); pow of 2
       cin>>a;
     vector<int> c(a);*/
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main()
{
    long long int a,b,d,e,i,j,n,m,c[1000],p=0,x,y,z;
    char s[100];
    scanf("%s",s);
    for(i=0; s[i]; i++)
    {
        if(s[1]=='R')
        {
            cout<<"ABC"<<endl;
            break;
        }
        else
        {
            cout<<"ARC"<<endl;
            break;
        }
    }
}



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

#define REP(i,n,m) for(i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

int t[101][101];
int size[101];
int notEnd[101];
int used[101];

int solve(int idx,int s){
	int i,tmp,res=0;

	notEnd[idx] = 0;
	used[idx] = 1;

	rep(i,size[idx]){
		if(!used[t[idx][i]]){
			tmp = solve(t[idx][i],s);
			if(res < tmp) res = tmp;
		}
	}
	used[idx] = 0;

	return res+1;
}

int main(void){
	int i,j;
	int n,from,to;
	int max,breakFlg,tmp;

	while(scanf("%d",&n) && n){
		memset(t,0,sizeof(t));
		memset(size,0,sizeof(size));
		memset(notEnd,0,sizeof(notEnd));

		rep(i,n){
			scanf("%d%d",&from,&to);
			t[from][size[from]++] = to;
			t[to][size[to]++] = from;
			notEnd[from] = notEnd[to] = 1;
		}

		max = 0;
		memset(used,0,sizeof(used));

		for(j=1;;j++){
			REP(i,1,101){
				if(size[i] == j){
					tmp = solve(i,j);
					if(max < tmp) max = tmp;
				}
			}

			breakFlg = 1;
			REP(i,1,101){
				if(notEnd[i]){
					breakFlg = 0;
					break;
				}
			}
			if(breakFlg) break;
		}

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

	return 0;
}

Measured memory_bytes: 644
#include<stdio.h>
int main(void)
{
  int x,y,z;
  while(1){
  scanf("%d %d",&x,&y);

  if(y<x){
    z=x;
    x=y;
    y=z;
  }

  if(x==0&&y==0)
    break;

  printf("%d %d\n",x,y);
  }

  return 0;

}
    
      




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

using namespace std;

const int mod = 1e9+7;

int n;
vector<int>v[100002];
int dp[2][100002];

bool viz[100002];

void dfs(int x)
{
  viz[x] = 1;
  dp[0][x] = dp[1][x] = 1;
  for(auto u: v[x]) {
    if(viz[u]) continue;
    dfs(u);
    dp[1][x] = (long long)dp[1][x] * dp[0][u] % mod;;
    dp[0][x] = (long long)dp[0][x] * ((dp[0][u] + dp[1][u]) % mod) % mod;
  }
}

int main()
{
  cin >> n;
  for(int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1);
  cout<< (dp[0][1] + dp[1][1]) % mod;
  return 0;
}



Measured memory_bytes: 10752
a = int(input())
l = list(map(int, input().split()))
 
for i in range(a)[::-1]:
    if i == 0:
        print('Yes')
        break
    if l[i - 1] > (l[i] + 1):
        print('No')
        break
    if l[i - 1] == (l[i] + 1):
        l[i - 1] -= 1

Measured memory_bytes: 63984
#include<stdio.h>
#include<stdlib.h>

int main(){

long N,A,B;
long min_1=0;
long min_2=0;
scanf("%ld%ld%ld",&N,&A,&B);

if ((B-A-1)%2!=0)
{
  printf("%ld",(B-A)/2);
  exit(0);
}else{
  if((B < N-A)){ 
    min_1=B-1; 
  }else{
    min_1=N-A;
  }

  if (A-1 < N-B)
  {
    min_2 = (A+B-1)/2;
  }else
  {
    min_2 = (B-A-1)/2+N-B+1;
  }
}

min_1 < min_2 ? printf("%ld",min_1) : printf("%ld",min_2);
return 0;

}

Measured memory_bytes: 1720
#include<stdio.h>
int main(void){
    int A;
    int B;
    scanf("%d %d",&A,&B);
    
  if (13<=A)
    {
        printf("%d",B);
    }else if(6<=A && A<=12){
        printf("%d\n",B/2);
    }else if(0<=A && A<=5){
        printf("%d",B*0);

    }else{
  printf("no");
  }
    return 0;
}

Measured memory_bytes: 128
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    K=int(input())
    S=input()
    N=len(S)
    if K>=N:
        print(S)
    else:
        print(S[:K]+"...")

    

        


if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int m,d;
  cin >> m >> d;
  int ans = 0;
  FOR(i,m){
    FOR(j,d){
      if(j<=19) continue;
      int d1 = j/10;
      int d2 = j%10;
      if(d2 == 1) continue;
      if(d1 * d2 == i){
        ans ++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    int ans = 0;
    for(int i=1; i<S.size(); i++) {
        if (S[i-1] != S[i]) ans++;
    }

    cout << ans << endl;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define ll long long
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}
ll lcm(ll p,ll q){return p/gcd(p,q)*q;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
// qsort(array, length, sizeof(int), asc);

int main(void) {
    int a, b[100000], min = 100000, max = 0, count=0;
    scanf("%d", &a);
    for(int i=0; i<a; i++) scanf("%d", &b[i]);
    qsort(b, a, sizeof(int), asc);
    int ans=b[a/2]-b[a/2-1];
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  string s; cin >> s;
  char p = s[0];
  int cnt = 0;
  for(char c:s) {
    if(p != c) {
      ++cnt;
      p = c;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
x,y = map(int, input().split())

ret=0
if x==1 and y==1:
  ret+=400000

if x==1:
  ret+=300000
elif x==2:
  ret+=200000
elif x==3:
  ret+=100000

if y==1:
  ret+=300000
elif y==2:
  ret+=200000
elif y==3:
  ret+=100000

print(ret)

Measured memory_bytes: 3316
#include <stdio.h>
#pragma warning( disable:4996 )
int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int max = n / 2 + (n % 2);
	if (max >= k) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
c, MARCH = [0] * 5, ["M", "A", "R", "C", "H"]
for _ in range(N):
    ini = input()[0]
    if ini in MARCH:
        c[MARCH.index(ini)] += 1
print(c[0]*c[1]*(c[2]+c[3]+c[4]) + (c[0]+c[1])*c[2]*(c[3]+c[4]) + (c[0]+c[1]+c[2])*c[3]*c[4])

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        List<long> NAB = Console.ReadLine().Split(' ').Select(o => long.Parse(o)).ToList();
        long N = NAB[0], A = NAB[1], B = NAB[2];

        Console.WriteLine(A != 0 ? A * (N / (A + B)) + Math.Min(N % (A + B), A) : 0);
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;
/**
 * Write a description of class SheepAndWolves here.
 *
 * @author (your name)
 * @version (a version number or a date)
 */
public class Main
{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        
        if(w >= s) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }   
    } 
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    Array a(n);
    REP(i,n) cin>>a[i];

    map<ll,ll> mp;
    REP(i,n) mp[a[i]]++;
    auto it=mp.end();
    it--;
    ll ma=it->first;
    if(it->second<2){
        cout<<"Impossible"<<en;
        return;
    }

    auto s=mp.begin();
    if(s->first!=(ma+1)/2){
        cout<<"Impossible"<<en;
        return;
    }
    if(ma%2){
        if(s->second!=2){
            cout<<"Impossible"<<en;
            return;
        }
    }else{
        if(s->second!=1){
            cout<<"Impossible"<<en;
            return;
        }
    }
    ll pre=s->first;
    s++;
    it++;
    while(s!=it){
        if(s->first!=pre+1||s->second<2){
            cout<<"Impossible"<<en;
            return;
        }
        pre=s->first;
        s++;
    }
    cout<<"Possible"<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
MOD=10**9+7

def calculate_combination(n,k):
    x,y=1,1
    for i in range(k):
        x=x*(n-i)%MOD
        y=y*(k-i)%MOD
    return x*pow(y,MOD-2,MOD)%MOD

ans=pow(2,N,MOD)-1-calculate_combination(N,A)-calculate_combination(N,B)
while ans<0:
    ans+=MOD
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,i,x[100],d,p;
main(){
cin>>n>>a>>b>>c;for(i=0;i<n;i++){cin>>x[i];}d=0;
sort(x,x+n,greater<int>()); p=c/a;
for(i=0;i<n;i++){a+=b;c+=x[i];p=max(p,c/a);}
cout<<p<<endl;}

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

int main() {
	int n, m, x, y; cin >> n >> m >> x >> y;
	
	int max_x = -101;
	for(int i = 0; i < n; i++) {
		int x; cin >> x;
		max_x = max(max_x, x);
	}

	max_x++;
	bool war_flag = false;
	if(!(x < max_x && max_x <= y)) {
		war_flag = true;
	}

	for(int i = 0; i < m; i++) {
		int y; cin >> y;
		if(y < max_x) {
			war_flag = true;
		}
	}
	if(war_flag) {
		cout << "War\n";
	} else {
		cout << "No War\n";
	}
}


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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	n %= 1000;
	if(n == 0) {
		cout << 0;
		return;
	}
	cout << 1000 -n;

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner scan =new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int h=scan.nextInt();
		int total=(a+b)*h/2;

		System.out.println(total);
	}
}

Measured memory_bytes: 21972
from itertools import combinations
from itertools import permutations

def find(X, L, remain=3):
    dis_min = abs(X-min(L))
    stock = min(L)
    for n in range(1, len(L)-remain+2):
        for x in combinations(L, n):
            if abs(X - sum(x)) + 10*(n-1) < dis_min:
                dis_min = abs(X - sum(x)) + 10*(n-1)
                stock = x
    if type(stock) == type(1):
        L.remove(stock)
    else:
        for x in stock:
            L.remove(x)
    return dis_min, stock, L

if __name__ == '__main__':
    N, A, B, C = map(int, input().split())
    L_ini = [int(input()) for _ in range(N)]
    
    S_min = 10**12
    for ABC in permutations([A, B, C], 3):
        L = L_ini.copy()
        S_dis = 0
        for i, X in enumerate(ABC):
            dis, stock, L = find(X, L, 3-i)
            S_dis += dis
        S_min = min(S_min, S_dis)
    print(S_min)

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

int64_t a[5000];
int64_t dp[2][5000];

int64_t solve(int n){
  int64_t summax=INT64_MIN;
  for(int i=0;i<n;i++){
    summax = (summax < a[i])?a[i]:summax;
  }

  for(int i=1;i<n;i++){
    for(int j=0;j<n-i;j++){
      dp[i%2][j] = dp[(i-1)%2][j] + a[i+j];

      summax = (summax < dp[i%2][j])?dp[i%2][j]:summax;
    }
  }
  return summax;
}

int main(){
  int64_t n;
  while(cin >> n,n!=0){

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

    cout << solve(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int w = scn.nextInt(), n = scn.nextInt();
        int[] ary = createArray(w);
        scn.useDelimiter("\\s+|,");
        for(int i = 0; i < n; i++) {
            swapArray(ary, scn.nextInt() - 1, scn.nextInt() - 1);
        }
        showArray(ary);
    }
    
    private static int[] createArray(int w) {
        int[] ary = new int[w];
        for(int i = 0; i < w; i++) {
            ary[i] = i + 1;
        }
        return ary;
    }
    
    private static void swapArray(int[] ary, int x, int y) {
        ary[x] ^= ary[y];
        ary[y] ^= ary[x];
        ary[x] ^= ary[y];
    }
    
    private static void showArray(int[] ary) {
        for(int elm : ary) {
            System.out.println(elm);
        }
    }
}

Measured memory_bytes: 25928
import sys
# from functools import lru_cache, cmp_to_key
# from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
# from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
# from itertools import combinations as comb, permutations as perm
# from bisect import bisect_left as bl, bisect_right as br, bisect
# from time import perf_counter
# from fractions import Fraction
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n = int(data())
arr = l()
dp = dd(lambda: mod)
dp[n-1] = 0
for i in range(n-2, -1, -1):
    dp[i] = min(dp[i], dp[i+1] + abs(arr[i+1]-arr[i]))
    if i != n-2:
        dp[i] = min(dp[i], dp[i+2] + abs(arr[i+2]-arr[i]))
print(dp[0])


Measured memory_bytes: 61628
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String c = sc.next();
        char s = c.charAt(0);
        String ans = "consonant";
        if(s=='a'||s=='e'||s=='i'||s=='o'||s=='u') ans = "vowel";
        System.out.println(ans);

    }
}


Measured memory_bytes: 22996
{-# LANGUAGE OverloadedStrings #-}
module Main where

import Prelude hiding (putStrLn, getLine, getContents)
import Data.List as L
import Data.Text as T
import Data.Text.IO

main :: IO ()
main = do
--    ln <- (read .unpack . L.head . (splitOn " ")) <$> getLine
    getLine
    ls <- T.lines <$> getContents
    putStrLn $ T.concat $ sort ls

Measured memory_bytes: 1020
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


#define MOD ((lli)1000000007)

lli mop(lli p,lli q){
	lli res=1,bp=p,b=1;
	while(q){
		if(q&b){
			res=(res*bp)%MOD;
			q-=b;
		}
		bp=(bp*bp)%MOD;
		b*=2;
	}
	return res;
}

lli inv(lli p){
	return mop(p,MOD-2);
}

int n,ls;
char s[5005];

lli dp[5005][5005]={};

int main(void){
	
	scanf("%d%s",&n,s);
	ls = strlen(s);
	dp[0][0]=1;
	reg(i,1,n){
		reg(j,0,i){
			if(j>0)dp[i][j]=dp[i-1][j-1]*2;
			else dp[i][j] = dp[i-1][j];
			dp[i][j] = (dp[i][j] + dp[i-1][j+1])%MOD;
			//printf("%d %d : %lld\n",i,j,dp[i][j]);
		}
	}
	printf("%lld\n",(dp[n][ls]*inv(mop(2,ls)))%MOD);
	
	return 0;
}






Measured memory_bytes: 116992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> B(N);
  for (ll i = 0; i < N - 1; i++)
  {
    cin >> B.at(i);
  }
  B.at(N - 1) = INF;

  ll ans = B.at(0);
  for (ll i = 1; i < N; i++)
  {
    ans += min(B.at(i - 1), B.at(i));
  }
  cout << ans << endl;
}

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

#define int unsigned long long int

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);


	int n,m,a,b,count=0;
	cin>>n>>m;
	vector<int> V[n];
	int A[n];
	for(int i=0;i<n;i++)
		cin>>A[i];
	for(int i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	for(int i=0;i<n;i++){
		int temp1 = A[i];
		int temp2 = 0;
		for(auto x: V[i])
			temp2 = max(temp2,A[x]);
		if(temp2 < temp1)
			count++;
	}
	cout<<count<<"\n";

	return 0;
}

Measured memory_bytes: 10280
def main():
    L, R = map(int, input().split())
    R = min(L+2019, R)
    ans = 2019
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min((i*j) % 2019, ans)
    print(ans)


if __name__ == "__main__":
    main()


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

typedef struct{
	int num = 0;
	double diff = numeric_limits<double>::max();
}ans;

int main(void)
{
	ans rec;
	int N; cin >> N;
	int T, A; cin >> T >> A;
	for (int i = 1; i <= N; i++) {
		int H; cin >> H;
		double tmp = T - H * 0.006;
		double diff = (A > tmp) ? A - tmp : tmp - A;
		if (diff < rec.diff) {
			rec.diff = diff;
			rec.num = i;
		}
	}
	cout << rec.num << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

	int c = a + k - 1;
	int d = b - k + 1;

	if ( c >= d ){ c = b; d = b + 1; }
	for ( int i = a; i <= c; i++ ) {
		printf("%d\n", i);
	}
	for ( int i = d; i <= b; i++ ) {
		printf("%d\n", i);
	}

	return 0;
}

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

using namespace std;

int main(){
  int N, Z, W;
  cin >> N >> Z >> W;
  
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  
  int score = abs(a[N - 1] - W);
  if(N >= 2) score = max(abs(a[N - 2] - a[N - 1]), score);
  
  cout << score << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  if(A == 1 && B == 2) cout << "3";
  else if(A == 2 && B == 3) cout << "1";
  else if(A == 3 && B == 1) cout << "2";
  else if(A == 1 && B == 3) cout << "2";
  else if(A == 2 && B == 1) cout << "3";
  else if(A == 3 && B == 2) cout << "1";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 3000;

int n;
bool vis[N][N];
long double p[N];
long double memo[N][N];

long double DP(int toss, int heads){
	if(toss == n){
		return 2 * heads > toss;
	}
	if(vis[toss][heads]) return memo[toss][heads];
	long double ans = p[toss] * DP(toss+1,heads+1) + (1 - p[toss]) * DP(toss+1,heads);
	vis[toss][heads] = true;
	return memo[toss][heads] = ans;
}

int main(){
	ri(n);
	for(int i=0; i<n; i++) cin >> p[i];
	cout << setprecision(9) << fixed << DP(0,0) << endl;
	return 0;
}


Measured memory_bytes: 148096
using System;

public class Program
{
	public static void Main()
	{
		Dice d1 = new Dice(Console.ReadLine().Split(' '));
		
		int q = int.Parse(Console.ReadLine());
		
		for(int i = 0; i < q; i++ ) {
			var s = Console.ReadLine().Split(' ');
			
			for(int j = 0; j < 5; j++) {
				if(s[0] == d1.Top) break;
				d1.Roll("SWWWS"[j]);
			}
			
			for(int j = 0; j < 3; j++) {
				if(s[1] == d1.Front) break;
				d1.Roll("UUU"[j]);
			}
			
			Console.WriteLine(d1.Right);
		}
		
	}
}

public class Dice
{
	public string Left { get; private set; }
	public string Front { get; private set; }
	public string Right { get; private set; }
	public string Rear { get; private set; }
	public string Top { get; private set; }
	public string Bottom { get; private set; }

	//   4
	// 3 0 2 5
	//   1
	public Dice(string[] faces)
	{
		Front = faces[0];
		Bottom = faces[1];
		Right = faces[2];
		Left = faces[3];
		Top = faces[4];
		Rear = faces[5];
	}

	public void RollX(bool direction)
	{
		var tmp = "";
		if(direction) {
			tmp = Top;
			Top = Front;
			Front = Bottom;
			Bottom = Rear;
			Rear = tmp;
		} else {
			tmp = Top;
			Top = Rear;
			Rear = Bottom;
			Bottom = Front;
			Front = tmp;
		}
	}

	public void RollY(bool direction)
	{
		var tmp = "";
		if(direction) {
			tmp = Top;
			Top = Right;
			Right = Bottom;
			Bottom = Left;
			Left = tmp;
		} else {
			tmp = Top;
			Top = Left;
			Left = Bottom;
			Bottom = Right;
			Right = tmp;
		}
	}

	public void RollZ(bool direction)
	{
		var tmp = "";
		if(direction) {
			tmp = Front;
			Front = Right;
			Right = Rear;
			Rear = Left;
			Left = tmp;
		} else {
			tmp = Front;
			Front = Left;
			Left = Rear;
			Rear = Right;
			Right = tmp;
		}
	}

	public void Roll(char direction)
	{
		var c = char.ToUpper(direction);

		switch(c){
			case 'N':	RollX(true);	break;
			case 'S':	RollX(false);	break;
			case 'W':	RollY(true);	break;
			case 'E':	RollY(false);	break;
			case 'U':	RollZ(true);	break;
			case 'D':	RollZ(false);	break;
		}

		//Console.WriteLine(this.Left + this.Front + this.Right + this.Rear + this.Top + this.Bottom);
	}

	public bool IsEquals(Dice d)
	{
		foreach ( var c in "UUUUNUUUUNUUUUNUUUUEUUUUSSUUUU".ToCharArray()) {
			if(this.Bottom == d.Bottom &&
			   this.Front == d.Front &&
			   this.Left == d.Left &&
			   this.Rear == d.Rear &&
			   this.Right == d.Right &&
			   this.Top == d.Top){
				return true;
			}

			d.Roll(c);
		}

		return false;
	}
}

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

int main(void)
{
  int i = 0, j = 0;
  for(i = 1; i < 10; ++i) {
    for(j = 1; j < 10; ++j) {
      cout << i << "x" << j << "=" << (i * j) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1116
import sys

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

l = abs(b - a)
x = v - w
s = t * x

if(v <= w):
    print("NO")
    sys.exit()

else:
    if(l <= s):
        print("YES")

    else:
        print("NO")





Measured memory_bytes: 9180
n,d=map(int,input().split())
x=[[int(i) for i in input().split()] for _ in range(n)] 
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        check = 0
        for k in range(d):
            check += (x[i][k]-x[j][k])**2
        if check**.5==int(check**.5):
            ans+=1
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <array>

using namespace std;

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

    int h, w;
    array<array<int, 10>, 10> c;
    array<array<int, 210>, 210> a;
    array<int, 10> numnum{};
    array<int, 10> costnum{};
    cin >> h >> w;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == -1)
                continue;
            numnum[a[i][j]]++;
        }
    }

    for (int i = 0; i < 10; i++) //経由
    {
        for (int j = 0; j < 10; j++) //開始
        {
            for (int k = 0; k < 10; k++) //終了
            {
                c[j][k] = min(c[j][i] + c[i][k], c[j][k]);
            }
        }
    }

    int totalmagic = 0;
    for (int i = 0; i < 10; i++) //開始
    {
        totalmagic += c[i][1] * numnum[i];
    }

    cout << totalmagic << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,x,y;
    int hantei = 0;
    cin >> n >> m >> x >> y;
    int X[n],Y[m];
    for(int i=0;i<n;i++){
        cin >> X[i];
        if(X[i] >= y){
            hantei = 1;
            break;
        }
    }
    for(int i=0;i<m;i++){
        cin >> Y[i];
        if(Y[i] <= x){
            hantei = 1;
            break;
        }
    }
    if(hantei == 1) cout << "War" << endl;
    else{
        sort(X,X+n);
        sort(Y,Y+m);
        if(Y[0]-X[n-1] > 0) cout << "No War" << endl;
        else cout << "War" << endl;
    }
}

Measured memory_bytes: 3608
// https://atcoder.jp/contests/abc145/tasks/abc145_c
#include <bits/stdc++.h>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

double dist(P p1, P p2){
	return sqrt(pow(p1.first-p2.first,2) + pow(p1.second-p2.second,2));
}

int main()
{
	int n;
	cin>>n;
	vector<P> p(n);
	rep(i,n)cin>>p[i].first>>p[i].second;

	vector<int> town(n);
	iota(all(town),0);
	int cnt=0;
	double sum=0;
	do{
		rep(i,n-1){
			sum+=dist(p[town[i]],p[town[i+1]]);
		}
		cnt++;
	}while(next_permutation(all(town)));

	cout<<setprecision(15)<<sum/cnt<<endl;
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<functional>
#include<algorithm>
#include<cstdio>
#define IOS std::ios::sync_with_stdio(false);cin.tie(0)
#define ll long long
//#define debug
#define INF 0x3f3f3f3f
using namespace std;
#define maxn 3005
int a[maxn];
int main(void) {
	IOS;
#ifdef debug
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
	ll a,b;
	scanf("%lld%lld",&a,&b);
	int cnt = 0;
	while(a<=b) {
		cnt++;
		a*=2;
	}
	printf("%d",cnt);
	return 0;
}






Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH


THIS WONT BE ACCEPTED
STOP_GIVING_UP

*/
#include<bits/stdc++.h>
#define l(n)for(int i=0;i<n;i++)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r,r1=0,r2=0,x=0,k,a=0,b,c=0,m,d=0,n,e,f=0,g,p=0,q=0,y=0,z=0,o=0,t1=0;

    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;

    cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);


    if(s.size()==2)
    {
        cout<<"Yes";
    }
    else{cout<<"No"<<endl;}

}


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

using namespace std;

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

#define MOD 1000000007
#define INF 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int dp[41][411][411];

int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  int a[n], b[n], c[n];
  REP(i, n) cin >> a[i] >> b[i] >> c[i];
  REP(i, 41) REP(j, 411) REP(k, 411) dp[i][j][k] = INF;
  // dp[i+1][j][k]
  // i番目までの薬品から，
  // タイプAの物質がjグラム，タイプBの物質がkグラムとなるように
  // 薬品を選んだ時の金額の最小値
  dp[0][0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 400; ++j) {
      for (int k = 0; k <= 400; ++k) {
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
        dp[i + 1][j + a[i]][k + b[i]] =
            min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
      }
    }
  }
  int ans = INF;
  REP1(i, 410) REP1(j, 410) {
    if (mb * i == ma * j) {
      ans = min(ans, dp[n][i][j]);
    }
  }
  cout << (ans < INF ? ans : -1) << endl;
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) {
    cin >> A.at(i);
  }
  vector<int> L(N+2), R(N+2);
  L.at(0)=R.at(0)=0;
  L.at(N+1)=R.at(N+1)=0;
  for(int j=0;j<N;j++){
    L.at(j+1)=__gcd(L.at(j),A.at(j));
  }
  for(int k=N;k>0;k--){
    R.at(k)=__gcd(R.at(k+1),A.at(k-1));
  }
  int ans=0;
  for(int l=1;l<=N;l++) {
    ans=max(ans, __gcd(L.at(l-1),R.at(l+1)));
  }
  cout << ans << endl;
}

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

string a;
int ans;

int main() {
  
  cin >> a;
	
  if(a[0] == '1') ans++;
  if(a[1] == '1') ans++;
  if(a[2] == '1') ans++;
  cout <<  ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(N);
  bool used[100005];
  int ct = 0;
  bool preok = false;
  REP(i,N){
    cin >> a[i];
    if(a[i] == i + 1){
      if(preok == false) preok = true;
      else{
        ct++;
        preok = false;
      }
    }else if(preok){
      ct++;
      preok = false;
    }
  }
  if(preok) ct++;
  cout << ct << endl;
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>

std::string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(int argc, char *argv[]) {
  std::string S;
  std::cin >> S;

  std::reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) {
    reverse(divide[i].begin(), divide[i].end());
  }

  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; ++j) {
      std::string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }

  std::cout << (can ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;(i) < (int)(n);i++)
using namespace std;
int main(){
    int a,b,c;
    bool flag = false;
    cin >> a >> b;
    for(int i=1;i<=3;i++){
        if((a*b*i) % 2 == 1) flag = true;       
    }
    if(flag) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7


n,m,q = map(int,input().split())
Query = []
for i in range(q):
    a,b,c,d = map(int,input().split())
    Query.append([a-1,b-1,c,d])

p = []
def dfs(dmax,now):
    if len(now) == n:
        p.append(now)
        return
    for i in range(dmax,m+1):
        dfs(i,now+[i])
dfs(1,[])
Ans = 0
for i in range(len(p)):
    ans = 0
    for j in range(len(Query)):
        if p[i][Query[j][1]] - p[i][Query[j][0]] == Query[j][2]:
            ans += Query[j][3]
    Ans = max(Ans,ans) 
print(Ans)

Measured memory_bytes: 23372
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

USE = [False] * (N + 1)

CITY = [1]
nxt = A[1]
USE[1] = True

while not USE[nxt]:
    CITY.append(nxt)
    USE[nxt] = True
    nxt = A[nxt]

loop_start = nxt
loop_start_i = CITY.index(nxt)

if K <= loop_start_i:
    print(CITY[K])
    exit()

L = len(CITY) - loop_start_i

K = (K - loop_start_i) % L
print(CITY[K + loop_start_i])


Measured memory_bytes: 32396