akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	int a[501][501],c[501],h=0;
	int i,i2,n, m,x,y;
	while (1){
		for (i = 0; i < 501; i++){
			for (i2 = 0; i2 < 501; i2++){
				a[i][i2] = 0;
			}
			c[i] = 0;
		}
		h = 0;
		scanf("%d %d", &n, &m);
		if (n == 0 && m == 0)
			break;
		for (i = 0; i < m; i++){
			scanf("%d %d", &x, &y);
			a[x][y] = 1;
			a[y][x] = 1;
		}
		c[0] = 1; c[1] = 1;
		for (i = 1; i <= n; i++){
			if (a[1][i] == 1){
				if (c[i] == 0){
					h++;
				}
				c[i] = 1;
				for (i2 = 1; i2 <= n; i2++){
					if (a[i][i2] == 1 && c[i2] == 0){
						c[i2] = 1;
						h++;
					}

				}

			}



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

Measured memory_bytes: 1580
import sys
import math
import numpy as np
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    def f(s):
        if s == "":return 0
        t = s.replace("A","").replace("T","").replace("G","").replace("C","")
        if t == "":return len(s)
        else:return 0
    s = S()
    n = len(s)
    ans = 0
    cnt = 0
    for i in range(n):
        for j in range(i,n):
            t = s[i:j+1]
            ans = max(f(t),ans)
    print(ans)

Measured memory_bytes: 27100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int tot = in.nextInt();
		int cake = in.nextInt();
		int donut = in.nextInt();
		System.out.println((tot - cake) % donut);
	}

}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int R = scan.nextInt();
		int G = scan.nextInt();
		// (R + x) / 2 = G
		// R + x = 2G
		// x = 2G - R
		System.out.println(2 * G - R);
		scan.close();

	}

}


Measured memory_bytes: 23252
#include <stdio.h>

typedef struct Dice {
    int f[6];
} Dice;

void roll(Dice *d, char dest)
{
    int temp;
    switch(dest) {
    case 'E':
        temp=d->f[0];
        d->f[0]=d->f[3];
        d->f[3]=d->f[5];
        d->f[5]=d->f[2];
        d->f[2]=temp;
        break;
    case 'N':
        temp=d->f[0];
        d->f[0]=d->f[1];
        d->f[1]=d->f[5];
        d->f[5]=d->f[4];
        d->f[4]=temp;
        break;
    case 'S':
        temp=d->f[0];
        d->f[0]=d->f[4];
        d->f[4]=d->f[5];
        d->f[5]=d->f[1];
        d->f[1]=temp;
        break;
    case 'W':
        temp=d->f[0];
        d->f[0]=d->f[2];
        d->f[2]=d->f[5];
        d->f[5]=d->f[3];
        d->f[3]=temp;
    }
}

int main()
{
    Dice d;
    int i;
    char dest;

    for(i=0; i<6; i++) {
        scanf(" %d", &d.f[i]);
    }

    while(scanf(" %c", &dest) !=EOF) roll(&d, dest);
    printf("%d\n", d.f[0]);
    return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  int n;
  vector<int> l;
  cin >> n;
  l.resize(n);
  for(ii=0;ii<n;ii++){
    cin >> l[ii];
  }

  //sort(l.begin(),l.end(),std::greater<int>() );
  int cnt = 0;

  for(ii=0;ii<n-2;ii++){
    for(jj=ii+1;jj<n-1;jj++){
      for(kk=jj+1;kk<n;kk++){

        if(l[ii] < l[jj] + l[kk] &&
           l[jj] < l[ii] + l[kk] &&
           l[kk] < l[jj] + l[ii] &&
           l[kk] != l[ii] && l[kk] != l[jj] && l[ii] != l[jj]){
          
          //cout << "ii:" << ii << " " <<l[ii];
          //cout << "jj:" << jj << " " <<l[jj];
          //cout << "kk:" << kk << " " <<l[kk];

          //cout << endl;
          
          cnt++;
        }
      }
    }
  }
 
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[100005],b[100005],sum,ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=1;i<=n+1;++i) cin>>a[i],sum+=a[i];
	for (int i=1;i<=n;++i) 
	{
		cin>>b[i];
		if (b[i]>=a[i]) b[i]-=a[i],a[i]=0;
		else
		{
			a[i]-=b[i];
			b[i]=0;
			continue;
		}
		if (b[i]>=a[i+1]) b[i]-=a[i+1],a[i+1]=0;
		else
		{
			a[i+1]-=b[i];
			b[i]=0;
			continue;
		}
	}
	for (int i=1;i<=n+1;++i) ans+=a[i];
	cout<<sum-ans;
	return 0;
}

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

