akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<set>
#include<bitset>
#include<algorithm>
using namespace std;

const int N = 49;

int w, h;
vector<vector<int>> field;
int size;
vector<vector<int>> vertex;
vector<vector<int>> edge;
bitset<N> visited;
set<unsigned long long> memo;

void make_graph() {
    enum {Y, X};
    const int NEXT[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
    const int NIL = -1;
    size = 0;
    vertex = vector<vector<int>>(h, vector<int>(w, NIL));
    for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) if(!field[y][x]) vertex[y][x] = size++;
    edge = vector<vector<int>>(h * w, vector<int>());
    for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) {
        if(vertex[y][x] == NIL) continue;
        for(const auto &d: NEXT) {
            int ny = y + d[Y];
            int nx = x + d[X];
            if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
            if(vertex[ny][nx] == NIL) continue;
            edge[vertex[y][x]].push_back(vertex[ny][nx]);
        }
    }
};

void reachability(const int &from, bitset<N> &visited) {
    visited.set(from);
    for(const auto &to: edge[from]) if(!visited[to]) reachability(to, visited);
}
bool cut_vertex(const int &from) {
    auto dup = visited;
    dup.set(from);
    for(const auto &to: edge[from]) {
        if(dup[to]) continue;
        reachability(to, dup);
        return dup.count() != size;
    }
    return dup.count() != size;
}

bool dfs(const int &start, int from) {
//     cout<<visited<<" "<<from<<endl;
    unsigned long long m = visited.to_ullong() * N + from;
    if(memo.count(m)) return false;
    memo.insert(m);

    // startの四方が囲まれていたらダメ
    bool deadend = true;
    for(const auto &v: edge[start]) deadend &= visited[v];
    if(deadend) return false;

    // cut vertexはダメ
    if(cut_vertex(from)) return false;

    // 現在地以外で次数1の頂点があるとダメ
    for(int u = 0; u < size; ++u) {
        if(u == from) continue;
        if(visited[u]) continue;
        int degree = 0;
        for(const auto& v: edge[u]) if(v == start || !visited[v]) ++degree;
        if(degree < 2) return false;
    }

    visited.set(from);
    for(const auto &to: edge[from]) {
        if(to == start && visited.count() == size) return true;
        if(visited[to]) continue;
        if(dfs(start, to)) return true;
    }
    visited.reset(from);
    return false;
}

bool solve() {
    visited = bitset<N>(0);
    make_graph();
    memo.clear();
    for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) if(!field[y][x]) return dfs(vertex[y][x], vertex[y][x]);
    return false;
}

