akhauriyash/Code-Regression huggingface dataset:
#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 <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,y[500010],n[500010];
ll end[500010],nosave[500010],dep[500010],ans[500010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N-1)cin>>y[i]>>n[i],y[i]--,n[i]--;
	
	end[N-1]=1;
	for(int i=N-2;i>=0;i--){
		end[i] = end[y[i]] + end[n[i]];
	}
	
	nosave[N-1]=0;
	for(int i=N-2;i>=0;i--){
		nosave[i] = end[y[i]]+nosave[y[i]] + end[n[i]]+nosave[n[i]];
	}
	
	dep[0]=0;
	rep(i,N-1){
		dep[y[i]] = dep[n[i]] = dep[i]+1;
	}
	
	ans[N-1]=0;
	for(int i=N-2;i>=0;i--){
		ans[i] = min( 1+ans[y[i]] + dep[i] + 1+ans[n[i]], min(
			end[y[i]]+nosave[y[i]] + 1+ans[n[i]],
			end[n[i]]+nosave[n[i]] + 1+ans[y[i]]) );
	}
	cout<<ans[0]<<endl;
}

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

int main(){
    int a, b, c, temp;
    
    cin >> a >> b >> c;
    
    if (a > b){
        temp = a;
        a = b;
        b = temp;
    }
    
    if (b > c){
        temp = b;
        b = c;
        c = temp;
    }
    
    if (a > b){
        temp = a;
        a = b;
        b = temp;
    }
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}



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

using namespace std;

const int maxi = 1e6+10;

int n;
int a[maxi];
int d[maxi];
int b[maxi];
int m;

int main()
{
    cin>>n;

    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
//       a[i]  = 0;

    long long  ans = 0;

   int m = 1;
   b[1] = a[1];

   for (int i=2;i<=n;i++)
     if (a[i])
     {
         b[++m] = a[i];
     } else d[m]++;

        for (int i=1;i<=m;i++)
    ans+=(1ll*d[i] * (d[i]+1))/2;

    for (int i=1;i<=m;i++)
    {
        int sum = 0;
        int xs = 0;

        for (int j=i;j<=min(22+i, m);j++)
        {
            xs^=b[j];
            sum+=b[j];
            if (xs==sum) {ans = ans + 1ll * (d[i-1] + 1) * (d[j]+1); } else break;
        }
    }

    cout<<ans<<endl;
}


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

int main(){
  ll i,j,k,s,cnt=1ll;
  cin >> s;
  bool x[1000010]={};
  x[s]=true;
  while(1){
    if(s%2==0)s=s/2;
    else s=3*s+1;
    cnt++;
    if(x[s]){
      cout << cnt << endl;
      return 0;
    }
    x[s]=true;
  }
  return 0;
}


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

static class Program
{
    static void Main(string[] args)
    {
        //入力
        var input = Console.ReadLine();

        //処理
       var list = input.GroupBy(i => i).Select(x => new{ n = x.Key, c = x.Count()});

        //出力
        Console.WriteLine(list.All(i => i.c % 2 == 0) ? "Yes": "No");

    }
}

Measured memory_bytes: 13408
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = np.array(lr())
recover = D[:, None] * D[None, :]
np.fill_diagonal(recover, 0)
answer = recover.sum() // 2
print(answer)


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

const int N = 2e5 + 10, mod = 1e9 + 7;



int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        int l; scanf("%d", &l);
        printf("%.12lf\n", pow((double)l / 3, 3));
    }    
    return 0;
}

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

//#define DEBUG

