akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(int a, int n) {
  vi v;
  rep(i, n) {
    v.pb(a % 10);
    a /= 10;
  }
  vi w = v;
  sort(all(v)), sort(rall(w));
  int t = 0;
  rep(i, n) {
    t += v.back();
    t *= 10;
    v.pop_back();
  }
  int b = 0;
  rep(i, n) {
    b += w.back();
    b *= 10;
    w.pop_back();
  }
  return (t - b) / 10;
}

void solve() {
  int a, n;
  while (cin >> a >> n, n) {
    map<int, int> m;
    int i = 0;
    for (;;) {
      if (m.count(a)) {
        cout << m[a] << ' ' << a << ' ' << i - m[a] << endl;
        break;
      }
      m[a] = i++;
      a    = f(a, n);
      // cout << a << endl;
    }
  }
}

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

using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
int n,m;
bool board[9][9];
map<vector<int> , int> harf;
int finishScore[9];

void dfs(int x, int y, int cnt, VI score) {
  if(cnt == n*(n-1)/4){
    harf[score]++;
    return;
  }
  int nx = x;
  int ny = y+1;
  if(ny >= x) ny = 0, nx++;

  if(board[x][y]) dfs(nx,ny,cnt+1,score);
  else{
    score[x]++;
    dfs(nx,ny,cnt+1,score);
    score[x]--;
    score[y]++;
    dfs(nx,ny,cnt+1,score);
  }
  return;
}

ll ans = 0;

void dfs2(int x, int y, VI score){
  if(x == n && y == 0){
    VI pairScore(n);
    rep(i,n){
      pairScore[i] = (n-1)/2 - score[i] - finishScore[i];
      if(pairScore[i] < 0) return;
    }
    ans += harf[pairScore];
    return;
  }

  int nx = x;
  int ny = y+1;
  if(ny == x) ny = 0, nx++;

  if(board[x][y]) dfs2(nx,ny,score);
  else{
    score[x]++;
    dfs2(nx,ny,score);
    score[x]--;
    score[y]++;
    dfs2(nx,ny,score);
  }
  return;
}


int main(){
  while(true){
    cin >> n;
    if(n == 0) break;

    memset(board,false,sizeof(board));
    memset(finishScore,0,sizeof(finishScore));
    harf.clear();

    cin >> m;
    rep(i,m){
      int x,y;
      cin >> x >> y;
      x--,y--;
      board[x][y] = true;
      board[y][x] = true;
      finishScore[x]++;
    }

    VI score(n,0);
    dfs(1,0,0,score);

    int nx = 1,ny = 0;
    rep(i,n*(n-1)/4){
      ny++;
      if(ny == nx) ny = 0, nx++;
    }

    dfs2(nx,ny,score);

    cout << ans << endl;
    ans = 0;
  }
}



Measured memory_bytes: 5520
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2005;
int n, a[MAXN];
int main () {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + 1); int ans =0;
	for(int i = 2; i <= n; ++i) {
		int k = i;
		for(int j = 1; j < i; ++j) {
			while(k < n && a[k+1] < a[i]+a[j]) ++k;
			ans += k-i;
		}
	}
	printf("%d\n", ans);
}

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