public class Main
{   
    static int h[];
    static int dp[];
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int sz = scan.nextInt();
		h = new int[sz];
		dp = new int[sz];
		for(int i = 0; i < sz; i++) h[i] = scan.nextInt();
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 2; i < sz; i++){
		   // int min = Integer.MAX_VALUE;
		    dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		 //   dp[i] = min;
		}
		System.out.println(dp[sz - 1]);
	}
}


Measured memory_bytes: 59960
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		Circle[] c = new Circle[2];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 2; j++) {
				double x = sc.nextDouble();
				double y = sc.nextDouble();
				double r = sc.nextDouble();
				c[j] = new Circle(x, y, r);
			}
			double l1 = norm(c[0].x, c[0].y, c[1].x, c[1].y);
			//System.out.println(l1);
			if(l1 < c[0].r - c[1].r) {
				sb.append(2).append("\n");
			}else if(l1 < c[1].r - c[0].r) {
				sb.append(-2).append("\n");
			}else if(l1 > c[0].r + c[1].r) {
				sb.append(0).append("\n");
			}else {
				sb.append(1).append("\n");
			}
		}
		sc.close();
		System.out.print(sb.toString());
	}
	static double norm(double x1, double y1, double x2, double y2) {
		double ret = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
		return Math.sqrt(ret);
	}
	static class Circle{
		double x, y, r;
		Circle(double x, double y, double r){
			this.x = x;
			this.y = y;
			this.r = r;
		}
	}
}


