akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
ll n; 
int main()
{
	cin>>n;
	ll ans=0;
	for(ll i=1;i*i<=n-1;i++)
	{
		if((n-1)%i==0)
		{
			if(i*i==(n-1)) ans--;
			ans+=2;
		}
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ll m=n;
			while(m%i==0) m/=i;
			m%=i;
			if(m==1) ans++;
		}
	}
	cout<<ans;
    return 0;
}

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

int flag[5];
string a;

int main()
{
    cin>>a;
    for(int i=0; i<a.length(); i++)
    {
    	if(a[i]=='N')  flag[1]=1;
    	if(a[i]=='W')  flag[2]=1;
    	if(a[i]=='S')  flag[3]=1;
    	if(a[i]=='E')  flag[4]=1;
	}
	if(flag[1]==flag[3] && flag[2]==flag[4])  puts("Yes");
	else  puts("No");
  return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<pair<int, int>> shop(n);
    for (auto &p: shop) cin >> p.first >> p.second;
    sort(shop.begin(), shop.end());
    long long ans = 0;
    for (auto &p: shop) {
        ans += 1LL * p.first * min(m, p.second);
        m -= min(m, p.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <chrono>
#include <random>
#include <ctime>
#include <algorithm>
#include <iosfwd>
#include <iostream>
#include <list>
#include <ostream>
#include <streambuf>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define fori(i, n) for(ll i = 0; i < (n); ++i)
#define forI(i, n) for(ll i = 1; i <= (n); ++i)
#define pll pair<ll, ll>
#define ff first
#define ss second

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#define pt pair<ll, ll>
#define x first
#define y second

pll operator+ (pll a, pll b){ return {a.x + b.x, a.y + b.y}; }

ll rand0m() {
    return (ull(rand()) << 15ull | ull(rand()));
}                   //[0 ... n)
ll rand0m(ll x) {
    return rand0m() % x;
}               //[0 ... n)
ll rand0m(ll minn, ll maxx) {
    return rand0m(maxx - minn + 1) + minn;
}   //[minn ... maxx]

const ll MAXN = 1e5 + 1;
const ll mod = 1e9 + 7;
const ll INF = 2e9 + 1000;

ll n, m;
ll d[3001][3001];
pll pre[3001][3001];

void solve() {
    string s, t;
    cin >> s >> t;
    n = s.size(), m = t.size();
    s = "." + s;
    t = "." + t;
    forI(i, n){
        forI(j, m){
            pre[i][j] = {i - 1, j};
            d[i][j] = d[i - 1][j];
            if(d[i][j] < d[i][j - 1]){
                pre[i][j] = {i, j - 1};
                d[i][j] = d[i][j - 1];
            }
            if(s[i] == t[j]){
                if(d[i - 1][j - 1] + 1 > d[i][j]){
                    d[i][j] = d[i - 1][j - 1] + 1;
                    pre[i][j] = {i - 1, j - 1};
                }
            }
        }
    }
    pll cur = {n, m};
    string ans;
    pll q = {-1, -1};
    while(cur.ff > 0 && cur.ss > 0){
        if(pre[cur.ff][cur.ss] == cur + q) ans.push_back(s[cur.ff]);
        cur = pre[cur.ff][cur.ss];
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
}

Measured memory_bytes: 211328
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>

int n;
int main(){
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++){
        int ii=i,res=0;
        while(ii)ii/=10,res++;
        if(res%2)cnt++;
    }
    cout<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream> 
using namespace std;
char a[6];
int count[4];

int main(){
	for(int i=0; i<6; ++i){
		cin >> a[i] ;
		++count[a[i]-'1'];
	}

	int max =0;
	int min =2;
	for(int i=0; i<4; ++i){
		if(count[i]> max){
			max = count[i];
		}
		if(count[i] < min){
			min = count[i];
		}
	}
	
	if(max == 2 && min == 1){
		cout << "YES";
	}else{
		cout << "NO";
	}
	
	return 0;
}

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

#define FOR(i, a) for(int i=0;i<(int)a;++i)
typedef long long ll;
using namespace std;

void solver() {
    int N;
    cin>>N;
    cout<<N*N*N<<endl;
}

int main() {
    solver();
    return 0;
}

Measured memory_bytes: 3088
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    mod = 10**9 + 7

    n,m = map(int, input().split())
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    dp = [[1]*(m+1) for _ in range(n+1)]
    for i in range(1, n+1):
        for j in range(1, m+1):
            if t[j-1] == s[i-1]:
                dp[i][j] = dp[i][j-1] + dp[i-1][j]
            else:
                dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1]
            dp[i][j] %= mod
    print(dp[-1][-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 99728
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define LL long long

int x[110],y[110],h[110];
int n;
int main(){
	int cx,cy,H;
	int allzero = 1;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i)scanf("%d%d%d",&x[i],&y[i],&h[i]),allzero &= (h[i] == 0);
	if(allzero){
		return printf("%d %d %d",100,100,1);
	}
	for(int i = 1;i <= n;++i)
	if(h[i]){
		for(cx = 0;cx <= 100;++cx)
			for(cy = 0;cy <= 100;++cy){
				H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
				int flag = 1;
				for(int i = 1;i <= n;++i)
				if(max(0,H - abs(x[i] - cx)  - abs(y[i] - cy)) != h[i])flag = 0;
				if(flag){
					return printf("%d %d %d",cx,cy,H),0;
				} 	
			}
	}
	return 0;
}

Measured memory_bytes: 128
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

int n;
int even;
int keta[200010][20];


int haiti(int x,int y,int z){
	int i,j;
	int lim=(1<<(y-1));

	if(x==even&&y!=even+1){
		haiti(y-1,y-1,z);
	}else if(x==even+1){
		haiti(even-1,y-1,z);
	}else if(x!=-1){
		haiti(x-1,y-1,z);
	}
			
	if(x!=-1){
		for(i=lim;i<lim*2;i++){
			for(j=0;j<20;j++){
				keta[z+i][j]=keta[z+2*lim-i-1][j];
			}
			keta[z+i][x]=(keta[z+i][x]^1);
		}
	}

	return 0;
}

int main(void)
{
	//変数の宣言
	int a,b;
//	int keta[200010][20];
	int ketab[20];
	int ketaa[20];
	int odd;
	int narabi[20];
	int memo[20];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	int ok,ng;
	int r;
	


	//データの読み込み


	scanf("%d %d %d",&n,&a,&b);
//	scanf_s("%d %d %d",&n,&a,&b);

/*	for(i=0;i<n;i++){
//		scanf("%d",&c[i]);
		scanf_s("%d",&c[i]);
	}*/
	
	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(n==1){
		if(a!=b){
			printf("YES\n%d\n%d",a,b);
		}else{
			printf("NO");
		}
		return 0;
	}


	temp=a^b;
	odd=0;
	for(i=0;i<n;i++){
		ketab[i]=temp%2;
		odd=odd+ketab[i];
		temp=temp/2;
	}

	temp=a;
	for(i=0;i<n;i++){
		ketaa[i]=temp%2;
		temp=temp/2;
	}

	temp1=0;
	temp2=n-odd;
	for(i=0;i<n;i++){
		if(ketab[i]==1){
			narabi[i]=temp2;
			temp2++;
		}else{
			narabi[i]=temp1;
			temp1++;
		}
	}

	if(odd%2==0){
		printf("NO");
		return 0;
	}else{
		printf("YES\n");
	}

	for(i=0;i<200010;i++){
		for(j=0;j<20;j++){
			keta[i][j]=0;
		}
	}

	even=n-odd-1;

	haiti(even,n-1,0);
	temp=(1<<n-1);
	for(i=0;i<n-1;i++){
		for(j=0;j<n;j++){
			keta[temp][j]=keta[temp-1][j];
		}
		if(n-i-1>even){
			keta[temp][n-i-1]=1;
		}else{
			keta[temp][n-i-1]=0;
		}
			
		if(n-i-2>even){
			haiti(even,n-i-2,temp);
		}else{
			haiti(n-i-3,n-i-2,temp);
		}

		temp=temp+(1<<n-2-i);
//		printf("temp=%d",temp);
	}

	for(i=0;i<n;i++){
		keta[temp][i]=keta[temp-1][i];
	}
	keta[temp][0]=0;
	temp++;

	for(i=0;i<(1<<n);i++){
		for(j=0;j<n;j++){
			memo[j]=keta[i][j];
		}

		for(j=0;j<n;j++){
			keta[i][j]=memo[narabi[j]]^ketaa[j];
		}
	}



	//	printf("計算部分終了\n");

	//出力

	for(i=0;i<(1<<n);i++){
		ans=0;
		for(j=0;j<n;j++){
//			printf("%d ",keta[i][j]);
			ans=ans+keta[i][j]*(1<<j);
		}
		printf("%d\n",ans);
	}


	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 16640
use proconio::input;

fn main() {
    input! {
        n: usize,
    }

    let mut testimonies: Vec<Vec<(usize, usize)>> = vec![vec![]; n];
    for i in 0..n {
        input! {
            a: usize,
        }
        for _ in 0..a {
            input! {
                x: usize,
                y: usize,
            }
            testimonies[i].push((x, y));
        }
    }

    let mut maximum = 0;
    // bit travese
    'outer: for bit in 0u64..1 << n {
        for i in 0..n {
            if bit & (1 << i) != 0 {
                for (x, y) in &testimonies[i] {
                    if !(*y == 0 && bit & (1 << (x - 1)) == 0
                        || *y == 1 && bit & (1 << (x - 1)) != 0)
                    {
                        continue 'outer;
                    }
                }
            }
        }
        //pass!
        if maximum < bit.count_ones() {
            maximum = bit.count_ones();
        }
    }

    println!("{}", maximum);
}


Measured memory_bytes: 2176
#include <stdio.h>
#define NIL -1
#define MAX_N 30
typedef struct node_ {
    int parent;
    int left;
    int right;
} Node;

Node T[MAX_N];
int D[MAX_N], H[MAX_N];

void setDepth(int u, int d) {
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u) {
    int h1 = 0, h2 = 0;
    if (T[u].left != NIL) {
        h1 = setHeight(T[u].left) + 1;
    }
    if (T[u].right != NIL) {
        h2 = setHeight(T[u].right) + 1;
    }

    if (h1 >= h2) {
        return H[u] = h1;
    } else {
        return H[u] = h2;
    }
}

int getSibling(int u) {
    if (T[u].parent == NIL) return NIL;
    if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) {
        return T[T[u].parent].left;
    }
    if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
        return T[T[u].parent].right;
    }
    return NIL;
}

void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));

    int deg = 0;
    if (T[u].left != NIL) deg++;
    if (T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);

    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if (T[u].parent == NIL) {
        printf("root\n");
    } else if (T[u].left == NIL && T[u].right == NIL) {
        printf("leaf\n");
    } else {
        printf("internal node\n");
    }
}

