akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int n;
ll x;
ll a[111111];
int main(void){
  scanf("%d %lld",&n,&x);
  for(int i = 0; i < n; i++){
    scanf("%lld",a+i);
  }

  ll ans = 0;
  for(int i = 1; i < n; i++){
    if(a[i-1] + a[i] > x){
      ll t = (a[i-1]+a[i]) - x;
      ans += t;
      a[i] = max(0LL,a[i]-t);
    }
  }
  printf("%lld\n",ans);
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   double n;
   cin>>n;

   for(double i = 1; i < 2*n; i++){
      if(floor(i * 1.08) == n)
         return cout<<i,0;
   }

   cout<<":(";
   return 0;
}

Measured memory_bytes: 256
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<int(ceil(log2(double(n))))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
struct node{
	vector<int> chilren;
	vector<int> weight;
}a[100001];
int color[100001];
int flag[100001];
void dfs(int now){
	flag[now]=1;
	if(a[now].chilren.size()==0) return;
	rb(i,0,a[now].chilren.size()-1){
		if(flag[a[now].chilren[i]]==0){
//			cout<<a[now].chilren[i]<<endl;
			if(a[now].weight[i]%2==1){
				color[a[now].chilren[i]]=color[now]^1;
				
			}
			else{
				color[a[now].chilren[i]]=color[now];
//				cout<<a[now].chilren[i]<<endl;
			}
			dfs(a[now].chilren[i]);
		}
	}
}
int main(){
	color[1]=1;
	flag[1]=1;
	int n;
	scanf("%d",&n);
	rb(i,1,n-1){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
//		cout<<x<<" "<<y<<" "<<z<<endl;
		a[x].chilren.push_back(y);
		a[x].weight.push_back(z);
		a[y].chilren.push_back(x);
		a[y].weight.push_back(z);
	}
	dfs(1);
	rb(i,1,n){
		cout<<color[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13952
#include<stdio.h>
int main(){
int n,a[100000],max=-1000000,min=10000000;
long sum=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<n;i++){
if(max<=a[i]){
max=a[i];
}if(min>=a[i]){
min=a[i];
}
sum+=(long)a[i];
}
printf("%d %d %ld\n", min, max, sum);
}

Measured memory_bytes: 1072
n,m,c = map(int,input().split())
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	a = [int(i) for i in input().split()]
	sum = c
	for i in range(m):sum+=b[i] * a[i]
	ans+=sum > 0
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

	public static void main(String[] args)throws IOException  {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		 List<Integer> list = new ArrayList<Integer>();
		 for (String s : Arrays.asList(br.readLine().trim().split("\\s+"))) list.add(Integer.parseInt(s));
		 
		 int a = list.get(0), b = list.get(1);
		 
		 System.out.println(""+(a*b)+" "+(2*a+2*b));
		 
	}

}

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

using namespace std;

string s, c0, cn;
void ask(int seat) {
   cout << seat << endl;
   cin >> s;
   if(s == "Vacant") {
      exit(0);
   }
}
string expected(int seat) {
   int r = seat % 2;
   if(r == 0)
      return c0;
   return cn;
}

int main() {
   //ifstream cin("data.in");
   int n;
   cin >> n;
   int st = 0, dr = n - 1;
   ask(0);
   c0 = s;
   ask(n - 1);
   cn = s;
   while(st <= dr) {
      int mid = (st + dr) >> 1;
      ask(mid);
      if(expected(mid)!=s)
      {
          dr = mid - 1;
      }
      else st = mid + 1;
   }

}


Measured memory_bytes: 852
/* 
		BURN OUT
	*/	  
		#include <bits/stdc++.h>
		using namespace std;
			     
		#define ll long long int
		#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
			     
		#define mp make_pair
		#define pb push_back
		#define ld long double
		#define F first
		#define S second
		const ll N =(1e6);  
		const ll mod = (1e9+7);

	int main(){
	fast;
	string s;
	int n ;
	cin >> n ;
	cin >> s;
	int c = 1;
	for(int i = 0 ; i < s.size()-1 ; i++){
		if(s[i]!=s[i+1])
			c++;
	}
	cout<<c;
	}

Measured memory_bytes: 512
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
def ConvexHullScan(P) :
 P = sorted(P)
 phU = []
 phU.append(P[0])
 phU.append(P[1])
 for p in P[2:] :
  phU.append(p)
  if isCLKWISE(phU) : continue
  while(True) :
   del phU[-2]
   try:
    if isCLKWISE(phU) : break
   except IndexError : break
 phL = []
 phL.append(P[-1])
 phL.append(P[-2])
 for p in P[-3::-1] :
  phL.append(p)
  if isCLKWISE(phL) : continue
  while(True) :
   del phL[-2]
   try:
    if isCLKWISE(phL) : break
   except IndexError : break
 ph = phU + phL[1:-1]
 return ph
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
P = P[idx:] + P[:idx]
for p in P : print(p[0],p[1])

Measured memory_bytes: 33104
#include<stdio.h>

int main(){
	int i,j,n,a,b,c,x,y[10001];
	while(1){
		scanf("%d %d %d %d %d",&n,&a,&b,&c,&x);
		if(n==0&&a==0&&b==0&&c==0&&x==0)break;
		j=0;
		for(i=0;i<n;i++)scanf("%d",&y[i]);
		for(i=0;i<=10000;i++){
			if(y[j]==x)j++;
			if(j==n)break;
			x=(a*x+b)%c;
		}
		printf("%d\n",( i > 10000 ? -1 : i));
	}
	return 0;
}

Measured memory_bytes: 604
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	string n;
	cin >> n;
	int sum = 0;
	for (char c : n) {
		sum += c - '0';
	}
	bool ans = sum % 9 == 0;
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3716
#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 N, K; cin >> N >> K;
  vector<ll> A(N, 0);
  REPLL(i, N){
    cin >> A[i];
  }

  while(K > 0){
    vector<ll> AA(N+2, 0);
    REPLL(i, N){
        if(A[i] != 0){
            ll l = ((i+1)-A[i] < 0 ? 0 : (i+1)-A[i]);
            ll r1 = ((i+1)+1 > N ? N+1 : (i+1)+1);
            ll r2 = ((i+1)+A[i]+1 > N ? N+1 : (i+1)+A[i]+1);
            AA[l]++;
            AA[i+1]--;
            AA[r1]++;
            AA[r2]--;
        }
    }
    for(ll i = 1; i <= N; i++){
        AA[i] = AA[i] + AA[i-1];
        A[i-1] = AA[i]+1;
    }
    if(A[0] == N && A[N-1] == N){
      for(ll i = 0; i < N; i++){
        cout << A[i];
        if(i == N-1){
          cout << endl;
        }else{
          cout << " ";
        }
      }
      return 0;
    }
    K--;
  }

  for(ll i = 0; i < N; i++){
    cout << A[i];
    if(i == N-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
}

Measured memory_bytes: 6312
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var sum = a.Sum(x => x);
        var max = -1L;
        for (int i = 1; i * i <= sum; i++)
        {
            if (sum % i != 0) continue;
            if (IsValid(a, i, nk[1])) max = Max(max, i);
            if (IsValid(a, sum / i, nk[1])) max = Max(max, sum / i);
        }
        Console.WriteLine(max);
    }
    static bool IsValid(long[] a, long m, int k)
    {
        var p = a.Select(x => x % m).OrderBy(x => x).ToArray();
        var valid = -1;
        var invalid = a.Length;
        while (invalid - valid > 1)
        {
            var mid = (invalid + valid) / 2;
            if (p.Take(mid).Sum() <= p.Skip(mid).Select(x => m - x).Sum()) valid = mid;
            else invalid = mid;
        }
        return p.Take(valid).Sum() <= k;
    }
}

