akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
const int mod = 1e9+7;
typedef long long ll;
int N;
vector<int> ady[maxn];
int dp[maxn][2];
void solve(int nodo,int p){
    ll x,y;
    x = y = 1;
    dp[nodo][0] = dp[nodo][1] = 1;
    for(int i : ady[nodo]){
        if (i != p){
            solve(i,nodo);
            x*=(dp[i][0]+dp[i][1]);
            x%= mod;
            y*=dp[i][0];
            y%=mod;
        }
    }
    dp[nodo][0] = x;
    dp[nodo][1] = y;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for (int i = 1; i <N;i++){
        int a,b;
        cin >> a >> b;
        ady[a].push_back(b);
        ady[b].push_back(a);
    }
    solve(1,1);
    cout << (dp[1][0]+dp[1][1]) % mod;
    return 0;
}


Measured memory_bytes: 13440
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  int64_t n;
  cin >> n;

  vector<int64_t> as(n);
  int64_t sum = 0;
  for (auto &a : as) {
    cin >> a;
    sum += a;
  }

  int64_t c = (n + 1) * n / 2;

  if (sum % c != 0) {
    cout << "NO" << endl;
    return 0;
  }

  int64_t k = sum / c;

  vector<int64_t> ds(n);
  for (int i = 0; i < n; i++) {
    ds[i] = as[(i + 1) % n] - as[i] - k;
  }

  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (!(ds[i] <= 0 && ds[i] % n == 0))
      ok = false;
  }

  cout << (ok ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>
int main(){
  int n,i,c,ans=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&c);
    if(i%2==1&&c%2==1)ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1708
s = list(input())

if s[0] != "A":
  print("WA")
  exit()

count = 0
for i in range(1,len(s)):
  if s[i] == "C" and 2<= i and i<=len(s)-2:
    count += 1
  elif s[i].isupper():
     print("WA")
     exit()

if count == 1:
  print("AC")
else:
  print("WA")
    
    

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int> > a(n + 1, vector<int>(3));
    vector<vector<int> > dp(n + 1, vector<int>(3, 0));
    for (int i = 1; i <= n; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j < 3; ++j)
            for (int k = 0; k < 3; ++k)
                if (j != k) dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i][k]);

    cout << *max_element(dp[n].begin(), dp[n].end()) << '\n';
    return 0;
}



Measured memory_bytes: 11264
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n, a;
  vector<int> v;
  vector<pair<int, int> > p;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  for (int i = 1; i < n - 1; i++) {
    if (v[i] > 0) {
      p.push_back({v[0], v[i]});
      v[0] -= v[i];
    } else {
      p.push_back({v[n - 1], v[i]});
      v[n - 1] -= v[i];
    }
  }
  p.push_back({v[n - 1], v[0]});
  v[n - 1] -= v[0];
  cout << v[n - 1] << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << p[i].first << " " << p[i].second << endl;
  }
}

Measured memory_bytes: 3188
import sys

# N
n = int(input())

res = n

for i in range(n+1):
    cc = 0
    t = i
    while(t > 0):
        cc += t % 6
        t //= 6
    t = n - i
    while(t > 0):
        cc += t % 9
        t //= 9
    if (res > cc):
        res = cc
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double acc = 1e-6;
main(){
    double l;
    cin >> l;

    double ans = (l/3.0)*(l/3.0)*(l/3.0);
    //cout << ans << endl; 
    printf("%0.12lf\n",ans) ;
}

Measured memory_bytes: 256
<?php   
fscanf(STDIN,"%s",$s);
fscanf(STDIN,"%s",$t);

//$li = explode(" ",trim(fgets(STDIN)));
	

for($i=0;$i<strlen($s);$i++){
  if($s[$i]!=$t[$i]){
    echo "No\n";
    exit;
  }
       
}
        
echo "Yes\n";



