akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>

using namespace std;

int main(){

	int ans=0;
	char c;
	int n;
	cin>>c;

	char c2 = c+1;

	cout<<c2;

	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  ll N;
  cin>>N;
  ll T,A;
  cin>>T>>A;
  ll H[N];
  rep(i,N){
    cin>>H[i];
    H[i]*=6;
  }
  
  ll ob=(T-A)*1000;
  
  ll mini=INF;
  ll ans=0;
  rep(i,N){
    mini=min(abs(H[i]-ob),mini);
    if(mini==abs(H[i]-ob)) ans=i+1;
  }
  
  cout<<ans<<endl;
}
  
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n;
long long dp[1007][20007], ans = 0;

struct data{
	int s, w;
	long long v;

	data(){}

	data(int _s, int _w, long long _v) :
		s(_s), w(_w), v(_v) {}

} dt[1007];

bool cmp(data x, data y){
	return (x.s + x.w < y.s + y.w);
}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		int a, b, c;
		cin >> a >> b >> c;
		dt[i] = data(b, a, c);
	}
	sort(dt + 1, dt + 1 + n, cmp);
	for(int i = 0; i <= n; i++){
		for(int j = 1; j <= 20000; j++){
			dp[i][j] = -1e18;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= dt[i].s + dt[i].w; j++){
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
			if(j >= dt[i].w){
				dp[i][j] = max(dp[i][j], dp[i - 1][j - dt[i].w] + dt[i].v);
			}
			ans = max(ans, dp[i][j]);
			//cout << dp[i][j] << " " << i << " " << j << endl;
		}
	}
	cout << ans;
}


Measured memory_bytes: 156800
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

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

    if (n % k == 0) {
        P("0");
    }
    else {
        P("1");
    }

    return 0;
}


Measured memory_bytes: 256
<?php
$cnt = array_fill(0,26,0);
while (!feof(STDIN)) {
    $s = strtolower(trim(fgets(STDIN)));
    foreach(range("a","z") as $k => $v){
        $cnt[$k] += substr_count($s,$v);
    }
}
foreach(range("a","z") as $k => $v){
    echo "$v : ".$cnt[$k]."\n";
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    ll g=__gcd(a,b);
    ll ans=(a*b)/g;

    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if (a>b)
    {
        printf("a > b\n");
    }
    if (a==b)
    {
        printf("a == b\n");
    }
    if (a<b)
    {
        printf("a < b\n");
    }
    //printf("%d:%d:%d",a/3600,(a%3600)/60,(a%3600)%60);
}



