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

#define INF 1e9
#define pb push_back
#define mp make_pair
#define nl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

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

	long double c,pi=3.14159265359;
	int R;
	cin >> R;
	c=2*pi*R;
	cout << c;

	return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
typedef long long int ll;
using namespace std;
int main()
{
ll n;
cin>>n;
vector<ll> d(n),v(n);
for(ll i=0;i<n;i++)
{
cin>>d[i];
v[i]=d[i];
}
ll c=0;
for(ll i=1;i<n;i++)
{
d[i]=max(d[i-1],v[i]);
}
for(ll i=0;i<n;i++)
{
c+=d[i]-v[i];

}
cout<<c;
}

//d[i]=  2 1 5 4 3
//v[i]=  2 1 5 4 3
//i=1
//v[i]=  1 5 4 3
//d[i-1]=2 1 5 3
//  max= 2 5 5 5
//i=0
//d[i]=2 2 5 5 5


Measured memory_bytes: 6424
import java.util.*;

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

		String s = sc.next();

		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='o') count++;
		}
		count=count+15-s.length();
		if(count>=8) System.out.println("YES");
		else System.out.println("NO");
	}
}
				


Measured memory_bytes: 21844
# O(klog(k))解法 多分...
import sys
from heapq import heappush,heapify,heappop
input = sys.stdin.readline
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

def make_kth(A, B):
    n, m = len(A), len(B)
    A.sort(reverse=1)
    B.sort(reverse=1)
    q = [(-A[0] - B[0], 0, 0)]
    r=[]
    for _ in range(min(k, n * m)):
        v, s, t = heappop(q)
        r.append(-v)
        if t + 1 < m:
            heappush(q, (-A[s] - B[t + 1], s, t + 1))
        if t == 0 and s + 1 < n:
            heappush(q, (-A[s + 1] - B[0], s + 1, 0))
    return r

r = make_kth(a, b)
r = make_kth(c, r)
print(*r,sep="\n")

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

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

    vector<int> a(N);
    for (int i = 0; i < N; i++)
        cin >> a.at(i);

    int i = 0;
    int now = 1;
    while (i < N)
    {
        i++;
        now = a.at(now - 1);

        if (now == 2)
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 640
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>

using namespace std;

typedef long long ll;

#ifdef ONPC
    mt19937 rnd(228);
#else
    mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = (int) s.size();
    int cnt = 0;
    ll ans = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == 'B')
        {
            ans += n - i - cnt - 1;
            cnt++;
        }
    }
    cout << ans << '\n';
}


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int T;
	cin>>T;
	while(T--){
		long long int n,a,b,c,d;
		cin>>n>>a>>b>>c>>d;
		map<long long int,long long int> pq;
		pq[n]=0;
		long long int ans=8e18;
		while(!pq.empty()){
			long long int x,y;
			tie(x,y)=*pq.rbegin();
			pq.erase(--pq.end());
			long double cur = y+(long double)x*d;
			if(cur<ans)
				ans=min(ans,y+x*d);
			if(x==2){
				if(pq.count(1))
					pq[1]=min(pq[1],y+min(a,d));
				else	pq[1]=y+min(a,d);
				continue;
			}
			if(x==1){
				break;
			}
			for(int i=-1;i<=1;i++)
				if((x+i)%2==0){
					long long int nx=(x+i)/2;
					if(pq.count(nx))
						pq[nx]=min(pq[nx],y+abs(i)*d+a);
					else
						pq[nx]=y+abs(i)*d+a;
				}
			for(int i=-1;i<=1;i++)
				if((x+i)%3==0){
					long long int nx=(x+i)/3;
					if(pq.count(nx))
						pq[nx]=min(pq[nx],y+abs(i)*d+b);
					else
						pq[nx]=y+abs(i)*d+b;
					
				}
			for(int i=-2;i<=2;i++)
				if((x+i)%5==0){
					long long int nx=(x+i)/5;
					if(pq.count(nx))
						pq[nx]=min(pq[nx],y+abs(i)*d+c);
					else
						pq[nx]=y+abs(i)*d+c;
				}
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int ans=0,mb=2000000010;
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        if (b<mb) {
            ans=a+b;
            mb=b;
        }
    }
    cout << ans << endl;

    return 0; 
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll ret=pow(x,y/2);
  ret*=ret;
  if(y%2==1) ret*=x;
  return ret;
}
int main(){
  int m,k;
  cin>>m>>k;
  if(pow(2,m)-1<k){
    cout<<-1<<endl;
    return 0;
  }
  if(k==0){
    ll border=pow(2,m);
    for(int i=0;i<border;i++) cout<<i<<" ";
    for(int i=border-1;i>0;i--) cout<<i<<" ";
    cout<<0<<endl;
    return 0;
  }
  ll pw=pow(2,m);
  vector<P> vec;
  vector<bool> used((int)pow(2,m),false);
  for(ll i=0;i<pow(2,m);i++){
    if(!used[i]){
      vec.push_back(P(i,i^k));
      used[i]=true;
      used[i^k]=true;
      //cout<<i<<" "<<(i^k)<<endl;
    }
  }
  if(vec.size()==1){
    if(k==0) cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
    else cout<<-1<<endl;
    return 0;
  }
  else{
    vector<ll> as;
    for(int i=0;i<vec.size();i+=2){
      as.push_back(vec[i].first);
      as.push_back(vec[i+1].first);
      as.push_back(vec[i+1].second);
      as.push_back(vec[i].first);
      as.push_back(vec[i].second);
      as.push_back(vec[i+1].second);
      as.push_back(vec[i+1].first);
      as.push_back(vec[i].second);
    }
    for(int i=0;i<as.size()-1;i++) cout<<as[i]<<" ";
    cout<<as[as.size()-1]<<endl;
  }

}


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


