akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer x;

  x=nil->next;
  while(x!=nil && x->key!=key){
    x=x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  /* your code */
  NodePointer x;
  
  x=listSearch(key);
  if(x==nil) return;
 /*x->prev->next=x->next;
   x->next->prev=x->prev;*/
  deleteNode(x);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  /*your code*/
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32988
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int h,w,k;
	std::cin >> h >> w >> k;
	std::vector<std::string> s(h);
	rep(i,h) std::cin >> s[i];
	std::vector<int> exists(h,false);
	rep(i,h) {
		rep(j,w) if(s[i][j]=='#') exists[i] = true;
	}
	std::vector<std::vector<int> > grid(h,std::vector<int>(w,0));
	int cur = 0;
	rep(i,h) {
		if(exists[i]) {
			cur++;
			int count = 0;
			int x = 0;
			while(x<w) {
				if(s[i][x]=='#') {
					if(count>0) cur++;
					count++;
				}
				grid[i][x] = cur;
				x++;
			}
		}
	}
	int firstex = h;
	rep(i,h) if(exists[i]) {
		firstex = i;
		break;
	}
	std::vector<int> lookat(h,firstex);
	int currentexists = firstex;
	rep(i,h) {
		if(exists[i]) currentexists = i;
		lookat[i] = currentexists;
	}
	rep(i,h) {
		rep(j,w) {
			std::cout << grid[lookat[i]][j] << ' ';
		} std::cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
constexpr long long int mod = 1000000007, MOD = 998244353;
constexpr double PI = 3.14159265358979323846;

int main() {
	int N;
	cin >> N;
	map<int,int>U;
	queue<int>Q;
	for (size_t i = 0; i < N; i++)
	{
		int p;
		cin >> p;
		U[p] = U[p]+1;
		Q.push(p);
	}
	long long ans=0;
	if (U[1] == 1) { cout << 1; 
	return 0;
	}
	else if (U[1] >= 2) { cout << 0; return 0; }
	while (!Q.empty()) {
		bool bit = true;
		if (U.at(Q.front()) >= 2) {
			Q.pop();
			continue;
		}
		for (int i=2;i<=sqrt(Q.front());i++)
		{
			if (Q.front() % i == 0&&(U[Q.front() /i]||U[i])) { bit = false; break; }
		}
		if (bit)ans++;
		Q.pop();
	}
	cout << ans;
}

Measured memory_bytes: 32660
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;


typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef vector<ii> vii; 
typedef vector<ff> vff;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(2*b>=a){
        cout<<"0\n";
    }else{
        cout<<a-(2*b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <exception>
#include <stdexcept>
#include <iterator>
#include <sstream>

using namespace std;

typedef long long i64;

int prefix_cnt[100100];

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

    string s;
    cin >> s;

    const int n = s.size();

    prefix_cnt[0] = 1;

    int global_max = n / 2 + n % 2;
    int cnt = 1;
    for (int i = 1; i < n; i++)
    {
        if (s[i] != s[i - 1])
            cnt = 0;

        cnt++;
        prefix_cnt[i] = cnt;

        global_max = max(global_max, cnt);
    }

    for (int i = n - 1; i >= n / 2; i--)
    {
        int cur_cnt = min(i + 1, n - i - 1 + prefix_cnt[i]);

        global_max = max(global_max, cur_cnt);
    }

    cout << global_max;
}

Measured memory_bytes: 848
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scanner = new Scanner(System.in);
		char topography[] = scanner.nextLine().toCharArray();
		int sum = 0;
		ArrayDeque<Pond> ponds = new ArrayDeque<Pond>();
		ArrayDeque<Integer> li = new ArrayDeque<Integer>();
		for (int i = 0; i < topography.length; i++) {
			if (topography[i] == '\\') {
				li.add(i);
			} else if (!li.isEmpty() && topography[i] == '/') {
				int a = i - li.getLast();
				sum += a;
				while (!ponds.isEmpty() && li.getLast() < ponds.getLast().i) {
					a += ponds.getLast().area;
					ponds.removeLast();
				}
				ponds.add(new Pond(a, li.pollLast()));
			}
		}
		System.out.print(sum + "\n" + ponds.size());
		for (Pond l : ponds) {
			System.out.print(" " + l.area);
		}
		System.out.println();
	}

}

class Pond {
	public int area, i;

	public Pond(int area, int i) {
		this.area = area;
		this.i = i;
	}
}


Measured memory_bytes: 30088
#include<stdio.h>

/*構造体の定義*/
typedef struct {
	char suit;
	int value;
} Card ;


void swap_Card(Card *x, Card *y)
{
	Card temp = *x;
	*x = *y;
	*y = temp;
}


//バブルソート
void BubbleSort(Card A[], int N) {
	int i, j;
	Card temp;

	for (i = 0; i < N-1; i++) {
		for (j = N - 1; j > i ; j--) {
			if (A[j].value < A[j - 1].value) {
				swap_Card(&A[j], &A[j - 1]);
			}
		}
	}
}

//選択ソート
void SelectionSort(Card A[], int N) {
	int i, j;
	int minj;
	Card temp;

	for (i = 0; i < N-1; i++) {
		minj = i;
		for (j = i+1; j < N; j++) {
			if (A[j].value < A[minj].value) {
				minj = j;
			}
		}
		swap_Card(&A[i], &A[minj]);
	}
}

int main()
{
	int N;
	scanf("%d\n", &N);

	int i,j;
	Card BC[36];
	Card SC[36];

	for (i = 0; i < N; i++) {
		Card c;
		scanf("%c", &c.suit);
		scanf("%d ", &c.value);
		BC[i] = c;
		SC[i] = c;
	}

    
	/* 
    for (i = 0; i < N - 1; i++) {
        for (j = N - 1; j > i; j--) {
            if (BC[j].value < BC[j - 1].value)
                swap_Card(&BC[j], &BC[j - 1]);
        }
    }
	
	
    for (i = 0; i < N - 1; i++) {
        int minj = i;
        for (j = i + 1; j < N; j++) {
            if (SC[j].value < SC[minj].value)
                minj = j;
        }
        swap_Card(&SC[i], &SC[minj]);
    }
    */
    
    BubbleSort(BC,N);
    SelectionSort(SC,N);
	
	/* Output */
	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", BC[i].suit, BC[i].value);
	}
	printf("%c%d\n", BC[N - 1].suit, BC[N - 1].value);
	puts("Stable");

	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", SC[i].suit, SC[i].value);
	}
	printf("%c%d\n", SC[N - 1].suit, SC[N - 1].value);

	for (i = 0; i < N; i++) {
		if (BC[i].suit != SC[i].suit) {
			puts("Not stable");
			return 0;
		}
	}
	puts("Stable");

	return 0;
}


