akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1e9+7;

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

    int n,m;
    cin >> n >> m;

    vector<int> h(n);
    rep(i,n) cin >> h[i];

    vector<int> a(m),b(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    vector<vector<int>> G(n);
    rep(i,m){
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    int ans = 0;
    bool ok;
    rep(i,n){
        ok = true;
        rep(j,G[i].size()){
            if(h[i] <= h[ G[i][j] ]) ok = false;
        }
        if(ok) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    ll ans = 0LL;
    cin >> k;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int l = 1; l <= k; ++l) {
                ans += (ll) __gcd(i, __gcd(j, l));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<vector<int>> edge;
vector<bool> isVisited;
vector<bool> beingVisited;

int findCycle(int node, vector<int>& result)
{
    isVisited[node] = true;
    beingVisited[node] = true;

    int ret = -1;
    for (int ch : edge[node]) {
        if (isVisited[ch]) {
            if (beingVisited[ch]) {
                result.push_back(node);
                ret = ch;
                break;
            }
        } else {
            int t = findCycle(ch, result);
            if (t >= 0) {
                result.push_back(node);
                if (node == t) {
                    t = -1;
                }

                ret = t;
                break;
            } else {
                if (result.size() > 0) {
                    break;
                }
            }
        }
    }

    beingVisited[node] = false;
    return ret;
}

void findMin(vector<int>& cycle, vector<int>& tp)
{
    const int n = cycle.size();

    rep(i, n)
    {
        for (int ch : edge[cycle[i]]) {
            if (tp[ch] >= 0 && tp[ch] != (i + 1) % n) {

                vector<int> ncycle;
                int offset = tp[ch];
                int size = (i - offset + n) % n + 1;
                rep(j, size)
                {
                    int idx = (offset + j) % n;
                    ncycle.push_back(cycle[idx]);
                }
                cycle = ncycle;

                fill(tp.begin(), tp.end(), -1);
                rep(i, cycle.size())
                {
                    tp[cycle[i]] = i;
                }
                return findMin(cycle, tp);
            }
        }
    }
}

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

    edge.resize(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        edge[a - 1].push_back(b - 1);
    }

    isVisited.resize(n, false);
    beingVisited.resize(n, false);
    rep(i, n)
    {
        if (!isVisited[i]) {
            vector<int> cycle;
            findCycle(i, cycle);

            if (cycle.size() != 0) {
                reverse(cycle.begin(), cycle.end());

                vector<int> tp(n, -1);
                rep(i, cycle.size())
                {
                    tp[cycle[i]] = i;
                }

                findMin(cycle, tp);
                cout << cycle.size() << endl;
                rep(i, cycle.size())
                {
                    cout << cycle[i] + 1 << endl;
                }

                return 0;
            }
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> p(N);
    rep(i,N)cin >> p[i];
    int res = 0;
    for(int i=0;i<N;i++){
        if(p[i]==i+1){
            swap(p[i],p[i+1]);
            res++;
        }            
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
A = str(input())
B = str(input())
C = str(input())

n = "a"
while 1:
  if n == "a":
    if len(A) == 0:
      print("A")
      quit()
    n = A[0]
    A = A[1:]
  elif n == "b":
    if len(B) == 0:
      print("B")
      quit()
    n = B[0]
    B = B[1:]
  elif n == "c":
    if len(C) == 0:
      print("C")
      quit()
    n = C[0]
    C = C[1:]
  
  



Measured memory_bytes: 3188
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


//変数
ll N, M;






//サブ関数
//入力
void input()
{
	cin >> N >> M;
}

vector<ll> divisions(ll num) {
	vector<ll> res;
	FOR(i, 1, sqrt(num) + 1) {
		if (num%i == 0) {
			res.push_back(i);
			res.push_back(num / i);
		}
	}
	sort(res.begin(), res.end());
	reverse(res.begin(), res.end());
	return res;
}

bool judge(ll div) {
	ll num = M / div;
	return (num >= N);
}

//計算
void calc()
{
	if (M == 1) {
		cout << M << endl;
		return;
	}
	else if (M == 2) {
		cout << M / N << endl;
		return;
	}
	else if (M == 3) {
		cout << (N == 1 ? M : 1) << endl;
		return;
	}
	auto divs = divisions(M);
	for (auto div : divs) {
		if (judge(div)) {
			cout << div << endl;
			return;
		}
	}
	cout << 1 << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val yy = sc.nextInt()

  for (zi in 0..n) {
    for (yi in 0..n-zi) {
      val xi = n - zi - yi
      if (xi * 10000 + yi * 5000 + zi * 1000 == yy) {
        val ans = arrayOf(xi, yi, zi)
        println(ans.joinToString(" "))
        return
      }
    }
  }

  println("-1 -1 -1")
}


Measured memory_bytes: 41452
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    res=1
    for i in 2:999
        res+=i
        if res-b==(res-i)-a
            println(res-b)
        end
    end
end
main()

Measured memory_bytes: 109376
//
// ABC046A
// URL : https://atcoder.jp/contests/abc046/tasks/abc046_a
// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoder
{
    class ABC046A
    {
        static void Main(string[] args)
        {
            preprocess();

            long[] inputLongArray = Console.ReadLine().Split(' ').Select(_inputStr => long.Parse(_inputStr)).ToArray();
            long a = inputLongArray[0];
            long b = inputLongArray[1];
            long c = inputLongArray[2];
            var ls = new List<long>(3);
            foreach(var l in inputLongArray)
            {
                if (ls.Contains(l) == false) {
                    ls.Add(l);
                }
            }
            var ans = ls.Count;

            Console.WriteLine(ans.ToString());
            Console.Out.Flush();
        }

        //---------------------------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        public static void preprocess()
        {
            //出力高速化
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
        }


        /// <summary>
        /// 与えられた数が素数かどうかを計算する
        /// </summary>
        /// <param name="num">対象数</param>
        /// <returns>true:素数, false:素数ではない(合成数)</returns>
        public static bool isPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// 順列mPnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Permutation(long m, long n)
        {
            long ret = 1;
            for(var i = 0; i < n; ++i)
            {
                ret *= m - i;
            }
            return ret;
        }
        /// <summary>
        /// 組み合わせmCnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Combination(long m, long n)
        {
            if(m == n || n == 0)
            {
                return 1;
            }
            long ans = 1;
            for(var i = 0; i <= n; ++i)
            {
                ans *= (m - i + 1) / i;
            }
            return ans;
        }

        static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        static long Lcm(long m, long n)
        {
            var gcd = Gcd(m, n);
            //return (m * n) / gcd;
            return m / gcd * n;//桁あふれ対策
        }
    }
}



Measured memory_bytes: 13280
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int cnt[200001];
int main()
{
    cin >> N >> K;
    memset(cnt, 0, N+1);
    int ans = 0;
    rep(i, N){
        cin >> A;
        cnt[A]++;
    }
    priority_queue<int, vector<int>, greater<int>> que;
    rep(i, N+1){
        if(cnt[i] != 0) que.push(cnt[i]);
    }
    while(que.size() > K){
        ans += que.top();
        que.pop();
    }
    cout << ans;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
ll lcm=1;
rep(i, n){
    cin>>a[i];
}
ll ans = 0;
rep(i,n){
    ans+=a[i] - 1;
}
cout << ans << endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int N; cin >> N;
    vector<int> R(9, 0);
    for (int i = 0; i < N; i++) {
        int r; cin >> r;
        if (r < 400) {
            R[0] = 1;
        } else if (r < 800) {
            R[1] = 1;
        } else if (r < 1200) {
            R[2] = 1;
        } else if (r < 1600) {
            R[3] = 1;
        } else if (r < 2000) {
            R[4] = 1;
        } else if (r < 2400) {
            R[5] = 1;
        } else if (r < 2800) {
            R[6] = 1;
        } else if (r < 3200) {
            R[7] = 1;
        } else {
            R[8]++;
        }
    }

    int mi = 0;
    for (int i = 0; i < 8; i++) if (R[i]) mi++;
    int ma = mi + R[8];
    if (mi == 0) mi = 1;

    cout << mi << " " << ma << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");
    else if(b>=0)puts("Zero"); 
    else if((a&1)^(b&1))puts("Positive");
    else puts("Negative");
    return 0;
}

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

using namespace std;

int main(){
    int m,f,r;
    while(true){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1){
            break;
        }
        if(m+f>=80){cout << "A" << endl;}
        else if(m+f>=65){ cout << "B" << endl; }
        else if(m+f>=50){ cout << "C" << endl; }
        else if(m==-1||f==-1){ cout << "F" << endl; }
        else if(m+f>=30){ 
            if(r>=50){ cout << "C" << endl; }
            else{ cout << "D" << endl; }
        }
        else {
            cout << "F" << endl;
        }
    }
    return 0;
}


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

int main() {
  vector<int> a(32);
  a = {
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51
  };
  int k;
  cin >> k;

  cout << a[k-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll f(ll n,ll x){
	ll p=n/x,r=n%x;
	if(p*x==n)return (2ll*p-1ll)*x;
	return 2ll*p*x+f(x,r);
}

int main(){
	ll n,x;
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",f(n-x,x)+n);
	return 0;
}



Measured memory_bytes: 128
#include <iostream>

using namespace std;

const int MAX_N = 505;

void failure () {
  cout << "No" << endl;
  exit(0);
}

void error () {
  cerr << "==== ERROR ====" << endl;
}

int kth [MAX_N];
int arr [MAX_N * MAX_N];
int cnt [MAX_N];
int spec [MAX_N * MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  
  for (int i = 1; i <= n; i++) {
    cin >> kth[i];
    spec[kth[i]] = i;
  }

  for (int i = 1; i <= n * n; i++) {
    if (spec[i] != 0) {
      if (cnt[spec[i]] != spec[i] - 1) failure();
      arr[i] = spec[i];
      cnt[spec[i]]++;
    } else {
      // find the leftmost spec we aren't ready for
      pair<int, int> cur_spec = make_pair(MAX_N * MAX_N, -1);
      for (int j = 1; j <= n; j++) {
        if (i < kth[j] && cnt[j] < j - 1) {
          cur_spec = min(cur_spec, make_pair(kth[j], j));
        }
      }

      if (cur_spec.second != -1) {
        arr[i] = cur_spec.second;
        cnt[cur_spec.second]++;
      } else {
        // find anything that passed and isn't full
        int cur = -1;
        for (int j = 1; j <= n; j++) {
          if (kth[j] < i && cnt[j] < n) {
            cur = j;
          }
        }

        if (cur != -1) {
          arr[i] = cur;
          cnt[cur]++;
        } else {
          failure();
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cnt[i] = 0;
  }

  for (int i = 1; i <= n * n; i++) {
    cnt[arr[i]]++;
    if (spec[i] != 0) {
      if (cnt[spec[i]] != spec[i]) {
         error();
        //cerr << "not kth of " << spec[i] << endl;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    if (cnt[i] != n) {
      error();
      //cerr << "not n of " << i << endl; 
    }
  }

  cout << "Yes" << endl;
  for (int i = 1; i <= n * n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}


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

int main()
{
	int get ;
	int debt = 100000 ;
	int num[4] ;

	cin >> get ;
	for( int i = 0 ; i < get ; i ++ )
	{
		debt *= 1.05 ;
		int tmp = debt ;

		for( int j = 0 ; j < 4 ; j ++ )
		{
			num[j] = (tmp % 10) ;
			tmp /= 10 ;
		}

		if( num[0] != 0 || num[1] != 0 || num[2] != 0 )
		{
			debt -= (num[0] + num[1]*10 + num[2]*100) ;
			debt += 1000 ;
		}
	}

	cout << debt << endl ;
	return 0 ;
}

Measured memory_bytes: 1160
def main():
    from collections import defaultdict

    inf = 10 ** 15

    N = int(input())
    *a, = map(int, input().split())

    it = iter(a)

    dp = [defaultdict(lambda: -inf) for _ in range(N + 1)]
    dp[0][0] = 0
    dp[1][0] = 0
    dp[1][1] = next(it)
    for i, x in enumerate(it, 2):
        mi = (i - 1) // 2
        ma = (i + 1) // 2
        for taken_count in range(mi, ma + 1):
            dp[i][taken_count] = max(
                dp[i - 1][taken_count],
                dp[i - 2][taken_count - 1] + x
            )

    ans = dp[N][N // 2]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 144528
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;

int main() {
  string S;
  int w;
  string S2;
  cin >> S >>w;
  fx(S.size()){
  	if(x%w==0){
  		S2+=S.at(x);
  	}
  	
  }
  ce(S2);
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{ int a, b,c;
	scanf("%d %d %d", &a, &b,&c);
	if(a<b){if(b<c){printf("Yes\n");	}else{printf("No\n");
	};
	}else{
	printf("No\n");};
	return 0;
}


Measured memory_bytes: 2048
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.awt.geom.*;
import static java.util.Arrays.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		long[] fib = new long[n+1];
		fib[0] = 1;
		fib[1] = 1;
		for(int i=2;i<=n;i++){
			fib[i] = fib[i-1] + fib[i-2];
		}

		out.println(fib[n]);
		out.flush();
	}
}

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

template<typename T, int M>
struct RMQ {
    T arr[M];
    T INF;
    int N;
    
    RMQ(int N_, T INF_) {
        INF = INF_;
        for (int j = 0; j < M; ++j) {
            arr[j] = INF;
        }

        N = 1;
        while (N < N_) N *= 2;
    }

    void update(int x, int a) {
        int ind = N - 1 + x;

        arr[ind] = a;

        while (ind > 0) {
            ind = (ind - 1) / 2;
            arr[ind] = min(arr[ind*2 + 1], arr[ind*2 + 2]);
        }
    }

    T query(int x, int y) {
        return query_(x, y, 0, 0, N);
    }
    
    T query_(int x, int y, int v, int l, int r) {
        if (y <= l || r <= x) return INF;

        if (x <= l && r <= y) return arr[v];

        T vl = query_(x, y, 2*v + 1, l, (l + r) / 2);
        T vr = query_(x, y, 2*v + 2, (l + r) / 2, r);

        return vl < vr ? vl : vr;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    RMQ<int, 300000> rmq(n, ((1 << 30) - 1) * 2 + 1);

    for (int j = 0; j < q; ++j) {
        int com, x, y;
        cin >> com >> x >> y;

        if (com == 0) {
            rmq.update(x, y);
        }

        if (com == 1) {
            int res = rmq.query(x, y+1);
            cout << res << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2336
#[allow(dead_code)]
fn main() {
    let mut dd = i::i();
    let mut nn = i::i();
    if (nn==100){
        nn=101;
    }
    if (dd==0){
        println!("{}",nn);
    }else{
        //let mut kazu=(100.0 as f64).powf(dd as f64);
        print!("{}",nn);
        for xx in 0..(dd as usize){
            print!("00");
        }
    }



}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2136
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
   
   ll ans = max(a*c,max(b*d,max(a*d,b*c)));


    //本文
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

int N, M, X, Y;
int x;
int y;
int MAX = -100;
int MIN = 100;

int main(){
	cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; i++){
		cin >> x;
		if (x > MAX){
			MAX = x;
		}
	}
	for (int i = 0; i < M; i++){
		cin >> y;
		if (y < MIN){
			MIN = y;
		}
	}
	for (int z = -100; z <= 100; z++){
		if (z > X){
			if (z < Y){
				if (z > MAX){
					if (z <= MIN){
						cout << "No War" << endl;
						return 0;
					}
				}
			}
		}
	}

	cout << "War" << endl;

	return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

template <class T>
T modpow(T x, T n, const T mod) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//---------------------------------------------------------------------------------------------------

signed main() {
    i64 m, n;
    cin >> m >> n;
    cout << modpow(m, n, (i64)(1e9 + 7)) << "\n";
}



Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long answer=0;
  for(int i=1;i<N;i++){
    answer+=(N-1)/i;
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3212
def slove():
    import sys
    input = sys.stdin.readline

    n, m = list(map(int, input().rstrip('\n').split()))
    x = list(map(int, input().rstrip('\n').split()))
    x.sort()
    ls = [0, m - 1]
    d = []
    for i in range(1, len(x)):
        d.append([abs(x[i] - x[i-1]), i, i - 1])
    d.sort(reverse=True)
    for i in range(min(n-1, len(d))):
        ls.append(d[i][1])
        ls.append(d[i][2])
    ls.sort()
    t = 0
    for i in range(1, len(ls), 2):
        t += (abs(x[ls[i]] - x[ls[i-1]]))
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 76584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n,k,x,y;
    while(~scanf("%d %d %d %d",&n,&k,&x,&y))
    {

        if(n>k)
            printf("%d\n", x*k+(n-k)*y);
        else

            printf("%d\n", x*n);

    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
   
   
    using namespace std;
   int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}
    int main()
    {
      int n;
      int m;
      cin>>n>>m;
      cout<<intlog(m,n)+1;
      return 0;
    }

Measured memory_bytes: 512
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

LOOP = input()
for loop in range(LOOP):
    puyo = []
    for i in range(12):
        puyo.append(list(raw_input()))
    
    for cnt in range(20):
        used = [[False] * 6 for i in range(12)]
        def func(y, x, c):
            if y < 0 or x < 0 or y >= 12 or x >= 6:
                return 0
            if puyo[y][x] != c or used[y][x]:
                return 0
            used[y][x] = True
            ret = 1
            ret += func(y - 1, x, c)
            ret += func(y + 1, x, c)
            ret += func(y, x - 1, c)
            ret += func(y, x + 1, c)
            return ret

        def erase(y, x, c):
            if y < 0 or x < 0 or y >= 12 or x >= 6:
                return
            if puyo[y][x] == 'O':
                puyo[y][x] = '.'
                return
            if puyo[y][x] != c:
                return
            puyo[y][x] = '.'
            erase(y - 1, x, c)
            erase(y + 1, x, c)
            erase(y, x - 1, c)
            erase(y, x + 1, c)

        flag = True
        for i in range(12):
            for j in range(6):
                if puyo[i][j] in "RGBYP":
                    num = func(i, j, puyo[i][j])
                    if num >= 4:
                        flag = False
                        erase(i, j, puyo[i][j])
        for t in range(50):
            for i in range(1, 12):
                for j in range(6):
                    if puyo[i][j] == '.':
                        puyo[i][j], puyo[i - 1][j] = puyo[i - 1][j], puyo[i][j]
        if flag:
            print cnt
            break


Measured memory_bytes: 5060
#include<bits/stdc++.h>
#include<set>
#define ll long long
#define st string
#define f(i,l,r) for(int i=l;i<=r;i++)
#define ff(i,l,r) for(int i=l;i>=r;i--)
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin >> a >> b;
    f(i,1,max(a,b)) cout << min(a,b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
const ll mod1 = 998244353;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod1;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod1;
        a = a * a % mod1;
        b /= 2;
    }
    return ans;
}

int main(){

 
   ios_base :: sync_with_stdio(0);
   cin.tie(0);
    ll n,x,y;
    cin>>n>>x>>y;

    ll ans[n+1] = {0};

    ll dist,dist2;

    for(int i = 1;i<=x;i++){
        for(int j=i+1;j<=x;j++){
                dist = j-i;
                ans[dist] += 1;
        }
    }
     for(int i = y;i<=n;i++){
        for(int j=i+1;j<=n;j++){
                dist = j-i;
                ans[dist] += 1;
        }
    }
     for(int i = 1;i<=x;i++){
        for(int j=y;j<=n;j++){
                dist = x-i;
                dist += j-y;
                dist++;
                ans[dist] += 1;
        }
    }
    for(int i = x+1;i<=y-1;i++){
        for(int j = 1;j<=x;j++){
            dist  = abs(j-i);
            dist2 = abs(i-y)+1;
            dist2 += x-j;
            ans[min(dist,dist2)] += 1;
        }
        for(int j = y;j<=n;j++){
            dist  = abs(j-i);
            dist2 = abs(x-i);
            dist2++;
            dist2 += j-y;
              ans[min(dist,dist2)] += 1;

        }
    }
    for(int i =x+1;i<=y-1;i++){
        for(int j = i+1;j<=y-1;j++){
             dist  = abs(j-i);
             dist2 = abs(x-i);
             dist2++;
             dist2 += abs(y-j);
               ans[min(dist,dist2)] += 1;

        }
    }

    rep(i ,1, n){
        cout<<ans[i]<<"\n";
    }
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
//数字の桁和を計算する
int digsum(int n) {
    int res = 0;
    while(n > 0) {
    res += n%10;
    n /= 10;
    }
    return res;
}

signed main(){
    gearup;
    ll n;cin>>n;
    if(n%digsum(n) == 0)out("Yes");
    else out("No");
}



Measured memory_bytes: 256
// ABC140-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int score=0;
    rep(i,n-1){
        if(s[i]==s[i+1]) score+=1;
    }
    score=score+2*k;
    cout<<min(score,n-1)<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>

int main()
{
	int x, y;
	char op;
	while(1){
		scanf("%d %c %d", &x, &op, &y);
		if(op == '?') break;
		if(op == '+') printf("%d\n", x + y);
		if(op == '-') printf("%d\n", x - y);
		if(op == '*') printf("%d\n", x * y);
		if(op == '/') printf("%d\n", x / y);
	}
	return 0;
}

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

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

    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i].first >> p[i].second;
    
    sort(p.begin(), p.end());
    
    double ans = 0.0;
    int fac = 0;
    do{
        for (int i = 0; i < n - 1; i++){
            ans += sqrt((double) ((p[i].first - p[i + 1].first) * (p[i].first - p[i + 1].first)) + (double) ((p[i].second - p[i + 1].second) * (p[i].second - p[i + 1].second)));
        }

        fac += 1;
    } while (next_permutation(p.begin(), p.end()));
    
    cout << fixed << setprecision(10);
    cout << ans / fac << '\n';

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
k = 26
m = 1
while n > k do
  n -= k
  k *= 26
  m += 1
end
n -= 1
s = ""
m.times do
  s = "abcdefghijklmnopqrstuvwxyz"[n % 26] + s
  n /= 26
end
puts s


Measured memory_bytes: 14296
K = gets.chomp.to_i

L = (K%7).zero? ? 9*K/7 : 9*K
i = 1
mod = 1
while i < 9*K
  mod = mod*10%L
  if mod == 1
    break
  end
  i += 1
end
if i < 9*K
  puts i
else
  puts -1
end

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

//#define LOCAL_DEFINE
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())

#define deb(x) cout<< #x <<" = " <<x <<endl;
#define deb2(x,y) cout<< #x <<" = "<<x << " "<<#y<<" = "<<y<<endl;
#define deb3(x,y,z) cout<<#x <<" = "<<x <<" "<<#y<<" = "<<y <<" "<<#z<<" = "<<z<<endl;
#define deb4(w,x,y,z) cout<<#w<<" = " << w<<" "<<#x <<" = "<<x <<" "<<#y<<" = "<<y <<" "<<#z<<" = "<<z<<endl;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;


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

    #ifdef LOCAL_DEFINE
    clock_t time_req;
    time_req = clock();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    //Start_code
    string s;
    cin>>s;
    
    if(s[2] == s[3] && s[4] == s[5])
        cout<<"Yes";
    else
        cout<<"No";

    
    //End_code
    #ifdef LOCAL_DEFINE
    time_req = clock()- time_req;
    cout << "Time elasped: "
        << (float)time_req/CLOCKS_PER_SEC << "s" << endl;
    #endif

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ttt = sc.nextInt();
        int[] c = new int[n];
        int[] t = new int[n];
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            t[i] = sc.nextInt();
        }
        int min = 100000;
        for (int i = 0; i < n; i++) {
            if (t[i] <= ttt) {
                if (c[i] < min) {
                    min = c[i];
                }
            }
        }
        if (min > 2000) {
            System.out.println("TLE");
        } else {
            System.out.println(min);
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n)  for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fi first
#define se second
#define pb(x) push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  LL  long long
#define  maxm(a,b,c)  max(a,max(b,c))
const int INF = 1e9+7;
const int MAXN = 3005;
LL dp[MAXN][MAXN];
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i = 0;i<n;++i){
  	cin>>a[i];
  }
  for(int L = n-1;L>=0;--L){
  	for(int R = L;R<n;++R){
  		if(L == R){
		  dp[L][R] = a[L];
		 
	}
  		else{
  			dp[L][R] = max(a[L] - dp[L+1][R] , a[R] - dp[L][R-1]);
		  }
	  }
  }
  cout<<dp[0][n-1];
  }
  


Measured memory_bytes: 70016
def main():
    N = int(input())
    c = input()
    cnt = 0
    left = 0
    right = len(c) - 1
    while True:
        while c[right] == "W" and left < right:
            right -= 1
        while c[left] == "R" and left < right:
            left += 1
        if left >= right:
            return cnt
        cnt += 1
        right -= 1
        left += 1
    return cnt

if __name__ == '__main__':
    print(main())

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

using namespace std;

int h,w;
const int mod=1e9+7;  
const int size=1e3+1;
int mat[size][size];
bool state[size][size];
bool vis[size][size];
int movx[2]={0,1};
int movy[2]={1,0};
bool valid(int x,int y){
  return x>=0 && x<h && y>=0 && y<w && state[x][y];
}
int dp(int i,int j){

  if(vis[i][j])
    return mat[i][j];

  if(i==h-1 && j==w-1)
    return 1;

  vis[i][j]=1;
  for(int x=0;x<2;x++){
    if(valid(i+movx[x],j+movy[x])){
      mat[i][j]+=(dp(i+movx[x],j+movy[x]));
      mat[i][j]%=mod;
    }
  }

  return mat[i][j];
}
int main(){

  scanf("%d %d",&h,&w);
  cin.ignore();
  char c;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf("%c",&c);
      if(c=='.')
        state[i][j]=true;
      else
        state[i][j]=false;
    }
    cin.ignore();
  }
  printf("%d\n",dp(0,0));

  return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
   int a, b, c, d;
   cin >> a >> b >> c >> d;
   int x = c - a;
   int y = d - b;
   cout << c - y << endl;
   cout << d + x << endl;
   cout << a - y << endl;
   cout << b + x << endl;
}

Measured memory_bytes: 256
N=gets.to_i
array=[]
N.times{
  array << gets.to_i
}
i=1
g=0
while true
	i=array[i-1]
	g+=1
	if i==2
  		puts g
  		break
	end
    if g >= N
      	puts -1
    	break
    end
end

Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt();
            var N = line[0];
            var M = line[1];
            var ranges = consoleReader.RepeatSplitInt(M).Select(l => new Range { start = l[0], end = l[1] });

            var resRange = new Range { start = 1, end = N };
            foreach (var r in ranges)
            {
                resRange = new Range { start = Math.Max(r.start, resRange.start), end = Math.Min(r.end, resRange.end) };
            }
            if (resRange.start > resRange.end) return 0;
            else return resRange.end - resRange.start + 1;
        }

        struct Range
        {
            public int start;
            public int end;
        }

        public const int mod = 1000000007;
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc()); static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    #region Console
    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int() => int.Parse(String()); public long Long() => long.Parse(String()); public ulong ULong() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt() => String().Split().Select(int.Parse).ToArray(); public long[] SplitLong() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitULong() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt(int count) { for (int i = 0; i < count; i++) yield return Int(); } public IEnumerable<long> RepeatLong(int count) { for (int i = 0; i < count; i++) yield return Long(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt(int count) { for (int i = 0; i < count; i++) yield return SplitInt(); } }
    #endregion
}

Measured memory_bytes: 17484
n, m = gets.split.map(&:to_i)
queue = []
(1..n).each do |id|
	s, t = gets.split.map(&:to_i)
	s, t = -s, -t if s > t
	queue << [s, :string_start, id]
	queue << [t, :string_end, id]
end

(1..m).each do
	q = gets.to_i
	queue << [-q, :cut_point]
	queue << [q, :cut_point]
end

queue.sort!

i = 0
even = 0
odd = 0
parity = {}
x0 = nil
sum = 0
until queue.empty?
	x = queue[0][0]
	x0 ||= x
	sum += (x - x0) * (i.odd? ? odd : even)

	cut = false
	while !queue.empty? && queue[0][0] == x
		_, event, id = queue.shift
		case event
		when :cut_point
			cut = true
		when :string_start
			i.odd? ? (odd += 1) : (even += 1)
			parity[id] = i % 2
		when :string_end
			parity[id].odd? ? (odd -= 1) : (even -= 1)
		end
	end

	i += 1 if cut
	x0 = x
end

p sum

Measured memory_bytes: 40340
#include<stdio.h>
int main(void){
	double a,b;
	int c,d;
	scanf("%lf %lf",&a,&b);
	c=a;
	d=b;
	printf("%d ",c/d);
	printf("%d ",c%d);
	printf("%lf\n",a/b);
	return 0;
}


Measured memory_bytes: 2104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] inputNumbers = br.readLine().split(" ");
            int numberAxNumberB = Integer.parseInt(inputNumbers[0]) * Integer.parseInt(inputNumbers[1]);

            String isOddPossible = "No";
            for (int i = 1; i <= 3; i++) {
                if ((numberAxNumberB * i) % 2 != 0) {
                    isOddPossible = "Yes";
                    break;
                }
            }

            System.out.println(isOddPossible);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 23124
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        m: usize,
    }

    if n>=m/2 {
        println!("{}", m/2);
    } else {
        println!("{}", (n+m/2)/2);
    }

}


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

int main(){
  int n;
  cin >> n;
  int t[n];
  int x[n];
  int y[n];

  for(int i=0;i<n;i++){
    cin >> t[i] >> x[i] >> y[i];
  }

  int t_now = 0;
  int x_now = 0;
  int y_now = 0;
  int flag = 1;

  for(int j=0;j<n;j++){
    if(j>0){
      t_now = t[j-1];
      x_now = x[j-1];
      y_now = y[j-1];
    }

    int t_diff = t[j] - t_now;
    int x_diff = x[j] - x_now;
    int y_diff = y[j] - y_now;

    if((abs(x_diff)+abs(y_diff) <= t_diff) &&
       (abs((x_diff + y_diff - t_diff) % 2) == 0)){
      flag = 1;
    }
    else{
      flag = 0;
    }
  }

  if(flag == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << " ";cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "Yes": "No") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define phi_v 1.618034

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	int count_red = 0, count_white = 0;
	for (int i = 0; i<n; i++) {
		if (s[i] == 'R') count_red++;
		else count_white++;
	}
	if (!count_red || !count_white) cout << 0 << '\n';
	else {
		int ret = min(count_red, count_white), tmp_ret = 0;
		string temp = "";
		for (int i = 0; i<n; i++) {
			temp += 'W';
			tmp_ret += s[i] != 'W';
		}
		ret = min(ret, tmp_ret);
		for (int i = 0; i<count_red; i++) {
			temp[i] = 'R';
			tmp_ret -= s[i] == temp[i];
			ret = min(ret, tmp_ret);
		}
		cout << ret << '\n';	
	}
	
}


Measured memory_bytes: 3856
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {
	int N;
	scanf("%d", &N) + 1;

	vector<int> vi;

	int tmp1;
	for (int i = 0; i < N; i++) {
		scanf("%d", &tmp1) + 1;
		vi.push_back(tmp1);
	}

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

	int ans = vi[0];
	for (int i = 1; i < N; i++) {
		int tmpA = ans;
		int tmpB = vi[i];
		while (1) {
			if (tmpB % tmpA == 0) break;
			int tmp = tmpA;
			tmpA = tmpB % tmpA;
			tmpB = tmp;
		}
		ans = tmpA;
	}
	
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 892