int A[100];
int B[100];
int C[100];

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>A[i];
    for(int i=1;i<=n;i++)
        cin>>B[i];
    for(int i=1;i<n;i++)
        cin>>C[i];
    int sum=0;
    for(int i=2;i<=n;i++){
        int idx=A[i];
        sum+=B[A[i]];
        if((A[i]-A[i-1])==1)
            sum+=C[A[i-1]];
    }

    sum+=B[A[1]];
    cout<<sum;


}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<cstring>
#include<iostream>

using namespace std;
int main()
{
	long long L[87];
	int n,i;
	scanf("%d",&n);
	for(L[0]=2,L[1]=1,i=2;i<=n;i++)
	{
		L[i]=L[i-1]+L[i-2];
	}
	printf("%lld\n",L[i-1]);
	return 0;
}



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

int main() {
    int n;
    string s, t;

    cin >> n >> s >> t;

    rep (i, n) {
        cout << s[i] << t[i];
    }
    cout << endl;
	return 0;
}


Measured memory_bytes: 3636
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int x,y,z;
     while(cin>>x>>y>>z){
        swap(x,y);
        swap(x,z);
        cout<<x<<" "<<y<<" "<<z<<endl;
     }

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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(){
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    vector<ll> sum(N+1);
    sum[0]=0;
    rep(i,N) sum[i+1]=sum[i]+a[i];
    vector<vector<ll>> dp(N,vector<ll>(N,IINF));
    rep(j,N){
        rep(i,N){
            if (i+j>=N) continue;
            if (j==0) dp[i][i+j]=0;
            rep(k,j){
                chmin(dp[i][i+j],dp[i][i+k]+dp[i+k+1][i+j]+sum[i+j+1]-sum[i]);
            }
        }
    }
    cout << dp[0][N-1] << endl;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N;
  cin >> N;
  map<string, int> m;
  rep(i, N){
    string c;
    cin >> c;
    m[c] = 1;
  }

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

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 19204
<?php
# スペース区切りの整数の入力を配列で受け取る
$input=explode(' ',trim(fgets(STDIN)));

preg_match_all("/./", $input[0], $result);
$sum = array_sum($result[0]);

if ($sum % 9 === 0) {
    echo "Yes".PHP_EOL;
} else {
    echo "No".PHP_EOL;
}



Measured memory_bytes: 23344
#include<stdio.h>
long long gcm(long long int a,long long int b)
{long long k,l;
long long c,d,r=1;
	k=a;l=b;
	while(r)
	{
		r=a%b;
		a=b;
		b=r;
	 } 
	 d=k/a*l;
	 return d;
}
long long t[10000000],n,i,j;
int main()
{
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&t[i]);
	}
	for(j=1;j<n;j++)
	{
		t[j]=gcm(t[j],t[j-1]);
	}
	printf("%lld\n",t[j-1]);
	return 0;
}



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

