akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    const char White = '.';
    const char Black = '#';

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var dic = new Dictionary<int, int>();
        foreach(var a in ary) {
            if (dic.ContainsKey(a)) dic[a]++;
            else dic[a] = 1;
        }

        var keys = dic.Keys.ToArray();
        Array.Sort(keys, (x, y) => y - x);

        long max1 = -1;
        long max2 = -1;

        int i = 0;
        while (i < keys.Length) {
            if (dic[keys[i]] >= 2) {
                max1 = keys[i];
                dic[keys[i]] -= 2;
                break;
            }
            i++;
        }
        while (i < keys.Length) {
            if (dic[keys[i]] >= 2) {
                max2 = keys[i];
                dic[keys[i]] -= 2;
                break;
            }
            i++;
        }

        if (max1 == -1 || max2 == -1) return 0;
        return max1 * max2;
    }

    static void SetArray<T>(T[] array, Func<T, int, T> f) {
        for (int i = 0; i < array.Length; i++)
            array[i] = f(array[i], i);
    }
    static void FillArray<T>(T[] array, T value) {
        for (int i = 0; i < array.Length; i++)
            array[i] = value;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 25056
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int keta = 1;
	int sum;
	
	while(scanf("%d %d", &a, &b) != EOF){
		sum = a + b;
		while(sum >= 10){
			sum /= 10;
			keta++;
		}
		printf("%d\n", keta);
		keta = 1;
	}
	
	return (0);
}

Measured memory_bytes: 1768
#include <iostream>

using namespace std;

char a[10][10];
char b[10][10];

int main()
{
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
        {
            cin>>a[i][j];
        }
    int ans=0;
    for(int i=0;i<(1<<h);i++)
        for(int j=0;j<(1<<w);j++)
        {
            for(int s=1;s<=h;s++)
                for(int t=1;t<=w;t++)
                    b[s][t]=a[s][t];
            for(int t=0;t<h;t++)
            {
                if((1<<t)&i)
                    for(int s=1;s<=w;s++)
                        b[t+1][s]='.';
            }
            for(int t=0;t<w;t++)
            {
                if((1<<t)&j)
                    for(int s=1;s<=h;s++)
                        b[s][t+1]='.';
            }
            int cnt=0;
            for(int i=1;i<=h;i++)
                for(int j=1;j<=w;j++)
                    if(b[i][j]=='#')
                        cnt++;
            if(cnt==k)
                ans++;
        }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string s;
  string ans = "Three";
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> s;
    if (s == "Y") {
      ans = "Four";
      break;
    } 
  }
  
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  ll k;
  cin >> n >> k;
  mint dp[n+1][n+1][62];
  rep(i, n+1) rep(j, n+1) rep(k, 62) dp[i][j][k] = 0;
  rep(i, n) rep(j, n) {
    int a; cin >> a;
    if(a == 1) dp[i+1][j+1][0] = 1;
  }

  for(int k = 1; k < 62; ++k) {
    for(int a = 1; a <= n; ++a) {
      for(int b = 1; b <= n; ++b) {
        for(int c = 1; c <= n; ++c) {
          dp[a][c][k] += dp[a][b][k-1]*dp[b][c][k-1];
        }
      }
    }
  }

  vector<mint> ans(n+1, 1);
  for(int i = 0; i < 62; ++i) {
    if(k & 1ll<<i) {
      vector<mint> next(n+1, 0);
      for(int a = 1; a <= n; ++a) {
        for(int b = 1; b <= n; ++b) {
          next[b] += dp[a][b][i] * ans[a];
        }
      }
      ans = next;
    }
  }
  mint res = 0;
  for(int i = 1; i <= n; ++i) res += ans[i];
  cout << res.x << endl;
}

Measured memory_bytes: 1536
N = int(input())
B = list(map(int, input().split()))

#与えられた数列から、j番目の数がjのものを削除していくのと同義
ans = []
while len(B) > 0:
    can_delete = False
    for i in range(len(B) - 1, -1, -1):
        if i + 1 == B[i]:
            ans.append(B[i])
            del B[i]
            can_delete = True
            break
    if not can_delete:
        break

if len(B) > 0:
    print(-1)
else:
    for i in ans[::-1]:
        print(i)

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    _ = int(input())
    L = tuple(map(int, input().split()))

    sum_l = sum(L)
    for l in L:
        if 2 * l >= sum_l:
            print('No')
            break
    else:
        print('Yes')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;


