akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int n ,amin ,amax;

	cin >> n;

	int a[n];

	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		if(i == 0){
			amax = a[i];
			amin = a[i];
		}
		else{
			if( amax <= a[i] ){
				amax = a[i];
			}
			else if( amin >= a[i] ){
				amin = a[i];
			}
		}

	}

	cout << amax - amin <<endl;

	return 0;
}

Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector <string> v;
    map <string, int> mp;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
        mx = max(mx, mp[s]);
    }
    for (auto it : mp) {
        if (it.second == mx) {
            cout << it.first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 23808
import sys
input = sys.stdin.readline

n = int(input())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append([b, a])

ab.sort()

time = 0

for b, a in ab:
    time += a
    if b < time:
        print('No')
        exit()
    
print('Yes')



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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll dp[1005][1005];

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll H, W;
  scanf("%lld %lld", &H, &W);

  vector<string> lines;
  for (ll i = 0; i < H; i++) {
    string s;
    cin >> s;

    lines.emplace_back(s);
  }

  dp[0][0] = 1;

  for (ll y = 0; y < H; y++) {
    for (ll x = 0; x < W; x++) {
      if (y + 1 < H && lines[y + 1][x] == '.') {
        dp[y + 1][x] += dp[y][x];
        dp[y + 1][x] %= MOD;
        // cout << y + 1 << " " << x << " " << dp[y + 1][x] << endl;
      }
      if (x + 1 < W && lines[y][x + 1] == '.') {
        dp[y][x + 1] += dp[y][x];
        dp[y][x + 1] %= MOD;
        // cout << y << " " << x + 1 << " " << dp[y][x + 1] << endl;
      }
    }
  }

  /*
    for (;;) {
      pair<ll, ll> c = q.front();
      q.pop();

      cout << c.first << " " << c.second << endl;

      bool can_v = false;
      if (c.first + 1 < H && lines[c.first + 1][c.second] == '.') {
        can_v = true;
      }

      bool can_h = false;
      if (c.second + 1 < W && lines[c.first][c.second + 1] == '.') {
        can_h = true;
      }

      if (can_v && can_h) {
        q.push(make_pair(c.first + 1, c.second));
        q.push(make_pair(c.first, c.second + 1));
        dp[c.first + 1][c.second] = dp[c.first][c.second] + 1;
        dp[c.first][c.second + 1] = dp[c.first][c.second] + 1;
      } else if (can_v) {
        q.push(make_pair(c.first + 1, c.second));
        if (dp[c.first + 1][c.second] == 0) {

        }
        dp[c.first + 1][c.second] = dp[c.first][c.second];
      } else if (can_h) {
        q.push(make_pair(c.first, c.second + 1));
        dp[c.first][c.second + 1] = dp[c.first][c.second];
      }
    }
    */
  cout << dp[H - 1][W - 1] << endl;
}


Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long A, long long B){
  op(max(max(A*B,A+B),A-B))
  return;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    double r;
    cin >> r;
    cout << setprecision(18) << r * M_PI * 2.0 << endl;

    return 0;
}

Measured memory_bytes: 3788
n=int(input())
po=[]
for i in range(n):
    a,b=map(int,input().split())
    po.append([a,b])

ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans+=((po[i][0]-po[j][0])**2+(po[i][1]-po[j][1])**2)**0.5

    
print(ans*2/n)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int main(){
    int N, L;
    cin >> N >> L;
    int res = 0;
    for(int i=0;i<N;i++){
      res += L + i;
    }
    cerr << res << endl;
    if(L < 0 && L + N - 1 > 0){
      cout << res << endl;
    }
    else{
      if(abs(L) < abs(L + N - 1)){
        cout << res - L << endl;
      }else{
        cout << res - (L + N - 1) << endl;
      }
    }
    return 0;
}


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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

class Point{
public:
	int x,y;

	Point(int tx,int ty){
		x = tx;
		y = ty;
	}
};

int w,h;
int t[52][52];
int dx[] = {-1,0,1,-1,1,-1,0,1};
int dy[] = {-1,-1,-1,0,0,1,1,1};

