akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)

#define pb              push_back
#define ff              first
#define ss              second
#define mp              make_pair

#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))

#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)

#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())

#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )

#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("out.txt","w",stdout)

/// DEBUG
#define deb             printf("OKA\n")
/// DEBUG ENDSk

using namespace std;

#define lim 1010
LL H,W,K;
char grid[15][lim];

LL m[15] , sum[15];

LL solveFor( LL mask ){
    if( (mask&1LL) == 0 ) return 1e18;
    RESET(m);
    for( LL i = 0 ; i<H ; i++ ) {
        if( mask&(1LL<<i) ) m[i+1] = i+1;
        else m[i+1] = m[i];
    }

    RESET(sum);
    LL ret = 0;
    for( LL c = 1 ; c<=W ; c++ ){

        bool y = false;
        for( LL r = 1 ; r<=H ; r++ ){
            if( grid[r][c] == '1' ) sum[ m[r] ]++;
            if( sum[ m[r] ] > K) y = true;
        }
        if(y){
            if( c == 1 ) return 1e18;
            ret++;
            RESET(sum);
            for( LL r = 1 ; r<=H ; r++ ){
                if( grid[r][c] == '1' ) sum[ m[r] ] += 1;
                else sum[ m[r] ] += 0;
                if( sum[m[r]] > 1e15 ) return 1e18; 
            }
        }

    }
    FOR(i,1,9) if( mask&(1LL<<i) ) ret++;
    return ret;
}


