akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int N,K;

int main(int argc, char const *argv[])
{
    cin>>N>>K;
    vector<int> h(N);
    for(size_t i=0;i<h.size();i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    vector<int> h_diff(N-K+1);
    for(int i=0;i+K<=N;i++){
        h_diff[i]=h[i+K-1]-h[i];
    }
    int min = *std::min_element(h_diff.begin(), h_diff.end());
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int main(){
 int n,a,b;
  cin>>n>>a>>b;
 ll ans=0;
 rep2(i,1,n+1){
   string s=to_string(i);
   int m=s.size();
   int digitsum=0;
   rep(j,m) digitsum+=s[j]-'0';
   if(a<=digitsum&&digitsum<=b) ans+=i;
  digitsum=0;
 }
  cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int a[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
   // cin>>t;
    while(t--){
        string s;
        cin>>s;

        if(s[0]==s[1] or s[1]==s[2] or s[2]==s[3]){
            printf("Bad\n");
        }
        else{
            printf("Good\n");
        }

        //printf("Case %d: ",++te);
    }
    return 0;
}




Measured memory_bytes: 256
// Template by [thunder_blade]
// IIIT ALLAHABAD
// includes :)

#include <bits/stdc++.h>
#include <ext/rope> 
using namespace __gnu_cxx;
using namespace std;
#define TEST  int test_case; cin>>test_case; while(test_case--)
#define all(v) (v).begin(),(v).end()
#define fi  first
#define se  second
#define pb push_back
#define mp make_pair
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define pf(x) printf("%f\n",x)
#define ps(x) printf("%s\n",x)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%f",&x)
#define ss(x) scanf("%s",x)
#define pis(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pfs(x) printf("%f ",x)
#define pss(x) printf("%s ",x)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007

const int INF = (int)1e8;
const int N = 500005;
int A[N];

int main()
{
    int n;
    si(n);
    for(int i=0;i<n;i++){
        si(A[i]);
    }
    sort(A, A+n);
    int sum=0;
    for(int i=1;i<n;i++){
        sum += (A[i]-A[i-1]);
    }   

    pi(sum);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

//#include <map>

using namespace std;
int main()
{
	double r;
	cin >> r;

	cout << fixed << setprecision(6) << M_PI * r * r << " " << 2 * M_PI * r << endl;


	return 0;
}

Measured memory_bytes: 3296
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(max(a,b),c)-min(min(a,b),c)<<endl;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    float x, px, sum1=0, sum2=0;
    vector<float> X;
    cin >> n;
    while(cin >> x){
        X.push_back(x);
        sum1 += x;
    }
    //cout << sum1 << endl;
    px = round(sum1 / n);
    for(int i =0; i<n; i++){
        sum2 += (px - X[i])*(px - X[i]);
    }
    cout << sum2 << endl;
}

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

Measured memory_bytes: 1020
N = int(input())
A = list(map(int,input().split()))

B = [0] * N
for i,a in enumerate(A):
    if i < N- 1:
        B[i+1] = A[i] * 2 - B[i]
    else:
        diff = A[i] - (B[i] + B[0])//2

B = [diff]
for i,a in enumerate(A):
    if i < N-1:
        B.append(A[i]*2 - B[i])

print(*B)

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

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, s, n) for(int i = s; i < n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << endl
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define FOREACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;

//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );

//global-----------------------------------------------------------------------------------------------------------------------

//function---------------------------------------------------------------------------------------------------------------------
int main() {
    FOR(i, 1, 10){
        FOR(j, 1, 10){
            printf("%dx%d=%d\n", i, j, i * j);
        }
    }
    return 0;
}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.at(0)== s.at(1)){
      if(s.at(2)== s.at(3)&& s.at(0) != s.at(2)){
      cout << "Yes" <<endl;
      return 0;
      }else{
       cout << "No" << endl;
      }
  }else if(s.at(0)== s.at(2)&& s.at(0) != s.at(1)){
      if(s.at(1)== s.at(3)){
      cout << "Yes" <<endl;
      return 0;
      }else{
       cout << "No" << endl;
       return 0;
       }
  }else if(s.at(0)== s.at(3)){
        if(s.at(2)== s.at(1)&& s.at(0) != s.at(2)){
      cout << "Yes" <<endl;
      return 0;
      }else{
       cout << "No" << endl;
       return 0;
      }
  }else cout << "No" << endl;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector <long> l(N);
  for (int i = 0; i < N; ++i) {
    cin >> l[i];
  }
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int k = j + 1; k < N; ++k) {
        if (l[i] + l[j] > l[k] &&
            l[j] + l[k] > l[i] &&
            l[k] + l[i] > l[j] &&
            l[i] != l[j] &&
            l[j] != l[k] &&
            l[k] != l[i]) {
          ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
bool isPerfectSquare(long double x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 

int main()
{
   ll d,t,s,p;
   cin>>d>>t>>s;
    p = t*s;
    if(p>=d)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
long long bigger_b[100001];
long long a[100001];
long long b[100001];
int n;
long long hp;
int main()
{
	cin>>n>>hp;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	long long mxa=-999;
	for (int i=1;i<=n;i++)
	{
		if (a[i]>mxa) mxa=a[i];
	}
	int cnt=1;
	for (int i=1;i<=n;i++)
	{
		if (b[i]>mxa) {
			bigger_b[cnt]=b[i];
			cnt++;
		}
	}
	sort(bigger_b+1,bigger_b+cnt);
	cnt--;
	long long ans=0;
	while (hp>0){
		if (cnt==0) {
			if (hp%mxa>0) ans++;
			ans+=hp/mxa;
			hp=0;
		}
		else {
			hp-=bigger_b[cnt];
			cnt--;
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<char, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int a, b; cin >> a >> b;
    cout << max( { a + b, a - b, a * b } ) << endl;
}


Measured memory_bytes: 256
S = input()

year = int(S[0:4])
month = int(S[5:7])
day = int(S[8:])

if year<=2018:
    ans = 'Heisei'
elif year == 2019:
    if month<=4:
        ans = 'Heisei'
    else:
        ans = 'TBD'
else:
    ans = 'TBD'

print(ans)


Measured memory_bytes: 9112
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int D = scan.nextInt();
        int x = scan.nextInt();
        for (int i = 0; i < 10; i++) {
            x =  r * x - D;
            System.out.println(x);
        }
    }
}


Measured memory_bytes: 21844
from collections import deque
N, M = [int(_) for _ in input().split()]
G = [[] for i in range(N+1)]
for i in range(M):
    A, B = [int(_) for _ in input().split()]
    G[A].append(B)
    G[B].append(A)

visited = [False for i in range(N+1)]
mark = [0 for i in range(N+1)]
q = deque([1])
while len(q) != 0:
    p = q.popleft()
    for g in G[p]:
        if not visited[g]:
            q.append(g)
            mark[g] = p
            visited[g] = True

cnt_visited = len([v for v in visited if v])
if cnt_visited != N:
    print('No')
else:
    print('Yes')
    for i in range(2, N+1):
        print(mark[i])




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

int main(){

  int A, B;
  cin >> A >> B;
  if((A+B)%2==0){
    cout << (A+B)/2 <<endl;
  
  }else{
     cout <<"IMPOSSIBLE" << endl;
  }
  

  
  return 0;
}

Measured memory_bytes: 256
from sys import stdin,stdout
n=int(stdin.readline())
p,q,r=map(int,stdin.readline().split())
for i in range(1,n):
    a,b,c=map(int,stdin.readline().split())
    p1=max(a+q,a+r)
    q1=max(b+p,b+r)
    r1=max(c+p,c+q)
    p,q,r=p1,q1,r1
stdout.write(str(max(p,q,r))+'\n')

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  long long keep = 0, ans = 0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'B') keep++;
    else ans += keep;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
long long h;
cin>>h;
long long cnt=0;
long long ruizyou=1;
long long sum=0;
while(h>0){
    h/=2;
    cnt++;
}
for(int i=0;i<cnt;i++){
    sum+=ruizyou;
ruizyou=ruizyou*2;
}
cout<<sum<<endl;
}









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

using namespace std;
#define ll long long
#define ld long double

int n;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    cin >> n;
    int curMin = INT_MAX / 2;
    int ans = 0;
    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        if(x <= curMin) {
            curMin = x;
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}



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

int main(void) {
    long n;
    cin >> n;

    vector<long> p(n);
    for(auto &e: p) cin >> e, e--;
    vector<long> q(n);
    for(long i=0; i<n; i++)
        q[p[i]] = i;

    for(long i=0; i<n; i++)
        cout << 1l + 30000l*i << ' ';
    cout << endl;
    for(long i=0; i<n; i++)
        cout << 1l + 30000l*(n-1-i) + q[i] << ' ';
    cout << endl;
}


Measured memory_bytes: 896
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(line);
            Console.WriteLine(line[0] == 5 && line[1] == 5 && line[2] == 7 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 11220
#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

struct Point
{
    double x, y;
};

double distance(Point& p1, Point& p2)
{
    double dx = p1.x - p2.x;
    double dy = p1.y - p2.y;
    return sqrt(dx * dx + dy * dy);
}

int main()
{
    int n;
    cin >> n;
    vector<Point> ps(n);
    for (auto& p : ps)
    {
        cin >> p.x >> p.y;
    }

    double mean = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            mean += distance(ps[i], ps[j]);
        }
    }
    mean /= n * (n - 1) / 2;

    cout << setprecision(15) << (mean * (n - 1)) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int N,K,i,A;
  int h[100000];
  A=0;
  scanf("%d %d",&N,&K);
  for(i=0;i<=N-1;i++){
    scanf("%d",&h[i]);
  }
  for(i=0;i<=N-1;i++){
    if(h[i]>=K){
      A++;
    }
  }
  printf("%d",A);
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = mod * mod;

int p[2][200010];
int prank[2][200010];
int card[200010];

int findp(int v, int kind) {
	if (v != p[kind][v])return (p[kind][v]=findp(p[kind][v], kind));
	else return v;
}

bool isUnion(int v1, int v2, int kind) {
	return (findp(v1,kind) == findp(v2,kind));
}

void link(int x, int y, int kind) {
	if (isUnion(x, y, kind))return;
	int px, py;
	px = findp(x, kind);
	py = findp(y, kind);
	if (prank[py] < prank[px]) {
		p[kind][py] = px;
	}
	else {
		if (prank[kind][px] == prank[kind][py])prank[kind][py]++;
		p[kind][px] = py;
	}
	return;
}

int main(){
	int n,k,l;
	cin >> n>>k>>l;
	for (int i = 0; i < n; i++) {
		p[0][i] = p[1][i] = i;
		prank[0][i] = prank[1][i] = 0;
		card[i] = 1;
	}
	for (int i = 0; i < k; i++) {
		int x, y;
		cin >> x >> y;
		link(--x, --y, 0);
	}
	for (int i = 0; i < l; i++) {
		int x, y;
		cin >> x >> y;
		link(--x, --y, 1);
	}
	pii lis[200010],lis_s[200010];
	for (int i = 0; i < n; i++) {
		lis[i] = lis_s[i] = make_pair(findp(i, 0), findp(i, 1));
	}
	sort(lis_s, lis_s + n);
	for (int i = 0; i < n; i++) {
		cout << upper_bound(lis_s, lis_s + n, lis[i]) - lower_bound(lis_s, lis_s + n, lis[i]) << endl;
	}

	return 0;
}


Measured memory_bytes: 7680
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, long long> cnt;
    for (auto &&i : a)
    {
        cin >> i;
        if(!cnt.count(i)) cnt[i] = 0;
        cnt[i]++;
    }
    long long ans = 0;
    for (auto &&i : cnt)
    {
        ans += i.second  * (i.second - 1) / 2;
    }
    for (auto &&i : a)
    {
        cout << ans - cnt[i] + 1 << "\n";
    }
}

Measured memory_bytes: 10240
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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



/******************************************************************************************/


const ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1]) {
			ans++;
		}
	}
	cout << min(n - 1, ans + k * 2);

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int n;
	cin >> n;
	vector<int> b;
	REP(i, n - 1) {
		int tmp;
		cin >> tmp;
		b.emplace_back(tmp);
	}
	int ans = b[0] + b[b.size() - 1];

	REP(i, n - 2) {
		ans += min(b[i], b[i + 1]);
	}
	cout << ans;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	long long n = 0;
	for (int i = 0; i < s.size(); i++) {
		n += (s[i] - '0');
		n %= 9;
	}

	if (n % 9 == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int main(void){
    int n,r=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='R')r++;
    }
    if(r>n-r){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a,b;
    int sum = 0;
    cin>>a>>b;
    if(max(a,b)==a){
        sum += a;
        a -= 1;
        if (max(a,b)==a) {
            sum += a;
        }else{
            sum += b;
        }
    }else{
        sum += b;
        b -= 1;
        if (max(a,b)==b) {
            sum += b;
        }else{
            sum += a;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    
    int x=a, ow=0;
    for(int i=a;i<=a*b;){
        if(i%b==c){
            cout<<"YES"<<endl;
            ow=1;
            break;
        }
        i+=a;
    }
    
    if(ow!=1) cout<<"NO"<<endl;
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;
 
 
//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cerr << x[i] << " ";
        }
        cerr << x[x.size()-1] <<endl;
    }
}
 
