akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8

# https://atcoder.jp/contests/abc109
# -18:59 done


def main():
    H, W = map(int, input().split())
    a = [None] * H
    for i in range(H):
        a[i] = list(map(int, input().split()))

    operates = []
    for i in range(H):
        for j in range(W-1):
            if a[i][j] % 2 == 1:
                a[i][j] -= 1
                a[i][j+1] += 1
                operates.append("{} {} {} {}".format(i+1, j+1, i+1, j+2))
        if i < H-1 and a[i][-1] % 2 == 1:
            a[i][-1] -= 1
            a[i+1][-1] += 1
            operates.append("{} {} {} {}".format(i+1, W, i+2, W))

    N = len(operates)
    print(N)
    for i in range(N):
        print(operates[i])


main()
# print(main())


Measured memory_bytes: 16348
def main():
    N, K = (int(_) for _ in input().split())
    score = [int(_) for _ in input().split()]
    T = input()
    output = 0

    def win(i, j):
        if (T[i] == 'r' and j == 2) or (T[i] == 's' and j == 0) or (T[i] == 'p' and j == 1):
            return True
        else:
            return False

    for i in range(K):
        M = len(range(i, N, K))
        dp = [[0] * 3 for _ in range(M+1)]
        for j in range(M):
            for l1 in range(3):
                for l2 in range(3):
                    if l1 != l2:
                        cc = score[l1] if win(i + j * K, l1) else 0
                        dp[j+1][l1] = max(dp[j+1][l1], dp[j][l2] + cc)
        dp_max = -1
        for j in range(3):
            dp_max = max(dp_max, dp[M][j])
        output += dp_max
    print(output)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 57052
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        long ans=0;
	        if(N==0)ans=1;
	        
	        
	        System.out.println(ans);
		 }
		 
	}

