akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    int[] rx = new int[n];
    for (int i = 0; i < n; i++) {
      x[i] = sc.nextInt();
      rx[i] = x[i];
    }
    Arrays.sort(rx);
    for (int i = 0; i < n; i++) {
      if (x[i] >= rx[n / 2]) {
        System.out.println(rx[(n - 1) / 2]);
      } else {
        System.out.println(rx[(n - 1) / 2 + 1]);
      }
    }
  }
}


Measured memory_bytes: 94820
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    a = a * pow(10, floor(log10(b)) + 1) + b;
    cout << (a == pow(floor(sqrt(a)), 2) ? "Yes" : "No") << endl;
    return 0;
}


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

int main(void)
{
	int N;
	cin >> N;
	unordered_map<long long, long long> a;
	for (int i = 0; i < N; i++)
	{
		long long _a;
		cin >> _a;
		a[_a]++;
	}
	int result=0;
	for (auto pair : a)
	{
		if (pair.first != pair.second)
		{
			if (pair.first > pair.second)
			{
				result += pair.second;
			}
			else
			{
				result += (pair.second - pair.first);
			}
		}
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 4260
loop do
  n = gets.to_i
  break if n.zero?
  as = gets.split.map(&:to_i)
  t, r = 0, 32
  while r > 0
    if t.even?
      r -= (r - 1) % 5
    else
      r -= [r, as[t / 2 % as.size]].min
    end
    p r
    t += 1
  end
end

Measured memory_bytes: 8940
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N; cin >> N;
    vector<double> A(N); rep(i, N)cin >> A[i];
    double sum = 0;
    rep(i, N) {
        sum += (double)1 / A[i];
    }
    cout << fixed << setprecision(18) << (double)1 / sum << endl;
}



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

using namespace std;
typedef long long ll;

#ifdef ZERO_IQ
ios_base::sync_with_stdio ( false ), cin.tie ( 0 ), cout.tie ( 0 );
#endif
ll ncr(ll n,ll m){
    ll res=1;
    for (int i = n-m+1; i <=n; ++i) {
        res*=i;
    }
    return res;
}
int main() {
    ll n,m,c=0,cc=0;
    cin>>n>>m;
    if(n>=2)
     c=ncr(n,2)/2;
    if(m>=2)
     cc=ncr(m,2)/2;
    cout<<c+cc;
    return 0;
}








/* ll n, c = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
      string s = to_string(i);
      string ss = s;
      reverse(ss.begin(), ss.end());
      ll q = stoi(ss);
      if (ss[0] == '0')continue;
      bool isfound = false;
      for (int j = 0; j < s.length() - 1; ++j) {
          if (s[j] != s[j + 1]) {
              isfound = true;
              break;
          }
      }

      if (q <= n) {
          c++;
          cout << s << " " << ss << endl;
      }
      if (!isfound) {
          while (true) {
              s.push_back(s[0]);
              ll qq = stoi(s);
              if (qq <= n) {
                  c += 2;
                  cout << s << " " << ss << endl;
              }
              else break;
          }
      }
  }
  cout << c;*/


Measured memory_bytes: 256
/*
By Tianyi Chen. All rights reserved.
Date: 2018-08-25
*/
#include<bits/stdc++.h>
using namespace std;
int n,k,x[100000],ans=INT_MAX;
int t(int x,int y){
 if((x>=0)==(y>=0))return max(abs(x),abs(y));
 x=abs(x);y=abs(y);
 if(x>y)swap(x,y);
 return x*2+y;
}
int main(){
 scanf("%d%d",&n,&k);for(int i=0;i<n;++i)scanf("%d",x+i);
 for(int i=0;i<n-k+1;++i)ans=min(ans,std::remove_reference<decltype(ans)>::type(t(x[i],x[i+k-1])));
 printf("%d\n",ans);
}

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

using namespace std;

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

    int a, b, c, x, y, ans;
    cin >> a >> b >> c >> x >> y;

    if (x > y)
        ans = 2 * y * c + (x - y) * min(2 * c, a);
    else
        ans = 2 * x * c + (y - x) * min(2 * c, b);
    ans = min(ans, a * x + b * y);

    cout << ans << '\n';

    return 0;
}


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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/