using namespace std;

vector<int> edges[623][2];
bool used[623];
unsigned valid[623][623];
bitset<623> dp[623][623];
int dpx;
int temp[623];

void rec(int v,int p,int d){
  if(temp[v]){
    if(temp[v]!=d)throw -1;
  }else{
    temp[v]=d;
    for(int i=0;i<2;i++){
      for(auto e:edges[v][i]){
	if(v==p)continue;
	rec(e,v,(i?1:-1)*d);
      }
    }
  }
}

void srec(int v,int p){
  if(!used[v]++){
    for(int i=0;i<2;i++){
      for(auto e:edges[v][i]){
	if(e==p)continue;
	srec(e,v);
      }
    }
  }
}

bitset<623> record;

void dodp(int v){
  for(int i=0;i<2;i++){
    fill(begin(temp),end(temp),0);
    try{
      rec(v,-1,i?1:-1);
      bitset<623> r;
      for(int i=0;i<623;i++){
	r[i]=temp[i]==1;
      }
      int ndiv=r.count();
      for(int j=600;j-ndiv>=0;j--){
	if(valid[dpx][j-ndiv]){
	  if(valid[dpx+1][j]==0&&valid[dpx][j-ndiv]==1){
	    valid[dpx+1][j]=1;
	    dp[dpx+1][j]=dp[dpx][j-ndiv]|r;
	  }else{
	    valid[dpx+1][j]=2;
	  }
	}
      }
    }catch(...){}
  }
  srec(v,-1);
  dpx++;
}

int main(){
  for(int n,p1,p2;cin>>n>>p1>>p2,n|p1|p2;){
    for(auto &e:edges){
      for(auto &f:e){
	f.clear();
      }
    }
    fill(begin(used),end(used),false);
    fill(valid[0],valid[623],0);
    while(n--){
      int x,y;
      char a[9];
      cin>>x>>y>>a;
      edges[x][a[0]=='y'].push_back(y);
      edges[y][a[0]=='y'].push_back(x);
    }
    valid[0][0]=1;
    dpx=0;
    for(int i=1;i<=p1+p2;i++){
      if(!used[i]){
	dodp(i);
      }
    }
    if(valid[dpx][p1]!=1){
      cout<<"no"<<endl;
    }else{
      for(int i=1;i<=p1+p2;i++){
	if(dp[dpx][p1][i]){
	  cout<<i<<endl;
	}
      }
      cout<<"end"<<endl;
    }
  }
}

Measured memory_bytes: 33124
#include<iostream>
using namespace std;
typedef long long ll;


