akhauriyash/Code-Regression huggingface dataset:
import sys

n = int( sys.stdin.readline() )
cards = { 'S': [ False ] * 13, 'H': [ False ] * 13, 'C': [ False ] * 13, 'D': [ False ] * 13 }
for i in range( n ):
	pattern, num = sys.stdin.readline().split( " " )
	if "S" == pattern:
		cards[ 'S' ][ int( num )-1 ] = True
	elif "H" == pattern:
		cards[ 'H' ][ int( num )-1 ] = True
	elif "C" == pattern:
		cards[ 'C' ][ int( num )-1 ] = True
	elif "D" == pattern:
		cards[ 'D' ][ int( num )-1 ] = True

for pattern in ( 'S', 'H', 'C', 'D' ):
	for i in range( 13 ):
		if not cards[ pattern ][ i ]:
			print( "{:s} {:d}".format( pattern, i+1 ) )

Measured memory_bytes: 4248
A, B = map(int, input().split())
def Main(A, B):
    if A == B:
        return 'Draw'
    elif A == 1:
        return 'Alice'
    elif B == 1:
        return 'Bob'
    else:
        return 'Alice' if A > B else 'Bob'
    
print(Main(A, B))


Measured memory_bytes: 2940
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  string x;
  cin >> x;

  size_t n = x.size();
  ll cnt = 0;
  ll scnt = 0, tcnt = 0;

  rep(i, n) {
    if (x.at(i) == 'S') ++scnt;
    else ++tcnt;

    if (scnt > 0 and x.at(i) == 'T') {
      cnt += 2;
      --scnt;
      --tcnt;
    }
  }

  cout << n - cnt << endl;

  return 0;
}

Measured memory_bytes: 720
import math

def plot(x,y):
    print(f"{x:.8f} {y:.8f}")

def koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    koch(n-1,x1,y1,sx,sy)
    koch(n-1,sx,sy,ux,uy)
    koch(n-1,ux,uy,tx,ty)
    koch(n-1,tx,ty,x2,y2)
    
n=int(input())
koch(n,0,0,100,0)
plot(100,0)


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

int index(char c){
	if(c == ' ') return 26;
	if(c == '\'') return 27;
	if(c == ',') return 28;
	if(c == '-') return 29;
	if(c == '.') return 30;
	if(c == '?') return 31;
	return (int)c - (int)'A';
}

string coder[] = {
	"100101", "10011010",
	"0101", "0001", "110",
	"01001", "10011011", "010000",
	"0111", "10011000", "0110",
	"00100", "10011001", "10011110",
	"00101", "111", "10011111",
	"1000", "00110", "00111",
	"10011100", "10011101",
	"000010", "10010010",
	"10010011", "10010000",
	"101", "000000",
	"000011", "10010001",
	"010001", "000001"
};

char uncoder[] = {
	'A', 'B', 'C', 'D',
	'E', 'F', 'G', 'H',
	'I', 'J', 'K', 'L',
	'M', 'N', 'O', 'P',
	'Q', 'R', 'S', 'T',
	'U', 'V', 'W', 'X',
	'Y', 'Z', ' ', '.',
	',', '-', '\'', '?'
};

string code(char c){
	return coder[index(c)];
}

char uncode(string s){
	int num = 0;
	for(int i = 0, j = 16;i < 5; i++, j = j / 2){
		if(s[i] == '1') num += j;
	}
	return uncoder[num];
}

int main(){
	string s;
	while(getline(cin, s)){
		string t;
		for(string::iterator iter = s.begin();
			iter != s.end(); iter++)
		{
			t += code(*iter);
		}
		while(t.size() % 5 != 0) t += "0";
		for(string::iterator iter = t.begin();
			iter != t.end(); iter += 5)
		{
			string t2(iter, iter + 5);
			cout << uncode(t2);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33772
#include <stdio.h>

int main(){
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  int tmp = b;
  b = a;
  a = tmp;
  tmp = c;
  c = a;
  a = tmp;
  printf("%d %d %d\n", a, b, c);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int p[123456], d[123456];
vector<int>v[123456];
void f(int a,int d_a) {
	d[a] = d_a;
	for (int i = 0; i < v[a].size(); i++) {
		f(v[a][i], d_a + 1);
	}
	return;
}
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)p[i] = -1;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			v[a].push_back(c);
			p[c] = a;
		}
	}
	for (int i = 0; i < n; i++)if (p[i] == -1) { f(i, 0); break; }
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << p[i] << ", depth = " << d[i] << ", ";
		if (p[i] == -1)cout << "root, [";
		else if (v[i].size() <= 0)cout << "leaf, [";
		else cout << "internal node, [";
		for (int j = 0; j < v[i].size(); j++) {
			if (j)cout << ", ";
			cout << v[i][j];
		}
		cout << "]\n";
	}
}