int main(void) {
    int i, n;
    scanf("%d", &n);
    for (i = 0; i < MAX_N; i++) {
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }

    for (i = 0; i < n; i++) {
        int id, left, right;
        scanf("%d %d %d", &id, &left, &right);
        T[id].left = left;
        T[id].right = right;
        if (left != NIL) T[left].parent = id;
        if (right != NIL) T[right].parent = id;
    }

    int r;
    for (i = 0; i < n; i++) {
        if (T[i].parent == NIL) r = i;
    }

    setDepth(r, 0);
    setHeight(r);

    for (i = 0; i < n; i++) {
        print(i);
    }

    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
	string h;
	cin >> h;
  vector<char>v;
	int goo = 0, per = 0;
	for (int i = 0; i < h.length(); ++i) {
		if (i == 0) {
			v.push_back('g');
			goo++;
		}
		else {
			if (goo >= per+1){
              v.push_back('p');
              per++;
            }
			else{
              v.push_back('g');
              goo++;
            }
		}
	}
  int ans=0,lose=0;
for(int i=0;i<v.size();++i){
  if(v[i]=='p'&&h[i]=='g') ans++;
  else if(v[i]!=h[i]) lose++;
}
  cout<<ans-lose<<endl;
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    if (N%1000 == 0) cout << 0;
    else cout << abs(N%1000 - 1000);
    
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<string> A(N),B(M);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  for(int i=0;i<=N-M;i++){
    for(int j=0;j<=N-M;j++){
      bool flag=true;
      for(int k=0;k<M;k++){
        for(int l=0;l<M;l++){
          if(A[i+k][j+l]!=B[k][l]){
            flag=false;
          }
        }
      }
      if(flag){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3604
fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ")
        .map { it.toInt() }.groupBy { it }.mapValues { it.value.size }


    var answer = 0
    for (x in a) {
        val tmp = x.value + (a[x.key - 1] ?: 0) + (a[x.key + 1] ?: 0)
        if (answer < tmp) {
            answer = tmp
        }
    }
    println(answer)
}

Measured memory_bytes: 61264
import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    while (true) {
      val n = readLine.toInt
      if (n == 0) return

      var map = scala.collection.mutable.LinkedHashMap[Int, Int]()

      for (i <- 0 until n) {
        val s = readLine.split(' ').map(x => x.toInt)
        val emp = s(0)
        val price = s(1)
        val num = s(2)
        map += emp -> (map.getOrElse(emp, 0) + price * num)
      }

      val emps = map.filter(t => t._2 >= 1000000).keys
      if (emps.isEmpty) println("NA")
      else emps.foreach(println)
    }
  }
}

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

int main(void)
{
    int N, result = 0;
    if(scanf("%d", &N) == EOF) exit(1);

    result = N % 1000;
    if (result != 0) result = 1000 - result;
    printf("%d", result);

    return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

void dijkstra( int s, vector<vii>& g, vl& dist ){
    priority_queue<pll,vll,greater<pll>> q;
    dist.assign(g.size(),1e18);
    dist[s] = 0;
    q.emplace(0,s);
    while( q.size() ){
        int from = q.top().second; ll  di = q.top().first;
        q.pop();
        if( di > dist[from] ) continue;
        for( pii tow : g[from] ){
            int to = tow.first;
            int co = tow.second;
            if( dist[to] > di+co ){
                dist[to] = di+co;
                q.emplace(dist[to],to);
            }
        }
    }
}

int main() {

    int N,M,s,t;
    Scd2(N,M);
    Scd2(s,t);
    s--,t--;

    vector<vii> ga(N);
    vector<vii> gb(N);
    int u,v,a,b;
    Rep(i,M){
        Scd2(u,v);
        Scd2(a,b);
        u--,v--;
        ga[u].emplace_back(v,a);
        ga[v].emplace_back(u,a);
        gb[u].emplace_back(v,b);
        gb[v].emplace_back(u,b);
    }

    vl da,db;
    dijkstra(s, ga, da);
    dijkstra(t, gb, db);

    ll tmp = 0;
    vl ans;
    RRep(i,N){
        tmp = max( tmp, 1000000000000000LL - da[i] - db[i] );
        ans.push_back(tmp);
    }

    RRep(i,N){
        printf ("%lld\n", ans[i] );
    }


    return 0;
}




Measured memory_bytes: 18468
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
    int x1, y1, x2, y2, x3, y3, x4, y4, a;

    cin >> x1 >> y1 >> x2 >> y2;

    x3 = x2+(y1-y2);
    y3 = y2+(x2-x1);

    x4 = x3+(x1-x2);
    y4 = y3+(y1-y2);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

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

int main()
{
    int a,b,c,s=0;
    cin>>a>>b>>c;
    if(a!=b&&a!=c&&b!=c)
        cout<<3;
    else if(a==b&&b!=c)
        cout<<2;
    else if(b==c&&a!=c)
        cout<<2;
    else if(c==a&&b!=a)
    cout<<2;

    else cout<<1;
    return 0;
}


Measured memory_bytes: 3632
from collections import deque
 
n,p=map(int ,input().split())
que=deque([])
 
for i in range(n):
    name,time=input().split()
    time=int(time)
    que.append([name,time])
 
t=0
while len(que)>0:
    atop=que.popleft()
    spend=min(atop[1],p)
    atop[1]-=spend
    t+=spend
    if(atop[1]==0):
        print(atop[0],t)
    else:
        que.append(atop)


Measured memory_bytes: 13272
# -*- coding: utf-8 -*-
import sys

N = int(input())
s = input()
t = input()

if s == t:
    print(N)
    sys.exit()

for i in range(1,N):
    if s[i:] == t[:-i]:
        print(N + i)
        sys.exit()
print(2 * N)

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
int main(void)
{
	int N, count[1000] = { 0 }, ch[1000] = {0}, max = 0, ans = 0;;
	char S[100010];
	scanf("%d%s", &N,S);
	for (int i = 1; i < N-1; i++) {
		for (int j = 0; j < i; j++) {
			count[S[j]] = 1;
		}
		for (int k = i; k < N; k++) {
			ch[S[k]]++;
			if (count[S[k]] == ch[S[k]]) {
				ans++;
			}
		}
		if (max < ans) {
			max = ans;
		}
		for (int l = 0; l < 1000; l++) {
			ch[l] = 0;
		}
		ans = 0;
	}
	printf("%d", max);
	return 0;
}

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

using namespace std;

vector <int> Veca;
int a,c=0,sum=0,p,q;

int main()
{
    for (int i=1;i<=3;i++)
    {
        cin >> a;
        Veca.push_back(a);
    }
    sort(Veca.begin(),Veca.end());

    for (int j=1;j<3;j++)
    {
        c = Veca[j] - Veca[j-1];
        sum += c;
    }
    cout << sum << endl;
}


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

using namespace std;

int main() {
	int a, b, result;
	cin >> a >> b;
	
	if (a > b) {
		result = a * 2 - 1;
	} else if (b > a) {
		result = b * 2 - 1;
	} else {
		result = a + b;
	}

	cout << result;
}

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

int main() {
    while (true) {
        int h[5];
        cin >> h[0];
        if (h[0] == 0) break;
        for (int i = 1; i < 5; i++) cin >> h[i];

        int cnt1, cnt2, cnt3;
        cnt1 = cnt2 = cnt3 = 0;
        rep(i, 5) {
            if (h[i] == 1) cnt1++;
            else if (h[i] == 2) cnt2++;
            else cnt3++;
        }
        
        if (cnt1 == 5 || cnt2 == 5 || cnt3 == 5 || cnt1*cnt2*cnt3 > 0) rep(i, 5) cout << 3 << endl;
        else {
            if (cnt1 == 0) rep(i, 5) {
                if (h[i] == 2) cout << 1 << endl;
                else cout << 2 << endl;
            } else if (cnt2 == 0) rep(i, 5) {
                if (h[i] == 3) cout << 1 << endl;
                else cout << 2 << endl;
            } else rep(i, 5) {
                if (h[i] == 1) cout << 1 << endl;
                else cout << 2 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N, K;
	string s;

	cin >> N >> K;
	cin >> s;
	s[K - 1] = tolower(s[K - 1]);
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def isqrt(n):
    if n > 0:
        x = 1 << (n.bit_length() + 1) // 2
        y = (x + n // x) // 2
        while y < x:
            x = y
            y = (x + n // x) // 2
        return x
    elif n == 0:
        return 0
    else:
        raise ValueError("isqrt() argument must be nonnegative")


def main():
    N = int(readline())
    n = (isqrt(8 * N + 1) - 1) // 2
    if N != n * (n + 1) // 2:
        print('No')
        return

    it = iter(range(1, N + 1))
    G = [[0] * n for _ in range(n)]
    for i in range(n):
        for j in range(i + 1):
            G[i][j] = G[j][i] = next(it)

    G.append([G[i][i] for i in range(n)])
    ans = ["{} {}".format(n, ' '.join(map(str, row))) for row in G]
    print('Yes')
    print(n + 1)
    print('\n'.join(ans))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 56412
#include<stdio.h>

#define MAX 1000

int top;
int S[MAX];

int initialize(){
       return top=0;
       }

int isempty(){
       return top==0;
       }

int isfull(){
       return top>=MAX-1;
       }

void push(int n){
       if (isfull()){return;}

       top++;
       S[top]=n;
       }

int pop(){
       if (isempty()){return;}

       top--;
       return S[top+1];
       }

int main(){
       int i,j,x,y;
       char op[MAX];
       initialize();
       while(scanf("%s",&op) != EOF){
                   if(op[0]=='+'){
                               x=pop();
                               y=pop();
                               push(y+x);
                               }
                   else if(op[0]=='-'){
                               x=pop();
                               y=pop();
                               push(y-x);
                               }
                   else if(op[0]=='*'){
                               x=pop();
                               y=pop();
                               push(y*x);
                               }
                   else {push(atoi(op));}
                   }
          printf("%d\n",pop());
          return 0;
          }




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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


ll k;


ll dp[20][20][2];
bool bio[20][20][2];
ll dig[20];
ll br = 0;

ll kolko(ll idx, ll cif, bool manji){
    if(idx >= br)return 1;
    if(bio[idx][cif][manji])return dp[idx][cif][manji];
    bio[idx][cif][manji] = 1;
    if(manji){
        ll res = kolko(idx + 1, cif, 1);
        if(cif != 0)res += kolko(idx + 1, cif - 1, 1);
        if(cif != 9)res += kolko(idx + 1, cif + 1, 1);
        return dp[idx][cif][manji] = res;
    }
    else{
        ll p = 0, d = 0, t = 0;
        ll res = 0;
        if(cif < dig[idx]){
            res += kolko(idx + 1, cif, 1);
        }
        else if( cif == dig[idx]){
            res += kolko(idx + 1, cif, 0);
        }

        if(cif != 0 && cif-1 < dig[idx]){
            res += kolko(idx + 1, cif-1, 1);
        }
        else if(cif != 0 && cif-1 == dig[idx]){
            res += kolko(idx + 1, cif - 1, 0);
        }

        if(cif != 9 && cif+1 < dig[idx]){
            res += kolko(idx + 1, cif+1, 1);
        }
        else if(cif != 9 && cif+1 == dig[idx]){
            res += kolko(idx + 1, cif + 1, 0);
        }
        return dp[idx][cif][manji] = res;
    }
}

ll resi(ll x){
    ll pomx = x;
    br = 0;
    while(pomx > 0){
        dig[br++] = pomx%10;
        pomx /= 10;
    }
    reverse(dig, dig + br);
    ff(i,0,15){
        ff(j,0,15){
            dp[i][j][0] = dp[i][j][1] = 0;
            bio[i][j][0] = bio[i][j][1] = 0;
        }
    }
    if(x <= 10){
        return x;
    }
    ll sum = 0;

    ff(i,1,9){
        if(i < dig[0]){
            sum += kolko(1,i,1);
        }
        else if(i == dig[0]){
            sum += kolko(1,i,0);
        }
    }
    ll prvimanjist = 1;
    while(prvimanjist <= x)prvimanjist *= 10;
    prvimanjist /= 10;
    prvimanjist--;
    return (sum) + resi(prvimanjist);
}


int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> k;
    ll l = 1;
    ll r = 1000000000000000000;

    //return 0;
    while(l < r){
        //cout << l << " " << r << endl;
        ll mid = (l + r) / 2;
        if(resi(mid) < k)l = mid+1;
        else r = mid;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 256
// G++ MACro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n,c,k);V t(n);VECCIN(t);
  sort(ALL(t));

  int ans=0;
  int nbus=0;
  int ntime=t[0];
  REP(i,n){
    if(nbus==0)ntime=t[i];
    if(ntime+k<t[i]){ans++;nbus=0;ntime=t[i];}
    nbus++;
    if(nbus==c){ans++;nbus=0;}
  }
  if(nbus)ans++;
  COUT(ans);

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define got(container,num) get<num-1>(container)
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m

using namespace std;
const int INF=LLONG_MAX-1e10;
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;

main()
{
    IOS
    cin>>n>>m;
    fu(i,1,1255)
    {
        if(floor(i*0.08)==n && floor(i*0.1)==m){
            out(i)
            return 0;
        }
    }
    out(-1)
    return 0;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
d = K - A[-1]
d = max(d, A[0] + (K - A[-1]))

for i in range(0, N - 1):
  d = max(d, A[i + 1] - A[i])
  
print(K - d)

Measured memory_bytes: 26436
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;

int n;
int x[216000];

vector<int> nums;


int main(){
	cin >> n;
	for(int i = 0; i< n;i++){
		cin >> x[i];
		nums.push_back(x[i]);
	}
	sort(nums.begin(), nums.end());
	int l = nums[n/2 - 1];
	int r = nums[n/2];
	for(int i = 0;i < n;i++){
		if(x[i] <= l)cout << r << endl;
		else cout << l << endl;
	}
	return 0;
				
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define BITF(n, i) (((n) >> i) & 1)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T> void print2(const T &x, const T &y) { cout << x << " " << y << "\n"; }
template <class T> void print3(const T &x, const T &y, const T &z) { cout << x << " " << y << " " << z << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec<int> x(N), y(N);
  int p[2] = {0, 0};

  REP(i, N) {
    cin >> x[i] >> y[i];
    p[abs(x[i] + y[i]) % 2]++;
  }
  if ((p[0] == N || p[1] == N)) {
    bool even = p[0] == N;
    int arm = 39 + even;
    print(arm);
    REP(i, 39) cout << BIT(i) << " ";
    if (even) {
      cout << "1"
           << "\n";
    } else {
      cout << "\n";
    }
    int maxV = BIT(39) - 1;
    REP(i, N) {
      int dx = x[i] - even;
      int dy = y[i];
      //変更するものにBITが立っている。
      int tx = (maxV - (dx + dy)) / 2;  // defaultだと、RU.
      int ty = (maxV - (dx - dy)) / 2;

      //      int isMinus= tx<0;
      REP(i, 39) {
        int val = 2 * BITF(tx, i) + BITF(ty, i);
        cout << "RUDL"[val];
      }
      if (even) cout << "R";
      cout << "\n";
    }

  } else {
    print(-1);
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	int v[110];
	for (int i = 0; i < N; i++) cin >> v[i];
	sort(v, v + N);
	double ans = (v[0] + v[1]) / 2.0;
	for (int i = 2; i < N; i++) {
		ans = (ans + v[i]) / 2.0;
	}
	printf("%.6f\n", ans);
}

Measured memory_bytes: 256
/**
 * 与えられた文字列の小文字と大文字を入れ替えるプログラムを作成してください。
*/

//スキャナつかうため

import java.util.Scanner;

public class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		//文字列を受け取る
		String moji = sc.nextLine();
		//受け取った文字数の配列の宣言
		char [] chmoji = new char [moji.length()];
		//受け取った文字の数処理を繰り返す
		for (int i =0; i<moji.length(); i++){

			chmoji[i]   = moji.charAt(i);
			//受け取った文字が大文字ならtrue 小文字ならfalse
			//booleanの変数kekkaに文字を入れる
			  boolean kekka = Character.isUpperCase(chmoji[i]);
			  //kekkaがtrue なら小文字に、falseなら大文字に変換
			 if (kekka == true ){
				 chmoji[i] = Character.toLowerCase(chmoji[i]);
			 }else {
				 chmoji[i] = Character.toUpperCase(chmoji[i]);
			 }
			 //結果を表示して並べる
			 System.out.print(chmoji[i]);

		}
		//改行
		System.out.println();
	}
}

Measured memory_bytes: 17296
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    /*ll t;
    cin>>t;
    while(t--)*/
     ll a,b,k;
     cin>>a>>b>>k;
     if(a>=k)
        cout<<a-k<<endl<<b;
     else
     {
         cout<<0<<endl;
         k=k-a;
         if(k>b)
            cout<<0;
         else
            cout<<b-k;
     }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
cnt = [[0] * 10 for i in range(10)]

for i in range(1,N+1):
    S = str(i)
    cnt[int(S[0])][int(S[-1])] += 1
ans = 0

for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)


Measured memory_bytes: 3060
# include "cstdio"
# include "iostream"

using namespace std;

long long GCD(long long x,long long y){
	return y==0?x:GCD(y,x%y); 
} 

int main(){
	int t; 
	scanf("%d",&t);
	while(t--){
		long long a,b,c,d;
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(a<b || b>d){
			puts("No"); 
		}else if(b<=c){
			puts("Yes"); 
		}else{
			long long gcd=GCD(b,d);
			if(b-gcd+a%gcd>c){
				puts("No"); 
			}else{
				puts("Yes"); 
			} 
		} 
	} 
	return 0; 
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final long a = fs.nextLong();
        final long b = fs.nextLong();
        final long c = fs.nextLong();
        final long d = fs.nextLong();
        long max = (long) -5e18;
        max = Math.max(max, a * c);
        max = Math.max(max, a * d);
        max = Math.max(max, b * c);
        max = Math.max(max, b * d);
        System.out.println(max);
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32672
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[6],k;
    for(int i=0;i<5;i++)
        cin>>a[i];
      cin>>k;
    int sum=0;
    int flag=0;
    for(int i=0;i<5;i++)
        for(int j=i+1;j<5;j++)
          {
              sum=a[j]-a[i];
              if(sum>k)
                flag=1;
          }
     flag==0? puts("Yay!"):puts(":(");
    return 0;
}


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

enum FACE{TOP, NORTH, WEST, EAST, SOUTH, BOTTOM};
int dice[6];

void roll(FACE a, FACE b, FACE c, FACE d)
{
	int t=dice[a];
	dice[a]=dice[b];
	dice[b]=dice[c];
	dice[c]=dice[d];
	dice[d]=t;
}

int main()
{
	int N;
	char buf[9];
	while(scanf("%d", &N), N)
	{
		for(int i=0; i<6; i++)
			dice[i]=i+1;
			
		while(N--)
		{
			scanf("%s", buf);
			if(buf[0]=='s') roll(TOP, NORTH, BOTTOM, SOUTH);
			if(buf[0]=='n') roll(TOP, SOUTH, BOTTOM, NORTH);
			if(buf[0]=='w') roll(TOP, EAST, BOTTOM, WEST);
			if(buf[0]=='e') roll(TOP, WEST, BOTTOM, EAST);
		}
		
		printf("%d\n", dice[TOP]);
	}
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int x = 0, y = 0;
			int array[][] = new int [2][n];
			for (int  i = 0;i<2;i++) {
				for(int j = 0;j<n;j++) {
					array[i][j] = sc.nextInt();
				}
			}
			for(int i = 0; i<n;i++) {
			if(array[0][i]>array[1][i]) {
				x+=array[0][i];
				y+=array[1][i];
			}
		}
			System.out.println(x-y);
			
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 22740
class UnionFind:
    def __init__(self, size):
        self.__data = [-1 for _ in range(size)]
    def find(self, x):
        if self.__data[x] < 0:
            return x
        else:
            self.__data[x] = self.find(self.__data[x])
            return self.__data[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.__data[y] < self.__data[x]:
                x, y = y, x
            self.__data[x] += self.__data[y]
            self.__data[y] = x
        return (x != y)
    def same(self, x, y):
        return (self.find(x) == self.find(y))
    def size(self, x):
        return -self.__data[self.find(x)]

N, K, L = [int(i) for i in input().split()]

uf1 = UnionFind(N)
for _ in range(K):
    p, q = [int(i) - 1 for i in input().split()]
    uf1.union(p, q)

uf2 = UnionFind(N)
for _ in range(L):
    r, s = [int(i) - 1 for i in input().split()]
    uf2.union(r, s)

from collections import Counter
C = Counter((uf1.find(i), uf2.find(i)) for i in range(N))
print(*[C[(uf1.find(i), uf2.find(i))] for i in range(N)])


Measured memory_bytes: 41504
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>

using namespace std;

// 10
// aabbbbaaca

int main() {
  int n;
  scanf("%d", &n);

  string slimes;
  cin >> slimes;

  int num = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0 || slimes[i - 1] != slimes[i]) {
      num++;
    }
  }
  cout << num << endl;
}


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

int main(){
  string s; cin>>s;
  
  for(int i=0;i<(int)s.size();i++){
    if(i%2==0){
      if(s[i]=='L'){
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      if(s[i]=='R'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  
  cout<<"Yes"<<endl;
  return 0;
}

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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
bool inte(double y){
  return floor(y) == y;
}

int main(){
  int n,d;
  cin >> n >> d;
  vvi x(n,vi(d));
  rep(i,n){
    rep(j,d){
      cin >> x.at(i).at(j);
    }
  }

  int ans =0;
  rep(i,n){
    rep(j,n){
      if(i==j)continue;
      int sum =0;
      rep(k,d){
        sum += pow((x.at(i).at(k)-x.at(j).at(k)),2);
      }
      if(inte(sqrt((double)sum))) ans++;
    }
  }
  cout << ans/2 << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.dat", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		int num = 0;
		stringstream ss(str);
		ss >> num;
		num %= 39;
		if (num == 0){
			num = 39;
		} // end if
		if (num < 10){
			cout << "3C0" << num << endl;
		}else{
			cout << "3C" << num << endl;
		} // end if
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
using ull = unsigned long long;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::array;
template <class T>
using matrix = vector<vector<T>>;
template <class T>
constexpr T inf = std::numeric_limits<T>::max();
template <class T>
constexpr T neg_inf = -std::numeric_limits<T>::max();
template <class T>
constexpr T pi = static_cast<T>(3.141592653589793);

template <class T = i64>
vector<T> read_vector(const u64 n)
{
    vector<T> vec;
    vec.reserve(n);
    for (u64 i = 0; i < n; i++)
    {
        T v;
        cin >> v;
        vec.emplace_back(v);
    }

    return vec;
}

template <class T>
void print(const vector<T>& vec, const bool new_line = false)
{
    const u64 n = vec.size(); 
    if (new_line)
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << '\n'; }
        }
    }
    else
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << ' '; }
        }
    }

    cout << endl;
}

int main()
{
    u32 n;
    cin >> n;
    string str;
    cin >> str;
    u32 sum = 0;
    char cur = '\0';
    for (u32 i = 0; i < n; i++)
    {
        if (cur != str[i])
        {
            sum++;
            cur = str[i];
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int x, y, z, k;
int main(){
	scanf("%d%d%d%d", &x, &y, &z, &k);
	if(x > y) swap(x, y);
	if(x > z) swap(x, z);
	if(y > z) swap(y, z);
	printf("%d\n", x + y + (z << k));
	return 0;
} 

Measured memory_bytes: 256