akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=998244353;
const int N=2e5+5;
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        string s;cin>>s;
        ll ans=1;
        ll r=0,g=0,b=0;
        rep(i,n){
            if(s[i]=='R')r++;
            if(s[i]=='G')g++;
            if(s[i]=='B')b++;
        }
        ans=r*g*b;
        ll temp=0;
        for(int i=0;i<n;i++){
            for(int j=i-1;j>=0;j--){
                int k=2*j-i;
                if(k>=0){
                    if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i])temp++;
                }
            }
        }
        cout<<ans-temp;
    }   
    timecalculater();
    return 0;   
} 


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

int L[5500][5500];
int R[5500][5500];
int a[5500];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	L[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (L[i][j]) {
				L[i + 1][j] = 1;
				if (j + a[i] < m) {
					L[i + 1][j + a[i]] = 1;
				}
			}
		}
	}
	R[n][0] = 1;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < m; j++) {
			if (R[i + 1][j]) {
				R[i][j] = 1;
				if (j + a[i] < m) {
					R[i][j + a[i]] = 1;
				}
			}			
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		vector<int> A;
		for (int j = 0; j < m; j++) {
			if (L[i][j]) {
				A.push_back(j);
			}
		}
		vector<int> B;
		for (int j = 0; j < m; j++) {
			if (R[i + 1][j]) {
				B.push_back(j);
			}
		}
		int flag = true;
		for (int x : A) {
			if (x + a[i] >= m) {
				flag = false;
				break;
			}
			int j = lower_bound(B.begin(), B.end(), m - x - a[i]) - B.begin();
			if (j < B.size() && x + B[j] < m) {
				flag = false;
				break;
			}
		}
		ans += flag;
	}
	cout << ans << endl;
	return 0;
}


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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    while(1) {
        bool ok = true;
        for (int i = 2; i * i <= n; ++i) {
            if (n % i == 0) {
                ok = false;
            }
        }
        if (ok) break;
        ++n;
    }
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