int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    ll ans=0,sum=0;
    for (int i=n-1;0<=i;--i)
    {
        ll cnt;
        if((a[i]+sum) % b[i] == 0) 
            cnt = 0;
        else 
            cnt = b[i] - ((a[i]+sum) % b[i]);
        ans += cnt;
        sum += cnt;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
  int n, s, count = 0;
  cin >> n;
  s = n;
  while(1){
    if(n > 0){
      count++;
      n -= 1000;
    }
    else
      break;
  }
  
  cout << 1000 * count - s << endl;
    
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    int x, y;
    cin >> x >> y;

    if (y % 2) {
        cout << "No" << endl;
        return 0;
    }

    if (y/2-x < 0 || x*2-y/2 < 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3548
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    t = n
    mt = 10 ** 20
    for i in range(1, int(n ** 0.5) + 1):
        if t % i == 0:
            mt = min(mt, (i - 1) + (t // i - 1))
    print(mt)


if __name__ == '__main__':
    solve()


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	cout<<min(b/a,c)<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222


vll edge[2222];
ll d[2222], d1[2222], d2[2222];


void dfs(ll cur) {
	rep(i, edge[cur].size()) {
		if (d[edge[cur][i]]) continue;
		d[edge[cur][i]] = d[cur] + 1;
		dfs(edge[cur][i]);
	}
}

void dfs1(ll cur) {
	rep(i, edge[cur].size()) {
		if (d1[edge[cur][i]]) continue;
		d1[edge[cur][i]] = d1[cur] + 1;
		dfs1(edge[cur][i]);
	}
}

void dfs2(ll cur) {
	rep(i, edge[cur].size()) {
		if (d2[edge[cur][i]]) continue;
		d2[edge[cur][i]] = d2[cur] + 1;
		dfs2(edge[cur][i]);
	}
}


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

	vpll v;
	cin >> n >> m;
	rep(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		edge[a].pb(b);
		edge[b].pb(a);
		v.pb(pll(a, b));
	}
	ans = inf;
	if (m % 2) {
		rep(i, n - 1) {
			ll a = v[i].first, b = v[i].second;
			FOR(j, 1, n + 1) d1[j] = 0;
			FOR(j, 1, n + 1) d2[j] = 0;
			d1[a] = 1; d2[b] = 1;
			dfs1(a); dfs2(b);
			cnt = 0;
			FOR(j, 1, n + 1) if (min(d1[j], d2[j]) - 1 > m / 2) cnt++;
			ans = min(ans, cnt);
		}
	}
	else {
		FOR(i, 1, n + 1) {
			FOR(j, 1, n + 1) d[j] = 0;
			d[i] = 1;
			dfs(i);
			cnt = 0;
			FOR(j, 1, n + 1) if (d[j] - 1 > m / 2) cnt++;
			ans = min(ans, cnt);
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 512
def main():
    n, y = map(int, input().strip().split())
    z = y // 1000
    # a + b + c == n
    # 10a + 5b + c == z
    # 9a + 4b == z - n
    for a in range(z - n // 9):
        if (z - n - 9 * a) % 4 == 0:
            b = (z-n-9*a)//4
            if b < 0:
                continue
            c = n - a - b
            if c < 0:
                continue
            print(a, b, c)
            return
    print("-1 -1 -1")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#define maxn 100005
using namespace std;
int t[maxn];
int x[maxn];
int y[maxn];
int main()
{
	int n,i;
	while(~scanf("%d",&n))
	{
	
	for(i=0;i<n;i++)
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
	for(i=0;i<n;i++)
	{
		if((x[i]+y[i])%2!=t[i]%2) break;
		else if(x[i]+y[i]>t[i]) break;
	}
	if(i==n) printf("Yes\n");
	else printf("No\n");
	}
	return 0;
	 
 } 

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

char x[5] = {'M', 'A', 'R', 'C', 'H'};
 
int main() {
    ll n;
    cin >> n;

    vl v(5);
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, 5) {
            if(s[0] == x[j]) {
                v[j]++;
            }
        }
    }

    ll ans = 0;
    exrep(i, 0, 2) {
        exrep(j, i+1, 3) {
            exrep(k, j+1, 4) {
                ans += v[i]*v[j]*v[k];
            }
        }
    }

    out(ans);
    re0;
}

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

int main() {

    int k, s, z, ans;
    
    cin >> k >> s;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            z = s - x - y;
            if (z < 0 || z > k) continue;
                ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>

using namespace std;

int main()
{
	int N = 0;
	cin >> N;
	vector<long long> T(N, 0);

	for (int i = 0; i < N; ++i) {
		cin >> T[i];
	}
	sort(T.rbegin(), T.rend());

	// 端から最小公倍数を求めてゆく。
	long long res = T[0];

	for (int i = 0; i < N; ++i) {
		long long cur0 = T[i];
		if ((res % cur0) != 0) {
			if (res < cur0) {
				swap(cur0, res);
			}
			long long addUnit = res;
			while ((res % cur0) != 0) {
				res += addUnit;
			}
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;
using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<int, int> pairs;
typedef complex<ll> G;
const int N=1e6+5;

const int INF = 1e9+5;

void solve() {

    int n;
    cin >> n;
    vector<int>frq(N, 0);
    bool vis[N] = {false};
    int qal = 0;
    set<int>q;
    for(int i=0; i< n;i++) {
        int x;cin >> x;

        q.insert(x);
        ++frq[x];
        if(frq[x] >  1){
            vis[x] = true;
            continue;
        }
        int p = x*2;
        if(frq[x] <= 1) {
            for(int j = p;j <= N;j+=x) {
                vis[j] = true;
            }
        }

    }
    int ans = 0;
    for(auto x : q) {
        if(!vis[x]) {
            ans++;
        }
    }

    cout << ans << '\n';
}
void another() {
    ll n;

    cin >> n;


}

int main() {


    fast;
    solve();

}


Measured memory_bytes: 17416
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[n - 1] - a[0] << endl;
  return 0;
}

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

int main(void){
  int N,K;
  cin >> N >> K;
  double ans;
  for(int i = 1;i <= N;i++){
    if(i <= K-1){
      double x = ceil(log2(K) - log2(i));
      ans += exp2(-x);
    }
    else ans += 1;
  }

  printf("%.12f",ans/N);
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n;
	cin >> n;
	int h[n];
	REP(i, n) cin >> h[i];
	int d[n];
	d[0] = 0;
	d[1] = abs(h[0]-h[1]);
	FOR(i, 2, n) d[i] = min(d[i-2]+abs(h[i-2]-h[i]), d[i-1]+abs(h[i-1]-h[i]));
	cout << d[n-1] << endl;
} 

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3+5;
map<int,int> m1;

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        m1[x]++;
        x++;
        m1[x]++;
        x--;
        x--;
        m1[x]++;
    }
    int ans = 0;
    for(auto x:m1){
        ans = max(ans,x.second);
    }
    cout<<ans<<endl;
    
}


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &d[i]);
    }

    sort(d.begin(), d.end());

    int mid = N / 2;
    int ans = d[mid] - d[mid - 1];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
N = int(input())
nums = list(map(int, input().split()))
Q = int(input())
operations = [list(map(int, input().split())) for _ in range(Q)]

counts = [ 0 for __ in range(10**5+1)]
answer = sum(nums)

for num in nums:
  counts[num] += 1

for b, c in operations:
  answer += counts[b]*(c-b)
  print(answer)
  counts[c] += counts[b]
  counts[b] = 0



Measured memory_bytes: 101160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String answers = "123";
        String A = String.valueOf(sc.nextInt());
        String B = String.valueOf(sc.nextInt());
        sc.close();

        answers = answers.replace(A, "").replace(B, "");

        System.out.println(answers);
    }

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

void chmax(int &a,int b){if(a<b) a = b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for(auto& c:S) if(c=='?') c = 'D';
    cout << S << "\n";
/*    int N = S.size();
    vvec<int> dp(N+1,vec<int>(2,0));
    vvec<int> pre(N+1,vec<int>(2,-1));
    for(int i=0;i<N;i++){
        if(S[i]=='P'){
            chmax(dp[i+1][0],max(dp[i][0],dp[i][1]));
        }else if(S[i]=='D'){
            chmax(dp[i+1][1],max(dp[i][0]+2,dp[i][1]+1));
        }else{
            int p = dp[i][1]
        }
    }*/
}

Measured memory_bytes: 3780
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int main()
{
	int h, w;
	while (cin >> h >> w)
	{
		if (h == 0 && w == 0)
		{
			break;
		}

		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if ((i + j) % 2 == 0)
				{
					cout << '#';
				}
				else
				{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 1e5;
int n;
LL a[MaxN + 5], sum;

void Init()
{
	sum = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		sum = sum + a[i];
	}
	a[0] = a[n];
}

bool Check()
{
	if (sum % ((LL)n * (n + 1) / 2) != 0) return false;
	LL T = (2 * sum) / ((LL)n * (n + 1)), cnt = 0;
	for (int i = 1; i <= n; i++) {
		LL d = a[i] - a[i - 1];
		if (T - d < 0) return false;
		if ((T - d) % n != 0) return false;
		cnt += (T - d) / n;
	}
	if (cnt == T) return true; else return false;
}

int main()
{
	while (~scanf("%d", &n)) {
		Init();
		if (Check()) printf("YES\n");
			else printf("NO\n");
	}
	return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    bool t = true;
    if((a>b) || (a==b)){
        for(int i=0;i<a;i++){
            if(abs(a-i) == abs(b-i)){
                cout<<i<<endl;
                t = false;
            }
        }
    }
    else{
        if((a<b) || (a==b)){
        for(int i=0;i<b;i++){
            if(abs(b-i) == abs(a-i)){
                cout<<i<<endl;
                t = false;
            }
        }
    }
}
    if(t){
            cout<<"IMPOSSIBLE"<<endl;

    }

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    int four=0;
    int odd=0;
    rep(i,n){
        int a;cin>>a;
        if(a%4==0)four++;
        if(a%2)odd++;
    }
    if(odd<=four||(four+odd==n&&odd==four+1))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
int r,g,b,n;
cin>>r>>g>>b>>n;
ll cnt=0;
for (int i = 0; i <= n; i++)
{
    for (int j = 0; j  <=n; j++){

        if(r*i+g*j<=n && (n-r*i-g*j)%b==0){
            cnt+=1;
            //cerr<<i<<j<<endl;
        }
    }
   
    
}
cout<<cnt<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9+7;

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n,t; cin >> n >> t;
    vi arr(n), maxi(n,-inf);
    for(int i=0;i<n;i++) cin >> arr[i];
    int sup = -inf, sum = 0;
    for(int i = n-2;i>=0;--i) maxi[i] = max(maxi[i+1], arr[i+1]), sup=max(sup, maxi[i] - arr[i]);
    for(int i=0;i<n;i++) sum += (maxi[i] - arr[i]) == sup;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

map<int, int> mp;

void solve(int p, int q){
    int cnt = 0, t = p*p + q*q;
    for(int d=1; d*d<=t; ++d)if(t % d == 0){
        for(int m=0; m*m<=d; ++m)if(mp.find(d-m*m) != mp.end()){
            int n = mp[d-m*m];
            rep(sgm, 2)rep(sgn, 2){
                int tm = m * (sgm*2-1), tn = n * (sgn*2-1);
                if((tm*p + tn*q) % d == 0 && (tm*q - tn*p) % d == 0) ++cnt;
            }
        }
    }
    puts(cnt == 8 ? "P" : "C");
}

int main(){
    int t;
    scanf("%d", &t);
    rep(i, 200) mp[i*i] = i;
    rep(_, t){
        int p, q;
        scanf("%d%d", &p, &q);
        solve(p, q);
    }
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

ll gcd(ll a, ll b){ return b ? gcd(b,a%b):a; }

ll ch(ll x){
  ll cnt=0;
  while(x%2==0){
    x /= 2;
    cnt++;
  }
  return cnt;
}

int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i,n){
    cin >> a[i];
    a[i] /= 2;
    b[i] = ch(a[i]);
  }
  rep(i,n){
    if(b[i]!=b[0]){ cout << 0 << endl; return 0;}
  }
  
  ll ans=1;
  rep(i,n){
    ans = ans*(a[i]/gcd(a[i],ans));
    if(ans > 1e9+7){ cout << 0 << endl; return 0;}
  }
  
  cout << ((m/ans)+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%s", $S);
$a = str_split($S);
$cnt = count($a);
$sum = [0];

define('STEP', 100010);
for ($i = 0; $i < $cnt - 1; $i++) {
    if ($a[$i] === 'L' && $a[$i + 1] === 'R') {
        $sum[] = $i + 1;
    }    
    if ($a[$i] === 'R' && $a[$i + 1] === 'L') {
        $sum[] = $i;
    }
}
$fixAns = new SplFixedArray($cnt);
for ($i = 0; $i < $cnt; $i++) {
    $fixAns[$i] = 0;
}
$sum[] = $cnt;
$fixSum = new SplFixedArray(count($sum));
for ($i = 0; $i < count($sum); $i++) {
    $fixSum[$i] = $sum[$i];
}
for ($i = 0; $i < count($sum) - 1; $i += 2) {
    for ($j = $fixSum[$i]; $j < $fixSum[$i+2]; $j++) {
        // echo $j . " ";
        $step = STEP;
        if ($a[$j] === "R") {
            $step -= $fixSum[$i+1] - $j;
            $loc = $fixSum[$i+1] + ($step % 2);
        }
        if ($a[$j] === "L") {
            $step -= $j - ($fixSum[$i+1] + 1);
            $loc = $fixSum[$i+1] + 1 - ($step % 2);
        }
        $fixAns[$loc] = $fixAns[$loc] + 1;
    }
}
echo implode(" ", $fixAns->toArray());


Measured memory_bytes: 23160
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, t;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s >> t;
  ans = LINF;
  rep(i, Size(s) - Size(t) + 1) {
    cnt = 0;
    rrep(j, i, i + Size(t)) {
      if (s[j] != t[j - i]) cnt++;
    }
    ans = min(ans, cnt);
  }
  Cout(ans);
  return 0;
}

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


void solve(long long X){
    ll ans = 0;
    ans = 1000 * (X / 500);
    X %= 500;
    ans += 5*(X/5);
    X %= 5;
    cout << ans << endl;
}

// Generated by 1.1.6 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 X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

int main(){
  string str;
  cin >> str;
  
  int ans=0;
  int i=0;
  int j=str.size()-1;
  while(i<j){
    if(str[i]!=str[j]) ans++;
    i++;
    j--;
  }
  cout<<ans<<endl;
}

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;
    std::cin >> N;
    std::vector<std::vector<int>> A(2,std::vector<int>(N,0));

    for(int i=0;i<N;i++)
    {
        cin >> A[0][i];
    }

    for(int i=0;i<N;i++)
    {
        cin >> A[1][i];
    }

    ll pointMax=0;
    ll downPoint =0;
    while(downPoint < N)
    {
        ll sum=0;
        for(int topRow=0;topRow<=downPoint;topRow++)
        {
            sum += A[0][topRow];
        }

//downRow++がdownRowになっていたことで、プログラム全体が止まった
        for(int downRow=downPoint;downRow<N;downRow++)
        {
            sum += A[1][downRow];
        }

        if(sum > pointMax)
        {
            pointMax = sum;
        }
        downPoint++;

    }

    std::cout << pointMax;

    return 0;
}




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

const int maxn = 600000;
static int dp[maxn];

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;

    int last = -1;
    for (int i = 2; i < N; i++) {
        dp[i + 1] = dp[i];
        if (s[i - 2] == '1' and s[i - 1] == '0' and s[i] == '1') {
            last = i - 2;
            for (int j = i - 2; j >= 0; j--) {
                if (s[j] == '0') break;
                dp[i + 1] = max(dp[i + 1], dp[j] + i - j - 1);
            }
        } else if (s[i] == '0') {
            last = -1;
        }

        if (last >= 0) {
            dp[i + 1] = max(dp[i + 1], dp[last] + i - last - 1);
        }
    }
    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 2820
#include<bits/stdc++.h>
#define __STDC_LIMIT_MACROS
#include <stdint.h>
using namespace std;
#define int             long long
#define endl '\n'	 
bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;
	
	}
	return true;
}
 
void c_p_c()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 
}
bool how(pair<int,int> a, pair<int, int>b)
{
	return a.second<b.second;
}
string multiply(string x, string y)
{
	int l1 = x.length();
	int l2 = y.length();
	if(l1==0 || l2 ==0)
		return "0";
	vector<int> ans(l1+l2,0);
	int n1=0;
	int n2=0;
	for(int i=l1-1; i>=0; i--)
	{
		int c = 0;
		int a = x[i]-'0';
		n2=0;
		for(int j=l2-1; j>=0; j--)
		{
			int b = y[j]-'0';
			int sum = a*b + ans[n1+n2] + c;
			c = sum/10;
			ans[n1+n2] = sum%10;
			n2++;
		}
		if(c>0)
			ans[n1+n2]+=c;
		n1++;
	}
	int i = ans.size()-1;
	while(i>=0 && ans[i]==0)
		i--;
	if(i==-1)
		return "0";
	string s = "";
	while(i>=0)
	{
		//s += to_string(ans[i--]);
	}
	return s;
}
int power(int x,int y)
{
	int a = 0;
	while(x%y==0)
	{
		a++;
		x=x/y;
	}
	return a;
}
vector<vector<int> > graph;
vector<bool> visited;

bool dfs(int cur_node, int par_node, int &nodes_cnt)
{
	if(visited[cur_node])
		return true;

	visited[cur_node] = true;
	//for(auto child_node : graph[cur_node])
	{
		//if(child_node!=par_node)
		{
			nodes_cnt++;
			//if(dfs(child_node,cur_node,nodes_cnt))
				return true;
		}
	}
	return false;
}
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//c_p_c();
	string s,t;
	cin>>s>>t;
	int ans = 0;
	for(int i = 0; i<s.length(); i++)
	{
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3756
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

int N;
int x[10], y[10];
vector <double> dist;
int fact[10];
double ans;

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d%d", x + i, y + i);
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			dist.push_back(hypot(x[i] - x[j], y[i] - y[j]));
		}
	}
	fact[1] = 1;
	for (int i = 2; i <= N; i++)
	{
		fact[i] = fact[i - 1] * i;
	}
	for (double i : dist)
	{
		ans += i * 2 * fact[N - 1];
	}
	ans /= fact[N];
	printf("%.10f\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int a, p;

signed main() {
    cin >> a >> p;
    cout << (a*3 + p)/2 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  vector<int64_t> c(26);
  rep(i, 26) { cin >> c[i]; }

  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) rep(j, 26) { cin >> s[i][j]; }

  vector<int> t(D);
  rep(i, D) {
    cin >> t[i];
    t[i]--;
  }

  int64_t result = 0;
  vector<int> last(26, -1);
  rep(i, D) {
    int j = t[i];
    result += s[i][j];
    last[j] = i;
    rep(k, 26) { result -= c[k] * (i - last[k]); }
    cout << result << "\n";
  }

  return 0;
}

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

int main() {
	// your code goes here
	string s;
	cin>>s;
	int n=s.length();
	int i;
	for(i=0;i<n-1;i++)
	cout<<s[i];
	if(s[i]=='s')
	cout<<"ses"<<endl;
	else cout<<s[i]<<"s"<<endl;
	return 0;
}


Measured memory_bytes: 3620
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(l[k - 1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
	vector<int> vec(5);
	for (int i = 0; i < 5; i++) {
		cin >> vec.at(i);
	}
	vector<int> loss(5);
	for (int i = 0; i < 5; i++) {
		loss.at(i) = 10 - (vec.at(i) - (vec.at(i) / 10) * 10);
		if (loss.at(i) == 10) loss.at(i) = 0;
	}
	int answer = 0;
	for (int i = 0; i < 5; i++) {
		answer += vec.at(i) + loss.at(i);
	}
	answer -= max({loss.at(0),loss.at(1),loss.at(2),loss.at(3),loss.at(4)});
	cout << answer << endl;
}

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

int main(){
  long n,r=0,g=0,b=0,rgb,unchi=0;
  int i,j;
  string s;
  cin >> n;
  cin >> s;
  for(i=0;i<n;i++){
    if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else if(s[i]=='B') b++;
  }
  rgb=r*g*b;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(j+(j-i)<n){
        if(s[i]!=s[j]&&s[j]!=s[j+(j-i)]&&s[i]!=s[j+(j-i)]) unchi++;
      }
    }
  }
  cout << rgb-unchi << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, x, i;
    cin>>n;
    vector<long long int> a, b;
    for(i=0; i<n; i++){
        cin>>x;
        b.push_back(x);
    }
    a=b;
    sort(a.begin(),a.end());
 
    for(i=0; i<n; i++){
        if(b[i]==a[n-1]){
            cout<<a[n-2]<<endl;
        }
        else{
            cout<<a[n-1]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4848
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] vOdd = new int[100001];
		int[] vEven = new int[100001];
		int maxOdd=0,maxEven=0,maxNumOdd=0,maxNumEven=0;
		for( int i=1; i<=N/2; i++ ){
			vOdd[sc.nextInt()]++;
			vEven[sc.nextInt()]++;
		}
		for( int i=1; i<=100000; i++ ){
			if( vOdd[i]>maxOdd ){
				maxOdd = vOdd[i];
				maxNumOdd = i;
			}
			if( vEven[i]>maxEven ){
				maxEven = vEven[i];
				maxNumEven = i;
			}
		}
		Arrays.sort(vOdd);
		Arrays.sort(vEven);
		int ans = 0;
		if( maxNumOdd!=maxNumEven ){
			ans = N - maxOdd - maxEven;
		}else{
			if( maxOdd==maxEven ){
				ans = N - maxOdd - Math.max(vOdd[99999],vEven[99999]);
			}else{
				if( maxOdd > maxEven ){
					if( maxOdd==vOdd[99999] ){
						ans = N - maxOdd - maxEven;
					}
					if( maxOdd > vOdd[99999] ){
						ans = N - maxOdd - vOdd[99999];
					}
				}
				if( maxEven > maxOdd ){
					if( maxEven==vEven[99999] ){
						ans = N - maxOdd - maxEven;
					}
					if( maxEven > vEven[99999] ){
						ans = N - maxEven - vEven[99999];
					}
				}
			}
		} 
		System.out.println(ans);     
	}
}