Measured memory_bytes: 2020
let prime_p n =
  if n == 2 then true
  else if n < 2 || n mod 2 = 0 then false
  else begin
    let x = int_of_float (sqrt (float_of_int n)) in
    let rec doit i =
      if i > x then true
      else if n mod i = 0 then false
      else doit (i + 2)
    in
    doit 3
  end

let () =
  let n = read_int () in
  let rec read i cnt =
    if i >= n then cnt
    else read (i + 1) (cnt + (if prime_p (read_int ()) then 1 else 0))
  in
  Printf.printf "%d\n" (read 0 0)

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> list(n);
  int total = 0;
  for(int i=0; i<n; i++) {
    cin >> list.at(i);
    total += list.at(i);
  }
  sort(list.begin(),list.end());
  int max = list.back();
  total -= max;
  if(max < total) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"NO\n";
#define CY cout<<"YES\n";

using namespace std;
using ll = long long;

void solve()
{
    ll n; cin>>n;
    map<string,ll>m;
    rep(i,n)
    {
        string s; cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"]<<"\n";
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
    //cin>>t;
    while(t--)
        {solve();}
    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,X;
  cin>>N>>X;
  vector<ll> L;
  REP(i,N){
    ll a;
    cin>>a;
    L.PB(a);
  }
  SORT(L);
  
  REP(i,N){
    if(X<L.at(i)){
      co(i);
      return 0;
    }
    else X-=L.at(i);
  }
  
  if(X==0) co(N);
  else co(N-1);
  return 0;
}

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

int main(void){
    double r;
    cin >> r;
    
    double pi = acos(-1);
    cout<<fixed<<setprecision(6);
    double area = r * r * pi;
    double cir = (r+r) * pi;
    cout<<area<<" "<<cir<<endl;
}


Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int N;
string s;

int main() {
  cin >> s;
  N = s.length();
  int p = 0;
  for (int i=0; i<N; i++) if (s[i] == 'p') p++;
  cout << (N / 2) - p << "\n";
  return 0;
}



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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int[] a = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int cnt = a[2] - a[1];
		a[1] += cnt;
		a[0] += cnt;
		int tmp = a[2] - a[0];
		if (tmp % 2 == 1) {
			tmp = tmp / 2 + 1;
			cnt += tmp + 1;
		} else {
			tmp = tmp / 2;
			cnt += tmp;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21972
if __name__ == '__main__':
    abc = input().split()
    A = int(abc[0])
    B = int(abc[1])
    C = int(abc[2])
    a = A % B
    r = 0 #result
    for i in range(1, B):
        if a * i % B == C:
            r = 1
            break
    if 1 == r:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

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

#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 INF 999999999

bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.first > secondElof.first;
}

int main() {
	int k, t;
	cin >> k >> t;
	vector<int>cake(t);

	REP(i, t) {
		cin >> cake[i];
	}
	int ans = 0;
	sort(cake.begin(), cake.end(), greater<int>());
	REP(i, t) {
		if (i)ans -= cake[i];
		else ans += cake[i];
	}
	ans--;
	if (ans < 0)ans = 0;
	cout << ans << endl;
}



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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 1000100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;

int n, k;
vl a;

int main()
{
    FAST_IO;

    cin >> n >> k;
    REP(n) {
        ll h; cin >> h;
        a.pb(h);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll s = 0;
    FOR(i, k, n-1) s += a[i];

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  vector<int>alp(26);
  int i;
  for(i=0;i<a.length();i++){
    alp[(int)(a[i]-'a')]++;
  }
  long ans = a.length();
  ans *= a.length()-1;
  ans/=2;
  ans ++;
  for(i=0;i<26;i++){
    ans -= (long)alp[i]*(alp[i]-1)/2;
  }
  cout << ans<<endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


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

	string s;
	cin >>s;
	
	int n=sz(s), ans=0;
	rep(i, n/2) if(s[i]!=s[n-1-i]) ans++;
	
	cout <<ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define _for(i,a,b) for(int i=a;i<=b;i++)
const int maxn = 55699;
int n,sum,prime[maxn],isprime[maxn],ans[maxn];
void ge()
{
    _for(i,2,maxn)
    {
        if(prime[i]==0)
        {
            isprime[++sum]=i;
            for(int j=i*2;j<=maxn;j+=i)prime[j]=1;
        }
    }
}
int main(int argc, char const *argv[])
{
    cin>>n;
    ge();
    int k = 0;
    _for(i,1,sum)
    {
        if(isprime[i]%5==1)
        {
            cout<<isprime[i]<<" ";
            k++;
        }
        if(k==n)
        {
            cout<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define N 200010
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,A[N],nw=0,winner;
int main()
{
	n=read(); for(int i=1;i<=n;i++) A[i]=read();
	while(1)
	{
		int ct0,ct1; ct0=ct1=0;
		for(int i=1;i<=n;i++)
			ct0+=!(A[i]&1),ct1+=A[i]&1;
		if(ct0&1) {winner=nw; break;}
		else if(ct1>1)
		{
			winner=nw^1; break;
		}
		else 
		{
			int td=0;
			for(int i=1;i<=n;i++)
				if(A[i]&1) td=i;
			if(A[td]==1)
			{
				winner=nw^1; break;
			}
			A[td]--; int xs=A[1];
			for(int i=2;i<=n;i++)
				xs=__gcd(xs,A[i]);
			for(int i=1;i<=n;i++) A[i]/=xs;
		}
		nw^=1;
	}
	if(!winner) puts("First");
	else puts("Second");
}

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

int N;
pair<long long, long long> A[1000];

int main(){		
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%lld%lld", &A[i].first, &A[i].second);
		if(i > 0){
			long long mult = max(ceil((long double)A[i - 1].first / A[i].first), ceil((long double)A[i - 1].second / A[i].second));
			A[i].first *= mult, A[i].second *= mult;
		}
	}
	printf("%lld\n", A[N - 1].first + A[N - 1].second);
	return 0;
}


Measured memory_bytes: 256
# Problem https://atcoder.jp/contests/abc087/tasks/abc087_b
# Ruby 2nd Try
have500y = 0
have100y = 0
have050y = 0
total = 0
answer = 0
have500y = gets.chomp().to_i
have100y = gets.chomp().to_i
have050y = gets.chomp().to_i
total = gets.chomp().to_i
for j in 0..have500y do
    for k in 0..have100y do
        for m in 0..have050y do
            nowtotal = j*500+k*100+m*50
            if nowtotal == total
                answer = answer + 1
            end
        end
    end
end
puts(answer)



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


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

int32_t main()
{
    
    int t;
    cin >> t;
    int ac=0,wa=0,tle=0,re=0;
    while(t--){
      string s;
      cin >> s;
      if(s == "AC")
        ++ac;
      else if(s == "WA")
        ++wa;
      else if(s == "TLE")
        tle++;
      else if(s == "RE")
        re++;
    }
    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a;
	scanf("%c", &a);
	if (a == 'A') {
		printf("T");
	}
	if (a == 'T') {
		printf("A");
	}
	if (a == 'C') {
		printf("G");
	}
	if (a == 'G') {
		printf("C");
	}
	return 0;
}

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

class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = test_cases; i >= 1; i--) {
            s.solve(1, in, out);
        }
        out.close();
    }

    static class Solver {

        public void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int ans = 0;
            for (int i = a; i <= b; i++) if (i >= c && i <= d) ans++;
            if (ans > 0) ans--;
            out.print(ans);
        }

        private boolean check(char[] s) {
            for (int i = 0; i < s.length / 2; i++) if (s[i] != s[s.length - i - 1]) return false;
            return true;
        }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 23380
B = (1e6 + 7).to_i
H = (1e9 + 7).to_i

def gen_hash(m, n, s)

  hash = 0
  n.times do |i|
    hash = hash * B + s[i]
    hash %= H
  end

  hash
end

def main
  n = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  a[n] = a[0]
  b = gets.chomp.split.map(&:to_i)
  b[n] = b[0]
  
  axa = []
  bxa = []
  #a+k xor a+1+k = b xor b+1 となるkを見つける
  bXor = b[0] ^ b[1]
  k = []
  n.times do |i|
    #a[i]xor a[i+1]の配列を作る 
    ax = a[i] ^ a[i+1]
    bx = b[i] ^ b[i+1]
    
    axa[i] = ax
    axa[i+n] = ax
    bxa[i] = bx
 
    if ax == bXor
      k.push(i)
    end
  end

  #全ての要素に対してa+k xor b = Xとなるかを確認する
  #ローリングハッシュで検索する
  b_hash = gen_hash(0, n, bxa)
  a_hash = gen_hash(0, n, axa)

  hash_back = 1
  n.times do
    hash_back *= B
    hash_back %= H
  end

  (n).times do |i|
    if a_hash == b_hash
      x = a[i] ^ b[0]
      puts "#{i} #{x}"
    end

    a_hash = a_hash * B + axa[n+i] - axa[i] * hash_back
    a_hash %= H
  end

end
 
main

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

int main(void){
    int H, W, N;
    cin >> H >> W >> N;
    int check[N][2];
    int ans[N];
    int area;
    int xmax = H;
    int ymax = W;
    int xmin = 0;
    int ymin = 0;
    for(int i = 0; i < N; i++){
        cin >> check[i][0] >> check[i][1] >> ans[i];
        if(ans[i] == 1)
            xmin = max(xmin,check[i][0]);
        if(ans[i] == 2)
            xmax = min(xmax,check[i][0]);
        if(ans[i] == 3)
            ymin = max(ymin,check[i][1]);
        if(ans[i] == 4)
            ymax = min(ymax,check[i][1]);

        }  
    int x = xmax-xmin;
    int y = ymax-ymin;
    if(x < 0)
        x = 0;
    if(y < 0)
        y = 0;
    area = x*y;
    
    cout << area << endl;   
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		int a = int.Parse(Console.ReadLine());

		Console.WriteLine(fact(a));
	}

        static long fact(int n)
        {
            if(n == 1)
               return 1;
            return (n * fact(n-1)) % ((long)Math.Pow(10, 9) + 7);
        }
}

Measured memory_bytes: 17364
#include <iostream>
 
using namespace std;
 
 
 
 
int main() {
 
	int A = 0;
	int B = 0;
	int C = 0;
	int X = 0;
	int count = 0;
	int chi = 0;
	int chj = 0;
	int chk = 0;
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> A >> B >> C >> X;
 
	for (int i = 0; i <= A;i++) {
		chi = 500 * i;
		if (chi <= X) {
			for (int j = 0; j <= B; j++) {
				chj = chi + 100 * j;
				if (chj <= X) {
					for (int k = 0; k <= C; k++) {
						chk = chj + 50 * k;
						if (chk == X) {
							count++;
							break;
						}
					}
				}
			}
		}
	}
 
	cout << count << endl;
 
	system("pause");
	return 0;
}

Measured memory_bytes: 504
N,A,B = map(int, input().split())

ans = 0
for i in range(1, N+1):
    c = 0
    j = 4
    num = i
    while j >= 0:
        temp = num//10**j
        c += temp
        num -= temp*(10**j)
        j -= 1
    if A <= c <= B:
        ans += i
        
print(ans)

Measured memory_bytes: 3060
#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 n;cin>>n;

  string last="";
  map<string,int> m;
  rep(i,n){
    string now;cin>>now;
    if(last.size()!=0 && last.at(last.size()-1)!=now[0] || m[now]>0){
      cout<<"No";return 0;
    }
    m[now]++;
    last=now;
  }

  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<k[n-1];
}


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

int main() {
    ll n, m;
    cin >> n >> m;

    ll ans = n == 1 || m == 1 ? max(1ll, n * m - 2) : (n - 2) * (m - 2);

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


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

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  ll cnt=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==1)cnt++;
  }
  if(cnt%2==0)cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))

