akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int from,int to, T cost) {
        edges[from].emplace_back(to, cost);
        if(!directed){
            edges[to].emplace_back(from,cost);
        }
    }


    int size() {
        return n;
    }
};


int main() {

    int N,B;

    cin >> N >> B;

    cout << N*B << endl;

    return 0;
}

Measured memory_bytes: 3676
N = int(input())
TA = [[int(x) for x in input().split()]for _ in range(N)]
t = 1
a = 1

for i in TA:
    j = max(t//i[0],a//i[1])
    if(t>i[0]*j or a>i[1]*j):
        j+=1
    t = i[0]*j
    a = i[1]*j

print(t+a)


Measured memory_bytes: 3188
#include<stdio.h>

int main(){

  int a,b,rest=1,temp;

  scanf("%d%d",&a,&b);


  if(b > a){
    temp = a;
    a = b;
    b = temp;
}

    while(b != 0){
    rest = a%b;

    a = b;
    b = rest;
    }


  printf("%d\n",a);

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = false;
void solve()
{
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * n * n << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mx = 1e9+7;
int N = 1e5+5;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    vector<int>dp(n,mx);
    dp[0] =0;
    for(int i=0;i<n;i++)
        for(int j=i+1;j<=(i+k);j++)
    {
        if(j<n)
        {
            dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;

// Ref. https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396 //
struct UnionFind {
    vector<int> par;

    // Initialize. All vertices are roots when initial state.
    UnionFind(int N) : par(N) {
        REP(n,N) par.at(n) = n;
    }

    // Return the root of tree which consists of vertex(x)
    int root(int x) {
        if (par[x] == x) return x;     // If x is the root, return x
        return par[x] = root(par[x]);  // Recursively find the root of tree. 
    }

    // Unite two vertices into one tree. 
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    // Return true if two vertices has the same root, else return false.
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> pn(N);
  REP(n,N){
    int tmp;
    cin >> tmp;
    pn.at(n) = tmp - 1;
  }


  UnionFind tree(N); // initialize
  REP(m,M){
    int x, y;
    cin >> x >> y;
    tree.unite(x-1, y-1);
  }

  int ans = 0;
  REP(n,N){
    int num = pn.at(n);
    if(tree.same(n,num)) ans += 1;
  }
  cout << ans << endl;
}


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

amax = a[-1]
dp = [True] * (amax+1)
ans = 0
for x in range(len(a)-1):
   i = a[x]
   if dp[i] == True:
      for j in range(amax//i+1):
         dp[i*j] = False
      if a[x] != a[x+1]:
         ans += 1
if dp[amax] == 1:
   ans += 1
print(ans)


Measured memory_bytes: 32296
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int H, W;
vector<string> S(21);
int bfs(int i, int j) {
    int m = 0;
    vector<vector<int>> res(21, vector<int>(21,-1)), C(21,vector<int>(21,0));
    queue<pair<int,int>> Q;
    C[i][j] = 1;
    res[i][j] = 0;
    if (i-1>=0 && S[i-1][j] == '.') {
        Q.emplace(i-1,j);
        res[i-1][j] = 1;
        m = 1;
    }
    if (j-1>=0 && S[i][j-1] == '.') {
        Q.emplace(i,j-1);
        res[i][j-1] = 1;
        m = 1;
    }
    if (i+1< H && S[i+1][j] == '.') {
        Q.emplace(i+1,j);
        res[i+1][j] = 1;
        m = 1;
    }
    if (j+1< W && S[i][j+1] == '.') {
        Q.emplace(i,j+1);
        res[i][j+1] = 1;
        m = 1;
    }
    // cout << "(0,0)" << endl;
    while (!Q.empty()) {
        int k = Q.front().first, l = Q.front().second;
        Q.pop();
        if (C[k][l]) continue;
        C[k][l] = 1;
        // cout << "(" << k << "," << l << ")" << endl;
        if (k-1>=0 && S[k-1][l] == '.' && !C[k-1][l]) {
            Q.emplace(k-1,l);
            res[k-1][l] = res[k][l]+1;
            m = res[k][l]+1;
        }
        if (l-1>=0 && S[k][l-1] == '.' && !C[k][l-1]) {
            Q.emplace(k,l-1);
            res[k][l-1] = res[k][l]+1;
            m = res[k][l]+1;
        }
        if (k+1< H && S[k+1][l] == '.' && !C[k+1][l]) {
            Q.emplace(k+1,l);
            res[k+1][l] = res[k][l]+1;
            m = res[k][l]+1;
        }
        if (l+1< W && S[k][l+1] == '.' && !C[k][l+1]) {
            Q.emplace(k,l+1);
            res[k][l+1] = res[k][l]+1;
            m = res[k][l]+1;
        }
    }
    return m;
}


int main(void) {
    cin >> H >> W;
    for (int i=0;i<H;i++) cin >> S[i];

    int res = 0;
    // res = bfs(0,0);
    // for (int j=0;j<W;j++) {
    //     if (S[0][j] != '#') res = max(res,bfs(0,j));
    // }
    // for (int j=0;j<W;j++) {
    //     if (S[H][j] != '#') res = max(res,bfs(H,j));
    // }
    // for (int i=0;i<H;i++) {
    //     if (S[i][0] != '#') res = max(res,bfs(i,0));
    // }
    // for (int i=0;i<H;i++) {
    //     if (S[i][W] != '#') res = max(res,bfs(i,W));
    // }
    for (int i=0;i<H;i++) for (int j=0;j<W;j++) {
        if (S[i][j] == '#') continue;
        res = max(res,bfs(i,j));
    }
    cout << res << endl;

    return 0;
}


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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll diff = c - a - b;
    if (diff < 0)
        cout << "No" << endl;
    else if (4 * a * b < (diff * diff))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

using namespace  std;


int main()
{
    string s1,s2;
    int i,c=0;
    cin>>s1>>s2;
    for (i=0;i<3;++i){

        if(s1[i]==s2[i])++c;

    }
    cout<<c<<endl;
    return 0;

}


Measured memory_bytes: 256
n = int(input())
p= [int(i) for i in input().split()]
count=0
for i in range(n-2):
    if (p[i]<p[i+1] and p[i+1]<p[i+2]) or (p[i]>p[i+1] and p[i+1]>p[i+2]):
        count+=1
print(count)

Measured memory_bytes: 3060
#include<cstdio>
#include<string>
#include<cstdlib>
#include<iostream>
using namespace std;
const int N=1e5+10;

int n;
char ans[N];
string str[N];

void dfs(int i,int a,int b,int c) {
	if(i>n) {
		puts("Yes");
		for(int i=1;i<=n;i++) putchar(ans[i]),puts("");
		exit(0);
	}
	if(str[i]=="AB") {
		if(a) ans[i]='B',dfs(i+1,a-1,b+1,c);
		if(b) ans[i]='A',dfs(i+1,a+1,b-1,c);
	}
	else if(str[i]=="AC") {
		if(a) ans[i]='C',dfs(i+1,a-1,b,c+1);
		if(c) ans[i]='A',dfs(i+1,a+1,b,c-1);
	}
	else {
		if(b) ans[i]='C',dfs(i+1,a,b-1,c+1);
		if(c) ans[i]='B',dfs(i+1,a,b+1,c-1);
	}
}

int main() {
	scanf("%d",&n); int a,b,c; scanf("%d %d %d",&a,&b,&c);
	for(int i=1;i<=n;i++) cin>>str[i];
	dfs(1,a,b,c); puts("No");exit(0);
}


Measured memory_bytes: 14720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

class Progaram
{
    static void Main(String[] args)
    {
        var l = Console.ReadLine().Split(' ')
            .Select(x => long.Parse(x)).ToArray();
        var n = l[0]; var t = l[1];
        var ts = Console.ReadLine().Split(' ')
            .Select(x => long.Parse(x)).ToArray();
        var bef = ts[0];
        var x = 0L;
        for (var i = 1; n > i; i++)
        {
            var sa = ts[i] - ts[i - 1];
            if (sa > t)
            {
                x += t;
            }
            else
            {
                x += sa;
            }
        }
        x += t;
        Console.WriteLine(x);
    }
}

Measured memory_bytes: 45620
using System;

public class Problem {
  public static void Main(string[] args) {
    var str = Console.ReadLine().Split();
    int n = int.Parse(str[0]);
    int r = int.Parse(str[1]);
    int ans = 0;
    
    if (n >= 10) {
      Console.WriteLine(r);
    }else {
      ans = r + 100 * (10 - n);
      Console.WriteLine(ans);
    }
  }
}

Measured memory_bytes: 11220
import math

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

def permutations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0
if (n > 1):
    ans += permutations_count(n, 2)
if (m > 1):
    ans += permutations_count(m, 2)

print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<set>

using namespace std;
set<int> memo;
int main() {
	int c, n, ans = 0;
	cin >> c >> n;
	vector<string> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n / 2; i++) {
		for (int j = 0; j < n / 2; j++) {
			if (a[i][j] == a[i][n - 1 - j] && a[i][j] == a[n - 1 - i][j] && a[i][j] == a[n - 1 - i][n - 1 - j]);
			else {
				memo.insert(i*n + j);
			}
		}
	}
	if (memo.size() == 0)ans++;
	for (int h = 1; h < c; h++) {
		int d, dx[101], dy[101];
		cin >> d;
		for (int i = 0; i < d; i++) {
			cin >> dx[i] >> dy[i];
			dx[i]--; dy[i]--;
			if (a[dx[i]][dy[i]] == '0')a[dx[i]][dy[i]] = '1';
			else a[dx[i]][dy[i]] = '0';
			if (dx[i] >= n / 2)dx[i] = n - 1 - dx[i];
			if (dy[i] >= n / 2)dy[i] = n - 1 - dy[i];
		}
		for (int i = 0; i < d; i++) {
			if (a[dx[i]][dy[i]] == a[dx[i]][n - 1 - dy[i]] && a[dx[i]][dy[i]] == a[n - 1 - dx[i]][dy[i]] && a[dx[i]][dy[i]] == a[n - 1 - dx[i]][n - 1 - dy[i]]) {
				memo.erase(dx[i] * n + dy[i]);
				memo.erase((n - 1 - dx[i])*n + dy[i]);
				memo.erase(dx[i] * n + n - 1 - dy[i]);
				memo.erase((n - 1 - dx[i])*n + n - 1 - dy[i]);
			}
			else memo.insert(dx[i]*n+dy[i]);
		}
		if (memo.size() == 0)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13252
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SORT(v) sort(all(v))
#define TROS(v) sort(all(v), std::greater<Type>());
#pragma endregion

int main() {
    // template
    int r, d, x;cin>>r>>d>>x;
    rep(i,10){
        x = r*x-d;
        cout<<x<<endl;
    }

}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,x; cin>>n>>x;
    vector<ll> m(n);
    rep(i,n){
        cin>>m[i];
        x-=m[i];
    }
    ll ans=n;
    sort(all(m));
    ans+=x/m[0];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
# AOJ 1042: Yes, I have a number
# Python3 2018.7.6 bal4u

while True:
	s = input()
	if s == "END OF INPUT": break
	ans, i, ls = '', 0, len(s)
	while i < ls:
		w = 0
		while i < ls and s[i] == ' ':
			w, i = w+1, i+1
		if w > 1: ans += '0'*(w-1)
		w = 0
		while i < ls and s[i].isalpha():
			w, i = w+1, i+1
		if w > 0: ans += chr(ord('0')+w)
	print(ans)


Measured memory_bytes: 5560
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

public class Test_153_a
{
        
        /// <summary>
        /// テスト環境の動作確認用
        /// </summary>
        public static void Main()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            int H = int.Parse(ss[0]);
            int A = int.Parse(ss[1]);

            Console.WriteLine(Solve(H,A).ToString());
        }

        static int Solve(int H, int A)
        {
            int d = H / A;
            int m = H % A;
            if (m > 0)
            {
                d++;
            }

            return d;
        }
}


Measured memory_bytes: 11092
function main(input) {
  var args = input.split(' ');
  var n = parseInt(args[0], 10);
  var m = parseInt(args[1], 10);
  if ( n === m) {
    return "Yes";
  } else {
    return "No";
  }
}
console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7372
x1, y1, x2, y2 = map(int, input().split())
v = (x2 - x1, y2 - y1)

x3, y3 = x2 - v[1], y2 + v[0]
x4, y4 = x3 - v[0], y3 - v[1]
print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const LL INF=1<<17;
   

int main(){
    int N;
    LL x;
    cin >> N >> x;
    LL a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a,a+N);
    int ans=0;
    for(int i=0;i<N;i++){
        x-=a[i]; 
        if(x>=0) ans++;
        else break;
    } 
    if(x>0) ans--;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))


# a, bの公約数の集合 と a, bの最大公約数の約数の集合 は同値
# a, bの最大公約数の約数のうち、互いに素なもの <= a, bの最大公約数の素因数と(と 1)
# n の素因数分解はO(√ n)で行える


def get_primes(n):
    root_n = int(n ** 0.5)
    is_prime = [True] * (n + 1)
    is_prime[0], is_prime[1] = False, False
    for i in range(2, root_n + 1):
        if not is_prime[i]:
            continue
        # i の倍数の素数判定をFalseにする
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def prime_factrize(n: int) -> list:
    # 素因数のリストを取得(重複する素因数を含む)
    # 例 : 18 -> [2, 3, 3]
    if n < 2:
        return []
    p_factors = []
    # 2だけ先に取り分けておく
    while n % 2 == 0:
        p_factors.append(2)
        n //= 2
    # 残りの奇数の素因数を探す
    f = 3
    while f * f <= n:
        if n % f == 0:
            p_factors.append(f)
            n //= f
        else:
            f += 2
    # nが素数の場合
    if n != 1:
        p_factors.append(n)
    return p_factors


def main():
    a, b = LI()
    gcd = math.gcd(a, b)
    pf = prime_factrize(gcd)
    pf = set(pf)  # 素因数だけ取り出す
    # 1 を加える
    pf.add(1)
    print(len(pf))


main()


Measured memory_bytes: 9228
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;
#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define pf          push_front
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(a)      a.begin(),a.end()
#define mp          make_pair
#define MAX         100
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

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

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

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      ll n;
      cin>>n;
      ll arr[n];
      loop(i,0,n){cin>>arr[i];}

      sort(arr,arr+n,cmp);

      ll sum=0;
      if(n>=2) sum+=arr[0];
      for(ll i=2,j=1; i<n; i++){
            sum+=arr[j];
            if(i%2) j++;
      }
      cout<<sum<<endl;


      bye;
}


Measured memory_bytes: 5236
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  double x = (double)(a + b)/2;
  int o = ceil(x);
  cout << o << endl;
  return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
int n;
int a,b;

int main(){
	fast_io();
	cin >> n;
	bool same = true;
	int mn = 1 << 30;
	ll sum = 0;
	cu(i,0,n){
		cin >> a >> b;
		sum += a;
		same &= a == b;
		if(a > b){
			gmin(mn,b);
		}
	}
	if(same){
		cout << 0 << '\n';
	}
	else{
		cout << sum - mn << '\n';
	}
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}


int main(){
    ll a,b,c,x,y,n,m,h,k,max=-10000000,min=1000000000,ans=0,sum=0;
    string s,t;
    cin >> n >> a >> b;
    if (a == b){
        cout << 1 << endl;
        return 0;
    }

    if( a > b || (a != b && n == 1)){
        cout << 0 << endl;
        return 0;
    }

    cout << (b*(n-2))-(a*(n-2))+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    int n, k;
    unordered_map<long, long> m;
    cin >> n >> k;
    REP(i,n) {
        long a;
        cin >> a;
        m[a]++;
    }
    vector<P> v;
    for (auto i = m.begin(); i != m.end(); i++) {
        v.push_back(P(i->second, i->first));
    }
    sort(v.begin(), v.end());
    long cnt = 0;
    REP(i,int(v.size()) - k) {
        cnt += v[i].first;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 14404
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<ll,ll>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  string s; cin>>s; int n=s.size();
  int u=0;
  for(int i=0;i<n;i++) {
    if (u==0&&s[i]=='C') u++;
    else if(u==1&&s[i]=='F') u++;
  }
  if (u==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var N, M int

type Pair struct {
	l, r int
}

type Pairs []Pair

func (a Pairs) Len() int           { return len(a) }
func (a Pairs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Pairs) Less(i, j int) bool { return a[i].r < a[j].r }

func main() {
	sc.Split(bufio.ScanWords)
	N, M = nextInt(), nextInt()
	pairs := make([]Pair, M)
	for i := 0; i < M; i++ {
		a := nextInt()
		b := nextInt()
		pairs[i].l = a - 1
		pairs[i].r = b - 1
	}

	sort.Sort(Pairs(pairs))
	//fmt.Println(arms[:N])

	end := -1
	ans := 0
	for i := 0; i < M; i++ {
		if pairs[i].l >= end {
			end = pairs[i].r
			ans++
		}
	}

	fmt.Println(ans)

}


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

int main() {
    int X, Y;
    string ans = "No";
    cin >> X >> Y;
    for (int i = 0; i < X + 1; i++) {
        if (Y == 4 * (X - i) + 2 * i) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <utility>

using namespace std;

int main()
{
    long long n, a[200010], ans=0;
	cin >> n;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) ans += abs(a[i] - a[n/2]);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1792
while 1:
	X,Y = map(int,raw_input().split())
	if X == 0: break
	A = [[0]+map(int,raw_input().split())+[0] for i in range(Y)]
	S = [[0]*(X+2) for i in range(Y)]
	for x in range(1,X+1): S[0][x] = 1 if A[0][x] == 0 else 0
	for y in range(1,Y):
		for x in range(1,X+1):
			if A[y][x] == 0:
				for i in range(-1,2):
					S[y][x] += S[y-1][x-i] if A[y-1][x-i] == 0 else 0
			if A[y][x] == 2:
				S[y][x] += S[y-1][x] if A[y-1][x] == 0 else 0
				if y+2 < Y and A[y+2][x] != 1:
					S[y+2][x] = S[y][x]
	ans = 0
	for x in range(1,X+1):
		ans += S[Y-1][x] + (S[Y-2][x] if A[Y-2][x] == 2 else 0)
	print ans

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

int main()
{
  int n, ans = 0;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++)
    cin >> v[i];
  
  for(int i=1; i<n-1; i++)
  {
    if(v[i-1] < v[i] && v[i] < v[i+1])
      ans++;
    else if(v[i+1] < v[i] && v[i] < v[i-1])
      ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    string s;
    cin >> s;
    map<char, int> alphabets;
    for(int i = 0; i < s.size(); i++){
        alphabets[s[i]]++;
    }
    int most = 'a';
    for(char i = 'a'; i <= 'z'; i++){
        if(alphabets[most] < alphabets[i]){
            most = i;
        }
    }
    int ans = 1e9;
    for(char looking = 'a'; looking <= 'z'; looking++){
        for(int i = 0; i < s.size(); i++){
            bool if_ok = true;
            for(int j = 0; j < s.size() - i; j++){
                bool if_in_looking = false;
                for(int k = j; k <= i + j; k++){
                    if_in_looking |= (s[k] == looking);
                }
                if_ok &= if_in_looking;
            }
            if(if_ok){
                ans = min(ans, i);
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
    
int run_test(){
    int k;
    cin >> k;
    if(k <= 9){
        cout << k;
        return 0;
    }
    queue<int> q;
    for(ll i=1; i <= 9; i++){
        q.push(i);
    }
    int count = 9;
    while(count != k){
        ll a = q.front();
        q.pop();
        int t = a % 10;
        for(int i=-1; i<=1; i++){
            if(t + i <= 9 && t + i >= 0){
                string s = to_string(a);
                char p = (t + i) + '0';
                s = s + p;
                count++;
                if(count == k){
                    cout << s;
                    return 0;
                }
                q.push(stoll(s));
            }
        }
    }
    return 0;
}
    
int main(){
   FAST;
    ll t;
    t = 1;
     
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 3904
n,w=map(int,input().split())
dic=[[],[],[],[]]
a,b=map(int,input().split())
dic[0].append(b)
p=a
v=[1,0,0,0]
for i in range(n-1):
    a,b=map(int,input().split())
    dic[a-p].append(b)
    v[a-p]+=1
for i in range(4):
    dic[i]=sorted(dic[i],reverse=True)
    for j in range(1,v[i]):
        dic[i][j]=dic[i][j]+dic[i][j-1]
    dic[i].insert(0,0)
max_v=0
for i in range(v[0]+1):
    for j in range(v[1]+1):
        for k in range(v[2]+1):
            for l in range(v[3]+1):
                if i*p+j*(p+1)+k*(p+2)+l*(p+3)<=w:
                    max_v=max(max_v,dic[0][i]+dic[1][j]+dic[2][k]+dic[3][l])
print(max_v)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std ;
 
#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)
 
#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))
 
using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;
 
template<typename T>
void O(T t){
  cout << t << endl;
}
 
const ll mod = 1e9+7;
constexpr ll inf = 1e18;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};
 
ll da[300001],db[300001],v[300001];
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  rep(i,3*N){
    cin >> v[i];
  }
  priority_queue<ll,vector<ll>,greater<ll>> a;
  ll A = 0,B = 0;
  rep(i, N * 2){
    A += v[i];
    a.push(v[i]);
    if(i >= N){
      ll k = a.top(); a.pop();
      A -= k;
    }
    if(i >= N -1){
      da[i] = A;
    }
  }
  priority_queue<ll> b;
  for(int i = 3*N - 1; i >= N; i--){
    B += v[i];
    b.push(v[i]);
    if(i < 2 * N){
      ll k = b.top(); b.pop();
      B -= k;
    }
    if(i <= 2 * N){
      db[i] = B;
    }
  }
  ll ans = -inf;
  for(int i = N - 1; i < 2 * N; i++){
    /* cout << da[i] << ' ' << db[i+1] << endl; */
    ans = max(ans,da[i]-db[i+1]) ;
  }
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 8820
W,H,x,y=map(int,input().split())
if x==W/2 and y==H/2:
    print(W*H/2,1)
elif not x or not y:
    print(W*H/2,0)
elif x/W==y/H or x/W==(H-y)/H:
    print(W*H/2,0)
else:
    print(W*H/2,0)


Measured memory_bytes: 2940
N = int(input())
A = list(map(int,input().split()))

S = sum(A)
x1 = S - 2*sum(A[1::2])
 
X = [x1] * (N)
for i in range(1,N):
    X[i] = 2*A[i-1] - X[i-1]
 
print(' '.join([str(xi) for xi in X]))

Measured memory_bytes: 24768
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct List {
  int key;
  struct List *before;
  struct List *next;
};

struct List l;

void insert(int key) {
  struct List *a = malloc(sizeof(struct List));
  a->key = key;
  a->before = &l;
  a->next = l.next;
  l.next = a;
  a->next->before = a;
}

void delete(int b) {
  struct List *c;
  c = l.next;
  while(c->key != -1) {
    if (c->key == b) {
      c->next->before = c->before;
      c->before->next = c->next;
      break;
    }  
    c = c->next;
  } 
  }

void delete_First() {
  l.next = l.next->next;
  l.next->before = &l;
}

void delete_Last() {
  l.before = l.before->before;
  l.before->next = &l;
}

int main(void) {
  int n;
  char command[12];
  int key;
  struct List *box;
  l.key = -1;
  l.before = &l;
  l.next = &l;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", command);
    if (strcmp(command, "deleteFirst") == 0)
      delete_First();
    else if (strcmp(command, "deleteLast") == 0)
      delete_Last();
    else {
      scanf("%d", &key);
      if (strcmp(command, "insert") == 0) 
	insert(key);
      else if (strcmp(command, "delete") == 0)
	delete(key);
      }
    }
 
  
  box = l.next;
  while(box->key != -1) {
    printf("%d", box->key);
    box = box->next;
    if (box->key != -1)
      printf(" ");
  }
  printf("\n");
  
  return 0;
}



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

struct Init {
  Init() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} Init;

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

  if (d == 0) {
    cout << (double)(m - 1) / n << endl;
  } else {
    cout << (double)2 * (n - d) * (m - 1) / (n * n) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    cin >> n;

    switch (n % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;

    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;

    default:
        cout << "bon" << endl;
        break;
    }
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <memory.h>
int main(void){
	int a[15][15]={0},i,j,x,y,f;
	while(1){
		memset(a,0,sizeof(a));
		f=1;
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				if(scanf("%1d",&a[i][j])==EOF){
					return 0;
				}
				if(a[i][j]&&f){
					x=i;
					y=j;
					f=0;
				}
			}
		}
		if(a[x][y+3]){
			puts("C");
		}
		else if(a[x+3][y]){
			puts("B");
		}
		else if(a[x+1][y-1]){
			if(a[x+2][y-1]){
				puts("D");
			}
			else{
				puts("G");
			}
		}
		else{
			if(a[x+2][y+1]){
				puts("F");
			}
			else if(a[x+1][y]){
				puts("A");
			}
			else{
				puts("E");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 580
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power1( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power1(b*b,e/2);
    return power1(b*b,e/2);
}
ll f(ll x){
	if(x%4 == 0){
		return x ;
	}
	else if(x%4 == 1){
		return 1 ;
	}
	else if(x%4 == 2){
		return (x+1) ;
	}
	else return 0 ;
}
int main(){
	 ll X ; cin >> X ;
	 //cout << power(2,5);
	 bool flag = 0 ;
	 for(ll i = -3000 ; i <= 3000 ; i++){
	 	   for(ll j = -3000 ; j <= 3000 ; j++){
	 	   	      ll x = power1(i,5);
	 	   	      ll y = power1(j,5);
	 	   	      if((x-y)==X){
	 	   	      	    cout << i << " " << j << endl;
	 	   	      	    flag = 1 ;
	 	   	      	     break;
				}
			}
		  if(flag) break ;
	 }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    SORT(a);
    a.erase(unique(all(a)), a.end());
    cout << (a.size() == n ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n % 10 == 9 || n / 10 == 9) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}


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

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        long a = in.nextLong();
        long b = in.nextLong();
        long c = in.nextLong();
        long k = in.nextLong();
        System.out.println((k % 2 == 1) ? b - a : a - b);
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int l, r; cin >> l >> r;
    int d; cin >> d;
    cout << r / d - (l - 1) / d << endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	string S;

	cin >> S;

	if (S == "ABC")
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "ABC" << endl;
	}

	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
typedef complex<ftype> point;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}

const int MAXN = 1e5+5;
const int MOD = 1e9+7;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) cout << s;
    else cout << "red";
    cout << endl;
    return 0;
}


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

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(long long e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e & 1) {a = (a * p) % mod; e--;}
            else {p = (p * p) % mod; e /= 2;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

template<int mod> struct Combination {
    vector<ModInt<mod>> fact, ifact;
    Combination(int n) : fact(n+1), ifact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i);
        ifact[n] = fact[n].inverse();
        for (int i = n; i > 0; i--) ifact[i - 1] = ifact[i] * i;
    }
    ModInt<mod> operator() (int n, int r) {
        if (r < 0 or r > n) return 0;
        return fact[n] * ifact[n-r] * ifact[r];
    }
    const ModInt<mod> &operator[] (int i) const {
        return fact[i];
    }
};

constexpr int MOD = 1000000007;
constexpr int MAX = 1000100;

int main() {
	Combination<MOD> binom(MAX);
	int n, k;
	cin >> n >> k;
	
	cout << binom(n + k - 1, n) << '\n';
	
	return 0;
}


Measured memory_bytes: 10580
H, W = map(int, input().split())
s = [input() for _ in range(H)]


def dfs(startx: int, starty: int) -> set:
    dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    stack = [(startx, starty, s[starty][startx] == '#')]
    reached = set()
    reached.add((startx, starty))
    b, w = 0, 0
    while stack:
        d = stack.pop()
        if d[2]:
            b += 1
        else:
            w += 1
        for a in dxdy:
            x = d[0] + a[0]
            y = d[1] + a[1]
            if (x, y) not in reached and 0 <= x < W and 0 <= y < H and d[2] ^ (s[y][x] == '#'):
                stack.append((x, y, s[y][x] == '#'))
                reached.add((x, y))
    return (reached, b, w)


reach = set()
ans = 0
for i in range(H):
    for j in range(W):
        if (j, i) not in reach:
            res = dfs(j, i)
            reach |= res[0]
            ans += res[1] * res[2]
print(ans)


Measured memory_bytes: 35532
N, X, Y = map(int, input().split())
graph = [[] for _ in range(N)]
for i in range(1, N):
    graph[i-1].append(i)
    graph[i].append(i-1)
graph[X-1].append(Y-1)
graph[Y-1].append(X-1)
from collections import deque, defaultdict
dic = defaultdict(int)

def bfs(s):
    checked = [0]*N
    queue = deque([(s, 0)])
    while queue:
        v, c = queue.pop()
        if checked[v]:
            continue
        checked[v] = 1
        dic[c] += 1
        for i in graph[v]:
            if not checked[i]:
                queue.appendleft((i, c+1))

for i in range(N):
    bfs(i)

for i in range(1, N):
    print(dic[i]//2)
        

Measured memory_bytes: 50652
#include<bits/stdc++.h>
using namespace std;
int n,m;
char r[600][600],b[600][600],a[600][600];
void solve() {
	for(int i=1; i<=n; i+=2)
		for(int j=1; j<=m; j++)
			r[i][j]='#';
	for(int i=2; i<=n; i+=2)
		for(int j=1; j<=m; j++) {
			r[i][j]='.';
		}
	for(int i=2; i<=n; i+=2)
		for(int j=1; j<=m; j++)
			b[i][j]='#';
	for(int i=1; i<=n; i+=2)
		for(int j=1; j<=m; j++) {
			b[i][j]='.';
		}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			char cur;
			cin>>cur;
			if(cur=='#') {
				r[i][j]='#';
				b[i][j]='#';
			}
		}
	}
	for(int i=1; i<=n; i++)
		r[i][1]='#',b[i][1]='.';
	for(int i=1; i<=n; i++)
		r[i][m]='.',b[i][m]='#';
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++)
			cout<<r[i][j];
		cout<<endl;
	}
	cout<<endl;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++)
			cout<<b[i][j];
		cout<<endl;
	}
}
int main() {
	cin>>n>>m;
	solve();

	return 0;
}

Measured memory_bytes: 1408