Measured memory_bytes: 60904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


/*
* Problem : Maximum Volume
* Acknowledgement : None
* Author : deathnaught_
* GitHub : www.github.com/DeathNaughT-GitHub
* Complexity : O(1)
*/

public class Main
{

    public static void main(String[] args) 
    {
        FastReader sc = new FastReader();
        int L = sc.nextInt();
        System.out.println(Math.pow(L / 3.0, 3));        
    }

    static class FastReader 
    { 

        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 

		boolean hasNext()
		{
		    return st == null ? false : true;
		}

        char nextChar()
        {
            return next().charAt(0);
        }
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 

        int[] nextArray(int rows)
        {
            int arr[] = new int[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextInt();
            return arr;
        }

        long[] nextLongArray(int rows)
        {
            long arr[] = new long[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextLong();
            return arr;
        }

        char[] nextCharArray(int rows)
        {
            char arr[] = new char[rows];
            for (int i = 0; i < rows; i++)
            arr[i] = next().charAt(0);
            return arr;
        }

        int[][] nextMatrix(int rows, int columns)
        {
            int mat[][] = new int[rows][columns];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    mat[i][j] = nextInt();
                }
            }
            return mat;
        }
    } 

}

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

int N;


int sub(int base, int num, int current){
    if(num == 0){
        //cout << N - current << endl;  
        return N - current;
    }
    else{
        int min = 1000;

        // ashikiri
        if((N - current) / pow(base, num) > pow(base, 2)){
            return N - current;
        }

        for(int i = 0; i < base; i ++){
            if(current + pow(base, num) * i > N){
                break;
            }
            int nextBase = 6;
            int nextNum = num;
            if(base == 6){
                nextBase = 9;
                nextNum --;
            }
            int temp = sub(nextBase, nextNum, current + pow(base, num) * i);
            if(temp + i < min){
                min = temp + i;
            }
        }
        return min;
    }
}

