akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define w(t) int t; cin>>t; while(t--)
#define ll long long int
#define rep(n) for (long long int i=0; i<n; i++)

int main ()
{
    string str;
    cin >> str;
    int sum=0,x=str.size();
    for (int i=0; i<x; i++)sum+=str[i]-'0';
    (sum%9==0 ? cout<<"Yes\n" : cout << "No\n"); 
    return 0;
}


Measured memory_bytes: 3732
n = int(input())
words = set()
from collections import defaultdict
count_dict = defaultdict(int)
ans = 0

for i in range(n):
  word = str(sorted(input()))
  if word in words:
    count_dict[word] += 1
    ans += count_dict[word]
  else:
    words.add(word)
    
print(ans)

Measured memory_bytes: 19308
#include<bits/stdc++.h>
    #define N int(2e5+1)
    #define M int(1e9+7)
    #define LL long long int
    using namespace std;
    int main()
    {
    	int k,n;
    	cin>>k>>n;
    	cout<<(k*500>=n?"Yes\n":"No\n");
    	return 0;
    }

Measured memory_bytes: 256
n=int(input())
m=n-n%2+1
d=[[i+j+2!=m and i!=j for i in range(n)] for j in range(n)]
print(sum([sum(i) for i in d])//2)
for i in range(n):
  for j in range(i+1,n):
    if d[i][j]:print(i+1,j+1)

Measured memory_bytes: 74476
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

char s[99], t[99];
main(){
    scanf("%s%s", s, t);
    t[strlen(s)] = 0;
    puts(strcmp(s,t)?"No":"Yes");
}

Measured memory_bytes: 1648
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    };
    let mut s = 0;
    for i in 0..32 {
        let b = 1 << i;
        let mut x = 0;
        for &a_i in a.iter() {
            x ^= a_i & b;
        }
        s |= x;
    }
    for &a_i in a.iter() {
        print!("{} ", s ^ a_i);
    }
}


Measured memory_bytes: 6388
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
#include <bitset>
using namespace std;
typedef int64_t ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef vector<long double> vld;
typedef vector<vld> vvld;
typedef unordered_map<ll, ll> uii;
typedef unordered_map<ll, ll> uuii;
typedef unordered_map<ll, ll> uuuii;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef bitset<64> bs;
const ll LINF = 1e18;
const long double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define ALL(X) (X).begin(),(X).end()

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    ll N; cin >> N;
    vl A(N); rep(i, N) cin >> A[i];
    
    ll cnt = 0;
    rep(i, N){
        if(i%2 == 0 && A[i]%2 == 1) cnt++;
    }
    
    cout << cnt << endstr;
    
    return 0;
}


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

int main(){
  int x, y;
  cin >> x >> y;
  if(x==2||y==2){
    cout << "No";
  }
  else if(x==4||x==6||x==9||x==11){
    if(y==4||y==6||y==9||y==11){
      cout << "Yes";
    }
    else{
      cout << "No";
    }
  }
  else{
    if(y==4||y==6||y==9||y==11){
      cout << "No";
    }
    else{
      cout << "Yes";
    }
  }
  cout << endl;
  return 0;
}

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

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    ll ans = 0;
    ll s = 0;
    rep(i, n-1){
        s = (s + a[i+1])%mod;
    }
    rep(i, n-1){
        ans += (s*a[i])%mod;
        s -= a[i+1];
        if(s < 0) s += mod;
    }
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 5124
import scala.io.StdIn.readInt

object Main {
  val r = Array(2,3,5,7)

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,BigInt(x).modPow(2,n).toLong, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,BigInt(x).modPow(2,n).toLong,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n==2 || n==3 || n==5 || n==7) true
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> {
        val m = readInt; isPrime(m)
      }
    })
  }
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  while(n > 0) {
    int tmp = 0;
    int cnt = 1;
    while(tmp < n) {
      tmp += cnt;
      cnt++;
    }
    cnt--;
    cout << cnt << endl;
    n -= cnt;
  }
}

Measured memory_bytes: 256
s = int(input())

sets = set([s])
count = 1
a = s
while 1:
    count += 1
    if a % 2==0:
        a = a // 2
    else:
        a = a*3 + 1

    if a in sets:
        print(count)
        break
    else:
        sets.add(a)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cctype>