Measured memory_bytes: 17696
from collections import deque
N = int(input())
c = [chr(ord("a") + i) for i in range(26)]
q = deque("a")
ans = []
while q:
    s = q.pop()
    if len(s) == N:
        ans.append(s)
        continue
    for x in c[:c.index(max(s)) + 2]:
        q.append(s + x)
[print(a) for a in sorted(ans)]

Measured memory_bytes: 64220
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 2e5+9;
vector<int> g[N]; 
int tot_dn[N], c[N];
map<int, int> col_cnt[N];   
ll ans[N];
void dfs(int u, int par) {
    tot_dn[u] = 1;
    int mx = -1, from = -1;
    for(int v: g[u]) {
        if(v == par) continue;
        dfs(v, u);
        tot_dn[u] += tot_dn[v];
        ll now = tot_dn[v] - (col_cnt[v].count(c[u]) ? col_cnt[v][c[u]] : 0);
        ans[c[u]] += now * (now + 1) / 2;
        if(from == -1 || col_cnt[from].size() < col_cnt[v].size()) {
            from = v;
        }
    }
    if(from != -1)
        swap(col_cnt[u], col_cnt[from]);
    for(int v: g[u]) {
        if(v == par) continue;
        if(v != from) {
            for(auto it: col_cnt[v]) {
                col_cnt[u][it.first] += it.second;
            }
        } 
    }
    col_cnt[u][c[u]] = tot_dn[u];
}
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> c[i];
        c[i]--;
    }
    for(int i = 0; i < n-1; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0, -1);
    for(int i = 0; i < n; i++) {
        if(i != c[0]) {
            ll now = tot_dn[0] - col_cnt[0][i];
            ans[i] += now * (now + 1) / 2;
        }
    }
    for(int i = 0; i < n; i++) {
        cout << 1ll*n*(n+1)/2-ans[i] << "\n";
    }



    return 0;
    
}


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