int main() {
    while(cin >> w >> h, w | h) {
        field = vector<vector<int>>(h, vector<int>(w));
        for(auto &line: field) for(auto &v: line) cin >> v;
        cout << (solve() ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 15324
def main():
    ABCD = list(input())
    A = int(ABCD[0])
    B = int(ABCD[1])
    C = int(ABCD[2])
    D = int(ABCD[3])

    flag = True
    for i in ['+', '-']:
        if flag:
            sumAB = A + B if i == '+' else A - B
            for j in ['+', '-']:
                if flag:
                    sumABC = sumAB + C if j == '+' else sumAB - C
                    for k in ['+', '-']:
                        if flag:
                            sumABCD = sumABC + D if k == '+' else sumABC - D
                            if sumABCD == 7:
                                print(str(A) + i + str(B) + j + str(C) + k + str(D) + "=7")
                                flag = False

if __name__ == '__main__':
    main()


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

int num[100];

void printArray(int A[], int n){
    for(int i=0; i<n; i++){
        cout << num[i];
        if(i!=n-1) cout << " ";
    }
    cout << "\n";
}

void insertionSort(int A[], int n){
    int v, j;
    for(int i=0; i<n; i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        printArray(A, n);
    }
}

int main(){
    int N;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> num[i];
    }

    insertionSort(num, N);

    return 0;
}



Measured memory_bytes: 3100
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=list(input())

ans=0
for i in n:
    ans+=int(i)

if ans%9==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 78212
#include <stdio.h>

int main() {
  int N,i,j,mini,temp,t;
  scanf("%d", &N);
  int a[N];
  for(i = 0; i < N; i++) scanf("%d", a+i);

  t = 0;
  for(i = 0; i < N-1; i++) {
    mini = i;
    for(j = i+1; j < N; j++)
      if(a[mini] > a[j])
	mini = j;
    if(i != mini) {
      temp = a[i];
      a[i] = a[mini];
      a[mini] = temp;
      t++;
    }
  }

  for(i = 0; i < N-1; i++) printf("%d ", a[i]);
  printf("%d\n%d\n", a[i], t);

  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#define N 3
#define MAX 15
typedef struct{
    int A[N][N];
}Pazzle;
Pazzle P;
int d_x[4]={0,1,0,-1};
int d_y[4]={1,0,-1,0};

void swap(int *A,int *B){
 int hoge;
 hoge=*A;
 *A=*B;
 *B=hoge;


}

int check(Pazzle P){
    int sum=0,i,j,hy,hx;
    for(i=0;i<N;i++){

    for(j=0;j<N;j++){
        if(P.A[i][j]==0)
        continue;
        hy=(P.A[i][j]-1)/N-i;
        hx=(P.A[i][j]-1)%N-j;
        if(hy<0)
        sum-=hy;
        else
        sum+=hy;
        if(hx<0)
        sum-=hx;
        else
        sum+=hx;


}
}

return sum;
}

int dfs(int x,int y,int max,int cnt,int m){
         int i;
  int heau;
  int x_0,y_0;
  int ans=-1;
  heau=check(P);
  if(heau==0) return cnt;
  if(cnt+heau>max) return -1;
  for(i=0;i<4;i++){
    x_0=x+d_x[i];
    y_0=y+d_y[i];

    if((m!=-1&&i==(m+2)%4)||!(0<=x_0 && x_0<N && 0<=y_0 && y_0<N)) continue;
    swap(&P.A[y][x],&P.A[y_0][x_0]);
    ans=dfs(x_0,y_0,max,cnt+1,i);
    if(ans!=-1) return ans;
     swap(&P.A[y][x],&P.A[y_0][x_0]);
  }
  return -1;
}

int main(void){
    Pazzle t_P;
    int  i,j,ans;
    int x0,y0;

    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            scanf("%d",&P.A[i][j]);
            if(P.A[i][j]==0){
                x0=j;
                y0=i;

            }

        }
    }
    t_P=P;
    for(i=1;i<46;i++){
        P=t_P;
    ans=dfs(x0,y0,i,0,-1);
    if(ans!=-1){printf("%d\n",ans); break;}
    }
    return 0;
}



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

int main()
{
int A;
int B;
int C;
int D;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;

	A += B;
	C += D;
	if( A < C )
		cout << "Right" << endl;
	else if( A > C )
		cout << "Left" << endl;
	else
		cout << "Balanced" << endl;

	return 0;
}



Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input_string = '';

process.stdin.on('data', function(chunk) {
    input_string += chunk;
});

process.stdin.on('end', function() {
    var lines = input_string.split('\n');
    main(lines.slice(0, lines.length-1));
});

function main(lines) {
    lines.forEach(function(x) {
        console.log(Math.pow(parseInt(x), 3));
    });
}

Measured memory_bytes: 15820
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
static const int MAX_N = 100;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point{
	public:
		double x, y;

		Point(double x = 0, double y = 0): x(x), y(y) {}

		Point operator + (Point p){ return Point(x + p.x, y + p.y);}
		Point operator - (Point p){ return Point(x - p.x, y - p.y);}
		Point operator * (double a){ return Point(a * x, a * y);}
		Point operator / (double a){ return Point(x / a, y / a);}

		double abs(){ return sqrt(norm());}
		double norm(){ return x * x + y * y;}

		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}

		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};

struct Segment {
	Point p1, p2;
};
typedef Segment Line;

class Circle{
	public:
		Point c;
		double r;
		Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

typedef Point Vector;
typedef vector<Point> Polygon;

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}

int n;
int x[MAX_N], y[MAX_N];

void solve(){
	double ans = 0.0;
	for(int i = 0; i < n - 1; i++){
		ans += 0.5 * (double)(x[i] - x[i + 1]) * (double)(y[i] + y[i + 1]);
	}
	ans += 0.5 * (double)(x[n - 1] - x[0]) * (double)(y[n - 1] + y[0]);
	printf("%.1lf\n", ans);
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d %d", &x[i], &y[i]);
	solve();
	return 0;
}

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

using namespace std;

