akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	//std::ifstream in("../../test.txt");
	//std::cin.rdbuf(in.rdbuf());

	ll X, A;
	cin >> X >> A;

	if (X < A) cout << 0 << endl;
	else cout << 10 << endl;


	return 0;
}



Measured memory_bytes: 888
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

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

func main() {
	rd := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n int
	var k int64
	fmt.Fscan(rd, &n, &k)
	a := make([]int, n)
	f := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(rd, &a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(rd, &f[i])
	}

	sort.Ints(a)
	sort.Sort(sort.Reverse(sort.IntSlice(f)))

	var l, r int64
	l, r = 0, int64(1e18)
	for l < r {
		m := int64(uint64(l+r) >> 1)
		tmp := k
		for i := 0; i < n; i++ {
			x := m / int64(f[i])
			tmp -= max(int64(a[i])-x, 0)
		}
		if tmp < 0 {
			l = m + 1
		} else {
			r = m
		}
	}

	ans := l
	fmt.Fprintln(w, ans)
}


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

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

    int a, b;
    cin >> a >> b;
    if (a - 2*b > 0) cout << a-2*b << endl;
    else cout << 0 << endl;
}

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

int main() {
    int n;
    std::cin >> n;
    std::string s;
    std::cin >> s;

    if (n % 2 == 1) {
        std::cout << "No" << std::endl;
    } else {
        if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    }

    return 0;
}


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

int a,b,c;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> a >> b >> c;
	if (a==b&&b==c&&!(a&1)){
		cout << "-1\n";
		return 0;
	}
	int ans=0;
	while (1){
		if ((a&1)||(b&1)||(c&1)){
			break;
		}
		int _a=a,_b=b,_c=c;
		a=(_b>>1)+(_c>>1);
		b=(_a>>1)+(_c>>1);
		c=(_a>>1)+(_b>>1);
		ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int solve(int n, int obj){
    int i, j, cnt = 0;
    for(i = 1; i <= obj/2; i++){
        for(j = i + 1; j < n; j++){
            int sub = obj - i - j;
            if(sub <= n && sub > j){
                cnt++;
            }
        }
    }

    return cnt;
}

int main(){
    int n, obj;
    while(1){
        scanf("%d %d", &n, &obj);
        getchar();

        if(n == 0)break;

        printf("%d\n", solve(n, obj));                       
    }
}


Measured memory_bytes: 2060
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
    auto s = readln().chomp();
    int[char] m;
    foreach(si; s) {
        m[si] = 1;
    }
    bool f = true;
    int v = m.get('S', 0) + m.get('N', 0);
    int h = m.get('E', 0) + m.get('W', 0);
    if(v % 2 == 1 || h % 2 == 1) {
        writeln("No");
    } else {
        writeln("Yes");
    }
}



Measured memory_bytes: 256
#include <iostream>
#define abs(a) (((a) < 0) ? (-(a)): (a))
using namespace std;
long long N, Z, W;
long long a[2048];
void ABS() {
	cin >> N >> Z >> W;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
long long max;
if (N==1) {
max = abs(a[N - 1] - W);
}else{
	max = abs(a[N - 1] - W) > abs(a[N - 1] - a[N-2]) ?  abs(a[N - 1] - W) : abs(a[N - 1] - a[N-2]);
}
	cout << max << endl;
}
int main() {
	ABS();
	return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
EDGES = M.times.map{ gets.split.map(&:to_i) }

dist = Array.new(N+1, Float::INFINITY)
dist[1] = 0

(N-1).times do
  EDGES.each do |a, b, c|
    if dist[b] > dist[a] - c
      dist[b] = dist[a] - c
    end
  end
end

ans1 = -dist[N]
N.times do
  EDGES.each do |a, b, c|
    if dist[b] > dist[a] - c
      dist[b] = dist[a] - c
    end
  end
end
ans2 = -dist[N]

puts(ans1 == ans2 ? ans1 : "inf")



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

set<char> st;
int main(){
	string s;
	
	cin >> s;
	for(int i = 0;i < s.size();i++){
		if(!st.count(s[i])) st.insert(s[i]);
		else{
			cout << "no";
			return 0;
		}
	}
	cout << "yes";
} 

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		int[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0 ; i < q ; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		// エラトステネスの篩で素数を調べる
		boolean[] isPrime = new boolean[100010];
		Arrays.fill(isPrime, true);
		for(int i = 2 ; i <= 100000 ; i++) {
			for(int j = i + i ; j <= 100000 ; j += i) {
				isPrime[j] = false;
			}
		}
		int[] sum = new int[100010];
		for(int i = 3 ; i <= 100000 ; i++) {
			if(isPrime[i] && isPrime[(i + 1) / 2]) sum[i]++;
		}
		for(int i = 3 ; i <= 100000 ; i++) {
			sum[i] += sum[i - 1];
		}
		for(int i = 0 ; i < q ; i++) {
			System.out.println(sum[r[i]] - sum[l[i] - 1]);
		}
	}
}


