akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main() {
  int n; cin >> n;
  long long a[n];
  bool used[n] = {false};
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a+n, greater<int>());
  vector<long long> ans;
  for(int i = 0; i < n-1; ++i) {
    if(a[i] == a[i+1]) {
      ans.push_back(a[i]);
      i++;
    }
  }
  if(ans.size() <= 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(ans.begin(), ans.end(), greater<int>());
  cout << ans[0] * ans[1] << endl;

  return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int E[N], W[N];
    REP(i,0,N){
        E[i] = 0;
        W[i] = 0;
    }
    REP(i,0,N){
        if (S[i]=='E') E[i] = 1;
        if (S[i]=='W') W[i] = 1;
    }
    REP(i,1,N){
        W[i] += W[i-1];
        E[N-i-1] += E[N-i];
    }
    int ans = N;
    REP(i,0,N){
        int k = E[i]+ W[i] - 1;
        if (ans > k) ans = k;
    }
    CO(ans);
    return 0;
}

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

namespace ITP1_4_D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            long n = ReadLong();
            long[] a = ReadLongAr();

            Console.WriteLine("{0} {1} {2}", a.Min(), a.Max(), a.Sum());
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 18576
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); 
	cout.tie(NULL);
ll n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++)
cin>>a[i];
ll mn=a[0],mx=a[0],am=1000;
for(ll i=1;i<n;i++)
{
    if(a[i]>=a[i-1])
    {
        mx=a[i];
        am=(am/mn)*mx+(am%mn);
        mn=a[i];
    }
    else{
        
        mn =a[i];
        mx=a[i];
    }
}
if(mx>mn)
am=(am/mn)*mx+(am%mn);
cout<<am;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int alice = 0, bob = 0;
  rep(i, N){
    if(i%2==0) alice += a.at(i);
    else bob += a.at(i);
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int A,B,C;
	cin>>A>>B>>C;
	
	if(A+B>=C){
		ce("Yes")
	}else{
		ce("No")
	}
}


Measured memory_bytes: 256
a = int(input())

N = []

for i in range(a):
    b = int(input())
    N.append(b)

max_n = -10000000000000000
min_n = N[0]

for i in range(1,a):
    max_n = max(max_n, N[i]-min_n)
    min_n = min(min_n, N[i])

print(max_n)





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