dp = [0]*n
for i in range(1,n):
	if i == 1:
		dp[i]=abs(a[0]-a[1])
	else:
		dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]))
print(dp[n-1])

Measured memory_bytes: 13928
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string S;
	cin >> S;
	string T="";
	for (int i = 0; i < S.size(); i++) {
		if (S.substr(i,1) == "0") {
			T = T + "0";
		}
		else{
			if (S.substr(i, 1) == "1") {
				T = T + "1";
			}
			else {
				if (S.substr(i, 1) == "B") {
					if (T == "") {

					}
					else {
						T.erase(T.end()-1);
					}
				}
			}
		}
	}
	cout << T<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    //input
    int N, X;
    cin >> N >> X;
    int m[N];
    int sum = 0;
    int min;
    for(int i = 0; i < N; i++){
        cin >> m[i];
        sum = sum + m[i];
        if(i == 0){
            min = m[0];
        }
        if(m[i] < min){
            min = m[i];
        }
    }
    cout << (X - sum) / min + N << endl;
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long solve (int n, int [] a, int [] b)
{
	alias Pair = Tuple !(int, q{val}, int, q{pos});
	auto t = redBlackTree !(Pair);
	foreach (i; 0..n)
	{
		if (b[i] != a[i])
		{
			t.insert (Pair (b[i], i));
		}
	}
	long res = 0;
	while (!t.empty)
	{
		auto i = t.back.pos;
		t.removeBack ();
		auto sub = b[(i + n - 1) % n] + b[(i + 1) % n];
		if (b[i] - sub < a[i])
		{
			return -1;
		}
		auto steps = (b[i] - a[i]) / sub;
		res += steps;
		b[i] -= steps * sub;
		if (b[i] > a[i])
		{
			t.insert (Pair (b[i], i));
		}
	}
	return res;
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		auto b = readln.splitter.map !(to !(int)).array;
		writeln (solve (n, a, b));
	}
}