Measured memory_bytes: 96172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int T;
ll H,W;
int main(){
  cin >> T;
  while( T-- ){
    cin >> H >> W;
    ll d = __gcd( H, W );
    H/=d; W/=d;
    if( H == W ){
      cout << "1 0" << endl;
    } else if( (H + W)&1LL ){
      cout << "1 1" << endl;
    } else {
      cout << H*W/2LL+1LL << " " << H*W/2LL << endl;
    }
  }
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

typedef pair<D,D> pd;

D dot(D a,D b,D c,D ad,D bd,D cd){return a*ad+b*bd+c*cd;}

D abs(D a,D b,D c){return sqrt(a*a+b*b+c*c);}

const D EPS=1e-9;

bool solve(){
  ll N;
  cin>>N;
  if(N==0){return false;}
  vector<pair<pd,D>> A(N);
  cin>>A;
  ll M;
  cin>>M;
  vector<pair<pd,pd>> B(M);
  cin>>B;
  for(auto &I:A){
    D uku=abs(I.F.F,I.F.S,I.S);
    I.F.F/=uku;
    I.F.S/=uku;
    I.S/=uku;
  }
  for(auto &I:B){
    D uku=abs(I.F.F,I.F.S,I.S.F);
    I.F.F/=uku;
    I.F.S/=uku;
    I.S.F/=uku;
  }
  ll cnt=0;
  for(auto &I:A){
    bool jd=false;
    for(auto &J:B){
      if(dot(I.F.F,I.F.S,I.S,J.F.F,J.F.S,J.S.F)>cos(J.S.S)-EPS){jd=true; break;}
    }
    if(jd){cnt++;}
  }
  cout<<cnt<<endl;

  return true;
}

int main(){
  while(solve());
  

  return 0;
}



Measured memory_bytes: 3348
S = gets.chomp.chars

ans = 0
cnt = 0 # The count of white on right in each step i.

N = S.size
(N - 1).downto(0).each do |i|
  c = S[i]
  if (c == 'W') 
    cnt += 1
  else # c == 'B'
    ans += cnt
  end
end

p ans

Measured memory_bytes: 16764
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int odd = 0;
    int even = 0;
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0){
            even++;
        } else {
            odd++;
        }
    }

    if(odd % 2 == 0){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

std::string a[53];
std::string out[53];


int main() {
    int h, w;
    std::cin >> h >> w;

    for (int i = 0; i < h; i++) {
        std::cin >> a[i];
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                std::cout << '#';
                continue;
            }
            int count = 0;
            for (int k = -1; k <= 1; k++) {
                for (int l = -1; l <= 1; l++) {
                    if (k == 0 && l == 0) continue;
                    if (i + k < 0 || i + k >= h || j + l < 0 || j + l >= w) continue;
                    if (a[i + k][j + l] == '#') count++;
                }
            }
            std::cout << count;
        }
        std::cout << std::endl;
    }
}


Measured memory_bytes: 256
#! /usr/bin/env python3

from fractions import gcd
# from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

S = input()

c = Counter(S)