Measured memory_bytes: 16196
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int S[100010],T[50010],n,q;
int binarysearchS(int left,int right,int t)
{
	if(left>right)
		return 0;
	int mid;
	mid=left+right;
	mid/=2;
	if(S[mid]==t)
		return 1;
	if(S[mid]>t)
		return binarysearchS(left,mid-1,t);
	return binarysearchS(mid+1,right,t);
}
int main()
{
	int C=0,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&S[i]);
	scanf("%d",&q);
	for(i=1;i<=q;i++)
		scanf("%d",&T[i]);
	for(i=1;i<=q;i++)
		C+=binarysearchS(1,n,T[i]);
	printf("%d\n",C);
	return 0;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int gcd(int a, int b) {
	if(b > a) return gcd(b,a);
	if(b==0) return a;
	return gcd(b, a % b);
}

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int x;
	cin >> x;
	int a = gcd(x, 360);
	cout << (360 / a) << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	int c=a/b;
	if(c==0)
	{
		printf("1");
	}
	else if(a%b==0)
	{
		printf("%d",c);
	}
	else
	{
		printf("%d",c+1);
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define N 1299710

int main(int argc, char const *argv[])
{
	int n;
	int p1,p2;

	bool f[N];

	for(int i1=0;i1<N;i1++) f[i1]=false;

	f[0]=true;
	f[1]=true;
	for(int i1=0;i1<N;i1++){
		if(f[i1]==false){
			for(int i2=2;i2*i1<N;i2++){
				f[i2*i1]=true;
			}
		}
	}

	while(1){
		cin>>n;
		if(n==0) break;

		p1=n;
		while(f[p1]==true) p1--;
		p2=n;
		while(f[p2]==true) p2++;

		cout<<p2-p1<<endl;

	}
	return 0;
}

Measured memory_bytes: 2428
e=enumerate
n,a=open(0)
a=sorted((int(i),j)for j,i in e(('0 '+a).split()))[::-1]
c=[0]*int(n)
t=10**18
for k,(i,j)in e(a[:-1],1):
  t=min(t,j)
  c[t-1]+=(i-a[k][0])*k
print(*c)

Measured memory_bytes: 68196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  ll x, y;
  cin >> s >> x >> y;
  s.push_back('T');
  vl a, b;
  ll cnt = 0;
  bool t = false;
  rep(i, s.size()) {
    if(s[i] == 'F')
      cnt++;
    else {
      if(t)
        b.push_back(cnt);
      else
        a.push_back(cnt);
      cnt = 0;
      t = !t;
    }
  }
  bool ans = true;
  ll geta = 8010;
  rep(q, 2) {
    ll n = a.size();
    bool dp[n + 1][16020] = {};
    rep(i, n + 1) rep(j, 16020) dp[i][j] = false;
    dp[0][geta] = true;
    rep(i, n) rep(j, 16020) {
      if(!dp[i][j]) continue;
      dp[i + 1][j + a[i]] = true;
      if(q == 1 || i != 0) dp[i + 1][j - a[i]] = true;
    }
    if(!dp[n][x + geta]) ans = false;
    swap(x, y);
    swap(a, b);
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 65848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,sx,sy;
ll mod=1e9+7;
ll x[200000],y[200000];
int main(){
    cin>>n>>m;
    for(ll i=1;i<=n;i++) cin>>x[i];
    for(ll i=1;i<=m;i++) cin>>y[i];
    for(ll i=1;i<=n;i++){
        sx+=((i-1)*x[i]-(n-i)*x[i])%mod;
        sx%=mod;
    }
    for(ll i=1;i<=m;i++){
        sy+=((i-1)*y[i]-(m-i)*y[i])%mod;
        sy%=mod;
    }
    cout<<sx%mod*sy%mod<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int tmp = 0, ans = 0;
  char c;
  
  for(int i = 0; i < n; i++){
    cin >> c;
    if(c == 'I') tmp++;
    else tmp--;
    if (tmp > ans) ans = tmp;
  }
  
  cout << ans;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

typedef pair<int, int> P; 


int main(){
    string s, t;
    int a, b;
    cin >> s >> t >> a >> b;
    string u;
    cin >> u;
    if(s == u) {
        cout << a-1 << " " << b << endl;
    } else {
        cout << a << " " << b-1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
AB = [list(map(int, input().split())) for _ in range(3)]

g = [[] for _ in range(4)]
for a, b in AB:
	a, b = a - 1, b - 1
	g[a] += [b]
	g[b] += [a]

def dfs(v, p, visited=None):
	if None == visited:
		visited = [False] * 4
	visited[v] = True
	for n in g[v]:
		if visited[n]:
			continue
		if n == p:
			continue
		return dfs(n, v, visited)
	return all(visited)

#print([dfs(x, -1) for x in range(4)])
print(["YES", "NO"][not(any([dfs(x, -1) for x in range(4)]))])


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {
        int K = nextInt();
        int S = nextInt();

        long ret = 0L;
        for(int a = 0; a <= K; ++a) {
            for(int b = 0; b <= K; ++b) {
                if(a + b > S) continue;
                int left = S - ( a + b );
                if(left <= K) ++ret;
            }
        }
        writer.println(ret);
    }

    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("highcard.in"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("highcard.out");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 8404
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define mp map<ll,ll>
#define mpi map<ii,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#include <unordered_map> 
#define ump unordered_map<ll,ll>
int main()
{ 
	fast 
	ll sum=0,square=0;
	ll i;
	ll n;
	cin>>n;
	for(i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		sum=sum+x;
		square=square+x*x;
	}
	ll ans=(sum*sum)-square;
	ans=ans/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N,Alice,Bob;
  cin >> N;
  vector<int> a (N);
  for (int i = 0;i<N;i++)
    cin >> a.at(i);
  for (int i = 0; i<N; i++){
    int high=0,number=0;
    for (int l = 0;l < N ;l++){
      if (high < a.at(l)){
        high = a.at(l);
        number = l;
      }
    }
    if(i%2 == 0) Alice += high;
    else Bob += high;
    a.at(number) = 0;
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, rhom, rect;
	
	rhom = 0;
	rect = 0;
	
	while (scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if ((a * a) + (b * b) == (c * c)){
			rhom++;
		}
		if (a == b){
			rect++;
		}
	}
	
	printf("%d\n%d\n", rhom, rect);
	
	return (0);
}

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

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0 , 0 , -1 , 1 } ;
int dy4[] = { -1 , 1 , 0 , 0 } ;
bool valid( int r , int c , int x , int y ){
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ; return 0 ;}

using namespace std;

int main ()
{
    int n;
    cin >> n;
    int a[n+2];
    for(int i=0;i<n;i++)
        cin >> a[i];
    int cnt=0;
    int mx = 0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i]>=a[i+1])
        {
            cnt++;
        }
        else
        {
            mx= max(cnt,mx);
            cnt=0;
        }
    }
    cout << max(mx,cnt) <<endl;

    return 0;
}



Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c, d, p;
    cin >> a >>b >> c >> d >> p;
    int x=a*p;
    int y;
    if(p<=c)
        y=b;
    else
        y=b+d*(p-c);
    if(x>y)
        cout << y << endl;
    else 
        cout << x << endl;
}


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

long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
   
    
   int binomial(int n, int k)  
{  
    // Base Cases  
    if (k == 0 || k == n)  
        return 1;  
  
    // Recur  
    return binomial(n - 1, k - 1) + binomial(n - 1, k);  
}   

bool Sieve(ll int n) 
{ 
    
    bool prime[n+100000]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    return prime[n];
}
  
    
vector<long long> factor;  
vector<long long>prime(long long n) {
 for (long long d = 2; d * d <= n; d++) {
     while (n % d == 0) {
         factor.push_back(d);
            n /=d;
        }
    }
 if (n > 1)
    factor.push_back(n);
    return factor;
}




//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}


  
int main() {
       int a,v;
       int b,w;
       cin>>a>>v>>b>>w;
       int t;
       cin>>t;
       int o;
       if(v<=w)
       {
           cout<<"NO"<<endl;
       }
       else
       {
           int l=v-w;
           int p=abs(a-b);
           if(p%l==0)
           {
               o=p/l;
           }
           else
           {
              o=(p/l)+1;
           }
           if(o<=t)
           {
               cout<<"YES"<<endl;
           }
           else
           {
               cout<<"NO"<<endl;
           }
       }
}





Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2*n-1) {
		put("No");
		return 0;
	}
	vector<int> res(2 * n - 1);
	REP(i, 3) {
		res[n - 2 + i] = x - 1 + i;
	}
	vector<int> temp;
	FOR(i, 1, x - 1) {
		temp.push_back(i);
	}
	FOR(i, x + 2, 2 * n) {
		temp.push_back(i);
	}
	REP(i, n-2) {
		res[i] = temp[i];
	}
	REP(i, n-2) {
		res[i+n+1] = temp[i+n-2];
	}
	put("Yes");
  	REP(i,2*n-1)put(res[i]);
	return 0;
}