int main()
{
	string s,ss,sss;int k=0,i;
	cin>>s;
	for(i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-1-i])k=1;
	for(i=0;i<s.size()/2;i++)ss=ss+s[i];
	for(i=s.size()/2+1;i<s.size();i++)sss+=s[i];
	for(i=0;i<ss.size()/2;i++)if(ss[i]!=ss[ss.size()-1-i])k=1;
	for(i=0;i<sss.size()/2;i++)if(sss[i]!=sss[sss.size()-1-i])k=1;
	if(k)printf("No\n");
	else printf("Yes\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
#define REP(i,n) for(int i=0;i<n;i++)

int N, M;


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

    cin >> N >> M;
    if(N%M ==0){
        cout << 0 <<endl;
    }else{
        cout << 1 << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define Death Komachi
#define REP(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;i++)
#define DREP(i,a,b) for(int i=(a),i##_end_=(b);i>i##_end_;i--)
#define LL long long
#define M 100004
 
int n,A[M];
LL Mn[M],Mx[M];
void Stop(){
	puts("-1");
	exit(0);
}
int main(){
	scanf("%d",&n);
	REP(i,1,n+1)scanf("%d",&A[i]);
        if(A[n]!=2)Stop();
	Mn[n]=2,Mx[n]=3;
	
	DREP(i,n,1){
		int a=A[i-1];
		
		Mn[i-1]=(Mn[i]+a-1)/a*a;
		Mx[i-1]=Mx[i]/a*a+a-1;
 
                if(Mn[i-1]>Mx[i-1])Stop();
	}
	printf("%lld %lld\n",Mn[1],Mx[1]);
	return 0;
}

Measured memory_bytes: 2176
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

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

const int N = 200005;
int a[N], n, m, k;
// is SUN, MON, TUE, WED, THU, FRI, or SAT.

void solve()
{
     int i, j;
     string s; cin >> s;
     if (s == "SUN")
          cout << 7;
     if (s == "MON")
          cout << 6;
     if (s == "TUE")
          cout << 5;
     if (s == "WED")
          cout << 4;
     if (s == "THU")
          cout << 3;
     if (s == "FRI")
          cout << 2;
     if (s == "SAT")
          cout << 1;


}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

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

typedef struct {
    double x;
    double y;
} point;

void rec(int n, point p1, point p2) {
    if (n == 0) {
        printf("%lf %lf\n", p2.x, p2.y);
    } else {
        point s, t, u;
        s.x = 2 * p1.x / 3 + p2.x / 3;
        s.y = 2 * p1.y / 3 + p2.y / 3;
        t.x = (p1.x + p2.x) / 2 - sqrt(3) * (p2.y - p1.y) / 6;
        t.y = (p1.y + p2.y) / 2 + sqrt(3) * (p2.x - p1.x) / 6;
        u.x = p1.x / 3 + 2 * p2.x / 3;
        u.y = p1.y / 3 + 2 * p2.y / 3;
        rec(n - 1, p1, s);
        rec(n - 1, s, t);
        rec(n - 1, t, u);
        rec(n - 1, u, p2);
    }
}

void koch(int n, point p1, point p2) {
    printf("%lf %lf\n", p1.x, p1.y);
    rec(n, p1, p2);
}

int main(void) {
    int n;
    point p1 = {0, 0};
    point p2 = {100, 0};
    scanf("%d", &n);
    koch(n, p1, p2);
}



Measured memory_bytes: 2104
# AB -> BBAA -> BAAAA -> BA
# Thus, this problem has commutative property.
# So, if we let A and B satisfy x^2 + x + 1 == 0,
# then A^2 == B, B^2 == A, and A^3 == B^3 == 1.
# So this makes an invariant.

from itertools import accumulate

S = input()
T = input()
q = int(input())
abcds = [tuple(map(int, input().split())) for _ in range(q)]

S_csum = list(map(lambda x: x%3, [0] + list(accumulate(map(lambda c: 1 if c == 'A' else -1, S)))))
T_csum = list(map(lambda x: x%3, [0] + list(accumulate(map(lambda c: 1 if c == 'A' else -1, T)))))

for a, b, c, d in abcds:
    if (S_csum[b] - S_csum[a-1]) % 3 == (T_csum[d] - T_csum[c-1]) % 3:
        print("YES")
    else:
        print("NO")

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

using namespace std;

struct dice{
  int pips[6];
  int p(int p){
    return p - 1;
  }
  int numToPipsID(int p){
    for(int i = 0; i < 6; i++){
      if(p == pips[i]){
        return i + 1;
      }
    }
  }
  int pipRightID(int up, int front){
    int ID_up, ID_front;
    ID_up = numToPipsID(up);
    ID_front = numToPipsID(front);
    switch(ID_up){
      case 1:
        if(ID_front == 2)      return 3;
        else if(ID_front == 3) return 5;
        else if(ID_front == 4) return 2;
        else /*ID_front == 5*/ return 4;
      case 2:
        if(ID_front == 1)      return 4;
        else if(ID_front == 3) return 1;
        else if(ID_front == 4) return 6;
        else /*ID_front== 6*/  return 3;
      case 3:
        if(ID_front == 1)      return 2;
        else if(ID_front == 2) return 6;
        else if(ID_front == 5) return 1;
        else /*ID_front == 6*/ return 5;
      case 4:
        if(ID_front == 1)      return 5;
        else if(ID_front == 2) return 1;
        else if(ID_front == 5) return 6;
        else /*ID_front == 6*/ return 2;
      case 5:
        if(ID_front == 1)      return 3;
        else if(ID_front == 3) return 6;
        else if(ID_front == 4) return 1;
        else /*ID_front == 6*/ return 4;
      default:  //case 6
        if(ID_front == 2)      return 4;
        else if(ID_front == 3) return 2;
        else if(ID_front == 4) return 5;
        else /*ID_front == 5*/ return 3;
    }
  }
};
int main(void){
  dice d;
  int q;
  int q_up[24];
  int q_front[24];
  for(int i = 0; i < 6; i++){
    cin >> d.pips[i];
  }
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> q_up[i];
    cin >> q_front[i];
  }
  for(int i = 0; i < q; i++){
    cout << d.pips[d.p(d.pipRightID(q_up[i], q_front[i]))] << endl;
  }
  return 0;
}



Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int dx[] = { 0,1,-1,0,1,-1,-1,1 };
int dy[] = { 1,0,0,-1,1,-1,1,-1 };

int main() {
	init();

	string s; cin >> s;
	int l = 0, r = s.size() - 1, cnt = 0;
	while (l < r) {
		if (s[l] != s[r]) {
			if (s[l] == 'x') {
				cnt++;
				l++;
			}
			else if (s[r] == 'x') {
				cnt++;
				r--;
			}
			else {
				cout << -1 << "\n";
				return 0;
			}
		}
		else {
			l++;
			r--;
		}
	}
	cout << cnt << "\n";

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | START | --------------------------------------///

/*
knapsack-2
https://atcoder.jp/contests/dp/tasks/dp_e
*/



#define int long long //change int main to int32_t main
const int INF = 1e9 + 5;

const int N = 1e5 + 5;

int dp[105][N];
int n, fw;


void solve()
{

	cin >> n >> fw;

	fr(i, 1, N)  dp[0][i] = INF;
	int ans = 0;
	fr(j, 1, n + 1)
	{
		int x, y; cin >> x >> y;
		fr0(i, N)
		{
			if (i - y >= 0)
				dp[j][i] = min(dp[j - 1][i], x + dp[j - 1][i - y]);
			else dp[j][i] = dp[j - 1][i];
			if (dp[j][i] <= fw) ans = max(ans, i);
		}
	}

	cout << ans << nl;
}




int32_t main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 82520
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m=map(int,input().split())
A=UnionFind(n)
P=list(map(int,input().split()))
for i in range(m):
  a,b=map(int,input().split())
  a=a-1
  b=b-1
  A.union(a,b)
V=[0]*n
ans=0
AA=[]
c=0
C={}
V=[0]*n
for i in range(n):
  if A.parents[i]<0:
    AA.append([i])
    C[i]=c
    c=c+1
    V[i]=1
for i in range(n):
  if V[i]==0:
    AA[C[A.find(i)]].append(i)
for i in range(len(AA)):
    B=[]
    for j in range(len(AA[i])):
      B.append(P[AA[i][j]]-1)
    ans=ans+len(AA[i])+len(B)-len(set(AA[i])|set(B))
print(ans)

Measured memory_bytes: 39776
#include <stdlib.h>
#include <stdio.h>


int main(void) {
    char input[5];
    scanf("%s", input);

    for (int i=0;i<3;i++) {
        if (input[i] == input[i+1]) {
            printf("Bad\n");
            return 0;
        }
    }

    printf("Good\n");
    return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author caoash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOneClue solver = new BOneClue();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOneClue {
        public void solve(int testNumber, FastScanner br, PrintWriter pw) {
            int k = br.nextInt();
            int x = br.nextInt();
            TreeSet<Integer> poss = new TreeSet<>();
            for (int i = x; i < x + k; i++) {
                for (int j = i - k + 1; j <= i; j++) {
                    poss.add(j);
                }
            }
            for (Integer curr : poss) {
                pw.print(curr + " ");
            }
            pw.close();
        }

    }

    static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastScanner.SpaceCharFilter filter;

        public FastScanner(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21076
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;

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

class UnionFind{
public://par,rank,init,uf,uf,root,same,unite
        int par[MAXN],
                rank[MAXN],
                sum[MAXN];
        void init(int n){
                rep(i,n){
                        par[i]=i;
                        rank[i]=0;
                        sum[i]=1;
                }
        }
        UnionFind(int n){
                init(n);
        }UnionFind(){

        }
        int root(int x){
                return par[x]==x?x:par[x]=root(par[x]);
        }
        bool same(int x,int y){
                return root(x)==root(y);
        }
        void unite(int x,int y){
                x=root(x);y=root(y);
                if(x==y)return;
                if(rank[x]<rank[y]){
                        par[x]=y;
                        sum[y]+=sum[x];
                }
                else{
                        par[y]=x;
                        sum[x]+=sum[y];
                        if(rank[x]==rank[y])++rank[x];
                }
        }
};

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

        lint n,m;cin>>n>>m;
        vector<lint> a(m),b(m);
        UnionFind t(n);
        rep(i,m){
                cin>>a[i]>>b[i];--a[i];--b[i];
        }lint ans=0;
        rep(r,m){
                t.init(n);
                rep(i,m)if(r!=i){
                        t.unite(a[i],b[i]);
                }ans+=(t.sum[t.root(0)]!=n);
        }cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
p = [int(_) - 1 for _ in input().split()]

r = 0

c = 0
for i in range(N):
    if p[i] == i:
        c += 1
    else:
        r += (c + 1) //2 
        c = 0

r += (c + 1) //2 

print(r)


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

#define ALL(c) std::begin(c), std::end(c)

using namespace std;
using ll = long long;

void solve() {
    string s;
    cin >> s >> s;

    long m = 0;
    for (int i = 0; i < s.length(); ++i) {
        vector<bool> tmp(26);
        for (int j = 0; j < i; ++j) {
            if (s.find(s.at(j), i) != string::npos) {
                tmp[s.at(j) - 'a'] = true;
            }
        }
        m = max(m, count(ALL(tmp), true));
    }
    cout << m << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


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

template <typename T> vector<vector<T>> permutation(vector<T> v) {
  vector<vector<T>> perms;
  do {
    perms.push_back(v);
  } while (next_permutation(v.begin(), v.end()));

  return perms;
}

void vprint(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i];
  }
  cout << endl;
}

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> x_y(N);

  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    x_y[i] = make_pair(x, y);
  }

  vector<int> pairs(N);
  for (int i = 0; i < N; i++) pairs[i] = i+1;

  vector<vector<int>> perm = permutation(pairs);

  double sum_dist = 0;
  for (int i = 0; i < perm.size(); i++) {
    for (int j = 0; j < N - 1; j++) {
      int index = perm[i][j] - 1;
      int index_ = perm[i][j+1] - 1;
      sum_dist += sqrt((x_y[index].first - x_y[index_].first)*(x_y[index].first - x_y[index_].first) + (x_y[index].second - x_y[index_].second)*(x_y[index].second - x_y[index_].second));
    }
  }

  double ave = sum_dist / perm.size();
    //cout << fixed << setprecision(6)とすれば10^-6までの精度で出力できる
  cout << fixed << setprecision(7);
  cout << ave << endl;
  return 0;
}


Measured memory_bytes: 3256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    S, T = read_str_list()
    A, B = read_int_list()
    U = read_str()
    if U == S:
      res = A - 1, B
    elif U == T:
      res = A, B - 1
    print(res[0], res[1])


main()


Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,W;cin>>n>>W;
	map<ll,ll> mp1,mp2;
	mp1[0]=mp2[0]=0;
	int w[101],v[101];
	rep(i,n)cin>>w[i]>>v[i];
	rep(i,n){
		for(pair<ll,ll> p:mp1){
			if(p.first+w[i]<=W){
				ll ww=p.first+w[i];
				mp2[ww]=max(mp2[ww],p.second+v[i]);
			}
		}
		mp1=mp2;
	}
	ll ret=0;
	for(pair<ll,ll> p:mp2)ret=max(ret,p.second);
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 640
import java.io.*;
class Main{
public static void main(String[] args)throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
boolean i=true;
while(i){
String str=br.readLine();
String[] arr=str.split(" ");
int h=Integer.parseInt(arr[0]);
int w=Integer.parseInt(arr[1]);
if(h==0 && w==0)  i=false;
else{
for(int k=0; k<h; k++){
for(int j=0; j<w; j++){
if(k%2==0){
if(j%2==0) System.out.print("#");
else  System.out.print(".");
}
else{
if(j%2==0) System.out.print(".");
else  System.out.print("#");
}
}
System.out.println();
}
System.out.println();
}
}
br.close();
}
}