Measured memory_bytes: 28416
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		
		int pi = 314159;
		
		System.out.println((double)(2*r*pi) / 100000);
	} 

}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > ans;
  vector<vector<int> > sum;
  if (n & 1) {
    sum.push_back({n});
    for (int i = 1; n-i > i; ++i)
      sum.push_back({i, n-i});
  }
  else {
    for (int i = 1; n + 1 - i > i; ++i) {
      sum.push_back({i, n+1-i});
    }
  }
  for (int i = 0; i + 1 < sum.size(); ++i) {
    for (int x : sum[i]) {
      for (int y : sum[i+1]) {
        ans.emplace_back(x, y);
      }
    }
  }
  if (sum.size() > 2) {
    for (int x : sum[0]) {
      for (int y : sum.back()) {
        ans.emplace_back(x, y);
      }
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto it : ans) {
    printf("%d %d\n", it.first, it.second);
  }
  return 0;
}

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

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

    int current_height = 0;
    int result = 0;

    for(int i=0; i<n ;++i)
    {
        int in;
        std::cin >> in;
        if(current_height <= in)
        {
            result++;
            current_height = in;
        }
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    # 条件1:全パターンはr*g*b
    r = s.count('R')
    g = s.count('G')
    b = s.count('B')
    # i, j, kの差が一致するもので条件1を満たすものを後から引く 
    cnt = 0
    # len(s)
    for i in range(n):
        for j in range(i+1, n):
                k = j + j - i
                if k >= n:
                    break
                if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                    cnt += 1
    ans = r*g*b - cnt
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(200010);
	vector<int> dp(n);
	rep(i, n) {
		cin >> a[i];
		dp[i] = 0;
	}
	rep(i, 200010) {
		b[i] = -1;
	}
	dp[0] = 1;
	rep(i, n) {
		if (i != 0) {
			dp[i] += dp[i - 1];
			dp[i] %= mod;
			if (b[a[i]] != -1&&b[a[i]]!=i-1) {
				dp[i] += dp[b[a[i]]];
				dp[i] %= mod;
			}
		}
		b[a[i]] = i;
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 2560
import sys
for s in sys.stdin:
  a=map(int,s.split(" "))
  w=a[0]
  a=sorted(a[1:])
  n=len(a)
  A=[a.pop(0)]
  while a:
    A=[a.pop()]+A
    if a==[]: break
    A+=[a.pop()]
    if a==[]: break
    A=[a.pop(0)]+A
    if a==[]: break
    A+=[a.pop(0)]
  a=A[0]+A[-1]
  for i in range(n-1): a+=2*(A[i]*A[i+1])**.5
  print ["OK","NA"][a>w]

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  if (isupper(c))
    cout << "A\n";
  else
    cout << "a\n";   
  return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
 
using namespace std;
#define N 4
#define N2 16
 
static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r','u','l','d'};
int MDT[N2][N2];
 
struct Puzzle {
  int f[N2], space, MD;
  int cost;
 
  bool operator < ( const Puzzle &p ) const {
    for ( int i = 0; i < N2; i++ ) {
      if ( f[i] == p.f[i] ) continue;
      return f[i] < p.f[i];
    }
    return false;
  }
};
struct State {
  Puzzle puzzle;
  int estimated;
  bool operator < (const State &s) const {
    return estimated > s.estimated;
  }
};
 
int getAllMD(Puzzle pz) {
  int sum = 0;
  for ( int i = 0; i < N2; i++ ) {
    if ( pz.f[i] == N2 ) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}
 
int astar(Puzzle s) {
  priority_queue<State> PQ;
  s.MD = getAllMD(s);
  s.cost = 0;
  map<Puzzle, bool> V;
  Puzzle u, v;
  State initial;
  initial.puzzle = s;
  initial.estimated = getAllMD(s);
  PQ.push(initial);
  while ( !PQ.empty() ) {
    State st = PQ.top(); PQ.pop();
    u = st.puzzle;
 
    if ( u.MD == 0 ) return u.cost;
    V[u] = true;
 
    int sx = u.space / N;
    int sy = u.space % N;
 
    for ( int r = 0; r < 4; r++ ) {
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
      v = u;
 
      v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] - 1];
      v.MD += MDT[sx * N + sy][v.f[tx * N + ty] - 1];
 
      swap(v.f[sx * N + sy], v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if ( !V[v] ) {
        v.cost++;
        State news;
        news.puzzle = v;
        news.estimated = v.cost + v.MD;
        PQ.push(news);
      }
    }
  }
  return -1;
}
 
int main() {
  for ( int i = 0; i < N2; i++ )
    for ( int j = 0; j < N2; j++ )
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
 
  Puzzle in;
 
  for ( int i = 0; i < N2; i++ ) {
    cin >> in.f[i];
    if ( in.f[i] == 0 ) {
      in.f[i] = N2;
      in.space = i;
    }
  }
  cout << astar(in) << endl;
 
  return 0;
}


Measured memory_bytes: 257568
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli r;
    cin>>r;
    double pi=3.14159265358979323846;
    double ans=2*pi*r;
    cout<<fixed<<setprecision(20);
	cout<<ans; 
    return 0;
}


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

int main(){
  int k,s,ans;
  cin >> k >> s;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      if(s-x-y>=0 && s-x-y<=k)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
require 'prime'

n = gets.to_i

divs = Prime.prime_division(n, Prime::EratosthenesGenerator.new)

count = 0
divs.each do |n, n_count|
  i = 0
  next_i = 1
  n_count.times do
    i += 1
    if i == next_i
      count += 1
      next_i += 1
      i = 0
    end
  end
end

puts count


Measured memory_bytes: 19520
import math
a, b, C = map(int,input().split())
Cr = math.radians(C)

S = (a*b*math.sin(Cr))/2

c2 = a**2+b**2-2*a*b*math.cos(Cr)
c = math.sqrt(c2)
L = a+b+c

h = b*math.sin(Cr)

print('{:.8f}'.format(S))
print('{:.8f}'.format(L))
print('{:.8f}'.format(h))


Measured memory_bytes: 5712
#include <stdio.h>          // printf(), scanf(), getc(), ungetc()
#include <string.h>         // memcpy()
#include <stdbool.h>

#define MAX_L 200
const char NUL = '\0';

bool
ope_line()
{
	char s[MAX_L + 1];
	char t[MAX_L + 1];
	int len;
	int n, h;
	int i;
	int c;

	c = getc(stdin);
	len = 0;
	while (c != '\n' && c != EOF)
	{
		s[len++] = c;
		c = getc(stdin);
	}

	s[len] = NUL;
	if (s[0] == '-' && len == 1)
		return false;

	ungetc(c, stdin);
	scanf("%d\n", &n);
	for (i = 0; i < n; ++i)
	{
		scanf("%d\n", &h);
		memcpy(t, s, h);
		memcpy(s, &s[h], len - h);
		memcpy(&s[len - h], t, h);
		s[len] = NUL;
	}

	printf("%s\n", s);
	return true;
}

int
main(int argc, char** argv)
{
	while (true)
	{
		if (!ope_line())
			break;
	}

	return 0;
}

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


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main() {
  ll n,k;
  cin>>n>>k;
  vector<P> s;
  for(ll i=1;i*i<=n;i++){
    s.push_back(make_pair(i,0));
    s.push_back(make_pair(n/i,0));
  }
  sort(s.begin(),s.end());
  s.erase(unique(s.begin(),s.end()),s.end());
  rep(i,s.size()-1){
    s[i].second=n/s[i].first-n/s[i+1].first;
  }

  map<ll,ll>mp;
  ll S=s.size();
  s[S-1].second=1;
  rep(i,S)mp[s[i].first]=i;
  vector<vector<mint>> dp(k+1,vector<mint> (S+1) );
  dp[0][S]=1;
  rep(i,S)dp[0][i]+=dp[0][i+1];

  rep(i,k){
for(ll j=S-2;j>=0;j--){
  dp[i][j]+=dp[i][j+1];
}
  rep(j,S){

  dp[i+1][j]+=dp[i][mp[n/s[j].first]]*s[j].second;
  // /cout<<dp[i+1][j]<<endl;
}
}
mint ans=0;
rep(i,S)ans+=dp[k][i];
cout<<ans.x;
}


Measured memory_bytes: 55540
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;
map<ll, ll> fact;

map<ll, ll> prime_factor(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n]++;
    }
    return res;
}