int main() {
	ULL  a, b, x, ans;
	cin >> a >> b >> x;

	if (b == 0) {
		ans = 1;
	}
	else if (a == 0) {
		ans = b / x + 1;
	}
	else {
		ans = b / x - (a - 1) / x;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int fac[400010], facinv[400010];
int n, k;

inline int quickmul(int x, int y) {
    int ret = 1, mul = x;
    while (y) {
        if (y & 1) {
            ret = (LL)ret * mul % mod;
        }
        mul = (LL)mul * mul % mod;
        y >>= 1;
    }
    return ret;
}

inline int C(int n, int k) {
    return (LL)fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

inline void init() {
    fac[0] = facinv[0] = 1;
    for (int i = 1; i <= n + k; ++i) {
        fac[i] = (LL)fac[i - 1] * i % mod;
        facinv[i] = quickmul(fac[i], mod - 2) % mod;
    }
}

inline void work() {
    cin >> n >> k;
    k = min(k, n - 1);
    init();
    int ans = 0;
    for (int i = 0; i <= k; ++i) {
        ans += (LL)C(n, i) * C(n - 1, n - i - 1) % mod;
        ans %= mod;
    }
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

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

using namespace std;

int main() {

	int a, b, c;
	cin >> a >> b >> c;
	
	int counter = 0;
	while (c > 0) {
		counter++;
		c -= a;
		if (counter != 0 && counter % 7 == 0) { c -= b; }

	}
	cout << counter << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <cstdio>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  double ret = 0.0;
  cin >> n >> k;
  for(i=1;i<=n;i++){
    double ans = 1.0/n,y=1.0;
    ll x = i,cnt=0;
    while(x<k){
      x*=2;
      cnt++;
      y*=0.5;
    }
    ans*=y;
    ret+=ans;
  }
  printf("%.12f\n",ret);
  return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;

lli n;
double ans;

int main(){
  cin >> n;
  for(lli i = 0;i < n;i++){
    double x;
    string s;
    cin >> x >> s;
    if(s=="JPY") ans += x;
    else ans += x*380000;
  }
  cout << setprecision(17);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#define N 100009
using namespace std;
const int INF = 0x3f3f3f3f;
char s[N];
int ans[N];
int nx[4] = {1, 1, 0, 0};
int ny[4] = {1, 0, 0, 1};

bool check(int a, int b, int n)
{
    ans[0] = a; ans[1] = b;
    for(int i = 1; i < n - 1; i++)
    {
        if(s[i] == 'o')
        {
            if(ans[i]) ans[i + 1] = ans[i - 1];
            else ans[i + 1] = !ans[i - 1];
        }
        else
        {
            if(ans[i]) ans[i + 1] = !ans[i - 1];
            else ans[i + 1] = ans[i - 1];
        }
    }
    if(s[0] == 'o')
    {
        if(ans[0])
        {
            if(ans[1] != ans[n - 1]) return false;
        }
        else if(ans[1] == ans[n - 1]) return false;
    }
    else
    {
        if(ans[0])
        {
            if(ans[1] == ans[n - 1]) return false;
        }
        else if(ans[1] != ans[n - 1]) return false;
    }
    if(s[n - 1] == 'o')
    {
        if(ans[n - 1])
        {
            if(ans[0] != ans[n - 2]) return false;
        }
        else if(ans[0] == ans[n - 2]) return false;
    }
    else
    {
        if(ans[n - 1])
        {
            if(ans[0] == ans[n - 2]) return false;
        }
        else if(ans[0] != ans[n - 2]) return false;
    }
    return true;
}


int main()
{
    int n;
    scanf("%d %s", &n, s);
    for(int i = 0; i < 4; i++)
    {
        if(check(nx[i], ny[i], n))
        {
            for(int i = 0; i < n; i++)
            {
                if(ans[i]) printf("S");
                else printf("W");
            }
            printf("\n");
            exit(0);
        }
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

void dfs(const vector<vector<int> > &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}

int main() {
  int n; cin >> n;
  if (n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9) {
    cout << "hon" << endl;
  } else if (n%10==0 || n%10==1 || n%10==6 || n%10==8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
	
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  long long ans=1+n-2;
  for(long long i=1;i<sqrt(n)+1;i++){
    if(n%i==0){
      if(ans>i+n/i-2){
        ans=i+n/i-2;
      }
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    long long A[N + 1];
    A[0] = 0;
    for (int i = 1; i < N + 1; i++) {
        cin >> A[i];
        A[i] += A[i - 1];
    }
    long long B[M + 1];
    B[0] = 0;
    for (int i = 1; i < M + 1; i++) {
        cin >> B[i];
        B[i] += B[i - 1];
    }

    int ans = 0;
    for (int i = 0; i < N + 1; i++) {
        int l = -1;
        int r = M + 1;
        while (r - l > 1) {
            int c = l + (r - l) / 2;
            if (A[i] + B[c] > K) {
                r = c;
            }
            else {
                ans = max(ans, i + c);
                l = c;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6748
#include<stdio.h>
#include<stdlib.h>
typedef unsigned long long int llu;
typedef long long int lli;
int main(void)
{
    lli n,m;
    lli a[100000];
    llu ans=0;
    llu dp[100001];

    scanf("%lld %lld",&n,&m);
    for(lli i=0;i<m;i++){
        scanf("%lld",&a[i]);
        if(i>0&&a[i]-a[i-1]==1){
            printf("0\n");
            return 0;
        }
        dp[a[i]]=-1;
    }
    if(dp[1]==-1){
        dp[1]=0;
        dp[2]=1;
    }
    else if(dp[2]==-1){
        dp[2]=0;
    }
    else{
        dp[1]=1;
        dp[2]=2;
    }
    for(lli i=3;i<=n;i++){
        if(dp[i]==-1){
            dp[i]=0;
            continue;
        }
        dp[i]=dp[i-1]+dp[i-2];
        dp[i]%=1000000007;
    }
    /*for(int i=0;i<=n;i++){
        printf(">%d %d\n",i,dp[i]);
    }*/
    printf("%llu\n",dp[n]%1000000007);
    return 0;
}

Measured memory_bytes: 1280
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val Array(n, x) = readLine.trim.split(' ').map(_.toLong)
  val positions = readLine.trim.split(' ').map{pos ⇒ abs(pos.toLong - x)}
  println(
    positions.foldLeft(positions(0)){(g, pos) ⇒ gcd(g, pos)}
  )

  def gcd(a: Long, b: Long): Long = {
    b match{
      case 0 ⇒ a
      case _ ⇒ gcd(b, a % b)
    }
  }
}


Measured memory_bytes: 42160
import sys
from heapq import heappop, heappush
from typing import List


def func(start: int) -> List[int]:
    global edges
    cost = [sys.maxsize] * n
    que = [(0, start)]
    cost[start] = 0

    while que:
        acc, num = heappop(que)
        for weight, to in edges[num]:
            if weight + acc < cost[to]:
                cost[to] = weight + acc
                heappush(que, (weight + acc, to))
    return cost


if __name__ == "__main__":
    n = int(input())
    edges = [[] for _ in range(n)]  # type: ignore
    for _ in range(n - 1):
        s, t, w = map(int, input().split())
        edges[s].append((w, t))
        edges[t].append((w, s))

    cost1 = func(0)
    max_ind = cost1.index(max(cost1))
    cost2 = func(max_ind)
    max_ind2 = cost2.index(max(cost2))
    cost3 = func(max_ind2)
    for i in range(n):
        print(max(cost2[i], cost3[i]))



Measured memory_bytes: 12528
using System;
class MainClass
{
    public static void Main(string[] args)
    {
        string[] input1 = Console.ReadLine().Split(' ');
        int n = int.Parse(input1[0]);
        int m = int.Parse(input1[1]);
        int x = int.Parse(input1[2]);
        int y = int.Parse(input1[3]);
        string[] input2 = Console.ReadLine().Split(' ');
        string[] input3 = Console.ReadLine().Split(' ');
        int wk1 = x;
        int wk2 = y;
        string ans = "War"; 

        for (int i = 0; i < n;i++){
            if(wk1 < int.Parse(input2[i]))
            {
                wk1 = int.Parse(input2[i]);
            }
        }
        for (int j = 0; j < m; j++)
        {
            if(wk2 >= int.Parse(input3[j]))
            {
                wk2 = int.Parse(input3[j]);
            }
        }
        if( (x < wk1 && wk1 <= y) &&(x < wk2 && wk2 <= y))
        {
            if( wk1 < wk2)
            {
                ans = "No War";
            }
        }

        Console.WriteLine(ans);
    }
}


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

using namespace std;


int main(){
 int n,a,b,c,d;
  cin>>n;
  a=n/1000;
  b=n/100-a*10;
  c=n/10-a*100-b*10;
  d=n-a*1000-b*100-c*10;
  
    
    if(a+b+c+d==7) cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
 else if(a+b+c-d==7)  cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a+b-c+d==7)  cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a+b-c-d==7)  cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b+c+d==7)  cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a-b+c-d==7)  cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b-c+d==7)  cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else   cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
}

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

using namespace std;

template <typename T>
string to_string(T t) {
  ostringstream ss;
  ss << t;
  return ss.str();
}

const int n = 200000;
const int bit = 63;
const int b = 31;

int main() {
  vector<string> res;
  auto add = [&](int i, int j, int k) {
    res.push_back("+ " + to_string(i) + " " + to_string(j) + " " + to_string(k));
  };
  auto compare = [&](int i, int j, int k) {
    res.push_back("< " + to_string(i) + " " + to_string(j) + " " + to_string(k));
  };
  vector<int> num(bit);
  vector<int> power(bit);
  for(int i = bit - 1; i >= 0; i--) {
    num[i] = n - 1 - i;
    power[i] = num[i] - bit;
  }
  compare(2, 0, num[1]);
  compare(2, 1, num[2]);
  add(num[1], num[2], num[1]);
  compare(num[0], num[1], num[1]);
  for(int i = 2; i < bit; i++) {
    add(num[i - 1], num[1], num[i]);
  }
  for(int i = 1; i < bit; i++) {
    add(power[i - 1], power[i - 1], power[i]);
    add(power[i], num[1], power[i]);
  }
  vector<int> go(2);
  for(int pos = 0; pos <= 1; pos++) {
    for(int i = 2; i < b + 2; i++) {
      add(power[i - 2], num[0], i);
    }
    for(int st = b + 2 + pos * b; st < 2 * b + 2 + pos * b; st++) {
      for(int j = st; j < st + b; j++) {
        compare(j - st + 2, pos, j);
        if(j > st + 1) {
          int v = j - st - 1;
          while(v--) {
            add(j, j, j);
          }
        }
      }
      for(int j = st + 1; j < st + b; j++) add(st, j, st);
      for(int i = 2; i < b + 2; i++) add(i, st, i);
    }
    go[pos] = b + 2 + pos * b;
  }
  vector<int> go_log(2);
  go_log[0] = go[0] + 2 * b;
  go_log[1] = go[1] + 2 * b;
  for(int pos = 0; pos <= 1; pos++) {
    for(int i = go[pos]; i < go[pos] + b; i++) {
      for(int j = i + 2 * b; j < i + 3 * b - 1; j++) {
        compare(power[j - i - 2 * b + 1], i, j);
      }
      for(int j = i + 1 + 2 * b; j < i + 3 * b - 1; j++) {
        add(i + 2 * b, j, i + 2 * b);
      }
    }
  }
  int sum = n >> 1;
  int cnt = sum >> 1;
  add(num[0], num[0], 2);
  for(int i = 0; i < b; i++) {
    for(int j = 0; j < b; j++) {
      compare(num[0], go[0] + i, cnt);
      compare(num[0], go[1] + j, cnt + 1);
      add(cnt, cnt + 1, cnt);
      compare(num[1], cnt, cnt);
      add(2, cnt, 2);
      add(go_log[0] + i, go_log[1] + j, cnt + 1);
      int bound = b - 1 - i + (b - 1 - j);
      for(int p = cnt + 2; p < cnt + 2 + bound; p++) {
        compare(num[p - cnt - 2], cnt + 1, p);
        add(p, cnt, p);
        compare(num[1], p, p);
        add(p, sum + p - cnt - 2, sum + p - cnt - 2);
      }
    }
  }
  for(int i = sum; i < sum + bit; i++) {
    int v = i - sum;
    while(v--) {
      add(i, i, i);
    }
    add(2, i, 2);
  }
  cout << res.size() << "\n";
  for(auto i : res) cout << i << "\n";
  return 0;
}


Measured memory_bytes: 15640
#include <stdio.h>
int main (void)
{
	int gr1[100][100],gr2[100][100],a1,a2,a3;
	int a,b,c,o,gou;
	long long  int an[100][100];

	for(a=0;a<100;a++)
	{
		for(b=0;b<100;b++)
		{
			gr1[a][b]=0;
			gr2[a][b]=0;
			an[a][b]=0;
		}
	}
	scanf("%d%d%d",&a1,&a2,&a3);

	for(a=0;a<a1;a++)
	{
		for(b=0;b<a2;b++)
		{
			scanf("%d",&gr1[a][b]);
		}
	}
	for(a=0;a<a2;a++)
	{
		for(b=0;b<a3;b++)
		{
			scanf("%d",&gr2[a][b]);
		}
	}

	for(a=0;a<a1;a++)
	{
		for(b=0;b<a3;b++)
		{	
			for(c=0;c<a2;c++)
			{
				an[a][b]+=(gr1[a][c]*gr2[c][b]);
			}
		}
	}

	for(a=0;a<a1;a++)
	{
		for(b=0;b<a3-1;b++)
		{
			printf("%lld ",an[a][b]);
		}
		printf("%lld\n",an[a][a3-1]);
	}
	return 0;
}

			







	

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

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

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

  ll n, x, y;
  cin >> n;
  vector<ll> d1(n);
  vector<ll> d2(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> x >> y;
    d1[i] = x + y;
    d2[i] = x - y;
  }
  sort(ALL(d1));
  sort(ALL(d2));
  cout << max(d1.back() - d1[0], d2.back() - d2[0]);

  return 0;
}

Measured memory_bytes: 6340
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] k = line.split(" ");
		int v = Integer.parseInt(k[0]);
		int v2 = Integer.parseInt(k[1]);
		int p = v / v2;
		int r = v % v2;

		double f = Integer.parseInt(k[0]);
		double f2 = Integer.parseInt(k[1]);
		double ff = f / f2;
		BigDecimal bigDecimal = new BigDecimal(ff);
		bigDecimal.setScale(5, BigDecimal.ROUND_DOWN);

		System.out.print(p);
		System.out.print(" " + r);
		System.out.println(" " + bigDecimal.toPlainString());

	}
}

Measured memory_bytes: 26540
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  t;
    cin>>t;
    long long  a[t+5];

    long long  sum=0;
    for(int i=0;i<t;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<t;i++)
    {
        if(a[i-1]>a[i])
        {
            sum+=(a[i-1]-a[i]);

            a[i]=a[i-1];
            //cout<<"A = "<<a[i]<<endl;
            //cout<<"Sum = "<<sum<<endl;
        }

    }
    cout<<sum<<endl;
}


Measured memory_bytes: 5152
n,a,b=map(int,input().split())
s=input()
cnt_ab=0
cnt_b=0
for i in range(n):
    if s[i]=="b":
        cnt_b+=1
        if cnt_ab<a+b and cnt_b<=b:
            cnt_ab+=1
            print("Yes")
        else:
            print("No")
    elif s[i]=="a":
        if cnt_ab<a+b:
            cnt_ab+=1
            print("Yes")
        else:
            print("No")
    else:
        print("No") 

Measured memory_bytes: 4016
#!/usr/bin/env python3
import sys


def solve(N: int, i: int):
    print(N-i+1)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    i = int(next(tokens))  # type: int
    solve(N, i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
 
public class Main{
 
    private static double a, b, c, d, e, f;
    private static double x, y;
 
    public static void main(String args[]) throws Exception {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        String[] array;
 
        while((line = br.readLine())  != null) {
            array = line.split(" ");
             
            // set input data
            setParams(array);
 
            // calc y
            if(d == 0 ){
                y = f/e;
            }
            else {
                y = c - f * a / d;
                y = y / (b - e * a / d);
            }
             
            // calc x
            if (a == 0) {
                x = (f - e * y) / d;
            } else {
                x = (c - b * y) / a;
            }
            System.out.println(new BigDecimal(x).setScale(3, BigDecimal.ROUND_HALF_UP) + " " + new BigDecimal(y).setScale(3, BigDecimal.ROUND_HALF_UP));
        }
    }
 
    private static void setParams(String[] array) {
        a = Double.parseDouble(array[0]);
        b = Double.parseDouble(array[1]);
        c = Double.parseDouble(array[2]);
        d = Double.parseDouble(array[3]);
        e = Double.parseDouble(array[4]);
        f = Double.parseDouble(array[5]);
    }
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];
ll B[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll sa = 0, sb = 0;
    REP(i, N) {
        cin >> A[i];
        sa += A[i];
    }
    REP(i, N) {
        cin >> B[i];
        sb += B[i];
    }

    ll M = sb - sa;
    REP(i, N) {
        ll n = A[i] - B[i];
        if (n >= 0)
            M -= n;
        else if (abs(n) % 2 == 1)
            M--;
    }

    if (M >= 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    int multiple_two = 0;
    int multiple_four = 0;
    int not_multiple_two = 0;
    for(int i=0; i<N; i++) {
        cin >> a[i];
        if(a[i] % 4 == 0) multiple_four++;
        else if(a[i] % 2 == 0) multiple_two++;
        else not_multiple_two++;
    }

    bool flg = false;
    if(N == multiple_two) flg = true;
    if(multiple_four + 1 >=  not_multiple_two && multiple_two == 0) flg = true;
    if(multiple_four ==  not_multiple_two) flg = true;
    cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3708
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
#ifdef LBT
    freopen("test.in", "r", stdin);
    int nol_cl = clock();
#endif

    int n, q, s, t;
    ll ans = 0;
    scanf("%d%d%d%d", &n, &q, &s, &t);
    ++n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) scanf("%lld", &a[i]);
    for (int i = n - 1; i; --i) a[i] -= a[i - 1];
    function<ll(ll)> gval = [=](ll h) { return -h * (h > 0 ? s : t); };
    function<void(int, int)> ch = [&](int k, int x) {
        ans -= gval(a[k]);
        ans += gval(a[k] += x);
    };
    for (int i = 0; i < n; ++i) ans += gval(a[i]);
    while (q--) {
        int l, r, x;
        scanf("%d%d%d", &l, &r, &x);
        ++l;
        ++r;
        ch(l - 1, x);
        if (r != n)
            ch(r, -x);
        printf("%lld\n", ans);
    }

#ifdef LBT
    LOG("Time: %dms\n", int((clock() - nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
    return 0;
}


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

 
int main() {
    long long int a,b,n;
    cin>>a>>b>>n;
    long long int x=min(n,b-1);
    long long int ans=(a*x/b)-a*(x/b);
    cout<<ans<<endl;
}

Measured memory_bytes: 3556
#include <stdio.h>

int main(void) {
	// your code goes here
		int n,i;
		long long int c=0;
		scanf("%d",&n);
		for(i=1;i<=n;i++){
			if(i%3!=0&&i%5!=0){
				c=c+i;
			}
		
		}
			printf("%lld",c);
	return 0;
}

Measured memory_bytes: 1736
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
# MOD = 10 ** 9 + 7
MOD = 998244353

N, M = list(map(int, sys.stdin.readline().split()))
A = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

# 列を選んだときに 1 が 1 個でもあれば奇数になるように選べるのが 2^(N-1) 通り
# 0 個になる数を数えて引く

# 方程式とく
A = np.array(A, dtype=int)
A = np.hstack((A, [[0] for _ in range(N)])).astype(bool)
rank = 0
for col in range(M):
    if rank >= N:
        break
    row = A[rank:, col].argmax() + rank
    if not A[row, col]:
        continue
    pivot_row = A[row].copy()
    A[A[:, col]] ^= pivot_row
    A[row] = A[rank]
    A[rank] = pivot_row
    rank += 1

# 1が1つ以上ある列の選び方
col_count = pow(2, M, MOD) - pow(2, M - rank, MOD)
# 1が1つ以上ある列から行の選び方が 2^(N-1) ある
ans = col_count * pow(2, N - 1, MOD) % MOD
print(ans)


Measured memory_bytes: 15304
#include<stdio.h>
 
int main(void){
 
int n,k,i,j; 
int key;
int a[1100];
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(j=1;j<=n;j++){
key = a[j];
i = j-1;
while(i>0 && a[i]>key){
a[i+1]=a[i];
i = i-1;
}
a[i+1] = key;
for(k=1;k<=n;k++){
if(k==n){
printf("%d\n",a[k]);
}
else{
printf("%d ",a[k]);
}
}
}
return 0;
}

Measured memory_bytes: 1788
N, K = map(int, input().split())
l = list(map(int, input().split()))
cnt = [0 for i in range(N)]
for i in l:
    cnt[i - 1] += 1
cnt.sort(reverse = True)
total = 0
for i in range(K):
    total += cnt[i]
print(N - total)

Measured memory_bytes: 24836
n = int(input())
t, a = map(int, input().split())
h_array = [int(x) for x in input().split()]

res = float("inf")
ret = float("inf")
for i, y in enumerate(h_array, 1):
    if res > abs(a-(t-y*0.006)):
        res = abs(a-(t-y*0.006))
        ret = i
print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>

typedef long long ll;

#define debug(x) cerr << #x << ": " << x << "\n";
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

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

  if(s.size() <= k) cout << s << endl;
  else cout << s.substr(0,k) + "..." << endl;
}

Measured memory_bytes: 3604
N = int(input())

# t = []
# for i in range(1, N+1):
#     if N // i == N % i:
#         print("→ :", i)
#         t.append(i)
#     else:
#         print("  :", i)

# print("G:", sum(t))

ans = (N-1) if N != 2 else 0
cur = 2
while (N-cur)//cur >= cur:

    if (N-cur)%cur == 0:
        a = (N-cur)//cur
        if N%a!=0:
            ans += (N-cur)//cur
    cur += 1

print(ans)

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

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

template<class T> 
inline bool chmin(T &a, const T &b){
    if(a > b){
        a = b;
        return true;
    }
    return 0;
}

signed main() {

    vector<int> tetra;
    for(int i = 1; ; ++i){
        int p = i*(i+1)*(i+2) / 6;  // 連続する3つの整数の積は6の倍数なので必ず割り切れる
        if(p > 1e6){
            break;
        }
        tetra.push_back(p);
    }
    int m = tetra.size();
    
    vector<int> dp(1e6 + 1, 1LL << 60), dp_odd(1e6 + 1, 1LL << 60);
    dp[0] = 0;
    dp_odd[0] = 0;
    rep(i, 1e6+1){
        rep(j, m){
            if(i + tetra[j] >= 1e6){
                break;
            }
            chmin(dp[i+tetra[j]], dp[i]+1);
            if(tetra[j] % 2){   // 正四面体数が奇数の時
                chmin(dp_odd[i+tetra[j]], dp_odd[i]+1);
            }
        }
    }
    
    int n;
    while(true){
        cin >> n;
        if(n == 0){
            break;
        }
        cout << dp[n] << ' ' << dp_odd[n] << '\n';
    }
    return 0;
}



Measured memory_bytes: 18144
#include<iostream>
#include<string>

using namespace std;

int main()
{
	char str[20];
	int length;
	
	cin >> str;
	for(length = 0; str[length] != '\0'; length++);
	
	for(int i = length-1; i > -1; i--){
		printf("%c",str[i]);
	}
	cout << endl;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		try {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (1 <= a && a <= 1000000000){
			if (1 <= b && b <= 1000000000){
				System.out.printf("%d %d %.5f", a/b, a%b, (double)a/b);
			}
			}
		}
		finally {
		sc.close();
		}
	}
}


Measured memory_bytes: 26472
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vll l(n), r(n), width(n), mid(n);
  rep (i, n) {
    scanf("%lld%lld", &l[i], &r[i]);
    l[i] *= 2;
    r[i] *= 2;
    width[i] = r[i] - l[i];
    mid[i] = (r[i] + l[i]) / 2;
  }
  ll left_offset, right_offset;
  left_offset = right_offset = 0;
  ll minval = 0;
  priority_queue<ll, vll, less<ll> > left;
  priority_queue<ll, vll, greater<ll> > right;

  left.push(mid[0]);
  right.push(mid[0]);

  FOR (i, 1, n) {
    ll width_ = (width[i] + width[i-1]) / 2;
    left_offset -= width_;
    right_offset += width_;
    ll max_left = left.top();
    ll min_right = right.top();

    assert(max_left + left_offset <= min_right + right_offset);

    if (max_left + left_offset <= mid[i] && mid[i] <= min_right + right_offset) {
      left.push(mid[i] - left_offset);
      right.push(mid[i] - right_offset);
    } else {
      if (mid[i] < max_left + left_offset) {
        minval += max_left + left_offset - mid[i];

        right.push(max_left + left_offset - right_offset);
        left.pop();
        left.push(mid[i] - left_offset);
        left.push(mid[i] - left_offset);
      } else {
        minval += mid[i] - (min_right + right_offset);

        left.push(min_right + right_offset - left_offset);
        right.pop();
        right.push(mid[i] - right_offset);
        right.push(mid[i] - right_offset);
      }
    }
  }

  printf("%lld\n", minval / 2);

  return 0;
}


Measured memory_bytes: 5228
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)

string s;
main(){
	string aidu = "AIDUNYAN";
	sort(aidu.begin(), aidu.end());
	while(cin >> s){
		string ans = "";
		REP(i, (int)s.size()){
			string t = s.substr(i, 8);
			sort(t.begin(), t.end());
			if(t == aidu){
				ans += "AIZUNYAN";
				i += 7;
			}else ans += s[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <queue>

using namespace std;

int main()
{
    std::queue<char> Sa,Sb,Sc;
    int i;
    string input;

    cin >> input;


    for(i=0;i<input.size();i++)
    {
        Sa.push(input.at(i));
    }

    cin >> input;

//    cout << input << input.size();
    for(i=0;i<input.size();i++)
    {
        Sb.push(input.at(i));
    }

    cin >> input;


    for(i=0;i<input.size();i++)
    {
        Sc.push(input.at(i));
    }

    char sun=Sa.front();
    Sa.pop();

    while(1)
    {
    //    cout << sun << endl;
        if(sun=='a')
        {
            if(Sa.empty())
            {
                cout << "A";
                break;
            }
            else
            {
                sun=Sa.front();
                Sa.pop();
            }
        }
        else if(sun=='b')
        {
            if(Sb.empty())
            {
                cout << "B";
                break;
            }
            else
            {
                sun=Sb.front();
                Sb.pop();
            }
        }
        else if(sun=='c')
        {
            if(Sc.empty())
            {
                cout << "C";
                break;
            }
            else
            {
                sun=Sc.front();
                Sc.pop();
            }
        }
    }
  
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a, b;
	cin >> a >> b;
	if (a <=8 && b<= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <set>
#include <map>
using namespace std;

void solve(vector<string> arr) {
    /*
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            cout << arr[i][j];
            if ((j+1)%3 == 0) {
                cout << " ";
            }
        }
        cout << endl;
        if ((i+1)%3 == 0) {
            cout << endl;
        }
    }
    */

    int i = 0;
    for (int k = 0; k < 3; k++) {
        int tmp = k;
        for (int j = 1; j <= 3; j++) {
            arr[i][tmp] = arr[i][tmp] == '1' ? '2' : '1';
            tmp+=3;
            i+=1;
        }
    }


    /*
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            cout << arr[i][j];
            if ((j+1)%3 == 0) {
                cout << " ";
            }
        }
        cout << endl;
        if ((i+1)%3 == 0) {
            cout << endl;
        }
    }
    */
    for (string s : arr) {
        cout << s << endl;
    }

}

int main()
{
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') {
        cout << 'A' << endl;
    }
    else {
        cout << 'a' << endl;
    }

}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)

int a, b, gcd, lcm;

void GCD(int x, int y)
{
	if (x < y) swap(x, y);
	x = x % y;
	if (x != 0) GCD(x,y);
	else gcd = y;
}

int main()
{

	while (cin >> a >> b)
	{
		GCD(a, b);
		lcm = a / gcd*b;
		cout << gcd << " " << lcm << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
from bisect import *

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    m = a[-1] / 2
    i = bisect(a, m)
    d0 = m - a[i - 1]
    d1 = a[i] - m
    if d0 < d1 or i == n - 1:
        print(a[-1], a[i - 1])
    else:
        print(a[-1], a[i])

main()


Measured memory_bytes: 14040
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, m, k := scanInt(), scanInt(), scanInt()
	as := scanInts(n)
	bs := scanInts(m)

	var t int
	for _, b := range bs {
		t += b
	}

	j := m
	var ans int
	for i := 0; i <= n; i++ {
		for j > 0 && t > k {
			j--
			t -= bs[j]
		}
		if t > k {
			break
		}
		ans = max(ans, i+j)
		if i == n {
			break
		}
		t += as[i]
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 7840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int cnt[10][10] = {};
    rep(i, 1, n + 1) {
        string s = to_string(i);
        int f = s[0] - '0';
        int b = s.back() - '0';
        cnt[f][b]++;
    }
    ll ans = 0;
    rep(i, 0, 10) {
        rep(j, 0, 10) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int pasta[3], drink[2];
	
	cin >> pasta[0]
		>> pasta[1]
		>> pasta[2];
	cin >> drink[0]
		>> drink[1];
		
	sort(pasta, pasta+3);
	sort(drink, drink+2);
	
	cout << pasta[0] + drink[0] - 50 << endl;
	
	return 0;
}

Measured memory_bytes: 1176
#include <cstdio>
#include <cstring>
using namespace std;
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
int main()
{
    long long h, n, a[1001], b[1001], f[10001];
    memset(f, 127, sizeof(f));
    f[0] = 0;
    scanf("%lld%lld", &h, &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld%lld", &a[i], &b[i]);
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= h; j++)
        {
            f[j] = min(f[j], f[max(0, j - a[i])] + b[i]);
        }
    }
    printf("%lld", f[h]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;


int main(){
	/*input*/
	int n,x;
    cin >> n >> x;
    int l[100];
    for(int i = 0; i < n; i++){
    	cin >> l[i];
    }


	/*calc*/
    int ans = 1;
    int x_place = 0;
	for(int i = 0; i < n; i++){
		x_place += l[i];
		if(x_place > x){
			break;
		}
		ans++;
	}

	/*output*/
   	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main()
{

  int height[10];//0~9Ã£ÂÂ¾Ã£ÂÂ§Ã£ÂÂ®Ã¥ÂÂÃ£ÂÂÃ§ÂÂ¿Ã¥ÂÂÃ¨Â¨Â10Ã¥ÂÂÃ£ÂÂÃ§ÂÂ¨Ã¦ÂÂ
  int n, j, t;


  //input
  for(n=0; n<10; n++){
    scanf("%d", &height[n]);
  }


  //Ã¥ÂÂ¦Ã§ÂÂÃ©ÂÂÃ¥Â§Â

  for(n=0; n<10; n++){
    
    for(j=n+1 ; j<10; j++){
    

      if(height[n] < height[j]){//Ã¥ÂÂ¥Ã£ÂÂÃ¦ÂÂ¿Ã£ÂÂ
	t=height[n];
	height[n]=height[j];
	height[j]=t;
      }

    }
  }
  //Ã¥ÂÂºÃ¥ÂÂ
  for(n=0;n<3; n++){
    printf("%d\n", height[n]);
  }


  return 0;
}

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

int main(){
  int n, min = 0,c = 0;
  cin >> n;
  vector<int> h(n);
  for(int i = 0;i < n;i++){
    cin >> h.at(i);
  }
  min = h.at(0);
  for(int i = 1;i < n;i++){
    if(n == 1)
      break;
    else if(min <= h.at(i)){
      min = h.at(i);
      c++;
    }
    else if(min - h.at(i) == 1)
      c++;
    else{
      cout << "No" << endl;
      break;
    }
  }
  if(c == n - 1)
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;

vector<int>ans;
int a[1000],b[1000],c[1000];
signed main(){
int x,y,z,k;cin>>x>>y>>z>>k;
for(int i=0;i<x;i++)cin>>a[i];
for(int i=0;i<y;i++)cin>>b[i];
for(int i=0;i<z;i++)cin>>c[i];
sort(a,a+x,greater<int>());
sort(b,b+y,greater<int>());
sort(c,c+z,greater<int>());
for(int i=0;i<x&&i<=k;i++){
 for(int j=0;j<y&&i*j<=k;j++){
  for(int u=0;u<z&&i*j*u<=k;u++){
  ans.push_back(a[i]+b[j]+c[u]);
  }
 }
}
  sort(ans.begin(),ans.end());
  reverse(ans.begin(),ans.end());
  for(int i=0;i<k;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 35172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a,b;
    cin>>a>>b;
    if(a>9||b>9){
        cout<<-1<<endl;
    }
    else{
        cout<<a*b<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
	int n;
	while(cin >> n){
		int count=0;
		bool first = true;
		while(n){
			if(n%2){
				if(first){
					cout << pow(2,count);
					first = false;
				}else cout << " " << pow (2,count);
			}
			count++;
			n/=2;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n){
	if(n == 1){
		return false;
	}else{
		for (int i = 2; i*i <= n; ++i) {
			if(n % i == 0) return false;
		}
		return true;
	}
}
int main(){
	long long q;
	cin >> q;
	vector<int> ans(100005,0);
	for(int i=0;i<100001;i++){
		if(i%2==0) continue;
		if(isPrime(i) && isPrime((i+1)/2)) ans[i]++;
	}
	for(int i=0;i<100001;i++){
		if(i>0){
			ans[i] += ans[i-1];
		}
	}
	for(int i=0;i<q;i++){
		int l,r;
		cin >> l >> r;
		cout << ans[r] - ans[l-1] << endl;
	}
    return 0;
}


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

using System.Collections;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());

        int[] vals = Enumerable.Repeat(-1, N+1).ToArray();        
        Queue<int> queue = new Queue<int>();

        List<int> units = new List<int>();
        foreach(var x in Enumerable.Range(1, int.MaxValue).Select(n => (int)Math.Pow(6, n)).TakeWhile(n => n <= N))
        {
            units.Add(x);
        }
        foreach (var x in Enumerable.Range(1, int.MaxValue).Select(n => (int)Math.Pow(9, n)).TakeWhile(n => n <= N))
        {
            units.Add(x);
        }
        units.Add(1);

        foreach (var x in units)
        {
            vals[x] = 1;
            queue.Enqueue(x);
        }

        while(queue.Any())
        {
            var n = queue.Dequeue();

            foreach(var x in units)
            {
                var next = n + x;

                if (next <= N && vals[next] == -1)
                {
                    vals[next] = vals[n] + 1;
                    queue.Enqueue(next);
                }
            }
        }

        Console.WriteLine(vals[N]);
    }
}


static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}


Measured memory_bytes: 14944