akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  
  int amount = N;
  int sum = 0;
  while (amount > 0) {
    sum += (amount % 10);
    amount /= 10;
  }
  
  if (N % sum == 0) cout << "Yes" << endl; 
  else cout << "No" << endl;
}

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

typedef struct Point{
  double x;
  double y;
}P;

void koch(int n, P a,P b){
  if(n == 0) return;
  P s,t,u;
  double th = M_PI*60.0/180.0;

  s.x = (2.0*a.x+1.0*b.x)/3.0;
  s.y = (2.0*a.y+1.0*b.y)/3.0;
  t.x = (1.0*a.x+2.0*b.x)/3.0;
  t.y = (1.0*a.y+2.0*b.y)/3.0;
  u.x = (t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y = (t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  P a,b;
  int n;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}



Measured memory_bytes: 2108
mod = 10**9 + 7

def accmulate(array):
    cs = [0]*(len(array)+1)
    for i in range(len(array)):
        cs[i+1] = cs[i] + array[i]
    return cs

def query(l,r):
    return cs[r+1] - cs[l]

N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [[0]*(K+1) for _ in range(N+1)]

dp[0][0] = 1

for i in range(1,N+1):
    cs = accmulate(dp[i-1])
    for j in range(K+1):
        dp[i][j] += query(max(j-A[i-1], 0), j)
        dp[i][j] %= mod

ans = dp[N][K]
print(ans)

Measured memory_bytes: 129560
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, m, dp[1001][1001], M = 1e9+7;
int dx[] = {0, 1}, dy[] = {1, 0};
char arr[1001][1001];
//pair<int, string> dp[3002][3002];

int solve(int i = 0, int j = 0) {
    if (i == n-1 && j == m-1) {
        return 1;
    }
    if (i >= n || j >= m || arr[i][j]=='#') {
        return 0;
    }
    int& ret = dp[i][j];
    if (~ret) {
        return ret;
    }
    ret = solve(i+1, j) + solve(i, j+1);
    if (ret >= M) {
        ret -= M;
    }
    return ret;
}
int main()
{
    IOS
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    cout << solve() << endl;


    return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<cstring>

using namespace std;
typedef long long ll;

//cout<< fixed << setprecision(12) <<dbl;
//iomanip

int n,c,k;
int times[100009];

bool good(int b){


	int covered=times[1]+k;
	int bus=1,has=1;

	for(int i=2;i<=n;++i)
		if(has>=c){
			++bus;
			covered=times[i]+k;
			has=1;
		}
		else{
			if(times[i]>covered){
				++bus;
				covered=times[i]+k;
				has=1;					
			}
			else
				++has;
		}
		

	if(bus<=b)
		return true;
	return false;
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>c>>k;

	for(int i=1;i<=n;++i)
		cin>>times[i];

	sort(times+1,times+1+n);

	int lo=1,hi=1e6;

	while(lo<hi){
	
		int mid=(lo+hi)/2;
		if(good(mid))
			hi=mid;
		else
			lo=mid+1;
	}

	cout<<lo<<endl;	
		
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
//#define random_shuffle(r...) random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}
ll prime[1000000];bool visprime[10000000];
void sieve(){ll k=0;for(ll i=2;i*i<=1000000;i++){for(ll j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(ll i=2;i<=1000000;i++){if(visprime[i]==false) prime[k++]=i;}}
int myrandom (int i) { return std::rand()%i;}

bool checkbit(int mask,int bit) {return (mask & (1<<bit));}

ll fact(ll n)
{
    if(n==0) return 1;
    if(n==1) return 1;
    ll ret=((n%mod)*(fact(n-1)%mod))%mod;
    return ret;

}

int main()
{

   int n;
   cin>>n;
   string str;
   cin>>str;
   str+='#';
   int cnt=0;

   for(int i=1;i<n+1;i++)
   {
       if(str[i]!=str[i-1]) cnt++;
   }

   cout<<cnt<<endl;



}

















Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)


int main(){
  ll n,m;
  cin >> n >> m;
  ll ans=0;
  ll a=min(n,m),b=max(n,m);
  if(a==1){
    if(a==b)ans=1;
    else ans=b-2;
  }else{
    ans=(a-2)*(b-2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,k;
bool f;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i*m+j*n-2*i*j==k)
			{
				printf("Yes\n");
				f=1;
				break;
			}
		}
		if(f) break;
	}
	if(!f) printf("No\n");
	return 0;
}

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

#define int long long

using namespace std;

const int maxn = 3010, mod = 998244353;
int dp[maxn][maxn], a[maxn], n, s;

signed main()
{
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin >> n >> s;
        for (int i = 0; i < n; i++) {
                cin >> a[i];
                dp[i][0] = dp[i][a[i]] = i + 1;
        }
        for (int i = 1; i < n; i++) {
                for (int k = 1; k <= s; k++) {
                        (dp[i][k] = dp[i - 1][k] + (k > a[i] ? dp[i - 1][k - a[i]] : 0) + (k == a[i] ? i + 1 : 0)) %= mod;
                }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
                (ans += dp[i][s]) %= mod;
        }
        cout << ans;

        return 0;
}

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

using namespace std;
using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> A(n), B(n), C(n-1);
    for(auto&& a:A){
        cin >> a;a--;
    }
    for(auto&& b:B)cin >> b;
    for(auto&& c:C)cin >> c;
    int rct = -5;
    int ret = 0;
    for(int i=0;i<n;i++){
        ret += B[A[i]];
        if(rct + 1 == A[i])ret += C[rct];
        cerr << rct << " " << ret << endl;
        rct = A[i];
    }
    cout << ret << endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	ll n;
	cin >> n;

	vector<int> a;

	while(n > 0)
	{
		if(n%26 == 0)
		{
			a.push_back(26);
			n--;
		}
		else
			a.push_back(n % 26);

		n /= 26;
	}

	for(int i = a.size()-1; i >= 0; i--)
		cout << char(a[i]+'a'-1);

	return 0;
}

Measured memory_bytes: 3624
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;

struct edge { int dst, time; };
vector<vector<edge>> g;
int n, m;

int main() {
    while (cin >> n >> m) {
        g.assign(n, {});
        for (int i = 0; i < m; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            --a; --b;
            g[a].push_back({ b,c });
        }

        priority_queue<pair<int,int>> q; // -time, node
        static int min_t[100010];
        fill(min_t, min_t + n, 1.5e9);
        min_t[0] = 0;
        q.push({ 0,0 });

        int ans = -1;

        while (q.size()) {
            int t, v;
            tie(t, v) = q.top();
            q.pop();
            t = -t;
            if (min_t[v] < t) continue;
            for (auto &e : g[v]) {
                if (e.time < t) continue;
                if (e.dst == n - 1) {
                    ans = max(ans, e.time);
                }
                if (min_t[e.dst] > t) {
                    min_t[e.dst] = e.time;
                    q.push({ -e.time, e.dst });
                }
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 8776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    ll a,b;
    cin >>a >>b;

    const ll g = __gcd(a,b);
    ll t = g;
    ll ans = 1;
    for(ll i=2; i*i<=g; ++i){
        if(t%i == 0){
            ++ans;
            while(t%i == 0) t/=i;
        }
    }
    if(t>1) ++ans;

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

struct Graph {
  vector<vector<int>> edge;
  Graph(int n = 0) { resize(n); }
  void resize(int n) { edge.resize(n, vector<int>()); }
  void addEdge(int from, int to) {
    edge[from].push_back(to); edge[to].push_back(from);
  }
  const vector<int>& operator[](int from) const { return edge[from]; }
};
constexpr int MOD = 1e9+7, MAX_N = 1e5;
long long dp[MAX_N][2];
long long dfs(const Graph &G, int cur, int prev, bool filled) {
  if (dp[cur][filled] != -1) return dp[cur][filled];
  long long ans = 1;
  for (const auto& to:G[cur]) {
    if (to == prev) continue;
    ans *= filled
      ? dfs(G, to, cur, false)
      : (dfs(G, to, cur, false) + dfs(G, to, cur, true)) % MOD;
    ans %= MOD;
  }
  return dp[cur][filled] = ans;
}
int main() {
  int in(N);

  Graph G(N);
  rep(i, N)
    dp[i][0] = dp[i][1] = -1;
  rep(i, N-1) {
    int in(x); int in(y);
    --x, --y;
    G.addEdge(x, y);
  }

  cout << (dfs(G, 0, -1, true) + dfs(G, 0, -1, false)) % MOD << endl;

  return 0;
}


Measured memory_bytes: 15616
#include<cstdio>
const int N=1e5;
int n,a[N+10],l,f[N+10],ans[N+10];
char s[N+10];
int main()
{
	scanf("%s",s);
	for(;s[n];n++)
		if(s[n]=='L')a[n+1]=-1;
		else a[n+1]=1;
	l=1;
	for(int i=1;i<n;i++)
		if(a[i]==1&&a[i+1]==-1)
		{
			for(int j=l;j<=i;j++)f[j]=i-j;
			for(int j=i+1;;j++)
			{
				if(j>n)
				{
					l=n;
					break;
				}
				if(a[j]!=-1)
				{
					l=j;
					break;
				}
				f[j]=i-j;
			}
		}
	for(int i=1,x;i<=n;i++)
		ans[i+f[i]+(N-f[i])%2]++;
	for(int i=1;i<=n;i++)
		printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <algorithm>
#include <climits>

using namespace std;

typedef long long ll;
int n, N;
ll a[2222], x;
int d[1<<21]; //nより大きい 2^k * 2

void init(int n_)
{
  n = 1;
  while( n < n_ ) n*=2;
  for( int i = 0; i < 2*n-1; i++ ) d[i] = INT_MAX;
}

void update(int i,int x)
{
  i += n-1;
  d[i] = x;
  while( i > 0 ) {
    i = (i-1)/2;
    d[i] = (d[i*2+1]<d[i*2+2] ? d[i*2+1] : d[i*2+2]);
  }
}

int qq(int i,int j,int k,int l,int r)
{
  if( r <= i || j <= l ) return INT_MAX;
  if( i <= l && r <= j ) return d[k];
  int a = qq(i,j,k*2+1,l,(l+r)/2);
  int b = qq(i,j,k*2+2,(l+r)/2,r);
  return a<b ? a : b;
}

int main(void) {
  scanf("%d%lld", &n, &x);
  N = n;
  init(n);
  for (int i = 0; i < N; i++) {
    scanf("%lld", a+i);
    update(i, a[i]);
  }
  ll res = 0;
  for (int i = 0; i < N; i++) res += a[i];
  for (int l = 1; l < N; l++) {
    ll y = 0;
    for (int i = 0; i < N; i++) {
      /*
      ll m = a[i];
      int idx = i;
      for (int j = 1; j <= l; j++) {
        ll s = a[(i-j+N)%n];
        if (m > s) {
          idx = (i-j+N)%n;
          m = s;
        }
      }
      y += a[idx];
      */
      // y += qq()
      if (i-l < 0) {
        // printf("%d %d %d %d %d\n", i, l, N+(i-l), N, min(qq(0, i, 0, 0, n), qq(N+(i-l), N, 0, 0, n)));
        y += min(qq(0, i+1, 0, 0, n), qq(N+(i-l), N, 0, 0, n));
      } else {
        y += qq(i-l, i+1, 0, 0, n);
      }
    }
    if (res > y+l*x) {
      res = y+l*x;
    }
  }
  printf("%lld\n", res);
  return 0;
}












Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1e9;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef int Weight;
struct Edge {
  int src, dst;
  Edge(int src, int dst) :
    src(src), dst(dst) { }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool augment(const Graph& g, int u,
    vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  FOR(e, g[u]) if (!visited[e->dst]) {
    visited[e->dst] = true;
    if (augment(g, matchTo[e->dst], matchTo, visited)) {
      matchTo[e->src] = e->dst;
      matchTo[e->dst] = e->src;
      return true;
    }
  }
  return false;
}
int bipartiteMatching(const Graph& g, int L, Edges& matching) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  REP(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  REP(u, L) if (matchTo[u] >= 0) // make explicit matching
    matching.push_back( Edge(u, matchTo[u]) );
  return match;
}

int adj[100][100];
int p[1000],t[1000];

int main() {
  int n,m,l;
  while(cin>>n>>m>>l,n||m||l) {
    REP(i,n)REP(j,n)adj[i][j]=INF;
    REP(i,n)adj[i][i]=0;
    REP(i,m) {
      int u,v,d;
      cin>>u>>v>>d;
      adj[u][v] = min(adj[u][v],d);
      adj[v][u] = adj[u][v];
    }
    REP(k,n)REP(i,n)REP(j,n) {
      adj[i][j]=min(adj[i][j],adj[i][k]+adj[k][j]);
    }
    //REP(i,n) {REP(j,n)cout<<adj[i][j]<<" ";cout<<endl;}
    Graph g(2*l);
    REP(i,l) {
      cin>>p[i]>>t[i];
    }
    REP(i,l) {
      REP(j,l) {
        if (i==j) continue;
        if (adj[p[i]][p[j]] <= t[j]-t[i]) {
          g[i].push_back(Edge(i,l+j));
          g[l+j].push_back(Edge(l+j,i));
        }
      }
    }
    Edges e;
    cout << l - bipartiteMatching(g, l, e) << endl;
  }
}

Measured memory_bytes: 11000
N = input()

target_n = int(N[-1])
if target_n == 2 or target_n == 4 or target_n == 5 or target_n == 7 or target_n == 9:
    print("hon")
elif target_n == 0 or target_n == 1 or target_n == 6 or target_n == 8:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 61612
import math
abhm = input('')
a=int(abhm.split(' ')[0])
b=int(abhm.split(' ')[1])
h=int(abhm.split(' ')[2])
m=int(abhm.split(' ')[3])

hx=360/12*h + 360/(12*60)*m
mx=360/60*m

#print("hx:{}/{} mx:{}/{}".format(h,hx,m,mx))

angle = abs(hx-mx)
if angle > 180:
    angle = abs(angle-360)

c2 = pow(a,2) + pow(b,2) - 2*a*b*math.cos(math.radians(angle))
#print("a:{} b:{} c**2:{} angle:{}->cos:{}".format(a,b,c2,angle,math.cos(math.radians(angle))))

print(math.sqrt(abs(c2)))


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;cin>>s;
    reverse(all(s));

    int ex[26]={};
    vector<string>v;
    int l=0;
    rep(i,s.size()){

        ex[s[i]-'a']=1;
        if(count(ex,ex+26,1)==26){
            v.pb(s.substr(l,i-l+1));
            l=i+1;
            memset(ex,0,sizeof(ex));
        }
    }
    v.pb(s.substr(l,s.size()-l));

    for(int i=v.size()-1;i>=0;i--){
        char c;
        for(c='a';;c++)if(find(all(v[i]),c)==v[i].end())break;
        cout<<c;
        if(i==0)break;
        string &t=v[i-1];
        reverse(all(t));
        int k=find(all(t),c)-t.begin();
        t=t.substr(k+1,t.size()-k-1);
        reverse(all(t));
    }
    return 0;
}


Measured memory_bytes: 1156
#include <stdio.h>

int main( )
{
  int a,b;
  char op;
  
  while(1)
    {
      scanf("%d %c %d",&a,&op,&b);
      if(op == '?')break;
      else if(op == '+')printf("%d\n",a + b);
      else if(op == '-')printf("%d\n",a - b);
      else if(op == '*')printf("%d\n",a * b);
      else if(op == '/')printf("%d\n",a / b);
    }

  return 0;
}

Measured memory_bytes: 600
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import itertools

sys.setrecursionlimit(500*500)

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m,q=map(int, readline().rstrip().split())

    aa=[0]*q
    bb=[0]*q
    cc=[0]*q
    dd=[0]*q

    for i in range(q):
        aa[i],bb[i],cc[i],dd[i]=map(int, readline().rstrip().split())

    max_score=0

    for a in itertools.combinations_with_replacement(list(range(1,m+1)),n):
        score=0
        for i in range(q):
            if (a[bb[i]-1]-a[aa[i]-1])==cc[i]:
                score+=dd[i]
        max_score=max(max_score,score)

    print(max_score)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()


### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string t;
	cin >> t;

	rep(i, t.size()) {
		if (t[i] == '?')t[i] = 'D';
	}

	cout << t << endl;

}


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

int main(){
  int64_t N, K; cin >> N >> K;

  int64_t cnt1 = 0, cnt2 = 0, ans = 0;
  for(int i=1; i<=N; i++){
    if(i % K == 0) cnt1++;
    if(i % K == K/2) cnt2++;
  }

  ans += cnt1*cnt1*cnt1;
  if(K % 2 == 0) ans += cnt2*cnt2*cnt2;

  cout << ans << endl;
}

Measured memory_bytes: 256
A,B,C = map(int, input().split())

ans = 0
if C>=(B):
    ans = ans + 2*B
    C = C - (B)
    if C<0:
        C = 0
    ans = ans + min(A, C)
    C = C - min(A,C)
    ans = ans + min(C, 1)
    print(ans)
else:
    print(B+C)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

bool naive(int64 n) {
    string s = to_string(n);
    for (int i=1; i<s.size(); i++) {
        if (abs(s[i-1] - s[i]) > 1) return false;
    }
    return true;
}

int dfs(int n, int64& ans) {
    if (n == 0) return 0;
    int i = n;
    ans += i%3 + dfs(i/3, ans);
    ans *= 10;
    return (i%3-1);
}

int main() {
    int64 k;
    cin >> k;

    queue<int64> q;
    for (int i=1; i<=9; i++) q.emplace(i);

    int64 ans = 0;
    for (int i=0; i<k; i++) {
        ans = q.front(); q.pop();
        if (ans % 10 != 0) q.emplace(10*ans - 1 + ans%10);
        q.emplace(10*ans + ans%10);
        if (ans % 10 != 9) q.emplace(10*ans + 1 + ans%10);
    }

   cout << ans << endl;
}

Measured memory_bytes: 1792
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> as(n); cin >> as;
    vector<ll> bs(m); cin >> bs;
    vector<ll> acca(n + 1), accb(m + 1);
    for(int i = 0; i < n; i++){ acca[i + 1] = acca[i] + as[i]; }
    for(int i = 0; i < m; i++){ accb[i + 1] = accb[i] + bs[i]; }
    printde(acca);
    printde(accb);
    int ans = 0;
    for(int i = 0; i <= n; i++){
        if(acca[i] > k){ break; }
        ans = max(ans, i + (int)(upper_bound(accb.begin(), accb.end(), k - acca[i]) - accb.begin() - 1));
    }
    cout << ans << '\n';
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

bool vis[26];

string str;

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    cin >> str;

    if(str.size() < 26){
        for(int a = 0; a < (int)str.size(); a++){
            int ch = str[a] - 'a';
            vis[ch] = true;
        }
        for(int a = 0; a < 26; a++){
            if(!vis[a]){
                str += char(a + 'a');
                cout << str;
                return 0;
            }
        }
    }

    string bad = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    string best = bad;
    for(int a = 0; a < (int)str.size(); a++){
        int ch = str[a] - 'a';

        string tmp = str.substr(0, a);
        bool good = false;
        for(int b = ch + 1; b < 26; b++){
            if(!vis[b]){
                tmp += char(b + 'a');
                good = true;
                break;
            }
        }
        if(good){
            best = min(best, tmp);
        }

        if(vis[ch]){
            break;
        } else {
            vis[ch] = true;
        }
    }

    if(best == bad){
        cout << -1;
    } else {
        cout << best;
    }
}


Measured memory_bytes: 256
main :: IO ()
main = do
    x <- read <$> getLine
    putStrLn $ show $ solve x

solve :: Int -> Int
solve x = maximum $ filter isExp [1..x]


isExp :: Int -> Bool
-- xがべき乗数か判定

isExp 1 = True
isExp x =
    length (filter judge [a | a <- [2..x], x `mod` a == 0]) > 0
    where judge = \m -> case isExpOf x m of
            Nothing   -> False
            Just n    -> n > 1


isExpOf :: Int -> Int -> Maybe Int
-- aをbの累乗で表せるか判定
-- 表せなかったらNothing、表せたら指数を返す

isExpOf 1 _ = Just 0
isExpOf x m = 
    case (x `mod` m == 0) of
        False -> Nothing
        True  -> do
            n <- isExpOf (x `div` m) m
            return (n + 1)

Measured memory_bytes: 508
#include<iostream>
using namespace std;
int v[25];
int c[25];
int main(void)
{
    int num=0;
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> v[i];
    for(int i=1;i<=n;i++)
        cin >> c[i];
    for(int i=1;i<=n;i++)
    {
        if(v[i]>c[i])
            num+=(v[i]-c[i]);
    }
    cout << num;
    return 0;
}

Measured memory_bytes: 256
/**
 *       Author:  kulubat
 *       Written on Thursday, 16 April 2020.
 **/

#include <bits/stdc++.h>


using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    
    int n;
    cin >> n;
    vector<int> A(n);
    int sum = 0;
    unordered_set<int> B;
    
    for(int i = 0; i < n; ++i) {
        cin >> A[i];
        sum += A[i];
    }

    double m = (double)sum/n;
    int mean1, mean2;

    mean1 = ceil(m);
    mean2 = floor(m);

    int cost1 = 0;
    int cost2 = 0;

    for(auto a: A) {
        cost1 += (a-mean1)*(a-mean1);
        cost2 += (a-mean2)*(a-mean2);
    }


    cout << min(cost1,cost2) << endl;

    return 0;


}


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

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


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



typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=1e5+10;

int n;
char s[N];
int ans[N];
int nxtl[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	drep(i,n,1) if(s[i]=='L') nxtl[i]=i;
	else nxtl[i]=nxtl[i+1];
	int pre=1;
	rep(i,1,n) {
		if(s[i]=='R') pre=i;
		//cout<<pre<<' '<<nxtl[i]<<endl;
		if(s[i]=='L') {
			int t=(i-pre)&1;
			//cout<<t<<endl;
			if(t&1) ans[pre+1]++;
			else ans[pre]++;
		} else {
			int t=(nxtl[i]-pre);
			//cout<<t<<endl;
			if(t&1) ans[nxtl[i]-1]++;
			else ans[nxtl[i]]++;
		}
	}
	rep(i,1,n) printf("%d",ans[i]),putchar(i==n?'\n':' ');
}






Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s,n,m,p[12]={31,29,31,30,31,30,31,31,30,31,30,31},i;
  while(cin>>n>>m,n){
    for(s=i=0;i<n-1;i++)s+=p[i];
      s+=m;
    if(s%7==0)cout<<"Wednesday"<<endl;
    else if(s%7==1)cout<<"Thursday"<<endl;
    else if(s%7==2)cout<<"Friday"<<endl;
    else if(s%7==3)cout<<"Saturday"<<endl;
    else if(s%7==4)cout<<"Sunday"<<endl;
    else if(s%7==5)cout<<"Monday"<<endl;
    else cout<<"Tuesday"<<endl;
  }
}

Measured memory_bytes: 3072
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
int X[N], Y[N], par[N];
vii arX[N], arY[N];
vi cmp[N];

int qry(int x) { return x == par[x] ? x : par[x] = qry(par[x]); }
void join(int x, int y) { par[qry(x)] = qry(y); }

int main() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", X+i, Y+i);
    arX[X[i]].pb({Y[i], i});
    arY[Y[i]].pb({X[i], i});
    par[i] = i;
  }
  for (int i = 1; i < N; i++) {
    if (sz(arX[i])) {
      // sort(arX[i].begin(), arX[i].end());
      trav(x, arX[i])
        join(arX[i][0].nd, x.nd);
    }
    if (sz(arY[i])) {
      trav(x, arY[i])
        join(arY[i][0].nd, x.nd);
      // sort(arY[i].begin(), arY[i].end());
    }
  }
  ll ans = -n;
  for (int i = 0; i < n; i++)
    cmp[qry(i)].pb(i);
  for (int i = 0; i < n; i++) {
    set<int> X1, Y1;
    trav(x, cmp[i]) {
      X1.insert(X[x]);
      Y1.insert(Y[x]);
    }
    // cerr << i << " " << sz(X1) << " " << sz(Y1) << endl;
    ans += sz(X1) * 1ll * sz(Y1);
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
    using namespace std;
    size_t N;
    cin >> N;
    deque<pair<size_t, size_t>> bef, aft;
    vector<size_t> ans(N * N), a(N);
    for(size_t i = 0, A; i < N;){
        cin >> A;
        if(i)for(size_t j = 0; j < i; ++j)bef.emplace_back(A, i + 1);
        if(++i != N)for(size_t j = i; j < N; ++j)aft.emplace_back(~A, i);
        ans[A - 1] = i;
    }
    sort(bef.begin(), bef.end());
    sort(aft.begin(), aft.end());
    size_t cnt{0UL};
    for_each(ans.begin(), ans.end(), [&bef, &cnt](auto& i){
        ++cnt;
        if(i)return;
        if(bef.empty())return;
        if(bef[0].first < cnt)return;
        i = bef[0].second;
        bef.pop_front();
    });
    ++cnt;
    for_each(ans.rbegin(), ans.rend(), [&aft, &cnt](auto& i){
        --cnt;
        if(i)return;
        if(aft.empty())return;
        if(~aft[0].first > cnt)return;
        i = aft[0].second;
        aft.pop_front();
    });
    if(!aft.empty() || !bef.empty())return 0 & puts("No");
    puts("Yes");
    for(const auto& i : ans)cout << i << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 7168
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();

    int i=1;
    int ans;

    while(true){
      if(n/(int)Math.pow(k,i-1)==0){
        ans = i-1;
        break;
      }

      i++;
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 1000030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{
		ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
  string s;
  cin>>s;
  ll x=0;
  ll q;
  ll sze=s.size();
  cin>>q;
  while(q--)
  {
  	ll t;
  	cin>>t;
  	if(t==1)
  	{
  		x^=1;
	  }
	  else
	  {
	  	ll t;
	  	string ch;
	  	cin>>t>>ch;
	  	if((x==0&&t==1)||(x==1&&t==2))
	  	{
			s.insert(0,ch);
		  }
		  else
		  {
		  	s.insert(sze,ch);
		  }
		  sze++;
	  }
  }
  if(x)
  reverse(s.begin(),s.end());
  cout<<s;

}

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

int R;

int main () {
    cin>>R;
    if(R<1200)
        cout<<"ABC"<<endl;
    else{
        if(R<2800)
            cout<<"ARC"<<endl;
        else
            cout<<"AGC"<<endl;
    }
}
// smangat

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

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

    map<string, int> ans;

    for (int i = 0; i < N; i++)
    {
        string S;
        cin >> S;

        ans[S] = 1;
    }

    cout << ans.size() << endl;
}

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

using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;

	for (int i = a; i <= min(b, a + k - 1); i++)
	{
		cout << i << endl;
	}
	for (int i = max(b - k + 1, a + k); i <= b; i++)
	{
		cout << i << endl;
	}
}


Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a,b;
    cin>>a>>b;
    long long ans=a*b/__gcd(a,b);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m; cin >> n >> m;
  vector<string> ans(n);
  for(auto & i : ans) cin >> i;
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){
  	if(ans[i][j] == '#'){
    	int tot = 0;
      if(i - 1 >= 0) tot += ans[i - 1][j] == '#';
      if(i + 1 <  n) tot += ans[i + 1][j] == '#';
      if(j - 1 >= 0) tot += ans[i][j - 1] == '#';
      if(j + 1 <  m) tot += ans[i][j + 1] == '#';
      if(!tot){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import datetime
s = input()
try:
  a = datetime.datetime.strptime(s, '%y%m')
except ValueError:
  a = None
try:
  b = datetime.datetime.strptime(s, '%m%y')
except ValueError:
  b = None
if a==None and b==None:
  print("NA")
elif a!=None and b!=None:
  print("AMBIGUOUS")
elif a!=None:
  print("YYMM")
elif b!=None:
  print("MMYY")

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int half = n/2-1;
    // cout << half << a.at(half) << a.at(half+1) << endl;
    if(a.at(half)==a.at(half+1)) cout << 0 << endl;
    else cout << a.at(half+1) - a.at(half) << endl;
    return 0;
}

Measured memory_bytes: 3772
H=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(H[K-1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define mk make_pair
using namespace std;
int dx[]={2,2,2,1,1,0,0,-1,-1,-2,-2,-2};
int dy[]={1,0,-1,2,-2,2,-2,2,-2,1,0,-1};
int n,px,py,x,y;
int main(){
  while(cin>>px>>py,px+py){
    cin>>n;
    vector<pair<int,int> >v;
    v.push_back(mk(px,py));
    if(n==0)cout<<"NA"<<endl;
    else{
    for(int o=0;o<n;o++){
      set<pair<int,int> >se;
      vector<pair<int,int> >t;
      cin>>x>>y;
      for(int i=0;i<v.size();i++){
        int sx=v[i].first,sy=v[i].second;
        for(int j=0;j<12;j++){
          int gx=dx[j]+sx,gy=dy[j]+sy;
          if(abs(gx-x)<=1&&abs(gy-y)<=1&&gy>=0&&gx>=0&&gy<10&&gx<10){
            if(se.count(mk(gx,gy)))continue;
            t.push_back(mk(gx,gy));
            se.insert(mk(gx,gy));
          }
        }
      }v=t;
    }
    if(v.size())cout<<"OK"<<endl;
    else cout<<"NA"<<endl;}
  }
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define ll long long
#define ii pair <int, int>
#define dl pair <ll, ll>
#define vi vector <int>
#define vl vector <ll>
#define vii vector <ii>
#define REP(a, b) for (int i = a; i < b; i++)
#define REP2(a, b) for (int j = a; j < b; j++)
#define REPS(a, b, c) for (int i = a; i < b; i += c)

using namespace std;

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

    double d, t, s;
    cin >> d >> t >> s;
    if (d / s < t || abs(d / s - t) < 0.0000001) cout << "Yes\n";
    else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;
ll const MOD = 998244353;

void yes(){
    cout<<"YES"<<'\n';
}

void no(){
    cout<<"NO"<<'\n';
}

ll fact(int n){
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans = (ans*i)%MOD;
    }

    return ans;
}

ll powM(int n, int x){
    if(x==0){
        return 1;
    }
    if(x==1){
        return n%MOD;
    }

    if(x%2==0){
        ll a = powM(n,x/2);
        return (a*a)%MOD;
    }else{
        return (n*powM(n,x-1))%MOD;
    }
}

ll C(int n, int k){
    return (fact(n) * powM((fact(k)*fact(n-k))%MOD,MOD-2))%MOD;
}

ll A(int n, int k){
    return (fact(n) * powM(fact(n-k)%MOD,MOD-2))%MOD;
}


void solve(){
    int n;
    cin>>n;
    vi dp(3);
    int a[n][3];
    for(int i=0;i<n;i++){
        vi ndp(3,-10000000);
        cin>>a[i][0]>>a[i][1]>>a[i][2];

        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(k!=j){
                    ndp[k] = max(ndp[k],dp[j]+a[i][k]);
                }
            }
        }

        dp = ndp;
    }
    

    cout<<max(dp[0],max(dp[1],dp[2]))<<'\n';
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;
//start
const int limit = 2e5 + 1;
int k;
vector<int> g[limit];
bool vis[limit];

void dfs(int s,int k){
    if(k >= 2) return;

    for(auto it:g[s]){
        if(!vis[it]){
            vis[it] = true;
            dfs(it, k+1);
        } 
    }
}


int main(){
    int n,m;
    cin >> n >> m;

    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(0,0);

    if(vis[n-1]) cout << "POSSIBLE" <<endl;
    else cout << "IMPOSSIBLE" <<endl;

}


Measured memory_bytes: 12144
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int answer(double x){
    int t=0;
    if(round(x)-x==0){
        t=1;
    }
    return t;
}

int main(void){
    int n, d, x[10][10];
    int s=0;
    scanf("%d %d", &n, &d);
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            scanf("%d", &x[i][j]);
        }
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            double t=0;
            for(int k=0; k<d; k++){
                t+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            t=sqrt(t);
            //    printf("%lf: %d\n", t, answer(t));
            s+=answer(t);
        }
    }
    printf("%d", s);
    return 0;


}

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

template <typename T> void setmin(T& a, T b) {
	if (b < a) a = b;
}

using ll = long long;

ll c2, c3, c5, c1;
map<ll, ll> memo;

ll solve(ll n) {
	if (!memo.count(n)) {
		if (n <= 1) {
			memo[n] = n * c1;
		} else {
			ll res = 7e18;
			if (n <= res / c1) setmin(res, c1 * n);
			setmin(res, solve(n / 2) + c2 + c1 * (n % 2));
			setmin(res, solve(n / 3) + c3 + c1 * (n % 3));
			setmin(res, solve(n / 5) + c5 + c1 * (n % 5));
			if (n > 2) setmin(res, solve(n / 2 + 1) + c2 + c1 * (2 - n % 2));
			setmin(res, solve(n / 3 + 1) + c3 + c1 * (3 - n % 3));
			setmin(res, solve(n / 5 + 1) + c5 + c1 * (5 - n % 5));
			memo[n] = res;
		}
	}
	return memo[n];
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int T;
	cin >> T;
	while (T--) {
		memo.clear();
		ll n;
		cin >> n;
		cin >> c2 >> c3 >> c5 >> c1;
		cout << solve(n) << '\n';
	}
}


Measured memory_bytes: 4732
n=int(input())
timelist=[int(i) for i in input().split()]
drinknum=int(input())
for i in range(drinknum):
    timelist2=timelist[:]
    qnum,time=[int(i) for i in input().split()]
    timelist2[qnum-1]=time
    sumtime=0
    for t in timelist2:
        sumtime+=t
    print(sumtime)

Measured memory_bytes: 3064
#include<stdio.h>

struct Node_struct{int id, par, dep, left, right, sib, height;};
typedef struct Node_struct Node;
Node node[200000];

int dfs(int pos, int dep){
  node[pos].dep = dep;
  int a = 0, b = 0;
  if(node[pos].left != -1) a = dfs(node[pos].left, dep + 1);
  if(node[pos].right != -1) b = dfs(node[pos].right, dep + 1);
  node[pos].height = a < b? b:a;
  return node[pos].height + 1;
}

int main(){
  int i, j, k;
  int N;
  int id, left, right;
  int deg;
  int root;
  scanf("%d", &N);
  for(int i=0;i<N;i++) node[i].par = node[i].left = node[i].right = node[i].sib = -1;
  
  for(i=0;i<N;i++){
    scanf("%d %d %d", &id, &left, &right);
    node[id].id = id;
    node[id].left = left;
    node[id].right = right;
    if(left != -1) node[left].par = id, node[left].sib = right;
    if(right != -1) node[right].par = id, node[right].sib = left;
  }
  
  for(i=0;i<N;i++) if(node[i].par == -1) root = i;
  dfs(root, 0);

  for(i=0;i<N;i++){
    deg = (node[i].left != -1) + (node[i].right != -1);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
	   node[i].id, node[i].par, node[i].sib, deg, node[i].dep, node[i].height);
    if(node[i].par == -1) printf("root\n");
    else if(node[i].left == -1 && node[i].right == -1) printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}



Measured memory_bytes: 2104
N = int(input())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
X_Y = [abs(x-y) for x, y in zip(X, Y)]

for p in [1, 2, 3, 'inf']:
    if p == 'inf':
        d = max(X_Y)
    else:
        d = sum([x_y**p for x_y in X_Y]) ** (1/p)
    
    print(d)
    




Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n;
    cin >> n;
    set <string> s;
    rep(i, n) {
     string a, b;
     cin >> a >> b;
     if (a.at(0) == 'i') {
         s.insert(b);
     } else {
         if (s.count(b)) {
             cout << "yes" << endl;
         } else {
             cout << "no" << endl;
         }
     }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int n, k;
  cin >> n >> k;

  int res = 1;

  rep(i, n) {
    if (res * 2 < res + k) {
      res *= 2;
    } else {
      res += k;
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
<?php
$num = fgets(STDIN);
// 標準入力を一行ずつ配列に代入します
for ($i = 0; $i < $num; $i++) {
  $moti[$i] = trim(fgets(STDIN));
}
$count = -1;
$max = -1;
while ($max !== 0){
    $max = max($moti);
    for ($i = 0; $i < count($moti); $i++) {
        if ($moti[$i] == $max){
            $moti[$i] = 0;
        }
    }
    $count = $count + 1;
}
echo $count;
?>

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;

int main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];
    sort(all(A));
    ll aj = A.back();
    ll now = 0;
    ll ai = 0;
    rep(i,n-1){
        if (min(aj-A[i],A[i])>now){
            ai = A[i];
            now = min(aj - A[i], A[i]);
        }
    }
    cout << aj << " " << ai << endl;
}


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

int main()
{
    int N;
    int M;
    int X;
    int cost1 = 0;
    int cost2 = 0;
    vector<int> A;

    cin >> N;
    cin >> M;
    cin >> X;

    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }

    for (int i = 0; i < M; i++) {
        if(A[i] < X) {
            cost1 += 1;
        }
    }

    for (int i = 0; i < M; i++) {
        if(A[i] > X) {
            cost2 += 1;
        }
    }

    if(cost1 >= cost2) {
        cout << cost2 << endl;
    } else {
        cout << cost1 << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =  long long;
using P = pair<ll,int>;
const ll INF = 1ll<<60;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<P>> G(n);
    for (int i = 0; i < m; i++) {
        int r, l; ll d;
        cin >> r >> l >> d;
        r--; l--;
        G[l].push_back(P(d,r));
        G[r].push_back(P(-d,l));
    }

    vector<ll> dist(n,INF);
    for (int i = 0; i < n; i++) {
        if (dist[i] != INF) continue;
        dist[i] = 0;
        queue<int> que;
        que.push(i);
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            ll d = dist[v];
            for (auto nv : G[v]) {
                if (dist[nv.second] == INF) {
                    dist[nv.second] = dist[v] + nv.first;
                    que.push(nv.second);
                } 
                else if (dist[nv.second] != dist[v] + nv.first) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 16712
/*
 * AtCoder079-ARC-B.cpp
 *
 *  Created on: Aug 27, 2017
 *      Author: Hossam Eissa
 *      Idea: 
 */



#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5;
const double eps=1e-9;
ll arr[51];
int main(){
	ll k;
	cin>>k;
	int n=50;
	for(int i=0;i<n;i++)
		arr[i]=i;
	ll x=k/n;
	k-=x*n;
	for(int i=0;i<n;i++)
		arr[i]+=x;
	for(int i=0;i<n&&k;i++,k--){
		arr[i]+=n+1;
		for(int j=0;j<n;j++){
			arr[j]--;
		}
	}
	cout<<n<<endl;
	for(int j=0;j<n;j++)
		cout<<arr[j]<<" \n"[j==n-1];
	return 0;
}


Measured memory_bytes: 256