Measured memory_bytes: 2680
#include	<bits/stdc++.h>
#define 	inf		21e8
#define 	maxn	500005
#define 	mod		998244353
#define 	fi 		first
#define 	se 		second
#define 	pb 		push_back
#define 	mp 		make_pair
#define 	db		double
#define 	ll		long long
#define 	si 		stack<int>
#define 	qi 		queue<int>
#define 	vi 		vector<int>
#define 	pi 		pair<int, int>
#define 	pq  	priority_queue< int, vector<int>, greater<int> >
using namespace std;
ll gcd(ll a, ll b) {for (; b; swap(a, b)) a = a % b;}
ll powmod(ll a, ll b) { ll res = 1; for (; b; b >>= 1) res = (res * ((b & 1) ? a : 1)) % mod, a = a * a % mod; return res;}
int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b;
	return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int A,B;
    cin >> A >> B;
    string S;
    cin >> S;
    int L=A+B+1;
    int check=0;
    rep(i,L){
        if(i!=A) if(!((S[i]-'0')>=0 && (S[i]-'0')<10)) check=1;
        if(i==A) if(S[i]!='-') check=1;
    }
    if(check==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans;
    
    if((b - 1) % (a - 1) == 0){
      ans = (b - 1) / (a - 1);
    } else {
      ans = ((b - 1) / (a - 1)) + 1;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;

	if(abs(b-a)<=d && abs(c-b)<=d)cout<<"Yes"<<endl;
	else if(abs(c-a)<=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

hu = []
sei = []
for i in a:
	if i < 0:
		hu.append(i)
	else:
		sei.append(i)
hu.sort()
sei.sort()
if len(hu)%2 == 0:
	ans = sum(sei) + (-1)*sum(hu)
else:
	if len(sei) == 0:
		ans = (-1)*sum(hu[:-1]) + hu[-1]
		print (ans)
		exit()
	else:
		b = sei[0]
	if len(hu) == 0:
		ans = sum(sei[1:] + sei[-1])
		print (ans)
		exit()
	else:
		c = hu[-1]
	if abs(b) <= abs(c):
		b *= -1
		c *= -1
	ans = sum(sei[1:]) + (-1)*sum(hu[:-1])
	ans += (b+c)
print (ans)


Measured memory_bytes: 14492
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;cin>>n>>k;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int min_d = a[0];
    rep(i,n){
        min_d = __gcd(min_d,a[i]);
    }
    rep(i,n){
        if(a[i]>=k&&(a[i]-k)%min_d==0){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  int N, L;
  cin >> N >> L;
  vector<int> apple(N + 1);
  int min = 999999;
  int mini = 0;
  int sum = 0;
  for(int i = 1; i <= N; i++){
    apple.at(i) = L + i - 1;
    if(abs(apple.at(i)) < min){
      min = abs(apple.at(i));
      mini = i;
    }
    sum += apple.at(i);
  }
  cout << sum - apple.at(mini) <<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int N , K , X , Y;
cin >> N>>K>>X>>Y;
if( X>Y && X<=10000 && N>=K){
X*=K;
Y=Y*(N-K);
cout<<X+Y<<endl;
}
else if(K>N && X>Y &&( X  <=10000)){
    K=N;
    X*=K;
Y=Y*(N-K);
cout<<X+Y<<endl;
}
}


Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#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;
    string S;
    cin >> N >> S;
    
    vector<std::set<int>> pos(10);
    std::set<int> test;
    FOR(i, 0, N) {
        int num = S[i] - '0';
        pos[num].insert(i);
    }
    int ans = 0;
    FOR(i, 0, 1000) {
        vector<int> ind(10);
        int v = i;
        int a, b, c;
        a = v % 10; v /= 10;
        b = v % 10; v /= 10;
        c = v % 10;
        int now = 0;
        auto itr = pos[c].lower_bound(now);
        if (itr != pos[c].end()) {
            now = *itr + 1;
        } else {
            continue;
        }
        itr = pos[b].lower_bound(now);
        if (itr != pos[b].end()) {
            now = *itr + 1;
        } else {
            continue;
        }
        itr = pos[a].lower_bound(now);
        if (itr != pos[a].end()) {
            now = *itr + 1;
        } else {
            continue;
        }
        ans++;
        //cerr << c << b << a << endl;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
	using namespace std;
	#define xxx ios::sync_with_stdio(),cin.tie(0),cout.tie(0)
	#define rep(i,n) for(int i=0;i<n;i++)
	#define int long long
	int bp(int a, int b, int m) {
   		a %= m;
   		int res = 1;
    	while (b > 0) {
        	if (b & 1)
            	res = res * a % m;
       		a = a * a % m;
       	 	b >>= 1;
 	    }
    return res;
	}
	int max(int a, int b){
		return (a>b)?a:b;	
	}
	int csb( int n) 
{ 
    int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
	int solve(int x){
		int r=0;
		while(x>0){
			int t=csb(x);
			x%=t;
			r++;
		}
		return r;
	}

	signed main(){
		int test=1;
		//cin>>test;
		while(test--){
			long double x;
			long double d,h,H;
			cin>>d>>H>>x;
			if(x==d*d*H){ cout<<0<<endl;break;}
			h=(long double)x/(d*d);
			if(h >= H/2 ) {h=H-h; H=2*(h);}
			long double theta=atan((2*d*h)/(H*H));
			theta=theta*(180/3.141592653589793238);
			cout<< fixed << setprecision(7) <<90-theta<<endl;
		}
		return 0;
	}

Measured memory_bytes: 3832
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.BitSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			k = scanner.nextInt();
			m = scanner.nextInt();
			r = scanner.nextInt();
			if ((n | k | m | r) == 0)
				break;
			if (m == 0)
				System.out.println(BigDecimal.ONE.divide(BigDecimal.valueOf(n),
						r, RoundingMode.DOWN));
			else {
				BitSet bs = new BitSet();
				BigInteger den = BigInteger.ONE;
				for (int i = 2; i <= n; i++) {
					if (!bs.get(i)) {
						long p;
						for (p = i; p <= n; p *= i)
							;
						den = den.multiply(BigInteger.valueOf(p / i));
						for (int j = i; j <= n; j += i)
							bs.set(j);
					}

				}
				BigInteger num = den;
				for (int i = 1; i <= n - 1; i++) {
					num = num.add(den.divide(BigInteger.valueOf(i)));
				}
				System.out.println(new BigDecimal(num).divide(new BigDecimal(
						den.multiply(BigInteger.valueOf(n))), r,
						RoundingMode.DOWN));
			}
		}
	}

	int n, k, m, r;
}

Measured memory_bytes: 62712
function main(input){
    args = input.split("\n");
    n = args[0];
    a = args[1].split(" ");
    c = 0;
    while (true){
        for (var i = 0; i < parseInt(n, 10 );i ++ ){
            if (a[i]%2 !==0) {console.log(c);return;}
            else{a[i] = a[i]/2}
        }
        c += 1;
    }
}
main(require('fs').readFileSync('/dev/stdin', {encoding:'utf8'}));

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

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

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


int t[10][10];

int main2() {
  int R = nextLong();
  int C = nextLong();

  REP(i, 10) REP(j, 10) t[i][j] = nextLong();

  REP(k, 10) REP(i, 10) REP(j, 10) {
    chmin(t[i][j], t[i][k] + t[k][j]);
  }

  ll ans = 0;
  REP(i, R) REP(j, C) {
    int a = nextLong();
    if (a != -1)
      ans += t[a][1];
  }

  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

int N,Y;
int c[3][3];
int main(){
    REP(i,0,3){
        REP(j,0,3){
            cin>>c[i][j];
        }
    }

    if ( c[0][0] + c[2][2] == c[0][2] + c[2][0] &&
         c[1][1] + c[2][2] == c[1][2] + c[2][1] &&
         c[0][0] + c[1][1] == c[0][1] + c[1][0]
            ) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  int k = 0, t = 0, m = 0;
  cin >> k >> t;
  for (int i=0; i<t; i++) {
    int buf = 0;
    cin >> buf;
    m = max(m, buf);
  }
  cout << max(0, 2*m - k - 1) << endl;
  return 0;
}


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

typedef long long ll;

int main() {
	ll n, t; cin >> n >> t;
	vector<ll>time(n); for (auto&& x : time)cin >> x;
	ll ans = n * t;
	for (int i = 1; i < n; i++) {
		if (time[i] - time[i - 1] < t) ans -= t - (time[i] - time[i - 1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
    string str;
    cin >> str;
    int c = 0;
    if (str.at(0) == '1') c++;
    if (str.at(1) == '1') c++;
    if (str.at(2) == '1') c++;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

char maze[55][55];
int H, W;

bool check(int y, int x){
  bool ok=false;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i], ny = y + dy[i];
    if(0 <= nx && nx < W && 0 <= ny && ny < H && maze[ny][nx] == '#')ok = true;
  }
  return ok;
}

int main(){
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> maze[i][j];
    }
  }
  
  bool ok = true;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(maze[i][j] == '#' && !check(i, j)) {
	ok = false;
	// cout << i << " " << j << endl;
      }
    }
  }

  cout << (ok?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
#define vi vector<int>
int n,flg[500];
char s[500];
vi q;
vector<pii> ans;
vi get(vi x){
	if (x.size()==1) return x;
	int t=x.back();
	x.pop_back();
	vi v=get(x),res;
	res.PB(t);
	for (auto i:v) res.PB(i);
	res.PB(-t); 
	reverse(v.begin(),v.end());
	for (auto i:v) res.PB(-i);
	return res;
}
void walk(int &x,int y){
	for (;x<y;ans.PB(pii(++x,0)));
	for (;x>y;ans.PB(pii(--x,0)));
}
int main(){
	scanf("%d%s",&n,s);
	For(i,0,(1<<n)-1) s[i]-='0';
	For(i,0,(1<<n)-1) For(j,0,(1<<n)-1)
		if ((i&j)==j&&s[i]&&!s[j])
			return puts("Impossible"),0;
	For(i,0,(1<<n)-1) if (!s[i])
		For(j,0,(1<<n)-1) if (j!=i&&(i&j)==j&&!s[j]) flg[i]=1;
	For(i,0,(1<<n)-1) if (!s[i]&&!flg[i]){
		//cout<<i<<endl;
		vector<int> tmp;
		For(j,0,n-1) if (i&(1<<j)) tmp.PB(j+1);
		tmp=get(tmp);
		for (auto j:tmp) q.PB(j);
	}
	int x=0;
	ans.PB(pii(0,0));
	for (auto i:q){
		int st,ed;
		if (i>0) st=i-1,ed=i;
		else st=-i,ed=-i-1;
		walk(x,st);
		ans.PB(pii(st,1));
		ans.PB(pii(ed,1));
		ans.PB(pii(ed,0));
		x=ed;
	}
	walk(x,0);
	printf("Possible\n%d\n",ans.size()-1);
	for (auto i:ans) printf("%d %d\n",i.fi,i.se);
} 

Measured memory_bytes: 512
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> have(N, false);
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            a--;
            have[a] = true;
        }
    }

    int cnt = 0;
    rep(i, N) {
        if (!have[i])
            cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3600
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = input()
k = ni()
keta = 0
for i in range(len(s)):
    if s[i] == "1":
        continue
    else:
        keta = i
        break
if k < keta + 1:
    print("1")
else:
    print(s[keta])


Measured memory_bytes: 38384
#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<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;


int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  int count=0;
  for(int i=0; i<N; i++){
    while(a[i]%2 == 0){
      count++;
      a[i] /= 2;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 4  ;
const int M = 13;
const int INF = INT_MAX ; 
const double eps = 1e-6 ; 
int main ( ){
fast_io();
cout <<fixed << setprecision(10)  ; 
int n  , k ; 
cin >> n >> k ;
vector<double> pre( n+1 , 1.0  ) ; 
pre[0] = 0.0; 
for ( int i = 1; i <= n ; ++ i ) {
int x ; 
cin >> x ; 
ll s = x * (x + 1 ) / 2 ;
pre[i] = pre[i-1] +  (1.0* s) /  x ;  
//cout << x << " "  << ((1.0* s) /  x ) ; br 
}
double res = pre[k] ; 
for (int i = 2 ; i + k <= n ; ++i ) {
	double curr = pre[i+ k] -  pre[i] ;
	if ( curr + eps >= res ) 
		{	//cout << i+ k << " "  << i ;br   
			res = curr ;
		}
	}



cout << res ; 

return 0 ;
 
}


Measured memory_bytes: 1792
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

vec dist;
int id=0,mx=0;
void dfs(int now,int pre,vvec &G){
    if(pre!=-1) dist[now]=dist[pre]+1;
    // if(chmax(mx,dist[now])) id=now;
    if(mx < dist[now]) mx = dist[now], id = now;
    for(auto &next:G[now]){
        if(pre==next) continue;
        dfs(next,now,G);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vvec G(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    dist.resize(n,0);
    mx=0;id=0;
    dfs(0,-1,G);
  //  debug(mx);
    mx=0;
   // debug(mx);
    dist.assign(n,0);
    dfs(id,-1,G);

    //debug(mx);
    
    if(mx%3!=1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

Measured memory_bytes: 22144
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = [0,0,0]
def judge(n):
    if  n!= 1 and all(n%i != 0 for i in range(2,round(n**(1/2) +1))):
        return True
    else:
        return False
for i in range(3,10**5):
    if judge(i) and judge((i+1)/2):
        b.append(1)
    else:
        b.append(0)
cnt = [0]*(10**5)
for i in range(1,10**5):
    cnt[i] = cnt[i-1] + b[i]
for i in range(n):
    ans = cnt[a[i][1]] - cnt[a[i][0]-1]
    print(ans)

Measured memory_bytes: 32036
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//dirichlet();
		fortune();
		
	}
	
	public static void fortune(){
		Scanner sc = new Scanner(System.in);
		int numOfData = sc.nextInt();
		for(int i = 0; i < numOfData; i++){
			int ini = sc.nextInt();
			int years = sc.nextInt();
			int num = sc.nextInt();
			int max = 0;
			for(int j = 0; j < num; j++){
				int isSev = sc.nextInt();
				double per = sc.nextDouble();
				int hand = sc.nextInt();
				int sum = ini;
				if(isSev == 1){
					for(int k = 0; k < years; k++){
						double plus = sum * per;
						int add = (int)plus;
						sum += add - hand;
					}
				}
				else{
					int save = 0;
					for(int k = 0; k < years; k++){
						//System.out.print(sum + " ");
						double plus = sum * per;
						int add = (int)plus;
						//System.out.print(add + " ");
						save += add;
						sum -= hand;
						//System.out.print(sum + " ");
						//System.out.println(add + " ");
					}
					sum += save;
					//System.out.println(sum);
					
				}
				if(max < sum){
					max = sum;
					
				}

				
			}
			System.out.println(max);
			
		}
		
	}
	
	/*public static void dirichlet(){
		//最大値は1000000
		int MAX_NUMBER = 1000001;
		
		boolean isPrime[] = new boolean[MAX_NUMBER];
		//エラトステネスの古いにかける
		isPrime[0] = false;
		isPrime[1] = false;
		for(int i = 2; i < MAX_NUMBER; i++){
			isPrime[i] = false;
			for(int j = 2; j < i/2; j++){
				if(i % j == 0){
					isPrime[i] = true;
					break;
				}
			}
		}
		System.out.println("END!!");
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int d = sc.nextInt();
		int n = sc.nextInt();
		while(a != 0 || d != 0 || n != 0){
			int sum = 0;
			int num = 0;
			sum = a;
			while(num < n){
				if(isPrime[sum]){
					num++;
				}
				sum += d;
			}
			System.out.println(sum);
			a = sc.nextInt();
			d = sc.nextInt();
			n = sc.nextInt();
		}
		
	}*/

}

Measured memory_bytes: 13000
#include <stdio.h>

int main(){
    char w[101];
    int keys[26] = {0}, flag = 0;
    scanf("%s", w);

    for(int i = 0; w[i] != '\0'; i++){
        keys[w[i] - 'a']++;
    }

    for(int i = 0; i < 26; i++){
        flag = (flag | keys[i]);
    }

    printf((flag & 1) == 0 ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#define l(s) s.length()
#define sort(v) sort(v.begin(), v.end());
#define scan(v,n) rep(i,0,n) {ll k; cin >> k; v.pb(k);}
#define print(v,n) {rep(i,0,n) cout << v[i] << " "; cout << endl;}
#define printstr(s,n) {rep(i,0,n) cout << s[i]; cout << endl;}
#define rev(a) reverse(a.begin(), a.end());
#define pb push_back
typedef long long ll;
typedef long double lld;
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
 
const ll mxN=2e5;
const ll N=1e9+7;
 
ll dp[mxN]; 
 
  int main() {
      int T=1;// cin >> T;
      while(T--){
          ll n; cin >> n; vi v; scan(v,n);
          dp[1]=abs(v[1]-v[0]);
          rep(i,2,n) {
              dp[i]=dp[i-1]+abs(v[i]-v[i-1]);
              if(dp[i]>dp[i-2]+abs(v[i]-v[i-2])) dp[i]= dp[i-2]+abs(v[i]-v[i-2]);
          }
          cout << dp[n-1];
      } 
      
	 return 0;
}


Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
char s[10000005];
int cnt;
int main()
{
	scanf("%s",&s);
	if (s[0]!='A')
	 {
	 	puts("WA");
	 	return 0;
	 }
	for (int i=2;s[i+1];i++)
	 if (s[i]=='C')cnt++,s[i]='a';
	if (cnt!=1)
	 {
	 	puts("WA");
	 	return 0;
	 }   
	for (int i=1;s[i];i++)
	 if (s[i]>'z'||s[i]<'a')
	  {
	  	puts("WA");
	  	return 0;
	  } 
	puts("AC"); 
} 

Measured memory_bytes: 256
local n = io.read("*n", "*l")
local str = io.read()
local t = {}
for strnum in string.gmatch(str, "%d+") do
  table.insert(t, tonumber(strnum))
end
local even = {}
local odd = {}
for i = 1, n, 2 do
  if(odd[t[i]] == nil) then odd[t[i]] = 1 else odd[t[i]] = odd[t[i]] + 1 end
  if(even[t[i + 1]] == nil) then even[t[i + 1]] = 1 else even[t[i + 1]] = even[t[i + 1]] + 1 end
end
if(n == 2) then
  if(t[1] == t[2]) then print(1) else print(0) end
else
  local evall, odall = {}, {}
  for k, v in pairs(even) do
    local t = {}
    t.key, t.val = k, v
    table.insert(evall, t)
  end
  table.sort(evall, function(x, y) return x.val > y.val end)
  for k, v in pairs(odd) do
    local t = {}
    t.key, t.val = k, v
    table.insert(odall, t)
  end
  table.sort(odall, function(x, y) return x.val > y.val end)
  if(evall[1].key ~= odall[1].key) then
    print(n - evall[1].val - odall[1].val)
  else
    if(evall[2] == nil and odall[2] == nil) then
      print(n / 2)
    elseif(evall[2] == nil) then
      print(n - evall[1].val - odall[2].val)
    elseif(odall[2] == nil) then
      print(n - evall[2].val - odall[1].val)
    else
      if(evall[2].val < odall[2].val) then
        print(n - evall[1].val - odall[2].val)
      else
        print(n - evall[2].val - odall[1].val)
      end
    end
  end
end


Measured memory_bytes: 14636
s = $stdin.gets

s = s.split

for e in 0...s.length
    s[e] = s[e].to_i
end

counter = 0
for i in 0..s[0]
    max = s[1] - i <= s[0] ? s[1] - i : s[0]
    for j in 0..max
        k = s[1] - i - j
        if k >=0 && k <= s[0] then
            counter += 1
        end
    end
end

print counter

Measured memory_bytes: 1788
let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let hs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun h -> h in
  Printf.printf "%d\n" @@
  Array.fold_right (fun h -> ( + ) @@ if k <= h then 1 else 0) hs 0


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

int n, K;
// int ct;
int getsg(int x) {
	// ++ct;
	if (x % K == 0) return x / K;
	int down = x / K * K;
	int delta = x - down;
	int step = delta / (x / K + 1);
	if (!step) return getsg(x - x / K - 1);
	return getsg(x - step * (x / K + 1));
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	int ans = 0;
	for (int i = 1, t; i <= n; ++i) {
		std::cin >> t >> K;
		// ct = 0;
		ans ^= getsg(t);
		// std::cerr << "TIME USED " << ct << std::endl;
	}
	std::cout << (ans ? "Takahashi" : "Aoki") << std::endl;
	return 0;
}


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


int main(){
  int N;
  cin >> N;
  vector<int> t(N),x(N),y(N);
  for(int i = 0; i < N; i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  
  bool ok = true;
  if(t[0] < abs(x[0] + y[0])) ok = false;
  else if(t[0] % 2 != abs(x[0] + y[0]) % 2) ok = false;
  for(int i = 1; i < N; i++){
    if(t[i] - t[i-1] < abs(x[i] - x[i-1]) + abs(y[i] -y[i-1])) ok = false;
    else{
      if(!(t[i] - t[i-1] % 2 == 0 && abs(x[i] - x[i-1]) + abs(y[i] -y[i-1]) % 2 == 0)) false;
      else if(!(t[i] - t[i-1] % 2 == 1 && abs(x[i] - x[i-1]) + abs(y[i] -y[i-1]) % 2 == 1)) false;
    }
  }
  if(ok){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int> 
 
int main(){
	ll int n;
	cin >> n;
	ll int ans = ((n-1)*n)/2;
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n, F[45];
	cin >> n;
	
	F[0] = F[1] = 1;
	
	for(int i = 2 ; i <= n ; i++){
		F[i] = F[i - 1] + F[i - 2];
		}
	
	cout << F[n] << endl;
	
	return 0;
}

Measured memory_bytes: 1160
def main():
    N = int(input())

    def sum_num(num):
        div = N // num
        
        ret = num * int(div * ((1 + div) / 2))
        
        return (ret)

    ans = 0

    for i in range(1, N + 1):
        ans += sum_num(i)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9012
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


string s;

int main() {
	cin >> s;
	sort(s.begin(), s.end());

	if (s[0] == s[1] && s[2] == s[3]) 
		if (s[0] != s[2]) {
			cout << "Yes" << endl;
			return 0;
		}

	cout << "No" << endl;
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0], x = tmp[1];

        int[] ls =  ReadIntArray();
        ls = ls.Concat(new int[] {10001}).ToArray();

        int i = 0;
        int pos = 0;

        while (pos <= x)
        {
            pos += ls[i++];
        }

        WriteLine(i);
    }
}


Measured memory_bytes: 13396
var a,b,i,c:longint;s:string;
begin
	readln(a,b);
	read(s);
	for i:=1 to a+b+1 do begin
		if not((i=a+1) and (s[i]='-') or (i<>a+1) and (s[i]<>'-'))then inc(c);
	end;
	if c>0 then write('No')else write('Yes')
end.


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll n;

ll quickpow(ll a,ll b){
	ll c=1;
	while(b){
		if(b&1)	c=c*a%MOD;
		a=a*a%MOD;b>>=1;
	}
	return c;
}
void solve(){
	scanf("%lld",&n);
	ll res1=quickpow(10,n);
	ll res2=quickpow(8,n);
	ll res3=quickpow(9,n)-res2;
	ll res=((res1-res2-res3-res3)%MOD+MOD)%MOD;
	printf("%lld\n",res);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 1700
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll Abs(ll x,ll y){
    if(x>=y)return x-y;
    else return y-x;
}

int ans[110][110];
int h,w;

int main(void){
    int n;
    cin>>h>>w;
    int now1 = 0;
    int now2 = 0;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        while(a>0){
            if(now1%2==0){
                ans[now1][now2]=i+1;
                now2++;
                if(now2==w)now1++;
            }
            else{
                now2--;
                ans[now1][now2]=i+1;
                if(now2==0)now1++;
            }
            a--;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j==w-1)cout<<ans[i][j]<<endl;
            else cout<<ans[i][j]<<" ";
        }
    }
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

const int INF = 1 << 30;
string s;
int nxt[200010][26];
int dp[200010];
int best[200010];

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

  int n = s.size();
  for (int i = n; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      int &nx = nxt[i][j];
      if (i == n) nx = n;
      else if (s[i] - 'a' == j) nx = i;
      else nx = nxt[i+1][j];
    }
  }

  dp[n] = 1;
  for (int i = n-1; i >= 0; i--) {
    dp[i] = INF;
    best[i] = -1;
    for (int j = 0; j < 26; j++) {
      int &nx = nxt[i][j];
      if (nx >= n) {
        if (dp[i] > 1) {
          dp[i] = 1;
          best[i] = j;
        }
      } else if (chmin(dp[i], dp[nxt[i][j]+1]+1)) {
        best[i] = j;
      }
    }
  }

  int cur = 0;
  while (cur < n) {
    cout << char(best[cur]+'a');
    cur = nxt[cur][best[cur]]+1;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 22548
#include <iostream>
using namespace std;
int main(void){
    int n,sum;
    cin>>n;
    string s;
    cin>>s;
    sum=1;
    char color=s[0];
    for(int i=0;i<n;i++){
        if (color!=s[i]){
            sum++;
            color=s[i];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 512
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 105;

char c[N];
ll cnt[N], ans;
int a[N];
int n, k;

int main() {
    scanf("%s", c + 1); n = strlen(c + 1); read(k);
    for(register int i = 1; i <= n; ) {
        int j = i;
        while(j < n && c[i] == c[j + 1]) ++j;
        ++cnt[j - i + 1]; a[i] = a[j] = j - i + 1; i = j + 1;
    }
    if(a[1] == n) print(1ll * n * k / 2, '\n');
    else {
        if(c[1] == c[n]) {
            for(register int i = 1; i <= n; i++) cnt[i] *= k;
            cnt[a[1] + a[n]] += (k - 1); cnt[a[1]] -= (k - 1); cnt[a[n]] -= (k - 1);
            for(register int i = 1; i <= n; i++) ans += 1ll * (i / 2) * cnt[i];
        } else {
            for(register int i = 1; i <= n; i++) cnt[i] *= k;
            for(register int i = 1; i <= n; i++) ans += 1ll * (i / 2) * cnt[i];
        }
        print(ans, '\n');
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int ans = m;
    REP(i,n){
	int s,t;
	cin >> s >> t;
	m += s - t;
	ans = max(m,ans);
	if(m < 0) {
	    ans = 0;
	    break;
	}
    }
    cout << ans << endl;
    return 0;
}

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

class Node{
  public:
    int key;
    Node *parent, *left, *right;

    Node(int k){
      key = k;
      parent = nullptr;
      left = nullptr;
      right = nullptr;
    }

};

int n;
Node *root, *nil;

void inOrder(Node *node){
  if(node == nil) return;
  inOrder(node->left);
  cout << " " << node->key;
  inOrder(node->right);
}

void preOrder(Node *node){
  if(node == nil) return;
  cout << " " << node->key;
  preOrder(node->left);
  preOrder(node->right);
}


void myInsert(int key){
  auto *y = nil;  // xの親
  auto *x = root;
 // tree.push_back(Node(key));
  auto *obj = new Node(key);

  while(x != nil){
    y = x;
    if(obj->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  obj->parent = y;
  if(y == nil){
    root = obj;
  }else {
    if(obj->key < y->key){
      y->left = obj;
    } else{
      y->right = obj;
    }
  }
}


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

  for(auto i = 0; i < n; i++){
    string command;
    cin >> command;
    if(command == "insert"){
      cin >> key;
      myInsert(key);
    }else if(command == "print"){
      // print
      inOrder(root);
      cout << endl;
      preOrder(root);
      cout << endl;
    }
  }

  return 0;
}



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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  bool ans=true;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]%2==0&&a[i]%5!=0&&a[i]%3!=0){
      ans=false;
    }
  }
  if(ans) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef complex<double> p;

double det(p a,p b)
{
	return a.real()*b.imag()-a.imag()*b.real();
}

bool comp(p a,p b)
{
	if(a.real()!=b.real()) return a.real()<b.real();
	return a.imag()<b.imag();
}

int main()
{
	int n;
	while(cin>>n,n)
	{
		p ps[n];
		for(int i = 0; i < n; ++i)
		{
			scanf("%lf,%lf",&ps[i].real(),&ps[i].imag());
		}

		sort(ps,ps+n,comp);
		int k=0;
		p qs[n*2];

		for(int i = 0; i < n; ++i)
		{
			while(k>1&&det(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0) --k;
			qs[k++]=ps[i];
		}

		for(int i = n-2, t=k; i >= 0; --i)
		{
			while(k>t&&det(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0) --k;
			qs[k++]=ps[i];
		}

		cout<<n-k+1<<endl;
	}
  return 0;
}

Measured memory_bytes: 1276
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		char[] a = s.toCharArray();
		char[] b = t.toCharArray();
		char temp;
		for (int i = 0; i < a.length - 1; i++) {
			for (int j = i + 1; j < a.length; j++) {
				if (a[j] < a[i]) {
					temp = a[i];
					a[i] = a[j];
					a[j] = temp;
				}
			}
		}
		String s2 = "";
		for (int i = 0; i < a.length; i++) {
			s2 = s2 + a[i];
		}
		for (int i = 0; i < b.length - 1; i++) {
			for (int j = i + 1; j < b.length; j++) {
				if (b[j] > b[i]) {
					temp = b[i];
					b[i] = b[j];
					b[j] = temp;
				}
			}
		}
		String t2 = "";
		for (int i = 0; i < b.length; i++) {
			t2 = t2 + b[i];
		}
		if (s2.compareTo(t2) < 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    in_arr(int, a, n);
    sort(a.begin(), a.end());
    int sum = 0;
    rep(i, n - 1){
        sum += a[i];
    }
    if(sum > a[n - 1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

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

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

const int MAX = 1 << 17;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int dat[2 * MAX - 1];

class SegmentTree {
    public:
        unsigned int N;
        SegmentTree(int n);
        int query(int a, int b, int k, int l, int r);
        void update(int k, int a);
};

SegmentTree::SegmentTree(int n) {
    N = 1;
    while (N < n) N *= 2;
    if (N == 1) N *= 2;
    rep(i, N) dat[i] = INF;
}

int SegmentTree::query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INF;

    if (a <= l && r <= b) {
        return dat[k];
    } else {
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}

void SegmentTree::update(int k, int a) {
    k += N - 1;
    dat[k] = a;

    while (0 < k) {
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
};

int main() {
    int N, M;
    string S;
    cin >> N >> M >> S;

    SegmentTree st = SegmentTree(N);
    st.update(N, 0);
    vector<int> dp(N + 1);
    dp[N] = 0;
    for (int i = N - 1; i >= 0; --i) {
        if (S[i] == '1') {
            dp[i] = INF;
            st.update(i, INF);
            continue;
        }
        int l = i + 1, r = min(N + 1, l + M);
        dp[i] = st.query(l, r, 0, 0, st.N) + 1;
        st.update(i, dp[i]);
    }

    if (dp[0] >= INF) {
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans;
    int x = 0;
    while (x < N) {
        int i = 1;
        while (dp[x] - 1 != dp[x + i]) i++;
        x += i;
        ans.push_back(i);
    }

    for (int i : ans) cout << i << " ";
    cout << endl;
}

Measured memory_bytes: 2424
#include <iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <algorithm>
#include <cstring>
#include<queue>
#include <stack>
#include<map>
#include<vector>
#include <math.h>
using namespace std;
#define ll long long


int main(){
    int n,k;
    int h[200005];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h,h+n);
    ll sum=0;
    for(int i=0;i<n-k;i++){
        sum+=h[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024