int main()
{
unsigned long long N;
unsigned long long M;
unsigned long long A;
A=0;
scanf("%llu %llu",&N,&M);
if(M/2 >= N)
{
 A = N + (M -2*N)/4;
}else{
 A = M/2;
}

printf("%llu",A);
return 0;
}

Measured memory_bytes: 128
// template version 1.9

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
const int INF=1e18;
const int MOD=1e9+7;
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int n;cin>>n;
  int a=0;
  int b=0;
  int c=0;
  int res=0;
  rep(i, n){
    string s;cin>>s;
    int m = sz(s);
    rep(j, 1, m){
      if (s[j-1]=='A' && s[j]=='B') res++;
    }
    if (s[0]=='B' and s[m-1]=='A') c++;
    if (s[0]!='B' and s[m-1]=='A') a++;
    if (s[0]=='B' and s[m-1]!='A') b++;
  }
  dump(res);
  dump(a, b, c);

  if (c>=2){
    res += c-1;
  }
  if (c>=1){
    if (a>=1) {
      res++;
      a--;
    }
    if (b>=1) {
      res++;
      b--;
    }
  }
  res += min(a, b);
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int t = sc.nextInt();
		if (X - t >= 0) {
			System.out.println(X-t);
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 21716
#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=10;
int N, P[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> P[i];

	int imax = 0;
	for(int i=0; i<N; i++){
		if(P[i] > P[imax]) imax = i;
	}

	int ans=0;
	for(int i=0; i<N; i++){
		if(i==imax) ans += P[i]/2;
		else ans += P[i];
	}
	cout << ans << endl;

	return 0;
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

string s;
int k;
VI as;

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

	rep (i, s.size()) {
		as.pb(s[i] - 'a');
	}

	rep (i, as.size()) {
		if (i + 1 == s.size() && k > 0) {
			as[i] = (as[i] + k) % 26;
			break;
		}
		if (as[i] != 0 && k - (26 - as[i]) >= 0) {
			k -= (26 - as[i]);
			as[i] = 0;
		}
	}

	string ans;
	for (int a : as) {
		ans += a + 'a';
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1096
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < d; j++) {
      if (a * j + 1 <= d) ans++;
    }
  }
  cout << ans + x << endl;
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N;
    cin >> N;
    double ans = 0;
    while (N--) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY")
        {
            ans += x;
        }
        else {
            ans += x * 380000.0;
        }
    }
    fcout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll result = N /(A+B) *A;
  if(N%(A+B) > A) result += A;
  else result += N%(A+B);
  cout << result << endl;
 }

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

