akhauriyash/Code-Regression huggingface dataset:
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll inf=1e18;
const ld pai=acos(-1);
ll n,MX=1e4+1;
ll a[1009];
ll w[1009],s[1009],v[1009];
ll dp[1009][10009];
bool cmp(ll a,ll b){
	return w[a]+s[a]<w[b]+s[b];
}
ll bt(ll id,ll crnt){
	crnt=min(crnt,MX);
	if(id==n)return 0;
	ll &ret=dp[id][crnt];
	if(ret!=-1)return ret;
	ret=0;
	ret=max(ret,bt(id+1,crnt));
	if(s[a[id]]>=crnt)ret=max(ret,bt(id+1,crnt+w[a[id]])+v[a[id]]);
	return ret;
}
int main(){
	mem(dp,-1);
	cin>>n;
	for(ll i=0;i<n;i++){
		a[i]=i;
		cin>>w[i]>>s[i]>>v[i];
	}
	sort(a,a+n,cmp);
	cout<<bt(0,0)<<endl;
}


Measured memory_bytes: 79232
// https://atcoder.jp/contests/abc162/tasks/abc162_c

#include <iostream>
using namespace std;

int gcd(int a, int b){
	if(b==0) return a;
	return gcd(b, a%b);
}

int gcd(int a, int b, int c){
	return gcd(gcd(a, b), c);
}

int main(){
	int k, a, b, c, r, g;
	cin >> k;
	r = 0;
	for(a=1; a<=k; ++a){
		for(b=1; b<=k; ++b){
			g = gcd(a, b);
			if(g==1) r += k;
			else{
				for(c=1; c<=k; ++c){
					r += gcd(g, c);
				}
			}
		}
	}
	cout << r << endl;
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
bool cmp(pair<int,int>v1,pair<int,int>v2){
    return v1.second <v2.second;
}

int main(){

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

    vector<pair<int,int>>gate;
    rep(i,m){
        int l,r;
        cin>>l>>r;
        gate.emplace_back(make_pair(l,r));
    }

    sort(gate.begin(),gate.end(),cmp);

    int left=-1,right=gate[0].second;
    int ans;
    rep(i,m){
        if(right<gate[i].first){
            //right=left-1;
            ans=0;
            break;
        }
        else{
            left=max(left,gate[i].first);
        }
        ans=right-left+1;
        
    }

    cout<<ans<<endl;
}
/*


*/


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr int INF=1e9;
int b[1252][1252];
int idx[1252];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, a[1252][1252];
	cin>>n;
	REP(i, n)REP(j, n-1){
		cin>>a[i][j];
		--a[i][j];
	}
	REP(i, n)FOR(j, 1, n){
		b[i][j]=INF;
	}
	queue<pii> q;
	REP(i, n-1){
		int t=a[i][0];
		if(i==a[t][0] && i<t){
			q.push(pii(i, t));
			++idx[i];
			++idx[t];
		}
	}
	while(q.size()){
		auto x=q.front();
		q.pop();
		int y=x.first;
		// DEBUG(y);
		if(idx[y]<n-1 && b[y][idx[y]]==INF){
			int t=a[y][idx[y]];
			if(y==a[t][idx[t]]){
				// DEBUG(t);
				q.push(pii(y, t));
				b[y][idx[y]]=b[t][idx[t]]=max(b[y][idx[y]-1], b[t][idx[t]-1])+1;
				// DEBUG(b[y][idx[y]]);
				++idx[y];
				++idx[t];
			}
		}
		y=x.second;
		// DEBUG(y);
		if(idx[y]<n-1 && b[y][idx[y]]==INF){
			int t=a[y][idx[y]];
			if(y==a[t][idx[t]]){
				// DEBUG(t);
				q.push(pii(y, t));
				b[y][idx[y]]=b[t][idx[t]]=max(b[y][idx[y]-1], b[t][idx[t]-1])+1;
				// DEBUG(b[y][idx[y]]);
				++idx[y];
				++idx[t];
			}
		}
	}
	int ans=0;
	REP(i, n){
		CHMAX(ans, b[i][n-2]);
	}
	cout<<(ans!=INF ? ans+1 : -1)<<'\n';
	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll double 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
bool isPalindrome(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.size() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return false; 
        } 
    } 
    return true;
}
ll maxvolume(ll s) 
{
    ll length = s / 3; 
    s -= length; 
    ll breadth = s / 2; 
    ll height = s - breadth; 
    return (double)length * breadth * height; 
} 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
    ll l;
    cin>>l;
    cout << fixed << setprecision(9) <<(double)maxvolume(l)<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 1 << 19 | 5;