Measured memory_bytes: 3188
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	string st; cin >> st;
	vector<int>v(26);
	for (int i = 0; i < st.size(); i+=2) {
		v[st[i] - 'a']++;
	}
	map<int, int>mp;
	for (int i = 0; i < 26; ++i) {
		mp[v[i]]++;
	}
	int ans = 0;
	for (auto m : mp) {
		if (m.first == 1) {
			ans += 2*m.second;
		}
		else if (m.first >= 2) {
			if (m.second == 1)ans += 2 * (m.second + 1);
			else ans += 2 * (m.second + 2);
		}
	}
	ans--;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<long long > q;
  for(int i=0; i < n; i++){
    long long p; cin >> p;
    q.push(p);
  }
  for(int i=0; i < m; i++) {
    long long p = q.top();
    q.pop();
    q.push(p/2);
  }
  long long result = 0;
  for(int i=0; i < n; i++) {
    result += q.top();
    q.pop();
  }
  cout << result << endl;
}


Measured memory_bytes: 1400
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> field(h, vector<int>(w, 0));
	vector<vector<int>> answer;
	for (int y = 0; y < h; ++y) {
		for (int x = 0; x < w; ++x) {
			int a;
			cin >> a;
			field[y][x] = a;
		}
	}

	int cnt = 0;
	for (int y = 0; y < h; ++y) {
		if (y % 2 == 0) {
			for (int x = 0; x < w; ++x) {
				if (field[y][x] % 2 == 1) {
					if (x + 1 == w) {
						if (y == h - 1) break;
						vector<int> as = { y,x,y + 1,x };
						field[y + 1][x]++;
						answer.push_back(as);
					}
					else {
						vector<int> as = { y,x,y,x+1 };
						field[y][x+1]++;
						answer.push_back(as);
					}
				}
			}
		}
		else {
			for (int x = w - 1; x >= 0; --x) {
				if (field[y][x] % 2 == 1) {
					if (x==0) {
						if (y == h - 1) break;
						vector<int> as = { y,x,y+1,x};
						field[y + 1][x]++;
						answer.push_back(as);
					}
					else {
						vector<int> as = { y,x,y,x -1 };
						field[y][x - 1]++;
						answer.push_back(as);
					}
				}
			}
		}
		cnt++;
	}

	cout << answer.size() << endl;
	for (auto val : answer) {
		cout << val[0]+1 << " " << val[1]+1 << " " << val[2]+1 << " " << val[3]+1 << endl;
	}
}


