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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pii> ans;
    int amin = 9999999;
    int amin_index = 0;
    int amax = -9999999;
    int amax_index = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(amin>a[i]){amin = a[i]; amin_index = i;}
        if(amax<a[i]){amax = a[i]; amax_index = i;}
    }
    bool IsAllPositive;
    if((ll)amin*amax<0){
        if(-1*amin<amax){
            for(int i = 0; i < n; i++){
                if(a[i]<0){
                    a[i] += amax;
                    ans.push_back({amax_index+1,i+1});
                }
            }
            IsAllPositive = true;
        }else{
            for(int i = 0; i < n; i++){
                if(a[i]>0){
                    a[i] += amin;
                    ans.push_back({amin_index+1,i+1});
                }
            }
            IsAllPositive = false;
        }
    }else{
        IsAllPositive = true;
        for(int i = 0; i < n; i++){
            if(a[i]>0){IsAllPositive = true; break;}
            else if(a[i]<0){IsAllPositive = false; break;}
        }
    }
    if(IsAllPositive){
        for(int i = 0; i < n-1; i++){
            a[i+1] += a[i];
            ans.push_back({i+1,i+2});
        }
    }else{
        for(int i = 0; i < n-1; i++){
            a[n-2-i] += a[n-1-i];
            ans.push_back({n-i,n-1-i});
        }
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N,hako,ans;
    cin >> N;

    hako = N;

    hako /= 100;

    ans = hako * 111;

    if(ans >= N)
        cout << ans << endl;
    else
    {
        cout << (hako + 1) * 111 << endl;
    }
    

    

}

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

int main()
{
  int N, K;
  std::cin >> N >> K;
  std::map<int, int> types;
  for(int i = 0; i < N; i++) {
    int a;
    std::cin >> a;
    auto checkTypes = types.find(a);
    if(checkTypes == types.end()) {
      types.insert(std::make_pair(a, 1));
    } else {
      checkTypes->second++;
    }
  }

  int answer = 0;
  std::vector<std::pair<int, int>> typesV(types.begin(), types.end());
  std::sort(typesV.begin(), typesV.end(), [](std::pair<int, int> a, std::pair<int, int> b){return a.second > b.second;});
  for(int i = 0; i < static_cast<int>(typesV.size()) - K; i++) {
    answer += (typesV.end() - i - 1)->second;
  }
  std::cout << answer << std::endl;
  return 0;
}


Measured memory_bytes: 11136
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int shihab;
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
    //  FI(); /// skip this line for compile
    string s;
    int cnt=0,mx=0;
    cin >> s;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='R')
            cnt++;
        else
        {
            if(cnt>mx)
                mx = cnt;

            cnt = 0;
        }
    }
    if(cnt>mx)
        mx = cnt;
    cout << mx << endl;
    return 0;
    //code end
}
//okbye


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}

template<typename T>
void vvdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        vdeb(da[i]);
    }
}

ll gg(int x){
    return (ll)x*(x-1)/2;
}

