akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b && a < c){
    cout << a << ' ';
    if (b < c){
      cout << b << ' ' << c << endl;
    } else {
      cout << c << ' ' << b << endl;
    }
  } else if (b < a && b < c){
    cout << b << ' ';
    if (a < c){
      cout << a << ' ' << c << endl;
    } else {
      cout << c << ' ' << a << endl;
    }
  } else {
    cout << c << ' ';
    if (a < b){
      cout << a << ' ' << b << endl;
    } else {
      cout << b << ' ' << a << endl;
    }
  }
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

string S;

int main() {
  cin >> S;
  if (S == "RRR") {
    cout << 3 << endl;
  } else if (S == "RRS" || S == "SRR") {
    cout << 2 << endl;
  } else if (S == "SSS") {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>
#include <queue>

using namespace std;

int main(){
    while(true){
        int x, y, s;
        cin >> x >> y >> s;
        if(x == 0 && y == 0 && s == 0) break;

        int ans = 0;
        for(int i = 1; i < s; ++i){
            for(int j = i; j < s; ++j){
                if(i * (100 + x) / 100 + j * (100 + x) / 100 == s){
                    ans = max(ans, i * (100 + y) / 100 + j * (100 + y) / 100);
                }
            }
        }
        cout << ans << endl;
    }
}


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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for ( int i = 0; i < N; i++ ) cin >> A.at(i);
    for ( int i = 0; i < N; i++ ) cin >> B.at(i);
    for ( int i = 0; i < N; i++ ) cin >> C.at(i);

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;
    for ( int i = 0; i < N; i++ ) {
        int a = distance(A.begin(), lower_bound(A.begin(), A.end(), B.at(i)));
        int c = distance(upper_bound(C.begin(), C.end(), B.at(i)), C.end());
        ans += (long long)a * c;
    }

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


Measured memory_bytes: 4508
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  string s;
  cin>>s;
  int len=s.size();
  int ans=0;
  int shift=s.size()-2;
  for(int i=0;i<(1<<(len-1));i++){
    int index=0;
    for(int j=shift;j>=-1;j--){
      string t="";
      t+=s[index++];
      while(1){
        if(j==-1)break;
        if(!(i&(1<<j))){
          t+=s[index++];
          j--;
        }else{
          break;
        }
      }
      int tmp=stoll(t);
      //cout<<tmp<<' ';
      ans+=tmp;
    }//cout<<endl;
  }
  cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
from collections import deque
from itertools import product

def bfs(s,x, y):
    
    INF=400
    DX = [1, 0, -1, 0]
    DY = [0, 1, 0, -1]
    
    que = deque()
    res = 0
    dist = [[INF for _ in range(W)] for _ in range(H)]
 
    que.append((x, y))
    dist[x][y] = 0
    while que:
        x, y = que.pop()
        res = max(res, dist[x][y])
 
        for i in range(4):
            dx, dy = x + DX[i], y + DY[i]
 
            if dx < 0 or dx >= H or dy < 0 or dy >= W:
                continue
            if s[dx][dy] == "#":
                continue
 
            if dist[dx][dy] == INF:
                dist[dx][dy] = dist[x][y] + 1
                que.appendleft((dx, dy))
    return res

H,W = map(int, input().split())

S = [list(input()) for _ in range(H)]

ans = 0
for x, y in product(range(H), range(W)):
  if S[x][y] == "#":
    continue
  ans = max(ans, bfs(S,x, y))
print(ans)


Measured memory_bytes: 3316
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<string>
using namespace std;
int main()
{
	int a[5];
	for(int i=0;i<5;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<5;i++)
	{
		if(a[i]==0)
		{
			cout<<i+1;break;
		}
	}
}

Measured memory_bytes: 3560
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int A[] = new int[100];
		int choco = 0;
		for(int i = 0;i < N;i++){
			A[i] = sc.nextInt();
			for(int j = 1;j<=D;j=j+A[i]){
				choco++;
			}
		}
		System.out.println(X+choco);
	}

}

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

bool hantei(long x){
	
	int i=2;
	while(1){
		if (x==1) return 0;
		if (i==x) return 1;
		if (x % i == 0) return 0;
		else {
			if(x < i*i) return 1;
			else i++;
		}
	}
}

