akhauriyash/Code-Regression huggingface dataset:
//author-micheal corleone
//the godfaher
#include <bits/stdc++.h>
#include <set> 
#include<algorithm>

#include <set> 
#include<algorithm>
#define ll long long int


#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
 
using namespace std;
 
 bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[1] < v2[1]; 
}
 
 

ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
 
int main()
{
   cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    
     ll t;
    // cin>>t;
     t=1;
   while(t--)
    {
        ll n,i1,i2,k,m,j,j1,f,a1,i31,i3,j2,i5,i4,i6,i7,i;    
       i4=INT_MIN,i1=0;
       f=0;
      // string s1,s2,s3;
      ll res,res1,ans;
      ll s1,s2,s3;
      s2=0;
      s1=0;
      ll q;
      i31=0;
       string s;
       cin>>s;
       
	    res=(s.length()-1)/2;
	    res1=(s.length()+3)/2;
	    ll x=s.length()-1;
	    f(i,0,s.length()/2)
	    {
	    	if(s[i]!=s[x])
	    	{
	    		f=1;
	    		break;
			}
			else
			{
				f=0;
			}
			x--;
		}
		//cout<<f<<endl;
		if(s.length()==3 && f==0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		ll f2=0;
		ll x2=s.length()-1;
		ll rem=s.length()-res+1;
	//	cout<<res<<endl;
	//	cout<<(rem/2)+res<<endl;
		for(i=res1-1;i<(rem/2)+res1;i++)
		{
			if(s[i]!=s[x2])
			{
				f2=1;
				break;
			}
			else
			{
				f2=0;
			}
			x2--;
		}
       ll f3=0;
       ll x1=res-1;
         f(i,0,res/2)
         {
         	if(s[i]!=s[x1])
         	{
         		f3=1;
         		break;
         		
			 }
			 else
			 {
			 	f3=0;
			 }
         	x1--;
		 }
      
	 //  cout<<q<<endl;
	  
	  
	//  cout<<f<<" "<<f2<<" "<<f3;
	  if(f==1 || f2==1 || f3==1)
	  {
	  	cout<<"No"<<endl;
	  }
	 
	  else
	  {
	  	cout<<"Yes"<<endl;
	  }
      
     
      
   }
}

       
  

Measured memory_bytes: 256
INF=float('inf')

n=int(input())
P=list(map(float,input().split()))#0

dp=[[0 for i in range(n+1)] for j in range(n+1)]

for i in range(n+1):
  if i==0:
    dp[0][0]=1
  else:
    dp[i][0]=(1-P[i-1])*dp[i-1][0]

    
for j in range(1,n+1):
  for i in range(1,n+1):
    if i<j:
      continue
    dp[i][j]=P[i-1]*(dp[i-1][j-1])+(1-P[i-1])*(dp[i-1][j])

ans=0
for i in range(1,n+1):
  if i>=(n+1)//2:
    ans+=dp[n][i]
    
print(ans)

Measured memory_bytes: 224412
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h, w,i,j;
    char a[100][100];
    cin>>h>>w;
    for(i=0;i<h;++i)
        for(j=0;j<w;++j)
        cin>>a[i][j];

   for(i=1;i<=w+2;++i)
        cout<<'#';

   for(i=0;i<h;++i)
   {
      cout<<endl<<'#';

    for(j=0;j<w;++j)
   {
       cout<<a[i][j];
   }

   cout<<'#';
   }
   cout<<endl;
   for(i=1;i<=w+2;++i)
        cout<<'#';

        return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,C,cnt;
    cin >> N >> M >> C;
    vector<int> B;
    for(int i=0; i<M; i++){
        int x;
        cin >> x;
        B.push_back(x);
    }

    for(int i=0; i<N; i++){
        int s=C;
        for(int j = 0; j < M; j++)
        {
            int x;
            cin >> x;
            s += x * B[j];
        }
        //cout << s;
        if (s>0) cnt++;
    }
    
    cout << cnt;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<iterator>

int main(){
	int n,x;
	std::cin >> n >> x;
	auto v = std::vector<int>(std::istream_iterator<int>(std::cin),std::istream_iterator<int>());

	long sum = 0;
	int i = 0;
	for (i = 0; i < n; i++)
	{
		if(sum + v[i] <= x){
			sum += v[i];
       }else{
			break;
		}

	}

	std::cout << i + 1 ;
	

}

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

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


Measured memory_bytes: 3080
n=gets.to_i
a=[]
b=[]
c=0

n.times{|i|
  a[i],b[i]=gets.split.map &:to_i
}


(n-1).downto(0){|i|
  c+=(b[i]-(a[i]+c)%b[i])%b[i]
}

puts c


Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
#define M 1e9 + 5
#define C 998244353
#define pi 3.14159265359
#define loop(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define rloop(i,a,b) for(ll i = ll(a); i >= ll(b); --i)
#define sloop(i,a) for (std::set<ll>::iterator i = a.begin(); i != a.end(); ++i)
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;

int solve(){
    ll n,p,k=0,r,ans=0;
    cin >> n>>k;
    vector<ll> a(n);
    loop(i,0,n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    loop(i,0,k){
        ans += a[i];
    }
    cout << ans << "\n";
    return 0;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    loop(f,0,t){    
        solve();
    }   
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n,d;
  std::cin >> n >> d;

  vt<vt<double>> X(n,vt<double>(d));
  rep(i,n)
    rep(j,d)
      std::cin >> X[i][j];

  int ans = 0;
  rep(i,n-1) {
    for(int cnt = i+1; cnt < n; cnt++) {
      double ddi = 0;
      rep(j,d)
        ddi += (X[i][j] - X[cnt][j])*(X[i][j] - X[cnt][j]);
      ddi = sqrt(ddi);
      int idi = ddi;
      if(idi == ddi)
        ++ans;
    }
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A

def solve(N, A):
    is_approved = True
    for a in A:
        if a % 2 == 0:
            if not (a % 3 == 0 or a % 5 == 0):
                is_approved = False
                break
    return 'APPROVED' if is_approved else 'DENIED'


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 3060
import java.util.Scanner

import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    val arr = Array.fill(n)(0)
    A.foreach { i =>
      arr(i-1) += 1
    }
    arr.mkString("\n")
  }


  println(solve())

}



Measured memory_bytes: 78136
#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <unordered_map>
#include <set>
#include <cassert> //assart
#include <numeric>
#include <iterator>
#include <list>
#include <tuple>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(int i=(max);i>=(min);i--)
const int MOD=1e9+7;
const int MOD2=998244353;
const int not0=1;
const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2 || not0){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
#define isdiff5(a,b,c,d,e) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c) and (e)!=(a) and (e)!=(b) and (e)!=(c) and (e)!=(d))
#define Func3(f,a,b,c) (f)((f)((a),(b)),(c))
#define Func4(f,a,b,c,d) (f)((f)((f)((a),(b)),(c)),(d))

inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！
//inline ll  ceil(double a){return (ll)a+1;}
//ans = accumulate(A, A+N, 0, [](int a, int b) {return gcd(a,b);});
//auto count = std::count_if(v.begin(), v.end(), [](int x) { return x == 1 || x == 3; } );




//Eと名のつくのはデバッグ用！
int EintN(ll array[],const ll num){
    for(int i=0;i<num;i++){cerr<<array[i]<<" ";}
    br;
    return 0;
}
//int EintNN(const int heighth,const int width,int array[heighth][width]){
//    FOR(i, 0, heighth){
//        FOR(k, 0, width){
//            {cerr<<array[i][k]<<" ";}
//        }
//        br;
//    }
//    br;
//    return 0;
//}
int Eint(string str,const ll num){
    cerr<<str<<" is "<<num<<" now."<<endl;
    return 0;
}












ll probA(){
    ll ans;ans=0;
    string S,T;
    cin>>S>>T;
    FOR(i,0 , 3){
        if(S[i]==T[i])ans++;
    }
    OutputAndReturn0(ans);
    return 0;
}

ll probB(){
    ll ans;ans=0;
    
    OutputAndReturn0("Yes");
    return 0;
}

ll probC(){
    ll ans;ans=0;
    
    OutputAndReturn0("Yes");
    return 0;
}

ll probD(){
    ll ans;ans=0;
    
    OutputAndReturn0("Yes");
    return 0;
}

signed main(){
    probA();
    return 0;
}


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

int main () {
	int k;
  	cin >> k;
  	vector<long long> a;
  	for (int i=1;i<=9;++i) a.push_back(i);
  	while (1) {
    	if (k <= a.size()) {
        	cout << a[k-1] << endl;
            return 0;
        }
      	k -= a.size();
      	vector<long long> old;
      	swap(old, a);
      	for (long long x : old) {
          for (int i = -1; i <= 1; ++i) {
            	int d = x%10 + i;
            	if (d < 0 || d > 9) continue;
            	long long nx = x*10 + d;
            	a.push_back(nx);
            }
        }
    }
  return 0;
  	
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n, q; cin >> n >> q;
    string s; cin >> s;
    vector<ll> a(n, 0);
    for(ll i=1; i<n; i++){
        a[i] = a[i-1];
        if(s[i-1] == 'A' && s[i] == 'C'){
            a[i]++;
        }
    }
    REP(i, q){
        ll l, r; cin >> l >> r;
        cout << a[r-1] - a[l-1] << endl;
    }

}

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

Measured memory_bytes: 1872
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<string>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i=0; i<4; i++) {
    for (int j=0; j<4; j++) {
      if (s[i] == s[j]) cnt++;
    }
  }
  if (cnt==8) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    string fst, snd;
    cin>>fst>>snd;
    if(fst.length() == snd.length()-1 && fst == snd.substr(0, fst.length()))
        cout<<"Yes";
    else
        cout<<"No";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3584
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
let outl s = stdout.WriteLine(s|>string)
let outsep ls = stdout.WriteLine(String.concat " " (ls|>Array.map string))
let outsepl ls = stdout.WriteLine(String.concat "\n" (ls|>Array.map string))
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let N,K=R2 int int
    let p=RS int64
    let gen =seq{
        let mutable sum = Array.sum(p.[0..K-1])
        yield sum
        for i in [K..N-1] do
            sum<-sum-(p.[i-K])+(p.[i])
            yield sum
    }
    [|for x in gen -> x|]
    |>Array.max
    |>fun c-> ((c+(K|>int64))|>double)/(2.0|>double)
    |>outl
    0
    

Measured memory_bytes: 36696
#include <iostream>
#include <set>
#include <utility>
using namespace std;
    
int n, m;
set<pair<int, int>> v;
set<int> w;

void center_point(){
    for(auto x: v){
        if(n == x.first)
            w.insert(x.second);
        else if(n == x.second)
            w.insert(x.first);
    }
}

bool search(){
    for(auto x: w){
        if(v.find(make_pair(x, 1)) != v.end()) return true;
        if(v.find(make_pair(1, x)) != v.end()) return true;
    }
    return false;
}

void solve(){
    center_point(); // Nから逆にたどって行ける島のリストをwに突っ込む
    if(search()){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    int a, b;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        v.insert(make_pair(a, b));
    }
    solve();
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

/*vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, m, r;
string s;
	
vll a[10];
multiset<ll> S;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	ll sum = 0;
	for(ll i=0;i<n;i++) {
		cin >> x;
		sum += x;
		S.insert(x);
	}

	if(sum%10) {
		cout<<sum;
		return;
	}

	for(auto it : S) {
		if((sum - it)%10) {
			cout<<sum - it;
			return;
		}
	}

	cout<<0;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main(){
int a[5];
int i,k,l;

for(i=0;i<5;i++){
    cin>>a[i];
}

cin>>k;
for(i=0;i<5;i++){
    for(int j=0;j<5;j++){
     	if(a[i]-a[j]>k){
          	l=1;
          	break;
     	}
      	else{
          l=0;
        }
    }
}
if(l==0){
    cout<<"Yay!";
}
else{
	cout<<":(";
}

}

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

using namespace std;

int main(){
    int H,W,K,ans=1e9;
    cin >> H >> W >> K;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }

    for(int i=0;i<pow(2,H-1);i++){

        int tmp=0,now=0;
        vector<int> sum(H,0),num(H);
        num[0] = 0;

        for(int j=0;j<H-1;j++){
            if( (i>>j & 1) == 1){
                tmp++;
                now++;
            }
            num[j+1] = now;
            //cout << num[j+1] << endl;
        }

        for(int j=0;j<W;j++){
            vector<int> one(now+1,0);

            for(int k=0;k<H;k++){
                if(S[k][j]=='1'){
                    sum[num[k]]++;
                    one[num[k]]++;
                }
            }

            bool div = false,out=false;

            for(int k=0;k<=now;k++){
                if(K<one[k]){
                    out = true;
                    break;
                }
            }

            if(out){
                tmp = 1e9;
                break;
            }

            for(int k=0;k<=now;k++){
                if(K<sum[k]){
                    tmp++;
                    div = true;
                    break;
                }
            }

            if(div){
                for(int k=0;k<=now;k++){
                    sum[k] = one[k];
                }
            }

        }

        ans = min(tmp,ans);
    }

    cout << ans <<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {
            int[] nm = GetIntList(Console.ReadLine());
            int count = 0;
            int[,] lines = new int[nm[0],30];
            int[] firstNum = new int[nm[0]];
            for(int aaa = 0; aaa < nm[0]; aaa++)
            {
                int[] getline = GetIntList(Console.ReadLine());
                firstNum[aaa] = getline[0];
                for(int b = 0; b < getline[0]; b++)
                {
                    lines[aaa, b] = getline[b+1];
                }
            }

            for(int i = 1; i < 31; i++)
            {
                var list = new List<int>();
                for(int asdf = 0; asdf < nm[0]; asdf++)
                {
                    for (int j = 0; j < firstNum[asdf]; j++)
                    {
                        list.Add(lines[asdf, j]);
                    }

                }
                if (list.Count(value => value == i) == nm[0])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
            Console.ReadLine();

        }
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();

        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,m,K;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
char mp[7][7],tmp[7][7];
int ans;
inline void paint(int str,int stc) {
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j)
			tmp[i][j]=mp[i][j];
	for (int i=1;i<=n;++i)
		if (str&(1<<(i-1))) {
			for (int j=1;j<=m;++j)
				tmp[i][j]='r';
		}
	for (int j=1;j<=m;++j)
		if (stc&(1<<(j-1))) {
			for (int i=1;i<=n;++i)
				tmp[i][j]='r';
		}
}
inline int count() {
	int ret=0;
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j)
			ret+=(tmp[i][j]=='#');
	return ret;
}
int main() {
	n=read(),m=read(),K=read();
	for (int i=1;i<=n;++i)
		scanf("%s",mp[i]+1);
	for (int str=0;str<(1<<n);++str)
		for (int stc=0;stc<(1<<m);++stc) {
			paint(str,stc);
			if (count()==K) {
				++ans;
			}
		}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
struct point
{
    int x,y;
};

int getlen(ll x)
{
    int ans=0;
    while(x>0)
    {
        ans++;
        x/=10;
    }
    return ans;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    int ans=getlen(n);
    for(ll i=2; i*i<=n; ++i)
    {
        if (n%i==0)
        {
            ans = min(ans,getlen(n/i));
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,K,C;
char S[200010];
signed main(){
    scanf("%lld",&N);
    //N-1の1以外の約数を求める
    int cnt1=-1;//1を抜く
    for(int i=1;i<sqrt(N-1)+1;i++){
        if(i*i>N-1)continue;
        if((N-1)%i==0){cnt1++;
            if(i*i!=(N-1))cnt1++;
        }
        //printf("%lld-",cnt1);
    }
    //Nの約数について調べる
    int cnt2=0;
    for(int i=1;i<sqrt(N)+1;i++){
        if(i*i>N)continue;
        if(N%i==0){
            if(i!=1){
                int n=N;
                while(n%i==0){
                    n=n/i;
                }
                n=n%i;
                if(n==1)cnt2++;
            }
            //逆についても調べる
            int j=N/i;
            if(i!=j){
                int n=N;
                while(n%j==0){
                    n=n/j;
                }
                n=n%j;
                if(n==1)cnt2++;
            }
        }
    }
    printf("%lld\n",cnt1+cnt2);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int r=n%10;
  if(r==3)
    cout<<"bon";
  else if(r==0 or r==6 or r==1 or r==8)
    cout<<"pon";
  else
    cout<<"hon";
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

template<int BUFSIZE>
struct ans_buf {
  char buf[BUFSIZE];
  int i;
  ans_buf(): i(0) {}
  void putZ(uint64_t v, char delim='\n') {
    uint64_t k = 1;
    while(k <= v/10) k*=10;
    for(; k>0; v%=k, k/=10) buf[i++] = (v/k)+'0';
    buf[i++] = delim;
  }
  void out() { std::fwrite(buf, 1, i, stdout); }
};

int const MAXN = 1000;
int N, M;
std::vector<int> G[MAXN];
bool used[MAXN];

int nv[MAXN], n;
bool dfs(int v) {
  used[v] = true;
  for(auto c: G[v]) {
    nv[v] = c;
    if(c == n) return true;
    if(!used[c] && dfs(c)) return true;
  }
  return false;
}

int main() {
  N = getZ(); M = getZ();
  for(int i = 0; i < M; ++i) G[getZ()-1].push_back(getZ()-1);
  for(int i = 0; i < N; ++i) {
    std::fill_n(used, N, false);
    if(dfs(n = i)) break;
    n = -1;
  }
  if(n < 0) fin(n);
  for(;;) {
    std::fill_n(used, N, false);
    used[n] = true;
    for(int k = nv[n]; k!=n; k=nv[k]) used[k] = true;
    bool ok = true;
    for(int i = 0; i < N; ++i) if(used[i]) {
      for(auto c: G[i]) if(used[c] && c != nv[i]) {
        nv[i] = n = c;
        ok = false;
        break;
      }
      if(!ok) break;
    }
    if(ok) break;
  }
  int ans = 0;
  for(int i = 0; i < N; ++i) if(used[i]) ++ans;
  ans_buf<4000> buf;
  buf.putZ(ans); 
  for(int i = 0; i < N; ++i) if(used[i]) buf.putZ(i+1);
  buf.out();
  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define llu long long unsigned
#define ll long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define ull unsigned long long int
#define pii pair<ll,ll>
#define vll vector<ll>
#define vp vector<pii>
#define mp make_pair
#define lb "\n"
#define ins insert
#define fon(i,n) for(int i = 0;i<n;i++)
#define foa(i,a) for(auto i = a.begin();i!=a.end();i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define INF 100000007
#define sz size
#define len length
ll max(ll x,ll y){if(x>y)return x;else return y;}
ll min(ll x,ll y){if(x>y)return y;else return x;}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
ll i,j,k,n,x,y;
cin>>n>>x>>y;
vll a(n,0);
if(x>y)
    swap(x,y);
rep(i,1,n)
rep(j,i+1,n+1)
{
    if(((i<=x)&&(j<=x))||((i>=y)&&(j>=y)))
        a[j-i]++;
    else if((i<=x)&&(j>=y))
        a[x-i+j-y+1]++;
    else if((i<=x)&&(j<=y))
    a[x-i+min(j-x,y-j+1)]++;
     else if((i>=x)&&(j>=y))
    a[j-y+min(i-x+1,y-i)]++;
    else
        a[min(j-i,i-x+y-j+1)]++;

}
rep(i,1,n)
cout<<a[i]<<lb;

return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


void try00(const string& s){
	int n = sz(s);
	VI ans(n), kgr, atm;
	rep(i, n){
		if(s.substr(i, 2)=="LR" ) kgr.push_back(i+1);
		if(s.substr(i, 2)=="RL" ) atm.push_back(i);
	}
	kgr.push_back(n);
	
	int stt =0;
	rep(i, sz(kgr)){
		int m = kgr[i] - stt;
		ans[atm[i]] = ans[atm[i]+1] = m/2 ;
		if(m%2){
			if(stt%2 == atm[i]%2) ans[atm[i]]++; else ans[atm[i]+1]++;
		}
		stt = kgr[i];
	}
	
	for(auto x :ans) cout<<x<<" "; cout<<"\n";
}

void try02(const string& s){
	const int n = sz(s);
	VI ans(n), cur(n);
	
	rep(i, n) cur[i] = s[i]=='L'? i-1: i+1;
	rep(i, 50){
		VI nxt(n);
		rep(j, n) nxt[j] = cur[cur[j]];
		swap(cur, nxt);
		
	}
	rep(i, n) ans[cur[i]]++;
	for(auto x :ans) cout<<x<<" "; cout<<"\n";
}
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s; cin >>s;
	//try00(s);
	try02(s);
	return 0;
	
}


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

using namespace std;

const int MAX_N = 1e5+1e3;
const int INF = (1<<30);

int main(int argc, char const *argv[])
{
	int N, h[MAX_N]={0}, K;
	int dp[MAX_N];
	cin >> N >> K;
	for (int i = 0; i < N; ++i) scanf("%d", &h[i+1]);

	fill(dp, dp+MAX_N, INF);
    dp[0] = 0;
    dp[1] = 0;

    for (int i = 1; i <= N; ++i) {
        for (int k = 1; k <= K && k+i <= N; ++k) {
            dp[i+k] = min(dp[i+k], dp[i]+abs(h[i]-h[i+k]));
        }
    }

    cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int k, i, n;
	string str;
	cin >> n;
	vector2d(cnt, int, 26, n, 0);
	for (k = 0; k < n; k++){
		string s;
		cin >> s;
		for (i = 0; i < s.size(); i++) cnt[s[i] - 'a'][k]++;
	}
	for (k = 0; k < 26; k++){
		int len = *min_element(full(cnt[k]));
		for (i = 0; i < len; i++) str += (char)(k + 'a');
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, Y = map(int, input().split())

a = 0
for x in range(N+1): 
    for y in range(N-x+1):
        if (10000*x + 5000*y + 1000*(N-x-y)) == Y:
            print(str(x)+" "+str(y)+" "+str(N-x-y))
            a = 1
            break
    if a == 1:
        break

if a != 1:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include <iostream> // includes cin to read from stdin and cout to write to stdout
#include <math.h>
using namespace std; // since cin and cout are both in namespace std, this saves some text

int main()
{
    int N;
    cin >> N;
    const int units[3]{1, 6, 9};
    
    int dp[100001][3];
    for (int i = 0; i <= N; ++i) dp[i][0] = i;
    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j < 3; ++j)
        {
            dp[i][j] = dp[i][j-1];
            for (int l = 1; l < 8; ++l)
            {
                int x = pow(units[j], l);
                if (x > i) break;
                
                int cnt = 1 + dp[i - x][2];
                if (dp[i][j] > cnt)
                {
                    dp[i][j] = cnt;
                }
            }
        }
    }
    cout << dp[N][2] << endl;
    
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
long long a[2010];
long long b[2010][2010];
int main()
{   
	int n;
	long long minx,sum,tmp,x;
    scanf("%d%lld",&n,&x);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
    {
    	b[i][0]=a[i];
    	for(int j=1;j<n;j++)
    	{
    		tmp=i-j;
    		if(tmp<=0) tmp=n+tmp;
    		b[i][j]=min(b[i][j-1],a[tmp]);	
		}
	}
    minx=1e14;
    for(int i=0;i<n;i++)
	{
        sum=0;
        for(int j=1;j<=n;j++)
            sum+=b[j][i];
        sum+=i*x;
        minx=min(sum,minx);
    }
    printf("%lld\n",minx);
    return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define N_MAX 100100

int main(int argc, char *argv[])
{
    // input values
    int N, K;
    std::cin >> N >> K;

    std::vector<int> h(N);
    for (int i = 0; i < N; i++) {
        std::cin >> h[i];
    }

    // dp table
    std::vector<int> dp(N_MAX, INF);

    // init dp table
    // ok

    // init condition
    dp[0] = 0;

    // loop
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            chmin(dp[i+j], dp[i] + std::abs(h[i+j] - h[i]));
        }
    }

    std::cout << dp[N-1] << std::endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    int n,k;
    string s;
    cin >> n >> k >> s;
    char x = '1';
    int c = 0;
    vector<int> v;
    rep(i,n){
        if(s[i]!=x){
            v.push_back(c);
            x = s[i];
            c = 1;
        }else{
            c++;
        }
        if(i==(n-1)) v.push_back(c);
    }
    int ans = 0;
    if((v.size()%2)==0) v.push_back(0);
    if((v.size()/2)<k){
        rep(i,v.size()) ans += v[i];
    }else{
        int a = 0;
        rep(i,2*k+1) a += v[i];
        ans = max(a,0);
        for(int i=2*k+3;i<=v.size();i=i+2){
            a += v[i-1] + v[i-2] - v[i-2*k-3] - v[i-2*k-2];
            ans = max(ans,a);
        }
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 1020
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,i,j,t;
            cin>>n>>t;
            ll dp[n+1][t+1];
            for(i=0;i<=n;++i)
                for(j=0;j<=t;++j)
                    dp[i][j]=0;
                vector<pll> v;
            ll ar[n+1],ar2[n+1];
            for(i=1;i<=n;++i)
            {
                cin>>ar[i]>>ar2[i];
                v.pb({ar[i],ar2[i]});
            }
            sort(v.begin(),v.end());
            for(i=1;i<=n;++i)
                ar[i]=v[i-1].f,ar2[i]=v[i-1].s;
            ll maxi=0;
            for(i=1;i<=n;++i)
            {
                for(j=0;j<=t-1;++j)
                {
                    dp[i][j]=dp[i-1][j];
                }
                for(j=0;j<=t-1;++j)
                {
                    if(j+ar[i]>=t)
                    {
                        maxi=max(maxi,ar2[i]+dp[i-1][j]);
                    }
                    else
                    {
                        dp[i][j+ar[i]]=max(dp[i][j+ar[i]],dp[i-1][j]+ar2[i]);
                        maxi=max(maxi,dp[i][j+ar[i]]);
                    }
                }
                for(j=1;j<=t-1;++j)
                {
                    dp[i][j]=max(dp[i][j],dp[i][j-1]);
                    //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
                }
            }
            for(i=0;i<=n;++i)
                for(j=0;j<=t;++j)
                    maxi=max(dp[i][j],maxi);
            cout<<maxi<<endl;
        }
        return 0;
    }


Measured memory_bytes: 70912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_019_42
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //new Logic_A().Start();
            new Logic_B().Start();
            Console.ReadLine();
        }

        public class Logic_B
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var N = Convert.ToInt32(str[0]);
                var L = Convert.ToInt32(str[1]);

                var s = new List<string>();
                for (int i = 0; i < N; i++)
                {
                    s.Add(Console.ReadLine());
                }
                var list = s.OrderBy(n => n);
                var result = string.Empty;
                foreach (var t in list)
                {
                    result += t;
                }
                Console.WriteLine(result);
            }
        }
}
}

Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,a,max=0,min;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(i==0)
			min=a;
		if(a>max)	
			max=a;
		if(a<min)
			min=a;
	}
	printf("%d",max-min);
	return 0;
}


Measured memory_bytes: 384
<?php 
fscanf(STDIN, "%d %d", $n, $y);
$flag = 0;
for ($i=$n; $i >= 0 ; $i=$i-1) {
  // 10000円
  for ($j=$n-$i; $j >= 0 ; $j=$j-1) {
    // 5000円
    $k = $n-$i-$j;
      if((10000*$i + 5000*$j + 1000*$k) == $y){
        echo "{$i} {$j} {$k}";
        $flag = 1;
        break 2;
      }
    }
  }
if($flag == 0){
  echo "-1 -1 -1";
}
?>


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

struct section {
    double l, r, y;

    double f(double x) {
        if (x < l) return y + (l - x);
        if (x > r) return y + (x - r);
        return y;
    }
};

int main() {
    int n;
    double t0 = 0, t1 = 0;
    cin >> n;
    vector<section> v(n + 2);
    for (int i = 0; i < n; i++) {
        t0 = t1;
        cin >> t1;
        t1 += t0;
        v[i + 1].l = t0, v[i + 1].r = t1;
    }
    for (int i = 0; i < n; i++) {
        double y;
        cin >> y;
        v[i + 1].y = y;
    }
    v[0].r = v[0].l = v[0].y = v[n + 1].y = 0;
    v[n + 1].r = v[n + 1].l = t1;
    double p0 = 0, p1 = 100000.0, ans = 0;
    for (double x = 0.5; x <= t1; x += 0.5) {
        for (int i = 0; i < n + 2; i++) {
            p1 = min(p1, v[i].f(x));
        }
        ans += (p1 + p0) / 4.0;
        p0 = p1;
        p1 = 100000.0;
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

def solve():
    N, K = [int(_) for _ in raw_input().split()]
    ret = 0
    coin_prob = 1
    tmp_cnt = 0
    start = N
    if N >= K:
        ret += (N - K + 1) * 1.0 / N
        start = K - 1
    for i in range(start,0,-1):
        cnt = int(math.ceil(math.log(K * 1.0 / i, 2)))
        coin_prob *= (0.5 ** (cnt - tmp_cnt))
        tmp_cnt = cnt
        ret += coin_prob / N
    print str(ret)

if __name__ == '__main__':
    solve()


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

int main(){
vector<int> x(3);

    for(int i = 0; i < 3; i++){ 
        cin >> x.at(i);
    }

sort(x.begin(),x.end());
reverse(x.begin(),x.end());

int ans = x.at(0) * 10 + x.at(1) + x.at(2);

cout << ans << endl; 

}


Measured memory_bytes: 256
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())

n, m = mi()
a = [li() for i in range(n)]
a.sort(reverse=True)
rem = m
sm = 0
while a:
    rate, cnt = a.pop()
    take = min(rem, cnt)
    sm += take * rate
    rem -= take
print(sm)

Measured memory_bytes: 27772
#include <bits/stdc++.h>
using namespace std;
 
struct node{
	int p,y;
}x[100005];
 
bool cmp(node a,node b)
{
	if(a.p==b.p) return a.y<b.y;
	return a.p<b.p;
}
 
int a[100005],b[100005];
 
map<pair<int , int >,int >m1;
 
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		x[i].p=a[i];
		x[i].y=b[i];	
	}
	sort(x+1,x+m+1,cmp);
	int t=0,tt=1;
	for(int i=1;i<=m;i++)
	{
		if(x[i].p==t){
			m1[make_pair(x[i].p,x[i].y)]=tt;
			tt++;
		}
		else{
			m1[make_pair(x[i].p,x[i].y)]=1;
			tt=2;
			t=x[i].p;
		}
	}
	for(int i=1;i<=m;i++)
	{		
		printf("%06d%06d\n",a[i],m1[make_pair(a[i],b[i])]);
	}
	return 0;
} 

Measured memory_bytes: 11136
function Main(arg) {
 
    var N = arg.split("\n")[0]-0;
    var S = arg.split("\n")[1].split("");
 
    var ans = 0;
    var prev = "";

    S.map(function (v) { 

        if (v !== prev) ans ++;
        prev = v;
    });

    console.log(ans)

    return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 23368
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>

#define rep(i,n) for(int i=0;i< (n);++i)
typedef long long ll;

using namespace std;


int main(){
    int N,W;
    
    cin>>N>>W;
    
    ll d[N+1][W+1];
    
    rep(i,N+1)rep(j,W+1)d[i][j]=0;
    
    ll w,v;
    
    for(int i=1;i<=N;++i){
        cin>>w>>v;
        
        for(ll j=1;j<=W;++j){
            if(j<v){
                d[i][j]=d[i-1][j];
                
            }else{
                d[i][j]=max(d[i-1][j-v]+w,d[i-1][j]);
            }
            
        }
        
    }
    
    cout<<d[N][W]<<endl;
    
 
    
}


Measured memory_bytes: 10996
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a,b,c=1,i;
    cin>>a>>b;
    for(i=0;i<a;i++){
        c=c*2;
        if(c>b){
            break;
        }
        
    }
    for(int j=0;j<a-i-1;j++){
        c=c+b;
    }
    cout<<c<<endl;
    
}

Measured memory_bytes: 256
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp
import itertools
import functools

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N,C = ria()
D = rian(C)
c = rian(N)

syukei = [ [0]*(C+1) for _ in range(3) ]
for i in range(N):
  for j in range(N):
    syukei[(i+j)%3][c[i][j]] += 1

@functools.lru_cache(C*3)
def f2(color, mod3):
  ret_ = 0
  for color_now in range(1, C+1):
    ret_ += D[color_now-1][color-1] * syukei[mod3][color_now]
  return ret_

def f(colors, upper):
  ret_ = 0
  for mod3, color in enumerate(colors):
    ret_ += f2(color, mod3)
    if ret_ > upper:
      return upper
  return ret_

ret = N*N*1000
for colors in itertools.permutations(range(1, C+1), 3):
  ret = min(ret, f(colors, ret))
print(ret)

Measured memory_bytes: 6252
#include <cstdint>
#include <vector>
#include <iostream>
#include <algorithm>
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#endif

#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	ll N; cin >> N;
	vector<ll> P(N), q(N);
	rep(n, N) { cin >> P[n]; }
	rep(n, N) { cin >> q[n]; }
	long long sa{0};
	if (P > q) swap(P, q);
	do {
		if (P == q) break;
		++sa;
	} while (next_permutation(begin(P), end(P)));
	p(sa);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}

int countBits(int in){
  int res=0;
  rep(i,10){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

int main() {
  int n,x,y;cin>>n>>x>>y;
  map<int,int> ans;
  fori(i,1,n){
    fori(j,i+1,n+1){
      int dist=j-i;
      dist=min(dist,abs(x-i)+1+abs(y-j));
      dist=min(dist,abs(y-i)+1+abs(x-j));
      if(ans.find(dist)==ans.end()){
        ans[dist]=0;
      }
      ans[dist]++;
    }
  }
  rep(i,n-1){
    cout<<ans[i+1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int solve(int L, int R) {
  if (L > 0) L = INF;
  if (R < 0) R = -INF;
  int ret;
  if (L == INF) {
    ret = R;
  } else if (R == -INF) {
    ret = -L;
  } else {
    L = -L;
    ret = min(L, R) + L + R;
  }
  return ret;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int ret = INF;
  for (int i = 0; i + m <= n; ++i) {
    ret = min(ret, solve(a[i], a[i + m - 1]));
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    int[] val = new int[N];
    
    for(int i = 0; i < M; i++){
      String[] T = sc.nextLine().split(" ");
      int a = Integer.parseInt(T[0]);
      int b = Integer.parseInt(T[1]);
      val[a-1]++;
      if(b != N){
        val[b]--;
      }
    }
    
    int count = 0;
    for(int i = 0; i < N; i++){
      if(i == 0){
      }else{
        val[i] += val[i-1];
      }
      
      if(val[i] == M){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 93584
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }

    return gcd(b, a % b);
}

fn lcm(a: i64, b: i64) -> i64 {
    return a / gcd(a, b) * b;
}

fn main() {
    let x: i64 = read_as_vec()[0];

    println!("{}", lcm(x, 360) / x);
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

	if(n[0] == n[1] && n[0] == n[2] || n[1] == n[2] && n[1] == n[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int Hs[10001];

int main(){
  int H,N;
  int A[1000],B[1000];
  cin >> H >> N;
  for(int i = 0;i < N;i++){
    cin >> A[i] >> B[i];
  }
  for(int i = H-1;i >= 0;i--){
    Hs[i] = 100000001;
  }
  Hs[H] = 0;
  for(int i = H;i > 0;i--){
    for(int j = 0;j < N;j++){
      if(i-A[j]<=0){
        if(Hs[i] + B[j] < Hs[0]){Hs[0] = Hs[i] + B[j];}
      }else{
        if(Hs[i] + B[j] < Hs[i-A[j]]){Hs[i-A[j]] = Hs[i]+B[j];}
      }
    }
  }
  cout << Hs[0] << endl;
}

Measured memory_bytes: 256