Measured memory_bytes: 66280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solv() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int slimeNum = N;
    rep(i, N - 1) {
        if(s[i] == s[i+1] ){
            slimeNum--;
        }
    }
    cout << slimeNum << endl;
}

int main() {
    solv();
    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<int> a(n), b(n), c(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];
  REP(i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  // REP(i, n) cout << a[i] << " ";
  // cout << endl;
  // REP(i, n) cout << b[i] << " ";
  // cout << endl;
  // REP(i, n) cout << c[i] << " ";
  // cout << endl;

  vector<int> d(n);
  REP(i, n) {
    d[i] = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
  }

  vector<int> e(n);
  int sum = 0;
  for(int i=n-1;i>=0;i--) {
    sum += d[i];
    e[i] = sum;
  }
  
  int count = 0;
  REP(i, n) {
    count += e[(upper_bound(b.begin(), b.end(), a[i]) - b.begin())];
  }
  cout << count << endl;


}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s; cin >> s;
  int ans = 0;
  char r = s[0];
  for(int i = 1; i < s.size(); i++){
    if(s[i] == r)continue;
    else{
      ans++;
      r = s[i];
    }
  }
  cout << ans << endl;
  system("pause");
}


Measured memory_bytes: 760
import numpy as np

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

value = np.array(list(map(int, input().split())))
r_value = value[::-1]

