akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2);
		return (tmp * tmp) % MOD;
	}
	return (a * mod_pow(a, n - 1)) % MOD;
}

vector<ll> fact;
vector<ll> inv_fact;

void comb_init(int n) {
	fact.resize(n + 1);
	inv_fact.resize(n + 1);
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv_fact[i] = (inv_fact[i - 1] * mod_pow(i, MOD - 2)) % MOD;
	}
}

ll comb(int n, int k) {
	if (n < k) return 0;
	ll ret = fact[n];
	(ret *= inv_fact[k]) %= MOD;
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}

ll perm(int n, int k) {
	if (n < k) return 0;
	ll ret = fact[n];
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}

vector<int> G[100000];
int N, K;
ll calc(int v, int p) {
	ll ret = perm(K - 2, G[v].size() - 1);
	for (int to : G[v]) {
		if (to == p) continue;
		(ret *= calc(to, v)) %= MOD;
	}
	return ret;

}
int main() {
	cin >> N >> K;
	for (int i = 0; i + 1 < N; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	comb_init(K);
	if (K == 1) {
		if (N == 1) cout << 1 << endl;
		else cout << 0 << endl;
		return 0;
	}
	ll ans = perm(K, G[0].size() + 1);
	for (int to : G[0]) {
		(ans *= calc(to, 0)) %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10368
#include <limits.h>
#include <stdio.h>

int main(){
  int a, b, c, d, i;
  long long int x[4], max=LLONG_MIN;

  scanf("%d %d %d %d", &a, &b, &c, &d);
  x[0]=(long long int)a*c;
  x[1]=(long long int)a*d;
  x[2]=(long long int)b*c;
  x[3]=(long long int)b*d;
  for(i=0; i<4; i++)
    if(x[i]>max)
      max=x[i];
  printf("%lld\n", max);

return 0;}


Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll =  long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}


}


int main() {

	char c;
	std::cin >> c;

	std::cout << (char)(c + 1) << std::endl;

	return 0;
}

Measured memory_bytes: 256
const [WHITE, BLACK] = [0, 1];

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const range_n = Array.from(Array(n), (e, i) => i);
  const adj = []
  let x, k, arr;
  lines.forEach((l, i) => {
    adj[i] = [].concat(range_n).fill(Infinity);
    [x, k, ...arr] = l.split(' ').map(Number);
    for (let j = 0; j < k; j++) adj[i][arr[2 * j]] = arr[2 * j + 1];
  });

  const dist = [];
  const color = [];
  for (let i = 0; i < n; i++) {
    dist[i] = Infinity;
    color[i] = WHITE;
  }
  dist[0] = 0;

  let mincost, u = 0, min = [].concat(range_n).fill(Infinity);
  min[0] = 0;

  while (true) {
    adj[u].forEach((v, i) => {
      if (color[i] !== BLACK && min[u] + v < min[i]) min[i] = min[u] + v;
    });

    mincost = range_n.reduce((m, i) => {
      if (color[i] === BLACK || min[i] >= m) return m;
      return min[u = i];
    }, Infinity);

    if (mincost === Infinity) break;

    color[u] = BLACK;
  }

  console.log(min.map((e, i) => `${i} ${e}`).join('\n'));
})();




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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e4 + 5);

int n, m;
vector<int> vec_a;

int dp[MAX_N];
map<int, int> mp;

vector<int> ans;

void prepare() {
  mp[1] = 2;
  mp[2] = 5;
  mp[3] = 5;
  mp[4] = 4;
  mp[5] = 5;
  mp[6] = 6;
  mp[7] = 3;
  mp[8] = 7;
  mp[9] = 6;
}

int main(void) {
  // Here your code !
  prepare();

  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    int a;
    scanf("%d", &a);
    vec_a.push_back(a);
  }

  sort(vec_a.begin(), vec_a.end(), greater<int>());

  fill(dp, dp + n, -1);

  dp[0] = 0;

  for (int i = 0; i < n; ++i) {
    if (dp[i] < 0) continue;

    for (auto &e : vec_a) {
      dp[i + mp[e]] = max(dp[i + mp[e]], dp[i] + 1);
    }
  }

  int i = n;

  while (i > 0) {
    for (auto &e : vec_a) {
      if (i >= mp[e] && dp[i - mp[e]] == (dp[i] - 1)) {
        ans.push_back(e);
        i -= mp[e];
        break;
      }
    }
  }

  for (auto &e : ans) {
    printf("%d", e);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int n,i,x;
cin>>n;
vector<pair<int,int> > v;
for(i=0;i<n;i++){
    cin>>x;
    v.pb({x,i+1});
}
sort(all(v));
for(i=0;i<n;i++){
    cout<<v[i].second<<" ";
}
cout<<endl;
}