using namespace std;

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
	int A;
    cin >> A;
    if(A%2 == 0 && A%3 != 0 && A%5 != 0){
    	cout << "DENIED" <<  endl;
      	return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int even[200005], odd[200005];
int main()
{
    int n;
    cin >> n;
    int a[n];
    for ( int i = 0; i <= n-1; i++ )
    {
        cin >> a[i];
    }
    for ( int i = 0; i <= n-1; i++ )
    {
        if ( i % 2 == 0 )
        {
            even[ a[i] ]++;
        }
        else
        {
            odd[ a[i] ]++;
        }
    }
    int maxeven = 0, maxodd = 0;
    int poseven = 0, posodd = 0;
    int lesseven = 0, lessodd = 0;
    for ( int i = 0; i <= 200004; i++ )
    {
        if ( even[i] >= maxeven )
        {
            maxeven = even[i];
            poseven = i;
        }
        if ( odd[i] >= maxodd )
        {
            maxodd = odd[i];
            posodd = i;
        }
    }
    for ( int i = 0; i <= 200004; i++ )
    {
        if ( even[i] >= lesseven && i != poseven )
        {
            lesseven = even[i];
        }
        if ( odd[i] >= lessodd && i != posodd )
        {
            lessodd = odd[i];
        }
    }
    if ( poseven != posodd )
    {
        cout << n - maxodd - maxeven;
    }
    else
    {
        cout << min ( n - maxodd - lesseven, n - maxeven - lessodd );
    }
}

Measured memory_bytes: 1408
#ifndef DEBUG
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;

#ifdef DEBUG
#define IO
#else
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define cerr
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
#define All(v) v.begin(),v.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
// template<typename T> using rkt = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main() {
    IO;

    ll n, a, b;
    cin >> n >> a >> b;
    ll z = n/(a+b), x = n%(a+b);
    cout << z*a+min(x,a) << endl;
 
}

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

int main(){
	long long mod= 1000000007;

	int n;
	std::vector<int> aList;
	std::vector<int> colorList;
	std::vector<long long> dpList;

	std::cin>>n;
	aList.resize(n);
	colorList.resize(200001, -1);
	dpList.resize(n, 0);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	dpList[0]= 1;
	colorList[aList[0]]=0;

	for(int i=1; i<n; i++){
		dpList[i]= dpList[i-1];

		if(aList[i]!=aList[i-1])
			if(colorList[aList[i]]>=0)
				dpList[i]= (dpList[i] + dpList[colorList[aList[i]]])%mod;

		colorList[aList[i]]= i;
	}

	std::cout<<dpList[n-1]<<std::endl;

	return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>
#include<string.h>
 
int main(){
    char str[1001];
    char order[32];
    char p[1001];
    int a,b;
    int q,loop;
    int i,j;
     
    scanf("%s",str);
    scanf("%d",&q);
    for(loop=1;loop<=q;loop++){
        scanf("%s %d %d",order,&a,&b);
        if(strcmp(order,"print")==0){
            for(i=a;i<=b;i++){
                printf("%c",str[i]);
            }
            printf("\n");
        }
        else if(strcmp(order,"reverse")==0){
            j=0;
            for(i=a;i<=b;i++){
                p[j]=str[b-j];
                j++;
            }
            j=0;
            for(i=a;i<=b;i++){
                str[i]=p[j];
                j++;
            }
        }
        else{
            scanf("%s",p);
            j=0;
            for(i=a;i<=b;i++){
                str[i]=p[j];
                j++;
            }
        }
    }
     
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;


#include <random>

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

    int D;
    cin>>D;
    int c[26];
    int q[D];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    int l[26]{};
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            int la[26];
            rep(_,26){
                la[_]=l[_];
            }
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    la[k]=0;
                }else{
                    la[j]++;
                    a-=la[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                l[y]=0;
            }else{
                l[j]++;
                ans-=l[j]*c[j];
            }
        }
        y++;
        q[i]=y;
    }

    int tr=0;
    std::random_device rnd; 
    while(tr<=145000){
        int g=rnd()%365;
        int h=rnd()%26;
        tr++;
        int ansm=0;
        int r[D];
        rep(i,D){
            if(i==g){
                if(h!=q[i]){
                    r[i]=h;
                }else{
                    r[i]=rnd()%26;
                }

            }else{
                r[i]=q[i];
            }
        }
        int lx[26]{};
        rep(i,D){
            ansm+=s[i][r[i]];
            rep(j,26){
                if(j==r[i]){
                    lx[r[i]]=0;
                }else{
                    lx[j]++;
                    ansm-=lx[j]*c[j];
                }
            }
        }
        if(ansm>ans){
            rep(i,D){
                q[i]=r[i];
            }
            ans=ansm;
        }
    }
    rep(i,D){
        cout << q[i] << endl;
    }

    



}


Measured memory_bytes: 3724
def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = 0
	for i in range(n):
		ans += b[i]
		if i > 0 and a[i-1] + 1 == a[i]:
			ans += c[a[i-1]-1]
	print(ans)
	