int main(void)
{
  int N;
  cin >> N;
  
  vector<int> a(N+1,0);
  vector<int> b(N+1,0);
  
  vector<pair<int,int>> vp;
  vector<vector<int>> G(N+1);
  
  for(int i=1;i<N;i++)
  {
    cin >> a[i] >> b[i];
    vp.emplace_back(a[i],b[i]);
    G[a[i]].emplace_back(b[i]);
    G[b[i]].emplace_back(a[i]);
    
  }
  
  int K=0; // 最大辺数（カラー個数）
  
  // 1〜Nの節点を幅優先で選択し、辺の色(I)をつける。
  map<pair<int,int>,int> I;	// 辺の色。節点pairをキーとして整数を代入。（順不同）
  vector<bool> used(N,false);	// 終了した節点にフラグを建てる。
  queue<int> que;
  
  que.emplace(1);	// 初期値に1を入れる
  used[1] = 1;	// 1に完了フラグを建てる。
  while(!que.empty()) // キューが空になったら終了
  {
    int colornum=1;	// 色番号
    int v;	// 探索中の節点番号
    v = que.front();
    que.pop();
    
#ifdef DEBUG
    cout << "v=" << v << endl;
#endif
    if(K<G[v].size()) K=G[v].size();	// 最大値更新

    // 親の色を格納するための変数を定義
    int pairent_color = 0;
    for(int i=0;i<G[v].size();i++)
    {
      int w;
      w = G[v][i];	// v節点に接続している節点をwとする（size分繰り返し）
      if(used[w]) pairent_color = I[make_pair(v,w)];
    }
      
    for(int i=0;i<G[v].size();i++)	// その節点に接続する節点数繰り返し
    {
      int w;
      w = G[v][i];	// v節点に接続している節点をwとする（size分繰り返し）
#ifdef DEBUG
      cout << "w=" << w << endl;
#endif
      // 親の場合、親との辺の色を格納する
      if(used[w])
      {
        pairent_color = I[make_pair(v,w)];
        continue;	// 色付け済の節点は、再度の色付けをしない。
      }
      
      // 色付け
      if(colornum == pairent_color) colornum++; // 親の色を避ける
      I[make_pair(v,w)]=I[make_pair(w,v)]= colornum; // 色付け

#ifdef DEBUG
      cout << "I=" << I[make_pair(v,w)] << endl;
#endif

      colornum++; // 色をインクリメント
      used[w]=true;
      que.emplace(w);
    }
  }
  cout << K << endl;
  for(auto ii:vp) cout << I[ii] << endl;
   
  return 0;
}


Measured memory_bytes: 20084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 998244353;

template <class T>
struct BIT {
    BIT(int n) : b(n + 1), n(n) {}
    void add(int i, T v) {
        for (int k = i + 1; k <= n; k += k & -k) b[k] += v;
    }
    T sum(int k) {
        T s = 0;
        for (; k > 0; k -= k & -k) s += b[k];
        return s;
    }
    vector<T> b;
    int n;
};

struct S {
    int l, r;
};

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

    int n, k;
    cin >> n >> k;
    n--;

    vector<S> s(k);
    for (int j = 0; j < k; j++) {
        int l, r;
        cin >> l >> r;
        l--;

        s[j] = { l, r };
    }

    BIT<ll> bt(n + 1);
    bt.add(0, 1);
    for (int i = 1; i <= n; i++) {
        ll t = 0;
        for (int j = 0; j < k; j++) {
            t += bt.sum(max(i - s[j].l, 0));
            t -= bt.sum(max(i - s[j].r, 0));
        }
        t %= P;
        if (i == n) {
            cout << t << endl;
            break;
        }
        bt.add(i, t);
    }

    return 0;
}

Measured memory_bytes: 4756
n,l=[int(i) for i in input().split()]
arr=[]
for i in range(1,n+1):
    arr.append(l+i-1)
tot = sum(arr)
diff = 10**9
ans=0
for i in range(len(arr)):
    cur_diff = abs(tot - (tot-arr[i]))
    if(abs(tot-(tot-arr[i]))<diff):
        diff = abs(tot-(tot-arr[i]))
        ans = tot-arr[i]
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;


int main(){
    string ans;
    ll a,b; cin>>a>>b;
    if(b<0){
        if((b-a)%2==1){
            ans="Positive";
        }else{
            ans="Negative";
        }
    }else if(b==0){
        ans="Zero";
    }else{
        if(a>0){
            ans="Positive";
        }else{
            ans="Zero";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define int long long
# define endl "\n"
using namespace std;

const int SIZE = 1e7 + 1;
int arr[SIZE];

void pre(int n) {

	for (int i = 1; i <= n; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i <= n; i++) {
		for (int j = i; j <= n; j += i) {
			arr[j]++;
		}
	}
}

void solve() {

	int n;
	cin >> n;

	pre(n);

	int Sum = 0;
	for (int i = 1; i <= n; i++) {
		Sum += i * arr[i];
	}
	cout << Sum << endl;
}

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif

	solve();

	return 0;
}

Measured memory_bytes: 81748
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,inn[21],tmp_high=0,sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>inn[i];
		if(inn[i]>=tmp_high){
			tmp_high=inn[i];sum++;
		}
	}
	cout<<sum<<endl;
 	return 0;
 }


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


int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B < C + D) cout << "Right" << endl;
	else if (A + B > C + D) cout << "Left" << endl;
	else cout << "Balanced" << endl;
    return 0;
}



Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
#(sx,sy)R(tx,sy)U(tx,ty)L(sx,ty)D(sx,sy)
# D(sx,sy-1)R(ts+1,sy-1)U(ts+1,ty)L(ts,ty)U(ts,ty+1)L(sx-1,ty+1)D(sx-1,sy)R(sx,sy)
print("R"*(tx-sx)+"U"*(ty-sy)+"L"*(tx-sx)+"D"*(ty-sy)+"D"+"R"*(tx+1-sx)+"U"*(ty-sy+1)+"L"+"U"+"L"*(tx-sx+1)+"D"*(ty+1-sy)+"R")


