akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;


public class Main {
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int r,g,b;
        r = sc.nextInt();
        g = sc.nextInt();
        b = sc.nextInt();
        if((r * 100 + g * 10 + b) % 4 == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line = br.readLine();
    Integer i = Integer.parseInt(line);

    System.out.println(i * i * i);
  }
}

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

int main() {
	string s;
	int q;
	cin >> s >> q;
	string first = "", end = "";
	int r = 0;
	for (int i = 0; i < q; i++)
	{
		int query; cin >> query;
		if(query == 1) {
			r = (r + 1) % 2;
		}
		else {
			int f; char c;
			cin >> f >> c;
			f--;
			if(r != f) {
				end.push_back(c);
			}
			else first.push_back(c);
		}
	}

	if(r) {
		reverse(end.begin(), end.end());
		reverse(s.begin(), s.end());
		cout << end << s << first << endl;
	}
	else {
		reverse(first.begin(), first.end());
		cout << first << s << end << endl;
	}
	return 0;
}


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

const int maxn = 1e5+100;
char s[maxn];

int main()
{
    while (scanf("%s",s)!=EOF)
    {
        int l = strlen(s);
        int k = 0, ans = l;
        for (int i = 1; i < l; ++i)
            if (abs(s[i-1] - s[i]) == 1)
            {
                k = max(i,l-i);
                ans = min(ans,k);
            }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

ll l[MAXN];
int main(void)
{
    ll w,h,x,y;
    scanf("%ld %ld %ld %ld",&w,&h,&x,&y);

    printf("%.10g ",(double)(w*h)/2.0);
    printf("%d\n",x*2==w&&y*2==h?1:0);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = 1e15;

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

    int n;cin>>n;
    vector<ll> a(n),sum(n,0);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i==0) sum[i]=a[i];
        else sum[i]=sum[i-1]+a[i];
    }
    ll res=1e15;
    for(int i=2;i<=n-2;i++){
        ll mid=sum[i-1];
        ll pre,post;
        ll low1,low2,low3,low4,high1,high2,high3,high4;
        auto itr=lower_bound(sum.begin(),sum.begin()+i,mid/2);
        post=mid-*itr;pre=*itr;
        low1 = min(pre, post);
        high1 = max(pre,post);
        
        low2=INF;high2=INF;
        if(itr!=sum.begin()){
            itr--;
            post=mid-*itr;pre=*itr;
            low2 = min(pre, post);
            high2 = max(pre,post);
        }

        mid = mid + (sum[n-1]-sum[i-1])/2;
        auto itr2=lower_bound(sum.begin()+i, sum.end(),mid);
        pre=(*itr2)-sum[i-1];post=sum[n-1]-(*itr2);
        low3=min(pre,post);
        high3=max(pre,post);

        low4=INF;high4=INF;
        if(itr2!=sum.begin()+i){
            itr2--;
            pre=(*itr2)-sum[i-1];post=sum[n-1]-(*itr2);
            low4 = min(pre, post);
            high4 = max(pre,post);
        }

        ll high,low;

        high=max(high1,high3);
        low=min(low1,low3);
        res=min(res,high-low);

        if(high4!=INF){
            high=max(high1,high4);
            low=min(low1,low4);
            res=min(res,high-low);
        }
        
        if(high2!=INF){
            high=max(high2,high3);
            low=min(low2,low3);
            res=min(res,high-low);
        }
        
        if(high2!=INF && high4!=INF){
            high=max(high2,high4);
            low=min(low2,low4);
            res=min(res,high-low);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3456
S = int(input())
lim = 10 ** 9

import math
y3 = math.ceil(S / lim)
x3 = lim * y3 - S

# print(lim * y3 - 1 * x3)

ans = list(map(str, [0, 0, lim, 1, x3, y3]))
print(' '.join(ans))



Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include<unordered_map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)
#define INF 1000000010
const int mo=1e9+7;

map<ll,ll> mp;

inline ll f(ll x)
{
    if(mp[x])return mp[x];
    return mp[x]=(f(x/2)+f((x-1)/2)+f((x-2)/2))%mo;
}
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n;
    cin>>n;
    mp[0]=1;
    mp[1]=2;
    printf("%lld\n",f(n));
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = Math.floor(Math.sqrt(a.toDouble())).toInt()
    var ans = a
    for (i in 1..b) {
        if (a % i == 0L && i + a / i - 2 < ans) ans = i + a / i - 2
    }
    println(ans)
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(rall(a));
  ll ans = 0;
  priority_queue<int> q;
  q.push(a[0]);
  REP(i,n) {
    ans += q.top();
    q.pop();
    q.push(a[i]);
    q.push(a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5040
import sys
input = sys.stdin.readline
from collections import *

def factorize(n):
    fct = []
    
    for i in range(2, int(n**0.5)+1):
        c = 0
        
        while n%i==0:
            n //= i
            c += 1
            
        if c>0:
            fct.append((i, c))
    
    if n>1:
        fct.append((n, 1))
    
    return fct

N = int(input())
fct = factorize(N)
ans = 0

for _, c in fct:
    sub = 1
    
    while c-sub>=0:
        c -= sub
        ans += 1
        sub += 1

print(ans)

Measured memory_bytes: 66352
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,i,j;
	string a,b;
	cin>>n>>a>>b;
	ll mx=0,cnt=0;
	for(i=0;i<n;i++){
		ll f=0;cnt=0;
		for(j=i;j<n;j++){
			if(a[j]!=b[j-i])f=1;
			else cnt++;
		}
		if(n-i==cnt&&!f)mx=max(mx,cnt);
	}
	cout<<2*n-mx;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
#include <fstream>
using namespace std;
vector<ll> adj[100005];
ll vis[100005];
stack<ll> st;
void dfs(ll x)
{
    vis[x]=1;
    for(ll i=0;i<adj[x].size();i++)
        if(!vis[adj[x][i]])
        dfs(adj[x][i]);
    st.push(x);
}
int main()
{
    //  freopen("timber_input.txt", "r", stdin);
   // freopen("out3_test.txt", "w", stdout);
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--) {
    ll n,m,i,j;
    cin>>n>>m;
    char arr[n+1][m+1];
    ll dp[n+1][m+1];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
        cin>>arr[i][j];
    dp[0][0]=1;
    for(i=1;i<n;i++)
        if(arr[i][0]=='#')
        dp[i][0]=0;
    else
        dp[i][0]=dp[i-1][0];
    for(i=1;i<m;i++)
        if(arr[0][i]=='#')
        dp[0][i]=0;
    else
        dp[0][i]=dp[0][i-1];
    for(i=1;i<n;i++)
        for(j=1;j<m;j++)
        if(arr[i][j]=='#')
        dp[i][j]=0;
    else
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%hell;
    cout<<dp[n-1][m-1];
    }

}


Measured memory_bytes: 14744
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int n, m, s;
    while (cin >> n >> m >> s, n) {
        double dp[n+1][n*m+1];
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        rep(i, n) {
            rep(j, n*m+1) {
                if (dp[i][j] > EPS) {
                    Rep(k, m+1) {
                        dp[i+1][j+k] += dp[i][j] / m;
                    }
                }
            }
        }
        double ans = 0;
        rep(i, n*m+1) {
            ans += dp[n][i] * ((i - s > 0) ? i-s : 1);
        }
        printf("%.10lf\n", ans);
    }

    return 0;
}

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

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

  vector<int> arr(c);

  for (int i=0;i < c ;i++)
    cin >> arr[i];

  int a = -1; 
  int b = -1;
  for (int i = 0;i < c - 1 ;i++){
    if (arr[i] > arr[i + 1]) {
      if (a < 0)
        a = i;
      else if (b < 0)
        b = i + 1;
    }
    if (a >= 0 && b >= 0){
      swap(arr[a], arr[b]);
      break;
    }
  }

  for (int i = 0;i < c - 1 ;i++){
    if (arr[i] > arr[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 256
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,itertools
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    l,r,d = invr()
    c = 0
    for i in range(l,r + 1):
        if i % d == 0:
            c = c + 1
    print(c)
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

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

using namespace std;

int main(){
    int a, b, c;
    while(cin >> a >> b >> c){
        int parts[a+b+c+1];
        for(int i=0; i< a+b+c+1; i++) parts[i] = 2;
        int n;
        cin >> n;
        vector<vector<int> >info;
        for(int i=0; i < n; i++){
            int p, q, r, s;
            cin >> p >> q >> r >> s;
            if(s == 1){parts[p] = 1; parts[q] = 1; parts[r] = 1;}
            else {
                vector<int> v;
                v.push_back(p); v.push_back(q); v.push_back(r);
                info.push_back(v);
            }
        }
        for(int i=0; i< info.size(); i++){
            int count = 0;
            for(int j=0; j < 3; j++) if(parts[info[i][j]] == 1) count++;
            if(count == 2) for(int j=0; j< 3; j++) if(parts[info[i][j]] == 2) parts[info[i][j]] = 0;
        }
        for(int i=1; i<= a+b+c; i++) cout << parts[i] << endl;
    }
}

Measured memory_bytes: 1288
using System;
class p
{
  static void Main()
  {
    string s1 = Console.ReadLine();
    string s2 = Console.ReadLine();
    Console.WriteLine(((s1[0] == s2[2]) && (s1[1] == s2[1]) && (s1[2] == s2[0])) ? "YES" : "NO");
  }
}

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

const int MOD = 1e9+7;

int r1, r2, c1, c2;

long long ksm(long long x,long long y)
{
	x %= MOD;
	long long rt = 1LL;
	while ( y )
	{
		if ( y & 1 )
			rt = rt * x % MOD;
		x = x * x % MOD;
		y >>= 1;
	}
	return rt;
}

int C(int n,int m)
{
	if ( n < m )
		return 0;
	long long rt = 1LL;
	for ( int i = 0 ; i < m ; i++ )
		rt = rt * (long long)(n-i) % (long long)MOD * ksm(i+1,MOD-2) % (long long)MOD;
	return (int)rt;
}

int u(int x,int y)
{
	return C(x+y,min(x,y));
}

int s(int x,int y)
{
	return u(y+1,x+1)-1;
}

int main()
{
	scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
	printf("%d",(s(r2,c2)-s(r2,c1-1LL)-s(r1-1LL,c2)+s(r1-1LL,c1-1LL)+MOD)%MOD);
	printf("\n");
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int gcd(int a, int b){
  if(a==1 || b==1)return 1;
  if (a < b)swap(a,b);
  
  return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b){
  return a * b / gcd(a, b);
}

int main(){
  int x;cin>>x;
  cout<<lcm(x, 360)/x<<endl;

  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int MAXN=1e5+5;
int n;
int a[MAXN],b[MAXN],c[MAXN];

int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&b[i]);
        }
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&c[i]);
        }
        sort(a+1,a+n+1);
        sort(b+1,b+n+1);
        sort(c+1,c+n+1);
        LL ans=0;
        for(int i=1;i<=n;i++)
        {
            LL p=lower_bound(a+1,a+n+1,b[i])-a;
            p--;
            LL q=upper_bound(c+1,c+n+1,b[i])-c;
            ans+=p*(n-q+1);
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class DTeleporter {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,k;
        in>>n>>k;
        vector<int> a(n);
        for(auto&i:a) in>>i,--i;
        int ans=0;
        if(a[0]) ++ans,a[0]=0;
        vector<int> h(n),d(n);
        queue<int> q;
        Fr(i,n-1) ++h[a[i]];
        fr(i,n) if(!h[i]) q.push(i);
        while(!q.empty()){
            int p=q.front();q.pop();
            if(d[p]==k-1&&a[p]!=0) ++ans,d[p]=-1;
            d[a[p]]=max(d[a[p]],d[p]+1);
            if(!--h[a[p]]) q.push(a[p]);
        }
        out<<ans<<endl;
    }
};

int main() {
    DTeleporter solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1920
n = int(input())
ls = []
for i in range(1,10):
    for j in range(1,10):
        a = i * j
        ls.append(a)
b = 0
for u in ls:
    if n == u:
        b += 1    
    else:
        continue
if b > 0:
    print("Yes")
else:
    print("No")


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

int main(){
  string S;
  cin >> S;
  int s=S.size(),ans=0;
  for(int i=0;i<s;i++){
    if(S[i]=='x')
      ans++;
  }
  if(ans<8)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  
  int a,b,i,d;
  
  while(1){
  scanf("%d %d",&a,&b);
if(a==0 && b==0)break;
  
  for(i=0;i<a;i++){
 
    for(d=0;d<b;d++)
{
    printf("#");
  } 
  printf("\n");
  
   
  }
  printf("\n");
  }
   
  
  return 0;
  }
 




 




  

 



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;


int32_t main() {

    fast

    int n,d;
    cin>>n>>d;

    int ans=0;

    int x,y;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d)ans++;
    }
    cout<<ans;



    return 0;
}



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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int x;
    cin >> x;

    for (int b = -300; b <= 300; b++) {
        for (int a = -300; a <= 300; a++) {
            int one = pow(abs(a), 5);
            int two = pow(abs(b), 5);

            if (a < 0)one *= -1;
            if (b < 0)two *= -1;

            int ans = one - two;
            if (ans == x) {
                cout << a << " " << b << endl;
                return;
            }
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 4080
import java.util.*;

class Graph2 {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph2() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int v;
		for(i = 0; i < totalVertex; i ++) {
			for(j = 0; j < totalVertex; j ++) {
				v = in.nextInt(); 
				if(v == -1) {
					adjMatrix[i][j] = 0;
					adjWeight[i][j] = 0;
				}
				else {
					adjMatrix[i][j] = 1;
					adjWeight[i][j] = v;
				}
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] MST(int s) {
		
		int[] dist = new int[totalVertex];
		for(int i = 0; i < totalVertex; i++) {
			dist[i] = Integer.MAX_VALUE;
		}
		dist[s] = 0;
		
		int curr = getUnsettledNearest(dist);
		
		while(Arrays.asList(ifSettled).contains(false) && dist[curr] != Integer.MAX_VALUE) {
			
			ifSettled[curr] = true;
			LinkedList<Integer> neighbor = getUnsettledNeighbors(curr);
			for(Integer n: neighbor) {
				dist[n] = Math.min(dist[n], getWeight(curr, n));
			}
			curr = getUnsettledNearest(dist);
			
		}
		
		return dist;
	}
	
}

public class Main {
	public static void main(String[] argv) {
		Graph2 g = new Graph2();
		g.loadAdjMatrix();
		int[] dist = g.MST(0);
		int tot = 0;
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			tot = tot + dist[i];
		}
		System.out.println(tot);
	}
}


Measured memory_bytes: 40996
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	x <- readInt
	-- 360 / x = res
	-- 360 = x res
	print $ head $ do
		i <- [ 1 .. 360 ]
		guard $ i * x `mod` 360 == 0
		return i

Measured memory_bytes: 3872
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();

		int[][] list1 = new int[a][b];
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				list1[i][j] = scanner.nextInt();
			}
		}
		int[][] list2 = new int[b][c];
		for (int i = 0; i < b; i++)
			for (int j = 0; j < c; j++)
				list2[i][j] = scanner.nextInt();

		for (int i = 0; i < a; i++) {
			for (int j = 0; j < c; j++) {
				long sum = 0;
				for (int k = 0; k < b; k++) {
					sum += list1[i][k] * list2[k][j];
				}
				if (j == 0)
					System.out.print(sum);
				else
					System.out.print(" " + sum);
			}
			System.out.println();
		}

	}
}



