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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  vector<pair<ll, ll>> x(n);
  for(int i = 0; i < n; i++) cin >> x.at(i).first >> x.at(i).second;
  
  sort(x.begin(), x.end());
  
  ll ans = 4e18 + 1;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      if(j - i + 1 < k) continue;
      
      vector<ll> y;
      for(int l = i; l <= j; l++) y.push_back(x.at(l).second);
      
      sort(y.begin(), y.end());
      
      for(int l = 0; l <= j - i + 1 - k; l++){
        ans = min(ans, (x.at(j).first - x.at(i).first) * (y.at(l + k - 1) - y.at(l)));
      }
    }
  }
  
  cout << ans << '\n';
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n, k;
  cin >> n >> k;
  vector<double> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = (a[i] + 1) / 2 + a[i - 1];
  }
  double ans = 0;
  for (int i = 1; i <= n - k + 1; i++) {
    ans = max(ans, a[i + k - 1] - a[i - 1]);
  }
  cout << fixed << setprecision(20) << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    ll x;
    cin >> x;
    ll dep = 100;
    ll year = 0;
    while(dep < x){
        dep *= 1.01;
        year++;
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
    long long x, ans = 0;
    cin >> x;
    
    for(int a = 1; a < x; a++) {
        for(int b = 1; a*b < x; b++) {
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    auto f = [&](ll b) {
        ll result = 0;
        for (ll i = 0; i < N; i++) {
            result += abs(A[i] - (b + i + 1));
        }
        return result;
    };

    ll ok = INT_MIN, ng = INT_MAX;
    while (ok + 2 < ng) {
        ll left = (2 * ok + ng) / 3;
        ll right = (ok + 2 * ng) / 3;
        assert(left <= right);

        ll left_value = f(left);
        ll right_value = f(right);

        if (left_value < right_value) {
            ng = right;
        } else {
            ok = left;
        }
    }

    ll ans = LLONG_MAX;
    for (ll j = ok - 1e2; j <= ng + 1e2; j++) {
        ans = min(ans, f(j));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
max_a = max(a)

b = [0]*(max_a + 2)

for i in a:
    b[i] += 1

ans = 0
for i in range(max_a + 1):
    tmp = b[i-1] + b[i] + b[i+1]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 13964
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	
	ll A, B, K;
	cin >> A >> B >> K;

	bool choku = true;
	for (int i = 0; i < K; i++)
	{
		if (choku)
		{
			if (A % 2 == 1)
			{
				A--;
			}

			A /= 2;
			B += A;
			choku = false;
		}
		else
		{
			if (B % 2 == 1)
			{
				B--;
			}

			B /= 2;
			A += B;

			choku = true;
		}


	}

	cout << A << " " << B << endl;

}





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int w, n, a[100], b[100],sw,ap;
	char ch;
	cin >> w >> n;
	for (int i = 1; i <= w; i++) {
		a[i] = i;
	}
	for (int i = 1; i <= n; i++) {
		cin >> sw >> ch >> ap;
		swap(a[sw], a[ap]);
	}
	for (int i = 1; i <= w; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2956
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    char[] N;

    private void solve() {
        N = next().toCharArray();

        if (N[1] == N[2] && (N[0] == N[1] || N[2] == N[3])) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22996
def main():
    n, m = map(int, input().split())
    if n & 1:
        for i in range(m):
            print(i+1, n-i)
    else:
        i = 0
        flag = False
        for i in range(m):
            if n-2*i-1 > n//2:
                print(i+1, n-i)
            else:
                print(i+1, n-i-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> A(n+1);
    vector<int> B(n);
    for(int i=0; i<n+1; i++){
        cin >> A.at(i);
    }
    for(int j=0; j<n; j++){
        cin >> B.at(j);
    }
    int64_t ans=0;
    for(int i=0; i<n; i++){
        if(A.at(i)>B.at(i)){
            ans+=B.at(i);
            continue;
        }
        else if(A.at(i)<B.at(i)){
            ans+=A.at(i);
            B.at(i)-=A.at(i);
            if(A.at(i+1)>B.at(i)){
                ans+=B.at(i);
                A.at(i+1)-=B.at(i);
            }
            else if(A.at(i+1)<B.at(i)){
                ans+=A.at(i+1);
                A.at(i+1)=0;
            }
            else if(A.at(i+1)==B.at(i)){
                ans+=A.at(i+1);
                A.at(i+1)=0;
            }
            continue;
        }
        else if(A.at(i)==B.at(i)){
            ans+=A.at(i);
            continue;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
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; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

vector<int> createEratos(int n)
{
  vector<int> isprime(n+1, 1);
  isprime[0] = 0;
  isprime[1] = 0;

  for (int i = 2; i * i <= n; i++) {
    if (isprime[i]) {
      int j = i + i;
      while (j <= n) {
        isprime[j] = 0;
        j = j + i;
      }
    }
  }
  return isprime;
}

vector<int> eratos;

bool like2017(const int& n) {
  return (eratos[n] == 1 && eratos[(n+1)/2] == 1) ? true : false;
}

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

  eratos = createEratos(1e+5);

  // 1. 1 ~ 10^5 までの2017に似た数の累積和を求める
  ll sum = 0;
  vector<ll> values(1e5 + 1, 0);
  for (int i = 3; i <= 1e5; i++) {
    if (like2017(i)) {
      sum++;
    }
    values[i] = sum;
  }

  rep(i, q) {
    int l, r;
    cin >> l >> r;
    cout << values[r] - values[l-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  cout<<cei(C,max(A,B));
return 0;}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int i = 0;
		int x = 0;
		Scanner sc= new Scanner(System.in);

		while( true ) {

			i++;
			x = sc.nextInt();

			if ( x == 0 ) {
				break;
			}

			System.out.println( "Case " + i + ": " + x );
		}
		sc.close();
	}
}


Measured memory_bytes: 41392
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] a = ReadIntArray();

	if ((n&1) == 0)
	{
	    for (int i = n - 1; i > 0; i -= 2)
	    {
		Write($"{a[i]} ");
	    }
	    for (int i = 0; i <= n - 2; i += 2)
	    {
		Write($"{a[i]}");
		if (n != n - 2){ Write(" "); }
	    }
	    Write("\n");
	}
	else
	{
	    for (int i = n - 1; i >= 0; i -= 2)
	    {
		Write($"{a[i]} ");
	    }
	    for (int i = 1; i <= n - 2; i += 2)
	    {
		Write($"{a[i]}");
		if (n != n - 2){ Write(" "); }
	    }
	    Write("\n");
	}
    }
}


Measured memory_bytes: 35880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;

int X,Y,Z;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>X>>Y>>Z;
    swap(X,Y); swap(X,Z);
    cout<<X<<' '<<Y<<' '<<Z;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var lst = new List<long>();
            for (var i = 0; i < N; ++i)
                lst.Add(Sarray()[0]);
            WriteLine(lst.Distinct().Count());
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28248
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



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

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        if (A * B % 2 == 1) Console.WriteLine("Odd");
        else Console.WriteLine("Even");
    }
    
}




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: 11092
from collections import Counter, deque

N = int(input())
A = list(map(int, input().split())) + [N+1]
B = list(map(int, input().split())) + [N+1]
C = [0]
D = [0]

AB_cn = Counter(A+B)
if AB_cn.most_common()[0][1] > N:
    print("No")
else:
    print("Yes")
    for i in range(N+1):
        if len(C) != A[i]:
            C.extend([i]*(A[i]-len(C)))
        if len(D) != B[i]:
            D.extend([i]*(B[i]-len(D)))
    ans = -100000000000000000
    for i in range(N):
        curr = C[i+1] - D[i]
        ans= max(curr, ans)
    B = B[:-1]
    print(*[B[(i-ans)%N] for i in range(N)])



Measured memory_bytes: 52464
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,k;
	cin>>n>>k;
	map<ll,ll > map;
	std::map<ll,ll> ::iterator it;
	for(ll i=1;i<=n;i++){
		map[i]=1;
	}
	
	for(ll i=1;i<=k;i++){
		ll d;
		cin>>d;
		for(ll i=0;i<d;i++){
			ll x;
			cin>>x;
			it=map.find(x);
			if(it!=map.end()){
				map.erase(x);
			}
		}
	}
	cout<<map.size()<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;


//0~n-1というデータを扱うことが前提となっている
//unique_ptr<UFtree<int>> uf(new UFtree<int>(n));
template <typename T>
class UFtree{
public:
    UFtree(int data_num){
        v.resize(data_num);
        for (int i = 0; i < data_num; i++){
            v[i] = i;
        }
    }
    ~UFtree(){}

    T get_root(T a){
        T result;
        if(v[a]==v[v[a]]){
            return v[a];
        }else{
            T result;
            vector<T> path;
            T now_where=a;
            while(v[now_where]!=v[v[now_where]]){
                path.push_back(now_where);
                now_where=v[now_where];

            }
            for(T &x:path){
                v[x] = v[now_where];
            }
            return v[now_where];
        }
    }

    //aにbをつける
    void attach(T a,T b){
        v[get_root(b)] = v[get_root(a)];
    }

    
    
    void check(){for(T &x:v){
            cout << x<<" ";
        }
        cout << endl;
    }

  private:
    vector<T> v;


};



int main(){

    int n, m;
    cin >> n >> m;
    unique_ptr<UFtree<long long int>> uf(new UFtree<long long int>(n));

    long long int tmpa, tmpb;
    REP(i,m){
        scanf("%lld %lld", &tmpa, &tmpb);
        uf->attach(tmpa,tmpb);
    }

    int q;
    cin >> q;

    REP(i,q){
        scanf("%lld %lld", &tmpa, &tmpb);
        //cout << uf->get_root(tmpa) << " " << uf->get_root(tmpb) << endl;
        if(uf->get_root(tmpa)==uf->get_root(tmpb)){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
    //uf->check();

    return 0;
}



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

int main() {
  int n,d,x,ans = 0;
  cin >> n >> d >> x;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  for(int j = 0; j < n; j++){
    ans += (d - 1) / a.at(j);
  }
  cout << ans + n + x << endl;
}

Measured memory_bytes: 256
mod=10**9+7
##mod,nについての制約は自分でいかに記入する
def pow_cal(x,n,mod):
    if n==0:
        return 1
    elif n==1:
        return x%mod
    elif n>=2:
        if n%2==0:
            return (pow_cal(x,n//2,mod)**2)%mod
        else:
            return (x*pow_cal(x,n//2,mod)**2)%mod

def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist
 
def find_inv_power(n,mod):
    #0!からn!までの逆元を素数modで割ったあまりリストを作る関数
    c=1
    uselist=[0 for i in range(n+1)]
    for i in range(1,n+1):
        c*=i
        c%=mod
    first=pow_cal(c,mod-2,mod)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(mod)
    return uselist
    
A=find_power(10**6,mod)
B=find_inv_power(10**6,mod)

def combi(n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (A[n]*B[r]*B[n-r])%(mod)
x,y=map(int,input().split())
if (x+y)%3!=0:
    print(0)
else:
    J=(2*y-x)//3
    K=(2*x-y)//3
    if J>=0 and K>=0:
        print(combi(J+K,J,mod))
    else:
        print(0)    

Measured memory_bytes: 82228
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int nn = sc.nextInt();
		q = sc.nextInt();
		n = 1;
		while (n < nn) n *= 2;
		init();
		StringBuilder sb = new StringBuilder();
		while (q-- > 0) {
			int a = sc.nextInt() - 1;
			int v = sc.nextInt();
			update(a, v);
			sb.append(id[0] + 1 + " " + dat[0] + "\n");
		}
		System.out.print(sb);
	}

	int n, q;
	int dat[];
	int id[];

	void init() {
		dat = new int[n * 2 - 1];
		id = new int[n * 2 - 1];
		for (int i = 0; i < n; i++) id[i + n - 1] = i;
	}

	void update(int i, int x) {
		i += n - 1;
		dat[i] += x;
		while (i > 0) {
			i = (i - 1) / 2;
			if (dat[i * 2 + 1] >= dat[i * 2 + 2]) {
				dat[i] = dat[i * 2 + 1];
				id[i] = id[i * 2 + 1];
			} else {
				dat[i] = dat[i * 2 + 2];
				id[i] = id[i * 2 + 2];
			}
		}
	}

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

Measured memory_bytes: 116064
#include <bits/stdc++.h>
using namespace std;
int a[100003],b[100003],c[100003],b1,b2,c1,c2,ans,N,b3,c3;
bool q,w;
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>a[i];
		if(i%2==1)
		b[a[i]]++;
		else
		c[a[i]]++;
	}
	for(int i=1;i<=100000;i++)
	{
		b1=max(b[i],b1);
		c1=max(c[i],c1);
	}
	for(int i=1;i<=100000;i++)
	{
		if(b[i]!=b1||q==1)
		b2=max(b[i],b2);
		else
		{
		q=1;
		b3=i;
	}	
		if(c[i]!=c1||w==1)
		c2=max(c[i],c2);
		else
		{
		w=1;
		c3=i;
	}	
	}
	if(b3!=c3)
	cout<<N-b1-c1<<endl;
	else
	cout<<N-max(b1+c2,c1+b2)<<endl;
	return 0;
}

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

#define ff       first
#define ss       second
#define vpop     pop_back
#define pb       push_back
#define mp       make_pair
#define ll       long long int
#define umap	 unordered_map
#define pii	 pair<int, int>
#define clz(x)   __builtin_clz(x)       
#define ctz(x)   __builtin_ctz(x)      
#define all(v)   v.begin(), v.end() 
#define sbts(x)  __builtin_popcount(x) 
#define ull      unsigned long long int
#define ms(a,v)  memset(a, v, sizeof(a))
#define ps(x, y) fixed << setprecision(y) << x
const int MOD  = 1e9 + 7;
const ll  INF  = 1e12;
const int   N  = 2e5 + 1;
vector<int> adj[N];
vector<bool> Vis(N, 0);

int dfs(int v) {
    Vis[v] = 1;
    int ans = 1;
    for (int u: adj[v]) {
        if (!Vis[u]) {
            ans += dfs(u);
        }
    }
    return ans;
}

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  cout.tie(NULL);
//  *-------------------------------*
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        adj[u].pb(v); adj[v].pb(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!Vis[i]) {
            ans = max(ans, dfs(i));
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 23856
import heapq
s=input()
k=int(input())
n=len(s)
ls=[[si,i] for i,si in enumerate(list(s))]
heapq.heapify(ls)
seen=set()
c=0
while c<k:
  a=heapq.heappop(ls)
  if a[0] not in seen:
    seen.add(a[0])
    c+=1
    #print(c,a[0])
    if c==k:
      print(a[0])
      exit()
  if len(a[0])+a[1]<n:
    a[0]+=s[len(a[0])+a[1]]
    heapq.heappush(ls,a)

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

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

        if(a>b) swap(a,b);
        for(int i=a;i<a+k;i++){
                if(i<=b) cout << i << endl;
        }

        for(int i=b-k+1;i<b+1;i++){
                if(i<=a+k-1) ;
                else cout << i << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if (x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3216
#include <stdio.h>
#define max(a,b) (a)>=(b)?(a):(b)
int main(){
    int a,b,c,cnt=0,hoge;
    scanf("%d%d%d",&a,&b,&c);
    if(a%2==b%2&&b%2==c%2){
        hoge=max(a,(max(b,c)));
        cnt+=(3*hoge-a-b-c)/2;
    }else{
        if(a<b){
            hoge=a;
            a=b;
            b=hoge;
        }
        if(b<c){
            hoge=b;
            b=c;
            c=hoge;
        }
        if(a<b){
            hoge=a;
            a=b;
            b=hoge;
        }
        if(b%2==c%2){
            cnt+=(a-b)/2;
            cnt+=(a-c)/2;
            cnt++;
        }else{
            if(a%2==b%2){
                cnt+=(a-c)/2;
                cnt++;
                c=a+1;
                cnt+=(c-b)/2;
                cnt++;
            }
            if(a%2==c%2){
                cnt+=(a-b)/2;
                cnt++;
                b=a+1;
                cnt+=(b-c)/2;
                cnt++;
            }
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128
h, w, k = list(map(int, input().split()))
m = []

for i in range(h):
    m.append(input())

def count(h, w):
    cnt = 0
    for i in h:
        for j in w:
            if m[i][j] == '#': cnt += 1
    return cnt

def remove(l, x):
    return [y for y in l if y is not x]

def search(hs, ws, hmin, wmin):
    nblack = count(hs, ws)
    if nblack < k:
        return 0

    res = 0
    if wmin == 0:
        for i in range(hmin, h):
            hs_ = remove(hs, i)
            res += search(hs_, ws, i + 1, wmin)

    for j in range(wmin, w):
        ws_ = remove(ws, j)
        res += search(hs, ws_, hmin, j + 1)

    if nblack == k:
        return res + 1
    return res

x = search(list(range(h)), list(range(w)), 0, 0)
print(x)

Measured memory_bytes: 9124
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
const int N=2e5+9;
int n,a[N];ll k;
vector<int>g[N];
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i],g[a[i]].push_back(i);
    ll x=1,xh=1;
    while(1){
        int i=lower_bound(g[a[x]].begin(),g[a[x]].end(),x)-g[a[x]].begin();
        if(i==g[a[x]].size()-1)x=g[a[x]][0],xh++;else x=g[a[x]][i+1];
        if(x==n)break;
        x++;
    }
    //cout<<xh<<endl;
    ll y=k%xh;
    x=1;
    while(y){
        int i=lower_bound(g[a[x]].begin(),g[a[x]].end(),x)-g[a[x]].begin();
        if(i==g[a[x]].size()-1){
                if(y==1)cout<<a[x]<<" ";else x=g[a[x]][0],y--;
        }else x=g[a[x]][i+1];
        x++;if(x>n)y--,x=1;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 13184
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

/* MACROS SAMPAH */
#define Jehian using
#define Norman namespace
#define Saviero std
#define cepet {ios_base::sync_with_stdio(0);cin.tie(0);}

Jehian Norman Saviero;

/* MACROS FOR TYPE */
typedef long l;
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

/* MACROS FOR PRINT */
#define nl printf("\n")
#define sp printf(" ")

/* MACROS FOR FUNCTION AND METHOD */
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define eb emplace_back
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for(int _je = sizeof(x)/sizeof(x[0]); _je--;) x[_je] = y
#define SQR(x) (x)*(x)
#define CUBE(x) SQR(x)*(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLSIZE(x,n) (x), (x)+(n)

/* MACROS FOR ATTRIBUTE */
#define fi first
#define se second

/* MACROS FOR SCAN */
#define scc(x) scanf("%c", &x)
#define scd(x) scanf("%Lf", &x)
#define scf(x) scanf("%f", &x)
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scld(x) scanf("%Lf", &x)
#define scui(x) sci(x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main(){
	ll N, A, B;
	cin >> N >> A >> B;
	if (abs(A-B) % 2) {
		cout << "Borys" << endl;
	} else {
		cout << "Alice" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
ps = []
for i in [0]*N:
    X,L = map(int, input().split(' '))
    ps.append((X-L,X+L))

ps.sort(key=lambda x:x[1])
now = -10**10
ans = 0
for l,r in ps:
    if now <= l:
        now = r
        ans += 1
print(ans)



Measured memory_bytes: 59136
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

var (
	reader io.Reader = os.Stdin
	writer io.Writer = os.Stdout
)

type input [][]int

func (in input) Len() int { return len(in) }
func (in input) Less(i, j int) bool {
	return in[i][0] < in[j][0]
}
func (in input) Swap(i, j int) { in[i], in[j] = in[j], in[i] }

func main() {
	run()
}

func run() {
	var N int
	fmt.Fscan(reader, &N)

	// prevTime, prevX, prevY := 0, 0, 0
	reader := bufio.NewReaderSize(reader, 21)
	inputs := make(input, 0, N)

	for i := 0; i < N; i++ {
		buffer, isPrefix, err := reader.ReadLine()
		buf := make([]byte, 0, 19)

		if err != nil || isPrefix {
			panic(err)
		}

		buf = append(buf, buffer...)

		var t, x, y int
		fmt.Sscan(string(buf), &t, &x, &y)

		inputs = append(inputs, []int{t, x, y})
	}

	sort.Sort(&inputs)

	prevTime, prevX, prevY := 0, 0, 0

	for _, ints := range inputs {
		t, x, y := ints[0], ints[1], ints[2]
		distance := abs(x-prevX) + abs(y-prevY)
		time := t - prevTime

		if t == prevTime || distance > time || (time-distance)%2 != 0 {
			fmt.Fprintln(writer, "No")

			return
		}

		prevTime, prevX, prevY = t, x, y
	}

	fmt.Fprintln(writer, "Yes")
}

func abs(a int) int {
	if a < 0 {
		return -a
	}

	return a
}


Measured memory_bytes: 9600
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,M=get_i.sort
if N==2 or M==2
    puts 0
elsif N==1
    if M==1
        puts 1
    else
        puts M-2
    end
else
    puts (N-2)*(M-2) 
end

Measured memory_bytes: 1788
#include <iostream>
#define llint long long

using namespace std;

llint n, x;
llint ans;

llint calc(llint a, llint b)
{
	if(a < b){
		return calc(b, a);
	}
	if(b == 0) return a;
	ans += a/b*b*2;
	return calc(b, a%b);
}

int main(void)
{
	cin >> n >> x;
	
	ans += n;
	ans -= calc(x, n-x);
	cout << ans << endl;
	
	return 0;
}

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

int main()
{
    int n, x, sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        sum += x;
    }
    cout << sum-n << endl;
    return 0;
}


Measured memory_bytes: 3580
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;

    input!{
        n: usize,
        x: usize,
        t: usize,
    }

    let ans = if n % x == 0 {
        (n / x) * t
    } else {
        (n / x + 1) * t
    };

    println!("{}", ans)
}

fn main() {
    solve();
}


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

int main(){
  int N;
  cin>>N;
  vector<int> ans(N);
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    ans.at(A.at(i)-1)=i;
  }

  for(int i=0;i<N;i++){
    cout<<ans.at(i)+1<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<numeric>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	char c;
	rep(i,3){
		rep(j,3){
			cin >> c;
			if(i==j)
				cout << c;
		}
	}
	cout << endl;

	return 0;
}

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

int64_t dp[401][401], p[401];

inline int64_t rsq(int l, int r) {
	if(l == 0) return p[r];
	return p[r] - p[l - 1];
}

int64_t recurse(int i, int j) {
	int64_t& state = dp[i][j];
  	if(state != -1) return state;
  	if(i == j) return state = 0;
  	state = numeric_limits<int64_t>::max();
  	int64_t cost = rsq(i, j);
  	for(int k = i; k < j; ++k) {
    	state = min(state, recurse(i, k) + recurse(k + 1, j) + cost);
    }
  	return state;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
	int64_t n; cin >> n;
	int64_t s[n];
  	for(auto& i: s) cin >> i;
  	memset(dp, -1, sizeof dp); memset(p, 0, sizeof p);
  	p[0] = s[0];
  	for(int i = 1; i < n; ++i) p[i] = p[i - 1] + s[i];
  	cout << recurse(0, n - 1) << endl;
} //farewell, until we meet again..

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

void solve(){
	int n;
	cin>>n;
	int ans[10005]={0};
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			for(int k=1;k<=100;k++){
				int x=i*i+k*k+j*j+i*k+i*j+j*k;
				if(x<=10000) ans[x]++;
			}
		}
	}
	for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
}

int32_t main(){
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}
}

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

int main() {
	int N;
	string str1;
	cin >> N;
	cin >> str1;
	int fore_rightstock = 0;
	int fore_leftstock = 0;
	int back_rightstock = 0;
	int back_leftstock = 0;
	int counter = 0;

	for(int i=1; i < N+1; i++){
		if(str1[N-i]==')'){
			back_rightstock++;
		}
		else {
			if(back_rightstock>0){
				back_rightstock--;
			}else{
				back_leftstock++;
			}
		}
	}
	for(int i=0; i < N; i++){
		if(str1[i]=='('){
			fore_leftstock++;
		}
		else {
			if(fore_leftstock>0){
				fore_leftstock--;
			}else{
				fore_rightstock++;
			}
		}
	}
	for(int i=0; i < back_rightstock; i++){
		cout << '(';
	}
	cout << str1;
	for(int i=0; i < fore_leftstock; i++){
		cout << ')';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc077c()
}

fun abc077c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }
        .sorted()
    val bList = readLine()!!.split(" ").map { it.toInt() }
        .sorted()
    val cList = readLine()!!.split(" ").map { it.toInt() }
        .sorted()

    val patterns = bList.map { b ->
        val subA = lowerBound(aList, b)
        val subC = cList.size - upperBound(cList, b)
        subA.toLong() * subC
    }.sum()

    println(patterns)
}

// list must be sorted
private fun lowerBound(list: List<Int>, key: Int): Int {
    var ng = -1
    var ok = list.size

    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        if (list[mid] >= key) ok = mid else ng = mid
    }
    return ok
}

// list must be sorted
private fun upperBound(list: List<Int>, key: Int): Int {
    var ng = -1
    var ok = list.size

    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        if (list[mid] > key) ok = mid else ng = mid
    }
    return ok
}


Measured memory_bytes: 109836
N = int(input())
h = list(map(int, input().split()))

t = 0
while max(h) > 0:
    si = N
    ei = N
    for i in range(N):
        if h[i] > 0:
            si = i
            break
    for i in range(si, N):
        if h[i] == 0:
            ei = i
            break
    for i in range(si, ei):
        h[i] -= 1
    t += 1
print(t)

Measured memory_bytes: 42844
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

int main() {

    long long int n, m, v, p;
    cin >> n >> m >> v >> p;

    vector< long long int > a;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        a.push_back( -in );
    }

    sort( a.begin(), a.end() );

    long long int q = 0;
    long long int ans = p;
    long long int s = 0;
    long long int d = 1;
    for ( long long int i = 0; i < n; i++ ) {
        if ( i < p - 1 ) continue;
        if ( i == p - 1 ) {
            q = -a[i];
            continue;
        }
        long long int k = q - (-a[i]);
//        cout << " " << i << " " << k << " " << d << " " << s << endl;
        if ( k > m ) break;
        if ( v <= ( n - d ) ) {
        } else {
            if ( m * ( v - ( n - d ) ) > s + ( (-a[i]) + m - q ) * d ) break;
        }
        ans++;
        d++;
        s += q - (-a[i]);
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P;
 
const double eps = 1e-8;
 
bool equals(double a, double b) {
  return abs(a - b) < eps;
}
 
double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}
 
P project(P s1, P s2, P p) {
  P base = s2 - s1;
  double t = dot(p - s1, base) / norm(base);
  return s1 + base * t;
}
 
P reflect(P s1, P s2, P p) {
  return p + (project(s1, s2, p) - p) * 2.0;
}
 
P getRotateP(P p, double rad, P o = P(0, 0)) {
  P q = p - o;
  return o + P(q.real()*cos(rad) - q.imag()*sin(rad),
               q.real()*sin(rad) + q.imag()*cos(rad));
}
 
double degToRad(double deg) {
  return deg * M_PI / 180.0;
}
 
 
int main() {
  int N; double D;
  while(cin >> N >> D && !(N == 0 && D == 0)) {
    P pos(0, 0);
    double rad = M_PI / 2.0;
    for(int i = 0; i < N; ++i) {
      double dl, dr, t;
      cin >> dl >> dr >> t;
      double L = degToRad(dl);
      double R = degToRad(dr);
      if(equals(L, R)) {
        pos += P(cos(rad), sin(rad)) * L * t;
      } else if(equals(-L, R)) {
        rad += R * t / D;
      } else {
        bool f1 = false, f2 = false;
        if(abs(L) > abs(R)) {
          swap(L, R); f2 = true;
        }
        if(R < 0) {
          L *= -1; R *= -1; f1 = true;
        }
        double r;
        r = (R + L) * D / (R - L);
        double th = R / (r + D);
        P base1(cos(rad), sin(rad));
        P base2 = getRotateP(base1, M_PI/2.0);
        P p;
        p = pos + base2 * r;
        P npos = getRotateP(pos, th * t, p);
        double add = th * t;
        if(f1) {
          npos = reflect(p, p + base2, npos);
          add = -add;
        }
        if(f2) {
          npos = reflect(pos, pos + base1, npos);
          add = -add;
        }
        pos = npos;
        rad += add;
      }
    }
    printf("%.5f\n%.5f\n", pos.real(), pos.imag());
  }
  return 0;
}

Measured memory_bytes: 1324
N = int(input())
def translate(n):
    if n == 0:
        return "z"
    else:
        return (chr(n+96))
def solve(N):
    ans = ""
    while True:
        mod = N%26
        if mod == 0:
            N = N//26 - 1
        else:
            N = N//26
        if N == 0:
            ans = translate(mod) + ans
            return ans
            break
        else:
            ans = translate(mod) + ans
print(solve(N))

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}



int main() {

	int k;
	cin >> k;

	ll ans = 0;

	FOR(i, 1, k + 1) {
		FOR(j, 1, k + 1) {
			FOR(l, 1, k + 1) {
				ans += gcd(gcd(i, j), l);
			}
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,u,v;
  cin>>N>>u>>v;
  u--,v--;
  vector<vector<int>> A(N);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    A[a-1].push_back(b-1);
    A[b-1].push_back(a-1);
  }
  vector<int> B(N,-1),C(N,-1);
  queue<int> Q;
  B[v]=0;
  Q.push(v);
  while(!Q.empty()){
    int I=Q.front();
    Q.pop();
    for(int i:A[I])
      if(B[i]==-1){
        B[i]=B[I]+1;
        Q.push(i);
      }
  }
  C[u]=0;
  Q.push(u);
  while(!Q.empty()){
    int I=Q.front();
    Q.pop();
    for(int i:A[I])
      if(C[i]==-1){
        C[i]=C[I]+1;
        Q.push(i);
      }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(B[i]>C[i])ans=max(ans,B[i]-1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 10892
#include <bits/stdc++.h>
using namespace std;
#define ld long double
int f(int a){
    int l=0;
    while(a>0){
        l++;
        a/=10;
    }
    return l;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    pair<int,pair<int,int>> a[m];
    for(int i=0;i<m;i++){
        int p,y;
        cin>>p>>y;
        a[i]={y,{p,i+1}};
    }
    sort(a,a+m);
   // for(int i=0;i<m;i++) cout<<a[i].first<<" "<<a[i].second.first<<" "<<a[i].second.second<<endl;
    vector<vector<int>> v(n+1);
    for(int  i=0;i<m;i++){
        v[a[i].second.first].push_back(a[i].second.second);
    }
    pair<int,int> b[m+1];
    for(int i=1;i<=n;i++){ // cout<<i<<",  ";
        for(int j=0;j<v[i].size();j++){
          b[v[i][j]]={i,j+1};
          //cout<<v[i][j]<<" ";
        }
       // cout<<endl;
    }
    for(int i=1;i<=m;i++){  
        int p=b[i].first; int x=b[i].second;
        int z=6-f(p);
       // cout<<p<<" "<<x<<endl;
        for(int i=0;i<z;i++) cout<<"0";
        cout<<p;
        z=6-f(x);
        for(int i=0;i<z;i++) cout<<"0";
        cout<<x;
        cout<<"\n";        
    }
}







Measured memory_bytes: 8960
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n; //nは階段の段数
    int sum[31]; //上り方の種類数
    
    while(true){
        cin >> n;
        if(n == 0) break;
        
        for(int i = 1; i < 31; i++){
            if(i == 1) sum[i] = 1;
            else if(i == 2) sum[i] = 2;
            else if(i == 3) sum[i] = 4;
            else sum[i] = sum[i - 1] + sum[i - 2] + sum[i - 3];
        }
        
        int day, year;
        for(int i = 1; i < 31; i++){
            if(sum[i] % 10 != 0) day = sum[i] / 10 + 1;
            else day = sum[i] / 10;

            if(i == n){
            if(day > 365) year = day / 365 + 1;
            else year = 1;
            }
        }  
        cout << year << endl;
        // if(day > 365) cout << day / 365 + 1 << endl;
        // else cout << "1" << endl;
    }
}




Measured memory_bytes: 3060
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[][] s = new int[100][51];
		int[][] res = new int[100][51];
		int yp = 0;

		for (int i=0;i<100;i++)	{
			Arrays.fill(s[i],-1);
			Arrays.fill(res[i],0);
		}

		try {
			s[yp++][0] = Integer.parseInt(br.readLine());

			int xp = 0;
			while (true) {
				StringTokenizer st = new StringTokenizer(br.readLine(),",");
				int count = st.countTokens();
				for (int i=0;i<count;i++) {
					s[yp][xp++] = Integer.parseInt(st.nextToken());
				}
				if (count==1) break;
				xp = 0;
				yp++;
			}

			//check_s(s,yp);

			res[0][0] = s[0][0];
			for (int i=1;i<=yp;i++) {
				for (int j=0;s[i][j]!=-1;j++) {
					if (i<=(yp/2)) {
						if (j==0) {
							res[i][j] = res[i-1][j]+s[i][j];
						} else if (s[i-1][j]==-1) {
							res[i][j] = res[i-1][j-1]+s[i][j];
						} else {
							int t1 = res[i-1][j]+s[i][j];
							int t2 = res[i-1][j-1]+s[i][j];
							if (t1>t2) res[i][j] = t1;
							else res[i][j] = t2;
						}
					} else {
						int t1 = res[i-1][j]+s[i][j];
						int t2 = res[i-1][j+1]+s[i][j];
						if (t1>t2) res[i][j] = t1;
						else res[i][j] = t2;
					}
				}
			}
			System.out.println(res[yp][0]);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void check_s(int[][] s,int yp) {
		for (int i=0;i<=yp;i++) {
			int j = 0;
			while (s[i][j]!=-1) System.out.print(s[i][j++]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 24852
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    int m = 0, n = 0, N;
    string s;
    cin >> N >> s;
    for (char &a : s) {
        if (a == 'I') n++;
        else n--;
        m = max(m, n);
    }
    cout << m << "\n";
    return 0;
}


Measured memory_bytes: 256