max_value = max(value[0], r_value[0])
for i in range(1, k):
    total_value = 0
    if i > n:
        s = value
        s.sort()
        s = list(s)
        for j in range(k-n):
            if s[0] < 0:
                s.pop(0)
        total_value = sum(s)
    else:
        for j in range(i+1):
            a = value[0:j]
            b = r_value[0:i-j]
            c = np.concatenate((a, b))
            c.sort()
            c = list(c)
            for l in range(k-i):
                if c[0] < 0:
                    c.pop(0)
                if c == []:
                    break
            total_value = sum(c)
            if total_value > max_value:
                max_value = total_value
print(max_value)

Measured memory_bytes: 12428
#include <iostream>

using namespace std;

int main()
{
    string s, alp = "abcdefghijklmnopqrstuvwxyz";
    cin >> s;

    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < s.size(); ++j) {
            if (alp[i] == s[j]) {
                break;
            } else if (j == s.size() - 1) {
                cout << alp[i] << endl;
                return 0;
            }
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){

	int a[100000];
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;
	int ans;
	int max;
	int min;
	scanf("%d %d %d %d", &n,&m,&x,&y);
	if (n%x == 0 && m%y == 0){
		printf("No\n");
	}
	else {
		printf("Yes\n");
		for (int i = 0; i < n; i++){
			for (int j = 0; j<m-1; j++){
				if (i%x == 0 && j%y == 0)printf("%d ", n*m);
				else if (i%x == x - 1 && j%y == y - 1)printf("%d ", -n*m - 1);
				else printf("0 ");
			}
			if (i%x == 0 && (m-1)%y == 0)printf("%d\n", n*m);
			else if (i%x == x - 1 && (m-1)%y == y - 1)printf("%d\n", -n*m - 1);
			else printf("0\n");
		}
	}

	return 0;
}