template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cerr << q.top() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cerr << q.front() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}
 
int main(void) {
    LL n;
    cin >> n;
    map<string, LL> msi;
    REP(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        // cerr << s << endl;
        decltype(msi)::iterator it = msi.find(s);
        if(it != msi.end()) {
            it->second++;
        } else {
            msi.insert(make_pair(s, 0));
        }
    }
    LL ret = 0;
    for(auto x : msi) {
        // cerr << x.first << ", " << x.second << endl;
        ret += (x.second + 1) * x.second / 2;
    }
    cout << ret << endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

string sa;
long long int num[500005];

int main(){
	int n,m;
	int i,j,k;
	long long int a,b,c;
	cin>>sa;
	n=sa.size();
	for(i=0;i<n;i++){
		if(sa[i]=='<')num[i+1]=num[i]+1;
	}
	for(i=n-1;i>=0;i--){
		if(sa[i]=='>')num[i]=max(num[i],num[i+1]+1);
	}
	a=0;
	for(i=0;i<=n;i++){
		a+=num[i];
	}
	cout<<a<<endl;
}

Measured memory_bytes: 4740
def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    if N == 2:
        if A[0] == A[1]:
            print('YES')
        else:
            print('NO')
        exit()

    for v in range(1, N+1):
        if len(adj[v]) != 1:
            v0 = v
            break

    # from collections import deque
    que = deque()
    que.append(v0)
    seen = [-1] * (N+1)
    seen[v0] = 0
    par = [0] * (N+1)
    child = [[] for _ in range(N+1)]
    seq = []
    while que:
        v = que.popleft()
        seq.append(v)
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + 1
                par[u] = v
                child[v].append(u)
                que.append(u)

    for v in reversed(seq):
        if not child[v]:
            continue
        L = []
        for u in child[v]:
            L.append(A[u-1])
        if len(L) == 1:
            if L[0] != A[v-1]:
                print('NO')
                exit()
            continue
        s = sum(L)
        m = max(L)
        if s < A[v-1]:
            print('NO')
            exit()
        if A[v-1] < (s+1) // 2:
            print('NO')
            exit()
        if A[v-1] < m:
            print('NO')
            exit()
        A[v-1] = 2 * A[v-1] - s

    if A[v0-1]:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 82540
syogens = []
n = int(input())
for i in range(n):
    syogens.append([])
    a = int(input())
    for j in range(a):
        m,s=map(int,input().split())
        syogens[i].append([m,s])
ok = 0
for i in range(2**n):
    ng = False
    i2 = format(i,"b").zfill(16)
    i2 = i2[::-1]
    for k,j in enumerate(syogens):
        if i2[k] == "1":
            for l,j2 in enumerate(j):
                if str(j2[1]) != i2[j2[0]-1]:
                    ng = True
    if ng:
        ng = False
    else:
        if i2.count("1") > ok: ok = i2.count("1") 
print(ok)

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,cnt;
string s,t;

main() {
    cin >> n >> s >> t;
    rep(i,s.size()) {
        if (s[i] == t[cnt]) cnt++;
        else {cnt=0;if (s[i]==t[0]) cnt++;}
    }
    ct(max(n,(int)(s.size()+t.size()-cnt)))
}


Measured memory_bytes: 256
//テンプレート
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
    int H,W,h,w,ans=0,i,j;
    
    scanf("%d%d%d%d",&H,&W,&h,&w);
    H-=h;
    W-=w;
    int array[H][W];
    for (i=0; i<H; i++) {
        for (j=0; j<W; j++) {
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define F first
#define S second

using ll = long long;
int main() {
    int n;
    cin >> n;
    vector<pair<string, string>> a(n);
    double total = 0.0;
    for (int i = 0; i < n; i++) {
        cin >> a[i].F >> a[i].S;
        if (a[i].F.find('.') != string::npos) {
            double y = stod(a[i].F);
            total += y *  380000.0;
        } else {
            total += stoi(a[i].F);
        }
    }
    cout << fixed;
    cout.precision(10);
    cout << total;

    return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())

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

const int MAXN = 1e5 + 5;

int n;
ll c;

ll pref[MAXN];
ll best[MAXN];

ll x[MAXN], v[MAXN];
ll sol;

void solve() {

  REP(i, n) {
    pref[i] = v[i];
    if(i) {
      pref[i] += pref[i - 1];
    }

    best[i] = pref[i] - x[i];
    if(i) {
      best[i] = max(best[i], best[i - 1]);
    }
  }

  ll tmp = 0;
  for(int i = n - 1; i >= 0; --i) {
    tmp += v[i];

    if(i) {
      sol = max(sol, (x[i] - c) * 2 + tmp + best[i - 1]);
    }

    sol = max(sol, (x[i] - c) + tmp);
  }

  sol = max(sol, best[n - 1]);
}

ll nx[MAXN], nv[MAXN];

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

  cin >> n >> c;

  REP(i, n) {
    cin >> x[i] >> v[i];
  }

  solve();

  REP(i, n) {
    nv[n - i - 1] = v[i];
    nx[n - i - 1] = c - x[i];
  }

  memcpy(x, nx, sizeof x);
  memcpy(v, nv, sizeof v);

  solve();

  cout << sol;
}


Measured memory_bytes: 4992
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int k = sc.nextInt();
	int[] a = new int[n];
	for(int i=0; i<n; i++) {
		a[i] = sc.nextInt();
	}
	int[] b = new int[n+1];
	for(int i=0; i<n; i++) {
		b[a[i]]++;		
	}
	int cout1 = 0;
	for(int i=1; i<n+1; i++) {
		if(b[i] != 0) {
			cout1++;
		}
	}
	int cout2 = 0;
	int[] c = new int[n];
	int j =0;
	if(cout1 <= k) {
		System.out.println(0);
	} else {
		Arrays.sort(b);
		for(int i=0; i<n; i++) {
			if(b[i] != 0) {
				c[j] = b[i];
				j++;
			}
		}
		for(int i=0; i<cout1-k; i++) {
			cout2 += c[i];
		}
		System.out.println(cout2);
	}
}
}