int u2, u4, u14, u24, u74;

int main()
{
    cin >> N;
    repe(i, 1, N)
    {
        auto f = prime_factor(i);
        for (auto e : f)
        {
            fact[e.first] += e.second;
        }
    }

    for (auto e : fact)
    {
        auto k = e.first;
        auto v = e.second;
        if (v >= 2)
            u2++;

        if (v >= 4)
            u4++;

        if (v >= 14)
            u14++;

        if (v >= 24)
            u24++;

        if (v >= 74)
            u74++;
    }

    ll ans = 0;
    if (u4 >= 2 && u2 >= 3)
    {
        ans += (u4 * (u4 - 1)) / 2 * (u2 - 2);
    }
    if (u14 >= 1 && u4 >= 2)
    {
        ans += u14 * (u4 - 1);
    }
    if (u24 >= 1 && u2 >= 2)
    {
        ans += u24 * (u2 - 1);
    }
    if (u74 >= 1)
    {
        ans += u74;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] list = new int[m+1];
      for (int i = 0; i < n; i++) {
        int k = sc.nextInt();
        for (int j = 0; j < k; j++) {
          list[sc.nextInt()]++;
        }
      }
      int ans = 0;
      for (int i = 0; i < m+1; i++) {
        if (list[i] == n) {
          ans++;
        }
      }
      System.out.println(ans);
    }
  }

Measured memory_bytes: 22356
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

const int MAX_N = 100005;
int n, k, a[MAX_N];

void input() {
    RI(n, k);
    REP(i, n) RI(a[i]);
}