Measured memory_bytes: 31476
using System;
class ITP1_1
{
    static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);

        int a = int.Parse(Console.ReadLine());

        Console.WriteLine( a*a*a );
    }
}

Measured memory_bytes: 9032
#O(N)ならいけそう
N = gets.to_i
num = gets.strip.split.map(&:to_i)
i = 0 #配列の番号
c = 1
while i<N do
  if num[i] == c
    c += 1
  end
  i += 1
end
if c==1
  puts "-1"
else
  puts N-c+1
end

Measured memory_bytes: 28624
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr 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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N; 
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	bool is = true;
	rep(i, N) {
		if (A[i] % 2 == 0) {
			if (A[i] % 3 == 0 || A[i] % 5 == 0)continue;
			else is = false;
		}
	}
	cout << (is ? "APPROVED" : "DENIED") << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		while(true) {
			int kazu=sc.nextInt();
			long price=sc.nextLong();
			if(kazu==0 && price==0) {
				System.exit(0);
			}
			mono=new long[kazu];
			for(int i=0; i<kazu; i++) {
				mono[i]=sc.nextInt();
			}
			long tmp=0;
			long kiroku=0;
			for(int i=0; i<kazu; i++) {
				tmp=mono[i];
				for(int j=i+1; j<kazu; j++) {
					if(tmp+mono[j]<=price && tmp+mono[j]>kiroku) {
						kiroku=tmp+mono[j];
					}
				}
			}
			if(kiroku==0) {System.out.println("NONE");}
			else{System.out.println(kiroku);}
		}
	}
}


