akhauriyash/Code-Regression huggingface dataset:
"""
https://atcoder.jp/contests/abc127/submissions/5606400
"""


def inv(x):
    return pow(x, MOD - 2, MOD)


def cmb(n, r):
    r = min(r, n - r)
    if r == 0:
        return 1
    if r == 1:
        return n

    f = 1
    for k in range(n, n - r, -1):
        f = (f * k) % MOD
        # n!/(n-r)!

    d = 1
    for k in range(2, r + 1):
        d = (d * k) % MOD
        # r!

    return (f * inv(d)) % MOD


MOD = 10 ** 9 + 7

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

ans = 0

for i in range(M):
    ans += i * (M - i) * N ** 2

for i in range(N):
    ans += i * (N - i) * M ** 2

pat = cmb(N * M - 2, K - 2)
ans = (ans * pat) % MOD

print(ans)


Measured memory_bytes: 3064
fun main(arr: Array<String>) {
    val n = readLine()!!
    if(n.length == 1) {
        println(n)
        return
    }
    if(n.all { it == '9' }) {
        println(9*n.length)
        return
    }
    if(n.drop(1).all { it == '9' }) {
        println(n.map { it.toString().toInt() }.sum())
        return
    }
    val tmp = 9 * (n.length-1) + (n[0].toString().toInt() - 1)
    println(tmp)
}



Measured memory_bytes: 36528
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int A = 0;
		int B = 0;
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int[] b = new int[N];
		for (int i = 0; i < N; i++) {
			b[i] = a[N - i - 1];
		}
		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				A += b[i];
			} else {
				B += b[i];
			}
		}
		System.out.println(A - B);
		sc.close();

	}

}

Measured memory_bytes: 21204
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, m; cin >> n >> m;
  const ll MAX = 100105;
  vector<bool> r(MAX, false); r[1] = true;
  vector<int> b(MAX, 1);
  rep(i, m) {
    ll x, y; cin >> x >> y;
    b[x]--;
    b[y]++;
    if (r[x]) r[y] = true;
    if (b[x] == 0) r[x] = false;
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++)
    if (r[i]) ans++;
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int n;
vector<string> A;
vector<char> B = {'3', '5', '7'};
vector<int> C;