Measured memory_bytes: 11824
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <time.h>
using namespace std;

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
//#define X first
#define Y second
#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 REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const LL INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const LL mod = 1000000007;
const LL MAX = 100047;

int A[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, mx = 0, k = 0;
	cin >> n;
	REP(i, n)
	{
		cin >> A[i];
		mx = max(mx, A[i]);
	}
	REP(i, n)
	{
		if (A[i] < mx && abs(2 * A[i] - mx) < abs(2 * k - mx))
			k = A[i];
	}
	cout << mx << ' ' << k;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
long int a, b, r, x, tmp;

cin >> a >> b;

x = a * b;

/* 自然数 a > b を確認・入替 */
if (a < b)
{
    tmp = a;
    a = b;
    b = tmp;
}

/* ユークリッドの互除法 */
r = a % b;
while (r != 0)
{
    a = b;
    b = r;
    r = a % b;
}

/* 最小公倍数を出力 */
cout << x / b;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
     public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long ans = 0;
        
        for(int i = 0;i < N;i++){
            if((i+1) % 3 == 0|| (i+1) % 5 == 0){
                
            }else{
                ans = ans + (i + 1);
            }
            //System.out.println(i + "=" + ans);
        }
        
        System.out.print(ans);
     }
}

Measured memory_bytes: 27192
x = int(input())
a = 2
b = 0
A = []
A.append(1 ** 5 - x)

while True:
    if (a + 1) ** 5 - a ** 5 > 10 ** 10:
        break
    A.append(a ** 5 - x)
    a = a + 1

while True:
    if b ** 5 in A:
        break
    elif -b ** 5 in A:
        b = -b
        break
    b = b + 1

a = int((x + b ** 5) ** 0.2)

print(a, b)

Measured memory_bytes: 9456
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def dfs(x):
        if r[x] != None:
            return 1
        f = 1
        res = 0
        for y in v[x]:
            if d[y]:
                d[y] = 0
                f &= dfs(y)
                d[y] = 1
            else:
                res = float("inf")
                f = 0
                break
            if res < r[y]:
                res = r[y]
        r[x] = res+1
        return f

    n = I()
    a = LIR(n)
    N = n*(n-1)
    f = [0]*N
    v = [[] for i in range(N)]
    lis = set()
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1
        k = a[i][0]
        x = n*min(i,k)+max(i,k)
        for j in range(1,n-1):
            l = a[i][j]
            y = n*min(i,l)+max(i,l)
            v[y].append(x)
            f[x] += 1
            lis.add(x)
            lis.add(y)
            x = y
    if min([f[i] for i in lis]):
        print(-1)
        return
    d = [1]*N
    r = defaultdict(lambda : None)
    for i in lis:
        if not f[i]:
            d[i] = 0
            if not dfs(i):
                print(-1)
                return
    print(max(r.values()))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 218680