Measured memory_bytes: 50016
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <complex>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  int n, m, q;

  cin >> n >> m >> q; //nは10の5乗数

  vector<long> l(m);
  vector<long> r(m);

  vector<long> p_(q);
  vector<long> q_(q);

  // vector<vector<long> > d(n,vector<long>(n,0));
  long d[1000][1000];


  // cerr << d.size() <<endl;

  for (int i = 0; i < m; ++i) {
    cin >> l[i] >> r[i];
    l[i]--;
    r[i]--;
    long dist = r[i] - l[i];
    d[l[i]][dist]+=1;
  }

  //d[開始街][距離]
  for (int i = 0; i < n; ++i){
    for (int j = 1; j < n; ++j){
      d[i][j] += d[i][j-1];
    }
  }

  
  for (int i = 0; i < n; ++i){
    for (int j = 0; j < n; ++j){
      // cerr << "d_" << i <<"_" <<j << "="<<d[i][j]<<endl;
    }
  }


  //d[開始街][その距離以内の本数]


  for (int i = 0; i < q; ++i) {
    cin >> p_[i] >> q_[i];
    p_[i]--;
    q_[i]--;
  }

  for (int i = 0; i < q; ++i) {
    long ans=0;
    long inter = q_[i] - p_[i];
    long start = p_[i];

    for (int j = 0; j <= inter; ++j){
      ans += d[start + j][inter - j];
      // cerr << "d_" << start + j <<"_" <<inter - j << "="<<d[start + j][inter - j]<<endl;
    }

    cout <<ans<<endl;
  }


  return 0;
}