void f(int rightRestB, string s){
    vector<bool> F(3, false);
    for(int i = 0; i < s.length(); i++){
        for(int j = 0; j < min(3, (int)s.size()); j++){
            if(s[i] == B[j]){
                F[j] = true;
            }
        }
    }
    if(count(F.begin(), F.end(), true) == 3){
        A.push_back(s);
    }
    if(rightRestB == to_string(n).length()){
        return;
    }
    for(int i = 0; i < 3; i++){
        f(rightRestB + 1, s + B[i]);
    }
    return;
}

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

    cin >> n;

    f(0, "");

    for(auto &x : A){
        C.push_back(stoi(x));
    }

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

    int ans = 0;
    for(auto &x : C){
        if(x <= n){
            ans++;
        }else{
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x,y;
    cin >> x >> y;
    if(abs(x-y) <= 1 ){
      cout << "Brown" << "\n";
    }else
    cout << "Alice" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = 998244353;
const ll MAX_N = 100010;
typedef pair<ll,ll> P;

int main() {
    cin>>K>>N;
    rep(i,2*K-1){
        cout<<N-K+1+i<<' ';
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
double x1,x2,x3,Y1,Y2,Y3;
double dist(double x,double y,double s,double t){
    return  sqrt(pow(x-s,2)+pow(y-t,2));
}
bool f(double x){
    double a=dist(x2,Y2,x3,Y3);
    double b=dist(x1,Y1,x3,Y3);
    double c=dist(x1,Y1,x2,Y2);
    
    double X=(a*x1+b*x2+c*x3)/(a+b+c);
    double Y=(a*Y1+b*Y2+c*Y3)/(a+b+c);
    
    double S=abs((x1-x3)*(Y2-Y3)-(x2-x3)*(Y1-Y3))/2;
    double d=(2*S)/(a+b+c);
    
    if(d<x) return false;
    
    double p1=((d-x)*x1+x*X)/d;
    double q1=((d-x)*Y1+x*Y)/d;
    double p2=((d-x)*x2+x*X)/d;
    double q2=((d-x)*Y2+x*Y)/d;
    double p3=((d-x)*x3+x*X)/d;
    double q3=((d-x)*Y3+x*Y)/d;
    
    
    if(dist(p1,q1,p2,q2)>=2*x) return true;
    if(dist(p1,q1,p3,q3)>=2*x) return true;
    if(dist(p3,q3,p2,q2)>=2*x) return true;
    return false;
}
int main() {
    cin>>x1>>Y1>>x2>>Y2>>x3>>Y3;
    
    double ng = 10000, ok = 0;
    rep(i,0,10000) {
        double mid = (ng + ok) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    
    cout<<fixed<<setprecision(12)<<ok<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
ll a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	re(max(a*c,max(a*d,max(b*c,b*d))))
	return 0;}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>

// =======================================================

using namespace std;

// =======================================================

#define rep(i,n) for(int i=0;i<n;i++)
#define pi 3.14159265358979

// =======================================================

//ライブラリ(*'▽')
int gcd(int a, int b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

int lcm(int a, int b) //最小公倍数
{
	return a * b / gcd(a, b);
}

// =======================================================

int main() {
	string n;
	cin >> n;
	int x = n.size(),ans;
	rep(i, x) {
		ans += n[i] - '0';
	}
	if (ans % 9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3700
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		int flag = 0;
		for(int i=N; i<1000; i++){
			flag = sepNumber(i);
			if(flag == 1){
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}
	public static int sepNumber(int x){
		String s = String.valueOf(x);
		String[] sep = s.split("");
		int tr = 0;
		if(sep[0].equals(sep[1]) && sep[1].equals(sep[2])){
			tr = 1;
		}
		return(tr);
	}
}


Measured memory_bytes: 22612
// Written By NewbieChd
#include <cstdio>
#include <cctype>
#include <algorithm>
#define int long long
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 200003;
int a[maxN], b[maxN], ind[maxN];
inline bool cmp(int x, int y) { return b[x] < b[y]; }

signed main() {
    int n = read(), i, now = 0;
    for (i = 1; i <= n; ++i)
        a[i] = read(), b[i] = read(), ind[i] = i;
    sort(ind + 1, ind + n + 1, cmp);
    for (i = 1; i <= n; ++i)
        if ((now += a[ind[i]]) > b[ind[i]])
            break;
    printf(i > n ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),k=nxtl();
    ll test=0;
    ll mod=1e9+7;
    vector <ll> ans;
    ans.resize(k+1,0);
    for(ll x=k;x>=1;x--)
    {
        ll q=k/x;
        ans[x]=power(q,n,mod);
        for(ll i=2;i<=k;i++)
            if(x*i<=k)
                ans[x]=(ans[x]+mod-ans[x*i])%mod;
            else
                break;
        //cout<<x<<" "<<ans[x]<<endl;

    }
    for(int i=1;i<=k;i++)
        (test+=ans[i]*i)%=mod;
    cout<<test<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 3992
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

# import math
# import numpy as np
# import copy
# from collections import defaultdict, Counter
# from itertools import product
# from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

S = input()
N = len(S)
c0 = S.count("0")
c1 = S.count("1")

print(2*min(c0, c1))


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

int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i+=2)
	{
		int d = 0;
		for (int k = 1; k <= i; k++)
		{
			if (i % k == 0)
				d++;
		}
		if (d == 8)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if(a < b){
        cout << "a < b" << endl;
    }
    else if(a > b){
        cout << "a > b" << endl;
    }
    else{
        cout << "a == b" << endl;
    }
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

void solve(){
	int n, ans = 0; double k;
	cin >> n >> k;
	while(n--){
		double x, y;
		cin >> x >> y;
		ans += (sqrt(x*x + y*y) <= k);
	}
	cout << ans << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3844
#include<iostream>
using namespace std;
int main(){
	int h,w;
	for(;;){
		cin>>h>>w;
		if(h,w==0){
			break;
		}
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if((i+j)%2==0){
				cout<<"#";
				}else{
					cout<<".";
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
#define N 200005
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	if(a>=13)cout<<b;
	else if(a>=6&&a<=12)cout<<b/2;
	else cout<<0;
	re 0;
}


Measured memory_bytes: 256
<?php
while (fscanf(STDIN, "%d", $n)) {
    $ans = 0;
    for ($a = 0; $a < 10; $a++) {
        for ($b = 0; $b < 10; $b++) {
            for ($c = 0; $c < 10; $c++) {
                for ($d = 0; $d < 10; $d++) {
                    if ($a + $b + $c + $d == $n) {
                        $ans++;
                    }
                }
            }
        }
    }
    echo $ans . "\n";
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template <typename P, typename Q>
ostream& operator<<(ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T> v)
{
  os << "(";
  each (i, v)
    os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char* argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<string> v(n);
    each (i, v)
      cin >> i;
    bool f = set<string>(v.begin(), v.end()).size() == n;
    for (int i = 0; i + 1 < n; ++i) {
      f = f && (v[i].back() == v[i + 1].front());
    }
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


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

vector<int> days[31];
int dp[50][50];  //??°???n?????????m????????????????????\: dp[n][m]??¨??????
int n;

bool isEnd(){
    for(int i=0;i<n;i++){
        bool b=true;
        for(int j=0;j<n;j++) if(dp[j][i]==10000) b=false;
        if(b) return true;
    }
    return false;
}

int main(void){
    while(cin>>n,n){
        //?????????
        for(auto& i : days) i.clear();
        fill_n(&dp[0][0],50*50,10000);

        //??\???
        int f,d;
        for(int i=0;i<n;i++){
            cin >> f;
            dp[i][i]=0;
            for(int j=0;j<f;j++){
                cin >> d;
                days[d].push_back(i);//d??\???i????????±?????\????????????????????????
            }
        }
        //DP
        for(int i=1;i<=30;i++){
            for(auto& a : days[i]) for(auto& b : days[i]){
                if(a!=b){
                    for(int k=0;k<n;k++){
                        if(dp[k][b]!=10000) dp[k][a]=min(dp[k][a],i);
                    }
                }
            }
            if(isEnd()){
                cout << i << endl;
                break;
            }else if(i==30){
                cout << -1 << endl;
            }
        }

    }
    return 0;
}

Measured memory_bytes: 2992
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>


int main(int argc, char **argv) {
    int a,b,c,d,e,k;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> d;
    std::cin >> e;
    std::cin >> k;
    if (e - a > k) {
        std::cout << ":(" << std::endl;
    } else {
        std::cout << "Yay!" << std::endl;
    }
    return 0;
}


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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ma = 0;
    ma = max({a*c, a*d, b*c, b*d});
    cout << ma << endl;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if (a + b - 1 > n) {
        cout << -1 << "\n";
        return 0;
    }
    if (a * b < n) {
        cout << -1 << "\n";
        return 0;
    }
    vl arr;
    arr.reserve(n);
    ll val    = 0;
    ll to_add = n - b + 1;
    ll lastb   = 0;
    for (int i = 0; i < to_add; ++i) {
        arr.push_back(val++);
        if (i % a == a - 1) {
            lastb = val - 1;
            val -= 2 * a;
            if (i != a - 1)
            to_add++;
        }
    }
    for (int i = 0; i < n - to_add; ++i) {
        lastb -= a;
        arr.push_back(lastb);
    }
    vl sorted = arr;
    sort(sorted.begin(), sorted.end());
    for (int i = 0; i < n; ++i) {
        cout << 1 + lower_bound(sorted.begin(), sorted.end(), arr[i]) - sorted.begin() << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 6912
x = []
y = []
s = []
while True:
    x1,s1,y1 = map(str,input().split())
    if (s1 == "?") :
        break
    x.append(int(x1))
    y.append(int(y1))
    s.append(s1)

for i in range(len(x)):
    if s[i]=="+":
        print(x[i]+y[i])
    elif s[i]=="-":
        print(x[i]-y[i])
    elif s[i]=="*":
        print(x[i]*y[i])
    elif s[i]=="/":
        print(x[i]//y[i])



Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <math.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int N;
P x[200100];

bool comp(P p, P q){
  if(p.first == q.first)  return p.second < q.second;
  else  return p.first < q.first;
}

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    ll a, b;
    cin >> a >> b;
    x[i].first = min(a, b);
    x[i].second = max(a, b);
  }
  sort(x, x+N, comp);
  ll y_min = 1e9, y_max = 0;
  for(int i = 0; i < N; i++){
    y_min = min(y_min, x[i].second);
    y_max = max(y_max, x[i].second);
  }

  //全体の最大値と最小値がセット。
  ll r = x[N-1].first - x[0].first;
  ll ma = x[N-1].first, mi = 1e9;
  for(int i = 0; i < N-1; i++){
    ma = max(ma, x[i].second);
    mi = min(mi, x[i].second);
    r = min(ma - min(x[i+1].first, mi), r);
    //cout << ma << " " << mi << " " << r << endl;
  }

  //cout << ma << endl;
  //cout << r << endl;
  //全体の最大値と最小値が違うセットも込
  cout << min(r*(y_max - x[0].first), (x[N-1].first - x[0].first)*(y_max - y_min)) << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	int ma = max(a, b);
	ma = max(ma, c);
	cout << a + b + c - ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X,A;
  cin >> X;
  for(int i = 2;i < X;i++) {
    A = X % i;
    if(A == 0) {
      i = 2;
      X++;
    }
    
  }
  cout << X << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
    string s,t;
    cin>>s>>t;
    int value = -1;
    for(int i=0;i<s.size()-t.size()+1;i++){
        bool flag = true;
        for(int j=0;j<t.size();j++){
            if(t[j]==s[i+j]||s[i+j]=='?'){
                continue;
            }
          	else{
                flag = false;
                break;
            }
        }
        if(flag) value = i;
    }
    if(value!=-1){
        for(int i=0;i<t.size();i++){
            s[value+i] = t[i];
        }
        for(int j=0;j<s.size();j++){
            if(s[j]=='?'){
                s[j] = 'a';
            }
        }
        cout<<s<<endl;
    }else{
        cout<<"UNRESTORABLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1

const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;

int n;
struct node {
    int val;
    int id;
}a[maxn],b[maxn];

bool cmp(node aa,node bb) {
    return aa.val < bb.val;
}

int p[maxn];

int main() {
    while(~scanf("%d",&n)) {
        for(int i = 0 ; i < n ; i++) {
            scanf("%d",&a[i].val);
            a[i].id = i;
        }
        for(int i = 0 ; i < n ; i++) {
            scanf("%d",&b[i].val);
            b[i].id = i;
        }
        sort(a,a+n,cmp);
        sort(b,b+n,cmp);
        bool flag = false;
        for(int i = 0 ; i < n ; i++) {
            if(a[i].val > b[i].val) {
                flag = true;
                break;
            }
        }
        if(flag) printf("No\n");
        else {
            for(int i = 0 ; i < n - 1 ; i++) {
//                cout << a[i+1].val << " " << b[i].val << endl;
                if(a[i+1].val <= b[i].val) {
                    flag = true;
                    break;
                }
            }
//            cout << flag << endl;
            if(flag) printf("Yes\n");
            else {
                memset(p,0,sizeof(p));
                for(int i = 0 ; i < n ; i++) {
                    p[a[i].id] = b[i].id;
                }
                int x = p[0] , len = 1;
                while(x != 0) {
                    x = p[x];
                    len++;
                }
                if(len > n - 1) printf("No\n");
                else printf("Yes\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2176
#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 inf = 1001001001;


int main(){
  int n;
  cin >> n;
  vector<int> p(n), q(n), r(n);;
  rep(i,n) cin >> p[i];
  rep(i,n) {
    cin >> q[i];
    r[i] = q[i];
  }
  sort(r.begin(),r.end());

  int a,b;
  int i = 0;
  do{
    i++;
    if(r == p) a = i;
    if(r == q) b = i;
  }while(next_permutation(r.begin(),r.begin()+n));

  cout << abs(a-b) << endl;
  
}


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

using namespace std;

using ll = long long;
using dd = double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<dd, dd>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<dd>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

template <class T, class V>
istream& operator>>(istream& in, pair<T, V>& pair) {
    return in >> pair.first >> pair.second;
}

template <class T>
istream& operator>>(istream& in, vector<T>& elements) {
    for (size_t i = 0; i < elements.size(); ++i) {
        in >> elements[i];
    }
    return in;
}

template <class Container, class Element>
bool Contains(const Container& container, const Element& element) {
    return container.find(element) != container.end();
}

template <class T>
ostream& operator<<(ostream& out, const vector<T>& elements) {
    for (const T& element : elements) {
        out << element << ' ';
    }
    return out;
}

template <class T, class V>
ostream& operator<<(ostream& out, const pair<T, V>& pair) {
    return out << pair.first << ' ' << pair.second;
}

#define FOR(i,n) for(size_t i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(c) sort((c).begin(), (c).end())
#define SUM(c) accumulate((c).begin(), (c).end(), 0ll)

vector<unordered_set<int>> tree;

void Normalize(vi& result, int cur_sum = 0, int vertex = 0, int parent = -1) {
    for (int child : tree[vertex]) {
        if (child != parent) {
            Normalize(result, cur_sum + result[vertex], child, vertex);
        }
    }
    result[vertex] += cur_sum;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    
    int n, q;
    cin >> n >> q;
    
    tree = vector<unordered_set<int>>(n);
    FOR(i, n - 1) {
        int from, to;
        cin >> from >> to;
        --from; --to;
        tree[from].insert(to);
        tree[to].insert(from);
    }
    
    vi p(q), x(q);
    FOR(i, q) {
        cin >> p[i] >> x[i];
        --p[i];
    }
    
    vi result(n);
    FOR(i, q) {
        result[p[i]] += x[i];
    }
    
    Normalize(result);
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 50048
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string s;cin >> s;
    deque<char> q;
    
    rep(i,s.size()){
        char c = s[i];
        q.push_back(c);
    }

    int ct = 0;

    while(!q.empty()){
        char f = q.front();
        char b = q.back();


        if(f == b){
            q.pop_front();
            if(q.empty())break;
            q.pop_back();
            continue;
        }
        
        if(f == 'x'){
            q.push_back('x');
            ct++;
            continue;
        }

        if(b == 'x'){
            q.push_front('x');
            ct++;
            continue;
        }

        if(f != b){
            ct = -1;
            break;
        }
    }

    cout << ct << endl;

}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	char s[10],t[10],u[10];
	int a,b;

	scanf("%s %s\n",s,t);
	scanf("%d %d\n",&a,&b);
	scanf("%s",u);

	if(!strcmp(s,u)){
		printf("%d %d",a-1,b);
	}else{
		printf("%d %d",a,b-1);
	}
	return 0;
}


Measured memory_bytes: 128
N = int(input())
a_list = list(map(int, input().split()))
b_list = [int(a % 2) for a in a_list]
zero_list = [0 for a in a_list]
i = 0
while zero_list == b_list:
    a_list = [int(a / 2) for a in a_list]
    b_list = [int(a % 2) for a in a_list]
    i += 1
print(i)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int p,q,r;
    cin>>p>>q>>r;
    cout<<min({p+q,q+r,p+r})<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int m = sc.nextInt(), f = sc.nextInt(), r = sc.nextInt();
                if(m == -1 && f == -1 && r == -1){
                    break;
                }
                if(m == -1 || f == -1){
                    System.out.println("F");
                }else if(m + f >= 80){
                    System.out.println("A");
                }else if(m + f >= 65){
                    System.out.println("B");
                }else if(m + f >= 50){
                    System.out.println("C");
                }else if(m + f >= 30){
                    if(r >= 50){
                        System.out.println("C");
                    }else{
                        System.out.println("D");
                    }
                }else{
                    System.out.println("F");
                }
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin >> a >> b >> c;
    cout << max({a,b,c})-min({a,b,c}) << "\n";

    return 0;
}

Measured memory_bytes: 3660
use proconio::input;
use proconio::fastout;

#[fastout]
fn main() {
    input! {
        a: usize,
        mut b: usize,
        mut c: usize,
        k: usize,
    }

    let mut count = 0;
    while b <= a {
        b *= 2;
        count += 1;
    }
    while c <= b {
        c *= 2;
        count += 1;
    }

    if count <= k {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 2156
#include<stdio.h>

int A[2001];
int main(void)
{
	int i,j,n,q,m;
	A[0]=1;
	int a;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		
		for(j=2000;j>=0;j--)
		{
			if(A[j]&&j+a<=2000)
			{
				A[j+a]=1;
			}
		}
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&m);
		if(A[m])
		{
			printf("yes\n");
		}
		else
		{
			printf("no\n");
		}
	}
	return 0;
}


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

int main() {
  int n;cin>>n;
  vector<int> x(n),y(n),vec(n);
  rep(i,n){
    cin>>x[i]>>y[i];
    vec[i]=i;
  }
  double ans=0;int cnt=0;
  do{
    rep(i,n-1){
      double dx=x[vec[i]]-x[vec[i+1]],dy=y[vec[i]]-y[vec[i+1]];
      ans+=sqrt(dx*dx+dy*dy);
    }
    cnt++;
  }while(next_permutation(all(vec)));
  ans/=cnt;
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3772
#!/usr/bin/env python3
import sys
import heapq
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def solve(N: int, x: "List[int]", y: "List[int]"):
    xy = []
    edges = [] # cost,node1,node2

    append = xy.append
    for i in range(N):
        append((i,x[i],y[i]))

    x_xy = sorted(xy, key= lambda x:x[1])
    y_xy = sorted(xy, key= lambda x:x[2])

    append = edges.append
    for i in range(N-1):
        cur = x_xy[i]
        next = x_xy[i+1]
        append((next[1]-cur[1],next[0],cur[0]))
        cur = y_xy[i]
        next = y_xy[i+1]
        append((next[2]-cur[2],next[0],cur[0]))

    edges.sort(key= lambda x: x[0])
    uf = UnionFind(N)
    answer = 0

    for cost,node1,node2 in edges:
        if uf.same(node1,node2):
            continue

        answer += cost
        uf.union(node1,node2)
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 49716
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int a,b,c;
 	cin>>a>>b>>c;
 	if(a==b&&b==c)
 		cout<<"No"<<endl;
 	else if(a==b||b==c||c==a)
 		cout<<"Yes"<<endl;
 	else
	 	cout<<"No"<<endl;	
 	
 	return 0;
}
 	
 					

Measured memory_bytes: 3552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20200719AtCorder
{
    class Class1
    {
        static void Main(string[] args)
        {
            int inpnumofacoin = int.Parse(Console.ReadLine());
            int inpnumofbcoin = int.Parse(Console.ReadLine());
            int inpnumofccoin = int.Parse(Console.ReadLine());
            int amountx = int.Parse(Console.ReadLine());
            int anscount = 0;

            for (var i = 0; i <= inpnumofacoin; i++)
            {
                for (var j = 0; j <= inpnumofbcoin; j++)
                {
                    for (var k = 0; k <= inpnumofccoin; k++)
                    {
                        var total = i * 500 + j * 100 + k * 50;
                        if (total == amountx) anscount++;
                    }
                }
            }
            Console.WriteLine(anscount);
        }
    }
}

Measured memory_bytes: 27444
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> PYN(M, vector<int>(3));
    for(int i = 0; i < M; i++){
        cin >> PYN[i][0] >> PYN[i][1];
        PYN[i][2] = i + 1;
    }
    sort(all(PYN));
    vector<int> X(M);
    X[0] = 1;
    int x = 1;
    for(int i = 1; i < M; i++){
        if(PYN[i - 1][0] != PYN[i][0]) x = 1;
        else x++;
        X[i] = x;
    }
    vector<vector<int>> NPX(M, vector<int>(3));
    for(int i = 0; i < M; i++){
        NPX[i][0] = PYN[i][2];
        NPX[i][1] = PYN[i][0];
        NPX[i][2] = X[i];
    }
    sort(all(NPX));
    for(auto v : NPX){
        printf("%06d", v[1]);
        printf("%06d\n", v[2]);
    }
}

Measured memory_bytes: 14616
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)



priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


void solve(){
    int n;
    cin >> n;
    vector<int>L(n);
    rep(i,0,n)cin >> L[i];
    sort(L);
    int ans=0;
    rep(i,0,n-2){
        rep(j,i+1,n-1){
            rep(k,j+1,n){
                if(L[i]==L[j])continue;
                if(L[j]==L[k])continue;
                if(L[i]==L[k])continue;
                if(L[i]+L[j]>L[k])ans++;
            }
        }
    }
    cout << ans << endl;
}

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





Measured memory_bytes: 3652
from collections import defaultdict
S = input()
N = len(S)

DP=[0]*(N+1)
for i,s in enumerate(reversed(S)):
    DP[i+1]=(DP[i]+pow(10,i,2019)*int(s))%2019

D=defaultdict(int)
for dp in DP:
    D[dp]+=1

ans=0
for dp in D.values():
    ans += dp*(dp-1)//2

print(ans)


Measured memory_bytes: 16504
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var answer = "No";
            if (N % 2 == 0)
            {
                var a = S.Substring(0, N / 2);
                var b = S.Substring(N / 2, N / 2);
                if (a == b)
                {
                    answer = "Yes";
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

template <typename T>
using ordered_set =tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define watch(x) cout << "debug : " << #x << " -> " << x << endl; 

//globals
ll const mod = 1e9+7;
ll const size_1d = 1e6 + 7;
ll const size_2d = 1e3 + 7;

//functions
ll power(ll x, ll y, ll mod = 2e18){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;} 
ll gcdext(ll a,ll b,ll *x = 0, ll *y = 0){if(a == 0){*x = 0;*y = 1;return b;}ll x1,y1;ll gcd1 = gcdext(b%a,a,&x1,&y1);*x = y1 - (b/a)*x1;*y = x1;return gcd1;}
int randomize(){return (rand()%10000);} 

// CODE STARTS HERE

int main() {
  IOS;

  int a,b,c;cin >> a >> b >> c;
  int k = a - b;
  cout << c - min(k,c) << endl;

  return 0;
}

Measured memory_bytes: 256
S = input()
Q = int(input())

# print(S, Q)

queries = []
for i in range(Q):
    query = input()
    queries.append(query)

from collections import deque
slist = deque(list(S))
isReversed = False
for query in queries:
    if query == "1":
        isReversed = not isReversed
    else:
        t, f, c = query.split()
        if f == '1':
            if isReversed:
                slist.append(c)
            else:
                slist.appendleft(c)
        else:
            if isReversed:
                slist.appendleft(c)
            else:
                slist.append(c)

if isReversed:
    slist.reverse()
print(''.join(slist))


Measured memory_bytes: 21352
from bisect import bisect
q=int(input())
lr=[list(map(int,input().split())) for i in range(q)]
lst=[]
for i in  range(2,10**5):
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            break
    else:
          lst.append(i)
li=[]
data=[0]*(10**5)
for i in range(1,len(lst)):
    u=lst[i]
    v=(u+1)//2
    a=bisect(lst,v)
    if v==lst[a-1]:
        data[u]=1
for i in range(1,10**5):
    data[i]=data[i]+data[i-1]
for i in range(q):
    l,r=lr[i]
    print(data[r]-data[l-1])



Measured memory_bytes: 70360
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (ll i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+2);
    a[0] = INF;
    rep(i, n) cin >> a[i+1];
    a[n+1] = 0;
    ll x = 1000;
    ll num = 0;
    rep(i, n+1) {
        if (i==0) continue;
        if (a[i]==a[i-1] && a[i]==a[i+1]) continue;
        if (a[i]<=a[i+1]) {
            ll tmp = x/a[i];
            num += tmp;
            x -= a[i]*tmp;
        }
        else if (a[i]>=a[i+1]) {
            x += a[i]*num;
            num = 0;
        }
    }

    
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(1000000)


def dfs(v):
    if cache[v] > -1:
        return cache[v]
    lv = links[v]
    cache[v] = ret = max(map(dfs, lv)) + 1 if lv else 0
    return ret


n, m = map(int, input().split())
sss = set(range(n))
links = [set() for _ in range(n)]
cache = [-1] * n
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    sss.discard(y)
    links[x].add(y)

print(max(map(dfs, sss)))


Measured memory_bytes: 238820
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(auto &x:v)
    {
        cin>>x;
    }
    vector<ll> left(n);
    vector<ll> right(n);
    left[0]=v[0];
    for(ll i=1;i<n;i++)
    {
        left[i] = max(v[i],left[i-1]);
    }
    right[n-1] = v[n-1];
    for(ll i=n-2;i>=0;i--)
    {
        right[i] = max(right[i+1],v[i]);
    }
    for(ll i=0;i<n;i++)
    {
        if(i==0)
        {
            cout<<right[i+1]<<endl;
        }
        else if(i==n-1)
        {
            cout<<left[i-1]<<endl;
        }
        else
        {
            cout<<max(left[i-1],right[i+1])<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 6272
using System;

class Program
{
    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        int n = int.Parse(array[0]);
        int m = int.Parse(array[1]);
        int k = int.Parse(array[2]);

        bool[] db = new bool[n * m + 1];
        for (int i = 0; i <= n; i++)
            db[i * m] = true;
        for (int i = 0; i <= m; i++)
            db[i * n] = true;

        for (int i = 1; i <= m / 2; i++)
        {
            for (int j = 1; j < n; j++)
            {
                db[i * n + j * (m - i * 2)] = true;
            }
        }

        for (int i = 1; i <= n / 2; i++)
        {
            for (int j = 1; j < m; j++)
            {
                db[i * m + j * (n - i * 2)] = true;
            }
        }

        if (db[k]) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

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

int x[10][10];
int main() {
	rep(i, 10)rep(j, 10)scanf("%d", &x[i][j]);
	int cnt = 0;
	rep(a, 10)rep(b, 10)rep(c, 10)rep(d, 10) {
		int e = x[x[x[x[0][a]][b]][c]][d];
		int k[]{ a,b,c,d,e };
		rep(i, 5) {
			int o = k[i];
			rep(j, 10) {
				if (o == j)continue;
				k[i] = j;
				if (x[x[x[x[x[0][k[0]]][k[1]]][k[2]]][k[3]]][k[4]] == 0) {
					cnt++; goto g;
				}
			}
			k[i] = o;
		}
		rep(i, 4) {
			if (k[i] == k[i + 1])continue;
			swap(k[i], k[i + 1]);
			if (x[x[x[x[x[0][k[0]]][k[1]]][k[2]]][k[3]]][k[4]] == 0) {
				cnt++; goto g;
			}
			swap(k[i], k[i + 1]);
		}
	g:;
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 3240
<?php
$n=trim(fgets(STDIN));
if($n<3){
  echo 0;
  exit;
}
$l=explode(" ",trim(fgets(STDIN)));
$m=array_count_values($l);
$c=count($m);
if($c<3){
  echo 0;
  exit;
}
sort($l);
$ans=0;
$i=0;
$r=1;
$s=1;
while($i<$n-2){
  $j=$i+1;
  while($l[$j]==$l[$i]){
    ++$r;
    ++$j;
  }
  while($j<$n-1){
    $k=$j+1;
    while($l[$k]==$l[$j]){
      ++$s;
      ++$k;
    }
    while($k<$n){
      if($l[$k]<$l[$j]+$l[$i]){
        $ans+=$r*$s;
      }else{
        break;
      }
      ++$k;
    }
    $j+=$s;
    $s=1;
  }
  $i+=$r;
  $r=1;
}
echo $ans;

Measured memory_bytes: 16188