Measured memory_bytes: 3060
class unionfind:
	def __init__(self,n):
		self.size = n
		self.ufp = [i for i in range(n)]
		self.ufr = [1 for i in range(n)]
	def find(self,x):
		if x == self.ufp[x]:
			return x
		else:
			self.ufp[x] = self.find(self.ufp[x])
			return self.ufp[x]
	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return 0
		if self.ufr[x] > self.ufr[y]:
			self.ufp[y] = x
			self.ufr[x] += self.ufr[y]
			return ((self.ufr[x]-self.ufr[y])*self.ufr[y])
		else:
			self.ufp[x] = y
			self.ufr[y] += self.ufr[x]
			return ((self.ufr[y]-self.ufr[x])*self.ufr[x])


n,m=map(int,input().split())
ans=[n*(n-1)//2]
g=[list(map(lambda a:int(a)-1,input().split())) for i in range(m)]
uf = unionfind(n)
for v in reversed(g):
	ans.append(ans[-1]-uf.union(v[0],v[1]))
for v in reversed(ans[:-1]):
	print(v)

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

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

  const int mod = 1e9 + 7;

  int bigger = max(n, m);
  int smaller = min(n, m);
  vector<long long int> fact(bigger+1, 0);
  fact[0] = 1;
  for(long long int i=1;i<=bigger;i++) {
    fact[i] = (fact[i-1] * i) % mod;
  }
  if(bigger - smaller > 1) cout << 0 << endl;
  else if (bigger - smaller == 1) {
    cout << fact[bigger] * fact[smaller] % mod << endl;
  } else {
    cout << fact[bigger] * fact[smaller] * 2 % mod << endl;
  }
}

Measured memory_bytes: 1024
import math
import itertools

n=int(input())
town=[]
length=0
pattern=math.factorial(n)
for i in range(n):
    tmp=list(map(int,input().split()))
    town.append(tmp)
town_all=list(itertools.permutations(town))
for i in town_all:
    for j in range(n-1):
        x_length=(i[j+1][0]-i[j][0])**2
        y_length=(i[j+1][1]-i[j][1])**2
        length+=math.sqrt(x_length+y_length)

print(length/pattern)