int main(){
	 string w; cin >> w;
	 if(w[w.length()-1]=='s'){
		w.push_back('e');
		w.push_back('s');
	}
	else {
		w.push_back('s');
	}
	cout << w;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

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

int32_t main()
{
	fastIO
	inp_out();

	int x, n; 
	cin >> x >> n; 
	set < int >  st; ; 

	for(int i = 0; i < n; ++i)
	{
		int z; 
		cin >> z; 
		st.insert(z); 
	}

	int dif = inf; 
	int ans = inf; 
	for(int i = x; i > x - 1000; --i)
		if(st.find(i) == st.end())
		{
			int diff = abs(x - i); 
			if(diff < dif)
			{
				dif = diff; 
				ans = i; 
			}
			break; 
		}

	for(int i = x; i  <  x  +  1000; ++i)
		if(st.find(i) == st.end())
		{
			int diff = abs(x - i); 
			if(diff < dif)
			{
				dif = diff; 
				ans = i; 
			}
			break; 
		}

	cout << ans; 

	return 0;
}

Measured memory_bytes: 3648
read n a b
ans=0
for (( k = 1; k <= n; k++ )); do
    dsum=0 k1=$k
    while (( k1 > 0 )); do
        dsum=$(( dsum + k1 % 10 )) k1=$(( k1 / 10 ))
    done
    (( dsum >= a && dsum <= b )) && (( ans += k ))
done
echo ${ans}

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

int main() {
    ll n,d;
    cin>>n>>d;
    ll x[n];
    ll y[n];
    ll ans = 0;
    rep(i,n){
        cin>>x[i]>>y[i];
        if(x[i]*x[i]+y[i]*y[i]<=d*d){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) (x & (-x))
#define BIT(a,b) ((ll)(a&(1<<b))==0 ? false : true)

const ll MAXN=5e3+10;

vector <short> r[MAXN];
vector <short> l[MAXN];

ll a[MAXN];

bool dpl[MAXN][MAXN];
bool dpr[MAXN][MAXN];

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

    ll n,k,res=0;
    cin>>n>>k;

    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }

    dpl[0][0]=true;
    l[0].pb(0);

    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<k;j++)
        {
            if (a[i]>j)
            {
                dpl[i][j]=dpl[i-1][j];
            }
            else
            {
                dpl[i][j]=dpl[i-1][j] | dpl[i-1][j-a[i]];
            }

            if (dpl[i][j])
            {
                l[i].pb(j);
            }
        }
    }

    dpr[n+1][0]=true;
    r[n+1].pb(0);

    for(ll i=n;i>0;i--)
    {
        for(ll j=0;j<k;j++)
        {
            if (a[i]>j)
            {
                dpr[i][j]=dpr[i+1][j];
            }
            else
            {
                dpr[i][j]=dpr[i+1][j] | dpr[i+1][j-a[i]];
            }

            if (dpr[i][j])
            {
                r[i].pb(j);
            }
        }
    }

    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<l[i-1].size();j++)
        {
            ll u=lower_bound(r[i+1].begin() , r[i+1].end() , k-l[i-1][j])-r[i+1].begin()-1;

            if (u==-1)
            {
                continue;
            }
            else
            {
                if ((r[i+1][u]+l[i-1][j]) >= (k-a[i]))
                {
                    res++;
                    goto E;
                }
            }
        }

        E:;
    }

    cout<<n-res;

    return 0;
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;
Graph G(100010);

queue<ll> Q;

void bfs(ll s,vector<ll>& table){ 
  for(int i = 0;i < table.size();i++){
    table[i] = INF;
  }
  table[s] = 0;
  Q.push(s);
  while(Q.size()){
    ll x = Q.front();
    ll n = G[x].size();
    Q.pop();
    for(ll i = 0;i < n;i++){
      ll y = G[x][i];
      if(table[y] == INF){
        table[y] = table[x] + 1;
        Q.push(y);
      }
    }
  }
  return;
}

int main(){
 ll N,U,V;
 cin >> N >> U >> V;
 U--;V--;
 vector<ll> par(N);
 for(int i = 0;i < N-1;i++){
   ll a,b;cin >> a >> b;
   a--;b--;
   par[max(a,b)] = min(a,b);
   G[a].push_back(b);
   G[b].push_back(a);
 }
 vector<ll> tableA(100010),tableT(100010);
 vector<bool> frag(100010);
 for(int i = 0;i < 100010;i++){
   frag[i] = 1;
 }
 bfs(V,tableA);
 bfs(U,tableT);
 
 ll ans = 0;
 for(int i = 0;i < N;i++){
   if(tableT[i] < tableA[i]){
     ans = max(ans,tableA[i]);
   }
 }
 cout << ans - 1 << endl;
}


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

using namespace std;