int main(){
       
     SL(H); SL(W); SL(K);
     FOR(i,1,H) scanf(" %s", &grid[i][1]);
     LL ans = 1e18;
     //ans = solveFor(1);
     for( LL mask = 0 ; mask<(1<<H) ; mask++ ) ans = min(ans,solveFor(mask));
     printf("%lld\n", ans);
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
 
int main()
{
	const int Max = 1e5 + 7;
	int lst[Max];

	int n;
	cin >> n;
	int f = 0;
	for (int i = 1; i <= n; i++)
	cin>>lst[i];
	int k = lst[1];
	for (int i = 1; i <= Max; i++)
	{
		if (k == 2)
		{
			f = i; break;
		}
		k = lst[k];
	}
	if (f) cout << f;
	else cout << -1;

	return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	ll m[1000005]={0LL};
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	ll ans=0;
	for (int i = 0; i < n; ++i)
	{
		ll temp=a[i];
		ll cnt=0;
		for(ll i=1;i*i<=temp;++i)
		{
			if(temp%i==0)
			{
				cnt+=m[i];
				if(i!=temp/i)cnt+=(m[temp/i]);
			}
		}
		if(cnt==1)ans++;
	}
	cout<<ans<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

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


using namespace std;
//dp[i] first player winns if its true stones left


long long int dp[3005][3005];

int main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	int r=0,l=n-1;

	for(l=n-1;l>=0;--l){
		for(r=l;r<n;++r){
			if(l==r){
				dp[l][r]=arr[l];
			}
			else{
			dp[l][r]=max(arr[l]-dp[l+1][r],arr[r]-dp[l][r-1]);
		}
	}
	}
	cout<<dp[0][n-1];
	return 0;
}


Measured memory_bytes: 70016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(), b=sc.nextInt(), c=sc.nextInt(), d=sc.nextInt();
		if(a+b == c+d) {
			System.out.println("Balanced");
		}else if(a+b > c+d) {
			System.out.println("Left");
		}else {
			System.out.println("Right");
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 500;
vector<int> G[MAXN];
int dfn[MAXN], low[MAXN];
int n, m, u, v, dep, ans;

void init()
{
	dep = ans = 0;
	memset(dfn, 0, sizeof(dfn));
	memset(low, 0, sizeof(low));
	for(int i = 0; i <= n; ++i) G[i].clear();
}

void Tarjan(int u, int fa)
{
	dfn[u] = low[u] = ++dep;
	for(int i = 0; i < G[u].size(); ++i)
	{
		int v = G[u][i];
		if(!dfn[v])
		{
			Tarjan(v, u);
			low[u] = min(low[u], low[v]);
			if(low[v] > dfn[u]) ++ans;
		}
		else if(v != fa)
			low[u] = min(low[u], dfn[v]);
	}
}

int main()
{
	while(cin >> n >> m)
	{
		init();
		for(int i = 0; i < m; ++i)
		{
			cin >> u >> v;
			G[u].push_back(v);
			G[v].push_back(u);
		}
		Tarjan(1, -1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split());m=998244353;D=[[0]*(d+1)for _ in range(c+1)];D[a][b]=1
for i in range(a,c+1):
 for j in range(b,d+1):
  x=D[i-1]
  D[i][j]+=(D[i][j-1]*i+x[j]*j-x[j-1]*(i-1)*(j-1))%m
print(D[c][d])

Measured memory_bytes: 133808
n = int(input())
a = list(map(int,input().split()))
c = 0
a = [j for j in a if j % 2 == 0]
a.sort(reverse = True)

while any(i % 2 == 0 for i in a):
    for i in range(len(a)):
      while (a[i] % 2 == 0):
        a[i] = a[i] / 2
        c += 1
      
print(c)
        

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

int main(){
  int a, b;  scanf("%d %d", &a, &b);
  int bcopy = b;
  do{
    a *= 10;
    bcopy /= 10;
  }while(bcopy);

  int n = a + b;

  if(pow(floor(sqrt(n)), 2) == n)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define M 2000000
#define CENTER(i) ((i)>>1)
#define WHITE(i)  ((i)<<1)
#define BLACK(i)  (((i)<<1)+1)

typedef struct{
  int k;
}WAG;

int cc;
WAG c[M+5];

void extract(int i){
  int w,b,ex;
  WAG rt;
  w = WHITE(i),b = BLACK(i);
  if(w < cc && c[w].k > c[i].k){
    ex = w;
  }
  else{
    ex = i;
  }
  if(b < cc && c[b].k > c[ex].k){
    ex = b;
  }
  if(ex != i){
    rt = c[i],c[i] = c[ex],c[ex] = rt;
    extract(ex);
  }
}

int rise(){
  int g = c[0].k;
  c[0] = c[--cc];
  extract(0);
  return g;
}

void delm(int k){
  int i,ex;
  WAG rt;

  i = cc++;
  c[i].k = k;
  while(i>0&&c[ex=CENTER(i)].k < c[i].k){
    rt = c[i];
    c[i] = c[ex];
    c[ex] = rt;
    i = ex;
  }
}

#if 1
#define gun() getchar_unlocked()
#define pun(c) putchar_unlocked(c)
#else 
#define gun() getchar()
#define pun(c) putchar(c)
#endif

int gp(){
  int m = 0;
  int c = gun();
  do m = 10 * m + (c & 0xf), c = gun(); while(c >= '0');
  return m;
}

char a[20];
void bump(int m){
  int i = 0;
  if(m==0)
    a[i++] = '0';  
  else
    while(m)
      a[i++] = m % 10 + '0',m/=10;
  while(i)
    pun(a[--i]);
    pun('\n');
}

int main(){
  int l;

  cc = 0;

  while(1){
    if(gun()=='e'){
      if(gun()=='n')
	break;
      l = 6;
      while(l--)
	gun();
      bump(rise());
    }
    else{
      l=6;
      while(l--)
	gun();
      delm(gp());   
    }
  }
  return 0;
}



Measured memory_bytes: 5340
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int main(){
    int n = 0;
    rep(i,4){
        int x;cin>>x;
        n+=x;
    }
    cout << n/60 << endl << n%60 << endl;
}

Measured memory_bytes: 1160
/*By Qiuly*/
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=3e5+5;
const int M=1e5+5;

int n,m;
struct line {
	int l,r;
	bool operator < (const line&b) const {return l<b.l;	}
} a[N]; 

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;	
}

int rt[N],tot;
struct Segment_Tree {
	#define mid ((l+r)>>1)
	struct Node {int lc,rc,sum;} t[N*45];
	void insert(int&now,int last,int l,int r,int pos) {
		now=++tot,t[now]=t[last],t[now].sum++;
		if(l==r) return;
		if(pos<=mid) insert(t[now].lc,t[last].lc,l,mid,pos);
		else insert(t[now].rc,t[last].rc,mid+1,r,pos); 
	}
	int query(int now,int last,int l,int r,int L,int R) {
		if(L>r||l>R) return 0; 
		if(L<=l&&r<=R) return t[now].sum-t[last].sum;
		return query(t[now].lc,t[last].lc,l,mid,L,R)+
			   query(t[now].rc,t[last].rc,mid+1,r,L,R);
	}
}tree;

int main() {
	IN(n),IN(m);
	for(int i=1;i<=n;++i) IN(a[i].l),IN(a[i].r);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;++i) tree.insert(rt[i],rt[i-1],1,m,a[i].r);
	for(int d=1;d<=m;++d) {
		int ans=0,now=0,las=0;
		for(int be=1;be*d<=m;++be) {
			now=0;
			for(int i=18;~i;--i)
				if(now+(1<<i)<=n&&(a[now+(1<<i)].l-1)/d<be) now+=(1<<i);
			if(now>n) now=n; 
			ans+=tree.query(rt[now],rt[las],1,m,d*((a[now].l-1)/d+1),m);
			las=now;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 68480
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = 1e9 + 10;

int N;
int F[101][5][2];
int P[101][11];
int c[100];

signed main()
{
	cin >> N;
	rep(i, N) {
		rep(j, 5) {
			rep(k, 2) {
				cin >> F[i][j][k];
			}
		}
	}

	rep(i, N) rep(j, 11) cin >> P[i][j];

	int mx = -inf;

	for (int S = 1; S < (1 << 10); ++S) {
		memset(c, 0, sizeof c);
		int score = 0;

		rep(i, 10) {
			if (S >> i & 1) {
				rep(j, N) {
					c[j] += F[j][i / 2][i % 2];
				}
			}
		}

		rep(i, N) score += P[i][c[i]];

		chmax(mx, score);
	}

	cout << mx << endl;
}



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

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

  int64_t calcu = 1 ; 
  int count = 0 ;
  for(int i = 1 ; i <= n ; i++)
  {
    calcu =  calcu * i % 1000000007 ;
  }

  cout << calcu  << endl ;
}


Measured memory_bytes: 256
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

bool c;
int point,N;
int H,X,Y ,Z,T, R, G, M, K, W, t[101], v[101], ans, now;
char S,s;

int main() {
	cin >> N >> M;
	H = 100 * (N - M) + 1900 * M;
	if (M == 1) {
		Z = 2;
}
	if (M == 2) {
		Z = 4;
	}
	if (M == 3) {
		Z = 8;
	}
	if (M == 4) {
		Z = 16;
	}
	if (M == 5) {
		Z = 32;
	}
	ans = Z*H;
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
import math
n=int(input())

def add_v(l1,l2):
    n=len(l1)
    l=[0]*n
    for i in range(n):
        l[i]=l1[i]+l2[i]
    return l

def scar_multiple_v(scalar,l):
    n=len(l)
    ans=[0]*n
    for i in range(n):
        ans[i]=l[i]*scalar
    return ans

def mat_multi_v(mat,l):
    n=len(l)
    ans=[0]*n
    for i in range(n):
        for j in range(n):
            ans[i]+=mat[i][j]*l[j]
    return ans

def make_points(tail,head):
    ans=[[0]*2 for _ in range(5)]
    ans[0]=tuple(tail)
    ans[1]=tuple(add_v(tail,scar_multiple_v(1/3,add_v(head,scar_multiple_v(-1,tail)))))

    v=scar_multiple_v(1/3,add_v(head,scar_multiple_v(-1,tail)))
    mat=[[1+math.cos(math.radians(60)),-math.sin(math.radians(60))],\
         [math.sin(math.radians(60))  ,1+math.cos(math.radians(60))]]
    ans[2]=tuple(add_v(tail,mat_multi_v(mat,v)))
    ans[3]=tuple(add_v(tail,scar_multiple_v(2/3,add_v(head,scar_multiple_v(-1,tail)))))
    ans[4]=tuple(head)
    return tuple(ans)

def make_1_coch_curve(iter,tail,head):
    points=make_points(tail,head)
    if iter == n-1:
        for i in range(len(points)-1):
            print("{} {}".format(points[i][0],points[i][1]))
            
    else:
        for i in range(4):
            make_1_coch_curve(iter+1,points[i],points[i+1])
            
if n == 0:
    print("{} {}\n{} {}".format(0,0,100,0))
else:
    make_1_coch_curve(0,[0,0],[100,0])
    print("{} {}".format(100,0))
        



Measured memory_bytes: 5748
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,n;
    cin >> x >> n;
    vint p(n);
    REP(i,n) cin >> p[i];
    REP(i,200){
        int now = x-i;
        bool f = true;
        REP(j,n){
            if(p[j]==now){
                f = false;
            }
        }
        if(f){
            cout << now << endl;
            return 0;
        }
        now = x+i;
        f = true;
        REP(j,n){
            if(p[j]==now){
                f = false;
            }
        }
        if(f){
            cout << now << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace _gnu_pbds;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i = a ; i < b ; i++)
#define stoink stack<ll>
#define quu queue<ll>
#define quee queue<pair<ll,ll>>
#define vec vector <ll>
#define vecd vector<ld>
#define vg vector<vector<ll> >
#define eg vector<pair<ll,ll>>
#define vgw vector<vector<pair<ll,ll> > >
#define pa pair<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 100000000000000000
#define mod 998244353
#define endl '\n'
ll n,m;
const int maxn = (int)(2e5 + 5);
vec tree(4 * maxn,0),lazy(4 * maxn,0);
void upd_lazy(ll ind,ll l,ll r) {
    if(lazy[ind] != 0) {
        tree[ind] += lazy[ind];
        if(l != r) {
            lazy[2 * ind] += lazy[ind];
            lazy[2 * ind + 1] += lazy[ind];
        }
        lazy[ind] = 0;
    }
}
void upd(ll ind,ll l,ll r,ll ql,ll qr,ll val) {
    upd_lazy(ind,l,r);
    if(r < l)
        return;
    if(qr < l || ql > r)
        return;
    if(ql <= l && r <= qr) {
        lazy[ind] = val;
        upd_lazy(ind,l,r);
        return;
    }
    ll mid = (l + r) / 2;
    upd(2 * ind,l,mid,ql,qr,val);
    upd(2 * ind + 1,mid + 1,r,ql,qr,val);
    tree[ind] = max(tree[2 * ind],tree[2 * ind + 1]);
}
ll query(int ind,ll l,ll r,ll ql,ll qr) {
    upd_lazy(ind,l,r);
    if(r < l ||  qr < ql)
        return 0;
    if(qr < l || ql > r)
        return - inf;
    if(ql <= l && r <= qr) {
        return tree[ind];
    }
    ll mid = (l + r) / 2;
    return max(query(2 * ind,l,mid,ql,qr),query(2 * ind + 1,mid + 1,r,ql,qr));
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> m;
    vgw qry(n);
    fr(i,0,m) {
        ll l,r,val;
        cin >> l >> r >> val;
        l--;r--;
        qry[r].pb({l,val});
    }
    fr(i,0,n) {
        ll maxi = query(1,0,n - 1,0,i - 1);
        if(maxi >= 0)
        upd(1,0,n-1,i,i,maxi);
        for(auto j : qry[i]) {
            upd(1,0,n - 1,j.ff,i,j.ss);
        }
    }
    ll ans = max(0LL,query(1,0,n-1,0,n-1));
    cout << ans;
    return 0;
}	

Measured memory_bytes: 26692
N, K = list(map(int, input().split()))
a = [i - 1 for i in list(map(int, input().split()))]
logK = 1
while ((1 << logK) < K):
    logK += 1
doubling = [[-1 for _ in range(N)] for _ in range(logK)]
for i in range(N):
    doubling[0][i] = a[i]
for i in range(logK - 1):
    for j in range(N):
        doubling[i + 1][j] = doubling[i][doubling[i][j]]
now, i = 0, 0
while K > 0:
    if (K & 1):
        now = doubling[i][now]
    K = K >> 1
    i += 1
print(now + 1)


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

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

    char s;
    for (int i = 0; i < N; ++i) {
        std::cin >> s;
        if (s == 'Y') {
            std::cout << "Four\n";
            return 0;
        }
    }

    std::cout << "Three\n"; 

    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    System.out.println(n*(n-1)/2+m*(m-1)/2);
  }
}

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

long N, K;
int main() {
    cin >> N >> K;
    long y = N / K;
    long x = N - y * K;
    long x_bef = 1000000000000000001;
    while (x <= x_bef) {
        x_bef = x;
        x = abs(x - K);
    }
    cout << x_bef << endl;
}



Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
string s,t,la;
int n,ans;
int main(){
    cin>>s;
    n=s.size();
    for(int i=0;i<n;++i){
        t+=s[i];
        if(t!=la){
            ++ans;
            la=t;
            t="";
        }
    }
    printf("%d\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main() {

    int quant, num[100], menor;

    scanf("%d", &quant);

    for (int i = 0; i < quant; i++) {
        scanf("%d", &num[i]);
    }

    for (int i = 0; i < quant; i++) {
        for (int j = i+1; j < quant; j++) {
            if (num[i] > num[j]) {
                menor = num[j];
                num[j] = num[i];
                num[i] = menor;
            }
        }
    }

    printf("%d\n", (num[quant-1]-num[0]));

    return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
long long tot1,tot2,a[200010],b[200010],c[200010],kk;
long long check1(long long ys){
	long long ans=0;
	for(long long i=1;i<=tot1;i++){
		long long k=1,s=tot2+1;
		while(k){
			if(s-k>0&&b[i]*c[s-k]<ys)s-=k,k=k*2;
			else k=k/2;
		}
		ans+=tot2-s+1;
	}
	return ans;
}
long long calc1(){
	long long l=-2e18,r=-1,aa=0;
	while(l<=r){
		long long mid=(l+r)/2,x=check1(mid),y=check1(mid+1);
		if(x<kk&&kk<=y)return mid;
		else if(x<kk)l=mid+1;
		else r=mid-1;
	}
}
long long check2(long long ys){
	long long ans=0;
	for(long long i=1;i<=tot1;i++){
		long long k=1,s=i;
		while(k){
			if(s+k<=tot1&&b[i]*b[s+k]<ys)s+=k,k=k*2;
			else k=k/2;
		}
		ans+=s-i;
	}
	for(long long i=1;i<=tot2;i++){
		long long k=1,s=i;
		while(k){
			if(s+k<=tot2&&c[i]*c[s+k]<ys)s+=k,k=k*2;
			else k=k/2;
		}
		ans+=s-i;
	}
	return ans;
}
long long calc2(){
	long long l=1,r=2e18,aa=0;
	while(l<=r){
		long long mid=(l+r)/2,x=check2(mid),y=check2(mid+1);
		if(x<kk&&kk<=y)return mid;
		else if(x<kk)l=mid+1;
		else r=mid-1;
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	long long n,ans1,ans2,ans3,s1=0,s2=0,s3=0;
	cin>>n>>kk;
	for(long long i=1;i<=n;i++)
	cin>>a[i];
	for(long long i=1;i<=n;i++)
	if(a[i]==0)s1++;
	else if(a[i]<0)s2++,b[++tot1]=a[i];
	else s3++,c[++tot2]=a[i];
	ans1=s2*s3;
	ans2=s1*(n-s1)+s1*(s1-1)/2;
	ans3=s2*(s2-1)/2+s3*(s3-1)/2;
	sort(b+1,b+tot1+1);
	sort(c+1,c+tot2+1);
	reverse(b+1,b+tot1+1);
	if(ans1<kk&&kk<=ans1+ans2){
		cout<<0<<"\n";
		return 0;
	}
	else if(kk<=ans1){
		long long ans=calc1();
		cout<<ans<<"\n";
		return 0;
	}
	else if(kk>ans1+ans2){
		kk=kk-ans1-ans2;
		long long ans=calc2();
		cout<<ans<<"\n";
		return 0;
	}
	return 0;
}

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

int main(){
    string s;cin>>s;
    int acc = 0;
    string previous_word = "";
    string current_word = "";
    bool last_flag;

    for (int i=0;i<s.size();i++){
        current_word += s[i];
        if (previous_word != current_word){
            acc++;
            previous_word = current_word;
            current_word = "";
            last_flag = true;
        } else {
            last_flag = false;
        }
    }
    if (last_flag){
        cout << acc << endl;
    } else {
        cout << acc << endl;
    }
    return 0;
}

Measured memory_bytes: 640
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)
print( str(x3) + " " +str(y3) + " " +str(x4) + " " +str(y4))

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
        String t = sc.next();
        int b = 0;

        for(int i=0;i<s.length();i++){if(s.charAt(i)!=t.charAt(i)){b++;
                                                 }
                            }
       
		System.out.println(b);
	}
}


Measured memory_bytes: 41104
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <queue>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	double r; cin >> r;
	printf("%.9f\n",2*r*acos(-1) );
}


Measured memory_bytes: 3808
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

N,M = map(int,input().split())
SC = [list(map(int,input().split())) for i in range(M)]


if N == 1 and M ==0:
    print(0)
    exit()

for i in range(M):
    for j in range(M):
        if SC[i][0] == SC[j][0] and SC[i][1] != SC[j][1]:
            print(-1)
            exit()
if [1,0] in SC and N == 1:
    print(0)
    exit()
if [1,0] in SC:
    print(-1)
    exit()

l = []
SC = get_unique_list(SC)

l = SC

s = ["0"]*N
for i in range(len(l)):
    s[l[i][0]-1] = str(l[i][1])


if s[0] == "0":
    s[0] = "1"


for i in s:
    print(i,end='')


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

int main() {
	ios_base::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int sum = accumulate(a.begin(), a.end(), 0);
	pair<int,int> best = make_pair(1e9, -1);
	for (int i = 0; i < n; ++i) {
		best = min(best, make_pair(abs(n * a[i] - sum), i));
	}
	cout << best.second << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
  string n;
  cin>>n;
  int ans = 0;
  rep(i,n.size()){
      if(n[i]=='2'){
          ans++;
      }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int ans = 0;
            if (a + b + 1 >= c) ans = b + c;
            else ans = b + (a + b + 1);

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n;
    ll k;
    cin>>n>>k;
    vector<ll>a(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    vector<ll>s(n+1,0);
    for(int i=1;i<n+1;++i){
        s[i]=(s[i-1]+a[i-1]-1)%k;
    }
    map<ll,ll>mp;
    for(int i=0;i<min(n+1,k);++i){
        mp[s[i]]++;
    }
    ll ans=0;
    for(int i=0;i<n;++i){
        ans+=--mp[s[i]];
        if(i+k<=n){
            mp[s[i+k]]++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 15872
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
s = input()
t = input()
ans = 0

for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1

print(ans)


Measured memory_bytes: 9424
use proconio::{fastout, input};

use rand::prelude::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::time::SystemTime;

#[fastout]

fn calc_score(d: usize, c: &Vec<i64>, s: &Vec<[i64; 27]>, t: &Vec<usize>) -> i64 {
    let mut res = 0;
    let mut last: [usize; 26 + 1] = [0; 26 + 1];
    for day in 1..=d {
        let now_contest = t[day];
        res += s[day][now_contest];
        last[now_contest] = day;
        for contest in 1..=26 {
            res -= c[contest] * (day - last[contest]) as i64;
        }
    }
    res
}

fn get_time(time: SystemTime) -> f64 {
    time.elapsed().unwrap().as_secs_f64()
}

fn main() {
    let time = SystemTime::now();
    let mut rand = rand_pcg::Pcg64Mcg::new(890482);

    // input
    input! {
        d: usize,
        _c: [i64; 26],
        _s: [[i64; 26]; d],
    }

    let mut c = vec![0];
    c.extend(_c.iter());

    let mut s = vec![[0; 26 + 1]; d + 1];
    for day in 1..=d {
        for contest in 1..=26 {
            s[day][contest] = _s[day - 1][contest - 1]
        }
    }

    let mut t = vec![1; d + 1];

    // process
    let mut score = calc_score(d, &c, &s, &t);
    while get_time(time) < 1.95 {
        for _ in 1..=1000 {
            if rand.gen_bool(0.5) {
                let day = rand.gen_range(1, d + 1);
                let contest = rand.gen_range(1, 26 + 1);

                let tmp = t[day];
                t[day] = contest;
                let next_score = calc_score(d, &c, &s, &t);
                if next_score > score {
                    score = next_score;
                } else {
                    t[day] = tmp;
                }
            } else {
                let day1 = rand.gen_range(1, d);
                let day2 = rand.gen_range(day1 + 1, min(d + 1, day1 + 16));

                let tmp = t[day1];
                t[day1] = t[day2];
                t[day2] = tmp;

                let next_score = calc_score(d, &c, &s, &t);
                if next_score > score {
                    score = next_score;
                } else {
                    t[day2] = t[day1];
                    t[day1] = tmp;
                }
            }
        }
    }

    for i in 1..=d {
        println!("{}", t[i]);
    }
}


Measured memory_bytes: 2400
package main

import "fmt"

var n, m, q int
var a, b, c, d []int
var ans int

func dfs(A []int) {
	if(len(A) == n + 1) {
		sum := 0
		for i:=0; i<q; i++ {
			if(A[b[i]]-A[a[i]] == c[i]) {
				sum += d[i]
			}
		}
		if(sum > ans) {
			ans = sum
		}
		return
	}
	A = append(A, A[len(A)-1])
	for A[len(A)-1] <=m {
		dfs(A)
		A[len(A)-1]++
	}
}

func main() {
	fmt.Scan(&n, &m, &q)
	a, b, c, d = make([]int, q), make([]int, q), make([]int, q), make([]int, q)
	for i:=0; i<q; i++ {
		fmt.Scan(&a[i], &b[i], &c[i], &d[i])
	}
	dfs([]int{1})
	fmt.Printf("%d", ans)
}

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

using namespace std;

char s[1005];
bool mark[500];

int main() {
    scanf("%s", s);
    for (int i = 0; s[i]; i++) mark[s[i]] = true;
    if ((mark['N'] ^ mark['S']) || (mark['E'] ^ mark['W'])) printf("No");
    else printf("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll N, vector<ll> A) {
  sort(ALL(A));
  ll x = 0, y = 0;
  for (;;) {
    const int n = A.size();
    if (n < 2) { cout << 0 << endl; return; }
    if (A[n-1] == A[n-2]) { x = A[n-1]; A.pop_back(); A.pop_back(); break; }
    A.pop_back();
  }
  for (;;) {
    const int n = A.size();
    if (n < 2) { cout << 0 << endl; return; }
    if (A[n-1] == A[n-2]) { y = A[n-1]; A.pop_back(); A.pop_back(); break; }
    A.pop_back();
  }
  cout << x * y << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &A[i]);
	}
	solve(N, A);
	return 0;
}


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

using namespace std;

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

  long long n; cin >> n;
  long long h[n];
  for(int i = 0; i<n; ++i) cin >> h[i];

  // i, h[i]: i-j = h[i]+h[j]
  //          i-h[i] = j+h[j]
  map<long long, long long> ct;
  long long ret = 0;
  for(int i = 0; i<n; ++i) {
    ret += ct[i-h[i]];
    ct[i+h[i]]++;
  }
  /*
  ct.clear();
  // i, h[i]: j-i = h[i]+h[j]
  //          i+h[i] = j-h[j]
  for(int i = n-1; i>=0; --i) {
    ret += ct[i+h[i]];
    ct[i-h[i]]++;
  }
  */
  cout << ret << endl;
}


Measured memory_bytes: 27884
#include<stdio.h>
#include<string.h>

int main()
{
    int n = 0, a = 0;
    int array[101];

    scanf("%d", &n);

    for (int i = 1; i<=n; i++)
    {
        scanf("%d", &array[i]);
        if (((array[i]%2) == 1)&&((i%2) == 1))
        {
            a++;
        }
    }

    printf("%d", a);

    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <iomanip>

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;

  if(A<=8&&B<=8) cout << "Yay!" << endl;
  else cout << ":(" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int h,w;

	while(1)
	{

		cin >> h >> w;

		if(h == 0 && w == 0)
		{
			break;
		}
		for(int i=1; i<=h; i++){
			for(int j=2; j<=w+1; j++)
			{
				if((i%2 != 0 && j%2 == 0) || (i%2 == 0 && j%2 != 0))
				{
					cout << "#";
				}

				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;

	}
		return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	using ull = unsigned long long;
	vector<ull> S(N), T(N), U(N), V(N);
	REP(i, N) scanf("%llu", &S[i]);
	REP(i, N) scanf("%llu", &T[i]);
	REP(i, N) scanf("%llu", &U[i]);
	REP(i, N) scanf("%llu", &V[i]);
	
	vector<vector<ull>> ans(N, vector<ull>(N, 0));
	REP(bit, 64) {
		REP(i, N) if (S[i] == 0) REP(j, N) ans[i][j] |= U[i] & (1ull << bit);
		REP(j, N) if (T[j] == 0) REP(i, N) ans[i][j] |= V[j] & (1ull << bit);
		
		vector<int> cx, cy; // 追加で置かなければならない
		vector<int> prx, pry; // 置いても良い
		REP(i, N) if (S[i] == 1 && (U[i] >> bit & 1)) { // i行目 OR 1
			bool ok = false; // j 列目 AND 1 の存在確認
			REP(j, N) if (T[j] == 0 && (V[j] >> bit & 1)) ok = true;
			if (ok) pry.push_back(i);
			else cy.push_back(i);
		}
		
		REP(j, N) if (T[j] == 1 && (V[j] >> bit & 1)) {
			bool ok = false;
			REP(i, N) if (S[i] == 0 && (U[i] >> bit & 1)) ok = true;
			if (ok) prx.push_back(j);
			else cx.push_back(j);
		}
		
		// S-U, T-V
		REP(i, N) if (S[i] == 0 && (U[i] >> bit & 1 ^ 1)) pry.push_back(i);
		REP(j, N) if (T[j] == 0 && (V[j] >> bit & 1 ^ 1)) prx.push_back(j);
		
		int ccx = cx.size();
		int ccy = cy.size();
		REP(i, prx.size()) cx.push_back(prx[i]);
		REP(i, pry.size()) cy.push_back(pry[i]);
		
		REP(i, ccx) {
			if (cy.empty()) continue;
			int cy_idx = i % (ccy >= 2 ? ccy : cy.size());
			ans[cy[cy_idx]][cx[i]] |= 1ull << bit;
		}
		REP(i, ccy) {
			if (cx.empty()) continue;
			int cx_idx = i % (ccx >= 2 ? ccx : cx.size());
			ans[cy[i]][cx[cx_idx]] |= 1ull << bit;
		}
	}
	
	bool ok = true;
	REP(i, N) {
		ull bor = 0, band = ans[i][0];
		REP(j, N) {
			bor |= ans[i][j];
			band &= ans[i][j];
		}
		if (!(S[i] == 0 && band == U[i] || S[i] == 1 && bor == U[i])) ok = false;
	}
	
	REP(j, N) {
		ull bor = 0, band = ans[0][j];
		REP(i, N) {
			bor |= ans[i][j];
			band &= ans[i][j];
		}
		if (!(T[j] == 0 && band == V[j] || T[j] == 1 && bor == V[j])) ok = false;
	}
	
	if (!ok) puts("-1");
	else REP(i, N) REP(j, N) printf("%llu%c", ans[i][j], j + 1 == N ? '\n' : ' ');
	return 0;
}


Measured memory_bytes: 7376
<?php
/**
 * ABC133
 * A - T or T
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d", $N);

switch ($N % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        echo "hon\n";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        echo "pon\n";
        break;
    case 3:
        echo "bon\n";
        break;
}


Measured memory_bytes: 16040
#include <stdio.h>
#include <math.h>
main(){
  int a,b,ra=90,x,y;
  double xx=0,yy=0,pi;
  while(1){
    scanf("%d,%d",&a,&b);
    if(a==0&&b==0) break;
    pi=acos(-1);
    xx+=a*cos(pi*ra/180);
    yy+=a*sin(pi*ra/180);
    ra-=b;
  }
  x=xx;
  y=yy;
  printf("%d\n%d\n",x,y);
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

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

    if (n&1)
    {
        cout << "No" << endl;
        return 0;
    }

    for (int i=0, j=n/2; i<n/2; ++i, ++j)
        if (s[i] != s[j])
        {
            cout << "No" << endl;
            return 0;
        }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int Yukichi = 0;
    int Higuchi = 0;
    int Noguchi = 0;
    
    boolean flag = false;

    loop: for(Yukichi = 0; Yukichi <= N; Yukichi++){
      for(Higuchi = 0; Yukichi + Higuchi <= N; Higuchi++){
        Noguchi = N - (Yukichi + Higuchi);
        int num = 10000*Yukichi + 5000*Higuchi + 1000*Noguchi;
        if(num == Y){
        	flag = true;
        	System.out.println(Yukichi +" "+ Higuchi +" "+ Noguchi);
        	break loop;
        }
      }
    }
    
    if(!flag)
    	System.out.println(-1 +" "+ -1 +" "+ -1);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int sx, sy, tx, ty;


string solve(){
	string ans;
	rep(i, sx, tx) ans.pb('R');
	rep(i, sy, ty) ans.pb('U');
	rep(i, sx, tx) ans.pb('L');
	rep(i, sy, ty) ans.pb('D');
	ans.pb('D');
	rep(i, sx, tx) ans.pb('R');
	ans.pb('R');
	rep(i, sy, ty) ans.pb('U');
	ans.pb('U');
	ans.pb('L');
	ans.pb('U');
	rep(i, sx, tx) ans.pb('L');
	ans.pb('L');
	rep(i, sy, ty) ans.pb('D');
	ans.pb('D');
	ans.pb('R');
	return ans;
}


signed main(){
	cin >> sx >> sy >> tx >> ty;

	cout << solve() << endl;

	return 0;
}

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

int f(int n, int* a, int x) {
	int b = 0, t = n, m;
	while (b < t) {
		m = (b + t) / 2;
		if (a[m] <= x) {
			b = m + 1;
		} else {
			t = m;
		}
	}
	return b;
}

int main() {
	int n, a[100000], b[100000], c[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	static int x[100000];
	static ll y[100001];
	for (int i = 0; i < n; i++) {
		x[i] = f(n, b, a[i]);
	}
	for (int i = 0; i < n; i++) {
		y[i] = n - f(n, c, b[i]);
	}
	y[n] = 0;
	for (int i = n - 2; i >= 0; i--) {
		y[i] += y[i + 1];
	}
	ll r = 0;
	for (int i = 0; i < n; i++) {
		r += y[x[i]];
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 2560
n = int(input())
tree = [set() for i in range(n)]
con = [0]*n
ans = [0]*n
scr = 0
for _ in range(n-1):
  a,b = map(lambda x:int(x)-1, input().split())
  tree[a].add(b)
  tree[b].add(a)
  con[a] += 1
  con[b] += 1
st = []
for i in range(n):
  if con[i] == 1:
    st.append(i)
c = list(map(int, input().split()))
c.sort(reverse=True)
while st:
  v = st.pop()
  if ans[v]:
    continue
  ans[v] = c.pop()
  scr += ans[v]*con[v]
  con[v] = 0
  for x in tree[v]:
    if ans[x]:
      continue
    con[x] -= 1
    if con[x] <= 1:
      st.append(x)
print(scr)
print(" ".join(map(str,ans)))

Measured memory_bytes: 7792
#include<stdio.h>
#include<ctype.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int R=1e5+1;
int IN(void)
{
  int x=0,f=1;char c=getchar();
  while(!isdigit(c)){if(c=='-')f=-f;c=getchar();}
  while(isdigit(c))x=(x*10)+(c-48),c=getchar();
  return f*x;
}
int main(void)
{
  int N,M,A,B,count=0,H[R],low[R]={0};
  N=IN(),M=IN();
  rep(i,N)H[i]=IN();
  rep(i,M){A=IN()-1,B=IN()-1;if(H[A]<=H[B])low[A]=1;if(H[A]>=H[B])low[B]=1;}
  rep(i,N)count+=!low[i];
  return printf("%d\n",count),0;
}

Measured memory_bytes: 2360
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ci cin
#define co cout
#define ed endl
#define vc vector
#define sr string
#define pb push_back
#define st(a,n) sort(a,a+n)
#define ms(a) memset(a,0,sizeof(a))
#define fr(i,k,n) for(int i=k;i<=n;++i)
#define FR(i,n,k) for(int i=n;i>=k;--i)
#define inf 0x3f3f3f3f
#define mod 10000019
#define maxn 1000
#define exp 1e-6
typedef long long ll;
using namespace std;
int a[10];
int n,k;
int TGR(int x)
{
    while(x)
    {
        int t=x%10;
        if(a[t])
            return 0;
        x/=10;
    }
    return 1;
}
int main()
{
    ci>>n>>k;
    fr(i,1,k)
    {
        int x;
        ci>>x;
        a[x]++;
    }
    for(int i=n;;++i)
    if(TGR(i))
    {
        co<<i<<ed;
        return 0;
    }
}


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

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy" << endl;
  else if (s == "Rainy") cout << "Sunny" << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

void mainsolve(){

    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    vector<vector<ll>> d(n, vector<ll>(n, INF));
    rep(i,n) d[i][i] = 0;

    vector<vector<ll>> to(n);
    rep(i,n){
        for(ll j = i+1; j < n; j++){
            if(s[i][j] == '1'){
                to[i].push_back(j);
                to[j].push_back(i);
                d[i][j] = d[j][i] = 1;
            }
        }
    }

    vector<ll> color(n,-1);

    // 二分グラフ判定
    function<bool(ll,bool)> dfs = [&](ll v, bool flag){
        color[v] = flag;

        for(auto next : to[v]){
            if(color[next] == flag) return false;
            if(color[next] == -1 && !dfs(next,flag^1)) return false;
        }

        return true;

    };
    if(!dfs(0,0)){
        cout << -1 << endl;
        return;
    }

    // ワーシャルフロイド
    rep(k,n) rep(i,n) rep(j,n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    ll res = -1;
    rep(root, n){
        rep(i,n) res = max(res, d[root][i]+1);
    }

    cout << res << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

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

	ullong cnt0 = 0;
	llong sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += a.at(i);
		if (i % 2 == 0 && sum >= 0)
		{
			cnt0 += 1 + sum;
			sum = -1;
		}
		else if (i % 2 == 1 && sum <= 0)
		{
			cnt0 += 1 - sum;
			sum = 1;
		}
	}

	ullong cnt1 = 0;
	sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += a.at(i);
		if (i % 2 == 0 && sum <= 0)
		{
			cnt1 += 1 - sum;
			sum = 1;
		}
		else if (i % 2 == 1 && sum >= 0)
		{
			cnt1 += 1 + sum;
			sum = -1;
		}
	}


	cout << min(cnt0, cnt1) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
 
int main(){
    int N, K;
    cin >> N >> K;

    vector<int> S(N,0);

    for(int i = 0; i < K ; i++){
        int d;
        cin >> d;
        for(int j = 0 ; j < d; j++){
            int s;
            cin >> s;
            S[s-1]++;
        } 
    }

    int count = 0;
    for(int i = 0; i < N ;i++){
        if(S[i] == 0) count++;
    }

    cout << count << endl;


    
    return 0;
}

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

int main(){
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  long long ans = 0;
  for(int i = 0; i < N; ++i){
    char c = T[i];
    if(i >= K and T[i-K] == c){
      T[i] = '?';
      continue;
    }
    if(c == 'r') ans += P;
    if(c == 'p') ans += S;
    if(c == 's') ans += R;
  }
  cout << ans << endl;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    cout << 6-a-b; 
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256