Measured memory_bytes: 7604
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[0]*m
x=[0]*m
for i in range(m):
  p[i],x[i]=map(int,input().split())
fulltime=sum(t)
for i in range(m):
  print(fulltime-(t[p[i]-1]-x[i]))

Measured memory_bytes: 3064
parseInt(x) = parse(Int, x)

function main()
  N = readline() |> parseInt
  s = Array{String}(N)
  for i=1:N
    s[i]=readline()|>strip
  end

  # w=count(b->b,map(ss->contains(ss,"AB"),s))
  w=sum(map(ss->(split(ss,"AB")|>length)-1,s))
  x=count(b->b,map(ss->ss[1]!='B'&&ss[end]=='A',s))
  y=count(b->b,map(ss->ss[1]=='B'&&ss[end]!='A',s))
  z=count(b->b,map(ss->ss[1]=='B'&&ss[end]=='A',s))
  # println([x,y,z,w])
  # result=z-1+(x>=1?1:0)+(y>=1?1:0)+((x>=1&&y>=1)?min(x-1,y-1):0)+w
  result=if z==0
    min(x,y)
  elseif x+y>0
    z+min(x,y)
  else
    z-1
  end
  result+=w

  println(result)
end

main()


Measured memory_bytes: 118688
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define ll long long