int main()
{
	SPEED;
	ll k,t,c=0,i,j,cs=0;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		double n,m;
		cin>>n>>m;
		// n=s.length();
		// ll a[n];
		double d=(n/m);
		cout<<fixed;
		cout<<setprecision(12)<<(d);
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N = 0


def set_inputs():
    global N
    N = get_int()
    return


def base_10_to_n(x, n):
    mod = x % n
    mod = abs(mod)
    div = (x - mod) // n
    if div == 0:
        return str(mod)
    return base_10_to_n(div, n) + str(mod)


def main():
    setrecursionlimit(100000)
    set_inputs()
    print(base_10_to_n(N, -2))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

int main() {
	ll x;
	cin >> x;
	ll ans = (x / 11) * 2;
	if (x % 11 > 0) {
		if (x % 11 <= 6) {
			ans += 1;
		}
		else {
			ans += 2;
		}
	}
	cout << ans << endl;

	return 0;
}

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

#define ll long long

#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)
#define scc(x) scanf("%[^\n]s",x); // For charecter string input , It will  read all charecter untill Enter new line .

#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x,y) insert({x,y})

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

//i64 gcd(i64 a,i64 b){if(!b)return a;return gcd(b,a%b);}


//i64 bigmod(i64 num,i64 n){if(n==0)return 1;i64 x=bigmod(num,n/2);x=x*x%mod;if(n%2==1)x=x*num%mod;return x;}

//i64 modinverse(i64 num){return bigmod(num,mod-2)%mod;}

//i64 po(i64 a,i64 b){i64 ans=1;while(b--)ans *= a;return ans;}

//i64 ncr(i64 n,i64 r){if(n==r)return 1;if(r==1)return n;if(dp[n][r]!=-1)return dp[n][r];return dp[n][r]=ncr(n-1,r)+ncr(n-1,r-1);}




#define pb push_back

#define max3(a, b, c) max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)

#define file_read(filename)  freopen("input.txt","r",stdin);
#define file_write(filename)  freopen("output.txt","w",stdout);

#define sv(a) sort(a.begin(),a.end())
#define sortD(a)  sort(a,a+n,greater<int>())
#define sortA(a)  sort(a,a+n)

int main()
{

   ll a,b,c,r;
   cin>>a>>b;
   c=a+b;
   if(a%3==0||b%3==0||c%3==0) printf("Possible\n");
   else printf("Impossible\n");
return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a, b;

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


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int h[1000];
	int w[1000];
	int num=0;
	int i,j,k;
	
	//input
	while(1){
		scanf("%d %d",&h[num],&w[num]);
	//	printf("%d %d\n",h[num],w[num]);
		if(h[num]==0&&w[num]==0) break;
		num++;		
	}
	
	
	//output
	for(i=0;i<num;i++){
				
		for(j=0;j<h[i];j++){
			if( (j%2)==0 ){
				for(k=0;k<w[i];k++){
					if((k%2)==0) printf("#");
					else 		 printf(".");
				}
			}else{
				for(k=0;k<w[i];k++){
					if((k%2)==0) printf(".");
					else 		 printf("#");
				}
			}
							
			printf("\n");
		}
		
		printf("\n");
	}
	
	return 0;
}


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

int main()
{
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
	return 0;
}

Measured memory_bytes: 3092
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  set<ll>S;
  ll count=0;
  rep(i,n){
    if(a[i]>=3200){
      count++;
      continue;
    }
    S.insert(a[i]/400);
  }
  ll k=S.size();
  if(k==0){
    cout<<1<<" "<<count<<endl;
    return 0;
  }
  cout<<k<<" "<<k+count<<endl;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

const int INF = 1000000007;
const ll MOD = 1000000007;

void solve_test()
{
    int n;
    cin >> n;
    vector<int> ct;
    for(int i=0; i<n; i++)
    {
        int d1, d2;
        cin >> d1 >> d2;
        d1--; d2--;
        if(d1 == d2)
            ct.PB(i);
    }
    if(ct.size() >= 3)
    {
        for(int i=0; i<(int)ct.size()-2; i++)
        {
            if(ct[i] + 1 == ct[i+1] && ct[i+1] + 1 == ct[i+2])
            {
                cout << "Yes\n";
                return;
            }
        }
    }
    cout << "No\n";
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tests;
    tests = 1;
    //cin >> tests;
    while(tests--)
    {
        solve_test();
    }
    return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;
    int spos = 0, tpos=0;
    for(int i=0; i<S.size(); ++i) {
        bool update = false;
        for(int j=(i%2 == 0 ? spos : tpos); j<S.size(); ++j) {
            if(i % 2 == 0) {
                if(S[j] == S[i]) {
                    spos = j+1;
                    update = true;
                    break;
                }
            } else {
                if(T[j] == S[i]) {
                    tpos = j+1;
                    update = true;
                    break;
                }
            }
        }
        if(!update) {
            break;
        }
        if(update && i == S.size()-1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    spos = 0, tpos=0;
    for(int i=0; i<S.size(); ++i) {
        bool update = false;
        for(int j=(i%2 == 0 ? tpos : spos); j<S.size(); ++j) {
            if(i % 2 == 0) {
                if(T[j] == S[i]) {
                    tpos = j+1;
                    update = true;
                    break;
                }
            } else {
                if(S[j] == S[i]) {
                    spos = j+1;
                    update = true;
                    break;
                }
            }
        }
        if(!update) {
            break;
        }
        if(update && i == S.size()-1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int Keta(long long int n) {
  long long int N = n;
  int count = 0; 
  while (N > 0) {
    count ++;
    N /= 10;
  }
  return count;
}
int Saikoui(long long int n) {
  long long int N = n;
  while (N >= 10) {
    N /= 10;
  }
  return N;
}
int main() {
long long int N; 
cin >> N; 
if(Saikoui(N) != Saikoui(N+1)){
cout << 9 * (Keta(N) - 1) + Saikoui(N) << endl; 
}
else{
cout << 9 * (Keta(N) - 1) + Saikoui(N) - 1 << endl; 
}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n,m,k,x;
  cin >> n >> m;
  vector<ll> like(m,0);

  rep(i,n){
    cin >> k;
    rep(j,k){
      cin >> x;
      like[x-1]++;
    }
  }
  ll sum=0;
  for(auto itr:like){
    if(itr == n){
      sum++;
    }
  }
  cout << sum;
}


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

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static int Calc(int n, int[] xs) {
        var dp = new int[n+1];
        for (int i = 0; i < dp.Length; i++)
            dp[i] = int.MaxValue/10;

        foreach (int x in xs) {
            if (x > n) continue;

            dp[x] = 1;
            for (int i = 0; i+x <= n; i++) {
                dp[i+x] = Math.Min(dp[i+x], dp[i] + 1);
            }
        }
        return dp[n];
    }

    static void Main() {
        var nm = ReadInts();
        int n = nm[0];
        var xs = ReadInts();

        Console.WriteLine(Calc(n, xs));
    }
}

Measured memory_bytes: 9820
A,B,C = map(int, input().split())

ABC = [A,B,C]

ans = 0

while 1:
    ABC.sort()
    
    if ABC[0] == ABC[1] and ABC[1] == ABC[2]:
        break
    
    elif ABC[0] == ABC[1]:
        ABC[0]+=1
        ABC[1]+=1
        
        ans += 1
        
    else:
        ABC[0] += 2
        
        ans += 1
        
print(ans)
        
        

Measured memory_bytes: 3064
def myAnswer(A: int, B: int, S: list) -> None:
    counter = 0
    foreignStu = 1
    for i, s in enumerate(S):
        if(s == 'a' and counter < (A + B)): #国内の学生で、カウンタの値が(A+B)未満なら通過
            print("Yes")
            counter += 1#カウンタの値を更新
        elif(s == 'b' and counter < (A + B) and foreignStu <= B): #海外の学生で、カウンタの値が(A+B)未満かつ海外学生の順位がB以下なら通過
            print("Yes")
            counter += 1
            foreignStu += 1
        else:
            print("No")


def main():
    N, A, B = map(int, input().split())
    S = list(input())
    myAnswer(A, B, S)


if __name__ == "__main__":
    main()

Measured memory_bytes: 4712
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-10;
const int MOD = 1000000007;

#define X real()
#define Y imag()

typedef complex<double> P;
struct L{
	P p1, p2;
	L(P p1, P p2):p1(p1), p2(p2){}
	L(){}
};
istream& operator>>(istream &is, P &p) {
	double x, y;
	is >> x >> y;
	p = P(x, y);
	return is;
}
inline int sig(double x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }
inline double norm(const P &p){return p.X*p.X+p.Y*p.Y;}
inline double inp(const P& a, const P& b){return (conj(a)*b).X;}
inline double outp(const P& a, const P& b){return (conj(a)*b).Y;}


int T;

int main(){
	ios::sync_with_stdio(false);
	cin >> T;
	while(T--){
		P p1, p2, p3, p4;
		cin >> p1 >> p2 >> p3 >> p4;
		puts(!sig(inp(p2-p1, (p4-p3)*P(0, 1))) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1224
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, k;
    scan(n, k);
    auto a = aryread();
    // writeln(a);
    // writeln(ceil(a.length / k) * (k - 1)
    // long ans = ((a.length + k - 1) / k) * (k - 1);
    // writeln(ans);
    long i = 0;
    long cnt;
    while (i < n)
    {
        i += k;
        if (i == n)
        {
            cnt += 1;
            break;
        }
        i -= 1;
        cnt += 1;
    }
    writeln(cnt);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 6688
function Main(s) {
  s = +s;
  var m = [2];
  var i = 7;
  while(m.length < s){
    if(primecheck(i)) m.push(i);
    i += 5;
  }
  console.log(m.join(" "));
}
function primecheck(n){
  if(n<4)return 1;
  if(n % 2 === 0)return;
  if(n % 3 === 0)return;
  const m = Math.sqrt(n);
  for(i = 5; i <= m; i += 6){
    if(n % i === 0)return;
    if(n % (i+2) === 0)return;
  }
  return 1;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int baseTmp = scanner.nextInt();
        int preferableTmp = scanner.nextInt();
        int[] location = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            location[i] = scanner.nextInt();
        }
        double tmpDif = 0;
        double currentDif = 0;
        int targetIndex = 0;
        for(int j=0; j<location.length; j++) {
            tmpDif = Math.abs((baseTmp - location[j] * 0.006) - preferableTmp);
            if(j == 0) {
                targetIndex = j;
                currentDif = tmpDif;
            }
            if(currentDif > tmpDif) {
                targetIndex = j;
                currentDif = tmpDif;
            }
        }
        System.out.println(targetIndex+1);
    }
}


Measured memory_bytes: 23508
H, W = gets.split(" ").map(&:to_i)
s=[]
H.times do
  s.push(gets.chomp)
end
rest = []
cnt = 0
0.upto(H-1) do |i|
  0.upto(W-1) do |j|
    next if s[i][j] == "."
    above = i-1>=0 ? s[i-1][j] : "."
    below = i+1<=H-1 ? s[i+1][j] : "."
    left = j-1>=0 ? s[i][j-1] : "."
    right = j+1<=W-1 ? s[i][j+1] : "."
    if above == "." && below == "." && left == "." && right == "."
      puts "No"
      exit
    end
  end
end
puts "Yes"

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


int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n,0);
  vector<pair<int,int>> x(n);
  for(int i=0;i<n;++i){
    cin >> a[i];
    int left=i-a[i];
    int right=i+a[i];
    if(left<0) left=0;
    if(right>n-1) right=n-1;
    x[i]=make_pair(left,right);
  }
  //sort(x.begin(),x.end());
  vector<int> ans(n+1,0);
  for(int i=0;i<n;++i){
    ans[x[i].first]++;
    ans[x[i].second+1]--;
  }
  for(int i=0;i<n;++i){
    ans[i+1]+=ans[i];
  }
  k--;
  bool ok=false;
  vector<int> tmp(n+1,0);
  for(int i=0;i<k;++i){
    if(ok)break;
    tmp=vector<int>(n+1,0);
    for(int j=0;j<n;++j){
      if(ok)break;
      int left=j-ans[j];
      int right=j+ans[j];
      if(left<0) left=0;
      if(right>n-1) right=n-1;
      tmp[left]++;
      tmp[right+1]--;
    }
    for(int m=0;m<n;++m){
      tmp[m+1]+=tmp[m];
      ans[m+1]=tmp[m+1];
    }
    ans[0]=tmp[0];
    for(int l=0;l<n;++l){
      if(ans[l]>=n){
        ans[l]=n;
        ok=true;
      }
      else{
        ok=false;
        break;
      }
    }
  }
  for(int i=0;i<n;++i){
    if(ans[i]>n) ans[i]=n;
    if(i!=n-1){
      cout << ans[i] << " ";
    }else{
      cout << ans[i] << endl;
    }
  }
  return 0;

}


Measured memory_bytes: 8012
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
const int N = 1e5 + 5;

struct node {
	int a, b, last;
	bool operator<(const node &rhs) {
		if (last != rhs.last) return last > rhs.last;
		return b > rhs.b;
	}
} job[N];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &job[i].a, &job[i].b);
		job[i].last = m - job[i].a;
	}
	sort(job, job + n);
	priority_queue<int> pq;
	int ans = 0;
	for (int i = m - 1, j = 0; i >= 0; i--) {
		while (j < n && job[j].last >= i) {
			pq.push(job[j].b);
			j++;
		}
		if (!pq.empty()) {
			ans += pq.top();
			pq.pop();
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4548
using System;
    class Program
    {
        static void Main(string[] args)
        {
            int i, temp;
            int[] kx = new int[4];
            string[] input = Console.ReadLine().Split(' ');
            for (i = 0; i < 2; i++)
            {
                kx[i] = int.Parse(input[i]);
            }
            kx[2] = kx[1] - kx[0] + 1;
            kx[3] = kx[0] * 2 - 1;        
            string[] zahyo = new string[kx[3]];
            for(i = 0; i < kx[3]; i++)
            {
                temp = (kx[2] + i);
                zahyo[i] = " " + temp.ToString();
            }
            Console.WriteLine(string.Concat(zahyo).Remove(0, 1));
        }
    }

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b;
    set<int>x;
    for(int i=0; i<b; i++)
    {
        cin>>c;
        for(int j=0; j<c; j++)
        {
            cin>>d;
            x.insert(d);
        }
    }
    cout<<a-x.size()<<endl;
}



Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    string s;
    cin >> s;
    if (s.size()<6) cout << "No";
    else if (s[2]==s[3] && s[4]==s[5]) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
    int x;
    cin >> x;
    if(x == 1) cout << 0 << endl;
    else cout << 1 << endl; 
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int n, m;
int main() {
	cin >> n >> m;
	int L, R;
	L = 1, R = n;
	for (int i = 0; i < m; i++) {
		if (i != n / 4 && ((R - L + n) % n == (L - R + n) % n))while (1);
		if (n % 2 == 0 && i == n / 4)R--;
		printf("%d %d\n", L, R);
		L++; R--;
	}
	return 0;
}

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
    vi p(n);
	vi q;
	REP(i,n) {
    	cin >> p[i];
		if (p[i-1] < p[i]) {
        	p[i] = p[i-1];
        } else {
        	cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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 main(void) {
    string S;
    cin >> S;
    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm> 

using namespace std;
const int Max_N(1050);
const int Max_M(2050);
typedef long long int LL;
const int MOD(1000000000 + 7);

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

struct edge
{
	int pos, u, v, w;
};
int N, M, Father[Max_N], power[Max_M];
edge E[Max_M]; 
LL X, MST[Max_M];

inline bool operator<(const edge &a, const edge &b)
{
	return a.w < b.w;
}

int Get_Father(int x)
{
	return Father[x] == x ? x : Father[x] = Get_Father(Father[x]);
}

void query(int must)
{
	for (int u = 1;u <= N;++u)
		Father[u] = u;
	for (int i = 1;i <= M;++i)
		if (E[i].pos == must)
			Father[E[i].v] = E[i].u, MST[must] += E[i].w;
	for (int i = 1, u, v;i <= M;++i)
		if ((u = Get_Father(E[i].u)) != (v = Get_Father(E[i].v)))
			Father[v] = u, MST[must] += E[i].w;
}

int main()
{
	scanf("%d%d", &N, &M);
	scanf("%lld", &X);
	power[0] = 1;
	for (int i = 1;i <= M;++i)
		E[i].pos = i, scanf("%d%d%d", &E[i].u, &E[i].v, &E[i].w), power[i] = Add(power[i - 1], power[i - 1]);
	sort(E + 1, E + 1 + M);
	for (int i = 0;i <= M;++i)
		query(i);
	if (MST[0] > X)
	{
		printf("0");
		return 0;
	}
	int a = 0, b = 0, c = 0;
	for (int i = 1;i <= M;++i)
		a += (MST[i] < X), b += (MST[i] == X), c += (MST[i] > X);
	if (MST[0] == X)
		printf("%d", Mult(power[c], Sub(power[b], 2)));
	else
		printf("%d", Mult(2, Mult(Sub(power[b], 1), power[c])));
	return 0;
}

Measured memory_bytes: 256
fn calc(mut n: usize) -> usize {
    let mut answer = 0;
    while n > 0 {
        answer += n % 10;
        n /= 10;
    }
    answer
}
fn main() {
    let n: usize = readln();
    let mut answer = usize::max_value();
    for a in 1..n {
        let b = n - a;
        answer = min(answer, calc(a) + calc(b));
    }
    println!("{}", answer);
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int[] a = new int[n];
    Map<Integer, Long> counter = new HashMap<>();
    long sum = 0;

    for (int i = 0; i < n; i++) {
      a[i] = scanner.nextInt();
      if (counter.containsKey(a[i])) {
        counter.put(a[i], counter.get(a[i]) + 1);
      } else {
        counter.put(a[i], (long) 1);
      }
    }

    for (final Entry<Integer, Long> entry : counter.entrySet()) {
      if (entry.getValue() > 1) {
        sum += entry.getValue() * (entry.getValue() - 1) / 2;
      }
    }

    for (int i = 0; i < n; i++) {
      long count = counter.get(a[i]);
      if (count == 1) {
        System.out.println(sum);
      } else {
        System.out.println(sum - (count * (count - 1) / 2) + ((count - 1) * (count - 2) / 2));
      }
    }
  }
}


Measured memory_bytes: 127088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int m = scanner.nextInt();
        int[] ai = new int[a];
        int[] bi = new int[b];
        int minA = 1000001;
        int minB = 1000001;
        int tmp;
        for (int i = 0; i < a; i++) {
            tmp = scanner.nextInt();
            ai[i] = tmp;
            minA = Math.min(minA, tmp);
        }
        for (int i = 0; i < b; i++) {
            tmp = scanner.nextInt();
            bi[i] = tmp;
            minB = Math.min(minB, tmp);
        }
        int minCost = minA + minB;
        int x,y,c;
        for (int i = 0; i < m; i++) {
            x = scanner.nextInt()-1;
            y = scanner.nextInt()-1;
            c = scanner.nextInt();
            minCost = Math.min(minCost, ai[x] + bi[y] - c);
        }
        System.out.println(minCost);
    }
}

Measured memory_bytes: 132352
#include<stdio.h>
int main(){
  int n,m,i,a,b;
  char s[5]={};
  scanf("%d %d",&n,&m);
  while(m--){
    scanf("%d %d",&a,&b);
    if(a==1&&b==0&&n-1)goto END;
    if(s[a-1]&&s[a-1]-b-'0')goto END;
    s[a-1]=b+'0';
  }
  if(s[0]==0)s[0]=n-1?'1':'0';
  for(i=1;i<n;i++){
    if(s[i]==0)s[i]='0';
  }
  printf("%s\n",s);
  return 0;
 END:;
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N, D;
	cin >> N >> D;
	vector<int> X(N);
	vector<int> Y(N);

	int count = 0;
	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> Y[i];
		if (sqrt(pow(X[i], 2) + pow(Y[i], 2)) <= D) {
			++count;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4860
#include <cctype>
#include <cstdio>
#include <cstring>

using namespace std;

char S[100][16]; int N, H, Q, R, T[100], P[100];

int main()
{
    scanf("%d %d", &N, &H);
    
    for(int i = 0; i < N; i++)
    {
        scanf("%s %d", S[i], &T[i]);
    }
    
    char F[2];
    
    for(int i = 0; i < N; i++)
    {
        int ptr = 0;
        
        while(ptr != strlen(S[i]))
        {
            printf("? %s\n", S[i]); fflush(stdout);
            
            scanf("%s", F); R++;
            
            if(tolower(S[i][ptr]) == tolower(F[0]))
            {
                S[i][ptr] = '_'; ptr++; Q++;
            }
            else
            {
                P[i]++;
                
                if(P[i] > T[i])
                {
                    H--; break;
                }
            }
        }
        
        if(H == 0)
        {
            printf("! Game Over\n"); return 0;
        }
    }
    
    int r = Q * 1000 / R;
    
    printf("! Game Clear %d.%d\n", r / 10, r % 10);
    
    return 0;
}

Measured memory_bytes: 3372
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << max(c - (a - b), 0) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]

if a[0] != 0:
    print(-1)
    exit()
inc_cnt = 0
ans = 0
for i in range(n-1):
    if a[i] + 1 < a[i+1]:
        print(-1)
        exit()
    if a[i] + 1 == a[i+1]:
        inc_cnt = a[i+1]
    else:
        ans += inc_cnt
        inc_cnt = a[i+1]
ans += inc_cnt
print(ans)

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

using namespace std;

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

int main() {
    int n;
    string s;

    cin >> n >> s;

    rep(i, (int)s.size()) s[i] = 'A' + ((s[i] + n - 'A') % 26);
    cout << s << endl;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    K = int(readline())

    n = 0

    def dfs(vec, d):
        nonlocal n
        if d == 0:
            n += 1
            if n == K:
                print(''.join(map(str, vec)))
                return
            else:
                return

        for i in range(max(0, vec[-1] - 1), min(9, vec[-1] + 1) + 1):
            vec.append(i)
            dfs(vec, d - 1)
            if n >= K:
                return
            vec.pop()

    for d in range(10 ** 20):
        for i in range(1, 10):
            vec = [i]
            dfs(vec, d)
            if n >= K:
                return

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 77924
package scc;
sub new{
	return bless[map[],1..$_[1]],$_[0];
}
sub add_edge{
	my$self=shift;
	push@{$self->[$_[0]]},$_[1];
}
sub scc{
	my$self=shift;
	my$now_ord=0,$group_num=0,@low,@ord=(-1)x@{$self},@ids;
	my@visited;
	my$dfs;
	$dfs=sub{
		my$v=shift;
		$low[$v]=$ord[$v]=$now_ord++;
		push@visited,$v;
		for$to(@{$self->[$v]}){
			if($ord[$to]==-1){
				$dfs->($to);
				$low[$v]=$low[$to]if$low[$v]>$low[$to];
			}
			else{
				$low[$v]=$ord[$to]if$low[$v]>$ord[$to];
			}
		}
		if($low[$v]==$ord[$v]){
			while(){
				my$u=pop@visited;
				$ord[$u]=@{$self};
				$ids[$u]=$group_num;
				last if$u==$v;
			}
			$group_num++;
		}
	};
	for$i(0..$#ord){
		$dfs->($i)if$ord[$i]==-1;
	}
	$_=$group_num-1-$_ for@ids;
	my@groups;
	for$i(0..$#ids){
		push@{$groups[$ids[$i]]},$i;
	}
	return\@groups;
}
package main;
my($N,$M)=split$",<>;
my$scc=scc->new($N);
for(1..$M){
	my($a,$b)=split$",<>;
	$scc->add_edge($a,$b);
}
$groups=$scc->scc();
print scalar(@{$groups}),$/;
for$L(@{$groups}){
	print scalar(@{$L}),$","@{$L}",$/;
}


Measured memory_bytes: 286696
n = $stdin.gets.chomp.to_i
arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end

arr2 = []

for i in 1..n
    arr2.push i
end

count = 0

for i in 0.. n - 1
  if arr[i] != arr2[i]
    count += 1
  end
end

if count == 2 or count == 0
    puts "YES"
else
    puts "NO"
end

Measured memory_bytes: 1788
r, c = map(int,input().split())
sheet = []
for i in range(0,r):
    row = []
    row[:] = map(int,input().split())
    rsum = 0
    for j in range(0,c):
        rsum+=row[j]
    row.append(rsum)
    sheet.append(row)
    print(' '.join(map(str,row)))

row = []
for j in range(0,c+1):
    csum = 0
    for i in range(0,r):
        csum+=sheet[i][j]
    row.append(csum)
print(' '.join(map(str,row)))



Measured memory_bytes: 5680
n = int(input())
lst = []
for _ in range(n):
    a,b = map(int,input().split())
    lst.append([b,a])
lst.sort()

time = 0
for i in range(n):
    simekiri, sigoto = lst[i][0],lst[i][1]
    time += sigoto
    if time <= simekiri:
        continue
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 38252
package main

import (
  "fmt"
)

var (
  A int
  B int
  C int
  D int
  E int
  F int
)

func makeX() map[int]int {
  ax := make(map[int]int)
  for i := 0; i <= F / (100 * A); i++ {
    for j := 0; j <= F / (100 * B); j++ {
      x := 100 * A * i + 100 * B * j
      if x > F {
        continue
      }
      if _, ok := ax[x]; !ok {
        ax[x] = 1
      }
    }
  }
  return ax
}

func makeY() map[int]int {
  ay := make(map[int]int)
  for i := 0; i <= F / C; i++ {
    for j := 0; j <= F / D; j++ {
      y := C * i + D * j
      if y > F {
        continue
      }
      if _, ok := ay[y]; !ok {
        ay[y] = 1
      }
    }
  }
  return ay
}

func main() {
  fmt.Scan(&A, &B, &C, &D, &E, &F)
  ax := makeX()
  ay := makeY()

  maxTotal := 0
  maxSugar := 0
  for x, _ := range ax {
    for y, _ := range ay {
      if x + y == 0 || x + y > F {
        continue
      }
      if 100 * y > E * x {
        continue
      }
      total := x + y
      if maxTotal == 0 {
        maxTotal = total
        maxSugar = y
        continue
      }
      if 100 * maxSugar * total < 100 * y * maxTotal {
        maxTotal = total
        maxSugar = y
      }
    }
  }
  fmt.Println(maxTotal, maxSugar)
}


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

int main(void) {
    int count = 0;

    int n;
    std::cin >> n;
    std::vector<int> s(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
    }

    int q;
    std::cin >> q;
    std::vector<int> t(q, 0);
    for (int i = 0; i < q; i++) {
        std::cin >> t[i];
    }

    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            if (t[i] == s[j]) {
                count++;
                break;
            }
        }
    }
    std::cout << count << std::endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> b(n-1, 0);
    rep(i, n-1){ cin >> b[i];}
    int output = b[0] + b.back();
    rep(i, n-2){
        output += min(b[i], b[i+1]);
    }
    cout << output << endl;
}   

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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  transform(a.begin(),a.end(),a.begin(),::toupper);
  transform(b.begin(),b.end(),b.begin(),::toupper);
  transform(c.begin(),c.end(),c.begin(),::toupper);
  cout<<a[0]<<b[0]<<c[0];
  return 0;
}


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

int main()
{
    ll N,K;
    cin >> N >> K;
    if(K==0){
        cout << N << endl;
    }else if(K==1){
        cout << 0 << endl;
    }else if(N%K==0){
        cout << 0 << endl;
    }else if(N>K){
        ll a=N%K;
        if(abs(a-K)<abs(a)){
            cout << abs(a-K) << endl;
        }else{
            cout << abs(a);
        }
    }
    else{
        ll ab=abs(N-K);
        while(ab<N){
            N=ab;
            ab=abs(N-K);
        }
        cout << N << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>

#define DEBUG 0;
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//三角形の内接円
//半径x
//http://wk1080id.hatenablog.com/entry/2018/02/21/000505
//
int main(){
#ifdef DEBUG
//    std::ifstream in("resource/input.txt");
//    std::cin.rdbuf(in.rdbuf());
#endif

	double x[4] = {};
	double y[4] = {};
	REP(i,3)
	{
	  cin >> x[i] >> y[i];
	}
	x[3] = x[0];
	y[3] = y[0]; 
	//REP(i,4)
	//{
	//	cout << x[i] << " " << y[i] << endl;
	//}

	double hen[3];
	REP(i,3)
	{
		//double diff_x = x[i+1] - x[i];
		//double diff_y = y[i+1] - y[i];
		//i to i+1
		hen[i] = hypot(abs(x[i+1] - x[i]), abs(y[i+1]-y[i]));
	//	cout << hen[i] << endl;
	}
	//double a = hypot(abs(x[3] - x[2]), abs(y[3]-y[2]));
	//cout << a << endl;



	double henMax = 0;
	REP(i,3)
	{
		henMax = max(henMax,hen[i]);
	}

	double s = (hen[0]+hen[1]+hen[2])/2.0;
	double area = sqrt(s * (s-hen[0]) * (s-hen[1]) * (s-hen[2]));
	//cout << s << endl;
	//cout << area << endl;

	double r = 2.0 * area /(hen[0]+hen[1]+hen[2]);
	//double r=area/s;


	//最大の半径をxとすると、
	//もとの三角形から半径x離れた地点にある点Pの集合は、相似で
	//r: r-x となる
	//1: 1-x/r
	//相似の三角形の最大の辺を2で割ったものが回答 

	//cout << henMax << endl;
	//cout << r << endl;

	double st = 0; 
	double en = henMax;
	REP(i,100000)
	{
		double _x = (st + en) /2.0;
		if(2 * _x * r <= (r - _x)*henMax)st = _x;
		else en = _x;

	}

	cout << fixed << setprecision(13) << st << endl;
	
  return 0;
}



Measured memory_bytes: 256