for i in c:
    if c[i] % 2 != 0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 5344
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    ll n,m;
    cin>>n>>m;
    const ll nmmax=50;
    char A[nmmax][nmmax],B[nmmax][nmmax];
    for(int y=0;y<n;++y){
        for(int x=0;x<n;++x){
            cin >> A[y][x];
        }
    }
    for(int y=0;y<m;++y){
        for(int x=0;x<m;++x){
            cin >> B[y][x];
        }
    }
    
    bool exist=false;
    
    rep(i,n){
        rep(j,n){
            if(i+m-1>=n || j+m-1>=n) continue;
            
            bool match = true;
            rep(y,m){
                rep(x,m){
                    if(A[y+i][j+x]!=B[y][x]) match=false;
                }
            }
            if(match) exist=true;
        }
    }
    cout<<(exist ? "Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N), b(N);
    REP(i,N) cin >> a[i] >> b[i];
    ll ans = 0;
    REP(i,N){
        bool ok = true;
        REP(j,30){
            if(((a[i] >> j) & 1) && !((K >> j) & 1)){
                ok = false;
                break;
            }
        }
        if(ok) ans += b[i];
    }
    REP(i,30){
        if(K >> i & 1){
            ll bits = K & ~(1LL << i);
            bits |= (1LL << i) - 1;
            ll tmp = 0;
            REP(j,N){
                bool ok = true;
                REP(l,30){
                    if(((a[j] >> l) & 1) && !((bits >> l) & 1)){
                        ok = false;
                        break;
                    }
                }
                if(ok) tmp += b[j];
            }
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std; 
const int N = 1e6;
int n , k;
std::vector<int> v;
int dp[N];

int f(int pos ){
  if(pos == n - 1) return 0;
  if(dp[pos] != -1) return dp[pos];
  int x = 1e9 , y = 1e9;

  if(pos + 1 <= n - 1)
    x = f(pos + 1) + abs(v[pos] - v[pos + 1]);
  if(pos + 2 <= n - 1)
    y = f(pos + 2) + abs(v[pos] - v[pos + 2]);
  dp[pos] = min(x , y);
  return min(x , y);
}

int32_t main() { 
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n ;
    for(int i = 0 ; i < n ; i++){
      int x ;
      cin >> x ;
      v.push_back(x);
    }
    memset(dp , -1 , sizeof dp);
    cout << f(0) << endl;

  return 0; 
}

Measured memory_bytes: 12148
#include <bits/stdc++.h>
using namespace std;
int main(){
	int arr[5],ans=0;
	for(int i=0;i<5;i++)cin>>arr[i];
   	for(int i=0;i<5;i++){
    	if(arr[i]==0){
    		ans=i+1;
    		break;
    	}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
	int k,m;
	cin >> k;
	int i=0,j=0;
	vector<int>mm(10000001),kk(k,0);
	
	mm.at(i) = 7 % k;
	//cout << mm.at(i) << endl;
	
	rep(i,10000001) {
		//cout << mm.at(i) << endl;
		if (mm.at(i) == 0) {
			cout << i+1 << endl;
			return 0;
		}
		kk.at(mm.at(i)) += 1;	
		if (kk.at(mm.at(i)) == 2) {
			cout << -1 << endl;
			return 0;
		}
	
		
		    mm.at(i+1)=((mm.at(i) * 10 + 7) % k);
	}
	/*	rep(j, k-1) {
			
			if (kk.at(mm.at(j)) == 2) {
				cout << -1 <<endl;
				return 0;
			}
		}*/
	return 0;
}//どうして・・・(´･_･`)

Measured memory_bytes: 46204
#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <utility>
#include <vector>

#define MAX_N (100000)
#define MAX_M (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, M, us[MAX_M], vs[MAX_M], S, T;
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &us[i], &vs[i]);
    us[i]--;  // NOTE : modified inputs
    vs[i]--;  // NOTE : modified inputs
  }
  scanf("%d %d", &S, &T);
  S--;  // NOTE : modified inputs
  T--;  // NOTE : modified inputs

  // create graph
  vector<vector<int>> adj_lists(N, vector<int>());
  for (int i = 0; i < M; i++) {
    adj_lists[us[i]].push_back(vs[i]);
  }

  // solve BFS
  int bss[MAX_N][3] = {};
  queue<pair<int, int>> que;
  que.push(make_pair(S, 0));
  bss[S][0] = 1;
  int cnt = 0, ans = -1;
  while (cnt < 10000000 && !que.empty()) {
    int cur = que.front().first, d = que.front().second;
    que.pop();
    if (cur == T && d % 3 == 0) {
      ans = d / 3;
      break;
    }
    for (int nxt : adj_lists[cur]) {
      if (!bss[nxt][(d + 1) % 3]) {
        bss[nxt][(d + 1) % 3] = 1;
        que.push(make_pair(nxt, d + 1));
      }
    }
    cnt++;
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 7680
// 2015/04/21 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int partition(int A[], int p, int r)
{
	int x = A[r];
	int i = p-1;

	for(int j=p; j<=r-1; j++){
		if(A[j]<=x){
			i++;
			swap(A[i], A[j]);
		}
	}

	swap(A[i+1], A[r]);

	return i+1;
}

int main()
{
	int n;
	cin >> n;

	int A[100000];
	for(int i=0; i<n; i++){
		cin >> A[i];
	}

	int q = partition(A, 0, n-1);

	for(int i=0; i<n; i++){
		if(i==q){
			cout << '[' << A[i] << ']';
		}
		else{
			cout << A[i];
		}

		if(i<n-1){
			cout << ' ';
		}
		else{
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1548
#define _CRT_SECURE_NO_WARNING

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm> 
using namespace std;
typedef long long ll;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(b%a==0) printf("%d\n",b+a);
	else printf("%d\n",b-a);
	return 0;
}

Measured memory_bytes: 256
from math import gcd
from collections import defaultdict
mod = 10**9+7
n = int(input())
mp = defaultdict(lambda: [0, 0])
zerozero = 0
for i in range(n):
    a, b = map(int, input().split())
    if (a, b) == (0, 0):
        zerozero += 1
        continue
    g = gcd(a, b)
    a //= g
    b //= g
    rot_cnt = 0
    while not (a > 0 and b >= 0):
        a, b = -b, a
        rot_cnt += 1
    mp[(a,b)][rot_cnt%2] += 1
ans = 1
for s, t in mp.values():
    now = (pow(2, s, mod) + pow(2, t, mod) - 1) % mod
    ans = (ans * now) % mod
ans = (ans - 1 + zerozero) % mod 
print(ans)

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

int main()
{
ll num=26;
string a ;
cin >> a ;
vector<ll> ans;
bool r[num]={};
ll dp[a.size()]={};
ll sy=0;
ll le=1;
for (ll i = a.size()-1; i >=0 ; i--)
{
  dp[i]=le;
  if(!r[a[i]-'a']){r[a[i]-'a']=1;sy++;}
  if(sy==num){
    rep(j,num)r[j]=0;
    sy=0;
    le++;
  }
}
char c='a';
bool ok=1;
rep(j,num)r[j]=0;
rep(i,a.size()){
  if(le!=dp[i]){
    le=dp[i];
    ok=0;
    rep(j,num){
      if(!r[j]){ans.push_back(j);
      c='a'+j;
      break;}
    }
    rep(j,num)r[j]=0;
  }

  if(ok){
    r[a[i]-'a']=1;
  }
  if(a[i]==c&&!ok){
    ok=1;
  }
}
rep(j,num){
  if(!r[j]){ans.push_back(j);
  break;}
}

rep(i,ans.size()){
  char c='a'+ans[i];
  cout << c;
}
  cout << endl;

return 0;
}


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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;


signed main(){
	while(true){
		int r; cin >> r;
		if(r == 0)break;
		vector<int> a(r+1, -(int)1e9);
		a[0] = 0;
		int dx[] = {-1,0,1,0};
		int dy[] = {0,1,0,-1};
		{
			int w,h,x,y;cin >> w >> h >> x >> y;
			vector<vector<int> > m(h+2,vector<int>(w+2,-(int)1e9));
			for(int i = 1; i <= h; i++)for(int j = 1; j <= w; j++){
				cin >> m[i][j];
				m[i][j] *= -1;
			}
			priority_queue<pair<int, pair<int, int> > > p;
			vector<vector<bool> > used(h+2, vector<bool>(w+2));
			p.push({m[y][x],{y,x}});
			used[y][x] = true;
			int c = 0;
			while(!p.empty()){
				auto tmp = p.top();
				c++;
				a[c] = tmp.first;
				if(c >= r)break;
				p.pop();
				for(int i = 0; i < 4; i++){
					int nextx = tmp.second.second+dx[i];
					int nexty = tmp.second.first+dy[i];
					if(0 < nextx && nextx <= w && 0 < nexty && nexty <= h){
					if(!used[nexty][nextx]){
						used[nexty][nextx] = true;
						p.push({min(tmp.first,m[nexty][nextx]),{nexty,nextx}});
					}
					}
				}
			}
		}
		vector<int> b(r+1, -(int)1e9);
		b[0] = 0;
		{
			int w,h,x,y;cin >> w >> h >> x >> y;
			vector<vector<int> > m(h+2,vector<int>(w+2,-(int)1e9));
			for(int i = 1; i <= h; i++)for(int j = 1; j <= w; j++){
				cin >> m[i][j];
				m[i][j] *= -1;
			}
			priority_queue<pair<int, pair<int, int> > > p;
			vector<vector<bool> > used(h+2, vector<bool>(w+2));
			p.push({m[y][x],{y,x}});
			used[y][x] = true;
			int c = 0;
			while(!p.empty()){
				auto tmp = p.top();
				c++;
				b[c] = tmp.first;
				if(c >= r)break;
				p.pop();
				for(int i = 0; i < 4; i++){
					int nextx = tmp.second.second+dx[i];
					int nexty = tmp.second.first+dy[i];
					if(0 < nextx && nextx <= w && 0 < nexty && nexty <= h){
						if(!used[nexty][nextx]){
							used[nexty][nextx] = true;
							p.push({min(tmp.first,m[nexty][nextx]),{nexty,nextx}});
						}
					}
				}
			}
		}
//		for(auto e : a)cerr << e << " ";
//		cerr << endl;
//		for(auto e : b)cerr << e << " ";
//		cerr << endl;
		int ans = -(int)1e9;
		for(int i = 0; i <= r; i++){
			ans = max(ans,a[i]+b[r-i]);
		}
		cout << (-ans) << endl;
	}


	return 0;
}




Measured memory_bytes: 5048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int ia = int.Parse(sS[0]);
            int ib = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sa = ia.ToString();
            string sb = ib.ToString();
            sa = new string(sa[0], ib);
            sb = new string(sb[0], ia);
            string sOut = sa;
            if (sa.CompareTo(sb) > 0) { sOut = sb; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11488
package main

import (
	"fmt"
)

func min(n ...int) int {
	ans := n[0]
	for _, v := range n {
		if v < ans {
			ans = v
		}
	}
	return ans
}

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)

	if x < y {
		fmt.Println(min(a*x+b*y, 2*y*c, 2*x*c+(y-x)*b))
	} else {
		fmt.Println(min(a*x+b*y, 2*x*c, 2*y*c+(x-y)*a))
	}
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll z(ll a){
  if(a<0)return -a;
  return a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;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;
  }
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(void){
  int a;
  scanf("%d",&a);
  for(int i=1;i<=50000;i++){
    int j=i*1.08;
    if(j==a){
      PRN(i);
      return 0;
    }
  }
  PRS(":(");
  return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> x;
	if (x>=30) s = "Yes";
	else s = "No";

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

vector<int> to[200005]; // グラフ用のvector

mint dfs(int v) {
    mint res = 1;
    for (int u: to[v]) {
        res *= dfs(u);
    }
    return res + 1; // res: vを1で塗った場合 1: vを0で塗った場合。
}

int main(){
    int N;
    cin >> N;
    vector<P> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(all(p));

    set<P> s; // x座標と頂点番号のpair。残っているものが根にあたる
    for (int i=N-1;i>=0;--i) {
        int x = p[i].first, d = p[i].second;
        while (s.size() && s.begin()->first < x + d) {
            to[i].push_back(s.begin()->second);
            s.erase(s.begin());
        }
        s.emplace(x, i);
    }

    mint ans = 1;
    for (auto x: s) {
        int v = x.second;
        ans *= dfs(v);
    }

    cout << ans.x << endl;
}

Measured memory_bytes: 22272
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def assign_color():
    _id = 1
    for m in range(vertices_num):
        if vertices_status_list[m] == -1:
            graph_dfs(m, _id)
            _id += 1
    return None


def graph_dfs(vertex, color):
    vertices_stack = list()
    vertices_stack.append(vertex)
    vertices_status_list[vertex] = color
    while vertices_stack:
        current_vertex = vertices_stack[-1]
        vertices_stack.pop()
        for v in adj_list[current_vertex]:
            if vertices_status_list[v] == -1:
                vertices_status_list[v] = color
                vertices_stack.append(v)
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num, relation_num = map(int, _input[0].split())

    relation_info = _input[1:relation_num + 1]

    question_num = int(_input[relation_num + 1])
    question_list = _input[relation_num + 2:]

    adj_list = tuple([] for _ in range(vertices_num))
    vertices_status_list = [-1] * vertices_num

    for relation in relation_info:
        key, value = map(int, relation.split())
        adj_list[key].append(value)
        adj_list[value].append(key)

    assign_color()

    # print(adj_list)
    for question in question_list:
        start, target = map(int, question.split())
        if vertices_status_list[start] == vertices_status_list[target]:
            print("yes")
        else:
            print("no")

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

 
  if (N % 1110 < 10) {
    cout << "Yes" << endl;
  } else if (N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<int> pre, suf, op;
    int crt = 1;
    while (N > 0) {
    	if (N % 2 == 1) {
    		// (N - 1) / 2
    		op.push_back(1);
    		N = (N - 1) / 2;
    	}
    	else {
    		// N - 1
    		op.push_back(0);
    		N--;
    	}
    }
    for (int i = 0;i < op.size() / 2;i++) swap(op[i], op[op.size() - i - 1]);
    for (int i = 0;i < op.size();i++) {
        if (op[i] == 1) {
            pre.push_back(crt);
            suf.push_back(crt);
        }
        else {
            pre.insert(pre.begin(), crt);
            suf.push_back(crt);
        }
        crt++;
    }
    for (int i = 0;i < suf.size();i++) pre.push_back(suf[i]);
    cout << pre.size() << endl;
    for (int i = 0;i < pre.size();i++) {
    	if (i != 0) cout << ' ';
    	cout << pre[i];
    }
    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int LGA = 60;

int main(){
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    ll a[n];
    ll f = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        f ^= a[i];
    }

    for (int i = 0; i < n; i++) {
        a[i] &= ~f;
    }

    ll bs[LGA] = {0};
    for (int i = 0; i < n; i++) {
        for (int j = LGA - 1; j >= 0; j--) {
            if (a[i] >> j & 1) {
                a[i] ^= bs[j];
            }
        }

        for (int j = LGA - 1; j >= 0; j--) {
            if (a[i] >> j & 1) {
                bs[j] = a[i];
                break;
            }
        }
    }

    ll ans = 0;
    for (int i = LGA - 1; i >= 0; i--) {
        if ((ans ^ bs[i]) > ans) {
            ans ^= bs[i];
        }
    }
    ans = ans * 2 + f;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
int main(){
    int N, W;
    cin >> N >> W;
    vector<ll> dp(W + 1);
    fop(i,0,N){
        int w, v;
        cin >> w >> v;
        for (int j = W; j >= w; --j)
            dp[j] = max(dp[j],dp[j - w]+v);
    }
    cout << dp[W] << endl;
}



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

int n, k, r, s, p;
string t;

int main() {
    cin >> n >> k >> r >> s >> p >> t;
    int ans = 0;
    for (int i = 0; i < k; i++) {
        int max_k = (n - i + k - 1) / k;
        // dp[i][j]:j-1番目にiをだす
        vector<vector<int>> dp(3, vector<int>(max_k + 1, 0));
        for (int j = 0; j < max_k; j++) {
            dp[0][j + 1] =
                max(dp[1][j], dp[2][j]) + (t[i + j * k] == 's' ? r : 0);
            dp[1][j + 1] =
                max(dp[2][j], dp[0][j]) + (t[i + j * k] == 'p' ? s : 0);
            dp[2][j + 1] =
                max(dp[0][j], dp[1][j]) + (t[i + j * k] == 'r' ? p : 0);
        }
        ans += max({dp[0][max_k], dp[1][max_k], dp[2][max_k]});
    }
    cout << ans << endl;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

LL x , k , d;
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> x >> k >> d;
    x = ABS(x);

    LL moves = x/d;
    moves = min(moves,k);

    x = x - moves * d;
    k = k - moves;

    if(k % 2 == 1){
        x = x - d;
        x = ABS(x);
    }
    cout << x << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


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

int main() {
    //
    string str;
    vector<string> vec(4);
    vec = {"remaerd", "maerd", "resare", "esare"};

    cin >> str;

    reverse(str.begin(), str.end());

    bool chk = true;
    bool kekka = false;
    int index = 0;
    while (chk == true) {
        if (str.size() - index >= 7) {
            if (str.substr(index, 7) == vec.at(0)) {
                index += 7;
                continue;
            }
        }

        if (str.size() - index >= 6) {
            if (str.substr(index, 6) == vec.at(2)) {
                index += 6;
                continue;
            }
        }

        if (str.size() - index >= 5) {
            if (str.substr(index, 5) == vec.at(1)) {
                index += 5;
                continue;
            } else if (str.substr(index, 5) == vec.at(3)) {
                index += 5;
                continue;
            }
        }

        if (index == str.size()) {
            chk = false;
            kekka = true;
        }

        // 見つからなかったら終わり
        chk = false;
    }

    if (kekka == true)
        cout << "YES";
    else
        cout << "NO";
    //
}


Measured memory_bytes: 3720
#include <stdio.h>
int main(void){
    char c[11];
    int n,k,i,m;
    
    scanf("%d",&n);
    scanf("%s",c);
    scanf("%d",&k);
    
    m=c[k-1];
    
    for(i=0;i<n;i++){
        if(c[i]!=m){
            c[i]='*';
        }
        printf("%c",c[i]);
    }
    
}



Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#define N 100010
using namespace std;
typedef long long LL;
int n,a[N],x,y,cnt;
bool cmp(int p,int q){
	return p>q;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	int i=1;
	while(i<n){
		if(a[i]==a[i+1]){
			cnt++;
			i++;
			if(cnt==1)x=a[i];
			else {
				y=a[i];
				break;
			}
		}
		i++;
	}
	cout<<(LL)x*y<<'\n';
}

Measured memory_bytes: 640
A, B, C = [int(_) for _ in input().split()]

a_0 = A % B
a_log = set()

a = a_0
while True:
    if a == C:
        print("YES")
        break
    else:
        if a in a_log:
            print("NO")
            break
        else:
            a_log.add(a)
            a = (a + a_0) % B

Measured memory_bytes: 2940
def main():
    def digit(x, n):
        x_tmp = x
        res = ''
        while x_tmp > 0:
            res += str(x_tmp % n)
            x_tmp = int(x_tmp/n)
        return len(res)

    n, k = map(int, input().split())

    print(digit(n, k))



if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef pair<int,int> p;

#define MAX 100000

bool visited[MAX+1];
int H[MAX+1];
vector<p> Hv;
vector<int> edge[MAX+1];
int main(void){
  int N,M;
  cin >> N >> M;
  for(int i=1;i<=N;i++){
    int h;
    cin >> h;
    H[i] = h;
    Hv.push_back(make_pair(h,i));
    visited[i] = true;
  }
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  //sort
  sort(Hv.begin(),Hv.end(),greater<p>());
  int visitNum = 0;
  int ans = 0;
  for(int i=0;i<Hv.size();i++){
    int pos = Hv[i].second;
    int hight = Hv[i].first;
    if(visitNum >= N){
      break;
    }
    if(visited[pos]){
      // 良いか?
      bool flag = true;
      for(int n=0;n<edge[pos].size();n++){
	// 枝の先のやつ
	int eV = edge[pos][n];
	int eVh = H[eV];
	if(eVh >= hight){
	  flag = false;
	  break;
	}
      }
      // flag = true 良い
      if(flag){
	ans = ans + 1;
	//枝の先は絶対に悪い
	for(int n=0;n<edge[pos].size();n++){
	  int eV = edge[pos][n];
	  if(visited[eV]){
	    visitNum++;
	  }
	  visited[eV] = false;
	}
      }
      //調べたので
      visited[pos] = false;
      visitNum++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9596
def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7
N, M = inpl()
S = [0] + inpl()
T = [0] + inpl()

DP = [[1]*(N+1) for _ in range(M+1)]

for i in range(1, M+1):
    for j in range(1, N+1):
        if S[j] == T[i]:
            DP[i][j] = (DP[i][j-1] + DP[i-1][j])%MOD
        else:
            DP[i][j] = (DP[i][j-1] + DP[i-1][j] - DP[i-1][j-1])%MOD
print(DP[-1][-1])

Measured memory_bytes: 72924
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

typedef double Real;

Real EPS = 1e-8;

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }
  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
};

struct circle{
  Point p;
  Real r;
  circle(){}
  circle(Point p, Real r) : p(p) , r(r){}
};

circle circumscribedCircle(Point p, Point q, Point r){
  Point a,b,c;
  a=(q-p)*2,b=(r-p)*2;
  c.x=p.dot(p)-q.dot(q);  
  c.y=p.dot(p)-r.dot(r);
  circle res;
  res.p.x=a.y*c.y-b.y*c.x;
  res.p.y=b.x*c.x-a.x*c.y;
  res.p=res.p/a.cross(b);
  return circle(res.p, p.dist(res.p));
}

int main(void){
  int n;
  cin >> n;
  while(n--){
    vector<Point>v(3);
    for(int i=0;i<3;i++)
      cin >> v[i].x >> v[i].y;

    circle res=circumscribedCircle(v[0],v[1],v[2]);
    printf("%.3f %.3f %.3f",res.p.x,res.p.y,res.r);
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1276
// Template
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

int main() {
    ll n;
    cin >> n;
    
    ll m = 2 * n;
    ll ans = m - 1;
    vector<ll> vec0(2), vec1(2);
    vec0[0] = 1;
    vec0[1] = 0;
    for (ll i = 2; i * i <= m; ++i) {
        if (m % i) continue;
        vec1[0] = i;
        vec1[1] = m / i;
        auto p = crt(vec0, vec1);
        if (p.first != 0) chmin(ans, p.first - 1);
        vec1[0] = m / i;
        vec1[1] = i;
        p = crt(vec0, vec1);
        if (p.first != 0) chmin(ans, p.first - 1);
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 3708
#include <stdio.h>
#include <math.h>

int main(){

    double x1,y1,x2,y2,x,y,d;

    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

    x = x2 - x1;
    y = y2 - y1;
    x = fabs(x);
    y = fabs(y);

    x = x * x;
    y = y * y;

    d = sqrt(x+y);

    printf("%lf\n", d);

    return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

int ps[10000000] = {0};
using namespace std;

int main(){
    vector<int> primes;
    vector<bool> ok(10000001,true);
    FOR(i,2,9999999){
	for(int j=2;j*i<=10000000;j++){
	    ok[j*i] = false;
	}
	/*
	bool flg = true;
	for(int j=0;primes[j]*primes[j]<=i;j++){
	    if(i % primes[j] == 0){
		flg = false;
		break;
	    }
	}
	if(flg){
	    primes.PB(i);
	}
	*/
    }
    ok[0] = false;
    ok[1] = false;
    REP(i,10000001){
	if(ok[i])
	    primes.PB(i);
    }
    int d[] = {8,6,2,0};
    while(true){
	int n;
	cin >> n;
	if(n==0) break;
	int p = upper_bound(ALL(primes),n) - primes.begin();
	RREP(i,p+1){
	    if(primes[i]>n) continue;
	    if(i>=3){
		if(primes[i]==(primes[i-1]+d[2])&&primes[i]==(primes[i-2]+d[1])&&primes[i]==(primes[i-3]+d[0])){
		    cout << primes[i] << endl;
		    break;
		}
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 7340
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 1e6;

//head

int h, w;
int h_, w_;
int mat[500][500];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> h >> w >> h_ >> w_;
  if(h%h_ == 0 and w%w_ == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    if(h%h_) {
      rep(i, h) rep(j, w) {
        if(i%h_ == h_-1) {
          mat[i][j] = -N*(h_-1)-1;
        } else {
          mat[i][j] = N;
        }
      }
    } else {
      rep(i, h) rep(j, w) {
        if(j%w_ == w_-1) {
          mat[i][j] = -N*(w_-1)-1;
        } else {
          mat[i][j] = N;
        }
      }
    }
    rep(i, h) rep(j, w) {
      cout << mat[i][j] << (j == w-1?'\n':' ');
    }
  }
}

Measured memory_bytes: 4628
class dice:
    def __init__(self,label):
        self.spots = label

    def roll(self,way):
        if way == "N":
            self.spots = [self.spots[1],self.spots[5],self.spots[2],self.spots[3],self.spots[0],self.spots[4]]
        if way == "E":
            self.spots = [self.spots[3],self.spots[1],self.spots[0],self.spots[5],self.spots[4],self.spots[2]]
        if way == "W":
            self.spots = [self.spots[2],self.spots[1],self.spots[5],self.spots[0],self.spots[4],self.spots[3]]
        if way == "S":
            self.spots = [self.spots[4],self.spots[0],self.spots[2],self.spots[3],self.spots[5],self.spots[1]]
    def output(self):
        return self.spots

dice_set=[]
dice_same=0


for l in range(int(input())):
    dice_set.append(list(map(int,input().split())))


for m in range(len(dice_set)):
    dice_list=[]       

    label = dice_set[m]
    rotation = dice(label)
    for i in range(3):
        dice_list.append(rotation.output())
        for j in range(3):
            rotation.roll("E")
            dice_list.append(rotation.output())
        rotation.roll("N")

    rotation.roll("N")
    rotation.roll("N")

    for i in range(3):
        dice_list.append(rotation.output())
        for j in range(3):
            rotation.roll("W")
            dice_list.append(rotation.output())
        rotation.roll("N")

    for n in range(m+1,len(dice_set)):
        if dice_set[n] in dice_list:
            dice_same += 1

if dice_same == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7676
#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <cstdio>
#include <utility>
#include <bitset>
#include <complex>
#include <stack>
#include <tuple>

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

const int INF = 1e7;
int main(){
	int N,M;
	cin >> N >> M;
	vector<vector<int>> dist(N,vector<int>(N,INF));
	vector<T> in(M);
	for(int i=0;i<M;i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--;
		dist[a][b]=c;
		dist[b][a]=c;
		in[i]=T(a,b,c);
	}
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
				if(i==j)
					dist[i][j]=0;
				else
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	}
	int ans=0;
	for(int i=0;i<M;i++){
		int a,b,c;
		tie(a,b,c)=in[i];
		if(dist[a][b]!=c)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256