n=int(input())
spi=[]

for i in range(n):
    S,P=input().split()
    spi+=[[S,int(P),i+1]]
spi.sort()
city=spi[0][0]
citys=[]
ans=[]
for s,p,i in spi:
    if city==s:
        citys+=[[p,i]]

    else:
        citys.sort(reverse=True)
        for x,y in citys:
            ans+=[y]

        city=s
        citys=[[p,i]]

citys.sort(reverse=True)
for x,y in citys:
    ans+=[y]

for i in ans:print(i)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  ll dx=tx-sx;//>0
  ll dy=ty-sy;//>0
  string s="";
  for(int i=0;i<dx;i++){
    s +="R";
  }
  for(int i=0;i<dy;i++){
    s +="U";
  }
  for(int i=0;i<dx;i++){
    s +="L";
  }
  for(int i=0;i<dy;i++){
    s +="D";
  }
  dx++;
  dy++;
  s +="D";
  for(int i=0;i<dx;i++){
    s +="R";
  }
  for(int i=0;i<dy;i++){
    s +="U";
  }
  s +="LU";
  for(int i=0;i<dx;i++){
    s +="L";
  }
  for(int i=0;i<dy;i++){
    s +="D";
  }
  s +="R";
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	cout<<((a-b)>0?(a-b):0)<<endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()


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

  int n;
  string s;
  cin >> n >> s;

  rep(i,s.length()){
    int si = s[i] - 'A';
    si += n;
    if(si >= 26)si -= 26;
    s[i] = 'A' + si;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M, C;
    cin >> N >> M >> C;

    int B[M];
    REP(i, M) {
        cin >> B[i];
    }

    int ans = 0;
    REP(i, N) {
        int s = 0;
        REP(j, M) {
            int a;
            cin >> a;
            s += a * B[j];
        }

        if (s > -C) ++ans;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int ans[1000];
	int n;
	cin >> n;
	for (int i = 0; i < 1000; i++) {
		int a = n % -2;
		ans[i] = abs(a);
		n /= -2;
		if (a < 0) {
			n++;
		}
	}
	bool ans1 = false;
	for (int j = 1000; j >= 0; j--) {
		if (ans[j] == 1) {
			ans1 = true;
		}
		if (ans1 == true) {
			cout << ans[j];
		}
	}
	if (ans1 == false) {
		cout << "0";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.lang.*;
import java.util.*;
public class Main 
{
    ///atcoder
    public static void main(final String args[]) 
    {
        final Scanner s = new Scanner(System.in);
        int n=s.nextInt();
        int a[]=new int[n+1];
        for(int i=0;i<n+1;i++)
        {
            a[i]=0;
        }
        int k;
        for(int i=0;i<n-1;i++)
        {
            k=s.nextInt();
            a[k]++;
        }
        for(int i=1;i<n+1;i++)
        {
            System.out.println(a[i]);
        }
    }
}

Measured memory_bytes: 58360
def lcs(s,t):
    m = len(s)
    n = len(t)

    dp = [[0]*(n+1) for _ in range(m+1)]

    for i in range(1,m+1):
        for j in range(1,n+1):
            if s[i-1] == t[j-1]:
                dp[i][j] = 1+ dp[i-1][j-1]
            else:
                dp[i][j] = max(dp[i-1][j],dp[i][j-1])
    
    
    substr = ""
    i,j = m,n
    while i>0 and j>0:
        if s[i-1] == t[j-1]:
            substr+=s[i-1]
            i-=1
            j-=1
        elif dp[i][j-1]>dp[i-1][j]:
            j-=1
        else:
            i-=1
    return substr[::-1]
    
    

# s = "abracadabra"
# t = "avadakedavra"
# s = "axyb"
# t = "abyxb"
s = input()
t = input()
print(lcs(s,t))

Measured memory_bytes: 144616
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
inline double sq(double x){ return x*x; }
typedef pair<double, int> P;
int main(){
  int n;
  while(cin>>n,n){
    double x[100],y[100],z[100],r[100];
    REP(i,n)cin>>x[i]>>y[i]>>z[i]>>r[i];
    double d[100][100];
    REP(i,n)REP(j,n){
      d[i][j] = sqrt(sq(x[i]-x[j]) + sq(y[i]-y[j]) + sq(z[i]-z[j])) - (r[i] + r[j]);
      d[i][j] = max(0.0, d[i][j]);
    }
    priority_queue<P> que;
    que.push(P(0,0));
    bool used[100] = {};
    double ans = 0;
    while(!que.empty()){
      P p = que.top(); que.pop();
      p.first *= -1;
      if(used[p.second]) continue;
      used[p.second] = true;
      ans += p.first;
      REP(i,n)if(!used[i]){
        que.push(P(-d[p.second][i], i));
      }
    }
    printf("%.3lf\n",ans);
  }
  return 0;

}

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

using namespace std;
int n, a, b;
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> a >> b;
    if (abs(b - a) % 2 == 0) cout << "Alice\n";
    else cout << "Borys\n";
    return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())
ans = 0

a = []
while N % 2 == 0:
    a.append(2)
    N //= 2
f = 3
while f * f <= N:
    if N % f == 0:
        a.append(f)
        N //= f
    else:
        f += 2
if N != 1:
    a.append(N)

A = collections.Counter(a)

A = list(A.values())

for i in range(len(A)):
    cnt = 1
    val = A[i]
    while val >= cnt:
        ans += 1
        val -= cnt
        cnt += 1
print(ans)

Measured memory_bytes: 9468
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int>P;

int N,K;
vector<int> G[5010];
int D[5010][5010];
int d[5010];
int C[10010];
int R[5010];
const int INF=100000000;

void bfs(int x){
	queue<int>q;
	q.push(x);
	while(R[x]>0){
		queue<int>q1;
	while(!q.empty()){
		int p=q.front(); q.pop();
		int n=G[p].size();
		for(int i=0;i<n;i++){
			if(D[x][G[p][i]]==INF){
				D[x][G[p][i]]=C[x];
				q1.push(G[p][i]);
			}
		}
	}
	  R[x]--;
	  q=q1;
	}
}

int main(void){

	cin >> N >> K;
	int i,j;
	for(i=1;i<=N;i++) cin >> C[i] >> R[i];
	int a,b;
	REP(i,K){
		cin >> a >> b;
		G[a].push_back(b); G[b].push_back(a);
	}

	for(i=1;i<=N;i++) for(j=1;j<=N;j++) D[i][j]=INF;

	for(i=1;i<=N;i++) bfs(i);

	priority_queue<P,vector<P>,greater<P> >Q;
	for(i=1;i<=N;i++) d[i]=INF;
	d[1]=0;
	Q.push(P(d[1],1));

	while(!Q.empty()){
		P p=Q.top(); Q.pop();
		int a=p.first,b=p.second;
		if(d[b]<a) continue;
		d[b]=a;
		for(i=1;i<=N;i++){
			if(d[i]>d[b]+D[b][i]){
			   d[i]=d[b]+D[b][i];
			   Q.push(P(d[i],i));
			}
		}
	}

	cout << d[N] << endl;

	return 0;
}

Measured memory_bytes: 99680
s = [0, 0, 0]
loop = int(raw_input())
for i in range(loop):
    w1, w2 = raw_input().split()
    tmp = 1 - cmp(w1, w2)
    if tmp == 1:
        s[0] += 1
        s[2] += 1
    else:
        s[tmp] += 3
print s[0], s[2]


Measured memory_bytes: 4652
#include <iostream>
using namespace std;
void pRec(int h, int w) {
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if ((i + j) % 2 == 0)
        cout << "#";
      else
        cout << ".";
    }
    cout << "\n";
  }
  cout << "\n";
}
int main(void) {
  int h, w;
  for(;;) {
    cin >> h >> w;
    if (h == 0 && w == 0)
      return 0;
    pRec(h, w);
  }
}