Measured memory_bytes: 53684
<?php
fscanf(STDIN,"%d",$n);
fscanf(STDIN,"%d",$k);
fscanf(STDIN,"%d",$x); 
fscanf(STDIN,"%d",$y); 

$sum=0;
if($n<=$k){
  $sum=$x*$n;
}elseif($n>$k){
  $sum=$x*$k+$y*($n-$k);
}
echo $sum;
?>

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define debug(x) cerr<<#x<<' '<<x<<'\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int jc[10];
bool vis[10];
set<int> s;
void dfs(int now,int n,int x) {
    if(now==n+1) {
        s.insert(x);
        return ;
    }
    rep(i,1,n) {
        if(!vis[i]) {
            vis[i]=true;
            dfs(now+1,n,x*10+i);
            vis[i]=false;
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    dfs(1,n,0);
    int a=0,b=0;
    rep(i,1,n) {
        char c;
        cin>>c;
        a=a*10+c-'0';
    }
    rep(i,1,n) {
        char c;
        cin>>c;
        b=b*10+c-'0';
    }
    int pos1=0,pos2=0,now=0;
    for(auto x:s) {
        if(x==a) pos1=now;
        if(x==b) pos2=now;
        now++;
    }
    cout<<abs(pos1-pos2)<<'\n';
    return 0;
}



Measured memory_bytes: 2176
x1,y1,x2,y2 = [int(i) for i in input().split()]
x3 = x2 + y1 - y2
y3 = y2 + x2 - x1
x4 = x1 - x2 + x3
y4 = y3 + y1 - y2
print(x3,y3,x4,y4)

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

int tanri(int, int, double, int);
int fukuri(int, int, double, int);

int main(){
  int m;

  cin >> m;

  for(int i=0;i<m;i++){
    int fund,years,n;
    cin >> fund >> years >> n;

    int max=0;

    for(int j=0;j<n;j++){
      int kind;
      double nenri;
      int tesuuryou;
      cin >> kind >> nenri >> tesuuryou;
      if(kind==0){
        if(max<tanri(years,fund,nenri,tesuuryou)) max = tanri(years,fund,nenri,tesuuryou);
      }else if(kind==1){
        if(max<fukuri(years,fund,nenri,tesuuryou))max = fukuri(years,fund,nenri,tesuuryou);
      }
    }
    cout << max << endl;
  }

  return 0;
}

int tanri(int years, int fund, double nenri, int tesuuryou){
  int ans=0;
  int rishi = 0;
  for(int i=0;i<years;i++){
    rishi += fund * nenri;
    fund -= tesuuryou;  
  }
  return ans = rishi + fund;
}

int fukuri(int years, int fund, double nenri, int tesuuryou){
  int ans=0;
  int rishi=0; 
  for(int i=0;i<years;i++){
    rishi = fund * nenri;
    fund += rishi - tesuuryou;
  }

  return ans = fund;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

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

  ll a = 0;
  for (ll i = 1; i < n + 1; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    a += i;
  }

  cout << a << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int n,m,i,j,k;
int num,id,cnt;

char A[10];
char B[10];
char tmp;

int flg[1001];

int main(){
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0)break;
    
    for(i=1;i<=n;i++)flg[i]=0;
    id=1;
    cnt=n;
    
    for(i=1;i<=m;i++){

      if(i%15==0){
        strcpy(A,"FizzBuzz");
      }else if(i%5==0){
        strcpy(A,"Buzz");
      }else if(i%3==0){
        strcpy(A,"Fizz");
      }else{
        j=0;
        sprintf(A,"%d",i);
        
        /*
        while(num>0){
          A[j]=num%10+'0';
          j++;
          num/=10;
        }
        for(k=0;k<j/2;k++){
          tmp=A[k];
          A[k]=A[j-1-k];
          A[j-1-k]=tmp;
        }
        A[j]='\0';
        */
      }
      
      scanf("%s",B);
      
      if(cnt==1)continue;

      if(strcmp(A,B)!=0){
        flg[id]=1;
        cnt--;
      }
      
      while(1){
        id++;
        if(id==n+1)id=1;
        if(flg[id]==0)break;
      }
      
    }
    
    j=0;
    for(i=1;i<=n;i++){
      if(flg[i]==0){
        if(j!=0)printf(" ");
        j=1;
        printf("%d",i);
      }
    }
    printf("\n");
    
  }
  return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int main(void)
{
  int i, num,jud=0;
  scanf("%d",&num);
  for(i=0;i<=6;i++)
  {
    if(num>=4*i && (num-4*i)%7==0) jud=1;
  }
  if(jud==0) printf("No");
  else printf("Yes");
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll a, b, c; cin >> a >> b >> c;
    if(a == 0 && b == 0){
        cout << 1 << endl;
        return 0;
    }else if(a == 0){
        cout << b/c +1 << endl;
        return 0;
    }
    a--;
    cout << b/c - a/c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

bool isPrime(int N)
{
    if(N<2) return false;
    for(int i=2;i*i<=N;i++){
        if(N%i==0) return false;
    }
    return true;
}

signed main()
{
    int N; cin>>N;
    vint cnt(N+1);
    for(int i=2;i<=N;i++){
        if(isPrime(i)){
            for(int j=i;j<=N;j*=i){
                cnt[i]+=N/j;
            }
        }
    }

    int ans=0;
    REP(i,N+1){
        if(cnt[i]>=74) ans++;
    }
    REP(i,N+1) REP(j,N+1){
        if(i==j) continue;
        if(cnt[i]>=2 and cnt[j]>=24) ans++;
        if(cnt[i]>=4 and cnt[j]>=14) ans++;
    }
    REP(i,N+1) REP(j,N+1) REP(k,N+1){
        if(i==j or j==k or i==k) continue;
        if(cnt[i]>=2 and cnt[j]>=4 and cnt[k]>=4 and j<k) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    H, W = input_nums()
    h, w = input_nums()
    total = H*W
    print(total - (h*W + w*H - h*w))

if __name__ == '__main__':
    main()


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

int main() {
	int N=0; //num of friends
	int M=0; //how many times the game was held
	int A[100]={};//indicates target of M
	int B[100][100]={{}}; //friends votes 
	int C[100]={}; //to keep track of friends scores
	
	cin>> N >> M;
	
	
	
	
	
	for(int i=0;i<M;i++){
	cin >> A[i];
	}
	
	for(int x=0;x<M;x++){
		for(int y=0;y<N;y++){
			cin >>B[x][y];
		}
	}
	
	
	
	for(int z1=0;z1<M;z1++){ //z1??????
		for(int z2=0;z2<N;z2++){ //z2??????
		
			if(B[z1][z2]==A[z1]){
				C[z2]++;
			}else{
				C[A[z1]-1]++;
			}
		
		}
	}
	
	for(int f=0;f<N;f++){
		cout <<C[f]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main(){
  int N,i,L[200],ans=0;
  scanf("%d",&N);
  for(i=0;i<2*N;i++)scanf("%d",&L[i]);
  qsort(L, 2*N, sizeof(int), compare_int);
  for(i=0;i<N;i++)ans+=L[i*2+1];
  printf("%d\n",ans);
}

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

int main(){
	long long n,ans=0,sum=0;
	cin >> n;
	long long x[n];
	for(int i = 0 ; i < n ; i += 1){
		cin >> x[i];
		if(x[i] <= 0){
			sum ^= 1;
		}
	}
	if(sum){
		long long maxi = 1000000000;
		for(int i = 0 ; i < n ; i += 1){
			ans += abs(x[i]);
			maxi = min(maxi,abs(x[i]));
		}
		cout << ans - 2*maxi;
	}else{
		for(int i = 0 ; i < n ; i += 1){
			ans += abs(x[i]);
		}
		cout << ans;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	string S;
	int N;
	cin >> N >> S;
	int x = 0;
	vector<int> data{0};
	vector<string> vec(N);
	for (int i = 0; i < N; i++) {
		vec.at(i) = S.at(i);
	}
	for (int j = 0; j < N; j++) {
		if (vec.at(j) == "I") {
			x++;
			data.push_back(x);
		}
		else if (vec.at(j) == "D") {
			x--;
			data.push_back(x);
		}
	}
	sort(data.begin(), data.end());
	cout << data.at(N) << endl;
}

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

void solve(long long K, long long X){
    for (int i=X-K+1; i<X+K; ++i){
        if (i == X+K-1)
            printf("%d", i);
        else
            printf("%d ", i);
    }
}

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


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
b = a
while(1):
    c = [b[0]]
    for i in range(1,len(b)):
        if b[i] % b[0]:
            c.append(b[i]%b[0])
    b = sorted(c)
    if len(b) == 1:
        print(b[0])
        exit()

Measured memory_bytes: 14252
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

L = [a+i for a, i in enumerate(A, 1)]
R = [a-i for a, i in enumerate(A, 1)]

ans = 0
R_c = Counter(R)
for l in L:
    ans += R_c[l]

print(ans)

Measured memory_bytes: 50544
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  int K;
  cin >> K;
  string t(s);
  sort(all(t));
  t.erase(unique(all(t)), t.end());
  set<string> v;
  for (char c = 'a'; c <= 'z'; c++) {
    if (v.size() >= K) {
      break;
    }
    rep(i, 0, s.size()) {
      if (s[i] == c) {
        int j = i;
        string tmp;
        int cnt=0;
        while (j < s.size() and cnt++<5) {
          tmp.push_back(s[j++]);
          v.insert(tmp);
        }
      }
    }
  }
  auto it = v.begin();
  loop(K - 1) it = next(it);
  cout << *it << endl;

  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 4 * 1000 * 100 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, x, y;
PII A[MAX];
LL F[MAX];
LL FR[MAX];
map<int, int> mapp;
int C[MAX];
int P[MAX];

LL bp(LL a, int n)
{
	LL res = 1;
	while (n)
	{
		if (n & 1) res = (res * a) % MOD;

		a = (a * a) % MOD;
		n >>= 1;
	}

	return res;
}

LL inv(LL a)
{
	return bp(a, MOD - 2);
}

struct DSU
{
	int P[MAX];
	multiset<int> S[MAX];
	void init()
	{
		FOR(i, 0, n)
		{
			P[i] = i;
			S[i].insert(A[i].second);
		}
	}

	int getParent(int v)
	{
		if (P[v] == v) return v;
		return P[v] = getParent(P[v]);
	}

	void unionSet(int a, int b)
	{
		a = getParent(a);
		b = getParent(b);

		if (a == b) return;
		if (SZ(S[a]) < SZ(S[b])) swap(a, b);

		for (auto i = S[b].begin(); i != S[b].end(); i++)
		{
			S[a].insert(*i);
		}

		P[b] = a;
	}

	LL calc()
	{
		LL ans = 1;
		FOR(i, 0, n)
		{
			if (P[i] != i) continue;

			LL all = SZ(S[i]);
			LL res = F[all];
			mapp.clear();
			for (auto it = S[i].begin(); it != S[i].end(); it++)
			{
				mapp[*it]++;
			}

			for (auto it = mapp.begin(); it != mapp.end(); it++)
			{
				res = (res * FR[it->second]) % MOD;
			}

			ans = (ans * res) % MOD;
		}

		return ans;
	}
} D;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);

	F[0] = FR[0] = 1;
	FOR(i, 1, MAX)
	{
		F[i] = (F[i - 1] * i) % MOD;
		FR[i] = inv(F[i]);
	}

	cin >> n >> x >> y;
	FOR(i, 0, n)
	{
		cin >> A[i].second >> A[i].first;
	}

	sort(A, A + n);
	FILL(C, -1);
	FOR(i, 0, n)
	{
		int c = A[i].second;
		P[i] = C[c];
		if (C[c] == -1) C[c] = i;
	}

	int p = -1;
	FOR(i, 0, n)
	{
		if (A[i].second != A[0].second)
		{
			p = i;
			break;
		}
	}

	D.init();
	FOR(i, 1, n)
	{
		if (A[i].second == A[0].second)
		{
			if (A[i].first + A[0].first <= x)
			{
				D.unionSet(0, i);
			}

			if (p != -1 && A[i].first + A[p].first <= y)
			{
				D.unionSet(p, i);
			}

			continue;
		}

		if (A[i].first + A[0].first <= y)
		{
			D.unionSet(i, 0);
		}

		if (P[i] != -1 && A[i].first + A[P[i]].first <= x)
		{
			D.unionSet(i, P[i]);
		}
	}

	LL ans = D.calc();
	cout << ans << endl;
}

Measured memory_bytes: 46848
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A;
    ll x[55];
    cin >> N >> A;
    rep(i,0,N){
        cin >> x[i];
        x[i] -= A;
    }
    ll dp[55][5010] = {}; // i枚目までみたときの平均がn
    ll pad = 2500;
    dp[0][pad] = 1;
    rep(i,0,N){
        rep(n,0,5001){
            dp[i+1][n] += dp[i][n];
            if(n - x[i] >= 0){
                dp[i+1][n] += dp[i][n-x[i]]; 
            }
        }
    }
    print(dp[N][pad]-1);


}


Measured memory_bytes: 2432
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

typedef long long lint;
constexpr lint inf = (1ll << 60);

int N, X, Y;
int A[5000];
lint dp[5001][5001];

int main() {

    cin >> N >> X >> Y;
    rep(i, N) cin >> A[i];

    rep(i, 1, N) rep(j, 0, N) dp[i][j] = inf;

    rep(i, N) {
        rep(j, 0, N) {
            if(j < A[i]) {
                chmin(dp[i + 1][j], dp[i][j] + X);
                chmin(dp[i + 1][A[i]], dp[i][j]);
            }
            if(j > A[i]) {
                chmin(dp[i + 1][j], dp[i][j] + Y);
            }
        }
    }

    lint ans = inf;
    rep(i, 0, N) chmin(ans, dp[N][i]);
    cout << ans << '\n';

}


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

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  rep(i, n) cin >> x[i];

  ll ans = 0;
  rep(i, n){
    ans += min(x[i]*2, abs(x[i] - k)*2);
  }
  cout << ans << endl;
  return 0;
}


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

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main() {
  int n,x,ans,d;
  cin>>x>>n;
  d=x;
  ans=0;
  vi a(200);
  rep(i,200)a.at(i)=i+1;
  
  rep(i,n){
      int k;
      cin>>k;
      a.at(k-1)=1000;
  }
    rep(i,200){
        if(d>abs(x-a.at(i))){
            d=abs(x-a.at(i));
            ans=i+1;
        }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
import collections as cl
import sys
import math


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


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


class Logs():
    def __init__(self, K, logs):
        self.K = K
        self.logs = logs

    def canCutUnderX(self, X):
        times = 0
        for log in self.logs:
            time = math.floor(log/X)
            if log % X == 0:
                time -= 1
            times += time
            if times > self.K:
                return False

        return True

    def solve(self):
        ans = self.nibutan(0, max(self.logs))
        return ans

    def nibutan(self, l, r):
        if l + 1 == r:
            return r
        c = (l + r) // 2

        if self.canCutUnderX(c):
            return self.nibutan(l, c)
        else:
            return self.nibutan(c, r)


def main():
    _, K = MI()
    logs = LI()

    solver = Logs(K, logs)
    print(solver.solve())


main()


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

int main(){
  int a,b;
  char op;
  while (1)
  {
    cin >> a >> op >> b;
    if (op == '?') break;

    if (op == '+')
    {
      cout << a+b << endl;
    }
    else if (op == '-')
    {
      cout << a-b << endl;
    }
    else if (op == '*')
    {
      cout << a*b << endl;
    }
    else if (op == '/')
    {
      cout << a/b << endl;
    }    
  }
  return 0;
}


Measured memory_bytes: 3068
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    s = insr()
    q = sum([int(s[i]) for i in range(len(s))])
    if q % 9 == 0:
        print("Yes")
    else:
        print("No")
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)
#-----------------------------------------------------------------------#
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 86008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
int h,w,m;
int main(void)
{
    cin>>h>>w>>m;
    vector<pair<int,int> > vx,vy;
    for(int i=0;i<h;++i) vx.push_back(make_pair(0,i));
    for(int i=0;i<w;++i) vy.push_back(make_pair(0,i));
    set<pair<int,int> > se;
    for(int i=0;i<m;++i)
    {
        int a,b;
        cin>>a>>b;
        a--,b--;
        vx[a].first++;
        vy[b].first++;
        se.insert(make_pair(a,b));
    }
    sort(vx.begin(),vx.end(),[](const pair<int,int> a,const pair<int,int> b){return a.first>b.first;});
    sort(vy.begin(),vy.end(),[](const pair<int,int> a,const pair<int,int> b){return a.first>b.first;});
    int ans=0;
    for(int i=0;i<h;++i)
        for(int j=0;j<w;++j)
        {
            int c=se.count(make_pair(vx[i].second,vy[j].second));
            ans=max(ans,vx[i].first+vy[j].first-c);
            if(c==0) break;
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 21904