int main(){
    cin >> N;
    int result = 0;

    result = sub(9, 6, 0);

    cout << result << endl;  
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    int n,a,b,c,d; 
    cin >> n >> a >> b >> c >> d;
    int numa,numc;
    if(n%a==0){
        numa = n/a;
    }else{
        numa = n/a+1;
    }
    if(n%c==0){
        numc = n/c;
    }else{
        numc = n/c+1;
    }
    cout << min(numa*b,numc*d) << endl;
}


Measured memory_bytes: 3120
function main(arg) {
  var input = arg.trim().split('\n');
  var n = parseInt(input[0]);
  var numbers = input[1].split(' ').map(i => parseInt(i));

  count = 0;

  var canDivide = function(item) {
    return item % 2 === 0;
  };

  while (canDivide) {
    if (numbers.every(canDivide)) {
      count++;
      numbers = numbers.map(item => item / 2);
    } else {
      canDivide = false;
      console.log(count);
    }
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,A,B; cin>>N>>A>>B;
  int ans=N/(A+B)*A+min(N%(A+B),A);
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s,t;
    int onazi=0;
    cin >> s >> t;
    
    for(int i=0;i<s.size();i++){
        for(int j=0;j<t.size();j++){
            if(s.at(i)<t.at(j)){
                cout << "Yes";
                return 0;
            }
            if(s.at(i)==t.at(j)){
                onazi++;
            }
        }
    }
    if(s.size()<t.size()&&s.size()*t.size()==onazi){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256