Measured memory_bytes: 87652
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        int x;
        int mincost;
        int result =0;
        Scanner input =  new Scanner(System.in);
        x=input.nextInt();
        int[] arr = new int[x];
        for(int i =0 ;i<x;i++){
            arr[i]=input.nextInt();
        }

        Arrays.sort(arr);
        int min =Arrays.stream(arr).min().getAsInt();
        int max = Arrays.stream(arr).max().getAsInt();
        mincost = Integer.MAX_VALUE;
        for(int i=min;i<=max;i++){
            for(int j=0;j<arr.length;j++){
                result+=Math.pow(arr[j]-i,2);

            }
            if(result<mincost){
                mincost=result;
            }
            result=0;
        }

        System.out.println(mincost);

    }
}

Measured memory_bytes: 28112
//codeforces
//
#include "bits/stdc++.h"
using namespace std;
int main(){
	char arr[200001];
	cin >> arr;

	long long int len = strlen(arr), nums[2020] = {1}, ans = 0;;
	int mods[len], dp[200005] = {0};;

	mods[len - 1] = 1, mods[len - 2] = 10;

	for(int i = len - 3; i >= 0; i--){
		mods[i] = (mods[i + 1] * 10) % 2019;
	}

	for(int i = len - 1; i >= 0; i--){
		dp[i] = (dp[i + 1] + ((arr[i] - '0') * mods[i])) % 2019;
		nums[dp[i]]++;
	}

	for(int i = 0; i < 2020; i++){
		ans += (nums[i] * (nums[i] - 1)) / 2;
	}

	cout << ans;
}


