akhauriyash/Code-Regression huggingface dataset:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    a,b,c,k = map(int,input().strip().split())
    # print( a-max(0,k-a-b)  )
    if a>k:
        print(k)
    elif k>a+b:
        print(2*a+b-k)
    else:
        print(a)


if __name__ == '__main__':
    main()

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"(";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<")";
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

constexpr ll Ten(int n){
	return n==0?1:Ten(n-1)*10;
}

template<class T>
vector<T> Uniqued(const vector<T>&vv){
	auto v(vv);
	sort(ALL(v));
	v.erase(unique(ALL(v)),v.end());
	return v;
}
template<class T>
void MakeUniqued(vector<T>&v){
	sort(ALL(v));
	v.erase(unique(ALL(v)),v.end());
}

signed main(){
	int k=read(),a=read(),b=read();
	int y=b-a;
	if(y<=2)
		print(k+1);
	else{
		int ans=1;
		int w=min(a-1,k);
		ans+=w;
		k-=w;
		if(k){
			int p=k/2,q=k%2;
			ans+=p*y;
			ans+=q;
		}
		print(ans);
	}
}


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

int main(){
  int64_t n;
  cin >> n;
  int64_t ans=2e12;
  for(int i=1;i<=sqrt(n);i++){
    if(n%i==0)
      ans=min(ans,i+n/i-2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3676
// https://atcoder.jp/contests/abc094/tasks/abc094_b

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;

    int l = 0;
    int r = 0;
    for (int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        if (a < x)
        {
            l++;
        }
        else
        {
            r++;
        }
    }

    int ans = min(l, r);
    cout << ans << endl;
}


Measured memory_bytes: 3556
const main = (input) => {
  input = input.trim().split('\n')
  const mod = BigInt(10**9 + 7)
  const arr = input[1].split(' ').map(BigInt)

  let sum = arr[0] + arr[1]
  let ans = arr[0] * arr[1] % mod

  for (let i=2; i<arr.length; i++) {
    ans += sum * arr[i]
    ans %= mod
    sum += arr[i]
  }

  const r = Number(ans % mod)
  console.log(r)
}


process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 72936
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/
int main(){
    int N; cin >> N;
    vector<pair<int,int> > a(N);
    for (int i = 0; i < N; i++){
        int num; cin >> num;
        a[i] = {num, i+1};
    }
    sort(a.begin(),a.end());
    for (int i = 0; i < N; i++){
        cout << a[i].second << " ";
    }
    cout << endl;
}

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

using namespace std;
using ll = long long;

int main(void) {
    int n;    
    scanf("%d", &n);
    vector<ll> arr(n);
    vector<ll> pre1(n), pre2(n);
    map<ll, int> cnt;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &arr[i]);
        pre1[i] = (arr[i] - i);
        pre2[i] = -1 * (i + arr[i]);
    }
    ll ans = 0;
    cnt[pre2[0]] = 1;
    for (int i = 1; i < n; i++) {
        if (cnt[pre1[i]])
            ans += cnt[pre1[i]];
        ++cnt[pre2[i]];
    }
    printf("%lld\n", ans);
    return 0;
}


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

at index i diff(ind) E [0, i]
h1 h2 h3 h4 ...... hn
i1 i2 i3 i4 ...... in

h[idx] + h[idx - x] = x
h[idx] + h[idx - x] = idx - (idx - x)
1. h[idx] - idx = -(h[idx - x] + idx - x) , x > 0

pre1 : 2 2 1 -2 -1 -4 (h[idx] - idx)
pre2 : -2 -4 -5 -4 -7 -6 (-(h[idx] + idx))
ans : 3
*/



Measured memory_bytes: 30620
#include<iostream>
#include<vector>
#include<numeric>

int main() {
    using namespace std;
    ios_base::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector vec(M,0);

    for(auto & v: vec) 
    {
        cin >> v;
    }

    cout << max(-1, N - std::accumulate(vec.begin(), vec.end(), 0));
    
}

Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X=X;}
#define TF(f) {f=f;}
#define END {}
#endif

  vector<ll>G[100010];
  bool vis[100010];
  deque<ll>ans;
  ll N,M;
  void dfs1(ll pos){
    vis[pos]=true;
    for(auto x:G[pos]){
      if(!vis[x]){
        ans.push_front(x);
        dfs1(x);
        break;
      }
    }
  }
  void dfs2(ll pos){
    vis[pos]=true;
    for(auto x:G[pos]){
      if(!vis[x]){
        ans.push_back(x);
        dfs2(x);
        break;
      }
    }
  }