Measured memory_bytes: 3004
from collections import deque

n,q=list(map(int,input().split()))
nt=deque()
for i in range(n):
  nt.append(input().split())
  nt[i][1]=int(nt[i][1])
t=0
while len(nt) > 0:
  if nt[0][1] <= q:
    t += nt[0][1]
    print(str(nt[0][0]) + " " + str(t))
    nt.popleft()  
  else:  
    nt[0][1]=nt[0][1]-q
    nt.rotate(-1)
    t += q


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
ll A[202020];

int ok(int pos) {
	if(pos<0) return 0;
	for(int L=2*pos,R=2*N-1;L<R;L++,R--) {
		if(A[L]+A[R]<M) return 0;
	}
	return 1;
	
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,2*N) cin>>A[i];
	
	sort(A,A+2*N);
	int cur=N;
	for(i=20;i>=0;i--) if(ok(cur-(1<<i))) cur-=1<<i;
	
	ll ma=0;
	FOR(i,cur) ma=max(ma,A[i]+A[2*cur-1-i]);
	FOR(i,N-cur) ma=max(ma,(A[2*cur+i]+A[2*N-1-i])%M);
	cout<<ma<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
 string s ;
 cin >> s ;
    int counter = 700;
    if (s[0] == 'o'){counter += 100;}
    if (s[1] == 'o'){counter += 100;}
    if (s[2] == 'o'){counter += 100;}
 cout << counter << endl;
}