int main() {
  int n,k,x,y;
  int ans = 0;
  cin >> n >> k >> x >> y;

  for(int i = 0; i < n; i++){
    if(i < k){
      ans += x;
    }else{
      ans += y;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b&&b<c)
    printf("Yes\n");
    else
        printf("No\n");

    return 0;
}



Measured memory_bytes: 3024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 3e5 + 5;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
int n, a[N], s[N];
void solve1() {
	int s0 = 0, s1 = 0;
	for(int i = 1; i <= n; ++ i) if(i & 1) s0 += a[i]; else s1 += a[i];
	printf("%d %d\n", max(s0, s1), min(s0, s1));
}
bool check(int mid) {
	int v = 0;
	for(int i = 1; i < n; i += 2) if(s[i] - v >= mid) v = min(v, s[i + 1]);
	return s[n] - v >= mid;
}
void solve2() {
	for(int i = 1; i <= n; ++ i) if(i & 1) s[i] = s[i - 1] + a[i]; else s[i] = s[i - 1] - a[i];
	int l = 1, r = n * 1000, mid, ans = l;
	while(l <= r) {
		mid = (l + r) >> 1;
		if(check(mid)) l = mid + 1, ans = mid;
		else r = mid - 1;
	}
	for(int i = 2; i <= n; i += 2) ans += a[i];
	int sum = 0;
	for(int i = 1; i <= n; ++ i) sum += a[i];
	printf("%d %d\n", ans, sum - ans); 
}
int main() {
	n = read();
	for(int i = 1; i <= n; ++ i) a[i] = read();
	if(n % 2 == 0) return solve1(), 0;
	else return solve2(), 0;
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int serch(int,int,int[]);

int main(){
  int S[100000];
  int t;
  int i,key,n,q,sum=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t);
    if(serch(n,t,S)==1){
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}

int serch(int n,int key,int S[]){
  int left=0,mid,right=n;

   while(left<right){
     mid=(left+right)/2;

     if(key==S[mid]){
       return 1;
     }
     if(key>S[mid]){
       left=mid+1;
     }
     else if(key<S[mid]){
        right=mid;
       }
   }
     return 0;
}

  



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

int main() {
  long n,a=0,b=0;
  string s;
  cin >> n >> s;
  for(long i=0;i<n;i++) {
    if(s[i]=='(') {
      b++;
    } else {
      if(b>0) {
        b--;
      } else {
        a++;
      }
    }
  }
  for(long i=0;i<a;i++) cout << "(";
  cout << s;
  for(long i=0;i<b;i++) cout << ")";
  cout << endl;
}

Measured memory_bytes: 3624
S = input()
s = 0
suma = 0
for i in range(2**(len(S)-1)):
    s1 = S[0]
    for j in range(len(S)-1):
        if (i >> j) & 1 == 1:
            s1 += ' + '
        s1 += S[j+1]
    suma += eval(s1)
print(suma)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
	char a[3];
	for (int b = 0; b < 3; b++) {
		cin >> a[b];
		if (a[b] == '1')a[b] = '9';
		else a[b] = '1';
	}
	cout << a[0] << a[1] << a[2] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int start = 0;
	int goal = s.size()-1;
	int ans = 0;
	while (true) {
		if (start >= goal)break;
		if (s[start]!=s[goal]) {
			if (s[start] == 'x') {
				ans++;
				start++;
			}
			else if(s[goal]=='x') {
				ans++;
				goal--;
			}
			else {
				cout << -1 << endl;
				return 0;
			}
		}
		else {
			start++;
			goal--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
	long long n, d;
	cin >> n >> d;
	vector<long long> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (d * d >= x[i] * x[i] + y[i] * y[i]) {
			ans++;
		}
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6424
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String output = "No";
		String command = "W";
		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//?????????????????????
			String line = sc.nextLine();
			Dice di = new Dice(line);
			int[] diceOne = di.surface;

			line = sc.nextLine();
			di = new Dice(line);
			int[] diceTwo = di.surface;

				//?????????????????????????????¢???

				for (int j = 0; j < 4; j++) {

					for (int k = 0; k < 4; k++) {
						if (!Arrays.equals(diceOne, diceTwo)) {
							command = "N";
							diceOne = Dice.diceroll(diceOne, command);
							command = "W";

							for (int l = 0; l < 4; l++) {
								diceOne = Dice.diceroll(diceOne, command);
								if (Arrays.equals(diceOne, diceTwo)) {
									output = "Yes";
									break;
								}
							}

						}else{
							output = "Yes";
							break;
						}
					}
					//
					if (!Arrays.equals(diceOne, diceTwo)) {
						command = "W";
						diceOne = Dice.diceroll(diceOne, command);
					}else{
						output = "Yes";
						break;
					}
				}
				System.out.println(output);
		} finally {
			sc.close();
		}
	}

}

//?????????????????????
class Dice{

	int[] surface;

	public Dice(String s){

		String[] work;

		work = s.split(" ");

		surface = new int[work.length];

		for (int i = 0; i < work.length; i++) {
			surface[i] = Integer.parseInt(work[i]);
		}
	}

	//?????????????????????
	public int[] dicemake(String s) {
		int[] dice;
		String[] work;

		work = s.split(" ");
		dice = new int[work.length];

		for (int i = 0; i < work.length; i++) {
			dice[i] = Integer.parseInt(work[i]);
		}

		return dice;

	}

	//????????????????????????????????????
	public static int[] diceroll(int[] di , String com){
		int n = 0;
		int[] dice = di;

		//???????????????
			switch (com) {
			case "N":
				n = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = n;
				break;

			case "S":
				n = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = n;
				break;

			case "W":
				n = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = n;
				break;

			case "E":
				n = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = n;
				break;

			default:
				System.out.println("other");
				break;
			}
		return dice;

	}
}

Measured memory_bytes: 26248
#include <bits/stdc++.h>
using namespace  std;
double a;int t;long long b,n;
int main(){
	cin >> n;
	a= 100.0; b = 100;
	while( ++t ){
		a = (double)b * 1.01; 
		b = ( long long ) a;
		//cout << b << a << endl;
		if( (double)b > a ) b--;
		if( b >= n ){
			printf( "%d\n", t );
			return 0;
		}
	}
	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 2 * 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
ll a[N], n, k, zero;
vector <ll> neg, pos;
int main()
{
    cin >> n >> k;
    FOR(i, 0, n - 1) cin >> a[i];
    sort(a, a + n);
    ll l = -LINF, r = LINF;
    while(l + 1 < r)
    {
        ll mid = (l + r) >> 1;
        ll cnt = 0;
        FOR(i, 0, n - 1)
        {
            if(a[i] < 0)
            {
                int u = i, v = n;
                while(u + 1 < v)
                {
                    int uv = (u + v) >> 1;
                    if(a[i] * a[uv] <= mid) v = uv;
                    else u = uv;
                }
                cnt += n - v;
                //cout << "A " << cnt << " " << u << " " << v << endl;
            }
            else
            {
                int u = i, v = n;
                while(u + 1 < v)
                {
                    int uv = (u + v) >> 1;
                    if(a[i] * a[uv] <= mid) u = uv;
                    else v = uv;
                }
                cnt += u - i;
            }
        }
       // cout << l << " " << r << " " << mid << " " << cnt << endl;
        if(cnt >= k) r = mid;
        else l = mid;
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 1792
from collections import defaultdict
import itertools
#ID
b = defaultdict(lambda: len(b))
n = int(input())
hed = ["M","A","R","C","H"]
for i in hed:
    b[i] 
li = [0]*5
for _ in range(n):
    a = input()
    if a[0] in hed:
        li[b[a[0]]] += 1
c = [j for j in li if j != 0]
ans = 0
for k in itertools.combinations(c,3):
    ans += k[0]*k[1]*k[2]
print(ans)

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

ll v[22],c[22];

int main(void){
	int n,i,j;
	ll ans=-INFLL,tmp;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> v[i];
	}
	for(i=0; i<n; ++i){
		cin >> c[i];
	}
	for(i=0; i<(1<<n); ++i){
		tmp = 0ll;
		for(j=0; j<n; ++j){
			if(i&(1<<j)){
				tmp += v[j]-c[j];
			}
		}
		ans = max(tmp,ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()

odd = []
even = []
for i in range(len(S)):
    if i%2 == 0:
        odd.append(S[i])
    else:
        even.append(S[i])

ans = "Yes"
for i in odd:
    if i not in "RUD":
        ans = "No"
        break

for i in even:
    if i not in "LUD":
        ans = "No"
        break

print(ans)

Measured memory_bytes: 3064
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = print n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStrLn n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  n <- readInteger
  a <- readInts
  print $ foldl1' gcd a


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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    string s,t; cin >> s >> t;
    int ans=INF;
    for(int i=0;i<s.size();i++){
        int cnt=0;
        bool flag=false;
        for(int j=0;j<t.size();j++){
            if((i+j)>=s.size()){
                flag=true;
                break;
            }
            if(s[i+j]!=t[j]){
                cnt++;
            }
        }
        if(flag) continue;
        ans=min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import kotlin.math.absoluteValue
import kotlin.math.min

fun main() {
    val ln = nextLongList()
    val ans = solve(ln)
    println(ans)
}


fun solve(ln: List<Long>): Long {
    val currentPoint = ln[0]
    val moveCount = ln[1]
    val moveAmount = ln[2]


    //移動する必要がある
    if (currentPoint.absoluteValue > moveAmount) {
        //実際に移動する回数
        //moveAmountを超える回数まで移動したあとは偶数か奇数かで移動回数が決まる。0回か1回
        //moveAmountを超える回数までの移動回数は？　→　初期値を
        val actualMoveCount =
            if (currentPoint.absoluteValue / moveAmount > moveCount)
                moveCount
            else
                currentPoint.absoluteValue / moveAmount

        val tempPoint = calculateMinPoint(
            point = currentPoint,
            moveCount = actualMoveCount,
            moveAmount = moveAmount
            )
//        val tempPoint = min(
//            (currentPoint - moveAmount * actualMoveCount).absoluteValue,
//            (currentPoint + moveAmount * actualMoveCount).absoluteValue
//        )

        return calculateMinPoint(
            point = tempPoint,
            moveCount = (moveCount - actualMoveCount) % 2,
            moveAmount = moveAmount
        )
//        return min(
//            (tempPoint - (moveCount - actualMoveCount) % 2 * moveAmount).absoluteValue,
//            (tempPoint + (moveCount - actualMoveCount) % 2 * moveAmount).absoluteValue
//        )

    } else {
        //移動回数が偶数である場合
        if (moveCount % 2 == 0L) {
            return currentPoint.absoluteValue
            //移動回数が奇数である場合
        } else {
            val oddMoveCount = 1L
            return calculateMinPoint(
                point = currentPoint,
                moveCount = oddMoveCount,
                moveAmount = moveAmount
            )
//            return min((currentPoint - moveAmount).absoluteValue, (currentPoint + moveAmount).absoluteValue)
        }
    }
}

private fun calculateMinPoint(point: Long, moveCount: Long, moveAmount: Long): Long {
    return min(
        (point - moveAmount * moveCount).absoluteValue,
        (point + moveAmount * moveCount).absoluteValue
    )
}

fun nextInt(): Int {
    return readLine()!!.toInt()
}

fun nextIntList(): List<Int> {
    return readLine()!!.split(" ").map { it.toInt() }
}

fun nextLongList(): List<Long> {
    return readLine()!!.split(" ").map { it.toLong() }
}

fun nextString(): String {
    return readLine()!!
}

Measured memory_bytes: 36408
s = input()
n1 = int(s[:2])
n2 = int(s[2:])
if 1 <= n1 <= 12 and 1 <= n2 <= 12:
    print("AMBIGUOUS")
elif (n1 > 12 or n1 == 0) and 1 <= n2 <= 12:
    print("YYMM")
elif 1 <= n1 <= 12 and (n2 > 12 or n2 == 0):
    print("MMYY")
else:
    print("NA")


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

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

	int ans = 1;
	int x = 7 % K;
	set<int> mod;
	while (mod.count(x) == 0) {
		mod.insert(x);
		if (x == 0) {
			cout << ans << endl;
			return 0;
		}
		else {
			x = (10 * x + 7) % K;
			ans++;
		}
	}
	cout << -1 << endl;
	return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::multiset<int64_t> l, r;

  for (int64_t i = 0; i < n; i++) {
    int64_t li, ri;
    std::cin >> li >> ri;

    r.insert(ri);
    l.insert(li);
  }

  int64_t ans = 0;

  int64_t cur1 = 0;
  int64_t cur2 = 0;
  auto itr1 = l.crbegin();
  auto itr2 = r.cbegin();
  for (; itr1 != l.crend() && itr2 != r.cend(); itr1++, itr2++) {
    cur1 += 2 * (*itr1);
    ans = std::max(ans, cur1);
    cur1 += -2 * (*itr2);
    ans = std::max(ans, cur1);

    cur2 += -2 * (*itr2);
    ans = std::max(ans, cur2);
    cur2 += 2 * (*itr1);
    ans = std::max(ans, cur2);
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 9600
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;


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

	cin >> N >> K;
	long long int ans = 0;
	for (long long int i = K; i <= N + 1; i++) {
		L = i * (i - 1) / 2;
		R = N * i - L;
		ans += R - L+1;
	}
	cout << ans % MOD << endl;
}


Measured memory_bytes: 3640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N, M; cin >> N >> M;

    Int res = 1;
    res <<= M;
    res *= 1900*M + 100*(N-M);
    
    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int sign(double x);

int main(void)
{
    double x1, y1, x2, y2, x3, y3;
    double xp, yp;

    double vec12_x_vec1p, vec23_x_vec2p, vec31_x_vec3p;
    int judge;

    while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
                &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF) {
        vec12_x_vec1p = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1);
        vec23_x_vec2p = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2);
        vec31_x_vec3p = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3);
        judge = sign(vec12_x_vec1p) + sign(vec23_x_vec2p) + sign(vec31_x_vec3p);

        if (judge == 1 + 1 + 1 || judge == -1 - 1 - 1) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}

int sign(double x)
{
    if (x >= 0) {
        return 1;
    } else {
        return -1;
    }
}

Measured memory_bytes: 612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int f(int a){
  int count = 0;
  int flag = 0;
  for(int i = 1; i <= pow(a,0.5); ++i){
    if(a % i == 0) count ++;
    if(i*i == a)flag = 1;
  }
  count *= 2;
  if(flag == 1) --count;
  return count;
}


int main(){

  int s;
  scanf("%d",&s);

  int h,m,sec;
  h = s / 3600; s %= 3600;
  m = s/60; s %= 60;
  sec = s;

  printf("%d:%d:%d\n",h, m, sec);

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll n,m,l;
ll dp[310][310];

void input() {
    cin >> n >> m >> l;
    REP(i,n) REP(j,n) {
        dp[i][j] = INF;
        if (i == j) dp[i][j] = 0;
    }
    REP(i,m) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        dp[a][b] = c;
        dp[b][a] = c;
    }
}

void solve() {
    REP(k,n) REP(j,n) REP(i,n) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    }
    REP(i,n) REP(j,n) {
        dp[i][j] = (dp[i][j] <= l ? 1: inf);
        if (i == j) dp[i][j] = 0;
    }
    REP(k,n) REP(i,n) REP(j,n) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    }
    int q;
    cin >> q;
    while (q--) {
        int s,t;
        cin >> s >> t;
        s--;t--;
        cout << (dp[s][t] == inf ? -1: dp[s][t] - 1) << endl;
    }
}

int main(int argc, char *argv[]){
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  cout<<a[n-1]-a[0]<<endl;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cstring>
using namespace std;
struct pasang{
    int l , r , idx;
    bool operator < (const pasang &a)const{
        return r < a.r;
    }
};
int main(){
    //point update range query
    int N , Q;
    scanf("%d%d" , &N , &Q);
    int arr[N + 1] , ans[Q] , bit[N + 1] = {0} , last[N + 1];
    memset(last , -1 , sizeof(last));

    for (int i = 1 ; i <= N ; i++)
        scanf("%d" , &arr[i]);

    pasang query[Q];
    for (int i = 0 , l , r ; i < Q ; i++){
        scanf("%d%d" , &l , &r);
        query[i] = {l , r , i};
    }
    sort(query , query + Q);
    int ptr = 1;
    for (int i = 0 ; i < Q ; i++){
        //printf("query[%d] : %d %d\n" , i , query[i].l , query[i].r);
        while(ptr <= query[i].r){
            for (int j = ptr ; j <= N ; j += j & -j)
                bit[j]++;
            if (last[arr[ptr]] != -1)
                for (int j = last[arr[ptr]] ; j <= N ; j += j & -j)
                    bit[j]--;
            last[arr[ptr]] = ptr;
            ++ptr;
        }
        int tambah = 0;
        for (int j = query[i].l - 1 ; j ; j -= j & -j)
            tambah -= bit[j];
        for (int j = query[i].r ; j ; j -= j & -j)
            tambah += bit[j];
        ans[query[i].idx] = tambah;
    }
    for (int i = 0 ; i < Q ; i++)
        printf("%d\n" , ans[i]);
}


Measured memory_bytes: 17292
#include<bits/stdc++.h>
#define INF (1e15)
#define int long long
using namespace std;

int n, dp[100005][3];
char C[100005];
int A[100005];

void solve(){
  
  for(int i=0;i<=n;i++)
    for(int j=0;j<3;j++) dp[i][j]=-INF;
  
  dp[1][0]=A[0];
  
  for(int i=1;i<n;i++){
    
    for(int j=0;j<3;j++){
      
      if(dp[i][j]==-INF) continue;
      
      char c=C[i];
      int num=A[i];  
      
      if(c=='+'){
	
	if(j==0) dp[i+1][0]=max(dp[i+1][0], dp[i][j]+num);
	
	if(j==1){
	  dp[i+1][0]=max(dp[i+1][0], dp[i][j]+num);
	  dp[i+1][1]=max(dp[i+1][1], dp[i][j]-num);
	}
	if(j==2){
	  dp[i+1][1]=max(dp[i+1][1], dp[i][j]-num);
	  dp[i+1][2]=max(dp[i+1][2], dp[i][j]+num);
	}
	    
      } else{
	
	if(j==0){
	  dp[i+1][0]=max(dp[i+1][0], dp[i][j]-num);
	  dp[i+1][1]=max(dp[i+1][1], dp[i][j]-num);
	}
	if(j==1){
	  dp[i+1][0]=max(dp[i+1][0], dp[i][j]-num);
	  dp[i+1][1]=max(dp[i+1][1], dp[i][j]+num);
	  dp[i+1][2]=max(dp[i+1][2], dp[i][j]+num);
	}
	if(j==2){
	  dp[i+1][1]=max(dp[i+1][1], dp[i][j]-num);
	  dp[i+1][2]=max(dp[i+1][2], dp[i][j]+num);
	}
		
      }
      
    }
  }
  
  int ans=-INF;
  
  for(int i=0;i<3;i++) ans=max(ans, dp[n][i]);
  
  cout<<ans<<endl;
}

signed main(){
  
  cin>>n;
  
  cin>>A[0];
  
  for(int i=1;i<n;i++) cin>>C[i]>>A[i];
  
  solve();
  
  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
void solve(){
    ll a,b,n;
    cin>>a>>b>>n;
  ///  int g=gcd(a,b);
    //cout<<g<<"   "<<(a*b)/g<<endl<<endl;
   /*
    for(int x=0;x<100;x++){

    ll r=(a*x)/b-a*(x/b);
    cout<<r<<endl;
    }*/
    ll x=min(b,n);
    if(x==b) x--;
    ll r=(a*x)/b-a*(x/b);
    cout<<r<<'\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
 //   cin>>tc;
    tc=1;
    while(tc--){
        solve();
    }
return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int ans = n;
  for(int i = 1; i < n; i++){
    if(s.at(i) == s.at(i - 1)) ans--;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 512
/*
Original problem: 
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
    void main() {
        int n, d = 0, temp;
		cin >> n;
		
		REP(i,0,n) {
			cin >> temp;
			if (temp != i+1) {
				d++;
			}
		}
		if (d == 0 || d == 2) cout << "YES" << endl;
		else cout << "NO" << endl;
		
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int a = s.size();
    int b = a/ 2;

    int ans = 0;
    for(int i = 0; i< b; i++){
        if(s[i] != s[a - i-1]){
            ans++;
        }
    }
    cout << ans << endl;
}


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

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

int block[101];

void solve() {
	int n; cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>block[i];
	}

	int bh = block[0];
	int mcu = 0, mcd = 0;
	for (int i = 1; i < n; i++) {
		//cout<<bh<<"|"<<block[i]<<endl;
		if (bh < block[i]) {
			mcu = max(mcu, block[i] - bh);
		} else {
			mcd = max(mcd, bh - block[i]);
		}
		bh = block[i];
	}
	cout<<mcu<<" "<<mcd<<endl;
	
}

int main(int argc, const char *argv[]) {
	int n; cin>>n;
	rep(n) solve();
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if (n == 1) {
    int ans = 0;
    if (a == b) {
      ans = 1;
    }
    printf("%d\n", ans);
    return 0;
  }
  ll ansmin = a * (n-1) + b;
  ll ansmax = a + b * (n-1);
  printf("%lld\n", max(0LL, ansmax - ansmin + 1));

  return 0;
}


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

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

	int N; cin >> N;
	int s[11000];
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	int Q; cin >> Q;
	int t[510];
	for (int i = 0; i < Q; i++) {
		cin >> t[i];
	}
	int cnt = 0;
	for (int i = 0; i < Q; i++) {
		for (int j = 0; j < N; j++) {
			if (t[i] == s[j]) {
				cnt++;
				break;
			}
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int a,b,c,k; cin >> a >> b >> c >> k;
    int x = max({a,b,c});
    int ans = (a+b+c)-x;

    for ( int i = 1 ; i <= k ; i++ ){
        x *= 2;
    }
    ans +=x;
    cout << ans << endl;
}

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

int main()
{
    int i,j,s;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    return 0;
}



Measured memory_bytes: 2592
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n>>m;
    ll w[n],val[n];
    for(i=0;i<n;i++)cin>>w[i]>>val[i];
    ll dp[m+1];
    mms(dp,0);
    for(i=1;i<=n;i++)
    {
        for(j=m;j>=w[i-1];j--)
        {
            dp[j]=max(dp[j],dp[j-w[i-1]]+val[i-1]);
        }
    }
    cout<<dp[m];
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int n; while(cin>>n,n){
		int d[99]={0},c=0;
		while(n>0){
			d[c++]=n%8;
			n/=8;
		}
		while(c--)cout<<"01235789"[d[c]];cout<<endl;
	}
	return 0;
}

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

int main(){
    ll x;
    cin >> x;

    ll gaku = 100;
    int ans = 0;
    while(gaku < x){
        gaku = gaku * 1.01;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int l,r,d;
  cin >> l >> r >> d;
  cout << r/d-(l-1)/d << endl;
  return 0;
}


Measured memory_bytes: 3648
n=int(input())
ans=1
zero=False
minus=False
li = input().split()
for i in li:
  a=int(i)
  if a==0:
    zero=True
    break
  if minus:
    continue
  ans*=a
  if ans>1000000000000000000:
    minus=True

if minus:
  ans=-1
if zero:
  ans=0
print(ans)


Measured memory_bytes: 19388
using System;
class Program{
	static void Main(){
		int s=int.Parse(Console.ReadLine());
		int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		
		double a=100000000000000;

		int c2=2,c1=1,c3=3;

		double n1=q[0],n2=0,n3=q[2]+q[1],n4=0;

		for (int i=3;i<s;i++){n4+=q[i];}

		for (;c2<s-1;c2++){
			n2+=q[c2-1];
			n3-=q[c2-1];

			while(c1<c2&&Math.Abs(n1-n2)>=Math.Abs((n1+q[c1])-(n2-q[c1]))){n1+=q[c1];n2-=q[c1];c1++;}
			while(c3<s&&Math.Abs(n3-n4)>=Math.Abs((n3+q[c3])-(n4-q[c3]))){n3+=q[c3];n4-=q[c3];c3++;}

			double[] arr={n1,n2,n3,n4};
			Array.Sort(arr);

			a=Math.Min(a,arr[3]-arr[0]);
        }
		Console.WriteLine(a);
	}
}

Measured memory_bytes: 32476