int main(){
    int n;
    cin>>n;
    int num[4];
    for(int i=0;i<4;i++){
        num[i]=n%10;
        n/=10;
    }
    if((num[0]==num[1])&&(num[1]==num[2])){
        cout<<"Yes\n";
    }else if((num[3]==num[2])&&(num[1]==num[2])){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/

#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define fo(x,y) for(int x = 1 ; x <= y ; ++x)
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;

typedef long long ll;
typedef unsigned int uint;
const int nmax = 200005;
const ll linf = LLONG_MAX;
const int mod = 1e9+7;
const int inf = INT_MAX;
#define pll pair<ll,ll>


int a, b;
string sa , sb , t;
int main(){
    cin >> sa >> sb >> a >> b;
    cin >> t;
    if(t == sa){
        cout << a-1 << ' ' << b << '\n';
    }else{
        cout << a << ' ' << b-1 << '\n';
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 gcd(i64 x, i64 y) {
  return x % y == 0 ? y : gcd(y, x % y);
}

i64 n;
vector<i64> a;
int main() {
  cin >> n;
  read_n(a, n);
  vector<i64> l(n), r(n);
  l[0] = a[0];
  r[n - 1] = a[n - 1];
  for (i64 i = 1; i < n; ++i) {
    l[i] = gcd(l[i - 1], a[i]);
  }
  for (i64 i = n - 2; i >= 0; --i) {
    r[i] = gcd(r[i + 1], a[i]);
  }
  i64 ans = max(l[n - 2], r[1]);
  for (i64 i = 0; i < n - 2; ++i) {
    ans = max(ans, gcd(l[i], r[i + 2]));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2688
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
vector<pint> ic;
int out[315][315];
string ma[315];
int main()
{
	int h,w,n;
	cin>>h>>w>>n;
	rep(i,h) cin>>ma[i];
	rep(i,h) rep(j,w){
		if(ma[i][j]=='#') ic.pb(mp(i,j));
	}
	ic.pb(mp(h,w));
	int it=0,nx=0,id=1;
	while(it<n){
		int i2=it;
		while(i2<n && ic[i2].fi==ic[it].fi) i2++;
			int ny=0;
			REP(j,it,i2){
				REP(k,ny,ic[j].se+1){
					REP(i,nx,ic[i2].fi) out[i][k]=id;
				}
				if(j==i2-1){
					REP(k,ic[j].se,w){
						REP(i,nx,ic[i2].fi) out[i][k]=id;
					}
				}
				ny=ic[j].se+1;
				id++;
			}
		nx=ic[i2].fi;
		it=i2;
	}
	rep(i,h){
		rep(j,w){
			cout<<out[i][j];
			if(j<w-1) cout<<' ';
			else cout<<endl;
		}
	}
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
struct dat{int h,f;};
int n;
vector<dat> A;

vector<dat> compless(vector<dat> A,int h){
  int n=A.size();

  for(int i=0;i<n-1;i++)
    if(A[i].f&&A[i+1].f)A[i+1].h=max(A[i+1].h,A[i].h),A[i]=(dat){0,0};

  for(int i=0;i<n-1;i++){
    if(A[i].f||A[i].h<=h)continue;
    int mn=A[i].h,idx=i;
    A[i]=(dat){0,0};
    while((A[++i].f&&h>=A[i].h)||!A[i].f){
      if(!A[i].f&&h>=A[i].h)continue;
      if(!A[i].f)mn=min(mn,A[i].h),idx=i;
      A[i]=(dat){0,0};
    }
    A[idx] = (dat){mn,0}; 
    i = idx;
  }

  vector<dat> res;
  for(int i=0;i<n;i++)if(A[i].h) res.push_back(A[i]);


  return res;
}
typedef pair<int,int>P;

int solve(){
  vector<int> H;
  A=compless(A,0);
  for(int i=0;i<A.size();i++)if(A[i].f)H.push_back(A[i].h);
  sort(H.begin(),H.end());
  H.erase(unique(H.begin(),H.end()),H.end());
  vector<dat> B[2];
  B[0] = A;
  for(int i=0;i<H.size();i++)B[(i+1)%2] = compless(B[i%2],H[i]);
  A = B[H.size()%2];
  int res=0;
  for(int i=0;i<A.size();i++)if(A[i].f==0)res++;
  return res;
}

int main(){
  cin>>n;
  A.resize(n+2);
  A[0]=(dat){10000,1};A[n+1]=(dat){10000,1};
  char ch;
  for(int i=1;i<=n;i++)cin>>ch>>A[i].h,A[i].f = ch=='n';
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main(){
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    int n;
    cin >> n;
    if(n < 1200 && n >= 0) cout << "ABC" << endl;
    else if(n < 2800 && n > 0) cout << "ARC" << endl;
    else if(n <= 4208 && n > 0) cout << "AGC" << endl;
return 0;
}


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

int main() {
    
    string s, t;
    int i, j;
    int sL, tL;
    int same = 0;
    int max = 0;

    cin >> s >> t;

    sL = s.length();
    tL = t.length();

    for(i=0; i<(sL-tL+1); i++){
        same = 0;
        for(j=0; j<tL; j++){
            // cout << s[j+i] << "  t:" << t[j] << same << endl;
            if(s[j+i] == t[j]){

                same++;
            }
        }
        if(max < same){
            max = same;
        }
    }

    cout << (tL - max) << endl;

    return 0;
}



Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{

    int length;    cin >> length;

    int sequenceA[100], sequenceB[100];
    for (int i = 0; i < length-1; i++){
        cin >> sequenceB[i];
    }

    sequenceA[0] = sequenceB[0];
    sequenceA[length] = sequenceB[length-2];
    int sum = sequenceA[0] + sequenceA[length];

    for (int i = 1; i < length-1; i++){
        if (sequenceB[i] > sequenceB[i-1]){
            sequenceA[i] = sequenceB[i-1];
        }

        else{
            sequenceA[i] = sequenceB[i];
        }

        //cout << sequenceA[i] << endl;
        sum += sequenceA[i];
    }

    cout << sum << endl;

    return 0;
}


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

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  if(a > b) swap(a,b);
  int count = 0;
  for(int i=a; i > 0;i--) {
    if(a%i==0&&b%i==0) {
      count++;
      if(count == k) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

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

  if ( a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else  {
    cout << "Even" << endl;
}
}
    

Measured memory_bytes: 3556
from bisect import bisect_left
n = int(input())
s = input()
d = {}

for i, c in enumerate(s):
    c = int(c)
    if c in d:
        d[c].append(i)
    else:
        d[c] = [i]

l = list(d.keys())
ans = 0

for i in l:
    index_i = d[i][0]
    for j in l:
        if d[j][-1] <= index_i:
            continue
        index_index = bisect_left(d[j], index_i)
        if i == j:
            if len(d[j]) > 1:
                index_index += 1
            else:
                continue
        index_j = d[j][index_index]

        for k in l:
            if d[k][-1] > index_j:
                ans += 1
print(ans)


Measured memory_bytes: 40048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;


int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;

    // 「1 の個数」「0 の個数」を交互に記録していく
    vector<int> nums;    
    if (S[0] == '0') nums.push_back(0); // 先頭が 0 だったら
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == S[i]) ++j; // S[i] の数値がどこまで続くか
        nums.push_back(j - i);
        i = j;
    }
    if (S.back() == '0') nums.push_back(0); // 最後尾が 0 だったら

    // 累積和
    vector<int> sums((int)nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); ++i) sums[i+1] = sums[i] + nums[i];

    // 偶数番目の添字から始まる、長さ 2K+1 (以下) の区間の総和のうち、最大値を求める
    int res = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + K*2+1;
        if (right >= sums.size()) right = (int)sums.size() - 1;
        res = max(res, sums[right] - sums[left]);
    }
    cout << res << endl;
}

Measured memory_bytes: 4144
#!/usr/bin/env/ python3
#S = input()
N = int(input())
#A, B, C = input().split()
#N, M = map(int, input().split())

#N = int(input())
A = [int(x) for x in input().split()]
B = [0] * N
#H, W = map(int, input().split())
#S = [input() for _ in range(H)]
#print(2*R*3.14159265)

for i in range(N-1):
    B[A[i]-1] += 1

for i in range(N):
    print(B[i])

Measured memory_bytes: 32328
<?php
fscanf(STDIN, "%d %d", $N, $K);
$ans = 0;
for ($i = $N; $i > 0; $i--) {
    $x = calc($N, $i, $K);
    $ans += $x;
}
printf("%d", $ans);

// $a 配る総数
// $b 配られる数
// $c 仕切り
function calc($a, $b, $c) {
    if ($c === 0) {
        return $a;
    } else {
        // 1つ当たり
        $d = intdiv($a, $b);
        // 余り
        $e = $a - $b * $d;
        $g = ($e >= $c) ? $e - $c + 1 : 0; 
        
        $f = $d * max(0, $b - $c);
        
        $h = $g + $f;
        //printf("a:%d b:%d c:%d d:%d amari:%d f:%d g:%d h:%d\n", $a, $b, $c, $d, $e, $f, $g, $h);
        return $h;
    }
}

Measured memory_bytes: 4728
# -*- coding: utf-8 -*-
N = int(input())
H = list(map(int, input().split()))
right = []
before = 0

for j in range(len(H)):
  if before >= H[j]:
    right.append(right[j - 1] + 1)
  else:
    right.append(0)
  before = H[j]

print(sorted(right, reverse=True)[0])

Measured memory_bytes: 15020
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
if(b==0) return a;
if(a < b) return GCD(b, a);
unsigned r;
while ((r=a%b)) {
a = b;
b = r;
}
return b;
}

int main() {
    char B;
    cin >> B;
    string ans;
    if(B == 'A'){
        ans = 'T';
    }else if (B == 'C'){
        ans = 'G';
    }else if (B == 'G'){
        ans = 'C';
    }else if (B == 'T'){
        ans = 'A';
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
//#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


const int N = 200100;
int a[N],b[N];

int32_t main(){
 fastio;
 int n;
 cin>>n;
 vector<pii> v(n);
 for(int i=0;i<n;i++){
  cin>>v[i].ff>>v[i].ss;
  a[i] = v[i].ff,b[i]=v[i].ss;
 }
 sort(a,a+n);
 sort(b,b+n);
 int meda = a[(n-1)/2],medb = b[(n-1)/2];
 
 vector<pii> seg;
 for(int i=0;i<n;i++){
  int l = max(meda,v[i].ff);
  int r = min(medb,v[i].ss);
  if(l<=r)seg.pb(pii(l,r));
 }

 sort(seg.begin(),seg.end());
 ll res=0;

 for(int i=0;i<sz(seg);){
   int r = seg[i].ss;
   int l = seg[i].ff;
   while(i<sz(seg) and seg[i].ff<=r){
     r = max(r,seg[i].ss);
     i++; 
   }
   res+=r-l+1;

 }


 if(n&1)cout << res << endl;
 else{
    meda = a[n/2],medb = b[n/2];
    seg.clear();
    for(int i=0;i<n;i++){
      int l = max(meda,v[i].ff);
      int r = min(medb,v[i].ss);
      if(l<=r)seg.pb(pii(l,r));
     }

     sort(seg.begin(),seg.end());
     ll res2=0;
     for(int i=0;i<sz(seg);){
       int r = seg[i].ss;
       int l = seg[i].ff;
       while(i<sz(seg) and seg[i].ff<=r){
         r = max(r,seg[i].ss);
         i++; 
       }
       res2+=(res-1) + r-l+1;
     }
     cout << res2 << endl;
 }

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 13616
import scala.util.control.Breaks

object Main extends App {
  val n = scala.io.StdIn.readInt()
  var fMap = scala.collection.mutable.Map.empty[Int, Set[Vector[Int]]]

  def caluc(x: Int, y: Int, z: Int) = {
    x * x + y * y + z * z + x * y + y * z + x * z
  }

  def loopVariableZ(x: Int, y: Int, z: Int) = {
    val b = new Breaks
    var i = z
    b.breakable {
      while (true) {
        val calucRes = caluc(x, y, i)
        if (calucRes > n) {
          b.break()
        } else {
          val fMapOpt = fMap.get(calucRes)
          if (fMapOpt.isDefined) {
            fMap.put(calucRes, fMapOpt.get + Vector(x, y, i).sorted)
          } else {
            fMap.put(calucRes, Set(Vector(x, y, i).sorted))
          }
        }
        i = i + 1
      }
    }
  }

  def loopVariableY(x: Int, y: Int, z: Int) = {
    val b = new Breaks
    var i = y
    b.breakable {
      while (true) {
        val calucRes = caluc(x, i, z)
        if (calucRes > n) {
          b.break()
        } else {
          val fMapOpt = fMap.get(calucRes)
          if (fMapOpt.isDefined) {
            fMap.put(calucRes, fMapOpt.get + Vector(x, i, z).sorted)
          } else {
            fMap.put(calucRes, Set(Vector(x, i, z).sorted))
          }
        }
        i = i + 1
        loopVariableZ(x, i, z)
      }
    }
  }

  def loopVariableX(x: Int, y: Int, z: Int) = {
    val b = new Breaks
    var i = x
    b.breakable {
      while (true) {
        val calucRes = caluc(i, y, z)
        if (calucRes > n) {
          b.break()
        } else {
          val fMapOpt = fMap.get(calucRes)
          if (fMapOpt.isDefined) {
            fMap.put(calucRes, fMapOpt.get + Vector(i, y, z).sorted)
          } else {
            fMap.put(calucRes, Set(Vector(i, y, z).sorted))
          }
        }
        i = i + 1
        loopVariableY(i, y, z)
      }

    }
  }

  loopVariableX(1, 1, 1)
  (1 to n).foreach { i =>
    val combVecOpt = fMap.get(i)
    if (combVecOpt.isDefined) {
      var result = 0
      val combVecVec = combVecOpt.get
      combVecVec.foreach { combVec =>
        if (combVec(0) == combVec(1) && combVec(0) == combVec(2) && combVec(1) == combVec(2)) {
          result = result + 1
        } else if (combVec(0) != combVec(1) && combVec(0) != combVec(2) && combVec(1) != combVec(2)) {
          result = result + 6
        } else {
          result = result + 3
        }
      }
      println(result)
    } else {
      println(0)
    }
  }
}

Measured memory_bytes: 70708
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(style))]
use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

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

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

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

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

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

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

//{{{utility macros missing in 1.15.1
// https://atcoder.jp/contests/nikkei2019-qual/submissions/4098548
macro_rules! eprint {
	($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
	    use ::std::io::Write;
            let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
    ($val:expr) => {
        match $val {
            tmp => {
                eprintln!(
                    "[{}:{}] {} = {:#?}",
                    file!(),
                    line!(),
                    stringify!($val),
                    &tmp
                );
                tmp
            }
        }
    };
}
//}}}

fn run() {
    input! {
        n: usize,
    }
    if n % 2 == 0 {
        println!("{}", n);
    } else {
        println!("{}", 2 * n);
    }
}

//{{{main
fn main() {
    let _ = ::std::thread::Builder::new()
        .name("run".to_string())
        .stack_size(1024 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join();
}
//}}}


Measured memory_bytes: 8572
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int n;
    cin >> n;
    if(n >= 30) output("Yes");
    else output("No");
    
    return 0;
}


Measured memory_bytes: 3648
from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
bset=set(b)

ans=0
for i in range(n):
  if a[i] in bset:
    ans=max(bisect_right(b,a[i])-i,ans)

# bを回転
b=(b+b)[ans:ans+n]
# check
for i in range(n):
  if a[i]==b[i]:
    exit(print("No"))
print("Yes")
print(*b)


Measured memory_bytes: 123904
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    string s;
    cin >> s;

    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    elif h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    else:
        p[A[i]] = False
        p[B[i]] = False
    
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))


Measured memory_bytes: 25352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,  digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vll path; vl D;
//***********//
int main() {
	ll A, B, C, D, E;
	string S, T;
	cin >> A >> B;


	cout << A * B;
}

Measured memory_bytes: 3632
W, H, N = map(int, input().split())
point_lst = [list(map(int, input().split())) for _ in range(N)]
x_1 = 0
x_2 = W
y_1 = 0
y_2 = H

for point in point_lst:
    if point[2] == 1:
        if point[0] > x_1:
            x_1 = point[0]

    elif point[2] == 2:
        if point[0] < x_2:
            x_2 = point[0]
    elif point[2] == 3:
        if point[1] > y_1:
            y_1 = point[1]
    else:
        if point[1] < y_2:
            y_2 = point[1]

width = x_2 - x_1 if x_2 > x_1 else 0
height = y_2 - y_1 if y_2 > y_1 else 0
print(width*height)

Measured memory_bytes: 62588
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
const int INF = 1e9;
int h,w;
int ch,cw;
int th,tw;
char s[N][N];
int dist[N][N];
int dh[] = {-1, 1, 0, 0};
int dw[] = {0, 0, -1, 1};
bool valid(int a, int b) {
	return a >= 0 and a < h and b >= 0 and b < w and s[a][b] != '#';
}
int main() {
	scanf("%d %d", &h, &w);
	scanf("%d %d", &ch, &cw);
	scanf("%d %d", &th, &tw);
	ch--, cw--, th--, tw--;
	for(int i = 0; i < h; ++i) {
		scanf("%s", s[i]);
		for(int j = 0; j < w; ++j)
			dist[i][j] = INF;
	}
	deque< tuple<int, int, int> > dq;
	dq.emplace_back(ch, cw, 0);
	dist[ch][cw] = 0;
	while(!dq.empty()) {
		auto front = dq.front();
		dq.pop_front();
		int ph = get<0>(front);
		int pw = get<1>(front);
		int d = get<2>(front);
		if(d > dist[ph][pw])
			continue;
		for(int i = 0; i < 4; ++i) {
			int nxt_h = ph + dh[i];
			int nxt_w = pw + dw[i];
			if(valid(nxt_h, nxt_w) and dist[ph][pw] < dist[nxt_h][nxt_w]) {
				dist[nxt_h][nxt_w] = dist[ph][pw];
				dq.emplace_front(nxt_h, nxt_w, dist[nxt_h][nxt_w]);
			}
		}
		for(int i = -2; i <= 2; ++i) {
			for(int j = -2; j <= 2; ++j) {
				int nxt_h = ph + i;
				int nxt_w = pw + j;
				if(valid(nxt_h, nxt_w) and dist[ph][pw] + 1 < dist[nxt_h][nxt_w]) {
					dist[nxt_h][nxt_w] = dist[ph][pw] + 1;
					dq.emplace_back(nxt_h, nxt_w, dist[nxt_h][nxt_w]);
				}
			}
		}
	}
	if(dist[th][tw] == INF) puts("-1");
	else printf("%d\n", dist[th][tw]);
	return 0;
}



Measured memory_bytes: 8708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<string> vs;
const long long INF = 1LL << 58;
const int INT_INF = 1 << 28;
const double PI = acos(-1.0);

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    auto solve = [&](int x, int y, int z) {
        vi a = {x, y, z};
        int i = 0;
        rep(j, N) {
            if (a[i] + '0' == S[j]) i++;
            if (i == 3) return true;
        }
        return false;
    };
    int ans = 0;
    rep(i, 10) {
        rep(j, 10) {
            rep(k, 10) {
                if (solve(i, j, k)) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
def comb_mod(n,r):
    mod = 10**9+7
    ans = 1
    for i in range(r):
        ans *= n-i
        ans %= mod
    for i in range(1,r+1):
        ans *= pow(i,-1,mod)
        ans %= mod
    return ans

def solve():
    n, a, b = map(int, input().split())
    mod = 10**9+7
    ans = pow(2,n,mod)-comb_mod(n,a)-comb_mod(n,b)-1
    ans %= mod
    return ans
print(solve())

Measured memory_bytes: 9188
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, M;
  cin >> N >> M;
  vec<pair<ll, ll>> X(N);
  REP(i, N) cin >> X[i].first >> X[i].second;
  sort(ALL(X));
  ll res = 0;
  for (ll i = 0, cans = 0; cans < M; i++) {
    const auto tmp = cans;
    cans = min(M, cans + X[i].second);
    res += (cans - tmp) * X[i].first;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4752
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
ll n,m;
ll check(double u)
{
	int i; ll s=0;
	double a;
	for(i=0;i<n;i++)
	{
		a=d[i]/u;
		s+=ceil(a)-1;
	}
	if(s<=m) return 1;
	else return 0;
}
int main()
{
   ll i,j,t,a,b,c,p,k,kk; 
    cin>>n>>m;
    double l,r,mid;
    for(i=0;i<n;i++)
    {
    	scanf("%lld",&d[i]);
	}
    l=0; r=1000000000+5.0;
    while(l+1e-6<=r)
    {
    	 mid=(l+r)/2;
    	if(check(mid)) r=mid;
    	else l=mid;
	}
	cout<<(ll)ceil(l)<<endl;
	
} 

Measured memory_bytes: 5360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ab=gcd(a,b);
  if(c==0){
    if(ab>1){
      cout << "YES" << endl;      
    }
    else{
      cout << "NO" << endl;
    }
  }
  else{
    if(ab==1) cout << "YES" << endl;
    else if(gcd(ab,c)>1){
      cout << "YES" << endl;
    }else {
      cout << "NO" << endl;
    }
  }

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define this-> tt
#define long long ll
using namespace std;
int main ()
{
int k,a,b,c;
string s="NG";
cin>>k>>a>>b;
for (int i=0;i<1000;i++)
{
    c=k*i;
    if (c>=a&&c<=b)
    {
      s="OK";
        break;
    }
}
cout<<s<<endl;
    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

//gcd
template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    ll a, b; cin >> a >> b;
    ll l = a / gcd(a, b) * b;
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int n,y;
  cin >> n >> y;
  int a[3];
  a[0]=a[1]=a[2]=0;

  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      a[0]=i;a[1]=j;a[2]=n-i-j;
      if(a[2]<0) continue;
      if(a[0]*10000+a[1]*5000+a[2]*1000 == y){
        cout << a[0] << " " << a[1] << " " << a[2] << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
int n;
int ans;

using namespace std;

int main()
{
	scanf("%d",&n);
	
	while(n)
	{
		if(n%10==2)
		{
			ans++;
		}
		n/=10;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;


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

for(int i =0;i<a.length;i++){
  a[i] = sc.nextInt();
}

Arrays.sort(a);


  System.out.println(a[0]+" "+a[1]+" "+a[2]);



}


}


Measured memory_bytes: 26164
use std::collections::hash_map;
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
/// input macro from https://qiita.com/tanakh/items/1ba42c7ca36cd29d0ac8
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input!(n: usize, l: [u64; n]);

    let mut hm = hash_map::HashMap::new();
    for li in l {
        let counter: &mut u64 = hm.entry(li).or_insert(0);
        *counter += 1;
    }

    let mut key_vec = Vec::new();
    for &k in hm.keys() {
        key_vec.push(k);
    }
    let mut value_vec = Vec::new();
    for &v in hm.values() {
        value_vec.push(v);
    }

    let mut counter: u64 = 0;

    let length = value_vec.len();
    for i in 0..length {
        for j in (i + 1)..length {
            for k in (j + 1)..length {
                // スーパー愚直
                if (key_vec[i] + key_vec[j] > key_vec[k])
                    && (key_vec[i] + key_vec[k] > key_vec[j])
                    && (key_vec[j] + key_vec[k] > key_vec[i])
                {
                    counter += value_vec[i] * value_vec[j] * value_vec[k];
                }
            }
        }
    }

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


Measured memory_bytes: 2204
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long M, long long D){
  long long ans = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < D; j++) {
      if (((j+1)/10 < 2) || ((j+1)%10 < 2)) {
        continue;
      }
      if (i+1 == ((j+1)%10)*((j+1)/10)) {
        ans++;
      }
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long M;
  scanf("%lld",&M);
  long long D;
  scanf("%lld",&D);
  solve(M, D);
  return 0;
}


Measured memory_bytes: 384
S = input()
T = input()

ans = 9999999999999999999
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

struct point{
    int t;
    int x;
    int y;
};

int main() {
    int n; cin >> n;
    vector<point> v;
    rep(i,n){
        int t,x,y; cin >> t >> x >> y;
        v.push_back({t,x,y});
    }
    v.insert(v.begin(),{0,0,0});
    bool flag = true;
    int nt,xy;
    for(int i = 1; i<n+1; i++){
        nt = v[i].t - v[i-1].t;
        int prexy = v[i-1].x + v[i-1].y;
        xy = abs(v[i].x + v[i].y - prexy);
        if(nt<xy) {
            flag = false;
            break;
        }else{
            if(nt%2==0 && xy%2!=0){
                flag = false;
                break;
            }else if(nt%2!=0 && xy%2==0){
                flag = false;
                break;
            }
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C;
bool poor = 0;
cin >> A >> B >> C;
if((A == B) || (B == C) || (C == A) ){
  poor = 1;
}
if((A == B) && (B == C) && (C == A) ){
  poor = 0;
}
if(poor){
  cout << "Yes" << endl;
}
else{
  cout << "No" << endl;
}

}


Measured memory_bytes: 256
require 'prime'

#約数一覧
def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

N, M = gets.chomp.split(" ").map(&:to_i)

ans = 0
divisors(M).reverse.each{|pr|
  (ans = pr; break) if M / pr >= N
}

puts ans


Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	double x1, y1, x2, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	double answer = 0;

	answer = sqrt(pow((x2 - x1), 2.0) + pow((y2 - y1), 2.0));

	cout << fixed << setprecision(8) <<answer << endl;

}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m>>n)

    {
        i=m+n;
        j=m-n;
        k=m*n;
        cout<<max(i,max(j,k))<<endl;

    }
    return 0;
}

Measured memory_bytes: 3656
#include <climits>
#include <iostream>

using namespace std;

const int CMIN = 0;
const int CMAX = 10000;
const int MIN = -1000000;
const int MAX = 1000000;

bool isRange(double v)
{
    if ((MIN <= v) && (v <= MAX))
    {
        return true;
    }
    return false;
}

int Max(int v1,int v2)
{
    if(v1 > v2)
    {
        return (v1);
    }
    else
    {
        return (v2);
    }
}

int Min(int v1,int v2)
{
    if(v1 < v2)
    {
        return (v1);
    }
    else
    {
        return (v2);
    }
}

int main()
{
    int num, in, max = -INT_MAX, min = INT_MAX;
    long sum;
    sum = 0;
    cin >> num;
    for(int i = 0; i < num; i++)
    {
        cin >> in;
        max = Max(max,in);
        min = Min(min,in);
        sum += in;
    }
    cout << min << " " << max << " " << sum << endl;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int slime = 1;
  for (int i = 0; i < s.size() - 1; i++){
    if (s[i] != s[i+1]) slime++;
  }
  
  cout << slime << endl;
}

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

int main() {
  int H, W;

  cin >> H >> W;

  vector<string> vec(H);

  for (int i = 0; i < H; i++) {
    cin >> vec.at(i);
  }

  cout << "#";
  for (int j = 0; j < W; j++) {
    cout << "#";
  }
  cout << "#" << endl;

  for (int i = 0; i < H; i++) {
    cout << "#";
    cout << vec.at(i);
    cout << "#" << endl;
  }

  cout << "#";
  for (int j = 0; j < W; j++) {
    cout << "#";
  }
  cout << "#" << endl;

}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {
	public static void main(String[] args) {
		int a=0,b=0,c=0;
		String s=null;
		InputStreamReader isr=new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try{
			s=br.readLine();
			StringTokenizer st=new StringTokenizer(s," ");
			a=Integer.parseInt(st.nextToken());
			b=Integer.parseInt(st.nextToken());
			c=Integer.parseInt(st.nextToken());
		}catch(IOException e){
			e.printStackTrace();
		}
		
		if(a<b&&b<c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
		
	}

}



Measured memory_bytes: 24312
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e6 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int k , n ; 
    cin >> k >> n ; 
    vector<int> v(n) ; 
    for(int i = 0; i < n; i++){
        cin >> v[i] ; 
    }
    int ans = v[n - 1] - v[0] ; 
    for(int i = 0; i < n - 1; i++){
        ans = min(ans, ( (v[i] - v[i + 1]) % k + k ) % k) ; 
    }
    cout << ans << endl;
    return 0 ;
}

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

#define X first
#define Y second
#define ll long long
#define MP make_pair
#define PB push_back

using namespace std;

ll MOD=1e9+7;
ll n,k;
ll niz[105];
ll dp[105][100005];
ll ps[100005];
ll br;
ll pom;

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

	cin>>n>>k;
	for(int i=0; i<n; i++){
		cin>>niz[i];
	}
	niz[n]=3;
	ps[k+1]=1;
	ps[max(pom,k-niz[0])]=-1;
	for(int i=0; i<n; i++){
		br=0;
		for(int j=k+1; j>=0; j--){
			dp[i][j]=br;
			dp[i][j]%=MOD;
			br+=ps[j];
	//		cout<<i<<" "<<j<<" "<<dp[i][j]<<" "<<ps[j]<<"\n";
		}
		for(int j=k+1; j>=0; j--){
			ps[j]=0;
		}
		for(int j=k; j>=0; j--){
			ps[j+1]+=dp[i][j];
			ps[max(pom,j-niz[i+1])]+=-dp[i][j];
	//		cout<<j-niz[i+1]<<"\n";
		}
	}
	cout<<dp[n-1][0];
	
	return 0;
}

Measured memory_bytes: 82524