akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define N 1000001

int arrr1[N+5],arrr2[N+5];
int main()
{
    int n,m,a,b;

    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>a>>b;
        if(a==1)
            arrr1[b]=1;//第一次的终点
        if(b==n)
            arrr2[a]=1;//第二次的起点
    }

    int p=0;
    for(int i=1; i<=m; i++)
    {
        if(arrr1[i]&&arrr2[i])
        {
            cout<<"POSSIBLE"<<endl;
            p=1;
        }
    }

    if(p==0)
        cout<<"IMPOSSIBLE"<<endl;

    return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>

int main(){

  int a,b,sum,abe;
  sum=0;
  for(a=0;a<5;a++){scanf("%d",&b);
    if(b<40){b=40;}
    sum=sum+b;}
  abe=sum/5;

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

Measured memory_bytes: 600
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		long answer = 0;
		for(int i = 0;i <= K;i++){
			for(int j = 0;j <= K;j++){
				if(0 <= S - i - j && S - i - j <= K)answer++;
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 23764
n,c = map(int,input().split())
x = [0]*n
v = [0]*n
for i in range(n): x[i],v[i] = map(int,input().split())
x1 = [0]+x
v1 = [0]+v
x2 = [0]+list(map(lambda a:c-a,x[::-1]))
v2 = [0]+v[::-1]
lst1 = [0]*(n+1)
lst2 = [0]*(n+1)
lst1[0] = lst2[0] = (0,0)

def f(l,x,v):
    maxcal = pos = sumcal = 0
    for i in range(1,n+1):
        dist = x[i]-x[i-1]
        sumcal += v[i] - dist
        if sumcal > maxcal:
            maxcal = sumcal
            pos = x[i]
        l[i] = (maxcal,pos)

f(lst1,x1,v1)
f(lst2,x2,v2)
# print(lst1)
# print(lst2)

ans = 0
for i in range(n+1):
    ans = max(ans,lst1[i][0]+lst2[n-i][0]-min(lst1[i][1],lst2[n-i][1]))
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<bool> flags(8);
  int minCnt = 0, maxCnt = 0;
  
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(a < 3200){
      int index = a / 400;
      if(flags[index] == false){
        flags[index] = true;
        minCnt++;
        maxCnt++;
      }
    } else {
      maxCnt++;
    }
  }

  if(maxCnt > N)
    maxCnt = N;
  if(minCnt < 1)
    minCnt = 1;

  cout << minCnt << " " << maxCnt << endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int T, X;
  cin >> T >> X;
  cout << 1.0 * T / X << endl;
  return 0;
}


Measured memory_bytes: 256
string = input()

if(len(string) % 2 != 0):
    print("No")
    exit()

for i in range(0, 10, 2):
    if len(string) > i:
        if string[i] != 'h' or string[i + 1] != 'i':
            print("No")
            exit()

print("Yes")

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

int main() {
  vector<int> groupA = {1,3,5,7,8,10,12};  
  vector<int> groupB = {4,6,9,11};
  bool same =false;
  int x,y;
  cin>>x>>y;
  
  for(int i=0; i<7; i++)
  {
    if (x == groupA.at(i))
  {
      for(int j=i+1; j<7;j++)
      {if(y ==groupA.at(j)){same = true; break;}}
      break;
    }
  }
  if(!same){
    for(int i=0; i<4; i++)
  {
    if (x == groupB.at(i))
  {
      for(int j=i+1; j<4;j++)
      {if(y ==groupB.at(j)){same = true; break;}}
      break;
    }
  }
  }
  if(same){
  cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n; cin >> n;
    if (n % 111 == 0)
        cout << n << endl;
    else {
    n /= 111;
    cout << 111 * (n+1) << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
string a,b,c;
cin>>a>>b>>c;
cout<<(char)(a.at(0)-' ')<<char(b.at(0)-' ')<<char(c.at(0)-' ')<<endl;
}










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

int main(){
  int n;
  cin >> n;
  int a, f=0, t=0, odd=0;
  for ( int i = 0; i < n; i++){
    cin >> a;
    if ( a % 4 == 0){
      f++;
    } else if (a % 2 == 0) {
      t++;
    } else{
      odd++;
    }
   }

  if ( odd <= f || (t == 0 && odd <= f + 1)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> x >> A >> B;
	if (A+x<B) {
		cout << "dangerous";
	}
	else if (B<=A) {
		cout << "delicious";
	}
	else {
		cout << "safe";
	}

}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc113/tasks/abc113_d
# あみだくじは, 日本に古くから伝わる伝統的なくじ引きである.
# あみだくじを作るには, まず W 本の平行な縦線を引き, 次にそれらを繋ぐ横線を引いていく.
# それぞれの縦棒の長さは H+1 [cm] であり、
# 横線の端点となれるのは上から 1,2,3,...,H [cm] の位置のみである.
# ここで,「正しいあみだくじ」とは, 以下のような条件を満たすあみだくじのことである.
# どの 2 つの横棒も端点を共有しない.
# それぞれの横棒の 2 つの端点は同じ高さになければならない.
# 横棒は隣り合う縦線を繋がなければならない.

# 縦棒 1 の上端から, 横線があれば必ずそれを通るというルールで下へたどったときに,
#  最終的にたどり着く縦棒の番号が K となるような「正しいあみだくじ」の本数を 1 000 000 007 で割った余りを求めなさい.
# H は 1 以上 100 以下の整数
# W は 1 以上 8 以下の整数
# K は 1 以上 W 以下の整数
# H W K
# 15 8 5
# 437760187
H, W, K = gets.split.map(&:to_i)

FIB = [1, 1, 2, 3, 5, 8, 13, 21]
MOD = (10**9) + 7

def getc(a,b)
  FIB[a] * FIB[W-1-b]
end

dp = Array.new(H+1) { Array.new(W, 0) }
dp[0][0] = 1
1.step(H) do |h|
  W.times do |w|
    dp[h][w]   += (dp[h-1][w] * getc(w,   w))%MOD
    dp[h][w-1] += (dp[h-1][w] * getc(w-1, w))%MOD if w != 0
    dp[h][w+1] += (dp[h-1][w] * getc(w, w+1))%MOD if w != W-1
  end
end
p dp[H][K-1]%MOD

Measured memory_bytes: 1788
n=int(input())
cnt=1
X=[]
def two(n):
    cnt=0
    while n%2==0:
        n=n/2
        cnt+=1
    return cnt
res=0  
ans=n
for i in range(n,1,-1):
    if res<two(i):
        res=two(i)
        ans=i

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cins(int, 4, a);
    Sort(a);
    CoutYN(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9);
}





Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

char str[1000][1005];

int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
void solve()
{
    int h, w;
    scanf("%d%d", &h, &w);
    queue<pair<int,int> > que;
#define P(i, j) ((i)*w+(j))
    int i, j;
    for (i = 0; i < h; i++) {
        scanf("%s", str[i]);
        for (j = 0; j < w; j++) {
            if (str[i][j] == '#') {
                que.push(make_pair(P(i, j),0));
            }
        }
    }

    int max = 0;
    while (!que.empty()) {
        auto tmp = que.front();
        que.pop();
        int x = tmp.first / w, y = tmp.first % w;
        int cnt0 = tmp.second;
        max = MAX(max, cnt0);
        int k;
        for (k = 0; k < 4; k++) {
            int x2 = x + dx[k], y2 = y + dy[k];
            if (x2 >= 0 && x2 < h && y2 >= 0 && y2 < w) {
                if (str[x2][y2] == '.') {
                    que.push(make_pair(P(x2, y2), cnt0+1));
                    str[x2][y2] = '#';
                }
            }
        }
    }
    printf("%d\n", max);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 9360
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
const int dx[]={-2,-2,-2,-1,-1,-1, 0, 0,0};
const int dy[]={-2,-1, 0,-2,-1, 0,-2,-1,0};
long long Ans[10+2];
int N,M,K;
map<pair<int,int>,long long> P;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d %d",&N,&M,&K);
	Ans[0]=1LL*(N-2)*(M-2);
	for(int i=1;i<=K;i++) {
		int x,y;
		scanf("%d %d",&x,&y);
		for(int j=0;j<9;j++) {
			int tx=x+dx[j],ty=y+dy[j];
			if(tx<1||tx>N-2||ty<1||ty>M-2)
				continue;
			P[make_pair(tx,ty)]++;
		}
	}
	for(map<pair<int,int>,long long>::iterator it=P.begin();it!=P.end();it++) {
		Ans[0]--;
		Ans[it->second]++;
	}
	for(int i=0;i<10;i++)
		printf("%lld\n",Ans[i]);
	return 0;
}

Measured memory_bytes: 56448
s = input()
big = 0
small = 0
n = 0
big2 =0
for i in range(len(s)):
  if s[i]=='<':
    big += 1
    n += big
    small =0
    big2 = big
  else:
    small += 1
    n += small
    if small<=big2:
      n-=1
      big =0
print(n)

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


int main() {
  int m,d;
  cin >> m>> d ;
  
  int c=0;
  for(int i=1;i<=m;i++){
    if(d<22){
      break;
    }
    for(int j=22;j<=d;j++){
      if(j%10==0||j%10==1) {
        continue;
      }
      if(((j%10)*(j/10))==i){
        c++;
      }
    }
  }
  
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <string>

using namespace std;

int main(){
    string input;

    //input
    getline(cin, input);

    int i = 0;
    while(1){
        if(input[i] == 0){
            break;
        }
        if(islower(input[i])){
            input[i] = toupper(input[i]);
        }
        else if(isupper(input[i])){
            input[i] = tolower(input[i]);
        }
        i++;
    }
    
    cout << input << endl;
    
    return 0;
    
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, a[Maxn], pos[Maxn];
ll ans, sum;
set<int> s;
set<int>::iterator pre, suf, x;
int main()
{
	rg int tmp;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		a[i] = read();
		pos[a[i]] = i;
	}
	s.insert(0);
	s.insert(n + 1);
	s.insert(pos[n]);
	for (int i = n - 1; i >= 1; i--)
	{
		pre = suf = x = s.upper_bound(pos[i]);
		pre--;
		suf++;
		if (suf != s.end())
			ans += 1LL * i * (pos[i] - (*pre)) * ((*suf) - (*x));
		if (pre != s.begin())
		{
			suf--;
			x = pre--;
			ans += 1LL * i * ((*x) - (*pre)) * ((*suf) - pos[i]);
		}
		s.insert(pos[i]);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

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

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

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;

int main(){
	cin>> s;
	ll ans = 0;
	rep(i,(1<<(s.size()-1))){
		ll sum = 0;
		ll num = s[0]-'0';
		rep(j,s.size()-1){
			if(i&(1<<j)){
				sum+=num;
				num=s[j+1]-'0';
			}
			else{
 				num*=10;
				num+=s[j+1]-'0';
			}
		}
		if(num!=0)sum+=num;
		ans += sum;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

 

int main() {
	string c[110];
	int H, W; cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < H; i++) {
		cout << c[i] << endl << c[i] << endl;
	}








	return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())

if (2*x-y)%3!=0 or (2*x-y)<0:
  print(0)
  exit()
if (2*y-x)%3!=0 or (2*y-x)<0:
  print(0)
  exit()
p=int((2*x-y)/3)
q=int((2*y-x)/3)
M=p+q+2
Mod=10**9+7

fac=[0]*M
finv=[0]*M
inv=[0]*M

def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
print(COM(p+q,p))

Measured memory_bytes: 82164
#include<stdio.h>

#define N 200000

int main(){
  int i,j,n,minv,maxv;
  int R[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }

  maxv = R[1] - R[0];
  minv = R[0];
  for(j=1;j<n;j++){
    maxv = (maxv > R[j] - minv)? maxv :R[j] - minv;
    minv = (minv < R[j])? minv :R[j];
  }

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

Measured memory_bytes: 1376
/* Sum of Numbers */
#include <stdio.h>

int main()
{
    char x[1000];
    int sum=0, i, n;
    while(1){
        scanf("%s", &x);
        if(x[0] == '0'){ break; }
        for(i=0;; i++){
            if(x[i] == '\0'){ break; }
            n = x[i] - 48;
            sum = n + sum;
        }
        printf("%d\n", sum);
        sum = 0;
    }
}


Measured memory_bytes: 2100
<?php
// 任意の整数を選ぶ
// Aの倍数であり、最低ひとつは選ばれること
// 総和をBで割ったあまりの数がCであること
$stdin = explode(' ', trim(fgets(STDIN)));
$flg_yes = false;
$a = $stdin[0];
$b = $stdin[1];
$c = $stdin[2];
$sum = 0;
$limit = 100000;

for($i = 1; $i < $limit; $i++) {
    $sum += $a;
    if($sum % $b == $c) $flg_yes = true;
}

if($flg_yes) {
    printf('YES');
} else {
    printf('NO');
}
?>

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define MAX (ll)(2e5 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () { 
	IO;
	int n, m;
	cin >> n >> m;
	int ans = 0;
	set<int> se;
	vector<pair<int, string>> vp;
	for (int i = 0; i < m; i++) {
		int x;
		string s;
		cin >> x >> s;
		if (s == "AC") {
			se.insert (x);
		}
		else {
			if (se.count (x) == 0) {
				ans++;
			}
		}
		vp.push_back (make_pair (x, s));
	}
	for (auto x : vp) {
		if (x.second == "WA" && se.count (x.first) == 0) {
			ans--;
		}
	}
	cout << se.size () << " " << ans << "\n";
}


Measured memory_bytes: 11248
#include <bits/stdc++.h>
#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() {
    int N; cin >> N;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

    rep(i, N){
        string S; cin >> S;
        if(S == "AC")ac++;
        if(S == "WA")wa++;
        if(S == "TLE")tle++;
        if(S == "RE")re++;
    }

    cout << "AC" << " x " << ac << endl;
    cout << "WA" << " x " << wa << endl;
    cout << "TLE" << " x " << tle << endl;
    cout << "RE" << " x " << re << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3852
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};


int main() {
  std::string s;
  std::cin >> s;
  int n = s.length();
  int sum = 0;
  for (int i=0; i<n; i++) {
    sum += int(s[i]) - int('0');
  }
  printf("%s\n",(sum%9==0)?"Yes":"No");
  return 0;
}

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

int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  string S;
  int N;
  cin >> S;
  N = S.length();
  long long int A[N];
  for(int i=0;i<N;i++){
    A[i] = S[i]-48;
  }
  long long int B[N];
  B[N-1]=1;
  for(int i=1;i<N;i++){
    B[N-i-1]=B[N-i]*10+Exp(2, i-1,9999999999);
  }
  long long int O=0;
  for(int i=0;i<N;i++){
    O = O + A[i]*B[i]*Exp(2,i,99999999999);
  }
  
  
  cout << O <<endl; 
  
  
  
  return 0;
}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3596
# coding: utf-8
import numpy as np
from numba import b1, i8, njit, types


@njit(types.Tuple((i8[:], b1))(i8[:]), cache=True)
def f(A):
    n = len(A)
    ret = np.zeros_like(A)
    for x, p in enumerate(A):
        ret[max(0, x-p)] += 1
        if x+p+1 < n:
            ret[x+p+1] -= 1
    ret = ret.cumsum()
    return ret, np.all(A == n)


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = np.array(tuple(map(int, args[1].split())), int)
    for _ in range(k):
        A, satulated = f(A)
        if satulated:
            break

    return ' '.join(map(str, A))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

int main(){
    string str;
    int K;
    cin >> str >> K;
    int N;
    N = (int)str.size();

    vector<string> sub;
    for(int i=0;i<N;i++){
        for(int j=1;j<K+1;j++){
            sub.push_back(str.substr(i,j));
        }
    }
    int v_size;
    v_size = (int)sub.size();
    sort(sub.begin(),sub.end());
    unique(sub.begin(),sub.end());
    cout << sub[K - 1] << "\n";
    return 0;

}


Measured memory_bytes: 1660
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    H, A = get_inputs(int)


    ans = 0
    while H > 0:
        H -= A
        ans += 1
    print(ans)

    return


if __name__ == '__main__':
    main()


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

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

    int ans;

    if (x >= 1800) {
        ans = 1;
    } else if (x >= 1600) {
        ans = 2;
    } else if (x >= 1400) {
        ans = 3;
    } else if (x >= 1200) {
        ans = 4;
    } else if (x >= 1000) {
        ans = 5;
    } else if (x >= 800) {
        ans = 6;
    } else if (x >= 600) {
        ans = 7;
    } else if (x >= 400) {
        ans = 8;
    }

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

Measured memory_bytes: 3632
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    char x,y;
    cin>>x>>y;
    cout<<(x==y?'=':x>y?'>':'<')<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
#define LINF 1e9+10
typedef long long ll;

using namespace std;

int dx[] = {1,-1, 0, 0};
int dy[] = {0, 0,-1, 1};
ll dp[1050][6000]; 

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll n,m; cin >> n >> m;
      vector<ll> a(n);
      rep(i,n) cin >> a[i];
      priority_queue<ll> q;
      rep(i,n) q.push(a[i]);
      while(m>0){
            auto x = q.top(); q.pop();
            x /= 2;
            q.push(x);
            m--;
      }
      ll ans = 0;
      while(!q.empty()){
            ans += q.top(); q.pop();
      }

      cout << ans << endl;

      return 0;
}


Measured memory_bytes: 2168
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr, tails, sort)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

isTriangle :: Int -> Int -> Int -> Bool
isTriangle a b c = a < b + c && b < c + a && c < a + b

naive = do
  n <- readLn :: IO Int
  xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ length [ (a,b,c) | a:xss <- tails xs, b:xsss <- tails xss, c <- xsss, isTriangle a b c ]

-- v は昇順にソートされているとする。
-- count a v は a 以上の要素の個数を数える。
countGE :: Int -> U.Vector Int -> Int
countGE !a v | U.null v = 0
             | U.length v == 1 = case compare a (U.head v) of
                                   LT -> 1
                                   EQ -> 1
                                   GT -> 0
             | otherwise = let n = U.length v
                               n2 = n `quot` 2
                           in case compare a (v U.! n2) of
                                LT -> countGE a (U.take n2 v) + n - n2
                                EQ -> countGE a (U.take n2 v) + n - n2
                                GT -> countGE a (U.drop n2 v)

main = do
  n <- readLn :: IO Int
  xs <- mergeSort . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ sum [ n - (j+1) - countGE c_max ys
              | i <- [0..n-1]
              , let a = xs U.! i
              , j <- [i+1..n-1]
              , let b = xs U.! j
              , let c_max = a + b {- c < a + b, b - a < c, a - b < c -}
              , let ys = U.drop (j+1) xs
              ]

mergeSortBy :: (U.Unbox a) => (a -> a -> Ordering) -> U.Vector a -> U.Vector a
mergeSortBy !cmp !vec = doSort vec
  where
    doSort vec | U.length vec <= 1 = vec
               | otherwise = let (xs, ys) = U.splitAt (U.length vec `quot` 2) vec
                             in merge (doSort xs) (doSort ys)
    merge xs ys = U.create $ do
      let !n = U.length xs
          !m = U.length ys
      result <- UM.new (n + m)
      let loop !i !j
            | i == n = U.copy (UM.drop (i + j) result) (U.drop j ys)
            | j == m = U.copy (UM.drop (i + j) result) (U.drop i xs)
            | otherwise = let !x = xs U.! i
                              !y = ys U.! j
                          in case cmp x y of
                               LT -> do UM.write result (i + j) x
                                        loop (i + 1) j
                               EQ -> do UM.write result (i + j) x
                                        UM.write result (i + j + 1) y
                                        loop (i + 1) (j + 1)
                               GT -> do UM.write result (i + j) y
                                        loop i (j + 1)
      loop 0 0
      return result

mergeSort :: (U.Unbox a, Ord a) => U.Vector a -> U.Vector a
mergeSort = mergeSortBy compare


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */

vi vc(MAX);

void solve() {
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		vc[x]++;
		sum += x;
	}

	int temp;
	cin >> temp;
	while(temp--) {
		int a, b;
		cin >> a >> b;
		sum += (b - a) * vc[a];
		vc[b] += vc[a];
		vc[a] = 0;
		cout << sum << endl;
	}
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long x,k,d; cin >> x >> k >> d;
    x = (long long)fabs(x);
	long long tmp = min(k, x / d);
	k -= tmp, x -= tmp * 1ll * d;
	if (k & 1)x -= d;
    cout << (long long)fabs(x) << endl;
    return 0;
}


Measured memory_bytes: 3612
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	strs := make([]string, len(s))
	for i, char := range s {
		asciiCode := int(char) + n
		if asciiCode >= 91 {
			asciiCode -= 26
		}
		strs[i] = string(asciiCode)
	}
	fmt.Println(strings.Join(strs, ""))
}


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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;

int gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	while(ll r = (a%b)) {
		a = b;
		b = r;
	}
	return b;
}

int main() {
	speed;
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	vector<int>l(n);
	vector<int>r(n);
	l[0] =a[0];
	r[n-1] = a[n-1];
	ffor(i, 1, n) {
		l[i] = gcd(a[i], l[i-1]);
		r[n - 1 - i] = gcd(r[n - i], a[n - 1 - i]);
	}
	int ans = 0;
	rep(i, n ) {
		if (i == 0)ans = max(ans, r[1]);
		else if (i == n - 1)ans = max(ans, l[n - 2]);
		else ans = max(ans, gcd(l[i - 1], r[i + 1]));
	}
	c(ans);
	return 0; 
}



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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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 << "\t|";
    __f(comma + 1, args...);
}


#define print(x) for(auto it : x) cout<< it << ' '; cout << '\n';
typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll) (a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll) mod(mod(a) * mod(b));}