Measured memory_bytes: 11520
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
const int MAXN=105;
char var[MAXN][MAXN];
int flag;
bool dfs(int x,int y)
{
    if(!var[x][y]||var[x][y]!=flag) return false;
    var[x][y]=0;
    dfs(x+1,y);
    dfs(x-1,y);
    dfs(x,y+1);
    dfs(x,y-1);
    return true;
}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        if(!n||!m) return 0;
        memset(var,0,sizeof(var));
        for(int i=1;i<=n;i++) scanf("%s",var[i]+1);
        /*for(int i=1;i<=n;i++) {

        for(int j=1;j<=m;j++) {
            printf("%c",var[i][j]);
        }
        printf("\n");
        }*/
        int cnt=0;
        flag=0;
        for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) {
            flag=var[i][j];
            if(dfs(i,j)) cnt++;
        }
        printf("%d\n",cnt);
    }
}

Measured memory_bytes: 1356
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> f(n, 0);
    for (int x=1; x<=100; x++) {
        for (int y=1; y<=100; y++) {
            for (int z=1; z<=100; z++) {
                int val = x * x + y * y + z * z + x * y + y * z + z * x - 1;
                if (val < n)
                    f[val]++;
            }
        }
    }
    for (auto &fi:f) cout << fi << '\n';
    return 0;
}