Measured memory_bytes: 256
// ~/SolverToBe/Developers/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 105, M = 1000005;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;

int n,W,w[N],v[N];
ll dp[N][100005];

ll calc(int i,int j) {
    if(i==n)
        return 0;
    ll &r = dp[i][j];
    if(r!=-1)
        return r;
    r = calc(i+1,j);
    if(w[i] <= j)
        r = max(r, calc(i+1,j-w[i]) + v[i]);
    return r;
}

int main() {
    scanf("%d%d",&n,&W);
    for(int i=0; i<n; i++)
        scanf("%d%d",w+i,v+i);
    memset(dp,-1,sizeof dp);
    printf("%lld\n", calc(0,W));
    return 0;
}

Measured memory_bytes: 82304
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n, m;
	cin >> n >> m;
	vector<int>a(n);
	int i;
	for (i = 0; i < m; i++)
	{
		cin >> a.at(i);
		n = n - a.at(i);
	}
	if (n < 0)
		n = -1;
	cout << n << endl;
} 

Measured memory_bytes: 7136
#include <stdio.h>
#include <math.h>

void sekibun(int d){
    int i, s;
    
    s = 0;
    
    for(i=d; i<=600-d; i+=d){
        
        s += i * i * d;
    }
    
    
    printf("%d\n", s);
    

}


int main(void){
    int d;
    
    while(scanf("%d", &d) != EOF){
        sekibun(d);
    }
    
    return 0;
}


Measured memory_bytes: 2056
//#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};