int main(){
  ios_base::sync_with_stdio(false);
  cin>>N>>M;
  REP(i,M){
    int a,b;
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  memset(vis,false,sizeof(vis));
  ans.push_back(1);
  dfs1(1);
  dfs2(1);
  cout<<ans.size()<<endl;
  REP(i,ans.size()-1)cout<<ans[i]<<" ";
  cout<<ans[ans.size()-1]<<endl;
  return 0;
}


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

class D
{
	static void Main()
	{
		var nexts = new[] { "01", "012", "123", "234", "345", "456", "567", "678", "789", "89" };
		var k = int.Parse(Console.ReadLine());

		if (k <= 9) { Console.WriteLine(k); return; }

		var t = 9;
		var ls = new List<List<string>> { Enumerable.Range(1, 9).Select(i => $"{i}").ToList() };
		for (int i = 0; ; i++)
		{
			var l = new List<string>();
			ls.Add(l);

			foreach (var s in ls[i])
			{
				foreach (var c in nexts[s[^1] - '0'])
				{
					l.Add(s + c);
					if (++t == k) { Console.WriteLine(l[^1]); return; }
				}
			}
		}
	}
}


Measured memory_bytes: 36248
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length;
		int M = T.Length;
		var BTSA = new BIT(N);
		var BTSB = new BIT(N);
		var BTTA = new BIT(N);
		var BTTB = new BIT(N);
		for(int i=0;i<N;i++){
			if(S[i] == 'A') BTSA.Add(i+1,1);
			if(S[i] == 'B') BTSB.Add(i+1,1);
		}
		for(int i=0;i<M;i++){
			if(T[i] == 'A') BTTA.Add(i+1,1);
			if(T[i] == 'B') BTTB.Add(i+1,1);
		}
		
		int[][] jud = new int[3][];
		jud[0] = new int[]{0,-1,1};
		jud[1] = new int[]{1,0,-1};
		jud[2] = new int[]{-1,1,0};
		
		
		var sbd = new StringBuilder();
		for(int q=0;q<Q;q++){
			int a = Query[q][0];
			int b = Query[q][1];
			int c = Query[q][2];
			int d = Query[q][3];
			int sa = BTSA.Sum(b) - BTSA.Sum(a-1);
			int sb = BTSB.Sum(b) - BTSB.Sum(a-1);
			int ta = BTTA.Sum(d) - BTTA.Sum(c-1);
			int tb = BTTB.Sum(d) - BTTB.Sum(c-1);
			
			sa %= 3;
			sb %= 3;
			ta %= 3;
			tb %= 3;
			
			if(jud[sa][sb] == jud[ta][tb]){
				sbd.AppendLine("YES");
			} else {
				sbd.AppendLine("NO");
			}
		}
		Console.Write(sbd.ToString());
	}
	
	String S,T;
	int Q;
	int[][] Query;
	public Sol(){
		S = rs();
		T = rs();
		Q = ri();
		Query = new int[Q][];
		for(int i=0;i<Q;i++) Query[i] = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
class BIT{
	int MM;
	int n;
	long[] bit;
	public BIT(int n_){
		n=n_;
		MM=1<<18;
		while(MM<n*2)MM<<=1;
		bit=new long[MM+1];
	}
	//1-origin!!
	public void Add(int i,int x){
		while(i<=n){
			bit[i]+=x;
			i+=(i&-i);
		}
	}
	
	// i=>sum(a_1,...,a_i)
	// i=0 -> return 0;
	public int Sum(int i){
		long s=0;
		while(i>0){
			s+=bit[i];
			i-= (i&-i);
		}
		return (int)s;
	}
}


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

#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 INF 1e9

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  ll S = a + b + a+b;
  if((S <= c && a!=b) || S < c){
    cout << "Yes" << endl;
  }
  else if(a+sqrt(a*b)*2+b < c){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split("")
x,y = gets.chomp.split(" ").map(&:to_i)
disp = [[0],[]]
f = 0
done = []
s.each do |str|
  if str == "F"
    disp[f][-1] += 1
  else
    f = 1-f
    disp[f] << 0
  end
end
start = [disp[0][0],0]
disp[0].shift
disp.each do |arr|
  arr.delete(0)
end
size = [disp[0].size,disp[1].size]
2.times do |i|
  done[i] = Array.new(size[i]+1).map{Hash.new(false)}
  done[i][0][start[i]] = true
  for j in 0..size[i]-1
    done[i][j].each do |k,v|
      done[i][j+1][k+disp[i][j]] = true
      done[i][j+1][k-disp[i][j]] = true
    end
  end
end
if done[0][-1][x] && done[1][-1][y]
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 262396
import heapq as h
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
e6 = 10**6
q = [-b[i]*e6-i for i in range(n)]
q.sort()
cnt = 0
while q:
  w = -h.heappop(q)
  v, i = divmod(w, e6)
  u = b[i-1] + b[(i+1)%n]
  if v < u or a[i] == v: continue
  elif a[i] > v: print(-1); exit(0)
  t = (v-a[i])//u
  if not t: print(-1); exit(0)
  cnt += t
  b[i] -= t*u
  if b[i] > a[i]:
    h.heappush(q,-b[i]*e6-i)
print(cnt if a==b else -1)


Measured memory_bytes: 118520
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,c,ans=inf; cin>>n>>c;
    vector<int> x(c,0),y(c,0),z(c,0);
    vector<vector<int>> d(c,vector<int>(c,0));
    rep(i,c){
        rep(j,c){
            cin>>d[i][j];
        }
    } 
    rep(i,n){
        rep(j,n){
            int co; cin>>co; co--;
            if((i+j)%3==0) x[co]++;
            if((i+j)%3==1) y[co]++;
            if((i+j)%3==2) z[co]++;
        }
    } 
    rep(p,c){
        rep(q,c){
            if(q==p) continue;
            rep(r,c){
                if(r==p || r==q) continue;
                int cnt=0;
                rep(i,c){
                    cnt+=x[i]*d[i][p];
                    cnt+=y[i]*d[i][q];
                    cnt+=z[i]*d[i][r];
                }
                ans=min(ans,cnt);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	bool ans=false;
	cin >>n;
	vector<int>fact;
	fact.push_back(1);
	for(int i=2;fact.back()<n;i++){
		fact.push_back(fact.back()+i);
	//	clog<<fact.back()<<" ";
	}
	if(fact.back()==n){
		ans=true;
	}
	cout<<solve(ans)<<endl;
	if(ans==false){
		return 0;
	}
	vector<vector<int>>box(fact.size()+1);
	int at=1;
	for(int ati=0;ati<box.size()-1;ati++){
		for(int ini=ati+1;ini<box.size();ini++){
			box[ati].push_back(at);
			box[ini].push_back(at);
			at++;
		}
	}
	cout<<box.size()<<endl;
	for(int i=0;i<box.size();i++){
		cout<<box[i].size();
		for(int j=0;j<box[i].size();j++){
			cout<<" "<<box[i][j];
		}
		cout<<endl;
	}
}

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

int main(int argc, char const *argv[])
{
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << flush;
  else
    cout << "consonant" << flush;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
 int R[MAX], n ;
 cin >> n ;
 for(int i=0;i<n;i++) cin >> R[i] ;
 int maxv = -2000000000;
 int minv = R[0];

 for(int i=1;i<n;i++){
   maxv = max(maxv,R[i]-minv);
   minv = min(minv,R[i]);
}
cout << maxv << endl ;
return 0 ;
}




Measured memory_bytes: 3868
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define rep(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

int n;cin>>n;
cout<<n*(1+n+n*n);
}

Measured memory_bytes: 3652
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	int t, x, s;
	cin >> x;
	t = 1;
	s = 0;
	while (s + t < x) {
		s += t;
		t++;
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        HashMap<String, Integer> map = new HashMap<>();

        for (int i = 0; i < w.length(); i++) {
            String key = String.valueOf(w.charAt(i));

            if (map.containsKey(key)) {
                map.put(key, map.get(key)+1);
            } else {
                map.put(key, 1);
            }
        }

        boolean isBeauty = true;
        for (HashMap.Entry entry: map.entrySet()) {
            if ((Integer) entry.getValue() % 2 != 0) {
                isBeauty = false;
                break;
            }
        }

        System.out.println(isBeauty ? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for (int i = 0; i < 3; i++) {
			if (s.charAt(i) == '1') {
				System.out.print('9');
			} else {
				System.out.print('1');
			}
		}
	}
}

Measured memory_bytes: 21840
while True:
    n, x = [int(_) for _ in input().split()]
    if n == x == 0:
        exit(0)
    
    cnt = 0
    for i in range(1, n):
        for j in range(i, n):
            if i == j:
                continue
            k = x - i - j
            if k > n:
                continue
            if k <= j:
                continue
            cnt += 1
    print(cnt)



Measured memory_bytes: 5604
M,K = (int(x) for x in input().split())

if M == 0:
    if K == 0:
        print("0 0")
        exit()
    else:
        print("-1")
        exit()
if M == 1:
    if K == 0:
        print("0 0 1 1")
        exit()
    else:
        print("-1")
        exit()

if K >= 2**M:
    print("-1")
    exit()

for i in range(2**M):
    if i != K:
        print(i, end=" ")
print(K, end=" ")
for i in range(2**M):
    if 2**M-1-i != K:
        print(2**M-1-i, end=" ")
print(K)



Measured memory_bytes: 4944
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
pair<int,int> a[N];
int n;
int main()
{
	scanf("%d",&n);
	for (int i=1,x,y;i<=n;i++) scanf("%d%d",&x,&y), a[i]=make_pair(x+y,x-y);
	sort(a+1,a+1+n);
	int cur=-1e9,ans=0;
	for (int i=1;i<=n;i++)
		if (cur<=a[i].second) ans++, cur=a[i].first;
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
f(int*a,int*b){return*a-*b;}
a[1<<17];buf[300000];char*p=buf;
i;
s=1e9;
l,r;
main(){
	read(0,buf,1100000);
	for(;*p;p+=1)
	{
		if(*p=='-')r=1;
		else if(*p<48)i++,r=0;
		else a[i]=a[i]*10+(r?48-*p:*p-48);
	}
	qsort(a+2,a[0],4,f);
	for(i=0;i<=a[0]-a[1];i+=1)
	{
		l=a[i+2]>0?0:-a[i+2];
		r=a[i+a[1]+1]<0?0:a[i+a[1]+1];
		r+=r<l?r:l;
		s=s<r+l?s:r+l;
	}
	printf("%d",s);
}


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

// NOTE TO SELF // try to simplyfy the problem

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

#define ll long long int

//const int mod=1000000007;

using namespace std;




int main()
{

    int n,k;
    cin>>n>>k;
    
    vector<int> h(n);
    
    for(auto &it:h)
        cin>>it;
    
    const int INF=1e9+5;
    
    vector<int> dp(n,INF);
    
    dp[0]=0;
    
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<i+1+k;j++)
        {
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            
            
            
        }
        
        
    }
    
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int x, y;
int a, b, c;
int p[N], q[N], r[N];
vector<pair<int, int> > v;

int32_t main()
{
	IOS;
	cin >> x >> y >> a >> b >> c;
	for(int i = 1; i <= a; i++)
	{
		cin >> p[i];
		v.push_back({p[i], -1});
	}
	for(int i = 1; i <= b; i++)
	{
		cin >> q[i];
		v.push_back({q[i], -2});
	}
	for(int i = 1; i <= c; i++)
	{
		cin >> r[i];
		v.push_back({r[i], -3});
	}
	int ans = 0;
	sort(v.rbegin(), v.rend());
	int extra = 0;
	for(auto &it:v)
	{
		if(extra == x + y)
			break;
		if(it.second == -1)
		{
			if(x > 0)
			{
				ans += it.first;
				x--;
			}
		}
		else if(it.second == -2)
		{
			if(y > 0)
			{
				ans += it.first;
				y--;
			}
		}
		else
		{
			ans += it.first;
			extra++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 12652
N,M = map(int,input().split())
array = []

for i in range(M):
    a = list(map(int,input().split()))
    a.pop(0)
    sum = 0
    for j in range(len(a)):
        sum += 2**(a[j]-1)
    array.append(sum)

s = 0
for i in range(N):
    s += 2**i

p = list(map(int,input().split()))

total = 0
for switch in range(s+1):
    c = 0
    for i in range(M):
        if (bin(switch & array[i]).count('1'))%2 == p[i]:
            c += 1
    if c == M:
        total += 1

print(total)



Measured memory_bytes: 3188
n,l = map(int,input().split())
a = list(map(int,input().split()))

renzoku_length = [0]*n
last_undo = -1
for i in range(1,n):
  renzoku_length[i] = a[i]+a[i-1]
  if renzoku_length[i]>=l:
    last_undo =i
    break

if last_undo ==-1:
  print("Impossible")
  exit()

print("Possible")

for i in range(1,last_undo):
  print(i)
for i in range(last_undo+1,n)[::-1]:
  print(i)
print(last_undo)

    

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

class uf{
  int n;
  vector<int> rank, parent;
public:
  uf();
  uf(int _n){
    init(_n);
  }
  void init(int _n){
    n = _n;
    rank.resize(n);
    parent.resize(n);
    for (int i = 0; i < n; i++) {
      rank[i] = 0;
      parent[i] = i;
    }
  }
  int find(int x){
    if(x == parent[x])return x;
    else return parent[x] = find(parent[x]);
  }
  
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      parent[x] = y;
    }else{
      parent[y] = x;
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
};


int main(){
  int n, q;
  std::cin >> n >> q;
  uf u(n);
  for (int i = 0; i < q; i++) {
    int com, x, y;
    std::cin >> com >> x >> y;
    if(com){
      std::cout << u.same(x, y) << std::endl;
    }else{
      u.unite(x, y);
    }
  }
  return 0;
}

Measured memory_bytes: 1280
var readline = require('readline')
var reader = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

var lines = [];
reader.on('line', function(line) {
  lines.push(line);
});

reader.on('close', function() {
  var words = lines[0].split(' ');
  var N = Number(words[0]), H = Number(words[1]);

  var B = [], amax = 0;
  for(var i=1; i<=N; ++i) {
    var ab = lines[i].split(' ').map(Number);
    amax = Math.max(amax, ab[0]);
    B.push(ab[1]);
  }
  B.sort(function(x,y){return y-x;})

  var ans=0;
  for(var i=0; i<N && B[i]>amax && H>0; ++i) {
    ans+=1;
    H -= B[i];
  }

  H = Math.max(H,0);
  ans += Math.ceil(H/amax);

  console.log(ans);

});

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

uint_fast32_t N, M, a[101010], A;

int main(){
    scanf("%u%u", &N, &M);
    for(int i = 1; i <= N; ++i){
        scanf("%u", a + i);
        a[i] += a[i - 1];
        a[i] %= M;
    }
    sort(a, a + N + 1);
    for(int i = 0, j = 0; i <= N; ++i){
        if(i && a[i] != a[i - 1])j = 0;
        A += j++;
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
	int A, B, C;
	int K;
	int max;
	int ans;

	cin >> A >> B >> C;
	cin >> K;

	if (A >= B && A >= C){
		for (int i = 1; i <= K; i++)
		{
			A *= 2;
		}
	}else if (B >= A && B >= C){
		for (int i = 1; i <= K; i++)
		{
			B *= 2;
		}
	}else if (C >= A && C >= B){
		for (int i = 1; i <= K; i++)
		{
			C *= 2;
		}
	}

	ans = A + B + C;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
while True:

    n, x = map(int, input().split())

    if n == 0 and x == 0:
        break

    count = 0
    for i in range(1, n+1):
        for j in range(1, i):
            for k in range(1, j):
                if i + j + k == x:
                    # print(i, j, k)
                    count+=1
                    break

    print(count)



Measured memory_bytes: 5596
/*
 * 高橋君は、N 以下の正の整数の 2 つ組 (a,b) を持っていましたが、忘れてしまいました。 高橋君は、a を b で割ったあまりが K 以上であったことを覚えています。
 * 高橋君が持っていた組としてあるうるものの個数を求めてください。
 */

import java.util.*;
	public class Main{
		public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            long n = Integer.parseInt(sc.next());
            long k = Integer.parseInt(sc.next());
            long ret = 0;
            
            // b(iとおいている)はkより大きくn以下
            for(int i=(int)k+1; i<=n; i++){
            	// n/iの商の個数だけ等しく(i-k)個条件を満たすものが存在、n%iの余りの分については余りの個数がMath.max(k-1, 0)を越えている分だけ余分に足す
            	ret += (n/i) * (i-k) + Math.max(0, n%i - Math.max(k, 1) + 1);
            }
            
            System.out.println(ret);
            sc.close();
		}
    }
	

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef priority_queue<int> Pr; typedef vector<int> Vi; typedef vector<P> Vp; typedef map<int,int> MP; typedef vector<Int> VI;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}
int cnt; WeightedGraph<int> g; vector<bool> s;
void dfs(int e){
	cnt++;
	for(auto k:g[e])if(!s[k]){
		s[k]=1; dfs(k);
	}
	return;
}

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

    int n; cin>>n; g.assign(n,{});
	priority_queue<P> we,be;
	for (int i = 0; i < n-1; i++){
		int a,b; cin>>a>>b;
		g[--a].emplace_back(--b,1);
		g[b].emplace_back(a,1);
	}
	Vi d=dijkstra(g,0),r; 
	int f=n-1; r.push_back(f); s.assign(n,0); s[f]=1;
	while(true){
		for(auto e:g[f])if(!s[e]&&d[e]==d[f]-1){
			f=e; s[e]=1; break;
		}
		r.push_back(f);
		if(!f)break;
	}
	//for(auto e:r)cout<<e<<' ';
	for (int i = 0; i < r.size()/2; i++){
		dfs(r[i]);
	}
	cout<<(cnt<n-cnt?"Fennec":"Snuke")<<'\n';
}

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

int main() {
    int N;
    cin >> N;
    int cnt[100100] = {}, a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        cnt[a]++;
    }

    int ans = 0;
    for (int i = 0; i <= 100000; i++) {
        ans = max(ans, cnt[i] + cnt[i + 1] + cnt[i + 2]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,p;
    int max = 0, ans = 0;
    cin >> N;
    rep(i,N){
        cin >> p;
        if (max < p){
            max = p;
        }
        ans += p;
    }
    ans = (ans - max) + (max / 2);
    cout << ans << endl;
}

Measured memory_bytes: 256
from math import cos,sin,pi,sqrt

A,B,H,M=map(int,input().split())
t=pi*(60*H+M)/360
s=pi*M/30
X=(A*sin(t),A*cos(t))
Y=(B*sin(s),B*cos(s))
print(sqrt((X[0]-Y[0])**2+(X[1]-Y[1])**2))


Measured memory_bytes: 62452
#include <iostream>
#include <string>

using namespace std;

// 選択ソート
// ソート済みと未ソート部分列を分けて、最小値をソート済みに設定していく

const int ARRAY_MAX = 100;

void printArray(int *A, int n)
{
    for (int i = 0; i < n; i++)
    {
        cout << A[i];
        if (i != n-1)
            cout << " ";
    }
    cout << endl;
}

void swap(int *A, int a, int b)
{
    int tmp = A[a];
    A[a] = A[b];
    A[b] = tmp;
}

// 交換回数を返す。
int selectionSort(int *A, int n)
{
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        int minj = i; // 未ソートで一番小さい要素のインデックス
        for (int j = i; j < n; j++)
        {
            if (A[j] < A[minj])
                minj = j;
        }
        if (i != minj)
        {
            swap(A, i, minj);
            count++;
        }
    }
    return count;
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A[ARRAY_MAX] = { 0 };

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i];

    int count = selectionSort(A, n);
    printArray(A, n);
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    char al = A.back();
    char bs = *B.begin();
    char bl = B.back();
    char cs = *C.begin();
    if(al==bs&&bl==cs){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b;
int cnt[5000];
vector<int> G[5000];

void solve(){
  int flg=0;
  queue<int> Q;
  for(int i=0;i<n;i++)
    if(cnt[i]==0)Q.push(i);

  while(!Q.empty()){
    if(Q.size()>1)flg=1;
    int pos=Q.front();Q.pop();
    printf("%d\n",pos+1);
    for(int i=0;i<(int)G[pos].size();i++){
      int to=G[pos][i];
      cnt[to]--;
      if(cnt[to]==0)Q.push(to);
    }
  }
  cout<<flg<<endl;
}
int main(){
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    a--,b--;
    G[a].push_back(b);
    cnt[b]++;
  }
  
  solve();
  return 0;
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int main(){
  ll n;cin >> n;vector<ll>a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) a[i]-=i+1;
  sort(a.begin(),a.end());
  ll stand = n/2,standard = a[stand],ans=0;
  for(int i=0; i<n; i++){
    a[i]-=standard;
    ans+=abs(a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

std::vector<int> eval(std::vector<int> & x) {
	std::vector<int> vec;
	std::set<int> st;
	for(auto v: x) {
		if(st.count(v)) {
			while(st.count(v)) {
				int p = vec.back();
				vec.pop_back();

				st.erase(p);
			}
		} else {
			st.insert(v);
			vec.push_back(v);
		}
	}

	return vec;
}

int main() {
	int n; i64 k; scanf("%d%lld", &n, &k); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);

	// solve
	std::vector<int> nearest(n);
	{ // construct nearest
		std::vector<int> last(2e5 + 10, -1);
		for(int i = 0; i < 2 * n; i++) {
			int v = a[i % n];

			if(~last[v] and last[v] < n) {
				nearest[last[v]] = i;
				last[v] = i;
			} else {
				last[v] = i;
			}
		}
	}

//	for(auto v: nearest) cout << v << " "; cout << endl;

	int T = 1;
	{ // 周期を求める（高々 N）
		int now = 0;
		while(true) {
			T += (n <= nearest[now]);
			now = (nearest[now] + 1) % n;
			
			if(!now) break;
		}
	}
	
	k %= T;
	int now = 0;
	while(k > 1) {
		k -= (n <= nearest[now]);
		now = (nearest[now] + 1) % n;
	}

	std::vector<int> ans;
	for(int i = now; i < n; i++) ans.push_back(a[i]);
	ans = eval(ans);

	for(auto v: ans) printf("%d ", v);
	printf("\n");
	return 0;
}


Measured memory_bytes: 13280
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
using namespace std;

#define int long long
int cnt[2020];

int32_t main() {
	
 	string s;
 	
    cin>>s;
   
	reverse(s.begin(),s.end());
	
	int ans=0;
	
	int p = 1;
	
	int total =0;
	
	for(int i=0 ;i<s.length(); i++){
		
		cnt[total]++;
		
		total += ( ( s[i] - '0') * p);
		
		total %= 2019;
		
		ans += cnt[total];
		
		p = p* 10 % 2019;
		
	}

	cout << ans << endl;
	
}

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

struct Graph {
	vector<vector<int> > edges;
	vector<int> dst;
	int size;
	Graph(int n) {
		size = n;
		edges.resize(n);
		dst.resize(n);
	}
	
	int deg(int i) {
		return edges[i].size();
	}
	
	void bfs(vector<int> s) {
		fill(dst.begin(), dst.end(), -1);
		queue<int> q;
		for (int i = 0; i < s.size(); i++) {
			q.push(s[i]);
			dst[s[i]] = 0;
		}
		while (!q.empty()) {
			int v = q.front();
			q.pop();
			for (int i = 0; i < edges[v].size(); i++) {
				int new_dst = dst[v] + 1;
				if (dst[edges[v][i]] == -1) {
					dst[edges[v][i]] = new_dst;
					q.push(edges[v][i]);
				}
			}
		}
		return;
	}
	
	void bfs(int s) {
		fill(dst.begin(), dst.end(), -1);
		queue<int> q;
		q.push(s);
		dst[s] = 0;
		while (!q.empty()) {
			int v = q.front();
			q.pop();
			for (int i = 0; i < edges[v].size(); i++) {
				int new_dst = dst[v] + 1;
				if (dst[edges[v][i]] == -1) {
					dst[edges[v][i]] = new_dst;
					q.push(edges[v][i]);
				}
			}
		}
		return;
	}
	void add_edge(int u, int v) {
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
};

int main() {
	int n;
	cin >> n;
	if (n == 2) {
		cout << "1 2\n";
		return 0;
	}
	Graph g(n);
	int u[n], v[n];
	for (int i = 1; i < n; i++) {
		cin >> u[i] >> v[i];
		g.add_edge(--u[i], --v[i]);
	}
	pair<int, ll> ans(n, n);
	for (int i = 0; i < n; i++) {
		g.bfs(i);
		int m[n], d = 0;
		fill(m, m+n, 0);
		for (int j = 0; j < n; j++) {
			d = max(d, g.dst[j]);
			m[g.dst[j]] = max(m[g.dst[j]], g.deg(j));
		}
		pair<int, ll> temp(d + 1, m[0]);
		for (int j = 1; j < d; j++) {
			temp.second *= m[j] - 1;
		}
		ans = min(ans, temp);
	}
	for (int i = 1; i < n; i++) {
		vector<int> s;
		s.push_back(u[i]);
		s.push_back(v[i]);
		g.bfs(s);
		int m[n], d = 0;
		fill(m, m+n, 0);
		for (int j = 0; j < n; j++) {
			d = max(d, g.dst[j]);
			m[g.dst[j]] = max(m[g.dst[j]], g.deg(j));
		}
		pair<int, ll> temp(d + 1, 2 * m[0] - 2);
		for (int j = 1; j < d; j++) {
			temp.second *= m[j] - 1;
		}
		ans = min(ans, temp);
	}
	cout << ans.first << " " << ans.second << endl;
	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
N,K
d = [0]*K
A = [[]]*K
A
for i in range(K):
    d[i] = int(input())
    A[i] = list(map(int,input().split()))

count = 0
for i in range(N):
    flag = 1
    for j in range(K):
        if i+1 in A[j]:
            flag = 0
    if flag == 1:
        count += 1

print(count)


Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

int main(){
  umap<string,string> mp = { {"Sunny","Cloudy"},{"Cloudy","Rainy"},{"Rainy","Sunny"}};
  string s; cin>>s;
  cout << mp[s];
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()

int main(){
	int n ; 
	cin>>n ; 
	int arr[n+5] , dp[n + 5] ;
	for(int i=1;i<=n;i++){
		cin>>arr[i] ; 
	}
	dp[n] = 1 ; 
	int ans = 1 ;
	for(int i=n-1;i>=1;i--){
		if(arr[i] >= arr[i + 1]){
			dp[i] = dp[i + 1] + 1 ; 
		}
		else{
			dp[i] = 1 ; 
		}
		ans = max(ans , dp[i]) ; 
	}

	cout<<ans - 1<<"\n" ;
}

Measured memory_bytes: 1024
N = int(input())
tmp_lst = input().split()
H_lst = []
for i in range(N):
    H_lst.append(int(tmp_lst[i]))

count = 1   #   一番西の必ず見えるところ
for i in range(1,N):
    ocean_vew = True
    for j in range(i):
        if H_lst[j] > H_lst[i]:
            ocean_vew = False
            break
    if ocean_vew:
        count += 1

print(count)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
from collections import *
from math import *

A, B, H, M = map(int, input().split())

if 60*H+M>=12*M:
    rad = 30*H+M/2-6*M
else:
    rad = 6*M-(30*H+M/2)

C = cos(radians(rad))
ans = A**2+B**2-2*A*B*C

print(ans**0.5)

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define int long long

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
 */

signed main()
{
  int a, b, q;
  cin >> a >> b >> q;

  vl s(a), t(b), x(q);
  rep(i, a) cin >> s[i];
  rep(i, b) cin >> t[i];
  rep(i, q) cin >> x[i];
  s.pb(linf);
  t.pb(linf);

  vl d1(a), d2(b);
  int c = 0;
  rep(i, a){
    while(abs(s[i] - t[c]) >= abs(s[i] - t[c+1])){
      c++;
    }
    d1[i] = abs(s[i] - t[c]);
  }

  c = 0;
  rep(i, b){
    while(abs(t[i] - s[c]) >= abs(t[i] - s[c+1])){
      c++;
    }
    d2[i] = abs(t[i] - s[c]);
  }

  rep(i, q){
    ll ans = linf;

    int j = lower_bound(all(s), x[i]) - s.begin();
    ans = min(ans, abs(x[i]-s[j]) + d1[j]);
    if(j > 0) ans = min(ans, abs(x[i]-s[j-1]) + d1[j-1]);

    j = lower_bound(all(t), x[i]) - t.begin();
    ans = min(ans, abs(x[i]-t[j]) + d2[j]);
    if(j > 0) ans = min(ans, abs(x[i]-t[j-1]) + d2[j-1]);

    cout << ans << endl;
  }

//  rep(i, a) cout << d1[i] << " \n"[i==a-1];
//  rep(i, b) cout << d2[i] << " \n"[i==b-1];

  return 0;
}


Measured memory_bytes: 5216
open System
#nowarn "25"

let inline readLine typeOperator = stdin.ReadLine() |> typeOperator
let inline readArray typeOperator = stdin.ReadLine().Split ' ' |> Array.map typeOperator
let modval = 1000000007

let NK = readArray int
let N = NK.[0]
let K = NK.[1]
let d = Array.zeroCreate K
let A = Array2D.zeroCreate K N
for i in 0 .. K - 1 do
    d.[i] <- readLine int
    let Aline = readArray int
    for j in 0 .. d.[i] - 1 do
        A.[i, j] <- Aline.[j]
eprintfn "%A" A

let haveSweets = Array.create N false
for i in 0 .. K - 1 do
    for j in 0 .. N - 1 do
        let snuk = A.[i, j]

        if snuk > 0 then
            haveSweets.[A.[i, j] - 1] <- true
eprintfn "%A" haveSweets
haveSweets
    |> Seq.filter (fun has -> not has)
    |> Seq.length
    |> printfn "%d"


Measured memory_bytes: 48664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){

int A,B,C;
cin>>A>>B>>C;

cout<<C<<" "<<A<<" "<<B<<"\n";

return 0;
}


Measured memory_bytes: 256
S = str(input())
T = str(input())
ans = 10000
for i in range(len(S)-len(T)+1):
    c = S[i:] 
    cnt = 0
    for j in range(len(T)):
        if str(T[j]) != str(c[j]):
            cnt += 1
    if cnt == 0:
        ans = cnt
    elif  ans > cnt:
        ans = cnt
print (ans)

Measured memory_bytes: 9092
from heapq import*
i=input
for s in[0]*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r)
 for x in x,y:
  h=[]
  for k,l,r in sorted(x):
   s+=r
   if k:s+=l-r;heappush(h,l-r)
   if len(h)>k:s-=heappop(h)
 print(s)

Measured memory_bytes: 51496
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] c1 = sc.next().toCharArray();
		char[] c2 = sc.next().toCharArray();
		sc.close();
		boolean f=false;
		out.println(c1[0]==c2[2]&&c1[1]==c2[1]&c1[2]==c2[0]?"YES":"NO");
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define FIND(v,x) (find(ALL(v),(x))!=v.end())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    vector<int> h_id, w_id;

    REP(i, h){
        bool flag = true;
        REP(j, w){
            char tmp;
            cin >> tmp;
            if(tmp == '#') {
                a[i][j]=1;
                flag = false;
            }
            else a[i][j]=0;
        }
        if(flag==true)h_id.pb(i);
    }

    REP(i, w){
        bool flag = true;
        REP(j, h){
            if(a[j][i]==1) flag = false;
        }
        if(flag==true)w_id.pb(i);
    }

    REP(i, h){
        if(FIND(h_id,i)) continue;
        REP(j, w){
            if(FIND(w_id,j)) continue;
            cout << (a[i][j]==1 ? '#' : '.');
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x<=W-r && x>=r && y<=H-r && y>=r)
    {
        printf("Yes\n");
    }
    else
    {
            printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2100