Measured memory_bytes: 2048
n, low, high = map(int, input().split())
ans = 0
save = 0

def keisan(j):
    goukei = 0
    while j > 0:
        goukei += int(j % 10)
        j = int(j / 10)
    return goukei
            
for i in range(n + 1):
    save = keisan(i)
    if low <= save <= high:
            ans += i
print(ans)

Measured memory_bytes: 3060
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

d = defaultdict(int)
for a in A:
    d[a] += 1

ans = 0
for i, c in d.items():
    if c >= i:
        ans += c - i
    else:
        ans += c
print(ans)


Measured memory_bytes: 68904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr first
#define sc second
void solve(){
    int k;
    cin>>k;
    long long ans = 0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int f = 1;f<=k;f++){
                int g = __gcd(i,j);
                ans+=__gcd(g,f);
            }
        }
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main()
{
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> sum(N);
  sum[0] = 0;
  vector<bool> ac(N);
  for (int i = 1; i < N; i++)
  {
    if (S[i - 1] == 'A' and S[i] == 'C')
    {
      sum[i] = sum[i - 1] + 1;
      ac[i] = true;
    }
    else
      sum[i] = sum[i - 1];
  }
  vector<int> a;
  for (int i = 0; i < Q; i++)
  {
    int l, r;
    cin >> l >> r;
    l--, r--;
    int ans = 0;
    if (l == 0)
    {
      ans = sum[r] - sum[0];
    }
    else
    {
      ans = sum[r] - sum[l - 1];
      if (ac[l])
        ans--;
    }
    a.push_back(ans);
  }
  for (int i = 0; i < Q; i++)
  {
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 1912
import numpy as np

n = int(input())
b = list(map(int, input().split()))

a  = np.zeros(n)

a[0] = b[0]
for i in range(1, n):
    a[i] = b[i - 1]
    if i != n - 1:
        if a[i] >= b[i]:
            a[i] = b[i]

print(int(sum(a)))

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

int H,W;

int line(){
 
   for (int i = 0; i < W; ++i){

   	cout << "#";   	  

   }

   cout << endl;

}

int main(){

	while(1){

		cin >> H >> W;
		if(H==0 && W==0)break;
		
		line();

		for (int j = 2; j < H; ++j){

			cout << "#";
			for (int k = 2; k < W; ++k)
			{
				cout << ".";
			}
			cout << "#" << endl;			
		}

		line();

		cout << endl;

	}

    
	
	return 0;
}

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

char m[10][10];
int h,w;
void decrypt(const string& s){
	h=0;w=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='/'){h++;w=0;}
		else if(s[i]=='b')m[h][w++]='b';
		else{
			for(int j=0;j<s[i]-'0';j++)m[h][w++]='.';
		}
	}
	h++;
}