void solve() {
	sort(a, a+n);
	int mi = 1e9;
	for(int i = 0; i <= n-k; i++) {
		mi = min(mi, a[i+k-1] - a[i]);
	}
	cout << mi << endl;
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

int fun(int n){
    int c=0;
int s= sqrt(n);

for(int i=1;i<=s;i++)
    if(n%i==0)
    c+=2;
if(s*s==n)
    c--;
return c;
}
int main()
{
    fast
    int q=1;

    while(q--)
    {
     int n;  cin>>n;
     ll sum=0;
     for(int i=1;i<=n-1;i++){
            //cout<<i<<" "<<fun(i)<<endl;
         sum+=fun(i);
     }

     cout<<sum;

    }

    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
 
#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define fi first
#define se second
 
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int maxm = 3e5 + 10;
const double PI = acos(-1.0);
const int inf = 1e9;



int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll ans = 0;
    ll n;
    cin >> n;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0) {
            if(!ans) {
                ans = i + n / i - 2ll;
            }
            else {
                ll tmp = i + n / i - 2ll;
                ans = min(ans,tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

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

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

int main() {
  int n;
  cin >> n;
  vector<ll> t(n);
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
  }
  ll ans = 1;
  for (int i = 0; i < n; ++i) {
    ans = lcm(ans, t[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
using namespace std;
int x[N],n,k,q,a,cnt;
int main(){
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++){
		cin>>a;
		x[1]++;
		x[a]--;
		x[n+1]--;
		x[a+1]++;
	}
	for(int i=1;i<=n;i++){
		cnt+=x[i];
		if(cnt>=k)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, X,T = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    print(T*math.ceil(N/X))


if __name__ == "__main__":
    main()

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

int main() {
    string s;
    cin >> s;
    for(int i = 0 ; i < s.size(); i++){
        if(s.at(i) == ','){
            s.at(i) = ' '; 
        }
    }
    cout << s << endl;
    return 0;
    
}




Measured memory_bytes: 256
import time
import random
d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = [random.choice(range(26)) for i in range(d)]
score = 0
start_time = time.time()
start_temp, end_temp = 10000, 10
while True:
    now_time = time.time()
    if now_time - start_time > 1.5:
        break
    p = random.choice(range(d))
    q = random.choice(range(26))
    memo = T[p]
    T[p] = q
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    new_score = 0
    for i in range(d):
        new_score += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        new_score -= C[j] * (dd - X[j])
    temp = start_temp + (end_temp - start_temp) * (now_time - start_time) / 2
    prob = 2**((new_score - score) / temp)
    u = random.random()
    if u < prob:
        score = new_score
    else:
        T[p] = memo

for t in T:
    print(t + 1)


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

namespace AtCoderB
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadIntArray(2);
            string a1 = "";
            string a2 = "";

            Enumerable.Range(1, a[0]).ToList().ForEach(x => a1 = a1 + a[1].ToString());
            Enumerable.Range(1, a[1]).ToList().ForEach(x => a2 = a2 + a[0].ToString());


            List<String> result = new List<string>();

            result.Add(a1);
            result.Add(a2);

             
            Console.WriteLine(result.OrderBy(x=>x).First());
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11744
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = [0] + list(map(int,SI()))
    ans = 0
    for i in range(len(N)-1,-1,-1):

        if N[i] < 6 and not(N[i] == 5 and (i > 0 and N[i-1] >= 5)):
            ans += N[i]
        else:
            ans += 10 - N[i]
            N[i-1] += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 124228
# 今日の曜日を表す文字列 S
# Sは SUN,MON,TUE,WED,THU,FRI,SAT のいずれか
# 次の日曜日 (あす以降) が何日後か

S = input()

if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

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

#define int long long

int arr[100005];
int dp[100005];
int k;

int f(int n)
{
	if(n==1)
	{
		return 0;
	}
	if(n<=0)
	{
	return INT_MAX;
	}
	if(dp[n]!=-1)
	{
		return dp[n];
	}
	int ans1 = INT_MAX;
	
	for(int i=1;i<=k;i++)
	{
		ans1 = min(ans1 , abs(arr[n] - arr[n-i]) + f(n-i));
	}
	
	dp[n] =  ans1;
	return dp[n];
}

int32_t main()
{
	int n;
	cin>>n>>k;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)	cin>>arr[i];
	cout<<f(n);
	return 0;
}

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

const int SIZE=100010;
const int INF=1e9;

int N,p[SIZE];
int to[SIZE],dist[SIZE];
bool used[SIZE];

int dfs(int v){
  if(p[v]==0) return v;
  used[v]=true;
  if(used[v+p[v]]){
    if(to[v+p[v]]==v+p[v]) return to[v]=-1;
    else return to[v]=to[v+p[v]];
  }
  return to[v]=dfs(v+p[v]);
}

void solve(){
  vector<int> dist(N+1);
  for(int i=1;i<=N;i++) dist[i]=INF;
  dist[1]=0;
  queue<int> Q;
  Q.push(1);

  while(!Q.empty()){
    int cur=Q.front(); Q.pop();
    for(int d=1;d<=6;d++){
      int nxt=cur+d;
      if(nxt>=N){
	if(dist[N]==INF) dist[N]=dist[cur]+1;
	cout<<dist[N]<<endl;
	return;
      }
      nxt=to[nxt];
      if(nxt==-1) continue;
      if(dist[nxt]==INF){
	dist[nxt]=dist[cur]+1;
	Q.push(nxt);
      }
    }
  }
  cout<<dist[N]<<endl;
}

int main(){
  cin>>N;
  for(int i=1;i<=N;i++) cin>>p[i]; //1-indexed

  for(int i=1;i<=N;i++) to[i]=i;
  for(int i=1;i<=N;i++){
    if(p[i]!=0 and to[i]==i) dfs(i);
  }
  solve();
}
  
  



Measured memory_bytes: 5312
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  cout<<(n*a)/(__gcd(n,a));
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> v1;

int main(){
	int n,p,q;
	int i,j,k;
	int a,b,c;
	int s=0;
	while(cin>>n>>p>>q){
		if(!n)break;
		p--,q--;
		v1.clear();
		for(i=0;i<n;i++){
			cin>>a;
			v1.push_back(a);
		}
		sort(v1.rbegin(),v1.rend());
		a=0;
		for(i=p;i<=q;i++){
			if(a<=v1[i]-v1[i+1]){
				a=v1[i]-v1[i+1];
				s=i+1;
			}
		}
		cout<<s<<endl;
	}
}
	



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

int main() {
  string t;
  cin >> t;
  
  for(int i = 0; i < t.size(); i++){
    if(t.at(i)=='?'){
      t.at(i) = 'D';
    }
    else{
      continue;
    }
    
  }
  
  for(int i = 0; i < t.size(); i++){
    cout << t.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 3724
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    static ContestScanner in;static Writer out;static StringBuilder sb=new StringBuilder();
    public static void main(String[] args)
    {try{in=new ContestScanner();out=new Writer();Main solve=new Main();solve.solve();
        in.close();out.flush();out.close();}catch(IOException e){e.printStackTrace();}}
    void solve() throws NumberFormatException, IOException{
        int r = in.nextInt();
        int d = in.nextInt();
        long x = in.nextInt();
        for (int i = 1; i <= 10; i++) {
            x = r * x - d;
            System.out.println(x);
        }
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 21076
use strict;
use utf8;
use warnings;
use feature qw/say/;

my $n = <>; chomp($n);
my $s = <>; chomp($s);

my ($r, $b) = (0, 0);
for (split(//, $s)) {
    $r++ if $_ eq 'R';
    $b++ if $_ eq 'B';
}
say $r > $b ? 'Yes': 'No';

Measured memory_bytes: 768
arr = [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]
n = input()
print(arr[int(n)-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
  bool flag;
  int x;
  cin >> x;
  if(x==2)
  {
    cout << x << endl;
  }else if(x==3)
  {
    cout << x << endl;
  }
  else
  {
    for(int i=x;i<=110000;i++)
    {
      flag=true;
      int sq=sqrt(i);
      for(int j=2;j<=sq;j++)
      {
        if(i%j==0)
        {
          flag=false;
          break;
        }
      }
      if(flag==true)
      {
        printf("%d",i);
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef complex<db> cplx;
const int N=(1<<22)+5;
const db PI=acos(-1.00);
int rev[N];
cplx omega(int n,int k,int flag){
    return cplx(cos(2*PI*k/n),flag*sin(2*PI*k/n));
}

void dft(int n,cplx *t,int typ){
    for(int i=0;i<n;i++)
        if(i<rev[i])swap(t[i],t[rev[i]]);
    for(int step=1;step<n;step<<=1){
        cplx wn=cplx(cos(PI/step),typ*sin(PI/step));//涓诲崟浣嶆牴 
        for(int i=step<<1,j=0;j<n;j+=i){
            cplx w=cplx(1.0,0);
            for(int k=0;k<step;k++,w*=wn){
                cplx x=t[j+k],y=t[j+k+step]*w;
                t[j+k]=x+y,t[j+k+step]=x-y;
            }
        }
    }
}
void fft(int P,cplx *A,cplx *B,cplx*C){
    dft(P,A,1);
    dft(P,B,1);
    for(int i=0;i<=P;i++)C[i]=A[i]*B[i];
    dft(P,C,-1);
}

cplx A[N],B[N],C[N];
int n,m;

const int mod = 200003;
int g=0;
int ig[mod];
inline void findg(){
	while(1){
		++g;
		// cout << "chk" << g << endl;
		for(int j=0;j<mod;j++)ig[j]=-1;
		int flag=0;
		// cout << ig[1] << endl;
		for(int j=0,cur=1;j<mod-1;++j,cur=1ll*cur*g%mod){
			// cout << cur << ":" << ig[cur] << endl;
			// cout << j << ":" << cur << ":" << ig[cur] << endl;
			if(ig[cur]!=-1){flag=j+1;break;}
			ig[cur]=j;
		}
		// cout << flag << endl;
		// system("pause");
		if(!flag)break;
	}
	// cout << g << endl;
}

inline int qpow(int a,int b){
	int ret=1;
	for(;b;b>>=1,a=1ll*a*a%mod){
		if(b&1)ret=1ll*ret*a%mod;
	}
	return ret;
}

int main()
{
	ll ans=0;
	findg();
	cin >> n;
	for(int i=1;i<=n;i++){
		int t;scanf("%d",&t);
		ans-=1ll*t*t%mod;
		t=ig[t];
		if(t==-1)continue;
		// cout << t << endl;
		// cout << t << ":" << qpow(g,t) << endl;
		A[t]=A[t]+1.00;
		B[t]=B[t]+1.00;
	}
    // scanf("%d%d",&n,&m);
    // for(int i=0;i<=n;i++)scanf("%lf",&A[i].real());
    // for(int i=0;i<=m;i++)scanf("%lf",&B[i].real());
    int p=1,l=0;
    while(p<=(mod*2))p<<=1,l++;
    for(int i=0;i<p;++i)
        rev[i]=(rev[i>>1]>>1)|((i&1)<<(l-1));
    fft(p,A,B,C);
	for(int i=0;i<mod*2;i++){
		ll x = ll(C[i].real()/p+0.5);
		// if(x!=0)cout << x << ":" << qpow(g,i) << endl;
		ans+=x*qpow(g,i);
	}
	cout << ans/2 << endl;
    // for(int i=0;i<=m+n;i++){
    //     printf("%d ",int(C[i].real()/p+0.5));
    // }
    return 0;
}


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

using namespace std;

int op(char a, char b, char c){
	if (a == b && b == c) return 0;
	if (a != b && b != c && c != a) return 2;
	return 1;
}

int main(void){
	int N; cin >> N;
	string A, B, C; cin >> A >> B >> C;
	int res = 0;
	for (int i = 0; i < N; ++i)
		res += op(A[i], B[i], C[i]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
const long long mod = 1000000007;
//const long long mod = 998244353;
struct T {
	int v;
	int p;
	int ura;
	bool operator<(const T&t)const {
		if (v == t.v)return p < t.p;
		else return v < t.v;
	}
};
int main() {
	int N;
	scanf("%d", &N);
	auto A = new int[N];
	auto B = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", A + i);
	for (int i = 0; i < N; i++)scanf("%d", B + i);
	auto t = new T[N];
	int min = mod;
	for (int i = 0; i < 1 << N; i++) {
		for (int j = 0; j < N; j++) {
			if (i&(1 << j)) {
				t[j] = T{ B[j],j,1 };
			}
			else {
				t[j] = T{ A[j],j,0 };
			}
		}
		std::sort(t, t + N);
		bool can = true;
		int s = -1;
		int ki = 0;
		for (int j = 0; j < N; j++) {
			if ((t[j].p - j + t[j].ura) % 2) {
				int pp = -1;
				for (int k = j + 1; k < N; k++) {
					if (t[k].v == t[j].v) {
						if (!((t[k].p - j + t[k].ura) % 2)) {
							//printf("%d %d  %d\n", i, j, k);
							pp = k;
							break;
						}
					}
					else {
						break;
					}
				}
				if (pp == -1) {
					/*for (int k = 0; k < N; k++) {
						printf("%d", (i >> k) & 1);
					}
					printf(" %d ", j);
					for (int k = 0; k < N; k++) {
						printf("%d", t[k].p);
					}
					printf(" ", j);
					for (int k = 0; k < N; k++) {
						printf("%d", (t[k].p - j) % 2);
					}
					printf("\n");*/
					can = false;
					break;
				}
				else {
					T temp = t[pp];
					for (int k = pp; k > j; k--) {
						t[k] = t[k - 1];
					}
					t[j] = temp;
				}
			}
			/*if (i == 230984) {
				for (int i = 0; i < N; i++) {
					if (i == j) {
						printf(" V ");
					}
					else {
						printf("   ");
					}
				}
				printf("\n");
				for (int i = 0; i < N; i++) {
					printf("%2d ", t[i].v);
				}
				printf("\n");
				for (int i = 0; i < N; i++) {
					printf("%2d ", t[i].p);
				}
				printf("\n");
				for (int i = 0; i < N; i++) {
					printf("%2d ", t[i].ura);
				}
				printf("\n\n");
			}*/
		}
		if (!can)continue;
		for (int i = 0; i < N; i++) {
			//printf("%d ", t[i].v);
			//printf("%d ", t[i].p);
		}
		int cnt = 0;
		for (int j = 0; j < N; j++) {/*
			int pp;
			for (int k = 0; k < N; k++) {
				if (t[k].p == j) {
					pp = k;
					break;
				}
			}
			cnt += pp - j;
			T temp = t[j];
			for (int k = j; k < pp; k++) {
				t[k] = t[k + 1];
			}
			t[pp] = temp;*/
			for (int k = 0; k < N - 1; k++) {
				if (t[k].p > t[k + 1].p) {
					T temp = t[k];
					t[k] = t[k + 1];
					t[k + 1] = temp;
					//printf("%d ", k);
					cnt++;
				}
			}

		}
		//printf("\n%d -- ", cnt);
		//printf("%d %d\n", i,cnt);
		if (min > cnt)min = cnt;
	}
	if (min == mod) {
		printf("-1");
	}
	else {
		printf("%d", min);
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  std::cout << std::fixed << std::setprecision(20);

  int64_t N;
  cin >> N;
  
  vector<vector<pair<int64_t,int64_t>>> G(N,vector<pair<int64_t,int64_t>>());


  REP(i,N-1){
    int64_t a, b;
    cin >> a >> b;
    G[a-1].emplace_back(b-1,i);
    G[b-1].emplace_back(a-1,i);
  }

  vector<int64_t> color(N-1,-1);
  vector<int64_t> dist(N,-1);
  queue<int64_t> que;

  que.push(0);
  dist[0] = 0;

  while(!que.empty()){
    int64_t v = que.front();
    que.pop();

    int64_t c = dist[v];
    int64_t i = 1;
    for(pair<int64_t,int64_t> nv: G[v]){
      if(dist[nv.first] != -1) continue;
      if(c == i) i++;
      dist[nv.first] = i;
      color[nv.second] = i;
      i++;
      que.push(nv.first); 
    }
  }

  int64_t ans = -1;
  REP(i,N-1){
    ans = max(ans,color[i]);
  }
  cout << ans << endl;
  REP(i, N-1) cout << color[i] << endl;
  
}

Measured memory_bytes: 9600
W,H,N=map(int,input().split())
x_l=0
x_r=W
y_h=H
y_l=0

for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        x_l=max(x_l,x)
    elif a==2:
        x_r=min(x_r,x)
    elif a==3:
        y_l=max(y_l,y)
    else:
        y_h=min(y_h,y)

#print(x_l,x_r,y_h,y_l)

print(max(x_r-x_l,0)*max(y_h-y_l,0))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		// 整数の入力


int A= sc.nextInt();
int B= sc.nextInt();
int C= sc.nextInt();
int K= sc.nextInt();
int max=A;
int sonota=B+C;
int sum=0;

	if(max<B){
		if(B<C){
			max=C;
			sonota=B+A;	
		}else{
			max=B;
			sonota=A+C;
		}
		
	}else{
		if(C<max){
			max=A;
			sonota=B+C;
		}else{
			max=C;
			sonota=A+B;
		}
	}


	for(int i=0; i<K; i++){
		sum=max*2+sonota;
		max=max*2;
	}
	System.out.println(sum);
	}

}


Measured memory_bytes: 20820
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef struct{
    llint aa;
    llint bb;
}frequent;
int cmp( const void *p, const void *q ) {
    return ((frequent*)p)->aa - ((frequent*)q)->aa;
}

int main(void){
    llint n,m,i,money=0;
    scanf("%lld%lld",&n,&m);
    frequent ab[n]; 
    for(i=0;i<n;i++){
        scanf("%lld%lld",&ab[i].aa,&ab[i].bb);
    }
    qsort(ab,n,sizeof(frequent),cmp);
    for(i=0;i<n;i++){
        if(m<=ab[i].bb){
            money+=m*ab[i].aa;
            break;
        }else{
            m-=ab[i].bb;
            money+=ab[i].bb*ab[i].aa;
        }
    }




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


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

int main() {
  string s,t; cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  vector<string> a(2),b(2);
  a[0] = s;
  a[1] = t;
  b[0] = s;
  b[1] = t;
  sort(a.begin(),a.end());
  if(a[0]==b[0] && a[0]!=a[1]) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>

constexpr intmax_t mod = 1e9+7;

template <typename Tp>
Tp gcd(Tp a, Tp b, Tp& x, Tp& y) {
  x = Tp(0);
  y = Tp(1);
  for (Tp u = y, v = x; a;) {
    Tp q = b/a;
    std::swap(x -= q*u, u);
    std::swap(y -= q*v, v);
    std::swap(b -= q*a, a);
  }
  return b;
}

template <typename Tp>
Tp modinv(Tp a, Tp mod) {
  Tp x, y;
  gcd(a, mod, x, y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

template <typename Tp>
Tp modadd(Tp a, Tp b, Tp mod) {
  a += b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modadd(std::initializer_list<Tp> const& adds, Tp mod) {
  Tp res = 0;
  for (auto const& add: adds) {
    res += add % mod;
    if (res < 0) res += mod;
    if (res >= mod) res -= mod;
  }
  return res;
}

template <typename Tp>
Tp modsub(Tp a, Tp b, Tp mod) {
  a -= b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modmul(std::initializer_list<Tp> const& muls, Tp mod) {
  Tp res = 1;
  for (auto const& mul: muls) (res *= mul) %= mod;
  return res;
}

template <typename Tp>
Tp modpow(Tp base, intmax_t iexp, Tp mod) {
  Tp res = 1;
  for (Tp dbl = base; iexp; iexp >>= 1) {
    if (iexp & 1) res = res * dbl % mod;
    dbl = dbl * dbl % mod;
  }
  return res;
}

class modchoose {
  std::vector<intmax_t> fact, fact_inv;
  const intmax_t mod;

public:
  modchoose(intmax_t N, intmax_t mod): mod(mod) {
    fact.resize(N+1);
    fact_inv.resize(N+1);
    fact[0] = 1;
    for (intmax_t i = 1; i <= N; ++i)
      fact[i] = fact[i-1] * i % mod;

    fact_inv[N] = modinv(fact[N], mod);
    for (intmax_t i = N; i--;)
      fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
  }

  intmax_t operator ()(intmax_t n, intmax_t r) const {
    if (!(0 <= r && r <= n)) return 0;
    intmax_t res = fact[n] * fact_inv[r] % mod;
    (res *= fact_inv[n-r]) %= mod;
    return res;
  }
};

int main() {
  intmax_t n, k;
  scanf("%jd %jd", &n, &k);

  modchoose mc(n+k, mod);
  intmax_t res = mc(n+k-1, k-1);
  printf("%jd\n", res);
}



Measured memory_bytes: 2760
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

a,b,h,m = MI()
sit = abs(2 * math.pi *  m / 60 - 2 * math.pi * (60 * h + m) / 720 )
print(numpy.sqrt(a ** 2 + b ** 2 - 2 * a * b * numpy.cos(sit) ))

Measured memory_bytes: 27280