main()

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){

    int n,m;
    int k,a[30];
    bool b1[30] = {}, b2[30];
    
    cin >> n >> m;

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

        b2[i] = true;

    }

    for(int i = 0;i < n; i++){

        cin >> k;

        for(int j = 0;j < k; j++){

            cin >> a[j];

            if(i == 0){

                b1[a[j] - 1] = true;

            }
            else b2[a[j] - 1] = true;

        }

        for(int j = 0;j < m; j++){

            if(b2[j] == false){
                if(b1[j] == true)b1[j] = false;
            }

        } 

        for(int j = 0;j < m;j++)b2[j] = false;
    
    }


    int sum = 0;

    for(int i = 0;i < m;i++)sum += b1[i];

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 256
import sys
import heapq

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
# マイナスを掛け最大値を優先順位にする
A = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A) # 優先度付きキューに変換

for _ in range(M):
  max_q = -heapq.heappop(A) # 最大値pop
  heapq.heappush(A, -(max_q//2)) # 最大値を割りリストに戻す
  
print(-sum(A))  # マイナスを掛け値を元に戻す

  


Measured memory_bytes: 14204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

double T,A;
double f(double x){
    return abs(T-0.006*x - A);
}

int main(void){
    int n;
    cin>>n>>T>>A;
    vector<double> h(n);
    rep(i,n)cin>>h[i];
    int index = 0;
    rep(i,n){
        if(f(h[i]) < f(h[index])) {
            index = i;
        }
    }
    cout<< index + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
N,M,Q = map(int,input().split())

num_all = [i+1 for i in range(M)]
#print(num_all)
Comb = list(itertools.combinations_with_replacement(num_all,N))

num_l = []         
for i in range(Q):
  a,b,c,d = map(int,input().split())
  num_l.append([a,b,c,d])
#print(num_l)  
  
#print(len(Comb))
d_sum_max = 0  
for A in Comb:
  d_sum = 0
  #print(A)
  #print()
  
  for x in num_l:
    a,b,c,d = x[0],x[1],x[2],x[3]
    #print(a,b,c,d)
    #print(A[b-1],A[a-1],':',A[b-1]-A[a-1],c)
    if(A[b-1]-A[a-1] == c):
      d_sum += d
      
  #print(A,d_sum)
  d_sum_max = max(d_sum_max,d_sum)

print(d_sum_max)    

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

ll n, m, ans;

ll calc(const vector<vi>& v, const vi& A) {
    ll ans = 0;
    for (auto i : v) {
        if (A[i[1]] - A[i[0]] == i[2]) {
            ans += i[3];
        }
    }
    return ans;
}

void solve(vi& A, int idx, const vector<vi>& v) {
    if (idx == n) {
        // for (auto i : A)    cerr << i << " ";
        //     cerr << endl;
        ans = max(ans, calc(v, A));
        // cerr << "ans " << ans << endl;
        return;
    }
    for (int val = A[idx - 1]; val <= m; val++) {
        A[idx] = val;
        solve(A, idx + 1, v);
    }
}

int main() {
    fastIO;
    ll q;
    cin >> n >> m >> q;

    // Checking the size of total state space

    // vector<vi> dp(n, vi(m + 1));
    // for (int i = 1; i <= m; i++)    dp[0][i] = 1;
    // for (int i = 1; i < n; i++) {
    //     for (int j = 1; j <= m; j++) {
    //         dp[i][j] = (j > 0 ? dp[i][j - 1] : 0) + dp[i - 1][j];
    //     }
    // }
    // cout << dp[n - 1][m] << endl;    // 48620

    vector<vi> v(q, vi(4));
    for (int i = 0; i < q; i++) {
        cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3];
        v[i][0]--, v[i][1]--;
    }

    ans = 0;
    vi A(n);
    A[0] = 1;
    solve(A, 1, v);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

    const ll N = 1e3 + 7;
    const ll mod = 1e9 + 7;
    const ll inf = 1e9;



void solve(){
    string s;
    cin >> s;
    if(s[1] == 'B')s[1] = 'R';
    else s[1] = 'B';
    cout << s;

}

int main(){
    TIME
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**



**/


Measured memory_bytes: 3500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		
		char[][] mines = new char[h+2][w+2];
		char[][] ans = new char[h][w];
		
		//fill
		for (int i = 0; i < h+2; i++) {
			for (int j = 0; j < w+2; j++) {
				mines[i][j] = '.';
			}
		}
		
		// input
		for (int i = 0; i < h; i++) {
			String s = scanner.next();
			char[] c = s.toCharArray();
			for (int j = 0; j < c.length; j++) {
				if (c[j]=='#') {
					mines[i+1][j+1] = '#';
				}else{
					mines[i+1][j+1] = '.';
				}
			}
		}
		
		for (int i = 1; i < h+1; i++) {
			for (int j = 1; j < w+1; j++) {
				if (mines[i][j]=='#') {
					ans[i-1][j-1] = '#';
				}else{
					int count = 0;
					for (int k = i-1; k <= i+1; k++) {
						for (int k2 = j-1; k2 <= j+1; k2++) {
							if (i==k && j==k2) {
								continue;
							}else{
								if (mines[k][k2]=='#') {
									count++;
								}
							}
						}
					}
					String s = String.valueOf(count);
					ans[i-1][j-1] = s.charAt(0);
				}
			}
		}

		for (int i = 0; i < h; i++) {
			String output = new String(ans[i]);
			System.out.println(output);
		}
		
		scanner.close();
	}

}

Measured memory_bytes: 23764
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  ll N, k;
  cin >> N >> k;
  vector<ll> a(N);
  rep(i, N){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  // rep(i, N){
  //   cout << a[i] << endl;
  // }
  ll h = 0;
  if (N - k >0){
    rep(i, N - k){
      h += a[i];
    }
  }
  cout << h << endl;

}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)

{  

   int n,i,a,b;  

   int  ai[10001];

   long c;  

   scanf("%d",&n);    

   for(i=0;i<n;i++)

   {  

      scanf("%d",&ai[i]);   

      if(i == 0)

      {    

         a=ai[0];    

         b=ai[0];   

      }   

      else

      {        

      if(a<=ai[i])

      {     

         a=ai[i];    

      }    

      if(b>=ai[i])

      {     

         b=ai[i];    

      }   

   }          

  }   

  c=0;  

  for(i=0;i<n;i++)

 {   

       c += ai[i];  

  }  

   printf("%d %d %ld\n",b,a,c);    

   return 0;

}
 

Measured memory_bytes: 640
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    t = ns()

    ans = 0
    for i, letter in enumerate(s): 
        if letter != t[i]:
            ans += 1
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9864
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.lang.Integer;

/**
 * Created by Messick on 2019/10/26.
 */
public class Main {
    public static void main(String[] args) {
        int []A = new int[4];
        Scanner in = new Scanner(System.in);
        A[1] = in.nextInt();
        A[2] = in.nextInt();
        A[3] = in.nextInt();
        if (A[1] + A[2] + A[3] >= 22) {
            System.out.println("bust");
        }else {
            System.out.println("win");
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
int flag[maxn];
int a[maxn];
int n;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%4==0){
            flag[2]++;
        }else if(a[i]%2==0){
            flag[1]++;
        }else{
            flag[0]++;
        }
    }
    if(flag[1])flag[0]++;
    if(flag[0]-1>flag[2]){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N, S; cin >> N >> S;
	const int NO = -1;

	ans = LINF;
	function<LL(LL, LL)>f = [&](LL b, LL n) {
		if (n < b)return n;
		else return f(b, n / b) + n % b;
	};
	for (LL b = 2; b*b <= N; b++) {
		LL ret = f(b, N);
		if (ret == S) {
			ans = min(ans, b);
		}
	}

	for (LL x = 1; x*x <= N; x++) {
		LL b = (N-(S-x)) / x;
		if (b > 1&& x<b&&(S-x)<b && f(b, N) == S) {
			ans = min(ans, b);
		}
	}

	if (N == S)ans = min(ans, N + 1);
	if (ans == LINF)ans = NO;
	cout << ans << "\n";

	return 0;
}

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

int a[200];
int main(){
	int n,m,x;cin>>n>>m>>x;
	rep(i,m)cin>>a[i];
	sort(a,a+m);
	cout<<min(lower_bound(a,a+m,x)-a,m-(lower_bound(a,a+m,x)-a))<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String str = String.valueOf(n);
      String x1 = str.substring(0,1);
      String x2 = str.substring(1,2);
      String x3 = str.substring(2,3);
      if(x1.equals("1"))x1 = "9";
      else x1 = "1";
      if(x2.equals("1"))x2 = "9";
      else x2 = "1";
      if(x3.equals("1"))x3 = "9";
      else x3 = "1";
      String str1 = x1+x2+x3;
      int n1 = Integer.parseInt(str1);
      System.out.println(n1);
      sc.close();
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm> 
#include <vector> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int lng(int a,int b){
    if(a%b==0){
        return b;
    }else{
        return lng(b,a%b);
    }
}


int main(void){
    // Your code here!
    
    int In;
    int ans_max = 1;
    vector<int> v;
    vector<int> f;
    vector<int> l;
    int n;
    cin >> n;
    rep(i,n){
        cin >> In;
        v.push_back(In);
    }
    l.push_back(v[n-1]);
    for(int i = 1; i < n; i++){
        if(l[i-1] < v[n-1-i]){
            l.push_back(lng(v[n-1-i],l[i-1]));
        }
        else{
            l.push_back(lng(l[i-1],v[n-1-i]));
        }
    }
    f.push_back(v[0]);
    for(int i = 1; i < n; i++){
        if(f[i-1] < v[i]){
            f.push_back(lng(v[i],f[i-1]));
        }
        else{
            f.push_back(lng(f[i-1],v[i]));
        }
    }
    rep(i,n){
        int ans;
        if(i == 0){
            ans = l[n-2];
        }else if(i == n-1){
            ans = f[n-2];
        }else{
            ans = lng(f[i-1],l[n-2-i]);
        }
        //cout << ans << endl;
        ans_max = max(ans,ans_max);
    }
    cout << ans_max << endl;
}


Measured memory_bytes: 1784
O = [i for i in input()]
E = [i for i in input()]
ans=[]
for (o,e) in zip(O,E):
    ans.append(o)
    ans.append(e)
if len(O)==len(E):
    print("".join(ans))
else:
    if len(O)>len(E):
        print("".join(ans)+O[-1])
    else:
        print("".join(ans)+E[-1])

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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ll n; cin>>n;
	ll ans = n*n - n;
	ans = ans>>1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

string s;
cin >> s;

if(s.length() % 2 != 0){
    cout << "No" << endl;
    return 0;
}
for(int i = 0;i < s.length()-1;i += 2){
    if(s[i] == 'h' && s[i+1] == 'i') ;
    else{
        cout << "No" << endl;
        return 0;
    }
}

cout << "Yes" << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

sl = []
flag = False
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            sl.append([i, j])

q = deque()
dire = [(0, 1), (0, -1), (1, 0), (-1, 0)]
ans = 0
for sh, sw in sl:
    c = [[0]*w for _ in range(h)]
    q.append((sh, sw, 0))
    while q:
        ph, pw, k = q.pop()
        if c[ph][pw] == 0:
            ans = max(ans, k)
            c[ph][pw] = 1
            for dh, dw in dire:
                hdh, wdw = ph+dh, pw+dw
                if 0 <= hdh < h and 0 <= wdw < w and c[hdh][wdw] == 0:
                    if s[hdh][wdw] == '.':
                        q.appendleft((hdh, wdw, k+1))

print(ans)

Measured memory_bytes: 93816
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long A, long long B, long long T) {
  std::cout << T / A * B << std::endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long T;
  scanf("%lld", &T);
  solve(A, B, T);
  return 0;
}


Measured memory_bytes: 256
# 2019-11-23 01:28:44(JST)
import sys


def main():
    a, b, c = map(int, sys.stdin.readline().split())
    if a < c < b or a > c > b:
        ans = 'Yes'
    else:
        ans = 'No'
    
    print(ans)

if __name__ == '__main__':
    main()


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

using ll = long long;
using namespace std;

const ll mod = 998244353;

ll rep_pow(int n, int p) { // n^p
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        ll t = rep_pow(n, p / 2);
        return t * t % mod;
    } else {
        return n * rep_pow(n, p - 1) % mod;
    }
}