int main() {
	
	int x;
	cin >> x;
	while(1){
		if (hantei(x) ) {
			cout << x << endl;
			break;
		}
		else x++;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main() {
	vector<ll> A(3);
    cin >> A[0] >> A[1] >> A[2];

	ll ans = numeric_limits<ll>::max();
	for(int i=0; i<3; i++) {
		for(int j=0; j<3; j++) {
			for(int k=0; k<3; k++) {
				if(i==j || j==k || k==i) continue;
				ans = min(ans, abs(A[i]-A[j])+abs(A[j]-A[k]));
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
xyz = [[int(i) for i in input().split()] for j in range(n)]

ans = 0

num = 2**3

for i in range(num):
    tmp = format(i,'0'+str(3)+'b')
    li = []
    for j in range(n):
        kari = 0
        for k in range(3):
            kari += xyz[j][k]*(-1)**int(tmp[k])
        li.append(kari)
    li.sort(reverse=True)
    temp = 0
    for l in range(m):
        temp += li[l]
    ans = max(ans,temp)
    
print(ans)

Measured memory_bytes: 43888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
	int N = 0, W = 0, E = 0, S = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		if (s[i] == 'N')
			N++;
		else if (s[i] == 'W')
			W++;
		else if (s[i] == 'E')
			E++;
		else
			S++;

	if (N > 0 && S > 0) {
		if (W == E)
			cout << "Yes" << endl;
		else if (W > 0 && E > 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else if (N == S) {
		if (W == E)
			cout << "Yes" << endl;
		else if (W > 0 && E > 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

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

int main()
{
	int h,w;
	cin >> h >> w;
	char s[100][100];
	int z =0;
	for(int i = 1 ; i <= h ; i++)
	{
		for(int j = 1 ; j <= w ; j++)
		{
			cin >> s[i][j];
		}
	}
	for(int i = 1 ; i <= h ; i++)
	{
		for(int j = 1 ; j <= w ; j++)
		{
			if(s[i][j] == '#' && s[i][j+1] != '#' && s[i][j-1] != '#' && s[i+1][j] != '#' && s[i-1][j] != '#')z++;
		}
	}
	if(z == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
//Author :: Soumyajit Dey (TheCodejit)
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define magic ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std; 

int main(){
	int s,w;
  	cin >> s >> w;
  	if(w>=s){cout << "unsafe";}
  	else{cout << "safe";}
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> arr;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		arr.push_back(a);
	}
	int dp[n];
	memset(dp,0,sizeof(dp));
	for(int i = 1; i<arr.size();i++)
	{
		dp[i] = dp[i-1] + abs(arr[i]-arr[i-1]);
		if(i > 1)
		dp[i] = min(dp[i-2] + abs(arr[i] - arr[i-2]), dp[i]);
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int INF = 1001001001;


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

int n;
cin >> n;

vector<int> a(n),b(n),c(n-1);
rep(i,n) cin >> a[i];
rep(i,n) cin >> b[i];
rep(i,n-1) cin >> c[i];

int sum = 0,now = INF;

rep(i,n){
    a[i]--;
    if(a[i]-now == 1) sum += c[now];
    now = a[i];
    sum += b[now];
}

cout << sum << endl;

return 0;
}

Measured memory_bytes: 256
def inpl():
    return list(map(int, input().split()))


def isAllOn(pattern):
    for i, s in enumerate(S):
        on = 0
        for k in s[1:]:
            if (pattern >> (k - 1)) % 2 == 1:
                on += 1
        # print(pattern, i, on)
        if on % 2 != P[i]:
            return False
    return True


N, M = inpl()

S = [inpl() for i in range(M)]
P = inpl()

ans = 0
for pattern in range(2**N):
    if isAllOn(pattern) is True:
        ans += 1

print(ans)


Measured memory_bytes: 3064
/*
g++ -std=c++11 -o2 -Wall ABC083C.cpp -o ./out/ABC083C.out
./out/ABC083C.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int ans = 1;
  ll x, y;
  cin >> x >> y;
  ll temp = x;
  while (2 * temp <= y) {
    temp *= 2;
    ++ans;
  }
  cout << ans << "\n";
}


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

int main(){
    string a,b,c;
    cin>>a>>b>>c;
  char A=(a[0]-0x20),B=(b[0]-0x20),C=(c[0]-0x20);
    cout<<A<<B<<C<<endl;
    
    }


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  cout << (char) (c + 1) << '\n';
  return 0;
}


Measured memory_bytes: 256
n,m,c= [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
a = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    s = 0
    for j in range(m):
        if j != m:
            s += a[i][j]*b[j]
    if s+c > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

        int n;

        cin >> n;

        int sum = 0, aux = n;

        while(n > 0) {
                sum += n%10;
                n = n/10;
        }

        if(aux%sum == 0) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = s; i < (n); i++)
using namespace std;

typedef long long ll;

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  ll r = 0;
  ll g = 0;
  ll b = 0;
  ll minus = 0;
  
  ll sum = 0;
  rep(i, n){
    if(s[i] == 'R') r++;
    else if(s[i] == 'G') g++;
    else if(s[i] == 'B') b++;
  }
  rep(i, n-2)rep2(j, i+1, n-1){
    if (j-i > (n-i-1)/2) break;
    if (s[i] != s[j] && s[i] != s[2*j-i] && s[j] != s[2*j-i])
      minus++;
  }
  sum = r * g * b - minus;
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N, A, B;

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

  cin >> N >> A >> B;

  int dist = abs(A-B);

  if (dist%2 == 0) {
      cout << "Alice" << endl;
  } else {
      cout << "Borys" << endl;
  }

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
typedef long long ll;
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
int n;
void work(int dif,int A,int x){
	if(__builtin_popcount(x)==1){
		printf("%d %d ",A,A^dif);
		return;
	}
	REP(i,0,n-1) if((dif&(1<<i))>0 && (x&(1<<i))>0)
		REP(j,0,n-1) if((x&(1<<j))>0 && i!=j){
			work(1<<j,A,x^(1<<i));
			work(dif^(1<<i)^(1<<j),A^(1<<i)^(1<<j),x^(1<<i));
			return;
		}
}
int main(){
	n=read();
	int A=read(),B=read();
	if(__builtin_popcount(A^B)%2!=1) return printf("NO\n"),0;
	printf("YES\n");
	work(A^B,A,(1<<n)-1);
	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 21:23:54 2020

@author: over-
"""
def check(N):
    c=0
    for i in range(1,N+1):
        if str(i)[-1] !=0:
            for j in range(1,N+1):
                if str(i)[0]==str(j)[-1] and str(i)[-1]==str(j)[0]: c+=1
                  
    return c

N=input()
L=len(N)

c=0
for i in range(1,int(N)+1):
    x=int(str(i)[0])
    y=int(str(i)[-1])

    
    if y!=0:
        d=0
        if x==y: 
            d+=1
        if L==2:
            if int(N)>=int('{}{}'.format(y,x)):
                d+=1
        if L==3:
            d+=1
            if int(N)>=int('{}9{}'.format(y,x)):
                d+=10
            elif int(N)>=int('{}0{}'.format(y,x)):
                d+=int(N[1:-1])
                if int(N)>=int('{}{}{}'.format(y,N[1:-1],x)):
                    d+=1
        if L==4:
            d+=1+10
            if int(N)>=int('{}99{}'.format(y,x)):
                d+=100
            elif int(N)>int('{}00{}'.format(y,x)):
                d+=int(N[1:-1])
                if int(N)>=int('{}{}{}'.format(y,N[1:-1],x)):
                    d+=1
        if L==5:
            d+=1+10+100
            if int(N)>=int('{}999{}'.format(y,x)):
                d+=1000
            elif int(N)>=int('{}000{}'.format(y,x)):
                d+=int(N[1:-1])
                if int(N)>=int('{}{}{}'.format(y,N[1:-1],x)):
                    d+=1
        if L==6:
            d+=1+10+100+1000
            if int(N)>=int('{}9999{}'.format(y,x)):
                d+=10000
            elif int(N)>=int('{}0000{}'.format(y,x)):
                d+=int(N[1:-1])
                if int(N)>=int('{}{}{}'.format(y,N[1:-1],x)):
                    d+=1
        
        c+=d
        #print(i,d)

print(c)
#print(check(int(N)))
    


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n;cin>>n;

	int ans =0;
	for(int i=1; i<=n; i++){
		if(i% 2 ==0)continue;
		int ct=0;
		for(int j=1; j<=i; j++){

			if(i % j==0)ct++;
		}
		if(ct ==8) ans++;
	}

	writeln(ans);
}




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

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

    static class LDeque {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int[] a = in.nextIntArray(N);
            long[][] opt = new long[N][N];  //optimal value of X-Y  X-->first Y-->second
            for (int i = 0; i < N; i++) {
                opt[i][i] = a[i];
            }
            for (int i = N - 1; i >= 0; i--) {
                for (int j = i + 1; j < N; j++) {
                    opt[i][j] = Math.max(-opt[i + 1][j] + a[i], -opt[i][j - 1] + a[j]);
                }
            }
            out.print(opt[0][N - 1]);

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

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

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

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

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] nextIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
                array[i] = nextInt();
            return array;
        }

    }
}



Measured memory_bytes: 129620
//Assalamualaikum//
//Mahmudul Ahsan Mahi
//RUET CSE 19'


#include<iostream>
#include<cstdio>
#include <bits/stdc++.h>
#include<cstring>
#include<vector>
#include<list>
#include<stack>
#include<iterator>
#include<algorithm>
#include<cstdlib>

#define ll long long
#define ull unsigned long long
#define pi acos(-1)

using namespace std;

int main()
{
    stack<int>st[1001];

    int i, n, q, o, t, x;

    cin>>n>>q;

    while(q--){
        cin>>o;

        if(o==0){
            cin>>t>>x;
            st[t].push(x);
        }

        else if(o==1){
            cin>>t;
            if(st[t].empty())
                ;
            else{
                cout<<st[t].top()<<endl;
            }
        }

        else if(o==2){
            cin>>t;
            if(st[t].empty())
                ;
             else{
                st[t].pop();
             }


        }
    }


    return 0;
}




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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int main(){
    int i;
    string str;
    cin >> str;
    
    int g,p;
    g=p=0;
    for (i=0;i<str.size();i++){
        if (str[i]=='g'){
            g++;
        }else if (str[i]=='p'){
            p++;
        }else{
            abort();
        }
    }
    
    cout << (g-p)/2 << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#define PUT(c) cout << c;
#define NL PUT(endl);
#define PUTS(c,e) for (i=0; i<e; i++) { PUT(c) }
using namespace std;
 
int main() {
    int h,w,i,j;
    while (true) {
        cin >> h >> w;
        if (0 == (h | w)) {
            break;
        }
        PUTS('#', w)
        NL
        for (j=2; j<h; j++) {
            PUT('#')
            PUTS('.', w-2)
            PUT('#')
            NL
        }
        PUTS('#', w)
        NL
        NL
    }
    return 0;
}

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


Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
const int MAXK=12;
bool use[MAXK];
char s[MAXK];
int pow10[MAXK];

int main()
{
	int N,K;
	scanf("%d%d",&N,&K);
	for(int i=1,x;i<=K;i++)
	{
		scanf("%d",&x);
		use[x]=true;
	}
	pow10[0]=1;
	for(int i=1;i<MAXK;i++)
		pow10[i]=pow10[i-1]*10;
	for(;;)
	{
		sprintf(s,"%d",N);
		int len=strlen(s);
		bool flag=true;
		for(int i=0;s[i];i++)
			if(use[s[i]-'0'])
			{
				N+=pow10[len-i-1];
				N-=N%pow10[len-i-1];
				flag=false;
				break;
			}
		if(flag)
			break;
	}
	printf("%d\n",N);
	
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == s[i + 1])
            s[i] = '*';
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] != '*')
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int y[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int x[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
int main()
{
	int h, w;
	char s[51][51];
	cin >> h >> w;
	REP(i, 0, h) REP(j, 0, w) cin >> s[i][j];

	REP(i, 0, h) {
		REP(j, 0, w) {
			if (s[i][j] == '.') {
				int cnt = 0;
				REP(k, 0, 8) {
					int yy = i + y[k];
					int xx = j + x[k];
					
					if (yy < 0 || yy >= h || xx < 0 || xx >= w) continue;
					
					if (s[yy][xx] == '#') cnt++;
				}

				s[i][j] = '0' + cnt;
			}
		}
	}

	REP(i, 0, h) {
		REP(j, 0, w) {
			cout << s[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
    int N,t,t1 = 0,t2,x1 = 0,y1 = 0,x2,y2,x,y,xn = 0,yn = 0,min,minN;
    int flag = 0,ng = 0;
    cin >> N;
    int a[4][2],b[4];

    for(int i = 0;i<N;i++){
        xn = 0;
        yn = 0;
        cin >> t2 >> x2 >> y2;
        t = t2 - t1;
        x = x2 - x1;
        y = y2 - y1;
        t1 = t2;
        x1 = x2;
        y1 = y2;
        for(int j = 1;j <= t;j++){
            a[0][0] = xn;
            a[0][1] = yn + 1;
            a[1][0] = xn;
            a[1][1] = yn - 1;
            a[2][0] = xn + 1;
            a[2][1] = yn;
            a[3][0] = xn - 1;
            a[3][1] = yn;
            if(x > a[0][0]){
                if(y > a[0][1])min = x - a[0][0] + y - a[0][1];
                else min = x - a[0][0] + a[0][1] - y;
            }else{
                if(y > a[0][1])min = a[0][0] - x + y - a[0][1];
                else min = a[0][0] - x + a[0][1] - y;
                }
            minN = 0;
            for(int k = 0;k<4;k++){
                if(x > a[k][0]){
                    if(y > a[k][1])b[k] = x - a[k][0] + y - a[k][1];
                    else b[k] = x - a[k][0] + a[k][1] - y;
                }else{
                    if(y > a[k][1])b[k] = a[k][0] - x + y - a[k][1];
                    else b[k] = a[k][0] - x + a[k][1] - y;
                }
                if(b[k] == 0 && (t - j) % 2 == 0)flag = 1;
                if(b[k] < min){
                    min = b[k];
                    minN = k;
                }
            }
            xn = a[minN][0];
            yn = a[minN][1];
            if(flag == 1)break;
        }
        if(flag == 1)flag = 0;
        else ng = 1;
    }
    if(ng == 1)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace debug
{
    public static partial class Program
    {
        public static void Main()
        {
            var n = Console.ReadLine().ToLong();
            var str = new List<string>();
            for (var i = 0; i < n; i++)
            {
                str.Add(Console.ReadLine());
            }
            
            var memo = new Dictionary<string, int>();
            for (var i = 0; i < n; i++)
            {
                var s = str[i].OrderBy(x => x).Join();
                if (memo.ContainsKey(s))
                {
                    memo[s]++;
                }
                else
                {
                    memo.Add(s, 1);
                }
            }

            Console.WriteLine(memo.Sum(x => F(x.Value)));
        }

        public static long F(long n) => n == 0 ? 0 : n - 1 + F(n - 1);
    }

    public static partial class Program
    {
        //テンプレここから
        private static long Gcd(long aaa, long bbb) => bbb == 0 ? aaa : Gcd(bbb, aaa % bbb);
        private static long Lcm(long aaa, long bbb) => aaa * bbb / Gcd(aaa, bbb);
        private static long ToLong(this double ddd) => (long) ddd;
        private static long ToLong(this string str) => long.Parse(str);
        private static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
        private static long[] ToLongArray(this string str, char opr = ' ') => str.Split(opr).ToLong();
        private static long Diff(long aaa, long bbb) => Math.Abs(Math.Max(aaa, bbb) - Math.Min(aaa, bbb));
        private static long Sign(this long iii) => Math.Sign(iii);
        private static bool IsEven(this long iii) => iii % 2 == 0;
        private static bool IsEven(this int iii) => iii % 2 == 0;

        private static readonly int[] _Dx =
        {
            0, -1, 0, 1
        };

        private static readonly int[] _Dy =
        {
            -1, 0, 1, 0
        };

        public const int MOD = 1000000007;
        public const string UPPER_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const string LOWER_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
        private static long ToLong(this char ccc) => ccc.ToString().ToLong();
        private static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
        private static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

        private static string JoinToStr(this IEnumerable<long> array, string sep = "") =>
            array.Select(xxx => xxx.ToString()).Join(sep);

        public static string JoinToStr(this IEnumerable<int> array, string sep = "") =>
            array.Select(xxx => xxx.ToString()).Join(sep);

        //テンプレここまで
    }
}


Measured memory_bytes: 32036
use proconio::*;
use std::cmp::max;
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    let mut score = 0;
    let mut lasts = [-1; 26];
    let mut t = vec![26; d];
    let depth = 40;
    for i in 0..d {
        let mut max_score = -10000000;
        for j in 0..26 {
            let tmp = search(i, j, &c, &s, &mut lasts, depth, d, 0, 4);
            if tmp > max_score {
                max_score = tmp;
                t[i] = j;
            }
        }
        score += max_score;
        lasts[t[i]] = i as i64;
    }

    for &a in &t {
        println!("{}", a + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}

fn search(
    i: usize,
    t: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    lasts: &mut [i64; 26],
    depth: usize,
    d: usize,
    cscore: i64,
    l: usize,
) -> i64 {
    if depth == 0 || i == d - 1 {
        return calc_score(i, t, &c, &s, lasts) + cscore;
    }

    let l = max(1, l - 1);
    let mut max_score = -1000000;
    let tmp_last = lasts[t];
    lasts[t] = i as i64;
    let tmp_score = calc_score(i, t, &c, &s, lasts);
    let mut cands = BinaryHeap::new();
    for j in 0..26 {
        let tmp_score = calc_score(i + 1, j, &c, &s, lasts);
        cands.push((tmp_score, j));
    }
    for &(_, j) in cands.iter().take(l) {
        let tmp = search(i + 1, j, &c, &s, lasts, depth - 1, d, cscore + tmp_score, l);

        if tmp > max_score {
            max_score = tmp;
        }
    }

    lasts[t] = tmp_last;
    max_score + cscore
}


Measured memory_bytes: 2340
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define CASET           \
    int ___T;           \
    scanf("%d", &___T); \
    for (int __CS = 1; __CS <= ___T; __CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
LL bin(LL x, LL n, LL MOD)
{
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1)
            ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const int maxn = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9 + 7;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    set<int> st;
    int ans = 0;
    int a[110] = {0};
    for (int i = 0; i < n; i++)
    {
        st.insert(s[i] - 'a');
        int tmp = 0;
        memset(a, 0, sizeof a);
        for (int j = i + 1; j < n; j++)
        {
            if (st.count(s[j] - 'a') && a[s[j] - 'a'] == 0)
                tmp++, a[s[j] - 'a'] = 1;
        }
        ans = max(ans, tmp);
        //cout << " i === " << i << "    tmp ==== " << tmp  << endl;
    }
    cout << ans << endl;
}

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

int main(){
  
  int h, w;
  cin >> h >> w;
  rep(i, w+2) cout << '#';
  cout << endl;

  rep(i, h){
    string a;
    cin >> a;
    string s = "#" + a + "#";
    cout << s << endl;
  }

  rep(i, w+2) cout << '#';
  cout << endl;

}


Measured memory_bytes: 256
import java.util.*;

 class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        int MAX = 0;
        int MAX2 = 0;
        
        for(int i = 0; i<N; i++) {
        	A[i] = sc.nextInt();
        }
        	
        for(int i = 0; i<N; i++) {
        	if(A[i]>=MAX) {
        		MAX2 = MAX;
        		MAX = A[i];
        	} else if(A[i]>MAX2) {
        		MAX2 = A[i];
        	}
        }

      	for(int i = 0; i<N; i++) {
       		if(A[i]==MAX) {
       			System.out.println(MAX2);
        	} else {
        		System.out.println(MAX);
        	}
        	
        }
        
    }
}

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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using Graph = vector<VE>;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, a, b; cin >> n >> a >> b;
	cout << min(a*n, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int a, b, area, length;

        scanf("%d %d",&a, &b);
        area = a*b;
        length = (a*2)+(b*2);

        if(a>=1&&b<=100){
        printf("%d %d\n",area, length);
        }

        return 0;
}

Measured memory_bytes: 1024
from collections import deque
H,W=map(int, input().split())

S=[]
for i in range(H):
    s=list(input())
    S.append(s)



dones=[[0]*W for _ in range(H)]
dh=[1,0,-1,0]
dw=[0,1,0,-1]

def judge(h,w):
    if 0<=h<H and 0<=w<W:
        if dones[h][w]==0:
            return True
    return False
ans=0
for h in range(H):
    for w in range(W):
        now=S[h][w]
        if now=="#" and dones[h][w]==0:
            que=deque([])
            que.append((h, w, "#"))
            dones[h][w]=1
            blacks=0
            whites=0
            while que:
                nowh, noww, color = que.popleft()
                if color=="#":
                    blacks+=1
                    #print(nowh, noww)
                else:
                    whites+=1
                for i in range(4):
                    nh=nowh+dh[i]
                    nw=noww+dw[i]
                    if judge(nh, nw):
                        if color=="#" and S[nh][nw]==".":
                            que.append((nh,nw,"."))
                            dones[nh][nw]=1
                        if color=="." and S[nh][nw]=="#":
                            dones[nh][nw]=1
                            que.append((nh,nw,"#"))
            ans+=blacks*whites
            #print(blacks, whites)

print(ans)

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

using namespace std;

int main(){
    int H,W,N;
    int now=0;
    bool right=true;
    cin >> H >> W;
    cin >> N;
    vector<int> a(N);
    int A[H][W];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(right){
                A[i][j] = now+1;
                a[now]--;
                if(a[now]==0){
                    now++;
                }
            }else{
                A[i][W-1-j] = now+1;
                a[now]--;
                if(a[now]==0){
                    now++;
                }
            }
        }
        if(right){
            right = false;
        }else{
            right = true;
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << A[i][j];
            if(j==W-1){
                cout << endl;
            }else{
                cout << " ";
            }
        }
    }
}

Measured memory_bytes: 384
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n, num;
		
		while (input.hasNext()){
			n = input.nextInt();
			num = (n + 1) * n / 2 + 1;
			System.out.println(num);
		}
	}
}

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

long n, m, l, a[100][100], b, c[100][100];
int main() {
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			cin >> b;
			for (int k = 0; k < n; k++)
				c[k][j] += a[k][i] * b;
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < l - 1; j++){
			cout << c[i][j] << " ";
		}
		cout << c[i][l-1] << endl;
	}
	return 0;
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b) cout<<"Draw"<<endl;
    else if(a==1) cout<<"Alice"<<endl;
    else if(b==1) cout<<"Bob"<<endl;
    else if(a>b) cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n,k;

int main() {
    cin >> n >> k;
    int res = 1;
    REP(i,n){
        if(res>k){
            res += k;
        }else{
            res *= 2;
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


void solve() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        string n = to_string(i);
        if(n[0] == n[4] && n[1] == n[3]) ans++;
    }
    cout << ans << "\n";
}

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


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

int main(){
    string n, k;
    int m, s, i;
    
    while(true){
        cin >> n;
        if(n == "-") break;
        cin >> m;
        for(i = 0; i < m; i++){
            cin >> s;
            k = n.substr(0, s);
            n.erase(0, s);
            n = n + k;
        }
        cout << n << endl;
    }
}



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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  rep(i, n) cin >> m[i];

  int m_min = m[0];
  rep(i, n) m_min = min(m_min, m[i]);

  int m_sum = 0;
  rep(i, n) m_sum += m[i];

  cout << (x - m_sum) / m_min + n << endl;

  return 0;
}


Measured memory_bytes: 256
#n = int(input())
n, m = map(int, input().split())
xl = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
xl.sort()
difl = []

for i in range(1, m):
    difl.append(xl[i]-xl[i-1])

difl.sort(reverse=True)

if n >= m:
    ans = 0
else:
    ans = xl[-1]-xl[0]-sum(difl[:n-1])
print(ans)

Measured memory_bytes: 20476
w, h, n = map(int, raw_input().split())
r = [map(int, raw_input().split()) for i in range(n)]
ans = 0
for i in range(n-1):
    dx = r[i][0] - r[i+1][0]
    dy = r[i][1] - r[i+1][1]
    if dx * dy >= 0:
        ans += max(abs(dx),abs(dy))
    else:
        ans += abs(dx) + abs(dy)
print ans

Measured memory_bytes: 6540
#include <iostream>

using namespace std;

int main() {
  int n, x, result;

  cin >> n >> x;
  while(n != 0 || x != 0) {
    result=0;
    for(int i=1; i <= n-2; i++) {
      for(int j=i+1; j <= n-1; j++) {
        for(int k=j+1; k <= n; k++) {
          if(i+j+k == x) result++;
        }
      }
    }
    cout << result << endl;
    cin >> n >> x;
  }

  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string S, T;
  cin>>S>>T;
  stringstream os;
  os<<T<<S;
  cout<<os.str()<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long



void solve()
{
   
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   
   int a1=a*c;
   int a2=b*d;
   int a3=a*d;
   int a4=b*c;
   
   cout<<max({a1,a2,a3,a4});
    
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--)solve();
	    
   
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])cout << "YES";
    else cout << "NO";
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll n,mx=0;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        mx=max(mx,a[i]);
    }
    ll mn=mx,res;
    rep(i,n){
        if(abs((double)mx/2-a[i])<mn&&a[i]!=mx){
            res=i;
            mn=abs((double)mx/2-a[i]);
        }
    }
    cout<<mx<<' '<<a[res]<<endl;
    return 0;
}

Measured memory_bytes: 1024