int main(){
    string s;
    cin >> s;
    int n = s.size() + 1;
    vector<pair<int,bool>> da(1);
    da[0].first = 0;
    da[0].second = true;
    int now = 1;
    rip(i,n-1,1){
        if(s[i]==s[i-1]){
            now++;
        }
        else{
            da.push_back(make_pair(now,s[i-1]=='<'));
            now=1;
        }
    }
    da.push_back(make_pair(now,s[n-2]=='<'));
    da.push_back(make_pair(0,false));
    int m = da.size();
    ll ans = 0;
    rip(i,m-1,0){
        if(da[i].second && !da[i+1].second){
            ans +=(ll) gg(da[i].first)+gg(da[i+1].first);
            ans += max(da[i].first,da[i+1].first);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3068
N, K = map(int, input().split())
S = input()

if S[K-1] == "A":
  print(S[:K-1] + "a" + S[K:])
elif S[K-1] == "B":
  print(S[:K-1] + "b" + S[K:])
else:
  print(S[:K-1] + "c" + S[K:])

Measured memory_bytes: 38384
N = int(input())
S = input()
T = input()
MOD = 10**9+7

ans = 3
if S[0] != T[0]:
    ans *= 2
for s1,t1,s2,t2 in zip(S,T,S[1:],T[1:]):
    if s1==s2 and t1==t2: continue
    if s1==t1:
        if s2==t2:
            ans *= 2
        else:
            ans *= 2
    else:
        if s2==t2:
            ans *= 1
        else:
            ans *= 3
print(ans%MOD)

Measured memory_bytes: 9120
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;
const int N = 200000 + 50;
vector<int> V[N];
int arr[N];
int n;
LL cache[N];

LL solve(int idx)
{
	if (idx == n + 1)
		return 1;
	LL &ans = cache[idx];
	if (ans != -1)
		return ans;
	int who = arr[idx];
	ans = 0;
	if (lower_bound(V[who].begin(), V[who].end(), idx + 1) != V[who].end()){
		if ((*(lower_bound(V[who].begin(), V[who].end(), idx + 1))) != idx + 1)
			ans = solve(*(lower_bound(V[who].begin(), V[who].end(), idx + 1)));
	}
	ans = (ans + solve(idx + 1)) % MOD;
	return ans;
}

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

    cin >> n;
    for (int i = 1; i <= n; i++)
    	cin >> arr[i];
    
    for (int i = 1; i <= n; i++){
    	V[arr[i]].PB(i);
    }

    memset(cache, -1, sizeof(cache));
    cout << solve(1) << endl;

	return 0;
}

Measured memory_bytes: 19840
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
     long long int a,b,k,sum=0,i;
     cin>>a;
     for(i=1;i<=a;i++)
     {
          if(i%3==0 || i%5==0)
          {
              continue;
          }
            else{sum=sum+i;}
     }
     cout<<sum<<endl;
     return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n, k; cin >> n >> k;
    int ans = 0;
    bool conti = true;
    while(conti){
        if(n / (int)pow(k, ans) == 0){
            conti = false;
        }else{
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

void swap_in_order(int *a, int *b, int *c)
{
    swap(*a, *b);
    swap(*a, *c);
}

int main()
{   
    int a, b, c;
    cin>>a>>b>>c;
    swap_in_order(&a, &b, &c);
    cout<<a<<" "<<b<<" "<<c;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;


using Graph = vector<vector<int>>;//グラフ型
void dfs(const Graph& G, int v/*根*/, vector<bool>& seen) {
	seen[v] = true;  //vを訪問済にする
	for (auto next_v : G[v]) { //訪問済にしたvとつながっている場所を順番に探す
		if (seen[next_v]) continue; //もし探索済みならスルー
		dfs(G, next_v, seen); //再帰的に探索
	}
}

void bfs(const Graph& G, queue<int>& que/*発見したが訪問はしていない*/, vector<int>& dist/*開始地点からの距離*/) {
	
	while (!que.empty()) {
		int v = que.front();//queのうち先頭のものからスタート
		que.pop();//先頭を削除

		for (int nv : G[v]) {//vとつながっている点を列挙
			if (dist[nv] != -1) continue;//発見済(=距離が格納されている)であればスルー
			dist[nv] = dist[v] + 1;//vとつながっている点に距離の情報を追加
			que.push(nv);//vとつながっている点を発見済にする
		}
	}
}

int main(void) {
	string q;
	cin >> q;
	bool ok = true;

	vector<char> s(q.length());
	for (int i = 0; i < q.length(); ++i) {
		s[i] = q[i];
	}

	int n = s.size();

	for (int i = 0, j = n - 1; i < n/2; ++i, --j) {
		if (s[i] != s[j]) {
			cout << "No";
			return 0;
		}
	}
	for (int i = 0, j = (n - 1) / 2 - 1; i < j; ++i, --j) {
		if (s[i] != s[j]) {
			cout << "No";
			return 0;
		}
	}
	for (int i = (n + 3) / 2 - 1, j = n - 1; i < j; ++i, --j) {
		if (s[i] != s[j]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1;
int a[maxn],st1[maxn],st2[maxn];
struct node{
    int cnt,id;
}has1[maxn],has2[maxn];;
int cmp(node a,node  b){
    return a.cnt == b.cnt ? a.id < b.id : a.cnt < b.cnt;
}
int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int len1 = 0,len2 = 0;
    for (int j = 0; j < n; j += 2) {
        st1[len1++] = a[j];
    }
    for (int j = 1; j < n; j += 2) {
        st2[len2++] = a[j];
    }
    sort(st1,st1+len1); sort(st2,st2+len2);
    for (int j = 0; j < len1; j++) {
        has1[st1[j]].cnt++;
        has1[st1[j]].id = st1[j];
    }
    sort(has1,has1+maxn,cmp);
    for (int j = 0; j < len2; ++j) {
        has2[st2[j]].cnt++;
        has2[st2[j]].id = st2[j];
    }
    sort(has2,has2+maxn,cmp);
  //  cout << has1[maxn-1].id << ' ' << has2[maxn-1].id << endl;
    if (has1[maxn-1].id == has2[maxn-1].id){
        int now1 = len1 - has1[maxn-2].cnt + len2 - has2[maxn-1].cnt;
        int now2 = len2 - has2[maxn-2].cnt + len1 - has1[maxn-1].cnt;
        if (now1 > now2){
            cout << now2 << endl;
        } else{
            cout << now1 << endl;
        }
    }else{
        cout << len1-has1[maxn-1].cnt + len2 - has2[maxn-1].cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,w;
    string s;
    cin >> n >> w;
    rep(i,n){
        cin >> s;
        cout << s << endl << s << endl;
    }
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        double w = sc.nextDouble();
        double h = sc.nextDouble();
        double x = sc.nextDouble();
        double y = sc.nextDouble();
        double s = w * h;
        // double res1 = x * h;
        // double res2 = y * w;
        // double ans = Math.max(Math.min(res1, s - res1), Math.min(res2, s - res2));
        // if (x == 0 || y == 0 || x == w || y == h) {
        // ans = Math.max(ans, s / 2);
        // }
        double ans = s / 2;
        System.out.printf("%.9f ", ans);
        if (x == w / 2 && y == h / 2) {
            System.out.println(1);
            return;
        }
        System.out.println(0);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23124
#include <iostream>
//#include <string>
//#include <iomanip>

using namespace std;
//#define

int main() {
	int tyukan,kimatu,saisi;
	while(1){
		cin >> tyukan >> kimatu >> saisi;
		if(tyukan == -1 && kimatu == -1 && saisi == -1){
			break;
		}

		int total = tyukan + kimatu;

		if( tyukan == -1 | kimatu == -1 ){
			cout << "F\n";
		} else if( total >= 80 ){
			cout << "A\n";
		} else if( total >= 65 ){
			cout << "B\n";
		} else if( total >= 50 ){
			cout << "C\n";
		}  else if( total >= 30 ){
			if(saisi >= 50){
				cout << "C\n";
			} else {
				cout << "D\n";
			}
		} else {
			cout << "F\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1120
#include<stdio.h>

#define MAX 10000
#define NIL -1

typedef struct{
  int p,l,r;
}Node;

Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }

  for(i=0;i<n;i++){
    if(T[i] .p==NIL)root=i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2004
s=input()
li=list(s)

i=0
j=len(s)-1
answer=0

while i<j:
    if li[i]==li[j]:
        i+=1
        j-=1
    else:
        if li[i]!="x" and li[j]!="x":
            answer=-1
            break
        elif li[i]=="x" and li[j]!="x":
            answer+=1
            i+=1
        elif li[i]!="x" and li[j]=="x":
            answer+=1
            j-=1

print(answer)


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

int main() {
    int a,b,c; cin >> a >> b >> c;
    if(b+c<=a){
        cout << 0 << endl;
    }
    else cout << b+c-a << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class main {
	public static void Main(string[] args) {
		for(int i=0; i<9; i++) {
			var input = Console.ReadLine().Split();
			int a = int.Parse(input[1]);
			int b = int.Parse(input[2]);
			Console.WriteLine("{0} {1} {2}", input[0], a+b, a*200+b*300);
		}
	}
}

Measured memory_bytes: 5624
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>
#define INF 1001001001
#define OUT 1234567
#define EPS 1e-8
#define x first
#define y second

using namespace std;
typedef vector<int> vint;
typedef vector<vint>  vvint;
typedef pair<int,int> pint;
typedef long long Int;
typedef pair<double,double> pt;
typedef pair<pair<double,pt>,pair<double,pt> > ans;

double pi=3.14159265358979;
double len(pt a){
	return hypot(a.x,a.y);
}
int cross(pt a,pt b){
	return (a.x*b.y-a.y*b.x);
}
int naiseki(pt a,pt b,pt c){
	b.x-=a.x;
	b.y-=a.y;
	c.x-=a.x;
	c.y-=a.y;
	return (b.x*c.x+b.y*c.y);
}
int ccw(pt a,pt b,pt c){
	b.x-=a.x;
	b.y-=a.y;
	c.x-=a.x;
	c.y-=a.y;
	if(cross(b,c)>0) return 1;
	if(cross(b,c)<0) return -1;
	return 0;
}
int ccw2(pt a,pt b,pt c){
	b.x-=a.x;
	b.y-=a.y;
	c.x-=a.x;
	c.y-=a.y;
	if((b.x*c.y-b.y*c.x)>0) return 1;
	if((b.x*c.y-b.y*c.x)<0) return -1;
	if((b.x*c.x+b.y*c.y)<0) return 2;
	if(len(b)<len(c)) return -2;
	return 0;
}
int kousa(pt s,pt e,pt p,pt q){
	if(ccw(s,e,p)==0 && ccw(p,q,s)==0) return 0;
	return (ccw(s,e,p)*ccw(s,e,q)<=0 && ccw(p,q,s)*ccw(p,q,e)<=0);
}
bool line(pt a,pt b,pt c){
	if(ccw2(a,b,c)==-2 || ccw2(c,b,a)==-2) return 1;
	return 0;
}
double kyori_(pt s,pt e,pt p){
	e.x-=s.x;
	e.y-=s.y;
	p.x-=s.x;
	p.y-=s.y;
	if(len(e)<=0) return 0;
	return abs((double)cross(e,p))/len(e);
}
double kyori(pt s,pt e,pt p,pt q){
	double ans=INF;
	if(naiseki(s,e,p)>0 && naiseki(e,s,p)>0) ans=min(ans,kyori_(s,e,p));
	if(naiseki(s,e,q)>0 && naiseki(e,s,q)>0) ans=min(ans,kyori_(s,e,q));
	if(naiseki(p,q,s)>0 && naiseki(q,p,s)>0) ans=min(ans,kyori_(p,q,s));
	if(naiseki(p,q,e)>0 && naiseki(q,p,e)>0) ans=min(ans,kyori_(p,q,e));
	ans=min(ans,hypot(p.x-s.x,p.y-s.y));
	ans=min(ans,hypot(p.x-e.x,p.y-e.y));
	ans=min(ans,hypot(q.x-s.x,q.y-s.y));
	ans=min(ans,hypot(q.x-e.x,q.y-e.y));
	return ans;
}
		
int main(){
	int n;
	while(cin >> n){
		if(n==0) break;
		
		double ans = 1234.5;
		pt s,e,p,q,r,t;
		scanf("%lf %lf %lf %lf",&s.x,&s.y,&e.x,&e.y);
		int h;
		
		int i,j;
		for(i=0;i<n;i++){
			scanf("%lf %lf %lf %lf %d",&p.x,&p.y,&r.x,&r.y,&h);
			q=pt(p.x,r.y);
			t=pt(r.x,p.y);
			
			if(p.x<=s.x && s.x<=r.x && p.y<=s.y && s.y<=r.y) ans=0;
			if(p.x<=e.x && e.x<=r.x && p.y<=e.y && e.y<=r.y) ans=0;
			
			if(kousa(s,e,p,q)) ans=0;
			if(kousa(s,e,q,r)) ans=0;
			if(kousa(s,e,r,t)) ans=0;
			if(kousa(s,e,t,p)) ans=0;
			
			double minl=INF;
			minl=min(minl,kyori(s,e,p,q));
			minl=min(minl,kyori(s,e,q,r));
			minl=min(minl,kyori(s,e,r,t));
			minl=min(minl,kyori(s,e,t,p));
			
			if(minl<(double)h) ans=min(ans,minl);
			else ans=min(ans,(minl*minl+(double)h*h)/(2.0*(double)h));
//			cout << ans << endl;
		}
		
		printf("%.5lf\n",ans);
	}
	
	return 0;
}

				
				
				
				
		

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll n,y;
  cin>>n;
  y = n % 11;
  if(y > 0 && y < 7){
    cout<<(n / 11) * 2 + 1 <<"\n";
  }else if(y == 0){
    cout<<n / 11 * 2 <<"\n";
  }else{
    cout<<(n / 11) * 2 + 2<<"\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  bool flag = true;
  if (c < d)
  {
    for (int i = b - 1; i < d - 1; ++i)
    {
      if (s[i] == '#' && s[i + 1] == '#')
        flag = false;
    }
    s[d - 1] = '#';
    for (int i = a - 1; i < c - 1; ++i)
    {
      if (s[i] == '#' && s[i + 1] == '#')
        flag = false;
    }
  }
  else
  {
    int itr = b - 1;
    for (int i = b - 2; i < d - 1; ++i)
    {
      if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
        itr = i + 1;
    }
    s[itr] = '#';
    for (int i = a - 1; i < c - 1; ++i)
    {
      if (s[i] == '#' && s[i + 1] == '#')
        flag = false;
    }
    s[c - 1] = '#';
    s[itr] = '.';
    for (int i = b - 1; i < d - 1; ++i)
    {
      if (s[i] == '#' && s[i + 1] == '#')
        flag = false;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
const long long INF=1e18;
typedef pair<ll,ll> pll;
#define F first
#define S second



int main(){
  ll r,s,p;
  cin>>r>>s>>p;
  vector<ll> A(p);
  for(int i=0;i<p;i++){
    ll x,y;
    cin>>x>>y;
    if(y<=s){y--;}
    x--;
    A[i]=abs(s-y)+r-x;
  }
  sort(A.begin(),A.end());
  for(int i=1;i<p;i++){
    A[i]=max(A[i],A[i-1]+1);
  }
  cout<<A.back()<<endl;

  
  
  return 0;
}



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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long n,k;
    cin>>n>>k;
    long count1=0;
    long count2=0;
    if(k%2==0){
        for(int i=1;i<=n;i++){
            if(i%k==0){
                count1++;
            }else if(i%k==k/2){
                count2++;
            }    
        }
    }else{
        for(int i=1;i<=n;i++){
            if(i%k==0){
                count1++;
            }
        }
    }
    cout<<count1*count1*count1+count2*count2*count2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
#define ll long long
int a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r,m,h,p[101],df[51];
string t,x,q,s;
double w;
vector<ll>dv[101],v,z;
vector<string>u;
map<string,ll>n;
set<ll>y;
void dfs(ll x){
    df[x]=1;
    for(ll i=0;i<dv[x].size();i++){
        if(dv[x][i]==0){
            dfs(dv[x][i]);
            df[dv[x][i]]=1;
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>a>>b>>c;
    if(b*c>=a){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
#define M_PI 3.14159265358979323846 
const int mod = 1e9 + 7;

int32_t main()
{
    fastio;

    int x[5];
    int ans = 0;
    for(int i=0; i<5; i++){
        int x; cin >> x;
        if(x == 0) ans = i+1;
    }

    cout << ans << endl;
    return 0;
}

/*

*/

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

double length(double x1,double y1,double x2,double y2){
  double a,b,c;
  
  if(x2>x1){
    a=x2-x1;
  }
  else{
    a=x1-x2;
  }
  if(y2>y1){
    b=y2-y1;
  }
  else{
    b=y1-y2;
  }
  c=a*a+b*b;
  c=sqrt(c);
  return(c);
}

double surface(double a,double b,double c){
  double s;

  s=(a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c);
  s=sqrt(s);
  s=s/4;
  return(s);
}

int main(void){
  double x1,y1,x2,y2,x3,y3,xp,yp;
  double len_12,len_13,len_23,len_1p,len_2p,len_3p;
  double s1,s2,s3,sc;
  double s;
  
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
    len_12=length(x1,y1,x2,y2);
    len_13=length(x1,y1,x3,y3);
    len_23=length(x2,y2,x3,y3);
    len_1p=length(x1,y1,xp,yp);
    len_2p=length(x2,y2,xp,yp);
    len_3p=length(x3,y3,xp,yp);
    s=surface(len_12,len_13,len_23);
    s1=surface(len_12,len_1p,len_2p);
    s2=surface(len_13,len_1p,len_3p);
    s3=surface(len_23,len_2p,len_3p);
    sc=s1+s2+s3;
    if((s-sc)*(s-sc)<0.00001){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }
  return(0);
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,i,u,v,m,j,s=0;cin>>n>>m;vvi g(n+1);vi vis(n+1,0);
	for(i=0;i<m;i++) cin>>u>>v>>j,g[u].eb(v),g[v].eb(u);
	for(j=1;j<=n;j++){
		if(vis[j]) continue;
		queue<ll>q;q.push(j);vis[j]=1;s++;
		while(q.size()){
			i=q.front();q.pop();for(auto j:g[i]) if(!vis[j]) q.push(j),vis[j]=1;
		}
	}cout<<s<<endl;
}


Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread(){}
template<class T1, class ...T2>
inline void qread(T1 &IEE, T2&... ls){
    register T1 __ = 0, ___ = 1;
    register char ch;
    while(!isdigit(ch = getchar())) ___ = (ch == '-') ? -___ : ___;
    do{
        __ = (__ << 1) + (__ << 3) + (ch ^ 48);
    }while(isdigit(ch = getchar()));
    __ *= ___;
    IEE = __;
    qread(ls...);
    return ;
}
double a, b, h, m, d;
int main(){
    cin >> a >> b >> h >> m;
    d = fabs(h * 30 - m * 6 + m / 2);
    while(d >= 360) d -= 360;
    if(d > 180){
        d = 360 - d;
    }
    d = d * 3.14159265358979323846264338327950288 / 180;
    printf("%.10lf", (double)sqrt(a * a + b * b - 2 * a * b * cos(d)));
    return 0;
}

Measured memory_bytes: 4224
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
   long long n;
   cin>>n;
   vector<long long> vec(n);
   rep(i,n){
       cin>>vec.at(i);
   }
   long long ans=0;
   rep(i,n){
       bool flag=true;
        for(long long j=2;j<=10000;j++){
           if(vec.at(i)%j==0&&vec.at(i)!=j){
               flag=false;
               break;
           }
       }
       if(flag){
           ans++;
       }
   }
   cout<<ans<<endl;
    
}






Measured memory_bytes: 3164
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
	llin(a);
	llin(b);
	llin(k);
	rFOR(i,1,100){
		if(a%i==0&b%i==0){
			k--;
		}
		if(k==0){
			sal(i);
			break;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

// basic euclidean
int gcd(int v1, int v2) {
	if (v1 < v2) {
		int t = v1;
		v1 = v2;
		v2 = t;
	}

	int m;
	int result = 1;
	for (;;) {
		m = v1 % v2;
		if (m == 0) {
			result = v2;
			break;
		}
		v1 = v2;
		v2 = m;
	}
	return result;
}

int main(void) {

	int N, X;
	int v;
	cin >> N >> X;

	int* pi = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> v;
		v = X - v;
		pi[i] = (v >= 0) ? v: -v;
	}

	int x = pi[0];
	for (int i = 1; i < N; i++) {
		x = gcd(x, pi[i]);
	}

	cout << x << endl;
	delete[] pi;

	return 0;
}


Measured memory_bytes: 640
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,x,a[2005],b[2005];
ll ans;
int main(){
    ans=orz*1ll*orz;
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=0;i<n;++i){
        ll res=0;
        for(int j=1;j<=n;++j)res+=a[j];
        ans=min(ans,res+x*1ll*i);
        for(int j=2;j<=n;++j)b[j]=min(a[j],a[j-1]);
        b[1]=min(a[1],a[n]);
        for(int j=1;j<=n;++j)a[j]=b[j];
    }
    printf("%lld\n",ans);
    //system("pause");
    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  if (s == "SUN") {
    cout << "7\n";
  } else if (s == "MON") {
    cout << "6\n";
  } else if (s == "TUE") {
    cout << "5\n";
  } else if (s == "WED") {
    cout << "4\n";
  } else if (s == "THU") {
    cout << "3\n";
  } else if (s == "FRI") {
    cout << "2\n";
  } else if (s == "SAT") {
    cout << "1\n";
  } else {
    cout << "Unexpected string: " << s << '\n';
    return 1;
  }
  return 0;
}


Measured memory_bytes: 256
N, P = map(int, input().split())
A = list(map(int, input().split()))

n = 0
for v in A:
  if v % 2 == 0:
    n += 1
if N == n:
  if P == 0: ans = 2 ** N
  else: ans = 0
else:
  ans = 2 ** (N-1)
print(ans)

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

    for(int i=1; i<=50000; i++){
	if(floor((double)i*1.08)==N){
	    cout << i << endl;
	    return 0;
	}
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
H = int(input())
SUM = 0
cn = 1

if H == 1:
    print(1)
    exit()

for i in range(10000):
    H = H // 2
    cn = cn + 1
    if H == 1:
        break

for i in range(cn):
    SUM = SUM + (2**i)
    
print(SUM)

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

int main(){
  
  map<string, int> mp;
  int n;
  cin >> n;
  rep(i, n){
    string s;
    cin >> s;
    if(!mp[s]) mp[s] = 1;
    else mp[s]++;
  }

  int m;
  cin >> m;
  rep(i, m){
    string s;
    cin >> s;
    if(!mp[s]) continue;
    else mp[s]--;
  }

  int ans = 0;
  for(auto p : mp){
    ans = max(ans, p.second);
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; i++)
  {
    cin >> b[i];
    b[i]--;
  }
  vector<int> ans;
  while (b.size() != 0)
  {
    bool erase = false;
    for (int i = (int)b.size() - 1; 0 <= i; i--)
      if (i == b[i])
      {
        ans.push_back(i + 1);
        b.erase(b.begin() + i);
        erase = true;
        break;
      }
    if (!erase)
    {
      cout << -1 << "\n";
      return 0;
    }
  }
  for (int i = ans.size() - 1; 0 <= i; i--)
    cout << ans[i] << "\n";

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int d;
  cin >> d;
  cout << "Christmas";
  for (; d < 25; ++d) {
    cout << " Eve";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

h,w = map(int,input().split())
sh,sw = map(int,input().split())
gh,gw = map(int,input().split())
s = [input() for _ in range(h)]

sh-=1; sw-=1; gh-=1; gw-=1;

dist = [[-1]*w for _ in range(h)]
dist[sh][sw] = 0
q = deque([(0,sh,sw)])
warpq = deque([])

while q or warpq:
    while q:

        d,vsh,vsw = q.popleft()

        flag = 0
        
        for dh,dw in [(-1,0),(1,0),(0,-1),(0,1)]:
            newh = vsh+dh
            neww = vsw+dw
            if newh<0 or h<=newh or neww<0 or w<=neww: continue
            if s[newh][neww] == "#":
                if flag ==0:
                    warpq.append((d,vsh,vsw))
                    flag = 1
                continue

            if dist[newh][neww] == -1:
                dist[newh][neww] = d
                q.append((d,newh,neww))

    while warpq:

        d,vsh,vsw = warpq.popleft()
        for dh in range(-2,3):
            for dw in range(-2,3):
                newh = vsh+dh
                neww = vsw+dw
                if newh<0 or h<=newh or neww<0 or w<=neww: continue
                if abs(dh)+abs(dw)<=0: continue
                if s[newh][neww] == "#": continue

                if dist[newh][neww] == -1:
                    dist[newh][neww] = d+1
                    q.append((d+1,newh,neww))
            
print(dist[gh][gw])

Measured memory_bytes: 98480
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vector<string> s(n);
    REP(i, n){
        cin >> s[i];
        VSORT(s[i]);
    }
    map<string, ll> mp;
    REP(i, n){
        mp[s[i]]++;
    }
    ll res = 0;
    for(auto v : mp){
        ll tmp = v.second * (v.second - 1) / 2;
        res += tmp;
    }
    cout << res << endl;
    return 0;
}

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

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

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

	if (strcmp(s,u)==0)
		printf("%d %d\n", a - 1, b);
	else if (strcmp(t,u)==0)
		printf("%d %d\n", a, b - 1);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define PREF_MAX 100000
#define CITY_MAX 100000

struct city {
    int pref;
    int year;
};

int asc_by_year(const void *a1, const void *a2) {
    struct city *ca1 = (struct city*)a1;
    struct city *ca2 = (struct city*)a2;
    return ca1->year - ca2->year;
}

struct list {
    int num;
    int idx;
    struct list *next;
};

#define HASH_SIZE 65536
struct list *create_htable(void) {
    static struct list htable[HASH_SIZE];
    int i;
    for(i = 0; i < HASH_SIZE; i++) {
        htable[i].next = &htable[i];
    }
    return htable;
}

int get_key(int num) {
    return num & (HASH_SIZE-1);
}

int find_idx(struct list *htable, struct city *c) {
    struct list *head = &htable[get_key(c->year)];
    struct list *elem;
    for(elem = head->next; elem != head; elem = elem->next) {
        if(elem->num == c->year) {
            return elem->idx;
        }
    }
    return -1;
}

void add_elem(struct list *htable, int num, int idx) {
    struct list *elem = malloc(sizeof(struct list));
    struct list *head = &htable[get_key(num)];
    elem->next = head->next;
    elem->num = num;
    elem->idx = idx;
    head->next = elem;
}

void zip(struct list *htable, struct city *cities, int size) {
    qsort(cities, size, sizeof(struct city), asc_by_year);
    int prev = 0;
    int i;
    static int idx[PREF_MAX+1];
    for(i = 0; i <= PREF_MAX; i++) idx[i] = 1;

    for(i = 0; i < size; i++) {
        int y = cities[i].year;
        int pref = cities[i].pref;
        // There are no multiple cities that are established in the same year.
        if(prev == y) continue;
        add_elem(htable, y, idx[pref]);
        prev = y;
        idx[pref]++;
    }
    return;
}

int main(void) {
    int num, cs;
    get_int2(&num, &cs);
    static struct city cities[CITY_MAX];

    int i;
    for(i = 0; i < cs; i++) {
        get_int2(&cities[i].pref, &cities[i].year);
    }
    static struct city sorted[CITY_MAX];
    memcpy(sorted, cities, sizeof(struct city)*cs);

    struct list *htable = create_htable();
    zip(htable, sorted, cs);

    for(i = 0; i < cs; i++) {
        struct city c = cities[i];
        printf("%06d%06d\n", c.pref, find_idx(htable, &c));
    }
    return 0;
}

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

using namespace std;
int main()
{
    int n, f, mn=INT_MAX, mx=0;
    cin >> n;
    while(n--)
    {
        cin >> f;
        mn=min(f,mn);
        mx=max(f,mx);
    }
    cout<<mx-mn<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
ll n;
cin>>n;
  ll a[n];
  REP(i,n){
  cin>>a[i];
  }
  ll count=0;
  REP(i,n-1){
  if(a[i]==a[i+1]){
  count++;
    a[i+1]=0;
  }
  }
cout <<count;

return 0;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    ll n,h,sum(0);
    cin >> h >> n;
    rep(i,n){
        int x;  cin >> x;
        sum += x;
    }

    if(sum>=h)  puts("Yes");
    else    puts("No");

    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 100000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back


int n,h;
ll a[110000],b[110000];

int main(){
  cin>>n>>h;
  rep(i,n){
    cin>>a[i]>>b[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  reverse(a,a+n);
  reverse(b,b+n);
  ll ans=0;

  int i=0;
  while(b[i]>a[0]&&h>0&&i<n){
    h-=b[i];
    ans++;
    i++;
  }
  if(h>0)
  	ans+=(h+a[0]-1)/a[0];
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+5;
ll a[maxn];
string s;
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    double sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];sum+=a[i];

    }
    sum/=(4*m);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]>=sum)
            ans++;
    }
    if(ans>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=100005;
using namespace std;
int n,S,a[N],lst=2;
long long b[N],ans;
bool fl;
int main(){
	scanf("%d%d",&n,&S);
	for(int i=1;i<=n;i++)
	scanf("%d%lld",a+i,b+i);
	a[n+1]=2e9;
	for(int h=1,t=n;;){
		if(a[h]<S&&a[t]>S){
			fl=b[h]<b[t];
			if(lst^fl)ans+=a[t]-a[h];
			fl?b[t]+=b[h++]:b[h]+=b[t--];
			lst=fl;
		}
		else{
			if(a[h]>S)lst?ans+=a[t]-S:0;
			if(a[t]<S)lst^1?ans+=S-a[h]:0;
			break;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-


n = int(input().strip())
#----------
sum=0
calc_n=n

while calc_n != 0:
    digit = calc_n % 10
    calc_n = calc_n // 10
    sum += digit
    
if (n % sum) == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
double dp[N][N];
double p[N];

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

	for (int i = 1; i <= n; ++i)
		cin >> p[i];

	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
			dp[i][j] = 0;
	
	dp[1][0] = 1 - p[1];
	for (int i = 2; i <= n; ++i)
		dp[i][0] = dp[i - 1][0] * (1 - p[i]);

	dp[1][1] = p[1];
	for (int i = 2; i <= n; ++i)
		dp[i][i] = dp[i - 1][i - 1] * p[i];

	for (int i = 1; i <= n; ++i)
		for (int j = 1; j < i; ++j)
			dp[i][j] = (1 - p[i])*dp[i - 1][j] + p[i] * dp[i - 1][j - 1];

	double sum = 0;
	for (int i = n / 2 + 1; i <= n; ++i)
		sum += dp[n][i];

	cout << fixed << setprecision(10) << sum;
	cin >> n;
	return 0;
}

Measured memory_bytes: 70784