Measured memory_bytes: 47212
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	bool a=false,b=false;	
	for(int i=0;i<3;i++){
		if(s[i] == 'A'){
			a=true;
		}
		else{
			b=true;
		}
	}
	if(a && b){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
string s[10001],t[10001];
string p;
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=n ;i++){
		cin >> s[i];
		t[i]=s[i];
		for(int j=0; j<s[i].size() ;j++){
			if(s[i][j]=='?') s[i][j]='a',t[i][j]='z';
		}
	}
	cin >> p;
	int cnt1=0,cnt2=0;
	for(int i=1; i<=n ;i++){
		if(s[i]<=p) cnt1++;
		if(t[i]<p) cnt2++;
	}
	for(int i=cnt2+1; i<=cnt1+1 ;i++){
		cout << i << " \n"[i==cnt1+1];
	}
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define N 200010
ll n,l[N],r[N],k[N];
vector<ll> v1[N],v2[N];
void solve(){
	cin>>n;
	rep(i,n+1){
		v1[i].clear();
		v2[i].clear();
	}
	ll base=0;
	ll cnt1=0,cnt2=0;
	rep(i,n){
		cin>>k[i]>>l[i]>>r[i];
		if(l[i]>=r[i]){
			v1[k[i]-1].push_back(l[i]-r[i]);
			base+=r[i];
			cnt1++;
		}
		else{
			v2[k[i]].push_back(r[i]-l[i]);
			base+=l[i];
			cnt2++;
		}
	}
	priority_queue<ll> Q;
	for(ll i=n-1;i>=0;i--){
		for(auto v:v1[i])Q.push(v);
		if(i<cnt1){
			if(!Q.empty()){
				base+=Q.top();
				Q.pop();
			}
		}
	}
	while(!Q.empty())Q.pop();
	for(ll i=0;i<n;i++){
		for(auto v:v2[i])Q.push(v);
		if(cnt1<=i){
			if(!Q.empty()){
				base+=Q.top();
				Q.pop();
			}
		}
	}
	cout<<base<<"\n";
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	ll t;
	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 23096
import sys
f=lambda:map(int,sys.stdin.readline().split())
_,_,n=f()
a,b=list(f()),list(f())
m=min(a)+min(b)
for _ in range(n): x,y,c=f(); m=min(m,a[x-1]+b[y-1]-c)
print(m)

Measured memory_bytes: 18616
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 1;

int main() {
  int N, a, pre, ans = 0; cin >> N >> pre;
  for (int i = 1; i < N; i++) {
    cin >> a;
    if (a == pre) {
      ans++;
      pre = -1;
    } else {
      pre = a;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c-'0'; len++; c=getchar_unlocked(); } *s='\0'; return len; }
void printint(uint32_t x){ if(x<0){x=-x; putchar_unlocked('-');}else if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }
void rsort_str(void *base, const int count, const int size);

char s[200001];
uint32_t m[2019]={1};

int main(void){
	uint32_t n=nextstr(s);
	uint32_t a=0, b=1;
	for(int32_t i=n-1; i>=0; i--){
		a+=b*s[i];
		a%=2019;
		m[a]++;
		b*=10;
		b%=2019;
	}
	uint64_t ans=0;
	for(uint32_t i=0; i<2019; i++){
		ans+=(uint64_t)m[i]*(m[i]-1)/2;
	}
	printf("%"PRIu64"\n", ans);
}


Measured memory_bytes: 1760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x < y) x = y;}
template<class T> void chmax(T& x, T y){if(x > y) x = y;}
int N, M;
int main(){
    cin >> N >> M;
    cout << (N * (N - 1) + M * (M - 1)) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int main(){
	int a,b,ans[201]={},i=0;
	while(cin>>a>>b){
		int q;
		q=a+b;
		while(1){
			if(q/10!=0){
				ans[i]++;
				q=q/10;
			}
			else break;
		}
		cout<<ans[i]+1<<endl;
		i++;
	}
}

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


int main(){
	int n ;
	string s ;

	cin >>n >> s ;
	int count = 1 ;
	char t = s[0] ;
	for( int i = 1 ; i < n ; i++ ){
		if( s[i] != t ){
			t = s[i] ;
			count++ ;
		} 
	}
	cout << count << endl ;


	return 0 ;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 1e5; // CAMBIAR ESTE

// GJNM
char mat[105][105];
bool vis[105][105];

int main(){
	int r,c;
	rii(r,c);
	priority_queue< pair< int , pair< int , pair< int , int > > > > pq;
	int ans = INF;
	FOR(i,0,r){
		scanf("%s",mat[i]);
	}

	if ( mat[0][0] == '#' )
		pq.push({-1,{-1,{0,0}}});
	else
		pq.push({0,{0,{0,0}}});

	while(!pq.empty()){
		auto p = pq.top();
		pq.pop();
		if ( p.s.s.f == r-1 && p.s.s.s == c-1 ){
			ans = -p.f;
			break;
		}
		int row = p.s.s.f;
		int col = p.s.s.s;

		if ( p.s.f == 0 ){ // white
			if ( row < r-1 && mat[row+1][col] == '.' && !vis[row+1][col])
				pq.push({ p.f , { 0 , { row+1 , col } } } );
			if ( col < c-1 && mat[row][col+1] == '.' && !vis[row][col+1])
				pq.push({ p.f , { 0 , { row , col+1 } } } );
			if ( row < r-1 && mat[row+1][col] == '#' && !vis[row+1][col])
				pq.push({ p.f-1 , { -1 , { row+1 , col } } } );
			if ( col < c-1 && mat[row][col+1] == '#' && !vis[row][col+1])
				pq.push({ p.f-1 , { -1 , { row , col+1 } } } );

		}
		else{ // black
			if ( row < r-1 && mat[row+1][col] == '.' && !vis[row+1][col])
				pq.push({ p.f , { 0 , { row+1 , col } } } );
			if ( col < c-1 && mat[row][col+1] == '.' && !vis[row][col+1])
				pq.push({ p.f , { 0 , { row , col+1 } } } );
			if ( row < r-1 && mat[row+1][col] == '#' && !vis[row+1][col])
				pq.push({ p.f , { -1 , { row+1 , col } } } );
			if ( col < c-1 && mat[row][col+1] == '#' && !vis[row][col+1])
				pq.push({ p.f , { -1 , { row , col+1 } } } );
		}
		vis[row][col] = true;
	}

	

	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 		//座標で
        int[][] c = new int[3][3];
        for(int i=0; i<3; i++) {
            for(int j=0; j<3; j++) {
                c[i][j] = sc.nextInt();
            }
        }
 
        int[] x = new int[3];
        int[] y = new int[3];
      	//y[0] =c[0][0]-x[0]するため代入
        x[0] = 0;
        for(int i=0; i<3; i++) {
            y[i] = c[0][i] - x[0];
        }
        for(int i=0; i<3; i++) {
            x[i] = c[i][0] - y[0];
        }
 
        for(int i=0; i<3; i++) {
            for(int j=0; j<3; j++) {
                if(c[i][j] != x[i]+y[j]) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 35688
#include <math.h>
#include <iostream>
using namespace std;

int main()
{
int a,b,ans;
string op;
cin >> a >> op >> b ;
while (op!="?")
{
if(op=="+")ans=a+b;
else if(op=="-")ans=a-b;
else if(op=="/")ans=a/b;
else ans=a*b;
cout << ans << endl;
cin >> a >> op >> b ;
}
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    ll n, x, d;
    cin >> n >> x >> d;
    if(d == 0)
    {
        if(x == 0)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << n+1 << endl;
        }
        return 0;
    }
    if(d < 0)
    {
        d *= -1;
        x *= -1;
    }
    vector<ll> sum(n+1);
    for(int i = 1; i <= n; i++)
    {
        sum[i] = sum[i-1] + i-1;
    }
    map<ll, vector<P>> m;
    for(int i = 0; i <= n; i++)
    {
        ll k = i * x % d;
        P v = P(i*x/d + sum[i], i*x/d + sum[n] - sum[n-i]);
        m[k].push_back(v);
    }
    ll ans = 0;
    for(auto itr = m.begin(); itr != m.end(); itr++)
    {
        vector<P> v = itr->second;
        sort(v.begin(), v.end());
        ll ma = 0;
        for(int i = 0; i < v.size(); i++)
        {
            P p = v[i];
            ll l = p.first;
            ll h = p.second;
            if(i == 0)
            {
                ans += h - l + 1;
                ma = h;
                continue;
            }
            if(h <= ma) continue;
            if(l <= ma)
            {
                ans += h - ma;
            }
            else
            {
                ans += h - l + 1;
            }
            ma = h;
        }
    }
    cout << ans << endl;
}


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

const ll INF = 1000000000000000001LL;

void solve() {
    int n;
    scanf("%d", &n);
    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        ll a;
        scanf("%lld", &a);
        if (a <= INF/ans) ans *= a;
        else ans = INF;
        if (ans == 0) break;
    }
    if (ans == INF) ans = -1;
    printf("%lld\n", ans);
}

int main(){

    solve();
	return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>
int main(void){
 
  int x,y,z,w;
  int a,b;
  scanf("%d%d%d%d",&x,&y,&z,&w);
 if(x<y) a=x;
  else a=y;
  if(z<w) b=z;
  else b=w;
  
  printf("%d",a+b);
 
  
 
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		if( a % 1000 != 0){
			System.out.println(1000 - (a % 1000));
		}else{
			System.out.println(0);
	
		}
		}
}

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

int main()
{
    long long i, j, k, n, t, x, y, s=0, c=0, l;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    cout << a[n-1]-a[0];
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        st: [(usize1, usize1); m],
    }

    let mut g = vec![vec![]; n];

    for (u, v) in st {
        g[u].push(v);
    }

    let mut ans = 1e10_f64;
    for i in 0..n {
        ans = ans.min(solve(0, &g, i, &mut vec![None; n]));
    }
    println!("{:.12}", ans);
}

fn solve(u: usize, g: &[Vec<usize>], i: usize, tbl: &mut [Option<f64>]) -> f64 {
    if u == tbl.len() - 1 {
        return 0.;
    }

    if let Some(ret) = tbl[u] {
        return ret;
    }

    let cs = g[u]
        .iter()
        .map(|&v| solve(v, g, i, tbl))
        .collect::<Vec<_>>();

    let sum: f64 = cs.iter().sum();
    let mut ret = sum / cs.len() as f64 + 1.;

    if u == i && cs.len() > 1 {
        for i in 0..cs.len() {
            ret = ret.min((sum - cs[i]) / (cs.len() - 1) as f64 + 1.0);
        }
    }

    tbl[u] = Some(ret);
    ret
}


Measured memory_bytes: 10492
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = a[0] + sum(b)
c = m
for i in range(n-1):
  x = a[i+1] - b[i] 
  c += x
  if c > m:
    m = c

print(m)
  
  
  


Measured memory_bytes: 3060
def abc114_c():
  n = int(input())

  def bit_mask(n):
    b, d = 4, 9  # bit, digit
    arr = []
    for i in range(d-1, -1, -1):
      arr.append(n // (b**i))
      n = n % (b**i)
    ret = str(int(''.join(map(str, arr))))
    return ret

  def decode753(arr):
    ret = ''.join(map(str, arr)).replace('3','7').replace('2','5').replace('1','3')
    return int(ret)

  ans = 0
  b, d = 4, 9
  for m in range(b**d):
    mask = bit_mask(m)
    if mask.count('0') == 0 and mask.count('1') > 0 and mask.count('2') > 0 and mask.count('3') > 0:
      x = decode753(mask)
      if x <= n: ans += 1
      else: break
  print(ans)

abc114_c()

Measured memory_bytes: 45020
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input! {
        mut s: u64,
    }

    let mut x = 1;
    let mut map = HashMap::new();

    loop {
        match map.get(&s) {
            Some(_) => {
                println!("{}", x);
                break;
            }
            None => {
                map.insert(s, x);
            }
        }
        s = if s % 2 == 0 { s / 2 } else { s * 3 + 1 };
        x += 1;
    }
}


Measured memory_bytes: 4476
#include <cstdio>
#define MAX_N 100000
using namespace std;

int n, l;
long long a[MAX_N];

int main(){
  scanf("%d %d", &n, &l);
  for(int i = 0; i < n; i++){
    scanf("%lld", &a[i]);
  }

  for(int i = 0; i < n - 1; i++){
    long long sum = a[i] + a[i + 1];
    if(sum >= l){
      printf("Possible\n");
      for(int j = 0; j < i; j++){
        printf("%d\n", j + 1);
      }
      for(int j = n - 2; j >= i; j--){
        printf("%d\n", j + 1);
      }
      return 0;
    }
  }

  printf("Impossible\n");

  return 0;
}


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

int main(int argc, char *argv[])
{
    string s, p;
    cin >> s >> p;
    s += s; // 環状化
    if (s.find(p) != string::npos)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3180
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 210000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
const ll ainf = 998244353;
int uf[100010];
int ufc[100010];
void uinit(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		ufc[i] = 1;
		uf[i] = i;
	}
}

int parent(int x) {
	if (uf[x] == x) return x;
	return uf[x] = parent(uf[x]);
}

ll unite(int x, int y) {
	int xp = parent(x);
	int yp = parent(y);
	if (xp == yp) return 0;
	ll res = ufc[xp] * ufc[yp];
	if (xp < yp) {
		uf[yp] = xp;
		ufc[xp] += ufc[yp];
	}
	else {
		uf[xp] = yp;
		ufc[yp] += ufc[xp];
	}
	return res;

}
void solv() {
	int n,m;
	cin >> n >> m;
	int a[100010], b[100010];
	ll sum = (n * (n - 1LL)) / 2LL;
	uinit(n);
	for (size_t i = 0; i < m; i++)
	{
		cin >> a[i] >> b[i];
	}
	ll res[100010];
	res[0] = 0;
	for (int i = m - 1; i >= 0; i--)
	{
		ll v = unite(a[i], b[i]);
		res[i] = sum;
		sum -= v;
	}
	for (size_t i = 0; i < m; i++)
	{
		cout << res[i] << endl;
	}
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define pow107 int(pow(10,9) + 7)
#define F(i,x,n) for(int i = x; i < n ; ++i)

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

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

inline bool pn(long int x){
    if(x <= 1)return false;
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i <= (3 + int(sqrt(x)))/2; ++i){
        if((x != i && x % i == 0) || (x != (3 + int(sqrt(x)) - i) && x % (3 + int(sqrt(x)) - i) == 0))
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

void warfl(vector<vector<int> > &dist, int n){
  for(int k=0; k<n; k++){
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  return;
}
//#define long long long

const int MAX = 1000000;
const int MOD = 1e9+7;

long mpow(long x, long n){
    long ans = 1;
    while(n != 0){
        if(n%2==1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n/2;
    }
    return ans;
}

long mfact(long n){
  long ans = 1;
  for(long i=2; i<=n; i++){
    ans = ans*i % MOD;
  }
  return ans;
}

long mcomb(long n, long m){ //aCbをmod計算
    if(n == 0 && m == 0) return 1;
    if(n < m || n < 0) return 0;
    long ans = mfact(n)*mpow(mfact(m), MOD-2) %MOD;
    ans = ans*mpow(mfact(n-m), MOD-2) %MOD;
    return ans;
}

long int jjjjj(long int n){
    long int x = 1;
    for(int i = 1; i <= n; ++i){
        x *=i;
    }
    return x;
}

int main(){
    int n,t,a,b,bt = 0,ba = 0,bb = 0;
    cin >> n;
    string s = "Yes";
    for(int i = 0; i < n; ++i){
        cin >> t >> a >> b;
        if((t - bt) >= (abs(a - ba) + abs(b - bb)) && (t - bt) % 2 == (abs(a - ba) + abs(b - bb)) % 2){
            ;
        }else{
            //cout << "#" << i << "#" << endl;
            s = "No";
        }
        bt = t;
        ba = a;
        bb = b;
    }

    cout << s << endl;

}

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

typedef long long ll;
using namespace std;

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> v(100007, 0);
	for(auto& x : a){
		cin >> x;
		++v[x];
	}
	int ans = 0;
	for(int i = 1; i < 100000; ++i){
		int k = 0;
		for(int j = i - 1; j <= i + 1; ++j)
			k += v[j];
		ans = max(ans, k);
	}
	cout << ans << endl;
}


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

typedef long long ll;

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

    int a,b;
    cin >> a >> b;
    string s;
    int ans = 0;
    for(int i=a;i<b+1;i++){
        s = to_string(i);
        if(s[0]==s[4] && s[1]==s[3]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  if (n < 2 * m - 1) {
    puts("-1");
    return 0;
  }
  vector<ii> a;
  int L = (n + 1) / 2;
  for (int i = 0, j = n - L; i < L; ++i, ++j) {
    a.emplace_back(m + i, m + n + j);
  }
  for (int i = L, j = 0; i < n; ++i, ++j) {
    a.emplace_back(m + i, m + n + j);
  }
  sort(a.begin(), a.end(), [](const ii& u, const ii& v) {
                             return u.first + u.second < v.first + v.second;
                           });
  for (int i = 0; i < n; ++i) {
    printf("%d %d %d\n", a[i].first, a[i].second, m + 2 * n + i);
  }
  return 0;
}


Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#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 ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;

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

	int a, b;
	cin >> a >> b;
	string ans;
	if ((a==1) || (b==1))
	{
		if (a==b)
			ans = "Draw";
		else if (a == 1)
			ans = "Alice";
		else
			ans = "Bob";
	}
	else
	{
		if (a > b)
			ans = "Alice";
		else if (a==b)
			ans = "Draw";
		else
			ans = "Bob";
	}
	cout << ans << endl;
	return 0;
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#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)



int main(void){

	
	int X; cin >> X;

	if(X == 7 or X == 5 or X == 3) cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;

}


Measured memory_bytes: 256
A , B = gets.split.map{|i| i.to_i}

if A % 2 == 0
    if A % 4 == 0
        x = 0
    else
        x = 1
    end
else
    if (A - 1) % 4 == 0
        x = A - 1
    else
        x = (A - 1) ^ 1
    end
end

if (B + 1) % 2 == 0
    if (B + 1) % 4 == 0
        y = 0
    else
        y = 1
    end
else
    if B % 4 == 0
        y = B
    else
        y = B ^ 1
    end
end

puts x ^ y

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	vector<int> v(3,0);
	
	for (int i = 0; i < 3; i++) {
		cin >> v[i];
	}

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

	cout << (v[0] * v[1]) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
s = input()
l1 = []
l2 = [0]
prev = "1"
for i in s:
    if i =="1":
        if prev == "0":
            l2.append(1)
        else:
            l2[-1]+=1
    else:
        if prev =="1":
            l1.append(1)
        else:
            l1[-1]+=1
    prev = i
l2.append(0)

res = sum(l2[:k+1])+sum(l1[:k])
ans = res
for i in range(1,len(l1)-k+1):
    res -= l2[i-1]+l1[i-1]
    res += l2[i+k]+l1[i+k-1]
    ans = max(ans,res)
print(ans)

Measured memory_bytes: 4456
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (a.at(i) == b.at(i) && b.at(i) == c.at(i)) {
        } else if (a.at(i) == b.at(i)) {
            cnt++;
        } else if (b.at(i) == c.at(i)) {
            cnt++;
        } else if (c.at(i) == a.at(i)) {
            cnt++;
        } else {
            cnt += 2;
        }
    }
    cout << cnt << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


n = int(input())
ans = 0
pattern = 0
list = [0] * n
for i in range(n):
    for j in range(n):
        for k in range(n):
            ans += gcd(i + 1, j + 1, k + 1)
print(ans)

Measured memory_bytes: 69584
#include <iostream>

#define MAX_N 100

int  N;
long T[MAX_N];

long gcd(long a, long b) {
    if (a%b == 0) return b;
    return gcd(b, a%b);
}

long lcm(long a, long b) {
    if (a == 0 || b == 0) return 0;
    return (long) (a / gcd(a, b))*b;
}

long solve() {
    if (N == 1) return T[0];
    long res = lcm(T[0], T[1]);
    for (int i=2; i<N; ++i) res = lcm(res, T[i]);
    return res;
}

int main() {
    std::cin >> N;
    for (int i=0; i<N; ++i) std::cin >> T[i];
    std::cout << solve() << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r<0||x+r>W||y-r<0||y+r>H){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 2112
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c, d ] <- readInts
	print $ max ( a * b ) ( c * d )


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int a, b;
	cin >> a >> b;
	a--;
	b--;
	// cerr << b << ' ' << a << endl;
	cout << (b + a - 1) / a << endl;
}


Measured memory_bytes: 256
import java.util.*;



/*
 * Aizuuuuuuu
 * 
 */
public class Main {
	public static void print(ArrayList<String> list) {
		for (String i :list) {
			System.out.println(i);
		}
	}
	public static void main(String[] args) {
		int globalTime = 0;
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int q = sc.nextInt();
		ArrayList<String> results = new ArrayList<String>();
		LinkedList<String> ns = new LinkedList<String>();
		LinkedList<Integer> qs = new LinkedList<Integer>();
		
		while (ns.size() < n) {
			ns.addLast(sc.next());
			qs.addLast(sc.nextInt());
		}
		
		String tempS = "";
		int tempI = 0;
		
		while (ns.size() > 0) {
			if (qs.peek() - q <= 0) {
				results.add(ns.poll() + " " + (qs.peek()+globalTime));
				globalTime += qs.poll();
			}
			else {
				tempI = qs.poll();
				tempI -= q;
				qs.addLast(tempI);
				ns.addLast(ns.poll());
				globalTime += q;
			}
		}
		print(results);
		
	}
}



Measured memory_bytes: 76836
n,k = map(int,input().split())
s = input()
edge,inside,cnt,ix = 0,0,0,0
if s[0]=='R' or s[-1]=='R':
  edge += 1
temp = ''
for i in range(n):
  if temp=='R' and s[i]=='L':
    inside += 1
  elif temp==s[i]:
    cnt += 1
  temp = s[i]
if inside>=k:
  print(min(k*2+cnt,n-1))
else:
  print(min(inside*2+edge+cnt,n-1))

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

int main()
{
    /*A
    int n,k;
    cin>>n>>k;
    vector <char> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }

    a[k-1]=tolower(a[k-1]);

    for(int i=0;i<n;i++)
    {
        cout<<a[i];
    }
    cout<<endl;
    */
    /*B
    int x;
    cin>>x;

    int L = x/100;
    int R = x%100;

    if(1<=L && L<=12)
    {
        if(1<=R && R<=12)
        {
            cout<<"AMBIGUOUS"<<endl;
        }
        else
        {
            cout<<"MMYY"<<endl;
        }
    }
    else
    {
        if(1<=R && R<=12)
        {
            cout<<"YYMM"<<endl;
        }
        else
        {
            cout<<"NA"<<endl;
        }
        
    }
    */

    
    int a,b;
    cin>>a>>b;
    double ret=0;
    for(int i=1;i<=a;i++){
        double tmp=1.0/a;
        int now=i;
        while(now<b){
            now*=2;
            tmp/=2;
        }
        ret+=tmp;
    }
    printf("%.12f\n",ret);
    
        
        return 0;
    }

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

using namespace std;

int xs[] = {0, 1, 0, -1}, ys[] = {1, 0, -1, 0};
char c[108][108];
int w, h;
bool come[108][108];
int dfs(int x, int y){
	if(x < 0 || y < 0 || x >= h || y >= w)return 0;
	if(c[x][y] == '#')return 0;
	if(come[x][y])return 0;
	come[x][y] = true;
	int res = 1;
	for(int i = 0;i < 4;i++){
		res += dfs(x + xs[i], y + ys[i]);
	}
	return res;
}

int main(){
	int si, sj;
	while(cin >> w >> h, w | h){
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				cin >> c[i][j];
				if(c[i][j] == '@'){
					si = i;
					sj = j;
				}
				come[i][j] = false;
			}
		}
		cout << dfs(si, sj) << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

N, M, L = [int(_) for _ in readline().split()]
ABCQST = np.array([int(_) for _ in read().split()], dtype=np.int64)
ABC = ABCQST[:3 * M]
ST = ABCQST[3 * M + 1:]
A, B, C = ABC[::3], ABC[1::3], ABC[2::3]
S, T = ST[::2], ST[1::2]
G = csr_matrix((C, (A, B)), shape=(N + 1, N + 1))
G2 = floyd_warshall(G, directed=0)
G3 = np.full((N + 1, N + 1), np.inf)
np.fill_diagonal(G3, 0)
G3[G2 <= L] = 1
G4 = floyd_warshall(G3, directed=0)
G4[G4 == np.inf] = 0
print(*(G4[S, T] - 1).astype(np.int64), sep='\n')


Measured memory_bytes: 35440