int solve(void){
	int res = 0;

	rep(i,h) rep(j,w) if(t[i][j] == 1) {
		res++;
		deque<Point> stack;
		stack.push_back(Point(j,i));

		while(!stack.empty()){
			Point p = stack.back(); stack.pop_back();
			t[p.y][p.x] = 0;

			rep(k,8){
				int nx = p.x + dx[k];
				int ny = p.y + dy[k];

				if(nx>=0 && nx<w && ny>=0 && ny<h && t[ny][nx]==1){
					stack.push_back(Point(nx,ny));
				}
			}
		}
	}

	return res;
}

int main(void){
	while(cin>>w>>h && (w||h)){
		rep(i,h) rep(j,w) cin>>t[i][j];
		cout<<solve()<<endl;
	}


	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    X = [list(map(int,input().split())) for _ in range(N)]

    ans = 0
    for i in range(2**3):
        m = [0 for _ in range(N)]
        for j in range(3):
            for k in range(N):
                    m[k] += X[k][j]*((-2)*((i>>j)&1)+1)
        m.sort(reverse=True)
        point = 0
        for l in range(M):
            point += m[l]
        ans = max(ans,point)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // boolean flag = false;
        int[] a = new int[3 * 3];

        // String s = sc.next();
        // int cnt = 1;

        for (int i = 0; i < 9; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        int n = Integer.parseInt(sc.next());
        int[] b = new int[n];

        for (int i = 0; i < n; i++) {
            b[i] = Integer.parseInt(sc.next());
            for (int j = 0; j < 9; j++) {
                if (b[i] == a[j]) {
                    a[j] = 0;
                    break;
                }
            }
        }

        if ((a[0] == 0 && a[1] == 0 && a[2] == 0) || (a[3] == 0 && a[4] == 0 && a[5] == 0)
                || (a[6] == 0 && a[7] == 0 && a[8] == 0) || (a[0] == 0 && a[3] == 0 && a[6] == 0)
                || (a[1] == 0 && a[4] == 0 && a[7] == 0) || (a[2] == 0 && a[5] == 0 && a[8] == 0)
                || (a[0] == 0 && a[4] == 0 && a[8] == 0) || (a[2] == 0 && a[4] == 0 && a[6] == 0)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
}

Measured memory_bytes: 23764
H,W,M=map(int,input().split())
HW=[tuple(map(int,input().split()))for i in range(M)]
HW=[(h-1,w-1)for h,w in HW]
st=set(HW)
countH=[0]*H
countW=[0]*W
for h,w in HW:
    countH[h]+=1
    countW[w]+=1
maxH=max(countH)
maxW=max(countW)
candiH=[]
candiW=[]
for i in range(H):
    if maxH==countH[i]:
        candiH.append(i)
for i in range(W):
    if maxW==countW[i]:
        candiW.append(i)
count=0
ans=maxH+maxW-1
add=0
for i in candiH:
    for j in candiW:
        if (i,j) not in st:
            add=1
        if count>300000:
            break
        count+=1
print(ans+add)

Measured memory_bytes: 225432
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############

A,B = inputIL()

print(lcm(A,B))

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

ll f(ll b, ll n) {
	ll ans = 0;
	while (n) {
		ans += n % b;
		n /= b;
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, s;
	cin >> n >> s;
	if (s > n) {
		cout << "-1\n";
		return 0;
	}
	if (s == n) {
		cout << n + 1 << '\n';
		return 0;
	}
	for (ll i = 2; i * i <= n; ++i)
		if (f(i, n) == s) {
			cout << i << '\n';
			return 0;
		}
	vector<ll> b;
	for (ll i = 1; i * i <= n - s; ++i)
		if ((n - s) % i == 0)
			b.eb(i);
	for (ll i : b)
		if (f(i + 1, n) == s) {
			cout << i + 1 << '\n';
			return 0;
		}
	reverse(all(b));
	for (ll i : b)
		if (f((n - s) / i + 1, n) == s) {
			cout << (n - s) / i + 1 << '\n';
			return 0;
		}
	cout << "-1\n";
	return 0;
}


Measured memory_bytes: 256
import numpy as np
from collections import Counter
n, k, q = list(map(int, input().split()))
A = Counter([int(input()) for i in range(q)])
points = (np.ones(n) * k) - q
for k, v in A.items():
  points[k-1] += v
for p in points:
  if p > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 21336
//
//  main.cpp
//  ITP1_10-B
//
//  Created by Saicj on 2015/08/05.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

#define PI 3.1415926

int main(int argc, const char * argv[]) {

    
    double a,b,C;
    
    cin >> a >> b >> C;
    
    /**
     *  ??¢?§????(???/???)?????????sin??
     ??¨??? a^2 + b^2 -2ab*cosC = c^2
     a + b + c
     
     
     */
    
    
    double rad = C * M_PI / 180.0;
    
    double area = (a * b)/2 * sin(rad);
    
    double c = sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(rad)));
    
    double perimeter = a + b + c;
    
    double h = (area * 2) / a;
    
    printf("%.4lf %.4lf %.4lf \n", area, perimeter, h);
    
    
    return 0;
}

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

int n, m, t;
int a[100];

int main() {
	int i;
	
	cin >> n >> m >> t;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int ans = a[0] - m;
	for (i = 1; i < n; i++) {
		ans += max(0, a[i] - a[i - 1] - 2 * m);
	}
	ans += max(0, t - a[n - 1] - m);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3120
# 2020-05-28 22:45:55

import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
ab = [list(map(int,input().split())) for _ in range (N-1)]

edge = [[] for _ in range(N)]
for u,v in ab:
    edge[u-1].append(v-1)
    edge[v-1].append(u-1)

fromNode = [0] * N
def dfs(v, p):
    for nv in edge[v]:
        if nv==p:continue 
        fromNode[nv] = v
        dfs(nv, v)
    return 

def pathFind(s, g, fromNode):
    path = []
    while s!=g:
        g = fromNode[g]
        if g==s:break
        path.append(g)
    path.reverse()
    return path
dfs(0,-1)
path = pathFind(0,N-1,fromNode)

colors = [-1]*N
colors[0] = 0
colors[N-1] = 1
for i in range(len(path)):
    if i<=(len(path)-1)//2:
        colors[path[i]] = 0
    else:
        colors[path[i]] = 1

def dfs_color(v, p, c):
    for nv in edge[v]:
        if nv==p:continue 
        if colors[nv]==-1:
            colors[nv] = c
            dfs_color(nv, v, c)
    return 

dfs_color(0,-1,0)
dfs_color(N-1, -1, 1)
for p in path:
    c = colors[p]
    dfs_color(p, -1, c)

B = 0
W = 0
for c in colors:
    if c==0:B+=1
    elif c==1:W+=1

if B>W:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 130032
X, N = map(int, input().split())
if N==0:
  print(X)
  exit()
else:
  A = sorted(map(int, input().split()))

if A.count(X)==0:
  print(X)
  exit()

for k in range(N+10):
  if A.count(X-k)==0:
    print(X-k)
    exit()
  elif A.count(X+k)==0:
    print(X+k)
    exit()

Measured memory_bytes: 9076
#include<stdio.h>
int main()
{
    long long n,h,N,sum=0;
    double w;
    while(scanf("%lld",&N)!=EOF)
    {
        sum=0;
        for(h=1 ; h<=3500 ; h++)
        {
            for(n=1 ; n<=3500 ; n++)
            {
                if(4*h*n-N*n-N*h==0)
                    continue;
                w=1.0*(N*h*n)/(4*h*n-N*n-N*h);
                if(w-(long long)w==0&&w>0)
                {
                    printf("%lld %lld %lld\n",h,n,(long long)w);
                    sum++;
                }
                if(sum==1)
                    break;
            }
            if(sum==1)
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    int a, b; cin >> a >> b;
    if(a + b < 10) cout << a + b;
    else cout << "error";
}


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

using namespace std;

int main() {
    int d, g;
    cin >> d >> g;

    vector<int> p(d), c(d);
    for (int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
    }

    int res = 1000000000;
    for (int i = 0; i < (1 << d); i++) {
        int solved = 0, score = 0, rem = -1;
        for (int j = d - 1; j >= 0; j--) {
            if ((i & (1 << j)) > 0) {
                solved += p[j];
                score += 100 * (j + 1) * p[j] + c[j];
            } else if (rem == -1) {
                rem = j;
            }
        }

        if (score < g && rem != -1 && (g - score + 100 * rem) / (100 * (rem + 1)) <= p[rem]) {
            int s = (g - score + 100 * rem) / (100 * (rem + 1));
            solved += s;
            score += 100 * (rem + 1) * s;
        }

        if (score >= g && res > solved) {
            res = solved;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  [a,b] <- reads2List
  putStrLn $ solve a b

solve :: Int -> Int -> String
solve a b | a `mod` 3 == 0 = "Possible"
          | b `mod` 3 == 0 = "Possible"
          | (a + b) `mod` 3 == 0 = "Possible"
          | otherwise = "Impossible"


s2List :: Read a => String -> [a]
s2List = fmap read . words

reads2List :: Read a => IO [a]
reads2List = do
  s <- getLine
  return (s2List s)


Measured memory_bytes: 508
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

int main(){

    long long int a,b,n;
    cin >> a >> b >> n;

    long long int c=0;

    if(b<=n){
        c=b-1;
    }
    else c=n;

    cout << (a*c)/b << endl;

}

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 10**9+7


def solve3():
    L = input()[:-1]
    # dp[smaller?][上からi桁目まで見た] = 何通りあるか?
    dp_1 = 1
    dp_2 = 0

    for c in L:
        t_1 = (dp_1*(int(c)+1)) % MOD
        t_2 = (dp_2*3+dp_1*int(c)) % MOD
        dp_1 = t_1
        dp_2 = t_2

    print((dp_1+dp_2) % MOD)


solve3()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int x;
    cin >> x;
    while(true){
        bool ans=true;
        for(int i=2;i*i<=x;i++){
            if(x%i==0){
                ans=false;
                break;
            }
        }
        if(ans){
            cout << x << endl;
            return 0;
        }
        ++x;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  ll mon = 1000;
  ll kb = 0;
  REP(i,n-1){
    if(a[i]<a[i+1]){
      ll cur = mon/a[i];
      kb += cur;
      mon -= cur*a[i];
      while(i<n-1 && a[i]<a[i+1]) i++;
      mon += kb*a[i];
      kb = 0;
    }
  }
  cout << mon << endl;
  return 0;
}


Measured memory_bytes: 3656
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 1844674407370955161
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define min_heap priority_queue<int, vector<int>, greater<int>>
#define max_heap priority_queue<int>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define pp pair<pair<ll,ll>,pair<ll,ll>>
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> 

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    if(a.ss < b.ss) return true; 
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff>b.ff) return true;
	else if(a.ff==b.ff) return a.ss<b.ss;
	else return false;
} 
bool sortff_resortss(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff<b.ff) return true;
	else if(a.ff==b.ff) return a.ss>b.ss;
	else return false;
}
bool sortbystring(const string &a, const string &b)
{
	string c=a+b;
	string d=b+a;
	if(c>=d) return true;
	else return false;
}

bool sortby(const pair<pair<int,int>,pair<int,int>> &a, const pair<pair<int,int>,pair<int,int>> &b)
{
	return a.ss.ss<b.ss.ss;
}

ll modi(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
ll Logn(ll  n, ll r) 
{ 
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0; 
} 

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modinv(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 

int main()
{
	FAST
	int t=1;
//	cin>>t;
	while(t--)
	{
		ll a,b,c,k;
		cin>>a>>b>>c>>k;
		ll sum=0;
		if(k>0)
		{
			sum+=min(a,k);
			k-=min(a,k);
		}
		if(k>0)
		{
			k-=min(b,k);
		}
		if(k>0)
		{
			sum-=min(c,k);
			k-=min(c,k);
		}
		cout<<sum<<endl;
	}
	return 0;
}


















Measured memory_bytes: 3656
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string s;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> s;
  bool f = false;
  for(int i=0;i<s.size();i++){
    if(s[i]=='7')f=true;
  }
  cout << (f?"Yes":"No") << endl;


return 0;
}
///....


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

int main()
{
	int n, k, m = 0, i = 1, j = 0;

	cin >> n >> k;

	while (1) {
		while (j > k * i)
			i++;
		if (n - j < i)
			break;
		m++;
		j += i;
	}

	cout << m << endl;
	
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
using pint = pair<int, int>;

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

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

int main()
{
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size())
  {
    if (s[i] != t[i])
      ans++;
  }

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


Measured memory_bytes: 3916
k,a,b=list(map(int,input().split(" ")))
if k<=a:
    print(k+1)
else:
    d=b-a
    if d<=2:
        print(k+1)
    else:
        l=k-a+1
        m=l&1
        print(a+(l>>1)*d+m)


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll N,A[100007],t=0,m=0;cin >> N;
    rep(i,N){
        cin >> A[i];
        if(i>0){
            if(A[i]<=A[i-1]){
                t++;
            }
            else{
                if(t>m){
                    m=t;
                }
                t=0;
            }
            if(i==N-1){
                if(t>m){
                    m=t;
                }
            }
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  int count = 0;
  for (int i = 0; i < h * w; i++) {
    char c;
    cin >> c;
    if (c == '#') {
      count++;
    }
  }
  if (count == h + w - 1) {
    cout << "Possible" << '\n';
  }
  else {
    cout << "Impossible" << '\n';
  }
}

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 063_arc_b / Link: https://abc047.contest.atcoder.jp/tasks/arc063_b?lang=en  ----- */
/* ------問題------

N 個の町が一直線上に並んでいます。行商人の高橋君は町 1 から出発し、リンゴの売買をしながら町 N へと向かいます。
はじめ高橋君は町 1 におり、リンゴを 1 つも持っていません。高橋君は次のいずれかの行動を繰り返し行います。
移動: 町 i (i<N) にいるとき、町 i+1 へ移動する。
リンゴの売買: リンゴを好きな個数だけ売買する。ここで、町 i (1≦i≦N) ではリンゴの買値も売値もともに Ai 円とする。ここで Ai は相異なる整数です。
1 つの町で売買するリンゴの個数に制限はありませんが、旅の中で売買するリンゴの個数は合計で (買う個数と売る個数を合わせて) T 個以下にしなくてはなりません。
高橋君は旅の利益、すなわちリンゴを売った代金から買った代金を引いた値を最大にするように旅をするとします。旅が終わったときに持っていたリンゴの価値は考えず、旅の中で売買した金額だけを考えます。
この旅に先立って、青木君は任意の町 i に対して Ai を好きな非負整数 Ai' に変えるという操作を好きなだけ行うことができます。ただし、この操作は行うごとに |Ai−Ai'| のコストがかかります。操作後には異なる町の間でリンゴの値段が同じになっていても構いません。
青木君の目的はできるだけ少ない合計コストの操作で高橋君の利益を少なくとも 1 円下げることです。合計コストの最小値を求めてください。
ただし、元の状態で高橋君が 1 円以上の利益を上げられることは仮定して構いません。

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

最大利益を得ることができる場所が何個あるかをカウントし、これの数を出力すれば良い。

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

LL N;

LL ans = 0LL;

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

	LL T;
	cin >> N>>T;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	LL Mn = a[0];
	int scnt = 0;
	LL gmx = -1;
	FOR(i, 0, N) {
		if (Mn > a[i]) {
			Mn = a[i];
		}

		if (gmx == a[i] - Mn)scnt++;
		else if (gmx < a[i] - Mn) {
			gmx = a[i] - Mn;
			scnt = 1;
		}
	}

	ans = scnt;
	cout << ans << "\n";

	return 0;
}


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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 110;

int n;
int cnt[M];

int main()
{
	cin >> n;
	for (int i = 2; i <= n; i ++ )
	{
		int t = i;
		for (int j = 2; j <= t / j; j ++ )
			while (t % j == 0)
			{
				cnt[j] ++ ;
				t /= j;
			}
		if (t > 1) cnt[t] ++ ;
	}
	
	int res = 0;
	for (int i = 2; i < M; i ++ )
		if (cnt[i] >= 74)
			res ++ ;
	
	for (int i = 2; i < M; i ++ )
		for (int j = 2; j < M; j ++ )
			if (cnt[i] >= 2 && cnt[j] >= 24 && i != j)
				res ++ ;
	
	for (int i = 2; i < M; i ++ )
		for (int j = 2; j < M; j ++ )
			if (cnt[i] >= 4 && cnt[j] >= 14 && i != j)
				res ++ ;
	
	for (int i = 2; i < M; i ++ )
		for (int j = 2; j < M; j ++ )
			for (int k = 2; k < j; k ++ )
				if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4)
					if (i != j && j != k && k != i)
						res ++ ;
	
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
L,R=map(int,input().split())
X=2019
a=10**20
for i in range(L,min(R,L+X)):
    for j in range(i+1,min(R+1,i+1+X)):
        t=(i*j)%X
        a=min(a,t)
        if t==0:
            break
print(a)

Measured memory_bytes: 2940
from sys import stdin

n = int(stdin.readline().strip())

dp = [0 for i in range(100010)]
dp[0] = 0
dp[1] = 1

for i in range(1,n+1):
    dp[i] = dp[i - 1] + 1
    j = 6
    while i>=j:
        dp[i] = min(dp[i], dp[i-j]+1)
        j *= 6

    j = 9
    while i>=j:
        dp[i] = min(dp[i], dp[i-j]+1)
        j *= 9

print(dp[n])

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double EPS = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int sumMod(int a, int b){return 0LL + a + b > mod ? a + b - mod : a + b;}
int n;
double mul;
double v[3010];
double dp[3010][3010];
double f(int i, int tail){
    if(i == n){
        return 1;
    }
    double &ans = dp[i][tail];
    if(ans < 0){
        ans = 0;
        int head = n - tail;
        if(head > tail + 1)
            ans += f(i + 1, tail + 1) * (1.0 - v[i]);
    
        ans += f(i + 1, tail) * v[i];
    }
    return ans;
}
int main(){
    //FL;
    FIN;
    cin >> n;
    mul = 1;
    for(int i = 0; i < n; i++){
        double x;
        cin >> v[i];
        mul *= v[i];
    }
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            dp[i][j] = -1.0;
    cout << fixed << setprecision(9) << f(0, 0) << '\n';
    EjecuteTime;
    return 0;
}       

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

int main() {
	string s;
	int Q;
	cin >> s >> Q;
	deque<char> q;
	rep(i, s.size()) {
		q.push_back(s[i]);
	}
	int rev = 0;
	rep(k, Q) {
		int t;
		cin >> t;
		if(t == 1) {
			rev ^= 1;
		}else{
			int f;
			char c;
			cin >> f >> c;
			if((rev==0 && f == 1)||(rev==1 && f == 2)) q.push_front(c);
			else q.push_back(c);
		}
	}
	if(rev) {
		while(!q.empty()){
			cout << q.back();
			q.pop_back();
		}
	}else {
		while(!q.empty()){
			cout << q.front();
			q.pop_front();
		}
	}
	cout << endl;
	return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,m,pw[200005];
string s;
int get(int x){
    if(x==0) return 0;
    int d=__builtin_popcount(x);
    return 1+get(x%d);
}
void solve(){
    cin>>n>>s;
    reverse(all(s));
    for(auto i:s) m+=i=='1';
    int mod=(m+1);
    if(m-1>0) mod*=(m-1);
    pw[0]=1;
    rep(i,1,n) pw[i]=2*pw[i-1]%mod;
    int cur=0;
    rep(i,0,n){
        if(s[i]=='1') cur=(cur+pw[i])%mod;
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='1'){
            if(m==1) cout<<0<<endl;
            else{
                int rem=(cur-pw[i]+mod)%(m-1);
                cout<<1+get(rem)<<endl;                
            }
        }
        else{            
            int rem=(cur+pw[i]+mod)%(m+1);
            cout<<1+get(rem)<<endl;
        }
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5340
import itertools
a = int(input())
j = 1
b = []
c = []

num1 = input().split()
num2 = input().split()
for i in range(0, len(num1)): 
    num1[i] = int(num1[i])
for i in range(0, len(num2)): 
    num2[i] = int(num2[i]) 

if(a>=2 and a<=8):
  while (j<=a):
      b.append(j)
      j = j+1

c = list(itertools.permutations(b))
index1 = c.index(tuple(num1))
index2 = c.index(tuple(num2))
res = index1-index2 
if(res<0):
    print(res*(-1))
else:
    print(res)


Measured memory_bytes: 8052
#include<iostream>
#include<algorithm>
#include <vector>
#include <cmath>
#include<string>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    string s;
    int n=0;
    char a='+',b='-';
    cin>>s;
    REP(i,4){
        if (s[i]==a){
            n++;
        }else if (s[i]==b){
            n--;
        }
    }
    cout<<n<<endl;   
    
    return 0;
}

Measured memory_bytes: 256
Inlist=[]

while True:
    xylist = list(map(int, input().split()))
    if xylist[0] == 0 and xylist[1] == 0:
        break
    else:
        Inlist.append(xylist)

for IN in Inlist:
    IN.sort()
    print('{} {}'.format(IN[0], IN[1]))


Measured memory_bytes: 5988
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<String> L = new List<String>();
		for(int i=0;i<H-1;i++){
			for(int j=0;j<W;j++){
				if(A[i][j] % 2 == 0) continue;
				L.Add(String.Format("{0} {1} {2} {3}",i + 1, j + 1, i + 2, j + 1));
				A[i][j]--;
				A[i+1][j]++;
			}
		}
		for(int j=0;j<W-1;j++){
			if(A[H-1][j] % 2 == 0) continue;
			L.Add(String.Format("{0} {1} {2} {3}",H - 1 + 1, j + 1, H - 1 + 1, j + 2));
			A[H - 1][j]--;
			A[H - 1][j+1]++;
		}
		
		Console.WriteLine(L.Count);
		Console.WriteLine(String.Join("\n",L));
		
		
	}
	int H,W;
	int[][] A;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1];
		A = new int[H][];
		for(int i=0;i<H;i++) A[i] = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main()
{
    int H,n;
    cin>>H>>n;
    vector<int> dp(H+1,1e9+5);
    dp[0]=0;
    while(n--)
{
    int value,cost;
    cin>>value>>cost;
    for(int i=0;i<=H;i++)
    {
        
        int j= min(H,i+value);
        dp[j]=min(dp[j],dp[i]+cost);
        
    }
}
cout<<dp[H]<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

public class Program
{
    public static long loop;

    static long n;
    static long a;

    static long[] x;

    static string output;

    public static void Main(string[] args)
    {
        loop = 0;

        Input();
        Proc();
        Output();
    }

    static void Input()
    {
        string[] input = null;

        // スペース区切りの整数の入力(横、個別)
        input = Console.ReadLine().Split(' ');

        n = long.Parse(input[0]);
        a = long.Parse(input[1]);

        // スペース区切りの整数の入力(横、配列)
        input = Console.ReadLine().Split(' ');

        x = new long[n];
        for (long idx = 0; idx < n; idx++)
        {
            x[idx] = long.Parse(input[idx]);
        }

    }

    static void Proc()
    {
        // 平均値を求める → あらかじめaを引いておき、合計0を求める
        // また、dpの最大幅を求めるためにxMaxを控えておく
        long[] yArray = new long[n];
        long xMax = 0;
        for (long idx = 0; idx < n; idx++)
        {
            yArray[idx] = x[idx] - a;
            if (x[idx] > xMax)
            {
                xMax = x[idx];
            }
        }

        // yは -x～+x まであり得る
        // n個、xMaxのプラスマイナスまで幅を確保
        long idxSumMax = n * xMax * 2;
        long[,] dp = new long[n + 1, idxSumMax];

        // dpを初期化(プラスマイナス0に相当する n * xMax を予め1にする)
        Array.Clear(dp, 0, dp.Length);
        dp[0, n * xMax] = 1;

        // dpメイン処理
        for (long idxY = 0; idxY < n; idxY++)
        {
            long y = yArray[idxY];

            for (long idxSum = 0; idxSum < idxSumMax; idxSum++)
            {
                // 一つ前の値を引き継ぎ
                dp[idxY + 1, idxSum] = dp[idxY, idxSum];

                // Sumの範囲内なら、yの分idxをずらした値も加算する
                if (idxSum - y >= 0 && idxSum - y < idxSumMax)
                {
                    dp[idxY + 1, idxSum] += dp[idxY, idxSum - y];
                }
            }
        }

        // プラスマイナス0に相当する n * xMax の値を出力(0個選択の分を除外するため-1)
        output = (dp[n, n * xMax] - 1).ToString();
    }

    static void Output()
    {
        // 出力
        Console.WriteLine(output);
        output = string.Empty;
    }
}


Measured memory_bytes: 12896
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

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;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];

int main(){
    int n,k;
    cin>>n;
    vector<int>a(n);
    rep(i,n){
        cin>>k;
        a.at(k-1)=i;
    }
    rep(i,n)
        cout<<a.at(i)+1<<" ";
    return 0; 

}




Measured memory_bytes: 1152
def solve(w, h, k):
    for y in range(h+1):
        if h == 2*y:
            continue
        x = (k - y*w) // (h - 2*y)
        if not (0 <= x <= w):
            continue
        s = x * (h-y) + (w-x) * y
        if s == k:
            return "Yes"
    return "No"

n, m, k = map(int, input().split())
print(solve(n, m, k))

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    c[i] = i + 1;
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int posx = -1;
  int posy = -1;
  int cnt = 0;
  do {
    cnt++;
    bool fail = false;
    for (int i = 0; i < n; i++) {
      if (c[i] != a[i]) fail = true;
    }
    if (!fail) posx = cnt;
    fail = false;
    for (int i = 0; i < n; i++) {
      if (c[i] != b[i]) fail = true;
    }
    if (!fail) posy = cnt;
  } while(next_permutation(c.begin(), c.end()));
  cout << abs(posx - posy) << endl;
  return 0;
}

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

int main(){
    //T時間駐車でA*T円
    //時間に関係なくB円
    int N, A, B;
    cin >> N >> A >> B;

    if(N * A <= B){
        cout << N * A << endl;
    }
    else{
        cout << B << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		
		int n, a, b, h, w, count = 0;
		n = sc.nextInt();
		h = sc.nextInt();
		w = sc.nextInt();
		for(int i = 0; i < n; ++i) {
			a = sc.nextInt();
			b = sc.nextInt();
			if(a >= h && b >= w)++count;
		}
		
		sc.close();
		
		System.out.println(count);
	}

}


Measured memory_bytes: 27964
#include<iostream>
using namespace std;
int x,y,z;
int main(){
  while(1){
    cin>>x>>y;
    if(x==0&&y==0)break;
    if(x>y){z=x;
      x=y;
      y=z;
}
   cout<<x<<" "<<y<<"\n";
   x=0,y=0,z=0;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<LL,int> PII;
#define X first
#define Y second
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
const int maxn=300010;
int n,m,M,x[maxn],y[maxn],r[maxn],c[maxn],maxr,maxc,cntr,cntc; 
PII a[maxn],ro[maxn],cu[maxn];
LL ans;
LL id(int x,int y){return (LL)x*(LL)n+y;}
int main()
{
	n=read();m=read();
	M=read();
	for(int i=0;i<M;i++)x[i]=read()-1,y[i]=read()-1,a[i]=make_pair(id(x[i],y[i]),i),r[x[i]]++,c[y[i]]++;
	sort(a,a+M);
	for(int i=0;i<n;i++)maxr=max(maxr,r[i]);//ro[i]=make_pair(r[i],i);
	for(int i=0;i<m;i++)maxc=max(maxc,c[i]);//cu[i]=make_pair(c[i],i);
	for(int i=0;i<n;i++)cntr+=(r[i]==maxr);
	for(int i=0;i<m;i++)cntc+=(c[i]==maxc);
	int cnt=0;
	for(int i=0;i<M;i++)if(r[x[i]]==maxr && c[y[i]]==maxc)cnt++;
//	cout<<cnt<<endl;
	if(cnt<(LL)cntr*(LL)(cntc))printf("%lld\n",maxc+maxr);
	else printf("%lld\n",maxc+maxr-1);
	return 0;
}
/*
1 2 1 2 2 1
*/


Measured memory_bytes: 12484
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0;
string s,S,t;
bool flag=false; 
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> m;
vector<vector<char>> A(n,vector<char>(n));
vector<vector<char>> B(m,vector<char>(m));
REP(i,n){
  REP(j,n){
    cin>>A[i][j];
  }
}
REP(i,m){
  REP(j,m){
    cin>>B[i][j];
  }
}
for(int i=0;i<n-m+1;i++){
  for(int j=0;j<n-m+1;j++){
    for(int k=0;k<m;k++){
      for(int l=0;l<m;l++){
          if(A[i+k][j+l]!=B[k][l]){
            flag=true;
              break;   
             }
          if(k==m-1){
            cout << "Yes"<<endl;
            return 0;
          }
             }
      if(flag){
      flag=false;
      break;
          } 
         }
        }
      }
     cout <<"No"<<endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
vector<int> to[100005];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  rep(i, n) {
    if (dist[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  rep(i, n) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10648