signed main(void)
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);

    int N,K,Q,A[2100];
    vector<P> V;
    cin>>N>>K>>Q;
    for(int i=1;i<=N;i++){
        cin>>A[i];
        V.push_back(P(A[i],i));
    }
    A[N+1]=-1;
    V.push_back(P(-1,0));
    sort(V.begin(),V.end());
    ll ans=INF;
    for(int i=0;i<N;i++){
        A[V[i].second]=-1;
        while(V[i+1].first==V[i].first){
            i++;
            A[V[i].second]=-1;
        }
        int now=1;
        vector<int> v;
        while(now<=N){
            int s=now;
            priority_queue<int> que;
            while(A[now]!=-1){
                que.push(-1*A[now]);
                now++;
            }
            int k=now-s;
            for(int j=0;j<k-K+1;j++){
                int x=que.top(); que.pop();
                v.push_back(-x);
            }
            now++;
        }
        sort(v.begin(),v.end());
        if((int)v.size()<Q) break;
        chmin(ans,v[Q-1]-v[0]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
n = int(input().strip())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

prefix=[1]*40
for i in range(1,40):
    prefix[i]=prefix[i-1]+i+1

ans=0
prime_table=prime_decomposition(n)
i=0
while i <len(prime_table):
    length=1
    while i<len(prime_table)-1 and prime_table[i+1]==prime_table[i]:
        length+=1
        i+=1
    i+=1
    for j in range(40):
        if prefix[j]>length:
            break
    ans+=j
print(ans)

Measured memory_bytes: 9300
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

cnt = 0
a.sort!
a.each_with_index{|t, i|
  if t <= x
    if i == a.size-1
      break if t != x
    end
    x -= t
    cnt += 1
  else
    break
  end
}

puts cnt



Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#define ll long long
#define mes(x,y) memset(x,y,sizeof(x))
using namespace std;
struct node{
	int x,y;
}b[100040];
bool cmp(node n1,node n2){
	return n1.y>n2.y;
}
int main(){
	std::ios::sync_with_stdio(false);
    int n,m,i,j,a[100040],len,flag;
    cin>>n>>m;
    	for(i=0;i<n;i++)cin>>a[i];sort(a,a+n);
    	for(j=0;j<m;j++)cin>>b[j].x>>b[j].y;sort(b,b+m,cmp);
    	//for(j=0;j<m;j++)cout<<b[j].x<<" "<<b[j].y<<endl;
		for(i=0,j=0;i<m;i++){
			len=b[i].x;
			flag=0;
			for(;j<n&&len>0;j++,len--){
				if(a[j]<b[i].y){
					a[j]=b[i].y;
				}
				else{
					flag=1;break;
				}
			}
			if(flag==1)break;
		} 
		ll sum=0;
		for(i=0;i<n;i++)sum+=a[i];
		cout<<sum<<endl;
	
}


Measured memory_bytes: 1408
n = gets.to_i
cs = Array.new(n)
ss = Array.new(n)
fs = Array.new(n)
(n-1).times do |i|
  cs[i], ss[i], fs[i] = gets.split.map(&:to_i)
end
cs[n-1], ss[n-1], fs[n-1] = [0, 0, 1]

(0...n).each do |i|
  t = 0
  (i...n).each do |j|
    c, s, f = cs[j], ss[j], fs[j]
    t = ([t, s].max.to_f / f).ceil * f + c
  end
  puts t
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int hour[3];
	cin >> hour[0] >> hour[1] >> hour[2];
	int ans = 1000;
	for (int i = 0; i < 2; i++) {
		for (int j = i + 1; j < 3; j++) {
			ans = min(ans, hour[i] + hour[j]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    while(1) {
        ll n, m;
        cin >> n >> m;
        if(!n) break;
        vector<ll> v(m);
        while(n--) {
            ll d, w;
            cin >> d >> w;
            d--;
            v[d] = max(v[d], w);
        }
        cout << accumulate(v.begin(), v.end(), 0ll) << endl;
    }
}



Measured memory_bytes: 3140
st=list(input())
n=list(map(int,st))
a=0
b=0
N=len(st)
retu10=[1,0]*(N//2  +1)
retu01=[0,1]*(N//2 +1)
r1=retu10[:N]
r0=retu01[:N]
for i in range(N):
  if r1[i]!=n[i]:
    a=a+1
  else:
    pass
for i in range(N):
  if r0[i]!=n[i]:
    b=b+1
  else:
    pass
print(min(a,b))


Measured memory_bytes: 7852
using static System.Math;
using System;

public class Hello
{
    public static int h, w;
    public static bool[,] map;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        h = int.Parse(line[0]);
        w = int.Parse(line[1]);
        map = new bool[h, w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++)
                if (s[j] == '.') map[i, j] = true;
        }
        goDp();
    }
    static void goDp()
    {
        var dp = new int[h, w];
        var pre = map[0, 0];
        for (int i = 1; i < w; i++)
        {
            if (pre && !map[0, i]) dp[0, i] = dp[0, i - 1] + 1;
            else dp[0, i] = dp[0, i - 1];
            pre = map[0, i];
        }
        pre = map[0, 0];
        for (int i = 1; i < h; i++)
        {
            if (pre && !map[i, 0]) dp[i, 0] = dp[i - 1, 0] + 1;
            else dp[i, 0] = dp[i - 1, 0];
            pre = map[i, 0];
        }
        for (int i = 1; i < h; i++)
            for (int j = 1; j < w; j++)
            {
                var c1 = map[i - 1, j] && !map[i, j] ? dp[i - 1, j] + 1 : dp[i - 1, j];
                var c2 = map[i, j - 1] && !map[i, j] ? dp[i, j - 1] + 1 : dp[i, j - 1];
                dp[i, j] = Min(c1, c2);
            }
        var dphw = dp[h - 1, w - 1];
        Console.WriteLine(!map[0, 0] ? dphw + 1 : dphw);
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main() {
	int A[100];
	int N, i, j, dum, ct=0;

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	for(i=0;i<N;i++){
		for (j = N - 1; j > 0; j--) {
			if (A[j] < A[j - 1]) {
				dum = A[j - 1];
				A[j-1]=A[j];
				A[j]=dum;
				ct++;
			}
		}
	}
	for (i = 0; i < N-1; i++) {
		printf("%d ",A[i]);
	}
	printf("%d\n",A[N-1]);
	printf("%d\n", ct);
	return 0;
}


Measured memory_bytes: 2084
<?php
define('MOD', pow(10, 9) + 7);

fscanf(STDIN, "%s", $S);
$a = str_split($S);
$len = strlen($S);
$array = array_fill(0, 13, 0);
for ($i = 0; $i < $len; $i++) {
    $new_array = array_fill(0, 13, 0);
    $pat = [];
    if ($a[$i] === '?') {
        $pat = range(0, 9);
    } else {
        $pat[] = intval($a[$i]);
    }
    foreach ($pat as $k) {
        if ($i === 0) {
            $new_array[$k]++;
        } else {
            for ($j = 0; $j < 13; $j++) {
                $index = ($j * 10 + $k) % 13;
                $new_array[$index] += $array[$j];
            }
        }
    }
    $new_array = array_map(function ($x) {return $x % MOD;}, $new_array);
    $array = $new_array;
}

printf("%d", $array[5]);


Measured memory_bytes: 22324