int main() {
    int n;
    cin >> n;
    vector<ll> count(n, 0);
    int mx = 0;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        if (i == 0 && d != 0) {
            cout << 0 << endl;
            return 0;
        }
        count[d]++;
        mx = max(mx, d);
    }
    if (count[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for (int i = 1; i < n; i++) {
        ans *= rep_pow(count[i - 1], count[i]) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jul  5 21:19:58 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    std::cout << 1000 * ((n + 999) / 1000) - n << std::endl;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    printf("%.10f\n",d);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int dp[2][9][9][2];
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string s;
	const int X[] = {0, 1, 2, 0, -1, 2, 0, 1, 2};
	while ( cin >> s, s != "#" ) {
		int N = s.size();
		vector<int> v(N);
		REP(i, N) v[i] = s[i]-'1';
		fill(dp[0][0][0], dp[1][8][9], inf);
		dp[0][4][4][0] = dp[0][4][4][1] = 0;
		REP(i, N) {
			fill(dp[i+1&1][0][0], dp[i+1&1][8][9], inf);
			REP(j, 9) REP(k, 9) REP(p, 2) {
				if (dp[i&1][j][k][p] == inf) continue;
//				cout << i << " " << j << " " << k << " " << p << " " << dp[i][j][k][p] << endl;
				REP(l, 2) {
					int nj = l == 0 ? j : v[i];
					int nk = l == 1 ? k : v[i];
					if (nj != 4 && nk != 4 && X[nj] > X[nk]) continue;
					if (i > 0 && (nj == 4 || nk == 4)) continue;
					int cost = p == l ? 1 : 0;
//					cout << nj << " " << nk << " " << l << endl;
					dp[i+1&1][nj][nk][l] = min(dp[i+1&1][nj][nk][l], dp[i&1][j][k][p]+cost);
				}
			}
		}
		int ans = inf;
		REP(i, 9) REP(j, 9) REP(k, 2) {
			ans = min(ans, dp[N&1][i][j][k]);
		}
		cout << ans << endl;
	}
}

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

typedef long long ll;

string s;
int k;

vector<vector<vector<ll>>> dp;

ll f(int indextoadd, bool isequal, int numleft){
	if (numleft<0){
		return 0;
	}
	if (indextoadd==s.size()){
		if (numleft==0){
			return dp[indextoadd][isequal][numleft]=1;
		} else {
			return dp[indextoadd][isequal][numleft]=0;
		}
	}
	if (dp[indextoadd][isequal][numleft]!=-1){
		return dp[indextoadd][isequal][numleft];
	}
	ll total = 0;
	for (int i = 0; i<=9; i++){
		if (isequal&&i>(s[indextoadd]-'0')){
			break;
		}
		total+=f(indextoadd+1,(isequal&&(s[indextoadd]-'0'==i)),(i==0?numleft:numleft-1));
	}
	return dp[indextoadd][isequal][numleft]=total;
}

int main(){
	cin>>s>>k;
	dp.resize(s.size()+1,vector<vector<ll>>(2,vector<ll>(k+1,-1)));
	cout<<f(0,true,k)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

//divisor Number
public class Main {
	public static void main(String args[])
	{
		String[] str = new String[3];
		int[] output = new int[3];
		Scanner sc = new Scanner(System.in);
		str = sc.nextLine().split(" ");
		output[0] = Integer.parseInt(str[0]);
		output[1] = Integer.parseInt(str[1]);
		output[2] = Integer.parseInt(str[2]);
		
		int number = 0;
		int divisor = 0;
		for(number = output[0];number<=output[1];number++)
		{
			if(output[2]%number == 0)
			{
				divisor++;
			}
		}
		System.out.println(divisor);
		sc.close();

	}
}



Measured memory_bytes: 26172
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
string s;
cin>>s;
s="2018"+s.substr(4);
cout<<s;
system("pause");
return 0;
}

Measured memory_bytes: 504
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		String s[] = new String[x];
		for(int i = 0; i < x; i++){
			s[i] = sc.next();
		}
		int n = sc.nextInt();
		String t[] = new String[n];
		for(int i = 0; i < n; i++){
			t[i] = sc.next();
		}
		int num = 0;
		int sco = 0;
		for(int i = 0; i < x; i++){
			for(int k = 0; k < x; k++){
				if(s[i].equals(s[k]))num++;
			}
			for(int j = 0; j < n; j++){
				if(s[i].equals(t[j]))num--;
			}
			if(num > sco)sco = num;
			num = 0;
		}
		System.out.println(sco > 0? sco : 0);
	}
}

Measured memory_bytes: 25172