akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int w_par[1000000];
int w_rank[1000000];


void w_init(int n){
	REP(i,n){
		w_par[i] = i;
		w_rank[i] = 0;
	}
}
int w_find(int x){
	if(w_par[x]==x){
		return x;
	}else{
		return w_par[x] = w_find(w_par[x]);
	}
}
void w_unite(int x, int y){
	x = w_find(x);
	y = w_find(y);
	if(x == y) return;
	if(w_rank[x] < w_rank[y]){
		w_par[x]=y;
	}else{
		w_par[y]=x;
		if(w_rank[x]==w_rank[y]) w_rank[x]++;
	}
}


int main(){
	int H,W;
	cin >> H >> W;
	int c[2],d[2];
	cin >> c[0] >> c[1];
	c[0]--; c[1]--;
	cin >> d[0] >> d[1];
	d[0]--; d[1]--;
	vector<string> s(H);
	REP(i,H) cin >> s[i];

	vector<bool> isway(H*W,true);
	w_init(H*W);
	REP(i,H){
		REP(j,W){
			if(s[i][j]=='#'){
				isway[i*W+j] = false;
				continue;
			}
			if(i!=0 && s[i-1][j]=='.') w_unite(i*W+j, (i-1)*W+j);
			if(i!=H-1 && s[i+1][j]=='.') w_unite(i*W+j, (i+1)*W+j);
			if(j!=0 && s[i][j-1]=='.') w_unite(i*W+j, i*W+j-1);
			if(j!=W-1 && s[i][j+1]=='.') w_unite(i*W+j, i*W+j+1);
		}
	}
	
	if(w_find(c[0]*W+c[1])==w_find(d[0]*W+d[1])){
		cout << 0 << endl;
		return 0;
	}
	
	map<int,set<int>> g;
	
	REP(i,H){
		REP(j,W){
			if(!isway[i*W+j]) continue;
			for(int k=-2; k<=2; k++){
				if(i+k<0 || i+k >= H) continue;
				for(int l=-2; l<=2; l++){
					if(j+l<0 || j+l >= W) continue;
					int now = (i+k)*W + j+l;
					if(!isway[now]) continue;
					if(w_find(i*W+j)==w_find(now)) continue;
					
					g[w_find(i*W+j)].insert(w_find(now));
					g[w_find(now)].insert(w_find(i*W+j));
					
				}
			}
		}
	}
	
	int start=w_find(c[0]*W+c[1]);
	int goal=w_find(d[0]*W+d[1]);
	map<int,int> count;
	queue<int> q;
	q.push(start);
	count[start] = 0;
	while(!q.empty()){
		int now = q.front();
		q.pop();
		
		for(auto x: g[now]){
			if(count[x]!=0) continue;
			if(x==goal){
				cout << count[now]+1 << endl;
				return 0;
			}
			count[x] = count[now]+1;
			q.push(x);
			
		}
	}
	
	cout << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 52560
fun main(args: Array<String>) {
    val s = readLine()!!

    print(if (req1(s)&&req2(s)&&req3(s)) ("AC") else ("WA"))
}

fun req1(s: String): Boolean {
    return s[0] == 'A'
}

fun req2(s: String): Boolean {
    var cnt = 0
    s.substring(2 until s.length-1).forEach{ c ->
        if (c == 'C') cnt++
    }
    return (cnt == 1)
}

fun req3(s: String): Boolean {
    return s.filter{c -> (c!='A' && c!='C')}.all{c ->
        c.toInt() >= 'a'.toInt() && c.toInt() <= 'z'.toInt()
    }
}


Measured memory_bytes: 33776
#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; 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 ll long long
#define pb(a) push_back(a)
#define pi M_PI

int main(){
  double r;
  cin >> r;

  cout << fixed << setprecision(7) << pi * r * r << " " << 2 * pi * r << " " << endl;
}



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


def solve(N: int, a: "List[int]"):
    ans = 0
    for i, num in enumerate(sorted(a)[::-1]):
        if i % 2 == 0:
            ans += num
        else:
            ans -= num
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == "__main__":
    main()


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

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define YES_ cout<<"Yes"<<endl; return 0;
#define NO_ cout<<"No"<<endl; return 0;

int main(){
    

    int n;
    cin>>n;
    cout<<n/3<<endl;




}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code
int n;
using edge = struct {LL to; LL cost;};
vector<vector<edge>> g;
VL color;

void dfs(int v, int par) {
	for (auto&& e : g[v]) {
		if (e.to == par) continue;
		color[e.to] = color[v] ^ (e.cost == 1 ? 1 : 0);
		dfs(e.to, v);
	}
}

int main(int argc, char const* argv[])
{
	cin >> n;
	g = vector<vector<edge>>(n);
	color = VL(n,-1);
	color[0] = 0;
	for (int i = 0; i < n-1; i++) {
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		c = c%2;
		g[a].push_back(edge{b, c});
		g[b].push_back(edge{a, c});
	}
	dfs(0, -1);
	for (int i = 0; i < n; i++) {
		cout << color[i] << endl;
	}
	return 0;
}


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

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

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

int main() {

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

  vector<bool> b(1000,true);

  REP(i,N){
    int p; cin >> p;
    b.at(p) = false;
  }

  int del = 1000, ans = X;

  REP(i,1000){
    if(!b.at(i))continue;
    if(chmin(del,abs(X-i))) ans = i;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		List<Integer> list = new ArrayList();
		for(int i=0; i<n ; i++) {
			list.add(Integer.parseInt(sc.next()));
		}

		int count = 0;
		for(int i=1; i<list.size()-1; i++) {
			int a=list.get(i-1);
			int b=list.get(i);
			int c=list.get(i+1);
			if((b < a && b >= c) || (b < c && b >= a)) {
				count++;
			}
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  1000LL
#define tmod            998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
t = q;
while(q--)
{
    ll n,m,k,i,j,l,r,c=0,b,a,g,counter=0,u,v,d,e,w,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> x >> n;
    x = __gcd(x,n);
    set<ll> Se;
    for(i=2;i*i<=x;i++)
    {

        if(x%i==0)
        {
            Se.insert(i);
            while(x%i==0)
                x = x/i;
        }
        //cout << x << " ";
    }
    if(x!=1) Se.insert(x);
    cout << (Se.size()+1);
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
player = [0] * N
point = [Q] * N

for i in range(Q):
    A = int(input())
    player[A-1] += 1

for i in range(N):
    result = point[i] - player[i]
    if K - result >= 1:
        print("Yes")

    else:
        print("No")


Measured memory_bytes: 5448
<?php
  $t1 = 0;
  $t2 = 0;
  $t3 = 0;
  while($i=(int)fgets(STDIN)) {
      if($i>$t3) {
          if($i>$t2) {
              if($i>$t1) {
                  $t3 = $t2;
                  $t2 = $t1;
                  $t1 = $i;
              } else {
                  $t3 = $t2;
                  $t2 = $i;
              }
          } else {
              $t3 = $i;
          }
      }
  }
  echo $t1."\n";
  echo $t2."\n";
  echo $t3."\n";

Measured memory_bytes: 15324
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int n,W,Ans;
int w[110],v[110],len[5];
int a[5][110],pre[5][110];

inline bool cmp(int a,int b){
  return a>b;
}

int main(){
  scanf("%d%d",&n,&W);
  for(int i=1;i<=n;i++) scanf("%d%d",&w[i],&v[i]);
  for(int i=1;i<=n;i++) a[w[i]-w[1]][++len[w[i]-w[1]]]=v[i];
  for(int i=0;i<4;i++) sort(a[i]+1,a[i]+1+len[i],cmp);
  for(int i=0;i<4;i++)
    for(int j=1;j<=len[i];j++) pre[i][j]=pre[i][j-1]+a[i][j];
  for(int A=0;A<=len[0];A++)
    for(int B=0;B<=len[1];B++)
      for(int C=0;C<=len[2];C++)
	for(int D=0;D<=len[3];D++)
	  if(1ll*A*w[1]+1ll*B*(w[1]+1)+1ll*C*(w[1]+2)+1ll*D*(w[1]+3)<=W)
	    Ans=max(Ans,pre[0][A]+pre[1][B]+pre[2][C]+pre[3][D]);
  printf("%d\n",Ans);
  return 0;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().ToArray();
            var expected = "CODEFESTIVAL2016".ToArray();
            var cnt = 0;
            for (var i = 0; i < input.Length; ++i)
            {
                if (input[i] != expected[i]) ++cnt;
            }
            Console.WriteLine(cnt);
        }
    }
}


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

char c[3][10001];
int l[3][10001];
int si[3];
vector<P> ans;

int main(){
	rep(i,3){
		for(int j = 0;;j++){
			cin >> c[i][j];
			if(c[i][j] == '$'){
				si[i] = j;
				break;
			}
			cin >> l[i][j];
		}
	}
	rep(i,si[0]){
		if(si[0]-i < si[1]) break;
		if(c[0][i] == c[1][0] && l[0][i] >= l[1][0]){
			if(si[1] == 1){
				l[0][i] -= l[1][0];
				rep(j,i) if(l[0][j] != 0) ans.push_back(P(c[0][j],l[0][j]));
				rep(j,si[2]) ans.push_back(P(c[2][j],l[2][j]));
				for(int j = i; j < si[0]; j++){
					if(l[0][j] != 0) ans.push_back(P(c[0][j],l[0][j]));
				}
				for(int j = ans.size()-1; j >= 1; j--){
					if(ans[j].first == ans[j-1].first){
						ans[j-1].second += ans[j].second;
						ans[j].second = 0;
					}
				}
				rep(j,ans.size()){
					if(ans[j].second == 0) continue;
					printf("%c %d ",ans[j].first,ans[j].second);
				}
				puts("$");
				return 0;
			}
			bool ok = true;
			for(int j = 1; j < si[1]-1; j++){
				if(c[0][i+j] != c[1][j] || l[0][i+j] != l[1][j]){
					ok = false;
					break;
				}
			}
			if(!ok) continue;
			{
				int j = si[1]-1;
				if(c[0][i+j] != c[1][j] || l[0][i+j] < l[1][j]){
					ok = false;
				}
				if(!ok) continue;
				l[0][i] -= l[1][0];
				l[0][i+j] -= l[1][j];
			}
			rep(j,i+1) if(l[0][j] != 0) ans.push_back(P(c[0][j],l[0][j]));
			rep(j,si[2]) ans.push_back(P(c[2][j],l[2][j]));
			for(int j = i+si[1]-1; j < si[0]; j++){
				if(l[0][j] != 0) ans.push_back(P(c[0][j],l[0][j]));
			}
			for(int j = ans.size()-1; j >= 1; j--){
				if(ans[j].first == ans[j-1].first){
					ans[j-1].second += ans[j].second;
					ans[j].second = 0;
				}
			}
			rep(j,ans.size()){
				if(ans[j].second == 0) continue;
				printf("%c %d ",ans[j].first,ans[j].second);
			}
			puts("$");
			return 0;
		}
	}
	rep(i,si[0]){
		printf("%c %d ",c[0][i],l[0][i]);
	}
	puts("$");
}

Measured memory_bytes: 1248
#include<stdio.h>
 
#define MAX 1000
#define N 100
 
int G[MAX][MAX];
int d[MAX],Q[N];
int n;
int max=0;
int min=0;
 
void en(int q){
  Q[max] = q;
  max++;
}
 
int de(){
  min++;
  return Q[min-1];
}
 
int size(){
  return max-min;
}
 
void bfs(int i){
  int a;
  for(a = 0; a < n; a++){
    if(G[i][a] == 1 && d[a] == -1){
      d[a] = d[i]+1;
      en(a);
    }
  }
}
 
int main(){
  int i,j,u,k,c;
 
  scanf("%d",&n);
 
  for(i=0;i<MAX;i++){
    d[i]=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      G[u-1][c-1]=1;
    }
  }
  d[0]=0;
  bfs(0);
 
  while(size()!=0){
    bfs(de());
  }
 
  for(i=0;i<n;i++){
    printf("%d ",i+1);
    printf("%d\n",d[i]);
  }
 
  return 0;
}

Measured memory_bytes: 988
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    int n, d;
    cin >> n >> d;
    int anw = 0, now = n;
    for(int i = n; i >= 1; i = now){
        int next = now - d;
        anw++;
        next--;
        next -= d;
        now = next;
        //cout << now << endl;
    }
    cout << anw;
    return 0;
}


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

int main(){
	double m;
	while(cin >> m){
		if(m <= 48) cout << "light fly" << endl;
		if(m > 48 && m <= 51) cout << "fly" << endl;
		if(m > 51 && m <= 54) cout << "bantam" << endl;
		if(m > 54 && m <= 57) cout << "feather" << endl;
		if(m > 57 && m <= 60) cout << "light" << endl;
		if(m > 60 && m <= 64) cout << "light welter" << endl;
		if(m > 64 && m <= 69) cout << "welter" << endl;
		if(m > 69 && m <= 75) cout << "light middle" << endl;
		if(m > 75 && m <= 81) cout << "middle" << endl;
		if(m > 81 && m <= 91) cout << "light heavy" << endl;
		if(m > 91) cout << "heavy" << endl;
	}
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main() {
	int N;
	long double number = 0.0;
	long double answer = 0.0;
	cin >> N;
	int V[N];
	for(int i = 0; i < N; i++) cin >> V[i];
	sort(V, V+N);
	number = V[0];
	for(int i = 0; i < N-1; i++) {
		number = (number+V[i+1])/2;

	}
	cout << number <<endl;	
}

Measured memory_bytes: 256
s = input()
t = input()
n = len(s)
m = len(t)
ans = 1000

for i in range(n - m + 1):
    cnt = 0
    for j in range(m):
        if s[i + j] != t[j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 9056
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

typedef double db;
db eps=1e-9;
struct point {
	db x,y;
	point() {}
	point(db x,db y):x(x),y(y) {}
	void input() { scanf("%lf%lf",&x,&y); }
	void output() { printf("%.10f %.10f\n",x,y); }
	db len() { return sqrt(x*x+y*y); }
	db len2() { return x*x+y*y; }
};
point operator + (const point &a,const point &b) { return point(a.x+b.x,a.y+b.y);}
point operator - (const point &a,const point &b) { return point(a.x-b.x,a.y-b.y);}
point operator * (const point &a,const db &b) { return point(a.x*b,a.y*b);}
point operator / (const point &a,const db &b) { return point(a.x/b,a.y/b);}
db dot(const point &a,const point &b) { return a.x*b.x+a.y*b.y; }
db det(const point &a,const point &b) { return a.x*b.y-a.y*b.x; }
struct line {
	point a,b;
	line() {}
	line(point a,point b):a(a),b(b) {}
};
point proj(const line &a,const point &b) {
	return a.a+(a.b-a.a)*dot(a.b-a.a,b-a.a)/(a.b-a.a).len2();
}
point reflect(const line &a,const point &b) {
	return proj(a,b)*2-b;
}
int sign(db x) {
	return fabs(x)<eps?0:(x>0?1:-1);
}
int relation(const line &a,const point &b) {
	int x=sign(det(a.b-a.a,b-a.a));
	if (x==1) return 0; // COUNTER_CLOCKWISE ?????¶???
	else if (x==-1) return 1; // CLOCKWISE ?????¶???
	else {
		x=sign(dot(b-a.a,a.b-a.a));
		if (x==-1) return 2; // ONLINE_BACK
		else {
			x=sign(dot(b-a.b,a.b-a.a));
			if (x==1) return 3; // ONLINE_FRONT
			else return 4; // ON_SEGMENT
		}
	}
}
bool parallel(const line &a,const line &b) { return sign(det(a.a-a.b,b.a-b.b))==0;}
bool ismiddle(const line &a,const point &b) {
	return sign(dot(b-a.a,a.b-a.a))>=0&&sign(dot(b-a.b,a.b-a.a))<=0;
}
int segcrossseg(const line &a, const line &b) {
	if (sign(min(b.a.x,b.b.x)-max(a.a.x,a.b.x))==1) return 0;
	if (sign(max(b.a.x,b.b.x)-min(a.a.x,a.b.x))==-1) return 0;
	if (sign(min(b.a.y,b.b.y)-max(a.a.y,a.b.y))==1) return 0;
	if (sign(max(b.a.y,b.b.y)-min(a.a.y,a.b.y))==-1) return 0;
	int d1=sign(det(a.b-a.a,b.a-a.a))*sign(det(a.b-a.a,b.b-a.a));
	int d2=sign(det(b.b-b.a,a.a-b.a))*sign(det(b.b-b.a,a.b-b.a));
	if (d1==-1&&d2==-1) return 2; // ?§??????????
	else if (d1<=0&&d2<=0) return 1; // ????§??????????
	else return 0; // ?????????
}
point crosspoint(const line &a,const line &b) {
	double a1=det(b.b-b.a,a.a-b.a),a2=det(b.b-b.a,a.b-b.a);
	return a.a*(a2/(a2-a1))-a.b*(a1/(a2-a1));
}

int q;
int main() {
	scanf("%d",&q);
	rep(i,0,q) {
		point p1,p2,q1,q2;
		p1.input(); p2.input(); q1.input(); q2.input();
		crosspoint(line(p1,p2),line(q1,q2)).output();
	}
}

Measured memory_bytes: 2756
# include <iostream>
const int MAX = 1e5 + 2;
using namespace std;
 
int main() {
    int N;
    int A[MAX];
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }

    int ans = 0;
    int prev = -1;
    int cur;
    int cnt = 1;
    for (int i = 0; i < N; i++){
        cur = A[i];
        if (prev == cur) {
            cnt ++;
        } else {
            ans += cnt / 2;
            cnt = 1;
        }
        prev = cur;
    }
    ans += cnt / 2;
    cnt = 0;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define ull unsigned long long

void solve()
{
	int n; cin >> n;
  	ull rs = 0;
  	for (int i = 1; i <= n; ++i)
    {
    	if (i%3 != 0 && i%5 != 0)
        {
          	rs += i;
        }
		
    }
	cout << rs << endl;
}

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


Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;


int w , h;
int land[51][51];

void dfs(int px , int py){
	int tx , ty;
	land[py][px]=0;
	for(int i=-1 ; i<=1 ; ++i){
		for(int j=-1 ; j<=1 ; ++j){
			tx=px+i , ty=py+j;
			if(tx<0 || tx>=w || ty<0 || ty>=h) continue;
			if(land[ty][tx]) dfs(tx , ty);
		}
	}
}


int main(){
	int cnt=0;
	while(cin >> w >> h , w||h){
		for(int i=0 ; i< h ; ++i){
			for(int j=0 ; j< w ; ++j){
				cin >> land[i][j];
			}
		}
		for(int i=0 ; i<h ; ++i){
			for(int j=0 ; j<w ; ++j){
				if(land[i][j]){
					dfs( j , i);
					cnt++;
				}
			}
		}
		cout << cnt << endl;
		cnt=0;
	}
	return 0; 
}

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

int n;
long ans;
ll a[100000];
ll b[100000];

long long abso(long long x) {
	return x < 0 ? -x : x;
}

int main() {

	scanf("%d",&n);

	for (int i = 0; i < n; ++i)
		scanf("%lld%lld",&a[i],&b[i]);

	for (int i = n-1; i >= 0; --i) {
		ll x = a[i]+ans;

		if (x%b[i] == 0)
			continue;
		
		long tmp;

		if (x >= b[i])
			tmp = b[i] - (x%b[i]);
		else
			tmp = b[i] - x;
		//cout << ans << '\n';
		ans += tmp;
	}

	printf("%ld\n",ans);

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
    long long int W,H,x,y;
    cin>>W>>H>>x>>y;
    cout<<(double)(W)*(double)(H)/2.0<<" ";
    if(2*x==W&&2*y==H) cout<<1<<endl;
     else cout<<0<<endl;;
    return 0;
}


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

int main() {
  int n; cin>>n;
  ll X[10][10]={};
  rep(i, 1, n+1) {
    int a=i%10;
    int b=to_string(i)[0]-'0';
    X[a][b]++;
  }
  ll res=0;
  rep(i, 1, 10) {
    rep(j, 1, 10) {
      res+=X[i][j]*X[j][i];
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public final class Main {
	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String arg[] = br.readLine().split(" ");
		int n = Integer.parseInt(arg[0]);
		int a = Integer.parseInt(arg[1]);
		Solver s = new Solver();
		arg = br.readLine().split(" ");
		int inp[] = new int[n + 1];
		for (int i = 0; i < arg.length; i++) {
			inp[i + 1] = Integer.parseInt(arg[i]);
		}

		System.out.println(s.solve(inp, a));
	}

}

class Solver {

	long solve(int[] n, int a) {

		long[][][] dp = new long[n.length][n.length][a * n.length + 1];
		for (long j = 1; j < n.length; j++) {
			for (long i = 1; i < n.length; i++) {
				for (long s = 1; s <= a * n.length; s++) {
					if (j == 1) {
						if (s == n[(int) i]) {
							dp[(int) i][(int) j][(int) s]++;
						}
					}
					long idx = (s - n[(int) i]) >= 0 ? (s - n[(int) i]) : 0;
					dp[(int) i][(int) j][(int) s] += (dp[(int) (i - 1)][(int) (j - 1)][(int) idx]
							+ dp[(int) (i - 1)][(int) j][(int) s]);
				}

			}
		}
		long ans = 0L;
		for (int i = n.length - 1; i <= n.length - 1; i++) {
			for (int j = 1; j <= n.length - 1; j++) {
				for (int k = 1; k <= a * n.length; k++) {
					if (dp[i][j][k] > 0 && k == a * j) {
						ans += dp[i][j][k];
					}
				}
			}
		}
		return ans;
	}

}


Measured memory_bytes: 87088
#include<stdio.h>
 
int main(void){
    int i,j,tem,hei[10];
   
    for(i=0;i<10;i++){
        scanf("%d",&hei[i]);
    }

    for(i=0;i<9;i++){
        for(j=0;j<9-i;j++){
            if(hei[j] < hei[j+1]){
                tem      = hei[j];
                hei[j]   = hei[j+1];
                hei[j+1] = tem;
            }
        }
    }
    for(i=0;i<3;i++){
        printf("%d\n",hei[i]);
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>

#define SMALLEST_VALUE (-(2*1000*1000*1000+1))
#define MAX_ARRAY_SIZE (500 * 1000 * 2)

void swap(int* a, int* b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

void max_heapify(int* array, int index)
{
    int left_index = index*2 + 1;
    int right_index = index*2 + 2;
    int largest_index;
    if(array[left_index]  <= array[index] &&
       array[right_index] <= array[index]) {
        largest_index = index;
    } else if(array[right_index] <= array[left_index] &&
              array[index]       <= array[left_index]) {
        largest_index = left_index;
    } else {
        largest_index = right_index;
    }

    if(largest_index != index) {
        swap(array + largest_index, array + index);
        max_heapify(array, largest_index);
    }
}

void build_max_heap(int* array, int size)
{
    for(int i = size / 2 - 1; 0 <= i; i--) {
        max_heapify(array, i);
    }
}

int main()
{
    int input_len;
    scanf("%d", &input_len);
    int* array = malloc(MAX_ARRAY_SIZE * sizeof(int));

    for(int i = 0; i < input_len; i++) {
        scanf("%d", &array[i]);
    }
    for(int i = input_len; i < MAX_ARRAY_SIZE; i++) {
        array[i] = SMALLEST_VALUE;
    }

    build_max_heap(array, input_len);

    for(int i = 0; i < input_len; i++) {
        printf(" %d", array[i]);
    }
    putchar('\n');

    free(array);
    return 0;
}

Measured memory_bytes: 5492
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
string S;

int main(){
    cin >> S;

    int N = S.size();
    if(S[0]=='0'||S[N-2]=='0'||S[N-1]=='1'){
        printf("-1\n");
        return 0;
    }
    for(int i=1; i<N/2; i++){
        if(S[i]!=S[N-i-2]){
            printf("-1\n");
            return 0;
        }
    }

    queue<int> que;
    que.push(1);
    for(int i=1; i<N/2; i++){
        if(S[i]=='1'){
            while(!que.empty()){
                printf("%d %d\n", que.front(), i+1);
                que.pop();
            }
        }
        que.push(i+1);
    }
    for(int i=N/2; i<N-1; i++){
        que.push(i+1);
    }
    while(!que.empty()){
        printf("%d %d\n", que.front(), N);
        que.pop();
    }
    return 0;
}

Measured memory_bytes: 2048
n = int(input())
h = list(map(int, input().split()))
tmp = h[-1]
ans = 'Yes'

for i in range(2,n+1):
    if tmp - h[-i] == -1:
        tmp = h[-i]-1
    elif tmp - h[-i] < -1:
        ans = 'No'
        break
    else:
        tmp = h[-i]

print(ans)

Measured memory_bytes: 14396
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(void){
    int a[5],b[5],x;
    x=0;
    cin >> a[1] >> b[1] >> a[2] >> b[2] >> a[3] >> b[3];
    if(a[1]==a[2]&&b[2]==b[3])x++;
    if(a[1]==a[2]&&b[2]==a[3])x++;
    if(a[1]==b[2]&&a[2]==b[3])x++;
    if(a[1]==b[2]&&a[2]==a[3])x++;
    if(a[2]==a[1]&&b[2]==b[3])x++;
    if(a[2]==a[1]&&b[2]==a[3])x++;
    if(a[2]==b[1]&&b[2]==b[3])x++;
    if(a[2]==b[1]&&b[2]==a[3])x++;
    
    if(a[2]==a[1]&&b[1]==b[3])x++;
    if(a[2]==a[1]&&b[1]==a[3])x++;
    if(a[2]==b[1]&&a[1]==b[3])x++;
    if(a[2]==b[1]&&a[1]==a[3])x++;
    if(a[1]==a[2]&&b[1]==b[3])x++;
    if(a[1]==a[2]&&b[1]==a[3])x++;
    if(a[1]==b[2]&&b[1]==b[3])x++;
    if(a[1]==b[2]&&b[1]==a[3])x++;
    
    if(a[1]==a[3]&&b[3]==b[2])x++;
    if(a[1]==a[3]&&b[3]==a[2])x++;
    if(a[1]==b[3]&&a[3]==b[2])x++;
    if(a[1]==b[3]&&a[3]==a[2])x++;
    if(a[3]==a[1]&&b[3]==b[2])x++;
    if(a[3]==a[1]&&b[3]==a[2])x++;
    if(a[3]==b[1]&&b[3]==b[2])x++;
    if(a[3]==b[1]&&b[3]==a[2])x++;
    if(x!=0)cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B, C, X; cin >> A >> B >> C >> X;
  ll ans = 0;
  REPLL(i, A+1){
    REPLL(j, B+1){
      REPLL(k, C+1){
        if(X == i*500 + j*100 + k*50) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nm[0];
        var m = nm[1];
        var bs = new Tuple<int, int>[m];
        for (int i = 0; i < bs.Length; i++)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            bs[i] = Tuple.Create(ab[0], ab[1]);
        }

        var points = new long[bs.Length];
        points[0] = (n - 1L) * (1 + n - 1) / 2;
        var uf = new UnionFind(n);
        for (int i = 1; i < bs.Length; i++)
        {
            var v = bs[bs.Length - i].Item1;
            var u = bs[bs.Length - i].Item2;
            var p = uf.GetGroupSize(v);
            var q = uf.GetGroupSize(u);
            points[i] = uf.Union(v, u) ? points[i - 1] : points[i - 1] - p * q;
            uf.Unite(v, u);
        }

        var sb = new System.Text.StringBuilder();
        for (int i = 0; i < points.Length; i++)
        {
            sb.AppendLine(points[points.Length - 1 - i].ToString());
        }
        Console.WriteLine(sb);
    }
}

class UnionFind
{
    int[] nodes;
    int[] groupSize;
    HashSet<int> group;
 
    public UnionFind(int size)
    {
        this.nodes = Enumerable.Range(0, size).ToArray();
        this.groupSize = E.Repeat(1, size).ToArray();
        this.group = new HashSet<int>(E.Range(0, size));
    }
 
    public int Find(int x)
    {
        var p = nodes[x];
        if (p == x)
        {
            return x;
        }
 
        return nodes[x] = Find(p);
    }
 
    public void Unite(int x, int y)
    {
        var p = Find(x);
        var q = Find(y);
        if (p == q)
        {
            return;
        }
 
        var r = groupSize[p];
        var s = groupSize[q];
        if (r < s)
        {
            nodes[p] = q;
            groupSize[q] += groupSize[p];
            group.Remove(r);
        }
        else
        {
            nodes[q] = p;
            groupSize[p] += groupSize[q];
            group.Remove(s);
        }
    }
 
    public bool Union(int x, int y)
        => Find(x) == Find(y);
    
    public int GetGroupSize(int x)
        => groupSize[Find(x)];

    public int GroupCount => group.Count;
}


Measured memory_bytes: 38068
main()
{
	int num[3];
	int i;
	int count = 0;
	scanf("%d %d %d",&num[0],&num[1],&num[2]);

	for (i = num[0]; i <= num[1]; ++i) 
	{
		if (num[2] % i == 0)
		{
			count = count + 1;
		}		
	}
	printf("%d\n", count);
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	string a,b;
	cin>>a>>b;
	for(int i=0,l=0,r=0;i<a.length()+b.length();i++)
		if(i%2==0)
			cout<<a[l++];
		else 
			cout<<b[r++];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
using Int = int_fast64_t;

Int ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<Int> d(n);
	for(auto &i:d) cin >> i;
	for(Int i=0; i<n-1; ++i)
		for(Int j=i+1; j<n; ++j)
			ans += d[i] * d[j];
	cout << ans << "\n";
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    a,b=map(int,input().split())
    x=(((b-1)//2)-(a-1)//2)%2
    if a%2==0:
        if b%2==0:print(x^b)
        else:print(x)
    else:
        if b%2==0:print(a^x^b)
        else:print(a^x)

if __name__=='__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long

const int N = 1e6 + 233;
int n, m, x, p[N], a[N], b[N], ans[N];
#define GG (puts("No"), exit(0))
signed main(void) {
	read(n); read(x);
	m = 2 * n - 1;
	if (n == 1) {
		if (x != 1) GG;
		cout << "1\n";
	} else {
		if (x == 1 || x == m) GG;
		ans[n - 1] = 1;
		ans[n] = x;
		ans[n + 1] = m;
		priority_queue <int> S;
		rep (i, m) {
			if (i == 1 || i == m || i == x) continue;
			S.push(i);
		}
		rep (i, n - 2) ans[i] = S.top(), S.pop();
		rep (i, n - 2) ans[m - i + 1] = S.top(), S.pop();
		cout << "Yes\n";
		rep (i, m) cout << ans[i] << "\n";
	} 
	
	// rep (i, m) a[i] = i;
	// set <int> s;
	// do {
	// 	vector <int> b(a + 1, a + m + 1);
	// 	int l = m;
	// 	while (l > 1) {
	// 		vector <int> c;
	// 		for (int k = 0; k + 2 < l; k++) {
	// 			int t[] = {b[k], b[k + 1], b[k + 2]};
	// 			sort(t, t + 3);
	// 			c.push_back(t[1]);
	// 		}
	// 		swap(c, b);
	// 		l = b.size();
	// 	}
	// 	s.insert(b.front());
	// } while (next_permutation(a + 1, a + m + 1));
	// for (int i : s) cout << i << " "; cout << "\n";
	
}


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

int main(){
    int n, a, b, c, i;
        cin >> a >> b >> c;
            n = 0; 
            for(i = a; i <= b; i++ ){ 
                if(c%i == 0){
                    n++;
            } 
        }
        cout << n << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << ", "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << ", "; cerr << "\n"; }
#define dbm(map) cerr << #map << ":"; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "\n";
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mli = map<ll, int>; using mll = map<ll, ll>;

int main() {
	int H, W; cin >> H >> W;
	vvb g(H, vb(W));
	vvi d(H, vi(W, -1));
	int white = 0;
	rep(i, H) {
		string s; cin >> s;		
		rep(j, W)	{
			if (s[j] == '.') {
				g[i][j] = true;
				white++;
			}
		}
	}
	dbvv(g); dbl(white);
	queue<pii> q;
	pii s(0, 0); q.push(s); d[0][0] = 1;
	vi di = { 1, 0, -1, 0 }, dj = { 0, 1, 0, -1 };
	while (!q.empty()) {
		int ui, uj; tie(ui, uj) = q.front(); q.pop();
		rep(k, 4) {
			int vi = ui + di[k], vj = uj + dj[k];			
			if (vi < 0 or vi >= H or vj < 0 or vj >= W) continue;
			if (!g[vi][vj] or d[vi][vj] != -1) continue;
			d[vi][vj] = d[ui][uj] + 1;
			q.push(make_pair(vi, vj));
		}
	}
	dbvv(d);	
	cout << (d[H - 1][W - 1] == -1 ? -1 : white - d[H - 1][W - 1]) << endl;
}

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

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    long long ans = min(k, a);
    k -= min(k, a);
    k -= min(k, b);
    ans -= k;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <map>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(){
	int Q;
	cin >>Q;
	while(Q--){
		int n;
		cin >>n;
		map<int,int>memo;
		int ans = 0;
		while(!memo[n] && n >= 10){
			memo[n] =true;
			int next = 0;
			stringstream ss;
			ss << n;
			string t =ss.str();
			for(int i = 0 ; i < t.size()-1 ; i++){
				string a = t.substr(0,i+1);
				string b = t.substr(i+1);
				int A = atoi(a.c_str());
				int B = atoi(b.c_str());
				next = max(next,A*B);
			}
			ans++;
			n = next;
		}
		if( n >= 10 ){
			cout << -1 << endl;
		}else{
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1228
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int a,b,c,d;
    cin>>a >>b >>c >>d;
    int ans=0;
    if(a>b)ans+=b;
    else ans+=a;
    if(c>d)ans+=d;
    else ans+=c;
    cout <<ans<<endl;
}


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

int n, a[100010], cnt[2], rem, first = 0, second = 1;
char ans[2][7] = {\
	{'F', 'i', 'r', 's', 't', 0, 0},\
	{'S', 'e', 'c', 'o', 'n', 'd', 0}\
};

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		cnt[a[i] & 1]++;
		if(a[i] & 1) {
			rem = i;
		}
	}
	for(;;) {
		if(cnt[0] & 1) {
			return !puts(ans[first]);
		}
		if(cnt[1] != 1 || a[rem] == 1) {
			return !puts(ans[second]);
		}
		first ^= 1;
		second ^= 1;
		--a[rem];
		int d = a[1];
		for (int i = 2; i <= n; ++i) {
			d = std::__gcd(d, a[i]);
		}
		cnt[0] = cnt[1] = 0;
		for (int i = 1; i <= n; ++i) {
			a[i] /= d;
			cnt[a[i] & 1]++;
			if(a[i] & 1) {
				rem = i;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		int n = Integer.parseInt(tmpArray[0]);
		int h = Integer.parseInt(tmpArray[1]);
		int w = Integer.parseInt(tmpArray[2]);

		int input[] = new int[n];
		tmpArray = br.readLine().split(" ");

		for(int i = 0; i < n;i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}

		int x[] = new int[n];
		//それぞれのpaneの左の座標を確定させる
		for(int i = 0; i < n; i++){
			if(i%2 == 0){
				x[i] = i*w + input[i];
			}
			else {
				x[i] = i*w - input[i];
			}
		}

		boolean closed[] = new boolean[n*w];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < w; j++){
				closed[x[i] + j] = true;
			}
		}

		int result = 0;
		for(int i = 0; i < closed.length; i++){
			if(!closed[i]){
				result += h;
			}
		}

		System.out.println(result);
	}

}



Measured memory_bytes: 24520
S=input()

N=len(S)
d={}
for i in range(2019):
    d[i]=0

d[0] = 1

mod=0
dig=1

for i in range(N):
    #s=S[N-1-i:]
    #d[int(s)%2019]+=1
    mod += dig * int(S[N-1-i])
    mod %= 2019
    d[mod] += 1
    dig *= 10
    dig %= 2019


ans = 0
for k in d.keys():
    v = d[k]
    if v > 1:
        ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 9320
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main(){
	int a, b; std::cin >> a >> b;
	std::cout << std::max({ a + b, a - b, a * b }) << std::endl;
}



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

a=list(map(int, input().split()))

a.sort(reverse=True)
A=[]
B=[]

for i,k in enumerate(a):
    if i%2 == 0:
        A.append(a[i])
               
               
    elif i%2 == 1:
        B.append(a[i])
        
    
print(sum(A)-sum(B))    

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
int h,m,s;
h=0;
m=0;
scanf("%d",&s);
h=s/3600;
m=(s/60)-(h*60);
s=s-((h*3600)+(m*60));
printf("%d:%d:%d\n",h,m,s);
return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int INF=1e9;

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i,N) cin >> a[i];
	int M=-INF, m=INF;
	int Max_Num=-1, Min_Num=-1;
	rep(i,N){
		if(M<a[i]){
			M=a[i];
			Max_Num=i+1;
		}
		if(m>a[i]){
			m=a[i];
			Min_Num=i+1;
		}
	}
	int num=0;
	vector<P> ans;
	if(M>=abs(m)){
		rep(i,N){
			num++;
			ans.emplace_back(P(Max_Num,i+1));
		}
		rep(i,N-1){
			num++;
			ans.emplace_back(i+1,i+2);
		}
	}
	else{
		rep(i,N){
			num++;
			ans.emplace_back(P(Min_Num,i+1));
		}
		rep(i,N-1){
			num++;
			ans.emplace_back(N-i,N-i-1);
		}
	}
	cout << num << endl;
	rep(i,num) cout << ans[i].first << " " << ans[i].second << endl;

	return 0;
}

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


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

    for(int j=0; j<N; j++){
        int x = A[j];
        B[x-1] = j+1;
    }

    for(int a=0; a<N; a++){
        cout << B[a];
        cout << " ";
    }

    return 0;
}

Measured memory_bytes: 1536
a = gets.chomp
b = gets.chomp
c = gets.chomp

player = "a"
ind_hash = {"a" => 0, "b" => 0, "c" =>0}
hand_hash = {"a" => a, "b" => b, "c" =>c}

while true
  ind = ind_hash[player]
  card = hand_hash[player][ind]
  break if card.nil?
  
  ind_hash[player] += 1
  player = card
end

puts player.upcase


Measured memory_bytes: 14256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
int sum[100100];

int main() {
	cin >> n;
	fill(sum, sum + 100100, 0);
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		sum[a]++;
		sum[b + 1]--;
	}
	int ans = 0;
	REP(i, n + 1) {
		sum[i + 1] += sum[i];
	}
	FOR(i, 1, n + 2) {
		if (i - 1 <= sum[i]) {
		//cout << sum[i];
			ans = max(ans, i - 1);
			//if (sum[i] >= i)ans = max(ans, i - 1);
			//else ans = max(ans, i);
		}
		//else if (i - 1 == sum[i])ans = max(ans, i - 1);
	}
	cout << ans << endl;
}

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

int main() {

  int a,b,c;
  cin>>a>>b>>c;
  int ans = 0;
  for(int i=a;i<=b;i++){
      if(c%i==0) ans++;
  }
  cout << ans << endl;
  return 0;
  

}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N == 7 || N == 5 || N == 3) {
			System.out.print("YES");
		} else {
			System.out.print("NO");
		}
	}
}

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

int main() {
  int N, M; cin >> N >> M;
  int H[N]; for (int i = 0; i < N; i++) cin >> H[i];
  list<int> E[N];
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b; a--; b--;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  int c = 0;
  for (int i = 0; i < N; i++) {
    bool g = true;
    for (auto it = E[i].begin(); it != E[i].end(); it++) {
      if (H[i] <= H[*it]) g = false;
    }
    c += g;
  }
  cout << c << endl;
}

Measured memory_bytes: 12600