typedef long long ll;
int n, a[N], G = 2, P = 200003, b[N];
int ksm(int a, int b, int p){
	int ans = 1; for(;b;b>>=1,a=1ll*a*a%P)
	if(b&1) ans=1ll*ans*a%P; return ans;
}
int fnd(int P){
	vector<int> fc;
	for(int i = 2; i * i < P; i++)
		if((P - 1) % i == 0) fc.pb(i), fc.pb((P - 1) / i);
	for(int i = 2; ; i++){
		bool ok = 1;
		for(int z : fc) if(ksm(i, z, P) == 1) {
			ok = false; break;
		} if(ok) return i;
	}
}
cs double PI = acos(-1.0);
struct cp{
	double x, y; cp(double _x = 0, double _y = 0){ x = _x, y = _y; }
	cp operator + (cs cp &a){ return cp(x + a.x, y + a.y); }
	cp operator - (cs cp &a){ return cp(x - a.x, y - a.y); }
	cp operator * (cs cp &a){ return cp(x * a.x - y * a.y, x * a.y + y * a.x); }
} c[N];
int up, bit, rv[N];
void init(int d){
	up = 1, bit = 0; while(up < d) up <<= 1, ++bit;
	for(int i = 0; i < up; i++) 
	rv[i] = (rv[i >> 1] >> 1) | ((i & 1) << (bit - 1));
}
void FFT(cp *a, int typ){
	for(int i = 0; i < up; i++) if(i < rv[i]) swap(a[i], a[rv[i]]);
	for(int i = 1; i < up; i <<= 1){
		cp wn(cos(PI / i), typ * sin(PI / i));
		for(int j = 0; j < up; j += (i << 1)){
			cp w(1, 0);
			for(int k = 0; k < i; k++, w = w * wn){
				cp x = a[k + j], y = w * a[k + j + i];
				a[k + j] = x + y, a[k + j + i] = x - y;
			}
		}
	} if(typ == -1){
		for(int i = 0; i < up; i++)
		a[i].x = a[i].x / up;
	}
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d", &n);
	for(int i = 0, mt = 1; i + 1 < P; i++)
		b[mt] = i, mt = 1ll * mt * G % P;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if(a[i]) c[b[a[i]]].x += 1;
	}
	init(P + P); 
	FFT(c, 1);
	for(int i = 0; i < up; i++) c[i] = c[i] * c[i];
	FFT(c, -1); ll ans = 0;
	for(int i = 0; i + 1 < P; i++) c[i].x += c[i + P - 1].x;
	for(int i = 0, mt = 1; i + 1 < P; i++)
		ans += (ll)(c[i].x + 0.49) * mt, mt = 1ll * mt * G % P;
	for(int i = 1; i <= n; i++) ans -= 1ll * a[i] * a[i] % P;
	cout << ans / 2; return 0;
}

Measured memory_bytes: 15844
// √ a + √ b < √ c (1)
// ⇔ ( √ a + √ b) 2 < c (2)
// ⇔ 2 √ ab < c − a − b (3)
// ⇔ c − a − b > 0 ∧ 4ab < (c − a − b) 2 (4)

fn main() {
    let vec_num : Vec<i64> = read_vec();


    if vec_num[0] == vec_num[2] || vec_num[1] == vec_num[2] {
    	println!("{}", "No" );
    	return;
    }

    let a = vec_num[0];
    let b = vec_num[1];
    let c = vec_num[2];
    let d = c - a - b;

    let ans = if d > 0 && 4*a*b < d*d {"Yes"} 
    			else {"No"};

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


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
  int n,h[100005],x[100005],max=0,count=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d",&h[i]);
  }
  for(int i=1;i<=n-1;i++){
    if(h[i+1]<=h[i]){
      count++;
      x[i]=count;
    }else{
      count=0;
      x[i]=count;
    }
  }

  for(int i=1;i<=n-1;i++){
    if(max<x[i]) max=x[i];
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 2468
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
	string S ;
	cin >> S ;
	int n = S.size() ;
    deque<char> que ;
	rep(i,n){
		if( S[i] == '0' || S[i] == '1' ){
		que.push_back(S[i]) ;
        }
        else{
        if(que.empty()) continue ;
        else que.pop_back() ;
        }
    }
    //cout << que.size() << endl;
    while(!que.empty()) {
    	cout << que.front() ; // 先頭要素を参照する
    	que.pop_front();
  }
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

ll gcd(ll x,ll y){
    x = x%y;
    return x == 0 ? y : gcd(y,x);
}
ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}