ll dp[3002][3002];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s, t; cin >> s >> t;
    s = "@" + s;
    t = "#" + t;
//    cout << s << '\n';
    std::fill(dp[0], dp[0] + 3002 * 3002, 0);
    int m = (int) s.size(), n = (int) t.size();
    for (int i = 1; i < m; i++) {
        for (int j = 1; j < n; j++) {
            if (s[i] == t[j])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string ans;
    // trace back the path
    m--; n--;
    while (m > 0 && n > 0) {
        if (s[m] == t[n]) {
//            cout << "char " << s[m] << '\n';
            ans += s[m];
            m--;
            n--;
        } else if (dp[m - 1][n] > dp[m][n - 1]) {
            m--;
        } else {
            n--;
        }
    }
    reverse(ans.begin(), ans.end());
//    for (int i = 0; i < ans.size(); i++) {
//        cout << i << " " <<  ans[i] << '\n';
//    }
    cout <<  ans << '\n';
    return 0;
}


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


int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int x=0;
  int m=0;
  rep(i, S.size()) {
    if(S[i] == 'I') x++;
    else x--;
    if(m<x) m=x;
  }
  cout << m <<endl;
}


Measured memory_bytes: 256
h,n= map(int,input().split())
ab=[[] for _ in range(n)]
for i in range(n):
    ab[i] = list( map(int,input().split()) )