Measured memory_bytes: 5336
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int result = 0;
    if (s.find("RRR") != string::npos) {
        result = 3;
    } else if (s.find("RR") != string::npos) {
        result = 2;
    } else if (s.find("R") != string::npos) {
        result = 1;
    }
    cout << result << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, j, i;
  cin >> a;
  c=0;
  vector<string> blue(100);
  for(i=0;i<a;i++) {
    cin >> blue.at(i);
  }
  cin >> b;
   vector<string> red(100);
  for(i=0;i<b;i++) {
    cin >> red.at(i);
  }
  for(i=0;i<a;i++) {
    d=0;
    for(j=0;j<100;j++) {
      if(blue.at(i) == blue.at(j)) {
        d++;
      }
      if(blue.at(i) == red.at(j)) {
        d--;
      }
         }
         if (d > c) {
           c=d;
         }
         }
         cout << c << endl;
         }

Measured memory_bytes: 256
n = gets.chomp.to_i
otoshi = 0.0

n.times do|i|
    ar = gets.chomp.split(" ")
    x = ar[0].to_f
    u = ar[1]
    if u == "JPY" then
        otoshi += x
    else
        otoshi += (x*380000.0)
    end
end
puts otoshi

Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
	int a, b, c, x, y;

	scanf("%d%d%d", &a, &b, &c);
	x = b - a;
	y = c - b;

	if (x == y) printf("YES\n");
	else printf("NO\n");

	return 0;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

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