#include<cstring>
#include<list>
#include<map>
#include<sstream>
#include<set>
#include<string>
#include<vector>
typedef long long ll;
using namespace std;
#define MN 300005
#define MM 600005
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define RF(i,a,b) for(int i=a;i>=(b);--i)
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define int long long
signed main()
{
   int n;
   cin>>n;
   queue<int> q;
   F(i,1,9)q.push(i);
   int cnt=1;
   while(1){
       int x=q.front();q.pop();
       if(cnt==n){
           cout<<x<<endl;
           return 0;
       }
       if(x%10!=0)q.push(x*10+(x-1)%10);
       q.push(x*10+(x)%10);
        if(x%10!=9)q.push(x*10+(x+1)%10);
       cnt++;
   }
   return 0;
}



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

int n;
vector<pair<int, int>> tasks;

int main() {
  cin >> n;
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    tasks.emplace_back(b, a);
  }
  
  sort(tasks.begin(), tasks.end());
  int sum = 0;
  bool isyes = true;
  for (auto v : tasks) {
    sum += v.second;
    
    if (sum > v.first) {
      isyes = false;
      break;
    }
  }
  
  cout << (isyes ? "Yes" : "No") << endl; 
  
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n = s.size();
    string s1 = s.substr(0, n/2);
    reverse(all(s));
    string s2 = s.substr(0, n/2);
    int ans=0;
    rep(i, n/2){
        if (s1[i]!=s2[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int x;
  string s, p;
  cin >> s;
  cin >> p;

  s += s;
  
  for (int i = 0; i < s.length() / 2; i++) {
    if (s[i] == p[0]) {
      x = 0;
      for (int j = 0; j < p.length(); j++) {
        if (s[i + j] != p[j])
          break;
        x++;
      }
      if (x == p.length()) {
        cout << "Yes" << endl;
          return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  string s;
  cin>>s;
  map<char,int> mp;
  rep(i,len(s)){
    mp[s[i]]++;
  }
  if(mp.size()!=2){
    cout<<"No"<<endl;
    return 0;
  }
  for(auto x:mp){
    if(x.second!=2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,y;
    cin>>x>>y;
    if (x<y&&x!=1)
        cout<<"Bob\n";
    else if (x>y&&y!=1)
        cout<<"Alice\n";
    else if (x==y)
        cout<<"Draw\n";
    else if (x==1)
        cout<<"Alice\n";
    else
        cout<<"Bob\n";
    return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;


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

    int k,x;
    cin >> k >> x;

    for (int i=max(-1000000,x-k+1);i<=min(1000000,x+k-1);i++){
        cout << i << " ";
    }
    cout << el;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int a,b,c,i,cnt=0;
	scanf("%d%d%d", &a, &b,&c);
	for (i = a; i <=b; ++i)if (c%i == 0) cnt++;printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long X = GetLong();
		long Y = GetLong();
		long Z = GetLong();
		long K = GetLong();
		var A = GetLongs(X);
		var B = GetLongs(Y);
		var C = GetLongs(Z);

		var AB = new List<long>((int)(X * Y));
		for(long i = 0; i < X; i++)
		{
			for(long j = 0; j < Y; j++)
				AB.Add(A[i] + B[j]);
		}
		AB.Sort();
		AB.Reverse();

		var ABC = new List<long>((int)Min(K, AB.Count));
		for(int i = 0, E = (int)Min(K, AB.Count); i < E; i++)
		{
			for(int j = 0; j < Z; j++)
				ABC.Add(AB[i] + C[j]);
		}
		ABC.Sort();
		ABC.Reverse();
		WriteLine(string.Join("\n", ABC.Take((int)K)));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

i32 n, c_siz, s, t, c;
vec<i32> imos;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    cin >> n >> c_siz;
    imos.resize(100010);
    rep(i,n) {
        cin >> s >> t >> c;
        ++imos[s];
        --imos[t+1];
    }
    rep(i,100005) {
        imos[i+1] += imos[i];
    }

    i32 answer = 0;
    for(auto im : imos) {
        chmax(answer, im);
    }
    chmin(answer, c_siz);

    cout << answer << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 1024
use std::cmp;

fn main() {
    // input
    let one = read_vec::<i64>();
    // N
    let n = one[0];
    // K
    let k = one[1];
    // S
    let s = read_line::<String>();

    let raw_unhappy = count_unhappy(s);
    let unhappy = cmp::max(raw_unhappy - k * 2, 1);
    println!("{}", n - unhappy);
}

fn count_unhappy(s: String) -> i64 {
    let mut before = 'a';
    let mut counter = 0;
    for c in s.chars() {
        if before != c {
            counter += 1;
        }
        before = c;
    }
    counter
}

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
int a,b;
scanf("%d %d",&a,&b);
if(a>b){
if(b==1){
printf("Bob\n");
}else{
printf("Alice\n");
}
}
if(b>a){
if(a==1){
printf("Alice\n");
}else{
printf("Bob\n");
}
}
if(a==b){
printf("Draw\n");
}
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MN 400005
char ch[MN],ch2[MN];
int nex[MN][26];
long long ans;
int main(){
	scanf("%s%s",ch+1,ch2);
	long long l1=strlen(ch+1),l2=strlen(ch2);
	for(int i=0;i<26;++i)nex[(l1<<1)][i]=-1;
	for(int i=(l1<<1);i;--i){
		for(int j=0;j<26;++j){
			nex[i-1][j]=nex[i][j];
		}
		int real=i;
		if(i>l1)real-=l1;
		nex[i-1][ch[real]-'a']=i;
	}
	int now=0;
	for(int i=0;i<l2;++i){
		if(nex[now][ch2[i]-'a']==-1){
			puts("-1");
			return 0;
		}
		now=nex[now][ch2[i]-'a'];
	//	cout<<"HI "<<i<<" "<<now<<endl;
		if(now>=l1)ans+=l1,now-=l1;
	}
	printf("%lld",ans+(long long)now);
}

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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        v[i] -= (i + 1);
    }

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

    int b;
    if (v.size() % 2 == 1) {
        b = v[(v.size() - 1) / 2];
    } else {
        b = (v[v.size() / 2 - 1] + v[v.size() / 2]) / 2;
    }

    long long int ss = 0;
    for (int i = 0; i < n; i++) {
        ss += fabs(v[i] - b);
    }

    cout << ss << endl;
}

Measured memory_bytes: 1024
import sys
import random
import time
import numpy as np

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def prob(e1,e2,T):
    if e2 < e1:
        return 1
    else:
        return np.exp((e1-e2)/T)

def solve():
    D = ni()
    c = nl()
    s = [nl() for _ in range(D)]
    m = 26
    start = time.time()
    dT = 0.995
    T = 10000

    def calc(sche, m=26):
        last = [-1] * m
        ans = 0
        for i in range(D):
            t = sche[i]
            ans += s[i][t]
            last[t] = i
            for j in range(m):
                ans -= c[j] * (i - last[j])
        return ans

    def change(d, q, sc):
        b = sche[d]
        fq, bq = -1, D
        fb, bb = -1, D
        for i in range(d):
            if sche[i] == q:
                fq = i
            if sche[i] == b:
                fb = i
        for i in range(D-1, d, -1):
            if sche[i] == q:
                bq = i
            if sche[i] == b:
                bb = i
        sc += ((bb - d) * (bb - d - 1) // 2 + (d - fb) * (d - fb - 1) // 2) * c[b]
        sc += ((bq - fq) * (bq - fq - 1) // 2) * c[q]
        sc -= s[d][b]
        sc -= ((bq - d) * (bq - d - 1) // 2 + (d - fq) * (d - fq - 1) // 2) * c[q]
        sc -= ((bb - fb) * (bb - fb - 1) // 2) * c[b]
        sc += s[d][q]
        return sc

    sche = [0] * D
    for i in range(D):
        sche[i] = s[i].index(max(s[i]))
    sc = calc(sche)
    bestst = sche[:]
    best = sc

    while time.time() - start < 1.8:
        for _ in range(300):
            d = random.randint(0, D-1)
            q = random.randint(0, m-1)
            nsc = change(d, q, sc)
            if best < nsc:
                bestst = sche[:]
                best = sc
            if random.random() < prob(-sc, -nsc, T):
                sche[d] = q
                sc = nsc
        T *= dT
    prn([1 + x for x in bestst])

    return

solve()


Measured memory_bytes: 27700
import java.util.*;

public class Main {
	
	static boolean judge(int i){
		for(int j=2; j<i; j++)
			if(i%j==0) return false;
		return true;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int down=0; int up=0;
			for(int i=0; i<=50021; i++){
				if(judge(i)){
					if(i > down && i < n) down = i;
					if(i > n){ up = i; break;}
				}
			}
			System.out.printf("%d %d%n",down,up);
		}
	}

}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<class T>
class SegmentTree {

public:
    /**
     * @param N size
     * @param def initial value
     * @param operation operation for query
     * @param updater operation for update
     */
    SegmentTree(size_t N, T _def, function<T(T, T)> operation, function<T(T, T)> updater)
            : def(_def), operation(std::move(operation)), updater(move(updater)) {
        n = 1;
        while (n < N) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    /**
     * iの値をxに更新
     * @param i index ( 0-indexed )
     * @param x  value
     */
    void update(int i, T x) {
        i += n - 1;
        data[i] = updater(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    /**
     * [a, b)の区間でクエリを実行
     */
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }

    /**
     * 添字でアクセス
     * @param i index ( 0-indexed )
     */
    T operator[](int i) {
        return data[i + n - 1];
    }

private:
    int n;
    vector<T> data;
    T def;
    function<T(T, T)> operation;
    function<T(T, T)> updater;

    T query(int a, int b, int k, int l, int r) {
        // 交差しない
        if (r <= a || b <= l) return def;
        // 区間 [a, b) に l, r が含まれる
        if (a <= l && r <= b) return data[k];
        // 左の子
        T c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
        // 右の子
        T c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return operation(c1, c2);
    }
};

void Main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, pair<int, ll>>> items;
    SegmentTree<ll> segmentTree(N, INF, [](ll a, ll b) { return min(a, b); }, [](ll a, ll b){ return min(a, b); });
    rep(i, M) {
        int l, r;
        ll c;
        cin >> l >> r >> c;
        items.push_back({r, {l, c}});
    }
    sort(items.begin(), items.end());

    vector<ll> dp(N, INF);
    dp[0] = 0;
    segmentTree.update(0, 0);
    rep(i, M) {
        int r = items[i].first;
        int l = items[i].second.first;
        ll c = items[i].second.second;
        l--;
        r--;
        ll x = segmentTree.query(l, r + 1);
        ll tmp = x + c;
        dp[r] = min(dp[r], tmp);
        segmentTree.update(r, tmp);
    }
    if (dp[N - 1] != INF) {
        cout << dp[N - 1] << '\n';
    } else {
        cout << -1 << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6900
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int rec1 = a * b;
		int rec2 = c * d;
		int maxRec = Math.max(rec1,rec2);
		System.out.println(maxRec);
	}
} 

Measured memory_bytes: 23636
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

		final Scanner stdin = new Scanner( System.in );
		final long[] convert = {0, 1, 2, 3, 5, 7, 8, 9};
		
		while ( true ) {

			long n = stdin.nextLong();
			if ( n == 0L ) break;

			long maxdigit = 1;
			long n8 = 0;
			while ( n > 0 ) {
				final int val = (int)( n % 8L );
				final long digit = convert[ val ];
				n8 += maxdigit * digit;
				maxdigit *= 10L;
				n /= 8;
			}
			System.out.println( n8 );	    
		}	
    }    
}

Measured memory_bytes: 47340
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())


typedef long long ll;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

struct UnionFind {
    //number of parents(par[i] = i => root)
    vector <int> par;
    //rank of tree
    vector <int> rank;

    UnionFind(int n) : par(n), rank(n, 1) {
        //initialize
        rep(n, i) par[i] = i;
    }

    //find root (keiroasshuku at the same time)
    int root(int x){
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //unite
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) swap(x, y);
        par[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
    }

    //same tree?
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

struct Edge {
    int from, to; ll cost;

    bool operator<(const Edge& o) const {
        return cost < o.cost;
    }
};

struct Kruskal {
    int V;  // number of nodes
    vector<Edge> edges;

    void input(){
        cin >> V;
        vector <intP> xs, ys;
        rep(V, i) {
            int x, y;
            scanf("%d %d\n", &x, &y);
            xs.pb(intP(x, i));
            ys.pb(intP(y, i));
        }
        sort(all(xs));
        sort(all(ys));
        rep(V-1, i) {
            Edge ex = {xs[i].second, xs[i+1].second, (xs[i+1].first-xs[i].first)};
            Edge ey = {ys[i].second, ys[i+1].second, (ys[i+1].first-ys[i].first)};
            edges.pb(ex);
            edges.pb(ey);
        }
    }

    // グラフが非連結のときは最小全域森のコストの和となる
    ll kruskal() {
        //init
        UnionFind uf(V);
        sort(all(edges));
        ll min_cost = 0LL;

        for (Edge e : edges) {
            if (!uf.same(e.from, e.to)) {
                min_cost += e.cost;
                uf.unite(e.from, e.to);
            }
        }
        return min_cost;
    }
};

void solve(){
    Kruskal k;
    k.input();
    cout << k.kruskal() << endl;
}

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


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

int main(){
  int n;
  cin >> n;
  vector <int>d(n);
  for ( int i = 0; i < n; ++i) {
    cin >> d[i];
  }

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

  if(n%2 == 0) {
    cout << d[n/2] - d[n/2 - 1]  << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll A, B, H, M;
  IN(A,B,H,M);
  ll TM = H*60+M;

  double A_x = (double)A*cos((double)TM/12/60*2.0*M_PI);
  double A_y = (double)A*sin((double)TM/12/60*2.0*M_PI);
  double B_x = (double)B*cos((double)M/60*2.0*M_PI);
  double B_y = (double)B*sin((double)M/60*2.0*M_PI);

  //debug_print(A_x, A_y, B_x, B_y);

  double dx = A_x-B_x;
  double dy = A_y-B_y;

  double l = sqrt(dx*dx+dy*dy);

  printf("%.12lf\n", l);

  return 0;
}

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

int main(){
   ll W, H, x, y;
   cin >> W >> H >> x >> y;
   cout << (W * H) / 2.0 << " ";
   if(x == W/2.0 && y == H/2.0) cout << 1 << endl;
   else cout << 0 << endl;
}

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

int main()
{
	int sta,end,n;
	cin >> sta >> end >> n;

	bool jud = true;
	int tsta,tend;
	for(int i=0;i<n;i++){
		cin >> tsta >> tend;
		if(!((sta<=tsta&&end<=tsta)||(sta>=tend&&end>=tend))){
			jud = false;
			break;
		}
	}

	if(jud){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}

	return 0;
}


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

#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)

using namespace std;

int main()
{

  string s;
  cin >>s;
  if(s=="Sunny")cout <<"Cloudy";
  else if(s=="Cloudy") cout << "Rainy";
  else cout <<"Sunny";
    
	return 0;
}





Measured memory_bytes: 256
import java.util.*;

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

         int area = a*b;
         int length = 2*(a+b);

         System.out.println(area + " " + length);
    }
}

Measured memory_bytes: 25912
#include <iostream>
#include <vector>
using namespace std;
bool prim[55555];
int main(){
  int n;cin>>n;
  vector<int> ans;
  for(int i = 2; 55555 > i && ans.size() != n; i++){
    if(!prim[i]){
      if(i%10 == 1){
        ans.push_back(i);
      }
      for(int _ = i+i; 55555 > _; _ += i)prim[_]=true;
    }
  }
  for(int i = 0; ans.size() > i; i++){
    cout << ans[i];
    if(i+1!=ans.size())cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll minn = min({a,b,c,d,e});
  ll time = (n-1)/minn + 5;
  cout << time << endl;
}

Measured memory_bytes: 256
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x, a, b = MAP()

if (abs(a - x) < abs(b - x)):
    print("A")
else:
    print("B")


Measured memory_bytes: 27128
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,c,k,ans=0;
  cin>>n>>c>>k;
  vector<int>v(n);
  for(int i=0;i<n;++i)cin>>v[i];
  stable_sort(v.begin(),v.end());
  for(auto it=v.cbegin();it!=v.cend();++ans){
    const int x=*it+k;
    for(int i=0;*it<=x&&i<c&&it!=v.cend();++i,++it);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
struct side{
    int n;
    int m;
    int l;
};
side sides[100000];
void mergesort(int l,int r){
    if(l==r)return;
    side temp;
    if(l==r-1){
        if(sides[l].l>sides[r].l){
            temp=sides[l];
            sides[l]=sides[r];
            sides[r]=temp;
        }
        return;
    }
    int mid=(l+r)/2,now=0;
    side b[r-l+1];
    mergesort(l,mid-1);
    mergesort(mid,r);
    for(int i=0;i<=r-l;i++){
        if(sides[i+l-now].l<sides[mid+now].l){
            b[i]=sides[i+l-now];
            if(i+l-now==mid-1){
                for(i++;i<=r-l;i++){
                    b[i]=sides[mid+now];
                    now++;
                }
            }
        }
        else{
            b[i]=sides[mid+now];
            now++;
            if(mid+now>r){
                for(i++;i<=r-l;i++)
                    b[i]=sides[i+l-now];
            }
        }
    }
    for(int i=0;i<=r-l;i++)
        sides[i+l]=b[i];
}
int main(){
    int n,m,a,ans=0,c=1;
    bool tree[10000];
    scanf("%d%d",&n,&m);
    if(m==0){
        printf("0\n");
        return 0;
    }
    tree[0]=true;
    for(int i=1;i<n;i++){
        tree[i]=false;
    }
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&sides[i].n,&sides[i].m,&sides[i].l);
    }
    mergesort(0,m-1);
    while(c<n){
        a=0;
        while(tree[sides[a].n]==tree[sides[a].m])a++;
        ans+=sides[a].l;
        tree[sides[a].n]=tree[sides[a].m]=true;
        c++;
    }
    printf("%d\n",ans);
}

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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

int n,m,a[100],ans;
long double sum;

signed main() {
    cin >> n >> m;
    rep(i,n) cin >> a[i], sum += a[i];
    sum /= (double)(4.0*m);
    rep(i,n) {
        if (a[i] < sum) ;
        else ans++;
    }
    if (ans >= m) yn(true)
    else yn(false)
}

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

using namespace std;

const int N=1e6+6;

int n,m,k;
int aa,bb,cc,dd;
set<int> r[N],c[N];
int dis[N];
string gr[N];
int mx[N][4];

void delet(int x,int y)
{
	r[x].erase(y);
	c[y].erase(x);
}

int get(int x,int y)
{
	return x*m+y;
}

int main()
{
	cin >> n >> m >> k;
	cin >> aa >> bb >> cc >> dd;
	aa--; bb--; cc--; dd--;
	for(int i=0;i<n;i++)
		cin >> gr[i];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(gr[i][j]=='.'&&(i!=aa||j!=bb))
			{
				r[i].insert(j);
				c[j].insert(i);
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		int las=-1;
		for(int j=0;j<m;j++)
		{
			if(gr[i][j]=='@')
				las=j+1;
			else
				mx[get(i,j)][0]=las;
		}
		las=m;
		for(int j=m-1;j>=0;j--)
		{
			if(gr[i][j]=='@')
				las=j-1;
			else
				mx[get(i,j)][1]=las;
		}
	}
	for(int i=0;i<m;i++)
	{
		int las=-1;
		for(int j=0;j<n;j++)
		{
			if(gr[j][i]=='@')
				las=j+1;
			else
				mx[get(j,i)][2]=las;
		}
		las=n;
		for(int j=n-1;j>=0;j--)
		{
			if(gr[j][i]=='@')
				las=j-1;
			else
				mx[get(j,i)][3]=las;
		}
	}
	queue<pair<int,int> > q;
	q.push({aa,bb});
	memset(dis,-1,sizeof dis);
	dis[get(aa,bb)]=0;
	while(q.size())
	{
		auto x=q.front();
		q.pop();
		int cx=x.first,cy=x.second;
		int ll=mx[get(cx,cy)][0],rr=mx[get(cx,cy)][1];
		ll=max(ll,cy-k); rr=min(rr,cy+k);
		set<int> del;
		for(auto it=r[cx].lower_bound(ll);it!=r[cx].end();it++)
		{
			if(*it>rr) break;
			del.insert(*it);
			dis[get(cx,*it)]=dis[get(cx,cy)]+1;
			q.push({cx,*it});
		}
		for(int i:del)
			delet(cx,i);
		ll=mx[get(cx,cy)][2]; rr=mx[get(cx,cy)][3];
		ll=max(ll,cx-k); rr=min(rr,cx+k);
		del.clear();
		for(auto it=c[cy].lower_bound(ll);it!=c[cy].end();it++)
		{
			if(*it>rr) break;
			del.insert(*it);
			dis[get(*it,cy)]=dis[get(cx,cy)]+1;
			q.push({*it,cy});
		}
		for(int i:del)
			delet(i,cy);
	}
	printf("%d\n",dis[get(cc,dd)]);
}

Measured memory_bytes: 242236
n, y = map(int, input().split())

flag = False

for i in range(n+1):
  for j in range(n-i+1):
    if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
      print(i, j, n-i-j)
      exit()
print(-1, -1 ,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define maxn 100010
#define maxm 200010
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
int ne[maxn], tot;
bool vis[maxn];
LL dist1[maxn], dist2[maxn], ways1[maxn], ways2[maxn];
struct Edge { int from, to, ne; LL w; }edge[maxm<<1];
void add(int u, int v, LL w) {
    edge[tot] = {u, v, ne[u], w};
    ne[u] = tot++;
}
struct node {
    int v; LL c;
    bool operator < (const node nd) const { return c > nd.c; }
};
int n;
void dfs(int src, LL* dist, LL* ways) {
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; ++i) dist[i] = inf;
    vis[src] = true; dist[src] = 0; ways[src] = 1;
    priority_queue<node> q;
    while (!q.empty()) q.pop();
    while (true) {
        for (int j = ne[src]; ~j; j = edge[j].ne) {
            int v = edge[j].to;
            if (vis[v]) continue;
            LL now = edge[j].w + dist[src];
            if (now == dist[v]) (ways[v] += ways[src]) %= mod;
            else if (now < dist[v]) {
                dist[v] = now; ways[v] = ways[src];
                q.push({v, now});
            }
        }
        while (!q.empty() && vis[q.top().v]) q.pop();
        if (q.empty()) break;
        vis[src = q.top().v] = true;
    }
}
int main() {
    memset(ne, -1, sizeof ne);
    int m, s, t;
    scanf("%d%d%d%d", &n,&m,&s,&t);
    for (int i = 0; i < m; ++i) {
        int u, v; LL w;
        scanf("%d%d%lld", &u,&v,&w);
        add(u, v, w), add(v, u, w);
    }
    dfs(s, dist1, ways1);
//    for (int i = 1; i <= n; ++i) printf("%lld ", dist1[i]); puts("");
//    for (int i = 1; i <= n; ++i) printf("%lld ", ways1[i]); puts("");
    dfs(t, dist2, ways2);
    assert(dist1[t] == dist2[s]);
    assert(ways1[t] == ways2[s]);
    LL ww = ways1[t];
    LL ans = ww * (ww-1) % mod;
//    printf("%lld\n", ans);
    LL dis = dist1[t];
    if (!(dis & 1)) {
        LL half = dis >> 1;
        for (int i = 1; i <= n; ++i) if (dist1[i] == half && dist2[i] == half) {
            LL temp = ways1[i] * ways2[i] % mod;
            ans = (ans - (temp * (temp-1)) % mod + mod) % mod;
        }
    }
//    printf("%lld\n", ans);
    for (int i = 0; i < m; ++i) {
        int id = i<<1,
            u = edge[id].from, v = edge[id].to;
        if (dist1[u] > dist1[v]) swap(u, v);
        if (dist1[u] + edge[id].w + dist2[v] == dis && (dist1[u]<<1) < dis && (dist2[v]<<1) < dis) {
            LL temp = ways1[u] * ways2[v] % mod;
            ans = (ans - (temp * (temp-1)) % mod + mod) % mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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


int main(){
    string fl, sl;
    cin >> fl >> sl;
    rep(i,3){
        if(fl[i] != sl[2-i]){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


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

int main() {
    int m, d; cin >> m >> d;
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            if (j < 10) continue;
            int a = j / 10;
            int b = j % 10;
            if (a >= 2 && b >= 2 && a * b == i) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a,b,c,d,n,i;
	while((scanf("%d",&n))!=EOF){
		i=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(a+b+c+d==n){
							i++;
						}
					}
				}
			}
		}
		printf("%d\n",i);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    bool b = false;
    rep(i,3){
        if(s[i]-'0'==s[i+1]-'0'){
            b = true;
        }
    }
    cout<< (b?"Bad":"Good") <<endl;
    return  0;
}


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

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){
  
  int n;
  cin >> n;
  double res = 0;
  REP(i,n){
    double x;
    string s;
    cin >> x >> s;
    if(s == "JPY"){
      res += x;
    }else{
      res += x*380000;
    }
  }
  cout << fixed << setprecision(15);
  cout << res << endl;




  return 0;
}

Measured memory_bytes: 256