Measured memory_bytes: 1780
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin>>a>>b;
    int t=a+b, h=a-b, j=a*b;
    if (t>=h && t>=j){
        cout<<t<<endl;
    }
    else if(h>=t && h>=j){
        cout<<h<<endl;
    }
    else {
        cout<<j<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

const int MXN = 110;
const int MXK = 100005;
int n, k;
int v[MXN], w[MXN];
ll dp[MXN][MXK];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    for(int i = n - 1; i >= 0; i--) {
        for(int j = k; j >= 0; j--) {
            dp[i][j] = dp[i + 1][j];
            if(j + w[i] <= k) {
                dp[i][j] = max(dp[i][j], dp[i + 1][j + w[i]] + v[i]);
            }
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 81744
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;




int main()
{
  int a,b,c,n; //かっている数//最大100
  // string s;
  cin >> n;

  vector<long> dp(n+1,0);

  dp[0] = 0;

  long ans =0;

  for (int i = 1; i <=  n; ++i){
    
    long minnum = 1000000;
    minnum = dp[i-1] + 1;

    for (int j = 1; j < 10; ++j){
      if (i >= pow(6,j) )minnum = min(minnum, dp[i-pow(6,j)] + 1 );
      if (i >= pow(9,j) )minnum = min(minnum, dp[i-pow(9,j)] + 1 );
    }
    dp[i] = minnum;
  }


  cout << dp[n] ;
  return 0;
}



























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

struct Mint {
  static int64_t &mod() {
    static int64_t _mod = 1000000007;
    return _mod;
  }

  int64_t v;
  Mint() { v = 0; }
  Mint(int64_t x) { v = x % mod(); if(v < 0) v += mod(); }

  Mint operator-() { return Mint(-v); };
  Mint operator+(Mint x) { return Mint(v + x.v); };
  Mint operator-(Mint x) { return Mint(v - x.v); };
  Mint operator*(Mint x) { return Mint(v * x.v); };
  Mint operator/(Mint x) { return Mint(v * pow(x.v, mod()-2).v); };

  Mint& operator+=(Mint x) { return *this = (*this + x); };
  Mint& operator-=(Mint x) { return *this = (*this - x); };
  Mint& operator*=(Mint x) { return *this = (*this * x); };
  Mint& operator/=(Mint x) { return *this = (*this / x); };

  static Mint pow(Mint base, int64_t exp) {
    if(exp == 0) return Mint(1);
    return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
  }

  friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};

lint f(lint num) {
  lint counter = 0;
  while(num) {
    num %= __builtin_popcount(num);
    counter++;
  }
  return counter;
}

int main() {
  lint N;
  cin >> N;
  string str;
  cin >> str;

  vector<lint> S;
  for(auto c : str) S.push_back(c - '0');
  lint popcount = count(S.begin(), S.end(), 1);
  reverse(S.begin(), S.end());

  vector<lint> ans[2];
  for(auto bit : {0, 1}) {
    lint mod = popcount + (bit == 0 ? 1 : -1);
    Mint::mod() = mod;
    if(mod == 0) { ans[bit] = {0}; continue; }

    Mint X = 0;
    for(lint i=0; i<N; i++) X += Mint::pow(2,i) * S[i];

    for(lint i=0; i<N; i++) if(S[i] == bit) {
      Mint xi = X + Mint::pow(2,i) * (bit == 0 ? 1 : -1);
      ans[bit].push_back(f(xi.v) + 1);
    }
  }

  while(S.size()) {
    cout << ans[S.back()].back() << endl;
    ans[S.back()].pop_back();
    S.pop_back();
  }
}

Measured memory_bytes: 8132
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(is,1<<h)rep(js,1<<w){
        int count =0;
        rep(i,h)rep(j,w){
            if(is>>i&1) continue;
            if(js>>j&1) continue;
            if(s[i][j] == '#') count++;
        }
        if(count == k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 312
typedef long long ll;
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
const int P = 1e9 + 7;
inline void ADD(ll &a, ll b) {
	a += b; if (a >= P)	a -= P;
}
int n, m;
struct edge{
	int nxt, to, val;
}e[N];
int head[N], ecnt;
inline void addedge(int from, int to, int val) {
	e[++ecnt] = (edge){head[from], to, val};
	head[from] = ecnt;
}

ll f[N][N][N];
int main() {
	read(n), read(m);
	for (int i = 1; i <= m; ++i) {
		int l, r, x; read(l), read(r), read(x);
		addedge(r, l, x);
	}
	f[1][0][0] = 3;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < i; ++j) {
			for (int k = 0; k < i; ++k) {
				for (int t = head[i]; t; t = e[t].nxt) {
					int l = e[t].to, x = e[t].val;
					if (x == 1) {
						if (j >= l || k >= l)	f[i][j][k] = 0;
					} else if (x == 2) {
						if ((j >= l && k >= l) || (j < l && k < l))	f[i][j][k] = 0;
					} else {
						if (j < l || k < l)	f[i][j][k] = 0;
					}
				}
				ADD(f[i + 1][j][k], f[i][j][k]);
				ADD(f[i + 1][i][k], f[i][j][k]);
				ADD(f[i + 1][j][i], f[i][j][k]);
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			ADD(ans, f[n][i][j]);
	printf("%lld\n", ans);
	return 0;
}

/*
3 1
1 3 3
//6
*/


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

int main(){
  int N,M;
  cin>>N>>M;
  
  if(N!=0 && M!=0){
    cout<<N*(N-1)/2+M*(M-1)/2<<endl;
  }
  else if(N==0 && M!=0){
    cout<<M*(M-1)/2<<endl;
  }
  else if(N!=0 && M==0){
    cout<<N*(N-1)/2<<endl;
  }
  else{
    cout<<0<<endl;
  }
  
}

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

int main()
{
    int N;
    cin >> N;
    vector<pair<double, double>> XY(N);
    for (int i = 0; i < N; i++)
    {
        pair<double, double> xy;
        cin >> xy.first >> xy.second;
        XY[i] = xy;
    }
    vector<vector<double>> dist(N);
    for (int i = 0; i < N; i++)
    {
        vector<double> tmp(N);
        for (int j = 0; j < N; j++)
        {
            tmp[j] = sqrt(pow((XY[i].first - XY[j].first), 2) + pow((XY[i].second - XY[j].second), 2));
        }
        dist[i] = tmp;
    }
    double ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            ans += dist[i][j];
        }
    }
    cout << setprecision(12) << ans / N << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
ans=1
Amax=max(A)
yakusu=[[],[]]

for i in range(2):
    for j in range(2,int(A[i]**0.5)+1):
        if A[i]%j==0:
            yakusu[i].append(j)
            yakusu[i].append(A[i]//j)
    yakusu[i].append(A[i])

yakusum=yakusu[0]
yakusum.extend(yakusu[1])
yakusum=sorted(set(yakusum))

for i in yakusum:
    counter=0
    for j in range(N):
        if A[j]%i!=0:
            counter+=1
            if counter==2:
                break
    if counter<=1:
        ans=i
print(ans)


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

int main() {
    int n;
    cin >> n;
    double d;
    cin >> d;
    vector<double> a(n);
    vector<double> b(n);
    int ans = 0;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for (int i = 0; i < n; i++){
        if (sqrt(a[i]*a[i] + b[i] * b[i]) <= d)
            ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6112
#include<iostream>

using namespace std;
int main(){
	int h = 0;
	int w = 0;
	while (1){
		cin >> h >> w;
		if (h == 0 && w == 0){
			break;
		}
		for (int i = 0; i < h; i++){
			for (int it = 0; it < w; it++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    string s,t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    cout << ((s<t)?"Yes":"No") << endl;
}

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

using namespace std;

inline int rem(int n) {
  return n % 100000;
}

int main() {
  for (;;) {
    int w, h, streets[100][100][4];
    cin >> w >> h;
    if (!w && !h) return 0;
    memset(streets, 0, sizeof streets);
    streets[0][0][0] = 1;
    streets[0][0][1] = 0;
    streets[0][0][2] = 1;
    streets[0][0][3] = 0;
    for (int i = 1; i < w; i++) {
      streets[0][i][0] = 1;
      streets[0][i][1] = 0;
      streets[0][i][2] = 0;
      streets[0][i][3] = 1;
    }
    for (int j = 1; j < h; j++) {
      streets[j][0][0] = 0;
      streets[j][0][1] = 1;
      streets[j][0][2] = 1;
      streets[j][0][3] = 0;
    }
    for (int j = 1; j < h; j++)
      for (int i = 1; i < w; i++) {
        streets[j][i][0] = rem(streets[j][i-1][0] + streets[j][i-1][1]);
        streets[j][i][1] = streets[j-1][i][2];
        streets[j][i][2] = rem(streets[j-1][i][2] + streets[j-1][i][3]);
        streets[j][i][3] = streets[j][i-1][0];
      }
    cout << rem(streets[h-1][w-1][0] + streets[h-1][w-1][2]) << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  double a, b, x;
  cin >> a >> b >> x;

  x /= a;

  double t;
  if(x >= a*b/2) t = atan2(2*(a*b-x), a*a);
  else t = atan2(b*b, 2*x);

  printf("%.9f\n", t*180/PI);

  return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
B - Time Limit Exceeded
https://atcoder.jp/contests/abc112/tasks/abc112_b

"""
import sys


def solve(N, T, path):
    ans = []
    for c, t in path:
        if t <= T:
            ans.append(c)
    return sorted(ans)[0] if ans else 'TLE'


def main(args):
    N, T = map(int, input().split())
    path = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, T, path)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include<stdio.h>

int length(char text[]){
  int i=0,count=0;
  while(text[i]!=0){
    count++;
    i++;
  }
  return(count);
}

int main(void){
  char s[100]={},p[100]={};
  int i,j,k;
  scanf("%s %s",s,p);
  for(i=0;i<length(s);i++){
    k = i;
    j = 0;
    while(s[k]==p[j]){
      j++;
      k++;
      if(k>=length(s))k -= length(s);
      if(j==length(p)){
	printf("Yes\n");
	return(0);
      }      
    }
    if(i==length(s)-1)printf("No\n");
  }
  return(0);
}

Measured memory_bytes: 1796
func readIntArray() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

let black: Character = "#"

let line = readIntArray()
let (H, W, K) = (line[0], line[1], line[2])
var c: [[Character]] = []

(0..<H).forEach({_ in c.append(Array(readLine()!))})

var ans = 0

for h in 0..<(1 << H) {
    for w in 0..<(1 << W) {
        var rem = 0
        
        for i in 0..<H {
            if ((h & 1 << i) > 0) {
                continue
            }
            for j in 0..<W {
                if ((w & 1 << j) > 0) {
                    continue
                }
                if (c[i][j] == black) {
                    rem += 1
                }
            }
        }
        
        if rem == K {
            ans += 1
        }
    }
}

print(ans)


Measured memory_bytes: 8232
import numpy as np
n, m = list(map(int, input().split()))
ac = np.zeros(n)
wa = np.zeros(n)
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        ac[p] = 1
    elif not ac[p]:
        wa[p] += 1
print("{} {}".format(np.sum(ac, dtype=np.int64), np.sum(ac * wa, dtype=np.int64)))

Measured memory_bytes: 15400
#include <iostream>

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;

    int count = 0;
    while (true) {
        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1)
            break;
        if (A == B && A == C) {
            std::cout << -1 << std::endl;
            return 0;
        }

        count++;

        int a, b, c;
        a = B / 2 + C / 2;
        b = C / 2 + A / 2;
        c = A / 2 + B / 2;
        A = a;
        B = b;
        C = c;
    }

    std::cout << count << std::endl;

    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define V2(T, x, y) (x, vector<T>(y, 0))
template<typename T> struct Sum2 {
	typedef vector<vector<T>> A;
	A s;
	int X, Y;
	Sum2() { X = Y = -1; }
	Sum2(A & p) { init(p); }
	void init(A & p) {
		X = p.size();
		Y = p[0].size();
		s = A V2(T, X + 1, Y + 1);
		inc1(x, X) { inc1(y, Y) { s[x][y]  = p[x - 1][y - 1]; } }
		inc1(x, X) { inc1(y, Y) { s[x][y] += s[x - 1][y    ]; } }
		inc1(x, X) { inc1(y, Y) { s[x][y] += s[x    ][y - 1]; } }
	}
	T sum(int xl, int xh, int yl, int yh) { // [xl, xh) × [yl, yh)
		assert(inII(xl, 0, X));
		assert(inII(xh, 0, X));
		assert(inII(yl, 0, Y));
		assert(inII(yh, 0, Y));
		assert(xl <= xh);
		assert(yl <= yh);
		return s[xh][yh] - s[xh][yl] - s[xl][yh] + s[xl][yl];
	}
};

// ----

int n, k, l;
vector<vector<int>> p V2(int, 4000, 4000);

int main() {
	cin >> n >> k;
	l = k * 2;
	inc(i, n) {
		int x, y; string c;
		cin >> x >> y >> c;
		if(c == "B") { x += k; }
		x %= l;
		y %= l;
		p[x + 0][y + 0]++;
		p[x + 0][y + l]++;
		p[x + l][y + 0]++;
		p[x + l][y + l]++;
	}
	
	Sum2<int> s(p);
	int ans = 0;
	inc(x, l) {
	inc(y, l) {
		int v =
			s.sum(x + 0, x + k, y + 0, y + k) + 
			s.sum(x + k, x + l, y + k, y + l)
		;
		setmax(ans, v);
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  int n=1;
  if(B==1){
    cout << 0 <<endl;
    return 0;
  }
  while(n*(A-1)+1<B){
    n++;
  }
  cout << n << endl;
}

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

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

using namespace std;

const int SIZE = 1 << 17;
int pointer = SIZE;
char buffer[SIZE];

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int n, sum = 0;
    map<int, int> have;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        have[x]++;
    }
    for (auto &it : have)
        sum ^= it.first;
    if (have.size() > 3) {
        printf("No\n");
        return 0;
    }
    if (have.size() == 3) {
        bool bad = false;
        for (auto &it : have)
            if (it.second != n / 3)
                bad = true;
        if (bad || sum != 0)
            printf("No\n");
        else
            printf("Yes\n");
    }
    else
        if (have.size() == 2) {
            bool bad = false;
            for (auto &it : have)
                if ((it.first == 0 && it.second != n / 3) || (it.first != 0 && it.second != n / 3 * 2))
                    bad = true;
            if (bad)
                printf("No\n");
            else
                printf("Yes\n");
        }
        else
            if (sum == 0)
                printf("Yes\n");
            else
                printf("No\n");
    return 0;
}


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

int left(int i) {
    return i * 2;
}

int right(int i) {
    return i * 2 + 1;
}

void maxHeapify(int A[], int i, int H){
    int l = left(i);
    int r = right(i);
    int largest;
    if (l <= H && A[l] > A[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= H && A[r] > A[largest]) {
        largest = r;
    }
    if (largest != i) {
        int tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(A, largest, H);
    }
}

void buildMaxHeap(int A[], int H){
    for (int i = H / 2; i >= 1; i--) {
        maxHeapify(A, i, H);
    }
}


int main(){
    int H;
    cin >> H;
    int A[H+1];
    int max = -2e9 - 1;
    for (int i = 1; i <= H; i++) {
        cin >> A[i];
        if (A[i] > max) max = A[i];
    }
    buildMaxHeap(A, H);
    for (int i = 1; i <= H; i++) {
        cout << " " << A[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4948
#include <iostream>

using namespace std;

int main(){

  int a,b,c,d;

  while(cin >> a >> b >> c >> d){

    if((a+b)>(c+d)) cout << "Left" <<endl;

    else if((a+b)<(c+d)) cout << "Right" <<endl;

    else cout << "Balanced" <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  if(n%a==0)
     ans=(n/a)*b;
  else
  {
     ans=(n/a+1)*b;
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef struct student{
  int number;
  int order;
}stu;

int cmp_order(const void *x, const void *y) {
  return ((stu *)x)->order - ((stu *)y)->order;
}

int main() {
  int n;
  scanf("%d", &n);
  stu a[n];
  for (int i=0; i<n; i++) {
    scanf("%d", &(a[i].order));
    a[i].number = i+1;
  }
  qsort(a, n, sizeof(stu), cmp_order);
  for (int i=0; i<n; i++) printf("%d ", a[i].number);
  printf("\n");
  return 0;
}


Measured memory_bytes: 1788
n = int(input())
S = input()
ans = 0
for i in range(10):
    first_idx = S.find(str(i))
    if first_idx == -1:
        continue

    for j in range(10):
        second_idx = S.find(str(j), first_idx+1)
        if second_idx == -1:
            continue


        count = [0] * 10
        for k in range(second_idx+1, n):
            num = int(S[k])
            count[num] += 1

        for c in count:
            if c != 0:
                ans += 1

print(ans)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var S = Read().ToList();
            var K = ReadLong();

            for (int i = 0; i < S.Count; i++)
            {
                if (S[i] != '1' && i + 1 <= K)
                {
                    Println(S[i]);
                    return;
                }
            }

            Println(1);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,max=-1;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin >> a.at(i);
    sort(a.begin(),a.end());
    cout << a.back()-a.at(0) << endl;
}


Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/tokiomarine2020/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int bef[202020], cur[202020];

int main(){
    
    // 1. 入力情報.
    int N, K;
    scanf("%d %d", &N, &K);
    rep(i, N) scanf("%d", &bef[i]);
    
    // 2. 各電球の光の強さを計算.
    K = min(41, K);
    rep(k, K){
        // 初期化.
        memset(cur, 0, sizeof(cur));
        
        // k回目の操作.
        rep(i, N){
            int l = max(0,     i - bef[i]);
            int r = min(N - 1, i + bef[i]);
            cur[l]++;
            if(r + 1 < N) cur[r + 1]--;
        }
        
        // 累計和から, 現在の電球の光の強さを計算.
        rep(i, N - 1) cur[i + 1] += cur[i];
        
        // 電球の光の強さを更新.
        rep(i, N)     bef[i] = cur[i];
    }
    
    // 3. 出力.
    rep(i, N){
        if(i == N - 1) printf("%d\n", cur[i]);
        else           printf("%d ",  cur[i]);
    }
    return 0;
    
}

Measured memory_bytes: 5352
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector<vector<lld> > dp(101,vector<lld>(100001,0));
vector<lld> sum(100001,0),sum1(100001,0);
int main()
{
     ios;
    lld n,k;
    cin>>n>>k;
    vector<lld> v(n+1);
    rep(i,1,n)
    cin>>v[i];
    dp[0][0]=1;
    sum[0]=1;
    rep(i,1,k)
    {
        sum[i]=sum[i-1]+dp[0][i];
    }
    rep(i,1,n)
    {
        rep(j,0,k)
        {
            if(j==0)
            {
                dp[i][j]=1;
                sum1[j]=1;
            }
            else
            {
                if(j<=v[i])
                   dp[i][j]=sum[j];
                else
                   dp[i][j]=((sum[j]-sum[j-v[i]-1])%mod+mod)%mod;
                sum1[j]=(sum1[j-1]+dp[i][j])%mod;
            }
        }
        sum=sum1;
    }
    cout<<dp[n][k]<<endl;
    return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vecs vector<string>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll n, k, v=LLONG_MAX;
  cin >> n >> k;
  vecll h(n);
  forll(i, 0, n)
	cin >> h[i];
  sort(h.begin(), h.end());

  forll(i, 0, n-k+1){
	v = min(v, h[i + k -1] - h[i]);
  }
  cout << v << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    cout << (h - a) * (w - b) << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int V,e; cin >> V >> e;
    ll dp[(1<<V)][V];
    rep(i,(1<<V)) rep(j,V) dp[i][j] = INF;
    dp[0][0] = 0;
    ll g[V][V];
    rep(i,V) rep(j,V) g[i][j] = INF;
    rep(i,e){
        int s,t,d; cin >> s >> t >> d;
        g[s][t] = d;
    }
    for(int S = 0; S < (1 << V); S++){
        for(int v = 0; v < V; v++){
            for(int u = 0; u < V; u++){
                if(S & (1<<v)){
                    //もらうDP
                    //S-{v}からSになるときの最小値を更新していく
                    dp[S][v] = min(dp[S][v],dp[S - (1<<v)][u] + g[u][v]);
                }
            }
        }
    }
    if(dp[(1<<V)-1][0] != INF){
        cout << dp[(1<<V)-1][0] << endl;
    }else{
        cout << -1 << endl;
    }
}


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




int main(){
	int n; cin >> n;
	int r[n];
	int maxdiff=-2147483647;

	for (int i=0;i<n;i++){
		cin >> r[i];
	}
	int minv=r[0];
	for (int i=1;i<n;i++){
		maxdiff = max(r[i]-minv,maxdiff);
		minv = min(minv,r[i]);
	}
	cout << maxdiff << endl;
	return 0;
}



Measured memory_bytes: 3900
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
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 dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	string n,x,s;
	cin >> n >> x >> s;
	transform(n.begin(), n.end(), n.begin(), ::toupper);
	transform(x.begin(), x.end(), x.begin(), ::toupper);
	transform(s.begin(), s.end(), s.begin(), ::toupper);
	cout << n[0] << x[0] << s[0] <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
   char c;
   for(int i=0;i<3;i++){
      cin >> c;
      if(c == '1'){
         cout << '9';
      }else if(c == '9'){
         cout << '1';
      }else {
         cout << c;
      }
   }

   cout << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
char a[55][55];
int n,m,ans;
using namespace std;
int bomb(int x,int y){
	ans=0;
	for(int i=x-1;i<=x+1;i++){
		for(int j=y-1;j<=y+1;j++){
			if(i==x&&j==y) continue;
			if(a[i][j]=='#') ans++;
		}
	}
    return ans;
}
int main(){
	cin>>n>>m;;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='.'){
				cout<<bomb(i,j);
			}else{
				cout<<'#';
			}
		}
		cout<<endl;
	}
	return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

long long a[N];
int main() {
  vector<pair<int, int> > ans;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", a+i);
  }
  int mi = 0, ma = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < a[mi]) mi = i;
    if (a[i] > a[ma]) ma = i;
  }
  if (abs(a[mi]) < abs(a[ma]))
    swap(mi, ma);
  for (int i = 0; i < n; i++) {
    long long mul = a[mi] * 1LL * a[i];
    if (mul < 0) {
      a[i] += a[mi];
      ans.emplace_back(mi+1, i+1);
    }
  }
  if (a[mi] >= 0) {
    for (int i = 1; i < n; ++i)
      ans.emplace_back(i, i+1);
  }
  else {
    for (int i = n-1; i > 0; --i)
      ans.emplace_back(i+1, i);
  }
  printf("%d\n", ans.size());
  for (auto it : ans)
    printf("%d %d\n", it.first, it.second);
  return 0;
}

Measured memory_bytes: 384
#B
N=int(input())
a=0
w=0
t=0
r=0

for i in range(N):
    S=input()
    if S=='AC':
        a+=1
    elif S=='WA':
        w+=1
    elif S=='TLE':
        t+=1
    else:
        r+=1
print('AC x %s' %a)
print('WA x %s' %w)
print('TLE x %s' %t)
print('RE x %s' %r)

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

using namespace std;

#define ALL(x) begin(x), end(x)

template <typename T>
T power(T x, int n) {
  T ans{1};
  while (n) {
    if (n % 2) ans *= x;
    x *= x;
    n >>= 1;
  }
  return ans;
}

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

  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));

  for (auto i = 0; i != N; ++i) {
    cin >> C[i];
    for (auto &a : A[i]) {
      cin >> a;
    }
  }

  constexpr int NA =  1<<24;
  int mi = NA;
  int NC = power(2, N);
  int Csum;
  vector<int> Asum(M,0);
  for (auto i = 1; i != NC; ++i) {
    Csum = 0;
    fill(ALL(Asum),0);
    for (auto j = 0; j != N; ++j) {
      if (!((i>>j) & 1)) continue;
      Csum += C[j];
      for (auto m = 0; m != M; ++m) {
        Asum[m] += A[j][m];
      }
    }

    if (all_of(ALL(Asum), [&](int x){ return x >= X;})) {
      mi = min(mi,Csum);
    }
  }

  cout << (mi == NA ? -1 : mi) << endl;
  return 0;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;
  double t,a;cin>>n>>t>>a;
  double h[1005];
  int ok = 1;
  for(int i=1;i<=n;i++){
    cin>>h[i];
    double v1 = t - h[ok] * 0.006;
    double v2 = t - h[i] * 0.006;
    if(abs(a-v1)>=abs(a-v2))ok = i;
  }
  cout<<ok<<endl;

  return 0;
}


Measured memory_bytes: 256
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return map(int, input_tuple)


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    b = input()

    if b == 'A':
        print('T')
    if b == 'T':
        print('A')
    if b == 'C':
        print('G')
    if b == 'G':
        print('C')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=998244353,MAX=1e7+2;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };

int main()
{
    int H, W;
    cin >> H >> W;

    vector<string> s(H);
    for (int i = 0; i < H; ++i) {
        cin >> s[i];
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (s[i][j] == '#') {
                bool ok = false;

                for (int k = 0; k < 4; ++k) {
                    int x = j + dx[k];
                    int y = i + dy[k];

                    if (x < 0 || W <= x || y < 0 || H <= y) {
                        continue;
                    }

                    if (s[y][x] == '#') {
                        ok = true;
                    }
                }

                if (!ok) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3048
X,K,D = map(int, input().split())
X = abs(X)

a = X//D

A = abs(X-D*a)
k = K - a

if k < 0:
  print(X-D*K)
else:
  if k%2 == 0:
    print(A)
  else:
    print(abs(A-D))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010
const ll mod = 1e9 + 7;
int n = read();
ll f[N][5][5][5];
/*
f[i][j][a][b]位置i，字符j,i-1字符a,i-2字符b

*/
map<int,string>mp;
bool check(int a,int b,int c, int d) {
    
    if(mp[a]+mp[c]+mp[b]=="AGC") return 0;
    if(mp[a]+mp[b]+mp[d]=="AGC") return 0;
    if(mp[a]+mp[c]+mp[d]=="AGC") return 0;
    
    if(mp[b]+mp[c]+mp[d]=="AGC") return 0;
    if(mp[b]+mp[d]+mp[c]=="AGC") return 0;
    
    if(mp[c]+mp[b]+mp[d]=="AGC") return 0;
    
    return 1;
}

int main() {
    if(n<=2) return outn(pow(4,n)), 0;
    mp[0]='Q'; mp[1]='A'; mp[2]='C';mp[3]='G';mp[4]='T';
    f[0][0][0][0]=1;
     for(int i = 1; i <= n; ++i) 
        for(int j = 1; j <= 4; ++j) 
            for(int a = 0; a <= 4; ++a) 
                for(int b = 0; b <= 4; ++b) 
                    for(int l = 0; l <= 4; ++l) 
                        if(check(l,b,a,j)) (f[i][j][a][b] += f[i-1][a][b][l]) %= mod;
     ll ans = 0;
     for(int i = 1; i <= 4; ++i) {
        for(int j = 1; j <= 4; ++j) {
            for(int k = 1; k <= 4; ++k) {
                (ans+=f[n][i][j][k])%=mod;
             }
         }
     }
     outn(ans);
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int h[100010],f[100010];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	f[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		f[i]=min(
		f[i-1]+abs(h[i]-h[i-1]),
		f[i-2]+abs(h[i]-h[i-2]));
	}
	printf("%d\n",f[n]);
} 

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N+1)

for i in A:
    B[i] += 1
sum_original = sum([j*(j-1)//2 for j in B])
for k in range(N):
    print(sum_original - B[A[k]] + 1)

Measured memory_bytes: 26140
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

signed main() {
  int k, a, b;
  cin >> k >> a >> b;

  if (b - a <= 2) {
    cout << 1 + k << endl;
  } else {
    int K = k - a + 1;
    cout << max(k + 1, a + K % 2 + K / 2 * (b - a)) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int t = Integer.parseInt(sc.next());
		long time = 0;
		while(n > 0){
			n -= x;
			time += t;
		}
		System.out.println(time);
	}
}


Measured memory_bytes: 35532
#include <iostream>
#include <map>
#include <vector>
#define int long long
typedef long long ll;
using namespace std;

ll N, A, B, C, Len[8], minmp=10000000000;

void dfs(ll id, ll v[8]){
    if(id==N-1) {
        ll abc[4]={0}, abclen[4]={0};
        for(int i=0;i<=id;i++) {
            abc[v[i]]++;
            abclen[v[i]] += Len[i];
        }
        if(abc[1]*abc[2]*abc[3]==0) return;
        ll mp = (abc[1]+abc[2]+abc[3]-3)*10;
        mp += abs(A-abclen[1]) + abs(B-abclen[2]) + abs(C-abclen[3]);
        minmp = min(mp, minmp);
        return;
    }
    v[id+1] = 0;
    dfs(id+1, v);
    v[id+1] = 1;
    dfs(id+1, v);
    v[id+1] = 2;
    dfs(id+1, v);
    v[id+1] = 3;
    dfs(id+1, v);
}

signed main(){
    cin >> N >> A >> B >> C;
    for(int i=0;i<N;i++) cin >> Len[i];
    ll vinit[8]={0};
    dfs(-1, vinit);
    cout << minmp << endl;
    return 0;
}

Measured memory_bytes: 256