ll n, k;
ll a[100010];
bool can = true;

bool solve() {
	ll res = a[0];
	for (int i = 0; i < n; i++) {
		res = gcd(res, a[i]);
	}

	if (res == 1 || k % res == 0) return true;

	return false;
}

int main(void){
	cin>>n>>k;
	ll maxv = -1;
	for (int i = 0; i < n; i++) {
		cin>>a[i];
		if (a[i] == k) {
			cout<< "POSSIBLE" <<endl;
			return 0;
		}
		maxv = max(maxv, a[i]);
	}

	if (maxv < k) can = false;

	if (solve() && can) cout<< "POSSIBLE" <<endl;
	else	cout<< "IMPOSSIBLE" <<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
  int i;
  int len;
  char s[1024],t[8192],u[6];
  while(fgets(s,1024,stdin)!=0){
    s[strlen(s)-1]=0;
    t[0]=0;
    len=strlen(s);
    for(i=0;i<len;i++){
      switch(s[i]){
      case 'A':sprintf(t,"%s100101",t);break;
      case 'B':sprintf(t,"%s10011010",t);break;
      case 'C':sprintf(t,"%s0101",t);break;
      case 'D':sprintf(t,"%s0001",t);break;
      case 'E':sprintf(t,"%s110",t);break;
      case 'F':sprintf(t,"%s01001",t);break;
      case 'G':sprintf(t,"%s10011011",t);break;
      case 'H':sprintf(t,"%s010000",t);break;
      case 'I':sprintf(t,"%s0111",t);break;
      case 'J':sprintf(t,"%s10011000",t);break;
      case 'K':sprintf(t,"%s0110",t);break;
      case 'L':sprintf(t,"%s00100",t);break;
      case 'M':sprintf(t,"%s10011001",t);break;
      case 'N':sprintf(t,"%s10011110",t);break;
      case 'O':sprintf(t,"%s00101",t);break;
      case 'P':sprintf(t,"%s111",t);break;
      case 'Q':sprintf(t,"%s10011111",t);break;
      case 'R':sprintf(t,"%s1000",t);break;
      case 'S':sprintf(t,"%s00110",t);break;
      case 'T':sprintf(t,"%s00111",t);break;
      case 'U':sprintf(t,"%s10011100",t);break;
      case 'V':sprintf(t,"%s10011101",t);break;
      case 'W':sprintf(t,"%s000010",t);break;
      case 'X':sprintf(t,"%s10010010",t);break;
      case 'Y':sprintf(t,"%s10010011",t);break;
      case 'Z':sprintf(t,"%s10010000",t);break;
      case ' ':sprintf(t,"%s101",t);break;
      case 39 :sprintf(t,"%s000000",t);break;
      case ',':sprintf(t,"%s000011",t);break;
      case '-':sprintf(t,"%s10010001",t);break;
      case '.':sprintf(t,"%s010001",t);break;
      case '?':sprintf(t,"%s000001",t);break;
      }
    }
    len=strlen(t);
    for(i=0;i<(5-len%5)%5;i++)
      sprintf(t,"%s0",t);
    len=strlen(t);
    for(i=0;i<len;i+=5){
      switch(atoi(strncpy(u,t+i,5))){
      case 0:printf("A");break;
      case 1:printf("B");break;
      case 10:printf("C");break;
      case 11:printf("D");break;
      case 100:printf("E");break;
      case 101:printf("F");break;
      case 110:printf("G");break;
      case 111:printf("H");break;
      case 1000:printf("I");break;
      case 1001:printf("J");break;
      case 1010:printf("K");break;
      case 1011:printf("L");break;
      case 1100:printf("M");break;
      case 1101:printf("N");break;
      case 1110:printf("O");break;
      case 1111:printf("P");break;
      case 10000:printf("Q");break;
      case 10001:printf("R");break;
      case 10010:printf("S");break;
      case 10011:printf("T");break;
      case 10100:printf("U");break;
      case 10101:printf("V");break;
      case 10110:printf("W");break;
      case 10111:printf("X");break;
      case 11000:printf("Y");break;
      case 11001:printf("Z");break;
      case 11010:printf(" ");break;
      case 11011:printf(".");break;
      case 11100:printf(",");break;
      case 11101:printf("-");break;
      case 11110:printf("'");break;
      case 11111:printf("?");break;
      }
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int e[3];
  cin >> e[0] >> e[1] >> e[2];
  sort(e, e + 3);
  cout << e[0] * e[1] / 2 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
        cout << "Possible";
    }
    else
    {
        cout << "Impossible";
    }
    
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
using namespace std;
int freqarr[10001];
int main()
{
  int N;
  cin>>N;
  int x;
  
  for(int i=1;i<=sqrt(N);i++){
    for(int j=1;j<=sqrt(N);j++){
      for(int k=1;k<=sqrt(N);k++){
        x=(i*i) +(j*j) +(k*k)+ (i*j)+ (j*k)+ (i*k);
        if(x<=N){
          freqarr[x]++;
        }
        else{
          break;
        }
      }
      
    }
  }
  for(int i=1;i<=N;i++){
    cout<<freqarr[i]<<endl;
  }
  return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n;cin >> n;
    int pre = 0, count = 0;
    int ans=0;
    //vector
    //REP()
    REP(i,n){
        int c;
        cin >> c;
        //cout << c << "\n";
        if(i==0){
            pre = c;
        }
        if(pre==c){
            count += 1;
        }else{
            ans += (count / 2);
            count = 1;
        }
        pre = c;
    }
    ans += (count / 2);

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
 
int main()
{
    // 入力
    map<int, int> mp1;
    map<int, int> mp2;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if(i % 2 == 0) mp1[a]++;
        else mp2[a]++;
    }

    // 最頻値から答えを求める１
    int max1 = 0;
    int key = 0;
    for(pair<int, int> m: mp1)
    {
        if(m.second > max1)
        {
            max1 = m.second;
            key = m.first;
        }
    }
    int max2 = 0;
    for(pair<int, int> m: mp2)
    {
        // mp1の最頻値となるkeyとは異なる値を選ぶ
        if(m.second > max2 && m.first != key) max2 = m.second;
    }
    int ans1 = (N/2 - max1) + (N/2 - max2);

    // 最頻値から答えを求める２
    max1 = 0;
    key = 0;
    for(pair<int, int> m: mp2)
    {
        if(m.second > max1)
        {
            max1 = m.second;
            key = m.first;
        }
    }
    max2 = 0;
    for(pair<int, int> m: mp1)
    {
        // mp2の最頻値となるkeyとは異なる値を選ぶ
        if(m.second > max2 && m.first != key) max2 = m.second;
    }
    int ans2 = (N/2 - max1) + (N/2 - max2);

    // 答えを出力
    int ans = min(ans1, ans2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8288
#include<bits/stdc++.h>
using namespace std;
#define lli long long
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli n,x;
  cin>>n;
  vector<lli> h;
  for(lli i=0;i<n;i++)
  {
    cin>>x;
    h.push_back(x);
  }
  vector<lli> dp(n,999999999);
  dp[0]=0;
  for(lli i=0;i<n;i++)
  {
    for(lli j=i+1;j<=i+2;j++)
    {
      if(j<n)
      {
      	dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
      }
    }
  }
  cout<<dp[n-1];
}

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

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    int[][] dp = new int[101][10001];
    int N, W;
    int[] v, w;

    void solve() throws IOException {
        N = ni();
        W = ni();
        v = new int[N];
        w = new int[N];
        for (int i = 0; i < N; i++) {
            v[i] = ni();
            w[i] = ni();
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= W; j++) {
                if (j < w[i]) {
                    dp[i + 1][j] = dp[i][j];
                } else {
                    dp[i + 1][j] = Math.max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
                }
            }
        }

        out.println(dp[N][W]);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 29200
N, C = map(int, input().split())
tv = [[0]*C for _ in range(100000)]
for _ in range(N):
    s, t, c = map(int, input().split())
    for i in range(s-1, t): tv[i][c-1] = 1
print(max([sum(tv[i]) for i in range(100000)]))

Measured memory_bytes: 107280
import java.util.Scanner;

/**
 * Created by malone on 2018/3/8.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int h = a / 3600, b = a % 3600, m = b / 60, s = b % 60;
        System.out.printf("%d:%d:%d\n", h, m, s);
    }
}


Measured memory_bytes: 26432
n=int(input())
l=[input().split() for i in range(n)]
l=[[x[0],int(x[1])] for x in l]
sorted_l=sorted([[x[0],-1*x[1]] for x in l]
                ,key=lambda x:(x[0],x[1]))

sorted_l=[[x[0],-1*int(x[1])] for x in sorted_l]

for x in sorted_l:
  print(l.index(x)+1)

Measured memory_bytes: 3064