int main(){
 
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n){
        cin >> l[i];
    }
    ll ans=0;
    rep(i,n){
        for(int j = i;j < n;++j){
            for(int k = j;k < n;++k){
                if(i == j || j == k || i == k) continue;
                if(l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) continue;
                if(l[i]+l[j] > l[k] && l[j]+l[k] > l[i] && l[k]+l[i] > l[j]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 V, E, r;
struct edge {
    u64 v, weight;
    bool operator<(const edge &e) const { return weight > e.weight; }
};

vector<list<edge>> edges;


int main(int argc, char *argv[])
{
    // input from txt （提出時にこの箇所は削除すること）
    //ifstream in("in.txt");
    //cin.rdbuf(in.rdbuf());
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> V >> E >> r;
    edges.resize(E * 2);
    for (u64 i = 0; i < E; i++) {
        u64 from, to , weight;
        cin >> from >> to >> weight;
        edges[from].push_back(edge{to, weight});
        edges[to].push_back(edge{from, Inf});
    }
    vector<u64> dist(V, Inf);
    dist[r] = 0;
    priority_queue<edge> q;
    q.push(edge{r, dist[r]});
    
    while (!q.empty()) {
        edge e1 = q.top(); q.pop();
        if (E == 0) continue;
        if (dist[e1.v] < e1.weight) continue;
        for (auto e2 : edges[e1.v]) {
            if (dist[e2.v] > dist[e1.v] + e2.weight) {
                dist[e2.v] = dist[e1.v] + e2.weight;
                q.push(edge{e2.v, dist[e2.v]});
            }
        }
    }
    
    for (u64 i = 0; i < V; i++) {
        if (dist[i] == Inf) {
            cout << "INF" << endl;
        } else cout << dist[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 66868
#include<stdio.h>

int gcd (int a,int b) 
{
    if (b==0) return a;
    else return gcd(b,a%b);
}

int main () {
    int k;
    scanf("%d",&k);
    int s=0;
    for (int i=1;i<=k;i++) {
        for (int j=1;j<=k;j++) {
            for (int l=1;l<=k;l++) {
                s+=gcd(gcd(i,j),l);
            }
        }
    }
    printf("%d",s);
    return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    for (i = 1; i * i + i < 2 * n; i++)
    {
    }
    for (; n > 0 && i > 0; i--)
    {
        if (i <= n)
        {
            printf("%d\n", i);
            n -= i;
        }
    }
    return 0;
}

Measured memory_bytes: 128
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
int d;
vector < int > P[50];

int sq(int x){
    return x*x;
}

int get(int a , int b){
    int dd = 0;
    for(int i = 0; i < d; i++){
        dd += sq(P[a][i] - P[b][i]);
    }
    for(int i = 0; i < 160; i++){
        if(i*i == dd)
            return 1;
    }
    return 0;
}

int main(){
    cin >> n >> d;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= d; j++){
            int x;
            cin >> x;
            P[i].push_back(x);
        }
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            cnt += get(i , j);
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
class Main{
	public static void main(String[] args){
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int t = sc.nextInt();
		int h = t/3600;
		int m = (t%3600)/60;
		int s = (t%3600)%60;
		System.out.println( h + ":" + m + ":" + s );
	}
}

Measured memory_bytes: 26176
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		//sを正順にソートして、tを逆順にソートする
		Arrays.sort(s);
		Arrays.sort(t);
		t = reverce(t);
		boolean getedAnser = false;
		//sとtの中身が要素数まで全く同じならば、NOを出力
		if(equal(t, s)){
			System.out.println("No");
		}else{
			//要素をはじめから比べて、tが辞書順で上になったらYesを出力する
			for(int i = 0;i < t.length && i < s.length; i++){
				if((int)s[i] < (int)t[i]){
					System.out.println("Yes");
					getedAnser = true;
					break;
				}else if((int)t[i] < (int)s[i]){
					System.out.println("No");
					getedAnser = true;
					break;
				}
			}
	//ここまで要素が一切同じで、どちらかの要素がそれより長い、tのほうがながければ辞書順で上になれる
			if(s.length < t.length && !getedAnser){
				System.out.println("Yes");
			}else if(!getedAnser){
				System.out.println("No");
			}
		}
	}

	public static char[] reverce(char[] c){
		//char並列の中身を逆順にする
		char[] t = new char[c.length];
		for(int i = (c.length - 1);0 <= i; i--){
			t[c.length - i - 1] = c[i];
		}
		return t;
	}

	public static boolean equal(char[] t, char[] s){
		//渡された配列の中身が同じかどうかを判断する。
		//まず要素数が違えばfalseを返す。
		if(t.length == s.length){
			for(int i = 0;i < t.length; i++){
				if(t[i] != s[i]){
					return false;
				}
			}
			return true;
		}else{
			return false;
		}
	}
}


Measured memory_bytes: 23124
#include <stdio.h>

int yakusu(int a, int b) {
	int tmp, r;

	if (a<b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int main() {
	long long int A, B, C, D, bc, bd, bcd, CD, x, y, Bkosu, Akosu, ac, ad, acd;

	scanf("%lld %lld %lld %lld", &A, &B, &C, &D);

	CD = C * D;
	x = yakusu(C, D);
	y = CD / x;

	bc = B / C;
	bd = B / D;
	bcd = B / y;
	Bkosu = B - (bc + bd - bcd);

	ac = (A - 1) / C;
	ad = (A - 1) / D;
	acd = (A - 1) / y;
	Akosu = (A - 1) - (ac + ad - acd);

	printf("%lld", Bkosu - Akosu);

	return 0;
}

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

public class Main {


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

        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int res = 0,cnt = 0;
        boolean flag = false;
        while(n--!=0){
            int a = s.nextInt(),b=s.nextInt();
            if(a==b)cnt++;
            else{
               if(cnt>=3)flag = true;
               cnt = 0;
            }
        }
        if(cnt>=3)flag = true;
        System.out.println(flag?"Yes":"No");


    }


}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25564
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc=new Scanner(System.in);
    	int n=sc.nextInt();
    	boolean can = true;
    	for(int i=0;i<n;i++) {
    		int m =sc.nextInt();
    		if(m%2==0) {
    			if(m%3!=0&&m%5!=0) {
    				can = false;
    			}
    		}
    	}
    	String s = can?"APPROVED":"DENIED";
    	System.out.println(s);
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;
  cin>>S;
  
  int ans=100000;
  
  
  for(int i=0;i<=S.size()-3;i++){
    string res;
    res[0]=S[i];
    res[1]=S[i+1];
    res[2]=S[i+2];
    
    int X=stoi(res);
    
    ans=min(abs(X-753),ans);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
/*
* welcome to my code!
* ------------------------------------------
* author : lynmisakura(twitter : @andoreiji11)
*/

#include<bits/stdc++.h>
using namespace std;

using ll = long long;

#define REP(i,n) for(int i = 0;i < n;i++)
#define all(x) x.begin(),x.end()
#define dup(x,y) (x + y - 1)/y
#define sz(v) (int)v.size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64_t n;cin >> n;
    int64_t a = 0,b = 0,c = 0,d = 0;
    REP(i,n){
        string s;cin >> s;
        if(s == "AC")a++;
        else if(s == "WA")b++;
        else if(s =="TLE")c++;
        else d++;
    }
    cout << "AC x " << a << '\n';
    cout << "WA x " << b << '\n';
    cout << "TLE x " << c << '\n';
    cout << "RE x " << d << '\n';
}


Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	char s[19];
	for(int i=0; i<19; i++)
	{
		scanf("%c",&s[i]);
		if(i==5||i==13)
		    s[i]=' ';
	}  
	for(int i=0; i<19; i++)
	    printf("%c",s[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n;
	cin >> n;
	vector<ll> v(n, 0);
	rep(i, n - 1) {
		ll a;
		cin >> a;
		a--;
		v.at(a)++;
	}
	rep(i, n) {
		cout << v.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 4748
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> set(N+1, 0);
  rep(i, N){
    int a;
    cin >> a;
    set[a]++;
  }
  sort(set.begin(), set.end(), greater<int>());
  int cnt = 0;
  int flag = N;
  rep(i, N){
    if(set[i] != 0){
      cnt++;
    }
    if(cnt == K){
      flag = i;
      break;
    }
  }
  int ans = 0;
  for(int i = flag+1; i < N; i++){
    ans += set[i];
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 1024
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std;
const int N=105; 
int n,m,f[N][N];
char s[N][N];
int main () {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	memset(f,63,sizeof(f));
	if(s[1][1]=='#')f[1][1]=1;else f[1][1]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(i!=1||j!=1)
			{
				if(s[i][j]=='#')
				{
					if(s[i-1][j]=='.')f[i][j]=min(f[i-1][j]+1,f[i][j]);
					if(s[i-1][j]=='#')f[i][j]=min(f[i-1][j],f[i][j]);
					if(s[i][j-1]=='.')f[i][j]=min(f[i][j-1]+1,f[i][j]);
					if(s[i][j-1]=='#')f[i][j]=min(f[i][j-1],f[i][j]);
				}
				else f[i][j]=min(f[i-1][j],f[i][j-1]);
			}
	printf("%d\n",f[n][m]);
    return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int five=0, seven=0;
  rep(i, 3) {
    int a;
    cin >> a;
    if(a == 5) five++;
    else if(a == 7) seven++;
  }
  if(five == 2 && seven == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int n = s.length()-2;
        System.out.print(s.charAt(0));
        System.out.print(n);
        System.out.print(s.charAt(s.length()-1));

    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int h,w;
    cin >> h >> w;
    char x[h][w];
    int cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> x[i][j];
            if(x[i][j] == '#'){
                cnt++;
            }
        }
    }
    if(cnt == h+w-1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 3412
#include<stdio.h>
int main(){
 int x,y,W,H,r;
 
 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 
 if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)
  printf("Yes\n");
 else
  printf("No\n");

 return 0;
}
  

Measured memory_bytes: 584
def main():
  s = input()
  end = len(s)
  ind = 0
  ans = 0
  while ind < end:
    j_num = 0
    o_num = 0
    i_num = 0
    while ind < end and s[ind] != "J":
      ind += 1
    while ind < end and s[ind] == "J":
      j_num += 1
      ind += 1
    while ind < end and s[ind] == "O":
      o_num += 1
      ind += 1
    while ind < end and s[ind] == "I":
      i_num += 1
      ind += 1
    if o_num <= i_num and o_num <= j_num and o_num > ans:
      ans = o_num
  print(ans)
main()


Measured memory_bytes: 7520
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
using namespace std;


typedef pair<int, int> P;
typedef long long ll;

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int sum = a + b + c;
	if(sum >= 22)	cout << "bust" << endl;
	else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, t, e, x[maxn];
long long f[maxn];
struct Seg {
	long long tr[maxn << 2];
	inline void Upd(int o, int l, int r, int p, long long d) {
		if(l == r)
			return tr[o] = d, void();
		int mid = (l + r) >> 1;
		if(p <= mid)
			Upd(o << 1, l, mid, p, d);
		else
			Upd(o << 1 | 1, mid + 1, r, p, d);
		tr[o] = min(tr[o << 1], tr[o << 1 | 1]);
	}
	inline long long Ask(int o, int l, int r, int ql, int qr) {
		if(ql > qr)
			return 1e18;
		if(ql <= l && r <= qr)
			return tr[o];
		int mid = (l + r) >> 1;
		long long ans = 1e18;
		if(ql <= mid)
			ans = min(ans, Ask(o << 1, l, mid, ql, qr));
		if(qr > mid)
			ans = min(ans, Ask(o << 1 | 1, mid + 1, r, ql, qr));
		return ans;
	}
}g, h;
int main() {
	scanf("%d%d%d", &n, &e, &t);
	for(int i = 1; i <= n; ++ i)
		scanf("%d", &x[i]);
	memset(f, 0x3f, sizeof f);
	f[0] = 0, g.Upd(1, 0, n, 0, 0), h.Upd(1, 0, n, 0, - 1ll * 2 * x[1]);
	for(int i = 1; i <= n; ++ i) {
		int p = lower_bound(x, x + i, x[i] - t / 2) - x;
		f[i] = min(g.Ask(1, 0, n, p - 1, i - 1) + t + x[i], h.Ask(1, 0, n, 0, p - 2) + 1ll * 3 * x[i]);
		if(i < n)
			g.Upd(1, 0, n, i, f[i] - x[i]), h.Upd(1, 0, n, i, f[i] - x[i] - 1ll * 2 * x[i + 1]);
		
	}
	printf("%lld\n", f[n] + e - x[n]);

}

Measured memory_bytes: 9116
#include <stdio.h>
#include <string.h>

int main(void){
 
	int i,moji,ccount=0;
	char s[10];
	char ans[] = "AC";
	scanf("%s",s);
	
	for(moji=0; s[moji]!='\0'; moji++);
	
	for(i=0; i<moji; i++){
		if((s[i] == 'B') | (s[i]>='D' && s[i]<='Z') | s[0] != 'A'){
			strcpy(ans,"WA");
		}
	}
	
	for(i=2; i<moji-1; i++){
		if(s[i] == 'C') ccount++;
		if(ccount >= 2){
			strcpy(ans,"WA");
		}
	}
	
	if(ccount == 0){
		strcpy(ans,"WA");
	}
	
	printf("%s\n",ans);
	
    return 0;
}

Measured memory_bytes: 128
import static java.util.Comparator.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

final class Star {
    public final int x;
    public final int y;
    public Star(int x, int y) {
        this.x = x;
        this.y = y;
    }
    public int getX() {
        return x;
    }
    public int getY() {
        return y;
    }

}

class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        Star[] redStars = new Star[n];
        Star[] blueStars = new Star[n];
        for (int i = 0; i < n; i++) {
            redStars[i] = new Star(cin.nextInt(), cin.nextInt());
        }
        for (int i = 0; i < n; i++) {
            blueStars[i] = new Star(cin.nextInt(), cin.nextInt());
        }

        int count = countPair(sortByY(redStars), sortByX(blueStars));

        System.out.println(count);
    }

    static Star[] sortByX(Star[] stars) {
        return Arrays.asList(stars).stream()
                .sorted(comparing(Star::getX))
                .toArray(Star[]::new);
    }

    static Star[] sortByY(Star[] stars) {
        return Arrays.asList(stars).stream()
            .sorted(comparing(Star::getY))
            .toArray(Star[]::new);
    }

    static int countPair(Star[] sortedRedStars, Star[] sortedBlueStars) {
        int count = 0;
        List<Star> sortedRedBuf = new ArrayList<Star>(Arrays.asList(sortedRedStars));
        for (Star blue : sortedBlueStars) {
            Star pairdRed = null;
            for (Star red : sortedRedBuf) {
                if (red.x < blue.x && red.y < blue.y) {
                    pairdRed = red;
                }
            }
            if (pairdRed != null) {
                count++;
                sortedRedBuf.remove(pairdRed);
            }
        }
        return count;
    }
}

Measured memory_bytes: 27476
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

int gay[105],n,ans;

int main(){
	
	cin>>n;
	for(int i=2;i<=n;i++){
		int clo=i;
		for(int j=2;j<=i;j++){
			while(clo%j==0){
				clo/=j;
				gay[j]++;
			}
		}
	}
	for(int i=2;i<=100;i++){
		if(gay[i]>=74)ans++;
	}
	for(int i=2;i<=100;i++){
		for(int j=2;j<=100;j++){
			if(i!=j){
				if(gay[i]>=14&&gay[j]>=4)ans++;
			}
		}
	}
	for(int i=2;i<=100;i++){
		for(int j=2;j<=100;j++){
			if(i!=j){
				if(gay[i]>=24&&gay[j]>=2)ans++;
			}
		}
	}
	for(int i=2;i<=100;i++){
		for(int j=2;j<=100;j++){
			for(int k=2;k<=100;k++){
				if(i!=j && j<k && i!=k){
					if(gay[i]>=2 && gay[j]>=4 && gay[k]>=4)ans++;
				}
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static int calcGCD(int a, int b) {
    if(b > 0) {
      return calcGCD(b, a % b);  
    }   
    else {
      return a;
    }
  }
 
  public static int calcLCM(int a, int b) {
    return ((a / calcGCD(a, b)) * b);
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) { 
      int a = sc.nextInt();
      int b = sc.nextInt();
      int gcd = calcGCD(a, b);      
      int lcm = calcLCM(a, b);
      System.out.println(gcd + " " + lcm);
    }    
  }
}

Measured memory_bytes: 25944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  vector<ll> a;
  for (ll i = 0; i < 2*N; i++) {
    ll x; cin >> x; a.push_back(x);
  }
  sort(a.begin(), a.end());
  ll res = 0;
  for (ll i = 0; i < N; i++) {
    res += a[2*i];
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class BCakesAndDonuts {
public:
	void solve(istream& in, ostream& out) {
        int n; in >> n;
        bool ok = true;
        for(int i = 0;i <= n / 7;i++){
            if((n - 7 * i) % 4 == 0){
                out << "Yes" << endl;
                ok = false;
                break;
            }
        }
        if(ok) out << "No" << endl;
	}
};

int main() {
	BCakesAndDonuts solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	ll n,b,i,j;
	cin>>n>>b;
	cout<<floor(log(n)/log(b))+1<<"\n";
	return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

const ll INF = 1ll<<55;

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<vector<ll>> l(n, vector<ll>(n, INF)), s(n, vector<ll>(n, INF));
        for(int i = 0; i < n; i++)  l[i][i] = s[i][i] = 0;

        for(int i = 0; i < m; i++){
            ll x, y, t;
            string z;
            cin >> x >> y >> t >> z;
            x--, y--;
            if(z == "S"){
                ll to = min(s[x][y], t);
                s[x][y] = s[y][x] = to;
            }else{
                ll to = min(l[x][y], t);
                l[x][y] = l[y][x] = to;
            }
        }

        // 陸のみ,海のみを通ったときの全点対間最短距離
        for(int k = 0; k < n; k++){
            for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                    l[i][j] = min(l[i][j], l[i][k]+l[k][j]);
                    s[i][j] = min(s[i][j], s[i][k]+s[k][j]);
                }
            }
        }

        int r;
        cin >> r;
        vector<int> z(r);
        for(int i = 0; i < r; i++)  cin >> z[i], z[i]--;

        // dp[i][j] := 船をjに置いてz[i]まで到達した時のコスト
        vector<vector<ll>> dp(r, vector<ll>(n, INF));
        dp[0][z[0]] = 0;

        // 最初の町にいるときの船の位置を全て試す
        for(int i = 0; i < n; i++){
            if(s[z[0]][i] != INF && l[i][z[0]] != INF){
                dp[0][i] = min(dp[0][i], s[z[0]][i]+l[i][z[0]]);
            }
        }

        for(int i = 1; i < r; i++){
            // z[i-1] --(land)--> z[i]
            for(int j = 0; j < n; j++){
                dp[i][j] = min(dp[i][j], dp[i-1][j]+l[z[i-1]][z[i]]);
            }
            // z[i-1] --(land)-> j --(sea)-> k --(land)-> z[i]
            for(int j = 0; j < n; j++){
                for(int k = 0; k < n; k++){
                    dp[i][k] = min(dp[i][k], dp[i-1][j] + l[z[i-1]][j]+s[j][k]+l[k][z[i]]);
                }
            }
        }

        ll ans = INF;
        for(int i = 0; i < n; i++)  ans = min(ans, dp[r-1][i]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5112
#include <stdio.h>

    int main (void)
    {
       int n,s=0,i;
       char num[11];
       char *p=num;
       scanf("%d",&n);

       snprintf(num,11,"%d",n);

       while(1){
         if(*p=='\0') break;
         s+=*p-'0';
         p++;
      }

       if(n%s==0) printf("Yes\n");
       else printf("No\n");

       return 0;
    }


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

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

  if (a + b > c + d)
    cout << "Left";
  else if (a + b < c + d)
    cout << "Right";
  else
  {
    cout << "Balanced";
  }

}


Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<i64>();
  let a = read::<i64>();
  let b = read::<i64>();

  println!(
    "{}",
    if b - a <= 0 {
      "delicious"
    } else if b - a <= x {
      "safe"
    } else {
      "dangerous"
    }
  )
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n)scanf("%d",&v[i]);
  sort(ALL(v));
  ll l = v[0],r = v.back();
  ll res = r-l;
  for(int i = 0,j = n-1;i < j;i++,j--){
    if(i & 1){
      res += v[j]-l;
      res += r-v[i];
      l = v[j];
      r = v[i];
    }else{
      res += l-v[i];
      res += v[j]-r;
      l = v[i];
      r = v[j];
    }
  }
  if(n & 1)res += max(abs(l-v[n/2]),abs(r-v[n/2]));
  cout << res << endl;
  




  return 0;
}

Measured memory_bytes: 1024
L, R= (int(i) for i in input().split())  

_min = 2018
_init = L%2019

for g in range(R-L):
	plus = _init + g
	_start = (plus*(plus+1))%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		_start = _start%2019
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

print(_min)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int a, b, c, d, n, ans;
int ar[234567];
string s;
bool b1, b2;
signed main() {
	int p, q, r;
	cin >> a >> b >> p >> q >> r;
	printf("%.10f\n", (double)b + (double)(b*p - (b - a)*q) / (q + r));
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
bool c[201];
vector<int> taro,hana;
bool comp(int a,int b) {
  return a < b;
}

int main() {
  int n,a;
  while(cin >> n) {
    if(n==0)break;
    taro.clear();hana.clear();
    for(int i=0;i<201;i++) {
      c[i] = true;
    }
    for(int i=0;i<n;i++) {
      cin >> a;
      taro.push_back(a);
      c[a] = false;
    }
    for(int j=1;j<2*n+1;j++) {
      if(c[j]) {
	hana.push_back(j);
      }
    }
    sort(taro.begin(),taro.end(),comp);
    sort(hana.begin(),hana.end(),comp);

    int step=2;
    int field=taro[0];
    taro.erase(taro.begin());

    for(;;) {

      if(step % 2 == 0) {
	bool x = true;
	for(unsigned int i=0;i<hana.size();i++) {
	  if(field < hana[i]) {
	    field = hana[i];
	    hana.erase(hana.begin()+i);
	    step++;
	    x = false;
	    break;
	  }
	}

	if(x) { //pass
	  step++;
	  field = 0;
	}
      }

      else if(step % 2 == 1) {
	bool x = true;
	for(unsigned int i=0;i<taro.size();i++) {
	  if(field < taro[i]) {
	    field = taro[i];
	    taro.erase(taro.begin()+i);
	    step++;
	    x = false;
	    break;
	  }
	}

	if(x) { //pass
	  step++;
	  field = 0;
	}
      }

      if(taro.size() == 0 || hana.size() == 0) {
	cout << hana.size() << endl << taro.size() << endl;
	break;
      }

    }

  }
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    dic = {}
    for i in range(1, N+1):
        tmp = str(i)
        s, e = int(tmp[0]), int(tmp[-1])
        if (s, e) in dic:
            dic[(s, e)] += 1
        else:
            dic[(s, e)] = 1
    
    ans = 0
    for (i, j), count in dic.items():
        tmp = 0
        if i == j:
            tmp = count**2
        else:
            if (j, i) in dic:
                tmp = count * dic[(j, i)]
        ans += tmp
        # print(i, j, count)
    print(ans)


if __name__ == "__main__":
    main()

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  int h, w, n; cin >> h >> w >> n;
  int sr, sc; cin >> sr >> sc;
  string s, t; cin >> s >> t;

  int r1 = sr, r2 = sr, c1 = sc, c2 = sc;
  REP(i, n){
    if(s[i] == 'L') c1--;
    else if(s[i] == 'R') c2++;
    else if(s[i] == 'U') r1--;
    else if(s[i] == 'D') r2++;

    if(c1 == 0 || c2 == w + 1 || r1 == 0 || r2 == h + 1){
      cout << "NO" << endl;
      return 0;
    }

    if(t[i] == 'L') c2 = max(1, c2 - 1);
    else if(t[i] == 'R') c1 = min(w, c1 + 1);
    else if(t[i] == 'U') r2 = max(1, r2 - 1);
    else if(t[i] == 'D') r1 = min(h, r1 + 1);
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 776
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int k = readInt();
        int n = 7;
        if (k % 2 == 0 || k % 5 == 0) {
            System.out.print(-1);
            return;
        }
        
        for (int i = 0; i < 1000000; i++) {
            if (n % k == 0) {
                System.out.print(i + 1);
                return;
            }

            n = (n % k) * 10 + 7;
        }

        System.out.print(-1);

    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32472
n = int(input())
x = []
for i in range(n):
    x.append(int(input()))
mx = float("inf") * (-1)
mn = x[0]
for i in range(1,n):
    if mx < (x[i] - mn):
        mx = x[i] - mn
    if mn > x[i]:
        mn = x[i]
print(mx)



Measured memory_bytes: 13612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << "\n"; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  int n; cin >> n;
  V b(n); cin >> b;
  rep(i, n) --b[i];

  bool ok = true;
  rep(i, n) if (b[i] > i) ok = false;
  
  if (!ok) {
    cout << -1 << "\n";
    return 0;
  }

  V ans;
  while (!b.empty()) {
    int k = -1;
    rep(j, b.size()) if (b[j] == j) k = j;
    ans.push_back(k+1);
    b.erase(b.begin() + k);
  }

  reverse(all(ans));
  cout << ans;
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ( (a % 2) == 0 || (b % 2) == 0  ) {
  cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
  
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){

string T;
cin >> T;

for (int i = 0; i < T.size(); i++){
     if(T.at(i) == '?'){
          T.at(i) = 'D';
     }
}

for (int i = 0; i < T.size(); i++){
     cout << T.at(i);
}

cout << endl;

return 0;
}

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

int main(){
    ll N,W;
    cin>>N>>W;
    V w(N),v(N);
    rep(i,N)cin>>w[i]>>v[i];
    vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }else{
                dp[i+1][j]=max(dp[i][j],v[i]+dp[i][j-w[i]]);
            }
        }
    }
    cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 80256