int main()
{
  int N,A,B;
  cin >> N >> A >> B;
  cout << min(N*A,B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define DE cout << "------" << endl
#define mems(a, b) memset(a, (b), sizeof a)
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int maxn = 20007;

char str[maxn];

bool ok[3];

int main(){
	ok[0] = ok[1] = ok[2] = true;
	scanf("%s", str + 1);
	if(str[1] !='A') ok[0] = false;
	int cnt = 0;
	for(int i = 3; i <= strlen(str + 1) - 1; i++) if(str[i] == 'C') cnt++;
	if(cnt != 1) ok[1] = false;
	for(int i = 1; i <= strlen(str + 1); i++){
		if(i != 1 && (str[i] == 'C' && i >= 3 && i <= strlen(str + 1) - 1) == false){
			if((str[i] >= 'a' && str[i] <= 'z') == false) ok[2] = false;
		}
	}
	if(ok[0] == false || ok[1] == false || ok[2] == false) puts("WA");
	else puts("AC");
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{   
    char s,a[5]={'a','e','i','o','u'};
    cin>>s;
    for(int i=0;i<5;i++){
        if(s==a[i]){
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int A,B;
cin>>A>>B;
if(A<10 && B<10){
  cout<<A*B<<"\n";
}
else{
  cout<<-1<<"\n";
}
return 0;
}


Measured memory_bytes: 256
import sys

# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

count = 0
def dfs(graph, v, seen):

    if not False in seen:
        global count
        count += 1
        return

    # 頂点vから行ける頂点を全探索
    for i in graph[v]:
        if seen[i]:
            continue
        seen[i] = True
        dfs(graph, i, seen)
        seen[i] = False
    
    return

# ここから本文
N, M = map(int, input().split())

# グラフ構造を作る
graph = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

seen = [False for i in range(N)]
seen[0] = True
dfs(graph, 0, seen)

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    int cnt[N+1][N+1];
    rep(i,0,N+1)rep(j,0,N+1)cnt[i][j] = 0;
    rep(i,0,M){
        int l,r;
        //cin >> l >> r;
        scanf("%d%d",&l ,&r);
        cnt[l-1][r-1]++;
    }
    rep(i,0,N)rep(j,1,N)cnt[i][j] += cnt[i][j-1];
    rep(j,0,N)for(int i = N-2;i >= 0;i--)cnt[i][j] += cnt[i+1][j];
    rep(i,0,Q){
        int sum = 0;
        int l,r;
        //cin >> l >> r;
        scanf("%d%d",&l ,&r);
        l--,r--;
        cout << cnt[l][r] << endl;
    }
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;



int main() {
    int N; cin >> N;
    ll tmp = 0;
    map<ll, ll> mp;
    rep(i, N) {
        ll a; cin >> a;
        tmp += a;
        mp[tmp] ++;
    }

    ll ans = 0;

    for (auto p : mp) {
        ll x = p.F, y = p.S;
        if (x == 0) ans += y * (y + 1) / 2;
        else ans += y * (y - 1) / 2;
    }

    cout << ans << endl;

}

Measured memory_bytes: 12800
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int x;
        int count = 1;

        while (true){
            x = Integer.parseInt(scan.next());

            if (x == 0)
                break;
            System.out.println("Case " + count + ": " + x);
            count += 1;
        }
    }
}

Measured memory_bytes: 40796
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
#define grade(a) cout << a << endl
using namespace std;

int main(){
    int i, S=0;
    char s[1005];
    while(1){
        fgets(s,1005,stdin);
        if(s[0] == '0')break;
        int l = strlen(s)-1;
        s[l] = '\0';
        rep(i,l) S += s[i] - '0';
        cout << S << endl;
        S = 0;
    }
    
    return 0;
}


Measured memory_bytes: 3092
import sys


def solve(obstacles):
    offset = 0
    obstacles.sort()
    for x, y in obstacles:
        if x > y + offset:
            return x - 1
        if x == y + offset:
            offset += 1
    return h


h, w, n = map(int, input().split())
obstacles = [tuple(map(int, line.split())) for line in sys.stdin.readlines()]
print(solve(obstacles))


Measured memory_bytes: 44324
#include <stdio.h>
#include <string.h>

int main(){
  char a[80];
  int b,c,d;
  while(NULL!=fgets(a,80,stdin)){
    b=strlen(a);
    for(c=0;c<26;c++){
      for(d=0;d<b;d++)
        if(a[d]>='a' && a[d]<='z') a[d]=(a[d]-'a'+1)%26+'a';
      if(strstr(a,"this") || strstr(a,"that") || strstr(a,"the")) break;
    }
    printf("%s",a);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include<cstring>
#include<tuple>


#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//SOUND HOUND C
int main(void) {
	long double n, m, d;
	cin >> n >> m >> d;
	long double prob = d == 0 ? 1 / n : 2*(n-d) / (n*n);
	cout << fixed << setprecision(10) << prob * (m - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    string S;
    cin>>S;
    if(N%2==1){cout<<"No"<<endl;exit(0);}
    REP(i,N/2){
        if(S[i]!=S[i+N/2]){cout<<"No"<<endl;exit(0);}
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

	char s[101];

int main(void) {
	scanf("%s", s);
	int n = strlen(s);
	int l = 0;

	for (int i = 0;i < n;i++) {
		if (s[i]!=s[n-1-i])
		{
			l++;
		}
	}

	printf("%d", l / 2);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
L = list(map(int, input().split()))
L.append(-1)
L.append(-2)
i =0
j = 0
k = 0
x = 0
for i in range(0,len(L)-2):
  j = i
  k = i
  while not L[1 + j] == -1:
    while not L[2 + k] == -2:
      a,b,c = (L[0+i],L[1+j],L[2+k])
      if not (a == b or a == c or b == c):
        if a+b>c and b+c>a and c+a>b:
          x += 1
      k += 1
    j += 1
    k = j

print(x)

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

int main(){
    string s;
    cin >> s;
    deque<string> deq;
    int q;
    cin >> q;
    int a[q],b[q];
    char c[q];
    bool z=true;
    deq.push_back(s);

    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));

    rep(i,q){
        scanf("%d",&a[i]);
        if(a[i]==1){
            z=!z;
            continue;
        }
        scanf("%d %c",&b[i],&c[i]);
        if(z){
            if(b[i]==1) deq.push_front(string{c[i]});
            else deq.push_back(string{c[i]});
        }
        else{
            if(b[i]==1) deq.push_back(string{c[i]});
            else deq.push_front(string{c[i]});
        }
    }
    string ans="";
    
    rep(i,deq.size()){
        ans+=deq[i];
    }
    if(!z) reverse(ans.begin(),ans.end());
    
    cout << ans << endl;
}

Measured memory_bytes: 13792
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = std::numeric_limits<T>::max() / 10;
std::mt19937 mt{std::random_device{}()};
int main()
{
    ll x, p;
    std::cin >> x >> p;
    if (x == 0) { return std::cout << 0 << std::endl, 0; }
    std::cout << std::fixed << std::setprecision(15) << (x % 2 == 0 ? 50.0 * x / p : 50.0 * (1 + x) / p) << std::endl;
    return 0;
}


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

int main()
{
	int n; cin >> n;
	int a[3*n];
	for (int i = 0; i < 3*n; ++i)
		cin >> a[i];
	sort(a, a+3*n);
	ll ans = 0;
	int m = 0;
	for (int i = 3*n-2; m < n; i -= 2, m++) ans += a[i];
	cout << ans << endl;
}



Measured memory_bytes: 4776
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

int ans[100005], N;
int A[100005];


int main(void) {
    scanf("%d", &N);
    rep(i, 1, N+1) scanf("%d", &A[i]);
    
    rep(i, 1, N+1) {
      if (i%2==1) ans[1] += A[i];
      else ans[1] -= A[i];
    }
    rep(i, 2, N+1) {
      ans[i] = 2*A[i-1] - ans[i-1];
    
    }
    rep(i, 1, N+1) {
      if (i > 1) printf(" ");
      
      printf("%d", ans[i]);
    
    }
    printf("\n");

	return 0;
}


Measured memory_bytes: 2048
a=input()
ct1=0
ct2=0
for i in range(len(a)):
    if (i+1)%2==0:
        if a[i]!='0':
            ct1+=1
        else:
            ct2+=1
    else:
        if a[i]=='0':
            ct1+=1
        else:
            ct2+=1
if ct1>ct2:
    print(ct2)
else:
    print(ct1)

Measured memory_bytes: 3188
dish = []
ans = 0
for _ in range(5):
    cost = int(input())
    rest = 10 - cost % 10
    if rest == 10:
        rest = 0
    dish.append((rest, cost))

dish.sort()
for r, c in dish:
    ans += r + c
print(ans-dish[4][0])


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

signed main() {
	int n, c, k;
	scanf("%d %d %d", &n, &c, &k);
	int nh = 0,cur,ans = 0,cc = 0;
	vector<int> num(n);
	REP(i, n) {
		scanf("%d", &cur);
		num[i] = cur;
	}
	sort(ALL(num));
	REP(i,n){
		cur = num[i];
		cc++;
		if (nh < cur || cc == c) {
			ans++;
			nh = cur + k;
			cc = 0;
		}
	}
	printf("%d\n" , ans);
	return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b < a) swap(a, b);
    if (a < c && c < b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll n; cin >> n;
    vector<ll> v(n);ll ans=0;
    for(int i =0;i<n;i++){
        cin >> v[i];
        ans ^= v[i];
    }
    
    for(int i =0;i<n;i++){
        ll res = ans^v[i];
        cout << res << " ";
    }


}

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

int main() {
	int n, k;
	cin >> n >> k;
	priority_queue<pair<int, int>> pq;
	for(int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		pq.push({x, 0});
	}
	while(k--) {
		pair<int, int> cur = pq.top();
		if(cur.first == 0)
			break;
		pq.pop();
		pq.push({cur.first / 2, cur.second + 1});
	}
	long long answer = 0;
	while(!pq.empty()) {
		answer += pq.top().first;
		pq.pop();
	}
	cout << answer;
}


Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  string s,t;
  cin >> s >> t;
  ll n=s.size();
  ll m=t.size();
  mat dp(n+1,vec(m+1));
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<m;j++) {
      dp[i+1][j+1]=max({dp[i+1][j+1],dp[i][j+1],dp[i+1][j]});
      if(s[i]==t[j]) dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
    }
  }
  string ans="";
  while(n>0&&m>0) {
    if(dp[n][m]==dp[n-1][m]) {
      n--;
    }
    else if(dp[n][m]==dp[n][m-1]) {
      m--;
    }
    else {
      n--;
      m--;
      ans=s[n]+ans;
    }
  }
  cout << ans << endl;
}

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

int d[50][50];
int o[3][50]; //色別の出現回数

int main(){
    int n,c; cin >> n >> c;
    for(int i=1;i<=c;i++){
        for(int j=1;j<=c;j++){
            cin >> d[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int col; cin >> col;
            o[(i+j)%3][col]++;
        }
    }
    int ans=1e9;
    for(int c1=1;c1<=c;c1++){
        for(int c2=1;c2<=c;c2++){
            for(int c3=1;c3<=c;c3++){
                if(c1==c2 || c2==c3 || c3==c1) continue;
                int cost=0;
                for(int i=1;i<=c;i++){
                    cost+=o[0][i]*d[i][c1];
                    cost+=o[1][i]*d[i][c2];
                    cost+=o[2][i]*d[i][c3];
                }
                ans=min(ans,cost);
            }
        } 
    }

    cout << ans << endl;    
}

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

const int N = 2020, M = N * N, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if(a < 0)
		a += MOD;
	else if(a >= MOD)
		a -= MOD;
	return a;
}

void _sum(int &a, int b) {
	a = sum(a, b);
}

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

void _mul(int &a, int b) {
	a = mul(a, b);
}

int power(int a, int b) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int n, k, dp[N], fac[M], pow_fac[M];

int f(int a) {
	return power(a, MOD - 2);
}

int choose(int a, int b) {
	return (a > b? 0: mul(fac[b], mul(pow_fac[a], pow_fac[b - a])));
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	fac[0] = 1;
	for (int i = 1; i < M; i++)
		fac[i] = mul(fac[i - 1], i);
	for (int i = 0; i < M; i++)
		pow_fac[i] = f(fac[i]);
	cin >> n >> k;
	if(k == 1) {
		cout << 1;
		return 0;
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			int val = choose(j, i);
			_mul(val, choose(j * k - j, i * k - j));
			_mul(val, mul(fac[j * (k - 1)], f(power(fac[k - 1], j))));
			_mul(val, dp[i - j]);
			dp[i] = sum(dp[i], (j & 1? 1: -1) * val);
		}
	}
	cout << dp[n];
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b,c;cin>>a>>b>>c;
    if(b-a==c-b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
import Control.Applicative
main :: IO ()
main = do  
 argsList <- words <$> getLine
 let a = argsList !! 0
     b = argsList !! 1
     area = read a * read b :: Int 
     perimeter = read a * 2 + read b * 2 :: Int
     showStr = show area ++ " " ++ show perimeter
 putStrLn showStr 


Measured memory_bytes: 3592
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];

	int ans = 0, st = 0, minh = 0;
	while (minh != INF) {

		st = 0;
		minh = h[0] > 0 ? h[0] : INF;

		if (N == 1) {
			ans = h[0];
			break;
		}

		for (int i = 1; i < N; i++) {

			minh = (h[i] > 0) && h[i] < minh ? h[i] : minh;

			if (h[i - 1] > 0 && h[i] <= 0 || (i == N - 1) && h[N - 1] > 0 ) {

				for (int j = st; j <= i; j++) h[j] -= minh;

				ans += minh;
				st = i;
				minh = INF - 1;

			}

		}

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
n,k=IL()
top=dict()
sub=[]
for i in range(n):
    t,d=IL()
    if t in top:
        sub.append(min(top[t],d))
        top[t]=max(top[t],d)
    else:
        top[t]=d

top=sorted(top.items(),key=lambda x:-x[1])
sub.sort(reverse=True)

rtop=[top[0][1]]
rsub=[0]
for i in range(1,len(top)):
    rtop.append(rtop[-1]+top[i][1])
for i in range(len(sub)):
    rsub.append(rsub[-1]+sub[i])

ans=0
for i in range(k):
    if i<len(rtop) and 0<=k-i-1<len(rsub):
        ans=max(ans,rtop[i]+rsub[k-i-1]+(i+1)**2)
print(ans)

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

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  int P[4]={0};
  P[1]=W;
  P[3]=H;
  
  for(int i=0 ; i<N ; i++){
    int X, Y, T;
    cin >> X >> Y >> T;
    switch(T){
      case 1:
        P[0]=max(X, P[0]);
        break;
      case 2:
        P[1]=min(X, P[1]);
        break;
      case 3:
        P[2]=max(Y, P[2]);
        break;
      case 4:
        P[3]=min(Y, P[3]);
        break;
    }
  }
  
  if(P[0]<=P[1] && P[2]<=P[3])
    cout << (P[0]-P[1])*(P[2]-P[3]) << endl;
  else
    cout << "0" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll N, K;
ll R, S, P;
string T;

ll best(string s) {
    vvll dp(s.size(), vll(3, -1));
    dp[0][0] = s[0] == 'r' ? P : 0;
    dp[0][1] = s[0] == 's' ? R : 0;
    dp[0][2] = s[0] == 'p' ? S : 0;

    reprr(i, 1, s.size()) {
        dp[i][0] = (s[i] == 'r' ? P : 0) + max(dp[i-1][1], dp[i-1][2]); 
        dp[i][1] = (s[i] == 's' ? R : 0) + max(dp[i-1][0], dp[i-1][2]); 
        dp[i][2] = (s[i] == 'p' ? S : 0) + max(dp[i-1][0], dp[i-1][1]); 
    }

    return max(dp[s.size()-1][0], max(dp[s.size()-1][1], dp[s.size()-1][2]));
}

int main()
{
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    vector<string> ss;
    rep(i, K) {
        string s = "";
        ll j = i;
        while (j < N) {
            s.push_back(T[j]);
            j += K;
        }
        //cout << s << endl;
        ss.push_back(s);
    }

    ll total = 0;
    for (auto s : ss) {
        total += best(s);
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define N (int)4e5
typedef long long ll;
vector<ll> v;
ll maxim[N],minim[N],n;

void preCompute() {
    priority_queue<ll> pQ;
    ll sum = 0;
    for (int i = (3 * n) - 1 ; i >= 0 ; i--) {
        pQ.push(v[i]);
        sum += v[i];
        if ((int)pQ.size() > n) {
            sum -= pQ.top();
            pQ.pop();
        }
        minim[i] = sum;
    }
    while (!pQ.empty()) pQ.pop();
    sum = 0;
    for (int i = 0 ; i < 3 * n ; i++) {
        pQ.push(-v[i]);
        sum += v[i];
        if ((int)pQ.size() > n) {
            sum += pQ.top();
            pQ.pop();
        }
        maxim[i] = sum;
    }
}

int main() {
    scanf("%lld" , &n);
    v.resize(3 * n);
    for (int i = 0 ; i < 3 * n ; i++)
        scanf("%lld" , &v[i]);
    preCompute();
    ll sol = LLONG_MIN;
    for (int i = n - 1 ; i < (2 * n) ; i++)
        sol = max(sol , maxim[i] - minim[i + 1]);
    printf("%lld\n" , sol);
}


Measured memory_bytes: 9588
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

if a<40:
    a=40
if b<40:
    b=40
if c<40:
    c=40
if d<40:
    d=40
if e<40:
    e=40
print((a+b+c+d+e)//5)


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a[3], k;
	cin >>a[0] >>a[1] >>a[2] >>k;
	ll ans = 0;
	VI pt ={1, 0, -1};
	rep(i, 3){
		int z = min(a[i], k);
		ans += z* pt[i];
		k-= z;
		if(k<=0) break;
	}
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 3624
import std.stdio, std.algorithm, std.conv, std.array, std.string;

long N = 10^^9 + 7;

void main()
{
    auto n = readln.chomp.to!int;
    auto as = readln.split.to!(long[]).sort();

    if (n == 1) {
        writeln(as[0] == 0 ? "1" : "0");
        return;
    }

    if (n&1) as = as[1..$];

    for (size_t i = 0; i < n-1; ++i) {
        if (as[i] != as[++i]) {
            writeln("0");
            return;
        }
    }

    long fact(long n) {
        if (n == 1) {
            return 2;
        } else if (n&1) {
            return 2 * fact(n/2) * fact(n/2) % N;
        } else {
            return fact(n/2) * fact(n/2) % N;
        }
    }
    writeln(fact(n / 2));
}

Measured memory_bytes: 4412
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////
int ans[1000][1000];
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m;
	cin>>n>>m;
	int k;
	cin>>k;
	map<int,int> r,c;
	set<pair<int,int>> bo;
	for(int i=0;i<k;++i){
		int x,y;
		cin>>x>>y;
		r[x]++;
		c[y]++;
		bo.insert({x,y});
	}
	vector<int> rn,cn;
	rn.push_back(1);
	cn.push_back(1);
	for(auto rr:r){
		if(rr.S>r[rn[0]]){
			rn.clear();
			rn.push_back(rr.F);
		}
		else{
			if(rr.S==r[rn[0]]){
				rn.push_back(rr.F);
			}
		}
	}
	for(auto rr:c){
		if(rr.S>c[cn[0]]){
			cn.clear();
			cn.push_back(rr.F);
		}
		else{
			if(rr.S==c[cn[0]]){
				cn.push_back(rr.F);
			}
		}
	}
	int ans=r[rn[0]]+c[cn[0]]-1;
	if(c.size()==1){
		if(r.size()<n)
			ans=k;
	}
	if(r.size()==1){
		if(c.size()<m)
			ans=k;
	}
	int fl=0;
	for(auto row:rn){
		for(auto col:cn){
			if(fl==0&&bo.find({row,col})==bo.end()){
				ans=r[rn[0]]+c[cn[0]];
				fl=1;
			}
			if(fl==1)
				break;
		}
		if(fl==1)
			break;
	}
	cout<<ans;
	#ifdef ANIKET_GOYAL
		// cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n+1);
  vector<bool>ball(n+1);
  for(int i=1;i<=n;i++) cin>>a[i];
  int m=0;
  vector<int>b;
  for(int i=n;i>=1;i--){
    int j=2;
    int now=0;
    while(i*j<=n){
      if(ball[i*j]) now++;
      j++;
    }
    if(now%2!=a[i]){
      m++;
      b.push_back(i);
      ball[i]=true;
    }
  }
  cout<<m<<endl;
  for(int i=0;i<m;i++) cout<<b[i]<<" ";
}


Measured memory_bytes: 4660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll ans = 0;
  rep(i, N - 1) {
    ll dst = A[i] - A[i + 1];
    if (dst > 0) {
      A[i + 1] += dst;
      ans += dst;
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

string input(){
  string a;
  cin >> a;
  return a;
}

vi sub(vector<bool> fin,ll n) {
  vi ret;
  REP(i,n) {
    if(fin.at(i))continue;
    vector<bool> cp = fin;
    cp.at(i) = true;
    vi result = sub(cp,n);
    ret.insert(ret.end(),result.begin(),result.end());
  }
  return ret;
}

int main() {
  ll n;
  cin >> n;
  map<string,ll> sallay;
  REP(i,n){
    string str;
    cin >> str;
    if( sallay.find(str) != sallay.end()) sallay[str]++;
    else sallay[str] = 1;
  }

  vector<pair<ll,string>> p;
  for ( auto iter : sallay ) {
    p.push_back({-(iter.second), iter.first});
  }
  
  sort(p.begin(),p.end());
  ll Num = p.at(0).first;
  REP(i,p.size()){
    if(p.at(i).first != Num) break;
    cout << p.at(i).second << endl;
  }
}


Measured memory_bytes: 28912
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var Ci = Sarray();
            Array.Sort(Ci);

            var cf = modpow(2, N, Mod);
            var sum = 0L;
            for (var i = 0; i < N; ++i)
            {
                var k = N - 1 - i;
                var t1 = Ci[i] * modpow(2, i, Mod) % Mod;
                var t2 = (k * modpow(2, k - 1, Mod) % Mod + modpow(2, k, Mod)) % Mod;
                sum = (sum + t1 * t2 % Mod) % Mod;
            }
            var ans = cf * sum % Mod;
            WriteLine(ans);
        }
        static long modpow(long a, long n, long mod)
        {
            var res = 1L;
            while (0 < n)
            {
                if (n % 2 != 0) res = res * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return res;
        }

    }
}

Measured memory_bytes: 47624
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 1000010
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll nq[MAXN],inv[MAXN];
ll fsp(ll x,int y){
    ll res=1;
    while(y){
        if(y&1) res=(res*x)%MOD;
        x=(x*x)%MOD;
        y>>=1;
    }
    return res;
}
ll C(int n,int m){
    if(n<m)
        return 0;
    return nq[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int n,k;
ll ans;
int main(){
    SF("%d",&n);
    nq[0]=1;
    for(int i=1;i<=n;i++)
        nq[i]=(nq[i-1]*i)%MOD;
    inv[n]=fsp(nq[n],MOD-2);
    for(int i=n;i>0;i--)
        inv[i-1]=(inv[i]*i)%MOD;
    ll las=0;
    for(int i=(n+1)/2;i<n;i++){
        ll num=C(i-1,n-i-1)*nq[i]%MOD*nq[n-i-1]%MOD;
        ll sum=(num-las+MOD)%MOD;
        ans=(ans+sum*i%MOD)%MOD;
        las=num;
    }
    PF("%lld",ans);
}


Measured memory_bytes: 15744
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;
graph g;

ll n,m,rr;
Vi r;

matrix warshall_floyd(graph _g){
    matrix dis(_g.size()+1,vector<ll>(_g.size()+1,INF));
    rep(i,dis.size())dis[i][i]=0;
    rep(i,_g.size()){
        rep(j,_g[i].size()){
            edge e = _g[i][j];
            dis[i][e.to] = e.cost;
        }
    }
    rep(i,_g.size()){
        rep(j,_g.size()){
            rep(k,_g.size()){
                chmin(dis[j][k],dis[j][i]+dis[i][k]);
            }
        }
    }
    return dis;
}

ll dp[1<<8][8];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>m>>rr;
    r.resize(rr);
    g.resize(n+1);
    ll aa,bb,cc;
    rep(i,rr){
        cin>>r[i];
    }
    rep(i,m){
        cin>>aa>>bb>>cc;
        g[aa].pb(edge(bb,cc));
        g[bb].pb(edge(aa,cc));
    }
    matrix dis = warshall_floyd(g);
    rep(i,1<<8){
        rep(j,8){
            dp[i][j] = INF;
        }
    }
    rep(i,rr){
        dp[1<<i][i] = 0;
    }
    rep(bt,1<<rr){
        rep(j,rr){
            if(!(bt & (1<<j)))continue;
            rep(k,rr){
                if(bt & (1<<k))continue;
                chmin(dp[bt|(1<<k)][k],dp[bt][j]+dis[r[j]][r[k]]);
            }
        }
    }
    ll ans = INF;
    rep(i,rr){
        chmin(ans,dp[(1<<rr)-1][i]);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 1408
#__author__ = "tatuo"
#__date__ = "$Mar 3, 2018 12:34:20 PM$"

import math
import re
import sys


def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result




arr_data = getinputdata()

a=int(arr_data[0][0])
b=int(arr_data[0][1])
c=int(arr_data[0][2])

if(a+b>=c):
    
    print("Yes")
    
else:
    
    print("No")


Measured memory_bytes: 3316
#define _DEBUG
#include "bits/stdc++.h"
#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int K;
    scan(K);
    rep(i,K){
        printf("%s","ACL");
    }
    kaigyo;
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <limits>

#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template <class T>
ostream &operator<<(ostream &os, vector<T> const &vec)
{
    if (vec.empty())
    {
        os << "{}";
    }
    else
    {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++)
            os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream &operator<<(ostream &os, array<T, S> const &arr)
{
    if (arr.empty())
    {
        os << "{}";
    }
    else
    {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++)
            os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

template <class T, class U>
ostream &operator<<(ostream &os, pair<T, U> const &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

namespace math
{
ll gcd(ll u, ll v)
{
    while (v != 0)
    {
        ll r = u % v;
        u = v;
        v = r;
    }
    return u;
}
ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;

    return ((m / math::gcd(m, n)) * n);
}

ull gcd(ull u, ull v)
{
    while (v != 0)
    {
        ull r = u % v;
        u = v;
        v = r;
    }
    return u;
}
ull lcm(ull m, ull n)
{
    if ((0 == m) || (0 == n))
        return 0;

    return ((m / math::gcd(m, n)) * n);
}
} // namespace math

int main(void)
{
    int N, A, B;
    cin >> N >> A >> B;

    vector<int> P(N);
    for (int i = 0; i < N; i++)
        cin >> P[i];
    
    array<int, 3> count = {0, 0, 0};
    for(int i = 0; i < N; i++){
        if(P[i] <= A)
            count[0]++;
        else if(P[i] <= B)
            count[1]++;
        else
            count[2]++;
    }

    cout << min({count[0], count[1], count[2]}) << endl;

    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int l = 0;
        int r = (s.length() / 2) - 1;
        for (int i = l; i <= r / 2 - 1; i++) {
            if (s.charAt(i) != s.charAt(r)) {
                System.out.println("No");
                return;
            }
            r--;
        }
        l = s.length() / 2 + 1;
        r = s.length() - 1;
        for (int i = l; i <= l + s.length() / 4; i++) {
            if (s.charAt(i) != s.charAt(r)) {
                System.out.println("No");
                return;
            }
            r--;
        }
        l = 0;
        r = s.length() - 1;
        for (int i = 0; i <= s.length() / 2 - 1; i++) {
            if (s.charAt(i) != s.charAt(r)) {
                System.out.println("No");
                return;
            }
            r--;
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 23764
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i
k = gets.chomp.to_i

[a,b,c,d,e].each do |p|
  [a,b,c,d,e].each do |q|
    if q - p > k then
      puts ":("
     exit
    end
  end
end

puts "Yay!"


Measured memory_bytes: 1788
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println(new HashSet<>(Arrays.asList(in.nextInt(), in.nextInt(), in.nextInt())).size());
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl "\n"
#define sp " "
#define int long long

int32_t main()
{
	FastIO ;
	int n,k;
	cin>>n>>k;
	int x=n/k;
	int y=x+1;
	x*=k;
	y*=k;
	int ans=min(abs(x-n),abs(y-n));
	cout<<ans<<nl;
	return 0 ;
}


Measured memory_bytes: 3580