Measured memory_bytes: 3616
def main():
    h, w = map(int, input().split())
    b = []
    for _ in range(h):
        b.append(input())

    # b[1][1] -> b[0][0], b[0][1], b[0][2], b[1][0], b[1][2], b[2][0], b[2][1], b[2][2]

    ans = []
    for i in range(h):
        e = []
        for j in range(w):
            e.append(0)
        ans.append(e)

    for i in range(h):
        for j in range(w):
            count = 0
            v = b[i][j]
            if v == "#":
                ans[i][j] = '#'
                continue

            for k in range(-1, 2):
                for l in range(-1, 2):
                    if i + k < 0 or i + k >= h:
                        pass
                    elif j + l < 0 or j + l >= w:
                        pass
                    else:
                        if b[i + k][j + l] == "#":
                            count += 1
            ans[i][j] = count

    for l1 in ans:
        for l2 in l1:
            print(l2, end="")
        print("")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
from collections import deque
k = int(input())
q = deque([i for i in range(1, 10)])
if k <= 9:
    print(k)
    quit()

k -= 9

while k > 0:
    a = q.popleft()
    b = a % 10
    if b == 0:
        q.append(10*a)
        q.append(10*a + 1)
        k -= 2
    elif b != 0 and b != 9:
        q.append(10*a + b - 1)
        q.append(10*a + b)
        q.append(10*a + b + 1)
        k -= 3
    elif b == 9:
        q.append(10*a + b-1)
        q.append(10*a + b)
        k -= 2

if k == 0:
    print(q[-1])
elif k == -1:
    print(q[-2])
elif k == -2:
    print(q[-3])

Measured memory_bytes: 41072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> A(3);
    rep(i,3) cin >> A[i];
    sort(A.begin(),A.end());
    cout << A[2] - A[0] << endl;
    return 0;
}


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

#ifdef local
template <class T> void _E(T x) { cerr << x; } void _E(double x) { cerr << fixed << setprecision(6) << x; } void _E(string s) { cerr << "\"" << s << "\""; } template <class A, class B> void _E(pair<A, B> x) { cerr << '('; _E(x.first); cerr << ", "; _E(x.second); cerr << ")"; } template <class T> void _E(vector<T> x) { cerr << "["; for (auto it = x.begin(); it != x.end(); ++it) { if (it != x.begin()) cerr << ", "; _E(*it); } cerr << "]"; }
void ERR() {} template <class A, class... B> void ERR(A x, B... y) { _E(x); cerr << (sizeof...(y) ? ", " : " "); ERR(y...); }
#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif

using ll = long long;

template <class V, int NV, V initV = 0> class Fenwick {
  vector<V> vals;
  inline int lowbit(int x) { return ~x & (x + 1); }

public:
  Fenwick() { vals.resize(NV, initV); }

  void upd(int at, V x) {
    for (int i = at; i < NV; i += lowbit(i)) {
      vals[i] += x;
    }
  }
  V prefix(int at) {
    V ret = initV;
    for (int i = at; i >= 0; i -= lowbit(i)) {
      ret += vals[i];
    }
    return ret;
  }
  V query(int L, int R) { return prefix(R) - prefix(L - 1); }
};

int main(int argc, char *argv[]) {
  cin.sync_with_stdio(false), cin.tie(nullptr);

  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i], --a[i];
  }
  vector<vector<pair<int, int>>> query(n);
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    query[r - 1].push_back({ l - 1, i });
  }
  Fenwick<int, 500005> fw;
  vector<int> ans(q), prv(n, -1);
  for (int i = 0; i < n; i++) {
    if (prv[a[i]] != -1) {
      fw.upd(prv[a[i]], -1);
    }
    fw.upd(i, 1), prv[a[i]] = i;
    for (auto x : query[i]) {
      ans[x.second] = fw.query(x.first, i);
    }
  }
  for (int i = 0; i < q; i++) {
    cout << ans[i] << "\n";
  }
}



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

ans = 1
sgn = 0
for i in range(1, N):
    if sgn == 0:
        if A[i] > A[i - 1]:
            sgn = 1
        elif A[i] < A[i - 1]:
            sgn = -1
    elif sgn == 1 and A[i] < A[i - 1] or sgn == -1 and A[i] > A[i - 1]:
        ans += 1
        sgn = 0
print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <cmath>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    int L;
    input(L);

    printf("%.10f\n", pow(L / 3.0, 3));
    return 0;
}

Measured memory_bytes: 256