ab.sort(key=lambda x:x[1],reverse=True)


dp=[0]*h
for i in range(n):
    for j in range(min(h,ab[i][0]) ):
        dp[j] = ab[i][1]

for i in range(1,h):
#    print(i,[ (j,i-j-1) for j in range(0,i//2+1) ])
    if dp[i]==0:
        dp[i] = min( dp[j]+dp[i-j-1] for j in range(0,i//2+1)) 
    else:
        dp[i] = min(dp[i] , min( dp[j]+dp[i-j-1] for j in range(0,i//2+1)) )

print(dp[-1])

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

int main(){
  int h,w;
  cin >> h >> w;
  char z[h][w];
  queue<pair<int,int>>que;
  int cost[h][w];
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
          cin >> z[i][j];
          cost[i][j]=10e6;
          if(z[i][j]=='#'){
              que.push(make_pair(i,j));
              cost[i][j]=0;
          }
      }
  }
  int dy[4]={0,0,1,-1};
  int dx[4]={1,-1,0,0};
  while(!que.empty()){
     int y = que.front().first;
     int x = que.front().second;
     que.pop();
     for(int i=0;i<4;i++){
         if(y+dy[i]<0||y+dy[i]>=h||x+dx[i]<0||x+dx[i]>=w)continue;
         if(cost[y+dy[i]][x+dx[i]] > cost[y][x]+1){
             cost[y+dy[i]][x+dx[i]] = cost[y][x]+1;
             que.push(make_pair(y+dy[i],x+dx[i]));
         }
     }
  }
  int ans = -10;
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
         ans = max(ans,cost[i][j]);
      }
  
  }
  cout<< ans << endl;
}

Measured memory_bytes: 13328
// 20200118

#include <bits/stdc++.h>
using namespace std;


int main() {
    int h, w, n;
    int count;
    int temp;

    cin >> h >> w >> n;
    if (h > w) temp = h;
    if (h <= w) temp = w;

    count = 0;
    count = n / temp;
    if (n % temp != 0) {
            count++;
    }
    cout << count << endl;    
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int y,m,d;
        cin>>y>>m>>d;
        int k=m;
        int cnt=0;
        if(y%3==0)
            cnt+=20-d+1;
        else if(m%2)
            cnt+=20-d+1;
        else
            cnt+=19-d+1;
        k++;
        for(int j=y;j<1000;j++){
            for(;k<=10;k++){
                if(j%3==0)
                    cnt+=20;
                else if(k%2)
                    cnt+=20;
                else
                    cnt+=19;


            }
            k=1;
        }
        cout<<cnt<<endl;

    }


    return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>
int main()
{
  int n, i, j, m, card[4][14];
  char mark;

  for(i = 0; i < 4; i++){
    for(j = 1; j <= 13; j++){
      card[i][j] = 0;
      
    }
  }
  
  scanf("%d",&n);

  for(i = 1; i <= n*2; i++){
    scanf("%c%d",&mark, &m);

    switch(mark){
    case 'S':
      card[0][m] = m;
      break;

    case 'H':
      card[1][m] = m;
      break;
      
    case 'C':
      card[2][m] = m;
      break;

    case 'D':
      card[3][m] = m;
      break;

    }
  }
  
  for(i=0; i<4; i++){
    for(j=1; j<=13; j++){
      if(card[i][j] == 0){
	switch(i){
	case 0:
	  printf("S %d\n",j);
	  break;

	case 1:
	  printf("H %d\n",j);
	  break;

	case 2:
	  printf("C %d\n",j);
	  break;

	case 3:
	  printf("D %d\n",j);
	  break;
	  
	}
      }
    }
  }
   
  return 0;
  
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi acos(-1)
typedef long long ll;
int main(){
    int R;
    cin>>R;
    cout<<(double)2*pi*R<<endl;
    return 0;
}

Measured memory_bytes: 3752
/**

     .=     ,        =.
  _  _   /'/    )\,/,/(_   \ \
   `//-.|  (  ,\\)\//\)\/_  ) |
   //___\   `\\\/\\/\/\\///'  /
,-"~`-._ `"--'_   `"""`  _ \`'"~-,_
\       `-.  '_`.      .'_` \ ,-"~`/
 `.__.-'`/   (-\        /-) |-.__,'
   ||   |     \O)  /^\ (O/  | .        <-  BESSIE THE COW / BESITE SOV
   `\\  |         /   `\    /
     \\  \       /      `\ /
      `\\ `-.  /' .---.--.\
        `\\/`~(, '()      ('
         /(O) \\   _,.-.,_)
        //  \\ `\'`      /
       / |  ||   `""""~"`
     /'  |__||
           `o

*/


//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


bool DEBUG = 0;
#define debug(x) if (DEBUG) {cerr << #x << " = " << x << "\n";}
#define debug_vec(x) if (DEBUG) {cerr << #x << " = {"; for(auto a : x) cerr << a << ","; cerr << "}" << endl;}

#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a, b;
main() {
    file("sort");
    ios;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int mod = 1000000007;
inline int mul(int x,int y){return 1ll*x*y%mod;}
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int sq(int x){return 1ll*x*x%mod;}
int pow(int a,int b){return b == 0 ? 1 : ( b&1 ? mul(a,sq(pow(a,b/2))) : sq(pow(a,b/2)));}

void upd(int &a,int b){a = add(a,b);}
char st[300030];
int dp[2][4][3];
int main() {
	cin>>st;
	int cu = 0;
	dp[cu][0][0] = 1;
	int n = strlen(st);
	for(int ech=0;ech<n;ech++){
		memset(dp[cu^1],0,48);
		if(st[ech] == '1' || st[ech] == '?'){
			for(int i=0;i<=3;i++){
				upd(dp[cu^1][min(i+1,3)][0],dp[cu][i][0]);
				upd(dp[cu^1][i][0],dp[cu][i][1]);
				upd(dp[cu^1][i][1],dp[cu][i][2]);
			}
		}
		if(st[ech] == '0' || st[ech] == '?'){
			for(int i=0;i<=3;i++){
				upd(dp[cu^1][i][1],dp[cu][i][0]);
				upd(dp[cu^1][i][2],dp[cu][i][1]);
				upd(dp[cu^1][i][1],dp[cu][i][2]);
			}
		}
		cu^=1;
	}
	int ans = 0;
	for(int i=1;i<=3;i++)for(int j=0;j<i;j++)ans = add(ans,dp[cu][i][j]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
N = int(input())
v = list(map(int, input().split()))

sv = sorted(v)

ans = 0

for i in range(N-1):
  if i == 0:
    ans = (sv[i] + sv[i+1]) / 2
  else:
    ans = (sv[i+1] + ans) / 2

print(ans)

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

int main(){
    int n; cin >> n;
    int bb[110] = {0};
    rep(i, n-1) {
        int b; cin >> bb[i];
    }
    int aa[110] = {0};
    aa[n-1] = bb[n-2];
    aa[0] = bb[0];
    for(int i=1; i<n-1; i++) {
        aa[i] = min(bb[i-1], bb[i]);
    }
    ll sum=0;
    rep(i, n) sum+=aa[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld         long long int
#define llf         long double
#define pb          push_back
#define mp          make_pair
#define IN          insert
#define loopN(n)    for(lld i=0;i<n;i++)
#define loop(p,n)   for(lld i=p;i<=n;i++)
#define rloop(p,n)  for(lld i=n;i>=p;i--)
#define loop2(p,n)  for(lld j=p;j<=n;j++)
#define all(v)      v.begin(),v.end()
#define F1          first
#define F2          second
#define INF         2e18
#define FILE        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define PI          2*acos(0.0)
#define ISO         ios::sync_with_stdio(false);cin.tie(0)
#define mod         100000007
#define mem(a,b)    memset(a,b,sizeof(a))
using namespace std;

bool pal(lld n)
{
    vector<lld>a;
    while(n!=0)
    {
        a.pb(n%10);
        n/=10;
    }
    lld p=0,q=a.size()-1;
    while(p<=q)
    {
        if(a[p]!=a[q])return 0;
        p++;
        q--;
    }
    return 1;



}


int main()
{
    ISO;
    lld a,b;
    cin>>a>>b;
    lld ans=0;
    loop(a,b)
    {
        if(pal(i))ans++;
    }
    cout<<ans<<endl;








    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

int main()
{
  int a, b;
  cin >> a >> b;
  cout << (a < b ? 0 : 10) << endl;
  return 0;
}


Measured memory_bytes: 256