int main()
{
  string str,tr;
  cin>>str>>tr;
  int n = str.size();
  int m = tr.size();
  int ans = INT_MAX;
  for(int i = 0;i <= n-m;i++)
  {
    int count = 0;
    for(int j = 0;j < m;j++)
    {
      if(str[i+j] != tr[j])
        count++;
    }
    ans = min(ans,count);
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 3624
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

int solve() {
	//ll n, k;
	//cin >> n >> k;

	//vector<ll> as(n);
	//REPD(i, 0, n) cin >> as[i];

	ll x;
	cin >> x;
	
	RET((x >= 30 ? "Yes" : "No"));

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
int main(){
    ll n;cin>>n;
    vector<ll> h(n),d(n);
    cin>>h.at(0);d.at(0)=0;
    For1(i,n) {
        cin>>h.at(i);
        if(h.at(i)<=h.at(i-1)){
            d.at(i)=d.at(i-1)+1;
        }
        else{
            d.at(i)=0;
        }
    }
    ll k=0;
    For(i,n) k=max(k,d.at(i));
    cout<<k<<endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long a[] = new long[n];
		a[0]=sc.nextLong();
		for(int i=1; i<n; i++) {
			a[i] = a[i-1]+sc.nextLong();
		}
		long ans = Long.MAX_VALUE;
		for(int i=0; i<n-1; i++) {
			ans = Math.min(ans, Math.abs(a[i] - (a[n-1] - a[i])));
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 63764
/*
ID: mayakyu1
TASK: task
LANG: C++                 
*/
#define usingfile1
#include <iostream>
#include <cstdio>
#include <algorithm>
int file_reopen(){
	freopen("task.in","r",stdin);
	freopen("task.out","w",stdout);
}
using namespace std;
#define ll long long
int n;const int maxn=1e5+9;
int a[maxn],k[maxn];
void main_program(){
	cin>>n;
	int i;
	for(i=1;i<=n;++i)cin>>a[i];
	if(i==1)k[i]=1;
	else{
		int r=1;
		for(i=2;i<=n;++i){
			k[i-1]+=r;
			k[i]-=r;
			r=-r;
		}
	}
	//for(i=1;i<=n;++i)printf("%-4d",k[i]);
	sort(a+1,a+1+n);
	
	sort(k+1,k+1+n);
	ll ans=0;
	for(i=1;i<=n;++i)ans+=(ll)a[i]*k[i];
	
	if(n&1==0)printf("%lld\n",ans);
	else{
		for(i=1;i<=n;++i)k[i]=-k[i];
		ll ansd=0;
		for(i=1;i<=n;++i)ansd+=(ll)a[i]*k[n+1-i];
		printf("%lld\n",max(ans,ansd));
	}
}
int main(){
	ios::sync_with_stdio(0);
	#ifdef usingfile
	file_reopen();
	main_program();
	fclose(stdin);fclose(stdout);
	#else
	main_program();
	#endif
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
string a[1000];
int tim[1000][2];
int main(){
	int n,m,z;
	while(true){
	cin>>n>>m;
	if(n==0&&m==0)break;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cin>>z>>tim[i][1];
		tim[i][0]=tim[i][1]-z;
	}
	for(int u=0;u<m;u++){
		string ans="Unknown";
		int cnt=-1;
		cin>>z;
		for(int i=0;i<n;i++)if(tim[i][0]<z&&tim[i][1]>=z){ans=a[i],cnt=z-tim[i][0];}
		cout<<ans;
		if(cnt>0)cout<<" "<<cnt;
		cout<<endl;
	}
	}
	return 0;
}

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

int main()
{
    int N;

    cin >> N;

    int W[N + 1];
    for (int i = 1; i <= N; i++)
    {
        cin >> W[i];
    }

    int min = 100 * 100;
    int sa;

    for (int T = 1; T < N; T++)
    {
        int S1 = 0;
        int S2 = 0;

        for (int i = 1; i <= T; i++)
        {
            S1 += W[i];
        }
        for (int j = T + 1; j <= N; j++)
        {
            S2 += W[j];
        }

        sa = abs(S1 - S2);
        if (sa < min)
        {
            min = sa;
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

ll N,M;
cin >> N >> M;

if( 2*N >= M ) cout << M/2 << endl;
else cout << N + (M-2*N)/4 << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,ans;
int main(){
	cin>>n>>m;
	ans=min(n,m/2);
	long long n2=n;
	n-=min(n,m/2);
	if(n2<m/2)
	{
		m-=n2*2;
	}
	else
	{
		m-=m/2*2;
	}
	ans+=m/4;
	cout<<ans;
	return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    int mount;
    int maxHeight = -1;
    for(int i = 0; i < N; i++) {
        cin >> mount;
        if (mount >= maxHeight) { 
            ans++;
            maxHeight = mount;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
  string a,b,c,A,B,C;
  cin>>a>>b>>c;
  A = a[0]-32;B = b[0]-32;C = c[0]-32;
  cout << A << B << C <<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	double n;
	while(cin >>n){
		double a[10] = {n},sum = n;
		for(int i=1; i<10; i++){
			if(i%2 == 0){a[i] = a[i-1]/3;}
			else{a[i] = a[i-1]*2;}
			sum+=a[i];
		}
		printf("%.8lf\n",sum);
	}
	return 0;
}

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

int main(void)
{
    ll n, x, y;
    cin >> n >> x >> y;
    vector<ll> v(n, 0);
    rep(i, 1, n + 1) rep(j, i + 1, n + 1) v[min(j - i, abs(x - i) + 1 + abs(y - j))]++;
    rep(i, 1, n) cout << v[i] << endl;
}


Measured memory_bytes: 3608
n = int(input())
A = list(map(int,input().split()))
for i in range(n):
    v = A[i]
    j = i-1
    while j >= 0 and  A[j] > v:
        A[j+1] = A[j]
        j -= 1
        A[j+1] = v
    print(" ".join(map(str,A)))


Measured memory_bytes: 5596
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [usize; n],
    }
    let mut ans = 0;
    let mut min = v[0];

    for i in 0..n {
        if min >= v[i] {
            ans += 1
        }

        if min > v[i] {
            min = v[i]
        } 
    }

    println!("{}", ans);
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int x,y;
    cin>>x>>y;

    vector<int> v = {0,300000,200000,100000,0};
    int res = 0;
    if (x==1&&y==1) res+=400000;

    x = min(x,4);
    y = min(y,4);
    res += v[x];
    res += v[y];
    cout<<res<<endl;    
    return 0;
}


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

int mycal(int ty,int tm,int td){
	int y=1,m=1,d=1;
	int ret = 0;
	while(1){
		bool isBigMonth = y%3==0 || m%2;
		if(d > 20 - !isBigMonth){
			m++;
			d=1;
		}
		if(m > 10){
			y++;
			m=1;
		}
		if(y == ty && m == tm && d == td){
			return ret;
		}
		d++;
		ret++;
	}
}

int main() {
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int y,m,d;
		cin >> y >> m >> d;
		cout << mycal(1000,1,1) - mycal(y,m,d) << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include<stdio.h> 

int main(void)
{
  int h,n;
  int sum = 0;
  scanf("%d %d",&h,&n);
  int s[n];
  for (int i=0; i < n; i++) {
    scanf("%d", &s[i]);
    sum += s[i];
  }
  if (sum >= h) {
    printf("Yes");
  } else {
    printf("No");
  }
}


Measured memory_bytes: 512
@cnt = 0

def g(i)
  @g ||= [1]

  if v = @g[i]
    return v
  end

  @g[i] = @g[i-1] + 3 ** i
end

# 1  insertionSort(A, n, g)
# 2      for i = g to n-1
# 3          v = A[i]
# 4          j = i - g
# 5          while j >= 0 && A[j] > v
# 6              A[j+g] = A[j]
# 7              j = j - g
# 8              cnt++
# 9          A[j+g] = v
def insertion_sort(a, gi)
  n = a.length
  for i in gi..(n-1)
    v = a[i]
    j = i - gi
    while j >= 0 && a[j] > v
      a[j+gi] = a[j]
      j = j - gi
      @cnt += 1
    end
    a[j+gi] = v
  end
end

#  shellSort(A, n)
#     cnt = 0
#     m = ?
#     G[] = {?, ?,..., ?}
#     for i = 0 to m-1
#         insertionSort(A, n, G[i])
def shell_sort(a)
  m = 0
  while a.length > g(m)
    m += 1
  end

  for i in [*0..m].reverse
    insertion_sort(a, g(i))
  end

  [m, @cnt, a]
end

n = gets.to_i
a = n.times.map{gets.to_i}

m, cnt, a = shell_sort(a)

m = 1 if m == 0

puts m
puts (0...m).map{|i|g(i)}.reverse.join(" ")
puts cnt
puts a



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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

set<string> st;
int N;

int main(){
	cin>>N;
	for(int i=0; i<N; i++){
		string s;
		cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
	return 0;
}


Measured memory_bytes: 19176
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Integer[] l = new Integer[n];
    for (int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
    }
    Arrays.sort(l, Collections.reverseOrder());
    int rst = 0;
    for (int i = 0; i < n - 2; i++) {
      for (int j = i + 1; j < n - 1; j++) {
        for (int k = j + 1; k < n; k++) {
          if (l[i] < l[j] + l[k]) {
            rst++;
          }
        }
      }
    }
    System.out.println(rst);
  }
}


Measured memory_bytes: 26968
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INPUT()

    l = [int(s) for s in N]
    print("Yes" if sum(l)%9 == 0 else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 11916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
 
struct mint {
    constexpr static int mod = 1000000007;
    long long x;
    mint(long long x = 0): x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll p = (n + 999) / 1000;
    mint a;
    a = p * 1000 - n ;
    cout << a.x << endl;
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main() { 
  string S,T;
  cin>>S>>T;
  int i=0;
  for(i=0;i<S.size();i++){
    if(S.at(i)!=T.at(i)){
      cout<<"No"<<endl;
      break;
      }
    if(i==S.size()-1){
      cout<<"Yes"<<endl;
      break;
      }
    }
  return 0;
  }



Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Sort[] s = new Sort[n];
        for(int i = 0; i < n; i++){
            s[i] = new Sort(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
        }
        Arrays.sort(s);
        
        PriorityQueue<Integer> queue = new PriorityQueue<>(Collections.reverseOrder());
        int x = 0;
        int ans = 0;
        for(int i = 1; i <= m; i++){
            while(x < n && s[x].a <= i){
                queue.offer(s[x].b);
                x++;
            }
            if(!queue.isEmpty()){
                ans += queue.poll();
            }
        }
        
        System.out.println(ans);
    }
}

class Sort implements Comparable<Sort>{
    int a;
    int b;
    
    Sort(int a, int b){
        this.a = a;
        this.b = b;
    }

    @Override
    public int compareTo(Sort s) {
        
        if(this.a < s.a){
            return -1;
        }else if(this.a > s.a){
            return 1;
        }else{
            return 0;
        }
    }
}

Measured memory_bytes: 63684
#include<stdio.h>

int main(){
  int A, B, C, r, i;
  
  scanf("%d %d %d", &A, &B, &C);
  
  for (i = 1; i < B; i++){
    if(A*i%B == C){
      break;
    }
  }
  if(i == B){
    printf("NO\n");
  } else {
    printf("YES\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
n = len(s)
kind = len(set(list(s)))
k = ni()

if n == 1:
    print(k // 2)
elif kind == 1:
    print(n*k // 2)
else:
    # 2個つなげる
    s2 = s + s

    # 前半、後半の変える場所を記録
    prev = ""
    flag = True
    fst = 0
    lat = 0
    for i, si in enumerate(s2):
        if si == prev:
            if flag:
                if i < n:
                    fst += 1
                else:
                    lat += 1
                flag = False

            else:
                flag = True
        else:
            flag = True

        prev = si

    print(fst + lat * (k-1))


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  deque<int> d;
  rep(i,n) {
    auto p = lower_bound(d.begin(), d.end(), a[i]);
    int index = p - d.begin();
    if (index == 0) {
      d.push_front(a[i]);
    } else d[index-1] = a[i];
  }
  int ans = d.size();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
object Main extends App {

  import scala.io.StdIn._

  val n = readLine.trim.toInt
  for (_ ← 0 until n){
    val first = readLine.trim.split(' ').map(_.toInt)
    if (canWin(Hand(first), Hand((1 to 13).filterNot(p ⇒ first.contains(p)).toArray))) {
      println("yes")
    }else{
      println("no")
    }
  }
  def canWin(first: Hand, second: Hand): Boolean = {
    val memo = Array.tabulate(7){_ ⇒ Array.tabulate(7){_ ⇒ None: Option[Boolean]}}
    def sub(first: Hand, second: Hand, gameState: GameState): Boolean = {
      if (second.isEmpty) false
      else {
        memo(7 - gameState.left)(gameState.right - 7) match {
          case Some(r) ⇒ r
          case None ⇒
           first.next (gameState).exists {case (nextFirst, game) ⇒ nextFirst.isEmpty || second.next (game).forall { case (nextSecond, g) ⇒ sub (nextFirst, nextSecond, g)}}.also(b ⇒ memo(7 - gameState.left)(gameState.right - 7) = Some(b))
        }
      }
    }
    sub(first, second, GameState())
  }
  case class GameState(left: Int = 7, right: Int = 7) {
    def isEnd: Boolean = left == 1 && right == 13
  }
  object Hand {
    def apply(array: Array[Int]): Hand = {
      Hand(array.filter(_ < 7).sorted.reverse.toList, array.filter(_ > 7).sorted.toList)
    }
  }
  case class Hand(left: List[Int], right: List[Int]) {
    def next(gameState: GameState): List[(Hand, GameState)] = {
      List(left match {
        case h::t if h + 1 == gameState.left ⇒ List((Hand(t, right), GameState(h, gameState.right)))
        case _ ⇒ Nil
      }, right match {
        case h::t if h - 1 == gameState.right ⇒ List((Hand(left, t), GameState(gameState.left, h)))
        case _ ⇒ Nil
      }
      ).flatten match {
        case Nil ⇒ List((this, gameState))
        case l ⇒ l
      }
    }
    def isEmpty: Boolean = left.isEmpty && right.isEmpty
  }
  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 53260
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    int N;
    int M;


    void calc()
    {
        cin = new Scanner();
        N = cin.nextInt();

        Tuple<int, int, int>[] tp = new Tuple<int, int, int>[N];

        for (int i = 0; i < N; i++)
        {
            int w = cin.nextInt();
            int s = cin.nextInt();
            int v = cin.nextInt();
            tp[i] = new Tuple<int, int, int>(s + w, w, v);
        }

        Array.Sort(tp);
        int MAX = 10001;
        long[] dp = new long[MAX + 1];

        for (int i = 0; i < N; i++)
        {
            int w = tp[i].Item2;
            int s = tp[i].Item1 - w;
            int v = tp[i].Item3;
            for (int j = s; j >= 0; j--)
            {
                int next = Math.Min(MAX, j + w);
                dp[next] = Math.Max(dp[next], dp[j] + v);
            }
        }

        Console.WriteLine(dp.Max());
        


    }



}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13428
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int d = a/b;
        int r = a%b;
        double f = (double)a / (double)b;
        
        System.out.println(d +" "+ r +" "+ String.format("%.8f", f));
        
        
    }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int n1=min(a,b);
  int n2=max(a,b);
  for(int i=1;i<=n2;i++){
    cout << n1;
    if (i==n2){
      cout << endl;
    }
  }
}


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


void solve(long long S){
  while (S != 0) {
      
  }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string s;
    cin >> s;
    for (int i = 1; i < 4; i++) {
      if (s[i] == s[i - 1]) {
	  cout << "Bad" << "\n";
	  return 0;
      }
    }
    cout << "Good" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include<cmath>
#include<string.h>
#include<vector>

#define M 1000000007

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
	int n,a,b,inv[200002];
	long long ca=1,cb=1,ans;
	scanf("%d %d %d",&n,&a,&b);
	
	
	for(int i=1;i<=200000;i++){
		inv[i] = modpow(i,M-2,M);
	}
	for(int i=1;i<=a;i++){
		ca = (ca*(n+1-i))%M;
		ca = (ca*inv[i])%M;
	}
	for(int i=1;i<=b;i++){
		cb = (cb*(n+1-i))%M;
		cb = (cb*inv[i])%M;
	}
	
	ans = (modpow(2,n,M) - ca - cb - 1 + 2*M)%M;
	//printf("%I64d %I64d %I64d\n",modpow(2,n,M),ca ,cb);
	printf("%I64d\n",ans);
	
	return 0;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int n, m;
  cin >> n >> m;
  int ans = n * m - (n * 2 + m * 2 - 4);
  if(n == 1) ans = m - 2;
  if(m == 1) ans = n - 2;
  if(n == 1 && m == 1) ans = 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<-1000||b>1000) return 0;
  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: 3032
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

typedef pair<int, int> Pi;
#define fi first
#define se second

int mx[] = {1, 0, -1, 0};
int my[] = {0, 1, 0, -1};

signed main()
{
  int W, H;
  char mas[25][25];
  
  
  
  while(cin >> W >> H, W || H) {
    queue < Pi > que;
    int ans = 1;
    Rep(i, H) Rep(j, W) {
      cin >> mas[i][j];
      if(mas[i][j] == '@') {
	que.push(Pi(i, j));
	mas[i][j] = '#';
      }
      
    }

    while(!que.empty()) {
      Pi d = que.front(); que.pop();
      int y = d.fi, x = d.se;

      Rep(i, 4) {
	int ny = y + my[i], nx = x + mx[i];
	if(ny < 0 || nx < 0 || ny >= H || nx >= W || mas[ny][nx] == '#') continue;
	ans++, mas[ny][nx] = '#';
	que.push(Pi(ny, nx));
      }
    }

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

Measured memory_bytes: 3016
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
map<string, set<string> > memo;
set<string> rec(string name, vector<string>& commands, map<string, int>& id){
  if(memo.count(name)) return memo[name];
  set<string> res;
  if(id.count(name)){
    string s = commands[id[name]];
    REP(i, s.size())if(s[i] == ':'){
      s = s.substr(i + 1);
      break;
    }
    REP(i, s.size())if(s[i] == ',' || s[i] == '.') s[i] = ' ';
    stringstream ss(s);
    string member;
    while(ss>>member){
      set<string> d = rec(member, commands, id);
      FORIT(it, d) res.insert(*it);
    }
  }else{
    res.insert(name);
  }
  return memo[name] = res;
}

int main(){
  int N;
  while(cin>>N && N){
    memo.clear();
    vector<string> commands(N);
    map<string, int> id;
    REP(i, N) cin>>commands[i];
    string first;
    REP(i, N){
      string s = commands[i];
      string group;
      REP(j, s.size())if(s[j] == ':') group = s.substr(0, j);
      id[group] = i;
      if(i == 0) first = group;
    }
    set<string> ans = rec(first, commands, id);
    //FORIT(it, ans) cout<<*it<<endl;
    cout<<ans.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>
int main()
{

  int i, j, k, n, x, sum = 0, count = 0;
  while(1){
    scanf("%d %d",&n, &x);
    count = 0;
    if(n == 0 && x == 0) break;
    for(i = 1; i <= n; i++){
      for(j = i+1; j <= n; j++){
	for(k = j+1; k <= n; k++){
	  sum = i + j + k;
	  if(sum == x) {
	    //printf("%d %d %d\n",i,j,k);
	    count++;
	  }
	}
      }
    } printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());

    ll ans = 0LL;
    for(int i=k;i<n;++i) {
        ans += a[i];
    }
    cout << ans << endl;
}


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

int main() {

    int N;
    cin >> N;
    
    
    if (N / 100 == 7 || (N / 10) % 10 == 7 || N % 10 == 7) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }
    
    
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int dx[8] = { 0, 1, 1, 1, 0,-1, -1, -1 };
int dy[8] = { -1,-1,0, 1, 1, 1, 0, -1 };
int main(void) {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> s(h+2, vector<char>(w+2));
	rep(i, 1, h+1) {
		rep(j, 1, w+1) {
			cin >> s[i][j];
		}
	}
	rep(i, 1, h+1) {
		rep(j, 1, w+1) {
			if (s[i][j] == '#')cout << "#";
			else {
				int cnt = 0;
				rep(k, 0, 8) {
					if (s[i + dx[k]][j + dy[k]] == '#') {
						cnt++;
					}
				}
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  string ans = "";
  while (n){
    n--;
    ans += 'a' + n%26;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
//@@@@@@@@@@ JAI BAJRANG BALI @@@@@@@@@

// COMPILE BY:) NAMAN


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define maxn 10000001
#define endl "\n"
#define inf INT_MAX
#define vec vector <ll>
#define mps map <ll,ll>
#define ppl vector<pair<ll,ll>> 
#define fi first
#define si second
#define pr pair<ll,ll> 
#define mvec map<ll,vector <ll>>
#define all(v) v.begin(),v.end()
#define infi LLONG_MAX
#define pi 3.141592653
#define ninf INT_MIN
#define ninfi LLONG_MIN
#define lbn lower_bound
#define ubn upper_bound
#define memset(a,b) memset(a,(b),sizeof(a))
  
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vec vi(n+1,0);
    for(ll i=0;i<k;i++)
    {
    	ll d;
    	cin>>d;
    	for(ll j=0;j<d;j++)
    	{
    		ll q;
    		cin>>q;
    		vi[q]=1;
    	}
    }
    ll c=0;

    for(ll i=1;i<=n;i++)
    	if(vi[i]!=1)
    		c++;
    	cout<<c<<endl;

return 0;
}


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

int main()
{
	string a, b;
	bool f = true;
	cin >> a >> b;
	for (int i = 0; i < 3; i++) {
		if (a[i] != b[2 - i]) f = false;
	}
	if (f) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

const int MOD = 1000000007;

template <typename T>
int pow(int x, T n, int mod = std::numeric_limits<int>::max()) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = static_cast<int64_t>(res) * static_cast<int64_t>(x) % mod;
    x = static_cast<int64_t>(x) * static_cast<int64_t>(x) % mod;
    n >>= 1;
  }
  return res;
}

template <typename T>
int64_t pow(int64_t x, T n, int64_t mod = std::numeric_limits<int64_t>::max()) {
  int64_t res = 1;
  while (n > 0) {
    if (n & 1) res = static_cast<__int128>(res) * static_cast<__int128>(x) % mod;
    x = static_cast<__int128>(x) * static_cast<__int128>(x) % mod;
    n >>= 1;
  }
  return res;
}

template <typename T>
T inverse(T a, T m) {
  T u = 0, v = 1;
  while (a != 0) {
    T t = m / a;
    m -= t * a;
    u -= t * v;
    std::swap(a, m);
    std::swap(u, v);
  }
  assert(m == 1);
  return u;
}

class Prime {
 public:
  template <typename T>
  static bool is_prime(T n) {
    if (n == 0 || n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for (T i = 3; i * i < n + 1; i += 2) {
      if (n % i == 0) return false;
    }
    return true;
  }

  template <typename T>
  static std::vector<T> factor(T n) {
    std::vector<T> res;
    for (T i = 2; i * i < n + 1; i++) {
      while (n % i == 0) {
        n /= i;
        res.emplace_back(i);
      }
    }
    if (n != 1) res.emplace_back(n);
    return res;
  }

  template <typename T>
  static T totient(T n) {
    T res = 1;
    std::vector<T> primes = factor(n);
    std::map<T, int> mp;
    for (T p : primes) {
      mp[p]++;
    }
    for (const auto &[p, c] : mp) {
      res *= pow(p, c - 1) * (p - 1);
    }
    return res;
  }

  template <typename T>
  static std::vector<T> sieve_of_eratosthenes(T n) {
    std::vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (T i = 2; i * i < n + 1; i++) {
      if (!is_prime[i]) continue;
      for (T k = 2 * i; k < n + 1; k += i) {
        is_prime[k] = false;
      }
    }
    std::vector<T> res;
    for (T i = 0; i < n + 1; i++) {
      if (is_prime[i]) res.emplace_back(i);
    }
    return res;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  map<int64_t, int64_t> primes;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    auto prime = Prime::factor(A[i]);
    map<int64_t, int64_t> mp;
    for (auto p : prime) {
      mp[p]++;
    }
    for (auto [k, v] : mp) {
      primes[k] = max(primes[k], v);
    }
  }
  int64_t l = 1;
  for (auto [k, v] : primes) {
    l *= pow(k, v, static_cast<int64_t>(MOD));
    l %= MOD;
  }
  int64_t res = 0;
  for (int i = 0; i < N; i++) {
    res += (l * inverse(A[i], static_cast<int64_t>(MOD)) % MOD);
    res %= MOD;
  }
  cout << (res + MOD) % MOD << '\n';
  return 0;
}


Measured memory_bytes: 4140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());

        double c = Math.sqrt(Math.pow((double)a, 2) + Math.pow((double)b, 2) - (2.0 * a * b * Math.cos(C * Math.PI / 180)));

        double s = (a + b + c) / 2.0;
        double S = Math.sqrt(s * (s - a) * (s - b) * (s - c));

        System.out.println(S);
        System.out.println(a + b + c);
        System.out.println(2 * S / a);
    }
}

Measured memory_bytes: 26380
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        sc.close();

        int mod = (int)Math.pow(10, 9)+7;
    
        long strt = 1;

        for(int i = 1; i <= N; i++){
            strt = ((strt%mod)*i)%mod;
        }

        System.out.println(strt);
    }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> yet(n,0);
  REP(i,n){
    int x;cin >> x;
    x--;
    a[i] = x;
  }
  int v = 0;
  ll res = 0;
  bool flag = false;
  REP(i,n){
    yet[v] = true;
    v = a[v];
    res++;
    if(v == 1)break;
    if(yet[v]){
      flag = true;
      break;
    }
  }
  if(!flag)cout << res << endl;
  else cout << -1 << endl;




  
  

  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import math

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

win_rate = 0
for i in range(1, N+1):
    tmp = 0.5**math.ceil(math.log2(K/i))
    if tmp < 1:
        win_rate += tmp/N
    else:
        win_rate += 1/N
print(win_rate)

Measured memory_bytes: 3316