akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define endl "\n"
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6+5;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            for(int j=i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int isprime(ll n){
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}
int main(){
    ios;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    ans+=min(a,k);
    k-=min(a,k);
    k-=min(b,k);
    ans=ans-min(c,k);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(vector<long long> N){
  vector<bool> is_used(4, false);
  for (int i = 0; i < N.size(); i++) {
    if (N[i] == 1 && !is_used[0]) {
      is_used[0] = true;
    } else if (N[i] == 9 && !is_used[1]){
      is_used[1] = true;
    } else if (N[i] == 7 && !is_used[2]){
      is_used[2] = true;
    } else if (N[i] == 4 && !is_used[3]){
      is_used[3] = true;
    } else {
      std::cout << "NO" << std::endl;
      return;
    }
  }
  std::cout << "YES" << std::endl;
  return;
}

int main(){
  vector<long long> N(4);
  for(int i = 0 ; i < 4 ; i++){
    scanf("%lld",&N[i]);
  }
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main()
{
    int a, b;
    
    cin >> a >> b;
    if (a > b)
      cout << "a > b" << endl;
    else if (a < b)
      cout << "a < b" << endl;
    else
      cout << "a == b" << endl;
   
    return 0;
}


Measured memory_bytes: 3092
import sys
from bisect import bisect_left
sys.setrecursionlimit(10**7)
def input():return sys.stdin.readline().strip()

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    to = [[] for _ in range(N)]
    for _ in range(N-1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        to[u].append(v)
        to[v].append(u)

    INF = 10 ** 18    
    ans = [0] * N
    dp = [INF] * N
    def dfs(now, pre):
        a = A[now]
        idx = bisect_left(dp, a)

        old = dp[idx]
        dp[idx] = a

        ans_idx = bisect_left(dp, INF)
        ans[now] = ans_idx

        
        for nv in to[now]:
            if nv != pre:
                dfs(nv, now)
        

        dp[idx] = old
    
    dfs(0, -1)

    print(*ans, sep="\n")
        

if __name__ == "__main__":
    main()

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

ll cut(ll &a,ll &m){
  return (a-1)/m;
}

bool can(ll &n,ll &k,ll &m,vector<ll> &a){
  ll i,s=0;
  for(i=0;i<n;i++){
    s += cut(a.at(i),m);
  }
  if(s<=k){
    return true;
  }else{
    return false;
  }
}

int main(){
  ll n,k,i;
  cin >> n >> k;
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  ll m=1;
  if(can(n,k,m,a)){
    cout << 1 << endl;
    return 0;
  }
  ll l=1,r=1000000000;
  while(l+1<r){
    m=(l+r)/2;
    if(can(n,k,m,a)){
      r=m;
    }else{
      l=m;
    }
  }
  
  cout << r << endl;
}

Measured memory_bytes: 4780
n,m=map(int,input().split())
s=input()
t=input()

def gcd(x,y):
  r=x%y
  return gcd(y,r) if r else y
#最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

L=lcm(n,m)
g=gcd(n,m)
for i in range(g):
  if s[int(i*n/g)]!=t[int(i*m/g)]:
    print(-1)
    exit()
print(L)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, T; cin >> N >> T;
    vector<ll> t(N); rep(i, N){cin >> t.at(i);}
    ll tmp = 0;
    rep(i, N){
        if (i == N - 1){
            tmp += T;
        } else {
            if (t.at(i) + T <= t.at(i + 1)){
                tmp += T;
            } else {
                tmp += (t.at(i + 1) - t.at(i));
            }
        }
    }
    cout << tmp << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val sp = (0 until n).map { Triple(it + 1, sc.next(), sc.next().toInt()) }
    println(problem128b(n, sp))
}

fun problem128b(n: Int, sp: List<Triple<Int, String, Int>>): String {
    return sp.sortedByDescending { it.third }.sortedBy { it.second }.map { it.first }.joinToString("\n")
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7 , mod = 1e9 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n;

ll mul(ll a , ll b) {
    return a%mod * (b%mod) % mod;
}

ll sum(ll a , ll b) {
    return (a%mod + b%mod) % mod;
}

ll a[N];
ll suff[N];

void solve(int testCase){

    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++) {
            scanf("%lld" , &a[i]);
    }

    suff[n] = 0;

    for(int i = n - 1 ; i >= 0 ; i --) {
            suff[i] = sum(suff[i + 1] , a[i]);
    }

    ll ans = 0ll;
    for(int i = 0 ; i < n ; i ++) {
            ans = sum(ans , mul(a[i] , suff[i + 1]));
    }

    printf("%lld\n" , ans);
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 6948
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
   ll n,p;
   cin>>n;
   vector<ll>v;
   for(ll i=0;i<n;i++)
   {
       cin>>p;
       v.pb(p);
   }
   sort(v.begin(),v.end());
   double dd=double(v[0]+v[1])/2;
   for(ll i=2;i<n;i++)
   {
       dd+=v[i];
       dd/=2;
   }
   cout<<dd;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI = 2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


const int ABMAX = 200000;
vector<ll> inv(ABMAX); // inv[i]...i+1のmod MODにおける逆元

void INVinit(){
  for (int i=0; i<ABMAX; i++){
    // i+1のmodMODにおける逆元を計算する
    inv.at(i) = powerM((ll)(i+1), MOD-2);
  }
}

int main() {
  INVinit();
  ll n; cin >>n;
  int a,b; cin >>a >>b;

  ll res = powerM(2LL, n) - 1; // とりあえずn本から1本以上の選び方を入れとく
  // ここからa,bほんの選び方を除けば答えになる
  ll bufa = 1;
  ll bufb = 1;
  // nCa, nCbを計算しMODしたものをbufa, bufbに格納し、これらをresから除く
  for (int i=0; i<a; i++) bufa = bufa * (n-i) % MOD * inv.at(i) % MOD;
  for (int i=0; i<b; i++) bufb = bufb * (n-i) % MOD * inv.at(i) % MOD;

  res = (res - bufa + MOD) % MOD;
  res = (res - bufb + MOD) % MOD;

  cout <<res <<endl;
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    if 400 <= N and N <= 599:
        print(8)
        return
    if 600 <= N and N <= 799:
        print(7)
        return
    if 800 <= N and N <= 999:
        print(6)
        return
    if 1000 <= N and N <= 1199:
        print(5)
        return
    if 1200 <= N and N <= 1399:
        print(4)
        return
    if 1400 <= N and N <= 1599:
        print(3)
        return
    if 1600 <= N and N <= 1799:
        print(2)
        return
    if 1800 <= N and N <= 1999:
        print(1)
        return


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    string S;
    cin >> S;
    int N = S.length(), ans = 0;
    rep(i,N/2) {
        ans += S[i] != S[N-1-i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

int H;

void maxHeapify(int A[], int i) {
    int l, r, largest;
    l = i*2;
    r = i*2+1;
    if (l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if (r <= H && A[r] > A[largest]) largest = r;

    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}

int main() {
    cin >> H;
    int A[H+1];
    for (int i = 1; i <= H; i++) cin >> A[i];

    for (int i = H/2; i >= 1; i--) maxHeapify(A, i);

    for (int i = 1; i <= H; i++) {
        cout << ' ' << A[i];
    }
    cout << endl;
}


Measured memory_bytes: 5028
#include<stdio.h>
int main() {
	int a,b,c, k;
	while (scanf("%d%d%d", &a, &b, &c) != EOF) {
		if (a < b) {
			int tmp = a;
			a = b;
			b = tmp;
		}
		if (a < c) {
			int tmp = a;
			a = c;
			c = tmp;
		}
		scanf("%d", &k);
		while (k--) {
			a *= 2;
		}
		printf("%d\n", a + b + c);
	}
	return 0;
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

ll x, y;

int main()
{
	cin >> x >> y;
	if( abs(x - y) > 1 )
		cout << "Alice" << endl;
	else
		cout << "Brown" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int H,W,N;
int main(){
    cin>>H;
    cin>>W;
    cin>>N;
    
    if(H>W){
        if(N%H==0)cout<<N/H;
        else cout<<N/H+1;
    }
    else{
        if(N%W==0)cout<<N/W;
        else cout<<N/W+1;
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

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

    vector<vector<int>> v(10, vector<int>(10, 0));
    rep(i, 1, n + 1) {
        string s = to_string(i);
        int first = s.front() - '0';
        int last = s.back() - '0';

        v[first][last]++;
    }

    long long ans = 0;
    rep(i, 1, n + 1) {
        string s = to_string(i);
        int first = s.front() - '0';
        int last = s.back() - '0';

        if (first == 0 || last == 0) continue;
        ans += (long long)v[last][first];
    }

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

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V;
	Pair[] es;
	void Solve()
	{
		var I = G;
		V = I[0]; var E = I[1] + V - 1;
		es = new Pair[E];
		for (var e = 0; e < E; e++) { I = G; es[e] = new Pair(I[0] - 1, I[1] - 1); }
		var topo = TopologicalSort(V, es);
		var rev = new Dictionary<int, int>();
		for (var i = 0; i < V; i++) rev[topo[i]] = i;
		var par = new int[V];
		for (var i = 0; i < V; i++) par[i] = -1;
		foreach (var e in es) par[e.Y] = Max(par[e.Y], rev[e.X]);
		for (var i = 0; i < V; i++) WriteLine(par[i] < 0 ? 0 : topo[par[i]] + 1);
	}
	static List<int> TopologicalSort(int V, Pair[] es)
	{
		var topo = new List<int>();
		var s = new Queue<int>();
		var g = new List<int>[V];
		var rg = new int[V];
		for (var i = 0; i < V; i++) g[i] = new List<int>();
		foreach (var e in es) { g[e.X].Add(e.Y); rg[e.Y]++; }
		for (var i = 0; i < V; i++) if (rg[i] == 0) s.Enqueue(i);
		while (s.Count > 0)
		{
			var n = s.Dequeue();
			topo.Add(n);
			foreach (var m in g[n]) if (--rg[m] == 0) s.Enqueue(m);
		}
		return topo.Count == V ? topo : null;
	}
}
struct Pair
{
	public readonly int X, Y;
	public Pair(int x, int y) { X = x; Y = y; }
}


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

using namespace std;

double p[303][303][303];
double ev[303][303][303];
int cnt[4];

int main(){
  setprecision(14);
  int N;
  cin >> N;
  int ind;
  for(int i = 0; i < N; i++){
    cin >> ind;
    cnt[ind]++;
  }
  p[cnt[1]][cnt[2]][cnt[3]]=1;
  for(int c = N; c >= 0; c--){
    for(int b = N; b >= 0; b--){
      for(int a = N; a >= 0; a--){
        if(a+b+c>N)
          continue;
        if(a==0&&b==0&&c==0)
          continue;
        double p_waste = (double)(N-(a+b+c))/N;
        double ev_waste =  p_waste/(1-p_waste);
        ev[a][b][c]+=ev_waste*p[a][b][c];
        if(a != 0){
          double p_go = (double)a/(a+b+c);
          p[a-1][b][c] += p[a][b][c]*p_go;
          ev[a-1][b][c] += ev[a][b][c]*p_go;
        }
        if(b != 0){
          double p_go = (double)b/(a+b+c);
          p[a+1][b-1][c] += p[a][b][c]*p_go;
          ev[a+1][b-1][c] += ev[a][b][c]*p_go;
        }
        if(c != 0){
          double p_go = (double)c/(a+b+c);
          p[a][b+1][c-1] += p[a][b][c]*p_go;
          ev[a][b+1][c-1] += ev[a][b][c]*p_go;
        }
      }
    }
  }
  printf("%.14f" ,ev[0][0][0] + cnt[1]+2*cnt[2]+3*cnt[3]);
  return 0;
}


Measured memory_bytes: 434432
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int N,M,count=0;
	cin >> N >> M;
	int a[M],b[M];
	for(int i=0;i<M;i++){
		cin >> a[i] >> b[i];
	}

	for(int j=1;j<=N;j++){
		count = 0;
		for(int p=0;p<M;p++){
			if(a[p]==j|b[p]==j){
				count++;
			}
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int x,y,S;
  while(true) {
    cin >> x >> y >> S;
    int max = 0;
    if (x == 0 && y == 0 && S == 0)
      break;
    for (int i = 1; i < S;i++)
      for (int j = i;j < S;j++)
	if ( i * (100 + x)/100 + j * (100 +x)/100 == S)
	  if (max < i * (100 + y)/100 + j * (100 + y)/100)
	    max = i * (100 + y)/100 + j * (100 + y)/100;
    cout << max << endl;
  }
  
}

Measured memory_bytes: 3092
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
N = int(input())
b = [int(input()) for _ in range(N)]

ans = False
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = 0
            

for i in range(3):
    if sum(a[i])==0:
        ans = True
        break
    if (a[0][i]+a[1][i]+a[2][i])==0:
        ans = True
        break
if (a[0][0]+a[1][1]+a[2][2])==0:
    ans = True

if (a[0][2]+a[1][1]+a[2][0])==0:
    ans = True

if ans:print('Yes')
else:print('No')


Measured memory_bytes: 3064
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
#include <limits>
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

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

    char odd[] = "RUD";
    char even[] = "LUD";

    string in;
    cin >> in;

    for (int i = 0; i < in.size(); i++)
    {
        bool acc = false;
        if (i % 2)
        {
            for (int j = 0; j < 3; j++)
            {
                if (even[j] == in[i])
                {
                    acc = true;
                    break;
                }
            }
        }
        else
        {
            for (int j = 0; j < 3; j++)
            {
                if (odd[j] == in[i])
                {
                    acc = true;
                    break;
                }
            }
        }
        if (!acc)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
    LL a, b, n;
    scanf("%lld%lld%lld", &a, &b, &n);
    LL x = min(b-1, n);
    LL ans = max(ans, a*x/b - a*(x/b));
    printf("%lld\n", ans);
}

Measured memory_bytes: 3844
n,m = [int(x) for x in input().split( )]
a = [[0 for x in range(m)] for y in range(n)]
b = []
for i in range(n):
    retsu = [int(x) for x in input().split( )]
    a[i] = retsu
for j in range(m):
    b.append(int(input()))
answer = []
for i in range(n):
    value = 0
    for j in range(m):
        value += a[i][j]*b[j]
    answer.append(value)
for ans in answer:
    print(ans)



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

int main(){
    string s;
    cin >> s;
    ll n;
    n=s.size();
    vector <ll> ans(13,0),ans2(13,0);
    ans[0]=1;
    string h;
    ll t,z;
    rep(i,n){
        //rep(j,13) cout << ans[j];
        //cout << endl;
        if(s[n-i-1]=='?'){
            rep(j,13){
                ans2[j]=0;
            }
            if((i+1)%6==1){
                z=1;
            }
            else if((i+1)%6==2){
                z=10;
            }
            else if((i+1)%6==3){
                z=9;
            }
            else if((i+1)%6==4){
                z=12;
            }
            else if((i+1)%6==5){
                z=3;
            }
            else if((i+1)%6==0){
                z=4;
            }
            rep(j,13){
                rep(k,10){
                    ans2[(j+k*z)%13]+=ans[j];
                }
            }
           
        }
        else{
            h=s[n-i-1];
            t=stoi(h);
            if((i+1)%6==1){
                z=t;
            }
            else if((i+1)%6==2){
                z=(10*t)%13;
            }
            else if((i+1)%6==3){
                z=(9*t)%13;
            }
            else if((i+1)%6==4){
                z=(12*t)%13;
            }
            else if((i+1)%6==5){
                z=(3*t)%13;
            }
            else if((i+1)%6==0){
                z=(4*t)%13;
            }

            rep(j,13){
                ans2[(j+z)%13]=ans[j];
            }

            
            


        }
        rep(j,13){
            ans[j]=(ans2[j]%1000000007);
        }
    }

    cout << ans[5] << endl;
    

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define pb push_back
using namespace std;

const int N = 100005;
ll n, m, t, a[N], k, l[N], r[N];
ll b[N];
vector<pll> kq;
string s;
priority_queue< pii, vector<pii>, greater<pii> > pr;
void sol()
{
    cin >> n >> s;
    s = " " + s;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        l[i] = i - 1;
        r[i] = i + 1;
    }
    for(int i = 2; i <= n; i ++)
    {
        if(s[i-1] != s[i])
        {
            k = abs(a[i] - a[i-1]);
            pii u;
            u.fi = k;
            u.se.fi = i-1;
            u.se.se = i;
            pr.push(u);
        }

    }
    while(!pr.empty())
    {
        pii u = pr.top();
        pr.pop();
        ll x = u.se.fi, y = u.se.se;
        if(b[x] == 1 || b[y] == 1)continue;
        b[x] = 1;
        b[y] = 1;

        l[r[y]] = l[x];
        r[l[x]] = r[y];
        kq.pb({x, y});
        if(l[x] > 0 && r[y] <= n && s[l[x]] != s[r[y]])
        {
            pii v;
            v.fi = abs(a[l[x]] - a[r[y]]);
            v.se.fi = l[x];
            v.se.se = r[y];
            pr.push(v);
        }
    }
    cout << kq.size() <<'\n';
    for(pll u : kq)cout << u.fi <<" "<<u.se<<'\n';
}
ll random(ll minn, ll maxn)
{
    return minn + rand() % (maxn + 1 - minn);
}
priority_queue<ll> st;
ll uoc(ll a, ll b)
{
    while(b != 0)
    {
        ll r = a % b;
        a = b;
        b = r;
    }
    return a;
}
void test()
{
    cin >> n;
    m = 360;
    cout << (m * n / uoc(m, n)) / n;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    test();
}


Measured memory_bytes: 3656
package main

import (
	"fmt"
)

func main() {
	var n,y,a,b,c int
	fmt.Scan(&n,&y)

	for i := 0; i <= n; i++ {
		for j := 0; j <= n - i; j++ {
			c = i
			b = j
			a = n - i - j
			sum := 1000 * c + 5000 *b + 10000 * a
			if sum == y {
				fmt.Println(a,b,c)
				return
			}
		}
	}

	fmt.Println(-1,-1,-1)
}

Measured memory_bytes: 512
N = int(input())
p = [int(x) for x in input().split()]

q = [int(x) for x in range(1,N+1)]

cnt = 0
for j in range(0,N):
  if p[j] != q[j]:
    cnt += 1

if cnt <=2:
  print('YES')
else:
  print('NO')
    

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>p(n);
  rep(i,n)cin>>p[i];
  ll res=0;
  rep(i,n-2){
    if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i]>p[i+1]&&p[i+1]>p[i+2])){
      res++;
    }
  }
  cout<<res<<endl;
  return 0;

}


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

int main(){
  ll h;
  cin>>h;
  int p=0;
  while(h>0){
    h/=2;
    p++;
  }
  ll ans=1;
  rep(i,0,p) ans*=2;
  cout<<ans-1<<endl;
}

Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ');
  buildMaxHeap(arr);
  console.log(' ' + arr.join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = 2 * i + 1|0;
    right = 2 * i + 2|0;
    if (left < n && Number(arr[left]) > Number(arr[largest])) largest = left;
    if (right < n && Number(arr[right]) > Number(arr[largest])) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };
  for (let i = Math.floor(n / 2 - 1); i >= 0; i=(i-1)|0) maxHeapify(i);
}



Measured memory_bytes: 88300
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	int A;
	cin >> A;

	cout << N * N - A;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 9223372036854775807
using namespace std;
long long ans;
long long N,K;
long long max_num, min_num; 
long long solve() {
  long retans;
  return retans;
}

int main(int arg, char* argv[]) {
  scanf("%d %d", &N, &K);
  max_num = -INF;
  min_num = INF;
  for(int i = 0; i < K; i++) {
    long long tmp = (N + i)/K;
    max_num = max(max_num, tmp);
    min_num = min(min_num, tmp);
  }
  cout << (max_num - min_num) << endl;
  return 0;
}


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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    unordered_map<ll, ll> mp;
    rep(i, n){
        cin >> a[i];
        if (mp.find(a[i]) == mp.end()){
            mp[a[i]] = 1;
        }else{
            mp[a[i]] += 1;
        }
    }

    ll sum=0;
    for (auto x: mp){
        sum += (x.second) * (x.second-1)/2;
    }

    rep(i, n){
        ll ans = sum - (mp[a[i]] - 1);
        cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 11760
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int w = sc.nextInt();
      	int h = sc.nextInt();
      	int n = sc.nextInt();
      	boolean[][] squ = new boolean[w][h];
      	squ = beTrue(squ, w, h);
      	int[] x = new int[n];
	    int[] y = new int[n];
      	int[] a = new int[n];
      	int count = 0;
      	
      	for(int i = 0; i < n; i++){
        	x[i] = sc.nextInt();
          	y[i] = sc.nextInt();
          	a[i] = sc.nextInt();
        }
      	
      	for(int i = 0; i < n; i++){
        	if(a[i]  == 1){
            	for(int j = 0; j < x[i]; j++){
                	for(int k =0; k < h; k++){
                    	squ[j][k] = false;
                    }
                }
            }else if(a[i]  == 2){
            	for(int j = x[i]; j < w; j++){
                	for(int k = 0; k < h; k++){
                    	squ[j][k] = false;
                    }
                }
            }else if(a[i]  == 3){
            	for(int j = 0; j < w; j++){
                	for(int k = 0; k < y[i]; k++){
                    	squ[j][k] = false;
                    }
                }
            }else if(a[i]  == 4){
            	for(int j = 0; j < w; j++){
                	for(int k = y[i]; k < h; k++){
                    	squ[j][k] = false;
                    }
                }
            }
        }
      	
     	for(int i = 0 ; i < w; i++){
        	for(int j = 0; j < h; j++){
            	if(squ[i][j] == true) count++;
            }
        }
      	System.out.println(count);
    }
  
  	public static boolean[][] beTrue(boolean[][] squ, int w, int h){
    	for(int i = 0; i < w; i++){
        	for(int j = 0; j < h; j++){
            	squ[i][j] = true;
            }
        }
      	return squ;
    }
}

Measured memory_bytes: 38812
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		double min = 100000000;
		for (int i = 0; i < n; i++) {
			double d = Math.abs(t - h[i] * 0.006 - a);
			if (d < min) {
				ans = i;
				min = d;
			}
		}
		System.out.println(ans + 1);
	}
}

Measured memory_bytes: 22868
#include <iostream>

using namespace std;

int n, a[20];

bool dfs(int v, int d, int dst) {
    if (v == dst)
        return true;
    if (v > dst || d == n)
        return false;
    if (dfs(v, d + 1, dst))
        return true;
    if (dfs(v + a[d], d + 1, dst))
        return true;
    return false;
}

int main() {
    int q, m;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    cin >> q;
    while (q--) {
        cin >> m;
        if (dfs(0, 0, m))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#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)

using ll = long long;
#define INF 1e9


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> P(M), Y(M);
  vector<pair<int, ll>> ans;
  vector<vector<pair<int, int>>> PY(N);
  REP(i, M){
    cin >> P[i] >> Y[i];
    P[i]--;
    PY[P[i]].push_back({Y[i], i});
  }
  REP(i, N){
    sort(PY[i].begin(), PY[i].end());
  }
  REP(i, N){
    REP(j, PY[i].size()){
      ans.push_back({PY[i][j].second, (ll)((i+1)*1e6+j+1)});
    }
  }
  sort(ans.begin(), ans.end());
  REP(i, M){
    printf("%012lld\n", ans[i].second);
  }

  return 0;
}


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

using namespace std;
typedef long long int lli;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

L, R = map(int,input().split())
if R - L >= 2018:
    print("0")
else:
    for i in range(L, R+1):
        if i % 2019 == 0:
            print("0")
            sys.exit()
    
    min = 2018
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            calc = ((i%2019)*(j%2019)) % 2019
            if calc < min:
                min = calc
    print(str(min))

Measured memory_bytes: 41964
#include <bits/stdc++.h>
#define ll long long
#define ulli unsigned long long int
#define ld long double  
#define endl "\n"
using namespace std; 

void solve() {
    int n, m, x;
    cin >> n >> m >> x;
    
    int temp = 0;
    int left = 0, right = 0;
    for (int i = 0; i < m; i++) {
        cin >> temp;
        if (temp < x) {
            left++;
        } else {
            right++;
        }
    }

    cout << min(left, right) << endl;
}

int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    //cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 


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

int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; ++a) {  
        for (int b = 0; b + a <= N; ++b) {
            int c = N - a - b;  
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {  
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <map>

const int mod = 1000000007;
//const int mod = 998244353;
int maximum(int a, int b) { return a < b ? b : a; }
double maximum(double a, double b) { return a < b ? b : a; }
bool same(char*s, char*t) {
	for (int i = 0;; i++) {
		if (s[i] != t[i])return false;
		if (s[i] == 0) {
			return true;
		}
	}
}

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	auto A = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", A + i);
	}
	auto B = new double[N];
	for (int i = 0; i < N; i++) {
		B[i] = (A[i] + 1) / 2.0;
	}
	double sum = 0;
	for (int i = 0; i < K; i++) {
		sum += B[i];
	}
	double max = sum;
	for (int i = K; i < N; i++) {
		sum += B[i];
		sum -= B[i - K];
		max = maximum(max, sum);
	}
	printf("%f", max);
	return 0;
}

Measured memory_bytes: 2560
class Union_Find():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M,K=map(int,input().split())

A=[set() for _ in range(N+1)]
U=Union_Find(N+1)
for _ in range(M):
    a,b=map(int,input().split())
    A[a].add(b)
    A[b].add(a)
    U.union(a,b)

C=[set() for _ in range(N+1)]
for _ in range(K):
    c,d=map(int,input().split())
    C[c].add(d)
    C[d].add(c)

S=[]
for k in range(1,N+1):
    t=U.size(k)
    for a in C[k]:
        if U.find(a)==U.find(k):
            t-=1

    t-=len(A[k])
    S.append(t-1)

print(" ".join(map(str,S)))


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    REP(i,n){
        cin >> s[i];
//        sort(All(s[i]));
    }
    sort(All(s));
    REP(i,n)cout << s[i];
    cout << endl;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

calc [] [] = 0
calc (s:ss) (t:ts) | s == t = 0 + calc ss ts
                   | otherwise = 1 + calc ss ts

main = do
  [ss] <- getString
  [ts] <- getString
  print $ calc ss ts


Measured memory_bytes: 6796
#!/usr/bin/env python3

import sys

graph = {}

def solve(start, visited = set()):
    global graph

    visited = visited | set([start])
    if len(visited) == len(graph):
        return 1

    ans = 0
    for next_ in graph[start]:
        if not next_ in visited:
            ans += solve(next_, visited)
    return ans

def read_int_list():
    return [int(s) for s in sys.stdin.readline().rstrip().split(" ")]

def dprint(*args, **kwargs):
    return
    print(*args, **kwargs)

def connect(f, t):
    global graph
    if not f in graph:
        graph[f] = set()
    graph[f].add(t)

def main():
    global graph
    
    _, m = read_int_list()
    for _ in range(0, m):
        a, b = read_int_list()
        connect(a, b)
        connect(b, a)

    dprint(repr(graph))
    print(solve(1))

main()

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <numeric>

using namespace std;

typedef long long int lo;
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 

int main() {
    fast
    lo a,b;
    cin >> a >> b;
    if(b >= a){
        cout << "unsafe\n";
    }
    else{
        cout << "safe\n";
    }
    return 0;
}

Measured memory_bytes: 3640
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

def main():
    n,m = mi()
    if n == m:
        print('Yes')
    else:
        print('No')




main()


Measured memory_bytes: 5628
// Problem : D - People on a Line
// Contest : AtCoder Regular Contest 090
// URL : https://atcoder.jp/contests/arc090/tasks/arc090_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define size(x) (int)x.size()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

struct adj_list {
	int v, w;
};

bool vis[N];
int n, m, cnt = 0, par[N], pos[N];
vector<adj_list> adj[N];

void dfs(int v) {
	vis[v] = 1;
	for (auto c : adj[v]) {
		int u = c.v, w = c.w;
		if (pos[u] == inf) {
			pos[u] = pos[v] + w;
		} else if (pos[u] != pos[v] + w) {
			cout << "No";
			exit(0);
		}
		if (vis[u]) {
			continue;
		}
		dfs(u);
	}
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 1, u, v, w; i <= m; i++) {
		cin >> u >> v >> w;
		adj[u].push_back({v, w});
		adj[v].push_back({u, -w});
	}
	fill(pos + 1, pos + n + 1, inf);
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			pos[i] = 0;
			dfs(i);
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 33024
<?php

fscanf(STDIN, "%d %d %d %d", $a, $b, $h, $m);

$rad = pi() * (($h + $m / 60) / 6 - $m / 30);

$c2 = $a * $a + $b * $b - 2 * $a * $b * cos($rad);

echo sqrt($c2);


Measured memory_bytes: 16572
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ab = new int[num][];
        var cd = new int[num][];
        var res = 0;
        for (var i = 0; i < 2 * num; i++)
            if (i < num) ab[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            else cd[i%num] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        cd = cd.OrderBy(c => c[0]).ToArray();
        var point = new bool[2*num];
        for(var i = 0; i < num; i++)
        {
            var abs = ab.Where(a=> a[0] < cd[i][0] && a[1] < cd[i][1] && !point[a[0]]).OrderByDescending(a=>a[1]).FirstOrDefault();
            if (abs != null)
            {
                point[abs[0]] = true;
                res++;
            }
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

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

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

    vector <int> data(N);
    for(int i = 0; i < N; i++){
        cin >> data[i];
    }

    double ans = 0.0;
    for(int i = 0; i < N; i++){
        ans += 1.0 / data[i];
    }

    ans = 1.0 / ans;
    cout <<setprecision(16) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<bitset>
#include<algorithm>
using namespace std;

set<int> vertex;
vector< vector<int> > edge;

int dfs(int v, bitset<101> visited, int depth) {
    int result = depth;
    visited.set(v);
    for(vector<int>::iterator i=edge[v].begin(); i!=edge[v].end(); i++) {
        if(visited.test(*i)) continue;
        result = max(result, dfs(*i, visited, depth+1));
    }
    return result;
}

int solve() {
    int result = 0;
    for(set<int>::iterator i=vertex.begin(); i!=vertex.end(); i++) {
        result = max(result, dfs(*i, bitset<101>(0), 1));
    }
    return result;
}

int main() {
    int n;
    while(cin>>n, n) {
        edge = vector< vector<int> >(101);
        for(int i=0; i<n; i++) {
            int u, v;
            cin>>u>>v;
            vertex.insert(--u);
            vertex.insert(--v);
            edge[u].push_back(v);
            edge[v].push_back(u);
        }
        cout<<solve()<<endl;
    }
}

Measured memory_bytes: 1228
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int[]X = new int[N];
			int[]S = new int[N];
			for(int i=0;i<N;i++){
				X[i] = scan.nextInt();	
				S[i] = X[i];
			}
			//Pの範囲も１から１００まで
			Arrays.sort(S);
			int ps = S[0];
			int pf = S[N-1];
			
			ArrayList<Integer> minpower = new ArrayList<Integer>();
			
			for(int i = ps;i<=pf;i++) {
				int souwa=0;
				for(int j = 0;j<N;j++) {
					souwa+=(int)Math.pow(X[j]-i, 2);
				}
				minpower.add(souwa);
			}
			
			Collections.sort(minpower);
			
			
			
			System.out.println(minpower.get(0));

			
			
		}
		
		
	}
		

}


Measured memory_bytes: 21844
import math

N, D = map(int,input().split())

XY = [map(int, input().split()) for _ in range(N)]
X, Y = [list(i) for i in zip(*XY)]

count = 0
i = 0

while i <= N-1:

    xy = X[i]**2 + Y[i]**2

    if math.sqrt(xy) <= D:
        count += 1
    
    i += 1

print(count)

Measured memory_bytes: 116744
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <climits>
#include <vector>

using namespace std;

typedef vector< int > VI;
typedef vector< VI > VVI;

struct edge{ int from, to, cost; };

#define MAX_N 101
#define MAX_E 1000

int par[MAX_N];
int Rank[MAX_N];
edge map[MAX_E];

// nで初期化
void init( int n ) {
	for(int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}

// 木の根を求める
int find( int x ) {
	if(par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}

// xとyの属する集合を合併
void unite( int x, int y ){
	x = find(x);
	y = find(y);

	if( x == y ) {
		return;
	}

	if( Rank[x] < Rank[y] ) {
		par[x] = y;
	} else {
		par[x] = y;
		if( Rank[x] == Rank[y] ) {
			Rank[x]++;
		}
	}
}

// xとyが同じ集合に属するか否か
bool same( int x, int y ) {
	return find(x) == find(y);
}


bool comp( const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

int main() {
	int n, m;

	while( true ){
		cin >> n >> m;
		if(n == 0 && m == 0) {
			break;
		}

		int a, b, c;
		for(int i = 0; i < m; i++) {
			cin >> a >> b >> c;
			map[i].from = a;
			map[i].to = b;
			map[i].cost = c;
		}

		sort(map, map + m, comp);
		init(n);
		int res = 0;
		for(int i = 0; i < m; i++) {
			edge e = map[i];
			if(!same(e.from, e.to)) {
				unite(e.from, e.to);
				res += e.cost;
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 1188
#include<iostream>
#include<fstream>
#include<string>

using namespace std;

int main(){
	
	int K,N,ans,d;
	ans = 1;
	cin >> N >> K ;
	
			for(int j=1;j<=N-1;j++){
				ans=ans*(K-1);	
			}
  	ans = K*ans;
  	cout << ans << endl;
	
return 0;	
};

Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def bisect_left_callable(fn, x, lo, hi):
    """
    (memo) いっぱい呼ぶなら np.searchsorted のほうがベクトル化されててはやそう
    lo から hi-1 のうち、fn の結果が x 以上となる、最も左の値
    bisect.bisect_left と同じ
    https://docs.python.org/ja/3/library/bisect.html
    :param callable fn:
    :param x:
    :param int lo: 最小値
    :param int hi: 最大値 + 1
    :return: lo <= ret <= hi
    """
    while lo < hi:
        mid = (lo + hi) // 2
        if fn(mid) < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


def solve(n, a=False):
    mts = A.copy()
    mts[0] -= n
    mts[-1] -= n
    hist = [n*2]
    for i in range(N):
        mts[(i + 1) % N] -= mts[i]
        hist.append(mts[i] * 2)
    if a:
        return hist
    else:
        return -mts[-1]


n = bisect_left_callable(solve, 0, 0, A[0] + 1)
print(*solve(n, True)[:-1])


Measured memory_bytes: 16828
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	while (N) {
		vector<vector<vector<int>>>dp(N + 1, vector<vector<int>>(M + 1, vector<int>(K + 1)));
		dp[0][0][0] = 1;
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= M; j++) {
				for (int k = i; k <= K; k++) {
					for (int l = 0; l < i; l++) {
						dp[i][j][k] += dp[l][j - 1][k - i];
					}
				}
			}
		}
		int ans = 0;
		for (int i = 1; i <= N; i++) {
			ans += dp[i][M][K];
		}
		cout << ans << endl;
		cin >> N >> M >> K;
	}
	return 0;
}


Measured memory_bytes: 3208