string crypt(){
	string s="";
	int l=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(m[i][j]=='b'){
				if(l!=0)s+=(char)('0'+l);
				l=0;
				s+='b';
			}
			else l++;
		}
		if(l!=0)s+=(char)('0'+l);
		l=0;
		s+='/';
	}
	s.erase(--s.end());
	return s;
}
int main(void){
	string s;
	int a,b,c,d;
	while(cin>>s,s!="#"){
		cin>>a>>b>>c>>d;
		a--;b--;c--;d--;
		decrypt(s);
		m[a][b]='.';
		m[c][d]='b';
		cout<<crypt()<<endl;
	}
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
typedef long long ll;
const int MAXN = 500050;

struct dot {
  int val, cnt;
  dot(int val = 0, int cnt = 0):val(val), cnt(cnt){}
};
bool operator < (dot a, dot b){
  if(a.cnt == b.cnt){
    return a.val < b.val;
  }
  return a.cnt < b.cnt;
}

int n, k, A[MAXN], ans;
vector<dot> V;

int main() {
  scanf("%d %d", &n, &k);
  forn(i, n){
    scanf("%d", &A[i]);
  }
  
  sort(A, A + n);
  int last = -1, cnt = 0;
  forn(i, n){
    if(A[i] == last){
      cnt++;
    }
    else {
      if(last != -1) V.pb(dot(last, cnt));
      last = A[i];
      cnt = 1;
    }
  }
  V.pb(dot(last, cnt));
  
  int hay = (int) V.size();
  sort(V.begin(), V.end());
  forn(i, V.size()){
    if(hay > k){
      ans += V[i].cnt;
      hay--;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3188
n,k=map(int,input().split())
P=list(map(int,input().split()))
P=[p-1 for p in P]
C=list(map(int,input().split()))

def main():
  ans=-float('inf')
  for si in range(n):
    x=si
    S=[]
    tot=0
    while True:
      x=P[x]
      S.append(C[x])
      tot+=C[x]
      if x==si:
        break
    l=len(S)
    t=0
    for i in range(l):
      t+=S[i]
      if i+1>k:
        break
      now=t
      if tot>0:
        e=(k-i-1)//l
        now+=tot*e
      ans=max(ans,now)
  return ans      


if __name__=='__main__':
  print(main())


Measured memory_bytes: 84356
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=1e3+5;
int a[N][N],vis[N][N],dis[N][N];
int n,m;
bool isvalid(int x,int y)
{
    return (x>=1&&y>=1&&x<=n&&y<=m&&a[x][y]==1);
}

void solve()
{
  memset(dis,-1,sizeof(dis));
  memset(vis,0,sizeof(vis));
  int x1,x2,y1,y2;
  cin>>n>>m;
  cin>>x1>>y1;
  cin>>x2>>y2;
  string s;
  dis[x1][y1]=0;
  deque<array<int,2>> q;
  q.push_back({x1,y1});


  for(int i=1;i<=n;i++)
  {
    cin>>s;
    for(int j=1;j<=m;j++)
    {
        if(s[j-1]=='.')
            a[i][j]=1;
        else
            a[i][j]=0;
    }
  }


  if(a[x1][y1]==0||a[x2][y2]==0)
  {
    cout<<-1;
    return ;
  }

  
  int dx[]={1,-1,0,0};
  int dy[]={0,0,1,-1};
  while(!q.empty())
  {
    int x=q.front()[0];
    int y=q.front()[1];
    //cout<<x<<endl;
    q.pop_front();
    if(x==x2&&y==y2)
    {
        cout<<dis[x][y];
        return ;
    }

    if(vis[x][y])
        continue;
    vis[x][y]=1;
//    cout<<x<<" "<<y<<endl;

    for(int i=0;i<4;i++)
    {
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(isvalid(nx,ny)&&(dis[nx][ny]==-1||dis[nx][ny]>dis[x][y]))
        {
            dis[nx][ny]=dis[x][y];
            q.push_front({nx,ny});
        }
    }

    for(int i=-2;i<=2;i++)
    {
        for(int j=-2;j<=2;j++)
        {
            int nx=x+i;
            int ny=y+j;
            if(isvalid(nx,ny)&&(dis[nx][ny]==-1||dis[nx][ny]>dis[x][y]+1))
            {
                dis[nx][ny]=dis[x][y]+1;
                q.push_back({nx,ny});
            }
        }
    }


  }

  cout<<-1;


}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    string s[n];
    map<string, bool> mp;

    rep(i, 0, n)
    {
        cin >> s[i];
        if (mp[s[i]] == true)
        {
            cout << "No\n";
            return 0;
        }
        else
        {
            mp[s[i]] = true;
        }
        if (i >= 1 && s[i][0] != s[i - 1][s[i - 1].size() - 1])
        {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
($H,$W,$N)=glob<>;
@c=(($H-2)*($W-2),(0)x9);
map{$a=$`+$_%3;$b=$'+$_/3|0;$c[$d{$a}{$b}]--,$c[++$d{$a}{$b}]++if$H>=$a&&$a>2&&$W>=$b&&$b>2}!/ /..8for<>;
print"@c"

Measured memory_bytes: 156032
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int n;
	while(cin>>n,n){
		for(int i =0;i < n;i++){
			int m,l,j;
			cin>>m>>l>>j;
			int heikin =(m+l+j)/3;
			int suei =(m+l)/2;
			if(m>=100||l>=100||j>=100){
				cout <<"A"<<endl;
			}else if(suei>=90){
				cout <<"A"<<endl;
			}else if(heikin>=80){
				cout <<"A"<<endl;
			}else if(heikin>=70){
				cout <<"B"<<endl;
			}else if(heikin>=50&&(m>=80||l>=80)){
				cout <<"B"<<endl;
			}else{
				cout <<"C"<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;
}


Measured memory_bytes: 3636
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		double w = sc.nextDouble();
		double h = sc.nextDouble();
		double x = sc.nextDouble();
		double y = sc.nextDouble();
			
		// 計算
		double result = w*h/2;
		int flg = 0;
		if(x == w/2 && y == h/2) flg = 1;

		// 出力
		System.out.print(result);
		System.out.print(" " + flg);
		
	}
}


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

int main() {
  int N,K,A=1;
  cin>>N>>K;
  vector<double> p{N+1};
  while(true){
    int B=(K-1)/A+1;
    if(B>N){
      p.push_back(N+1);
    }
    else if(B==1){
      p.push_back(1);
      break;
    }
    else{
      p.push_back(B);
    }
    A*=2;
  }
  
  double S=0,Q=1;
  for(int i=1;i<p.size();i++){
    S+=(p.at(i-1)-p.at(i))*Q;
    Q/=2;
  }
  S/=N;
  cout << fixed << setprecision(12);
  cout<<S<<endl;

      
      
}

Measured memory_bytes: 256