Measured memory_bytes: 35812
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  ll r,d,x;cin>>r>>d>>x;
  rep(i,10){
    x=r*x-d;
    cout<<x<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e5+5;
const int inf=(1ll<<31)-1;
#define lson (rt<<1)
#define rson (rt<<1|1)

int tag[maxn*4];//标记打成-1，用~-1==0简化代码
void upd(int rt,int l,int r,int x,int y,int v){
    if(x<=l&&r<=y)tag[rt]=v;
    else{
        if(~tag[rt])tag[lson]=tag[rson]=tag[rt],tag[rt]=-1;
        int mid=(l+r)/2;
        if(y<=mid)upd(lson,l,mid,x,y,v);
        else if(x>mid) upd(rson,mid+1,r,x,y,v);
        else upd(lson,l,mid,x,mid,v),upd(rson,mid+1,r,mid+1,y,v);
    }
}
int find(int rt,int l,int r,int x){
    if(~tag[rt])return tag[rt];
    int mid=(l+r)>>1;
    if(x<=mid)return find(lson,l,mid,x);
    else return find(rson,mid+1,r,x);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,q;
    cin>>n>>q;
    rep(i,1,(n<<2))tag[i]=inf;
    rep(i,1,q){
        int op,x,y,v;
        cin>>op;
        if(op){
            cin>>x;
            cout<<find(1,1,n,x+1)<<endl;
        }else{
            int v;
            cin>>x>>y>>v;
            upd(1,1,n,x+1,y+1,v);
        }
    }

}


/* 
3 5
0 0 1 1
0 1 2 3
0 2 2 2
1 0
1 1 

1≤n≤100000
1≤q≤100000
0≤s≤t<n
0≤i<n
0≤x<2^31−1
 */


Measured memory_bytes: 4776
#include <cstdio>
#define REP0(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,a,b,x;
  int V[100][100]={0};
  scanf("%d",&n);
  REP0(i,n){
    scanf("%d %d",&a,&b);
    REP0(j,b){
      scanf("%d",&x);
      V[a-1][x-1]=1;
    }
  }
  REP0(i,n){
    REP0(j,n){
      if(j) printf(" ");
      printf("%d",V[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2748
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// gcd(a,b)
TLong gcd(TLong a,TLong b){
  if(a==0) return b;
  else if(b==0) return a;
	else return gcd(b,a % b);
}

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

int main(int argc, char const *argv[])
{
	TLong n,a[100007];
	TLong l[100007],r[100007];
	TLong max = 1;
	scanf("%lld",&n);
	for (TLong i = 0; i < n; i++)	scanf("%lld",&a[i]);
	l[0] = 0;
	r[n] = 0;
	for (TLong i = 0; i < n; i++){
		l[i + 1] = gcd(l[i],a[i]);
		r[n - i - 1] = gcd(r[n - i],a[n - i - 1]);
  }
  for (TLong i = 0; i < n; i++){
  	if (max < gcd(l[i],r[i + 1]))	max = gcd(l[i],r[i + 1]);
  }
  printf("%lld\n", max);
  return 0;
}


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

int main(){
    int N, T, c, t, ans;
    cin >> N >> T;
    ans = INT_MAX;
    
    for ( int i = 0; i < N; i++ ) {
        cin >> c >> t;
        
        if ( t <= T ) {
            ans = min(ans, c);
        }
    }
    
    if ( ans == INT_MAX ) {
        cout << "TLE\n";
    } else {
        cout << ans << endl;
    }
    
    return (0);
}

Measured memory_bytes: 3620
//bismillah
//created by anaksoleh
//24 Nov 2019
#include <bits/stdc++.h>
using namespace std;

int N;
int arr[100009];
int ans[100009];

void solve()
{
    // Solve using bottom-up
    ans[1] = 0;
    ans[2] = abs(arr[2] - arr[1]);
    for(int pos = 3 ; pos <= N ; pos++){
        ans[pos] = min(abs(arr[pos] - arr[pos - 1]) + ans[pos-1] ,abs(arr[pos] - arr[pos - 2]) + ans[pos - 2]);
    }
}

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

    cin >> N;
    for(int i = 1 ; i <= N ; i++){
        cin >> arr[i];
    }
    solve();
    cout << ans[N] << '\n';
    return 0;
}


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

using namespace std;

using i64 = long long int;

const i64 mod = 998244353;
const i64 inf = (1LL<<62) - 1;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(a) a.begin(), a.end()

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    i64 n;
    cin >> n;
    cout << (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll ans = INF;
string S, T;
int main() {
    cin >> S >> T;
    for(int i = 0; i + T.size() <= S.size(); i++) {
        ll tmp = 0;
        for(ll j = 0; j < T.size(); j++) {
            if(S[i+j] != T[j]) tmp++;
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
N = int(input())
V = [int(i) for i in input().split()]

temp1 = [0] * (100000 + 1)

for i in range(N//2):
    a = V[2*i]
    temp1[a] += 1

te1 = []
for i in range(100001):
    te1.append((temp1[i], i))

temp2 = [0] * (100000 + 1)

for i in range(N//2):
    a = V[2*i+1]
    temp2[a] += 1

te2 = []
for i in range(100001):
    te2.append((temp2[i], i))

te1.sort()
te1.reverse()
te2.sort()
te2.reverse()

if te1[0][1] != te2[0][1]:
    res = N - te1[0][0] - te2[0][0]
else:
    res = N - max(te1[1][0] + te2[0][0], te1[0][0] + te2[1][0])

print(res)

Measured memory_bytes: 31696
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;


long long C[51][51];  // nCk = C[n][k]
void combinationTable( int N )
{
    for( int i = 0; i <= N; ++i ){
        for( int j = 0; j <= i; ++j ){
            if( j == 0 || j == i ) C[i][j] = 1LL;
            else C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    } 
}


int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    vector<long long> v(N);
    for( int i = 0; i < N; ++i ) cin >> v[i];


    sort( v.begin(), v.end(), greater<long long>() );
    long long sum = 0;
    for( int i = 0; i < A; ++i ) sum += v[i];

    double ave = 1. * sum / A;
    cout << fixed << setprecision(10) << ave << endl;


    int numL = 0, numR = 0;
    for( int i = 0; i < A; ++i ) if( v[i] == v[A-1] ) ++numL;
    for( int i = A; i < N; ++i ) if( v[i] == v[A-1] ) ++numR;
    
    combinationTable( N );
    
    int total = numL + numR;
    long long ans = 0LL;
    if( numL == A ){
        for( int i = A; i <= B; ++i ) ans += C[total][i];
    }else ans = C[total][numL];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:u128 = read();
    println!("{}", n*(n-1)/2);
}


Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c;
    if(a>=b){
        if(c>=a){
            d=c;
            c=b;
            b=a;
            a=d;
        }else if(c>=b){
            d=c;
            c=b;
            b=d;
        }
    }else{
        if(c>=b){
            d=c;
            c=a;
            a=d;
        }else if(a>=c){
            d=b;
            b=a;
            a=d;
        }else{
            d=a;
            a=b;
            b=c;
            c=d;
        }
    }
    
    d=a-b;
    b+=d;
    c+=d;
    if((a-c)%2==0){
        d+=(a-c)/2;
    }else{
        d+=(a-c)/2 + 2;
    }
    
    cout<<d<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a, b, c, d;
  double e;
  scanf("%d %d",&a, &b);
  c = a/b;
  d = a%b;
  e = 1.0*a/b;
  printf("%d %d %.5f\n",c, d, e);
  return 0;
}



Measured memory_bytes: 2740
import java.util.Arrays;

public class Main {
  private static void solve() {
    int n = ni();
    int[] dp = new int[n + 1];
    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;
    
    for (int i = 0; i < n; i ++) {
      dp[i + 1] = Math.min(dp[i + 1], dp[i] + 1);
      for (int v = 6; v + i <= n; v *= 6) {
        dp[i + v] = Math.min(dp[i + v], dp[i] + 1);
      }
      for (int v = 9; v + i <= n; v *= 9) {
        dp[i + v] = Math.min(dp[i + v], dp[i] + 1);
      }
    }
    System.out.println(dp[n]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 23252
#include <bits/stdc++.h>
#pragma warning (disable:4996)
using namespace std;
#define ll long long 
#define ull unsigned long long

int main()
{
	int n;
	cin >> n;
	if (n == 1)
		cout << 1;
	else if (n == 2)
		cout << 8;
	else
		cout << n * n * n;

	return 0;
}

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

LL INF;
int main() {
	INF = 1000000;
	INF *= INF;
	int N;
	cin >> N;
	vector<PII> data;
	for(int i=0; i<N; i++ ) {
		int h, p;
		cin >> h >> p;
		data.push_back(PII(h+p, p));
	}
	sort(data.begin(), data.end());
	
	vector<LL> res(N+1, 0);
	for(int i=1; i<res.size(); i++)
		res[i] = 1000000;
		
	
	vector<LL> dp(N+1, INF);
	dp[0] = 0;
	
	for(int i=0; i<N; i++) {
	//	for(int j=0; j<N; j++ ) cout << dp[j] << " ";
		
		//cout << endl;
		for(int j=N-1; j>=0; j--) {
			LL h = data[i].first - data[i].second;
			if(dp[j] <= h ) {
				dp[j+1] = min(dp[j+1], dp[j] + data[i].second);
			}
		}
	}
	
	int ans = 0;
	for(int i=0; i<=N; i++) {
		if(dp[i] < INF)
			ans = i;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

// #define N 50005


int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    int n;
    cin >> n;
    string a,b,c;
    cin >> a >> b >> c;
    // int n = sz(a);

    int ans = 0;
    rep(i,n) {
        map<char,int> M;
        M[a[i]]++;
        M[b[i]]++;
        M[c[i]]++;

        if(sz(M) == 3) ans += 2;
        else if(sz(M) == 2) ans += 1;
    }
    cout << ans << "\n";
}

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

if a%d==0:
    x=a//d
else:
    x=a//d+1 

if c%b==0:
    y=c//b
else:
    y=c//b+1
    
if y<=x:
    print("Yes")
elif x<y:
    print("No")

Measured memory_bytes: 9188
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <cmath>
#include <queue> 
#define P pair<int ,int >
#define pb push_back
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define db double
//#define int LL
using namespace std;
const int N   = 1e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define rep(i,x,y) for (int i=x;i<=y;++i)
#define rrep(i,x,y) for (int i=x;i<y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}
int n,k,ok,cnt,sz[N];
vector <int > s[N];
signed main()
{
	read(n);
	for (k=1;1ll*k*(k-1)<=2*n;++k)
	  if (1ll*k*(k-1)==2*n)  
	  {
	  	ok=1;
	  	break;
	  }
	if (!ok) 
	{	
		printf("No");
		return 0;
	}
	printf("Yes\n%d\n",k);
	rep(i,1,k) 
	  rep(j,i+1,k)
	    ++cnt,s[i].pb(cnt),s[j].pb(cnt),++sz[i],++sz[j];
	rep(i,1,k)
	{
		printf("%d ",sz[i]);
		rep(j,1,sz[i]) printf("%d%c",s[i][j-1],j==sz[i]?'\n': ' ');
		//printf()
	}
	return 0;
	  
}


Measured memory_bytes: 4608
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------
 
signed main() {
	tezz
 
	int n,p,c=0;
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> p;
		if(i&1 && p&1)c++;
	}
	cout << c;
 
	return 0;
}  

Measured memory_bytes: 3608
h1,m1,h2,m2,k=[int(x) for x in input().rstrip().split()]

if h1<=h2:
  h1m=h1*60+m1
  h2m=h2*60+m2
  print(h2m-h1m-k)
else:
  h1m=h1*60+m1
  h2=(h2+12)*60+m2
  print(h2m-h1m-k)
  


Measured memory_bytes: 9168
K = int(input())

import math

ans = 0
for i in range(1, K+1):
    for j in range(1, i+1):
        for k in range(1, j+1):
            if i == j and j == k and k == i:
                ans += i
            elif i == j or j == k or k == i:
                x = math.gcd(i, j)
                ans += math.gcd(x, k) * 3
            else:
                x = math.gcd(i, j)
                ans += math.gcd(x, k) * 6
print(ans)

Measured memory_bytes: 68140
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,j=0,ans=0,h=0;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		for(;j<n&&!(h&a[j]);j++)
			h^=a[j];
		ans+=(j-i);
		h^=a[i];
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int mul=0;
  ll w,h,x,y;
  cin >> w >> h >> x >> y;
  if(h%2==0 && w%2==0 && h/2==y && w/2==x)mul++;
  double W=w,H=h,X=x,Y=y;
  cout << setprecision(12) << (W*H)/2.0 << ' ' << mul << endl;
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;

int main(){
	IOS;
	ll n;
	cin >> n;
	ll a[n];
	loop(i, 0, n)
		cin >> a[i];
	sort(a, a + n);
	ll cnt = 0;
	loop(i, 0, n)
		loop(j, i + 1, n)
			loop(k, j + 1, n){
				if(a[i] + a[j] >  a[k]){
					if(a[i] != a[j] && a[j] != a[k])
						cnt++;
				}
			}
	cout << cnt << endl;
}

Measured memory_bytes: 3664
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ss = Array.init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s
let g () = Array.make_matrix h w 0
let us, ds, ls, rs = g (), g (), g (), g ()
let f i j = ss.(i).[j] <> '#'
let ans = ref 0
let _ =
  for i = 0 to h - 1 do
    for j = 0 to w - 2 do if f i j then ls.(i).(j + 1) <- ls.(i).(j) + 1 done done;
  for i = 0 to h - 1 do
    for j = w - 1 downto 1 do if f i j then rs.(i).(j - 1) <- rs.(i).(j) + 1 done done;
  for j = 0 to w - 1 do
    for i = 0 to h - 2 do if f i j then us.(i + 1).(j) <- us.(i).(j) + 1 done done;
  for j = 0 to w - 1 do
    for i = h - 1 downto 1 do if f i j then ds.(i - 1).(j) <- ds.(i).(j) + 1 done done;
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do if f i j then ans := max !ans @@ 1 + us.(i).(j) + ds.(i).(j) + ls.(i).(j) + rs.(i).(j) done done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 135028
#include<stdio.h>
int main(void)
{
  int debt=100000;
  int n;
  int i;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    debt=debt*1.05;
    if(debt%1000!=0)
      debt=debt-debt%1000+1000;
  }

  printf("%d\n", debt);

  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, C;
int D[510][510], c[510][510];
int S[3][30];

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

    std::cin >> N >> C;

    for(int i=0;i<C;++i){
        for(int j=0;j<C;++j){
            std::cin >> D[i][j];
        }
    }

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            std::cin >> c[i][j];
            c[i][j] -= 1;
        }
    }

    for(int co=0;co<C;++co){
        for(int i=0;i<N;++i){
            for(int j=0;j<N;++j){
                S[(i + j) % 3][co] += D[c[i][j]][co];
            }
        }
    }

    int mn = std::numeric_limits<int>::max();
    for(int c1=0;c1<C;++c1){
        for(int c2=0;c2<C;++c2){
            if(c2 == c1){
                continue;
            }

            for(int c3=0;c3<C;++c3){
                if(c3 == c1 || c3 == c2){
                    continue;
                }

                mn = std::min(mn, S[0][c1] + S[1][c2] + S[2][c3]);
            }
        }
    }

    std::cout << mn << std::endl;
}


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

int main() {
	long long n;
	cin>>n;
	unordered_map<string,int> m;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll N;
    cin >> N;
    // 2と5の数を数えれば良い
    //多分５のほうが少ない
    if(N % 2LL == 1LL) {
        cout << 0 << endl;
        return 0;
    }
    // 5が何回出てくるかをしらべる
    ll tmp = N / 10LL;
    ll res = tmp;
    //すくなくともtmp回数はいける
    //くわえてtmp * tmp-1*tmp-2*........を計算しないといけない
    ll start = 5LL;
    while(start <= tmp) {
        res += tmp / start;
        start *= 5LL;
    }
    cout << res << endl;
    return 0;
}
// 1000000000000000000
// 124999999999999995

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

using namespace std;
using ll = long long;

#define endl '\n'
#define FIO() ios_base::sync_with_stdio(0);cin.tie(NULL);

#define mx 1000006
bitset <mx> mark;
vector <int> primes;
int dx[mx];

void sieve() {
    for (int i = 1; i < mx; i++) dx[i] = i;
    mark[0] = mark[1] = 1;
    primes.push_back(2);
    int lim = sqrt(mx * 1.0) + 2;
    for (int i = 4; i < mx; i += 2) {mark[i] = 1, dx[i] = 2;}
    for (int i = 3; i < mx; i += 2) {
        if (!mark[i]) {
            primes.push_back(i);
            if (i <= lim) {
                for (int j = i * i; j < mx; j += i) {
                    mark[j] = 1;
                    dx[j] = min(dx[j], i);
                }
            }
        }
    }
}

int main() {
    FIO();
    sieve();

    ll n; cin >> n;
    ll ans = 0;

    for (ll c = 1; c < n; c++) {
        ll ab = n - c;
        ll cnt = 1;
        ll x = ab;
        while (x > 1) {
            ll a = 0;
            ll d = dx[x];
            while (x % d == 0) {
                x /= d;
                a++;
            }

            cnt *= (a + 1);
        }

        ans += cnt;
    }

    cout << ans << endl;
}

Measured memory_bytes: 7888
#include <iostream>
#include <map>


using namespace std;


typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1000000007;
int BITS;
ull N;
map<ll, ll> CACHE;


void release_memory( unsigned int**, ll );
void show( ll, ll, ll, ll );
unsigned int bit_size( ll );
ll solve( int, ll);


unsigned int bit_size( ll N ) {
    if ( N == 0 ) { return 0; }
    
    return 1 + bit_size( N >> 1 );
}


ll solve( ull x ) {
    if ( x <= 1 ) { return x; }
    if ( CACHE[ x ] != 0 ) { return CACHE[ x ]; }

    ull res = 2 * solve( x >> 1 ) + solve( ( x >> 1 ) + ( ( x & 1 ) ? 1 : -1 ) );

    return CACHE[ x ] = res % MOD;
}


int main() {
    cin >> N;
    cout << solve( N + 1 ) << endl;
    
    return 0;
}


Measured memory_bytes: 384
/*input
1 2019
*/

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

int main() {
    ll a, b;
    cin >> a >> b;
    while (b > 0) {
        ll r = a%b;
        a = b;
        b = r;
    }
    int ans = 1; // 1 is always ok.
    for (ll i = 2; i*i <= a; i++) {
        if (a%i == 0) ans++;
        while (a%i == 0) {
            a /= i;
        }
    }
    if (a != 1) ans++;
    cout << ans << endl;
} 

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

int main() {
    int k;
    cin >> k;
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << endl;
} 

Measured memory_bytes: 256
#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)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    int odd = 0, even = 0;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        tmp % 2 == 1 ? odd += 1 : even += 1;
    }
    cout << pow(3, N) - pow(2, even) << endl;
    return 0;
}

Measured memory_bytes: 4132
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 100010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,L,T;
int pos[maxn];
int main()
{
    n=read();L=read();T=read();
    int tmp=0;
    for(int i=0;i<n;i++)
    {
        int x=read(),w=read();
        if(w==1)
        {
            pos[i]=(x+T)%L;
            tmp+=(x+T)/L;
        }
        else{
            pos[i]=(x-T)%L;
            tmp+=(x-T)/L;
            if(pos[i]<0)
            {
                pos[i]+=L;
                tmp--;
            }
        }
    }
    tmp=(tmp%n+n)%n;
    sort(pos,pos+n);
    for(int i=tmp;i<n;i++)  printf("%d\n",pos[i]);
    for(int i=0;i<tmp;i++)  printf("%d\n",pos[i]);
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      if(S.contains("RRR")){
        System.out.println("3");
      }else if(S.contains("RR")){
        System.out.println("2");
      }else if(S.contains("R")){
        System.out.println("1");
      }else{
        System.out.println("0");
      }
    }
}

Measured memory_bytes: 35776
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        long ans=0;
        int prev=s.nextInt();
        for(int i=1;i<n;i++){
            int ele=s.nextInt();
            if(ele<prev){
                ans+=prev-ele;
            }
            else{
                prev=ele;
            }
        }

        System.out.print(ans);
    }
}

Measured memory_bytes: 48636
def f(A, N, M, Q, conditions):
    L = len(A) - 1

    if L > N:
        return

    elif L < N:
        fans = 0
        for j in range(A[L], M + 1):
            fans = max(fans ,f(A + [j], N, M, Q, conditions))

    else: # L = N
        fans = 0
        for i in range(Q):
            a, b, c, d = conditions[i]
            if A[b] - A[a] == c:
                fans += d
        
    return fans

N, M, Q = [int(x) for x in input().split()]

conditions = []
for i in range(Q):
    c = [int(x) for x in input().split()]
    conditions.append(c)

ans = f([1], N, M, Q, conditions)

print(ans)

Measured memory_bytes: 8928
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long seg_tree[seg_size*2] = {};
long long seg_find(int now,int n_l,int n_r,int w_l,int w_r){
	if(w_l <= n_l&&n_r <= w_r) return seg_tree[now];
	if(w_r <= n_l||w_l >= n_r) return 0;
	return seg_find(now*2,n_l,(n_l+n_r)/2,w_l,w_r) + seg_find(now*2+1,(n_l+n_r)/2,n_r,w_l,w_r);
}
long long seg_set(int now){
	seg_tree[now] = seg_tree[now*2] + seg_tree[now*2+1];
	if(now != 1) seg_set(now/2);
	return 0;
}
int main(){
	int n,query;
	cin >> n >> query;
	for(int i = 0;i < query;++i){
		int a,b,c;
		cin >> a >> b >> c;
		if(a == 0){
			seg_tree[seg_size + b] += c;
			seg_set((seg_size + b)/2);
		}else{
			cout << seg_find(1,0,seg_size,b,c+1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4708
#include <iostream>
using namespace std;
int main(){
        int N;
        while(true){
        cin >> N;
        if(N==0)
                break;
        int table[100][100];
        for(int i=0 ; i<N ; i++ ){
                int sum=0;
                for(int j=0 ; j<N ; j++ ){
                        cin >> table[i][j];
                        sum+=table[i][j];
                }
                table[i][N]=sum;
        }
        for(int i=0 ; i<=N ; i++ ){
                table[N][i]=0;
                for(int j=0 ; j<N ; j++ ){
                        table[N][i]+=table[j][i];
                }
        }
        for(int i=0 ; i<=N ; i++ ){
                for(int j=0 ; j<=N ; j++ ){
                        int space=0;
                        if(table[i][j]<10)
                                space=4;
                        else if(table[i][j]<100)
                                space=3;
                        else if(table[i][j]<1000)
                                space=2;
                        else if(table[i][j]<10000)
                                space=1;
                        for(int l=0 ; l<space ; l++ )
                                cout<<" ";
                        cout << table[i][j];
                //      if(j!=N)
                //              cout<<" ";
                }
                cout << endl;
        }
        }
        return 0;
}

Measured memory_bytes: 3012
from operator import itemgetter
n = int(input())
lst = [0] * n
for i in range(n):
  lst[i] = tuple(map(int, input().split()))
lst.sort(key=itemgetter(1))
t = 0
for i in range(n):
  t += lst[i][0]
  if t > lst[i][1]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 98388
import collections
d=collections.deque()
for _ in range(int(input())):
 e=input()
 if'i'==e[0]:d.appendleft(e.split()[1])
 else:
  if' '==e[6]:
   m=e.split()[1]
   if m in d:d.remove(m)
  elif len(e)%2:d.popleft()
  else:d.pop()
print(*d)


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

typedef long long ll;

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

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

    while(t-- > 0){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;

        if(a < b || b > d){
            cout << "No" << endl;
            continue;
        }

        if(b <= c+1){
            cout << "Yes" << endl;
            continue;
        }

        ll g = gcd(b,d);
        // there exists an integer t s.t. c < (a-b + t*g) < b ?

        ll first = a-b;

        if(first > c){
            first -= (first-c)/g * g;
        }else if(first < c){
            first += (c-first)/g * g;
            if(first < c)   first += g;
        }

        bool found = false;
        while(1){
            if(c < first && first < b){
                found = true;
                break;
            }else if(first >= b){
                break;
            }else{
                first += g;
            }
        }

        if(found)   cout << "No" << endl;
        else        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            int n = scan.nextInt();
            int y = 2;
            int s = 0;
            if (n >= 2) {
                s++;
            }
            for (int x = 3; x <= n; x += 2) {
                y = 3;
                while (x % y != 0 && x >= y * y) {
                    y += 2;
                }
                if (x < y * y) {
                    s++;
                }
                y = 2;
            }
            System.out.println(s);
        }
    }
}



Measured memory_bytes: 26440
#include <bits/stdc++.h>
const long long mod=1e9+7;
#define ll long long
using namespace std;
int lim=0;

/*ll power(ll n)
{
    if(n==0) return 0%mod;
    if(n==1) return 1%mod;
    return ((power(n-1)%mod) + (power(n-2)%mod ))%mod;
}
int main()
{
    ll n;cin>>n;
    cout<<power(n%mod)%mod;
}*/
ll pw(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=res*x*1ll%mod;
        x=x*x*1ll%mod;
        n/=2;
    }return res;
}
int main()
{
    int i,n,s=0,flg;scanf("%d",&n);
    int a[n],t,j,k;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }sort(a,a+n);

    for(i=n-1;i>0;i--)
    {
        for(j=i-1;j>0;j--)
        {
            for(k=j-1;k>=0;k--)
            {
                if((a[i]+a[j]>a[k])&&(a[j]+a[k]>a[i])&&(a[k]+a[i]>a[j]))
                {
                    s++;
                }
            }
        }
    }printf("%d",s);
}
// C++ program to find sum of two large numbers.
/*#include<bits/stdc++.h>
using namespace std;

// Function for finding sum of larger numbers
string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}

// Driver code
int main()
{
    string str1 ,str2 ;
    cin>>str1>>str2;
    cout << findSum(str1, str2);
    return 0;
}
*/
// CPP program to find (a^b) % MOD where a and
// b may be very large and represented as strings.




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

    vector<int> H(N);
    vector<int> ma(N);
    rep(i, N) {
        cin >> H[i];
        ma[i] = 0; // 比較対象の展望台の最大の高さ
    }
    
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        ma[A - 1] = max(ma[A - 1], H[B - 1]);
        ma[B - 1] = max(ma[B - 1], H[A - 1]);
    }

    int ans = 0;
    rep(i, N) {
        ans += H[i] > ma[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3996
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>


constexpr long long int MOD = 1000000007;
long long int power(long long int base, int exp) {
	switch (exp) {
	case 0: return 1L;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp >> 1) * power(base, exp & 1) % MOD;
	}
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
int main() {
	int n, k; std::cin >> n >> k;
	std::vector<long long int> pure(k + 1, 0);
	long long int result{ 0 };
	for (auto g = k; g >= 1; --g) {
		long long int pattern{ power(k / g, n) };
		for (auto i = 2; g * i <= k; ++i) {
			pattern += MOD - pure[i * g];
			pattern %= MOD;
		}
		pure[g] = pattern;
		result += pattern * g % MOD;
		result %= MOD;
	}
	std::cout << (result % MOD + MOD) % MOD << std::endl;
}

Measured memory_bytes: 3544
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
N = int(input())
A = inputlist()
c = Counter(A)
key = list(c.keys())
dic = {}
dica = {}
for i in key:
    dic[i] = c[i]*(c[i]-1)//2
    dica[i] = (c[i]-1)*(c[i]-2)//2
ans = 0
for i in key:
    ans += dic[i]
for i in range(N):
    suma = ans
    suma = suma - dic[A[i]] + dica[A[i]]
    print(suma)


Measured memory_bytes: 40476
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  string s;
  cin>>s;
  cout<<s[0]<<s.length()-2<<s[s.length()-1];
}

// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//int isEmpty(int);
//int isFull(int);
void push(int);
int pop();

int S[1000];
int top;

int main(){
  int a,b;
  int top=0;
  char s[100];
 
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if ( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);
    }
    else {
      push(atoi(s));  
    }
  }
  printf("%d\n",pop());
  return 0;
}

/*int isEmpty(int top){
  if(top == 0) return 0;
  else return 1;
}

int isFull(int top){
  if(top >= 100 - 1)return 1;
  else return 0;
  }*/

void push(int x){
  /* if(isFull(top+1)==1)printf("error Overflow\n");
     else*/ 
  S[++top] = x;
}

int pop(){
  /*if(isEmpty(top)==1)printf("error Underflow\n");
    else*/ top--;
  return S[top+1];
}

Measured memory_bytes: 548
#include<stdio.h>
int main()
{
	int a , b , c ;
	scanf("%d %d %d",&a,&b,&c);
	if(a==5&&b==5&&c==7)
	{
		printf("YES");	
	}
	else if(a==7&&b==5&&c==5)
	{
		printf("YES");	
	}
	else if(a==5&&b==7&&c==5)
	{
		printf("YES");	
	}
	else
	{
		printf("NO");
	}
		
	return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	X := []int{nextInt(), nextInt(), nextInt()}
	if X[0]&1 == 0 || X[1]&1 == 0 || X[2]&1 == 0 {
		out(0)
	} else {
		sort.Ints(X)
		out(X[0] * X[1])
	}
}


Measured memory_bytes: 640