akhauriyash/Code-Regression huggingface dataset:
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

#define MAX_N 100010

typedef struct {
	int suit;
	int rank;
	int origi_order;
} card_t;

#define exchange(a, b) exchange_(&(a), &(b))
void exchange_(card_t *a, card_t *b) {
	card_t tmp = *a;
	*a = *b;
	*b = tmp;
}

int Partition(card_t *A, int p, int r) {
	int x = A[r].rank;
	int i = p - 1, j;
	for (j = p; j < r; j++) {
		if (A[j].rank <= x) {
			i++;
			exchange(A[i], A[j]);
		}
	}
	exchange(A[i+1], A[r]);
	return i+1;
}

void Quicksort(card_t *A, int p, int r) {
	if (p < r) {
		int q = Partition(A, p, r);
		Quicksort(A, p, q-1);
		Quicksort(A, q+1, r);
	}
}

card_t arr[MAX_N];
int n;

int main(int argc, char **argv)
{
	int i, rank, stable;
	char suit[16];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %d", suit, &rank);
		arr[i].suit = suit[0];
		arr[i].rank = rank;
		arr[i].origi_order = i;
	}

	Quicksort(arr, 0, n-1);

	stable = 1;
	for (i = 1; i < n; i++) {
		if (arr[i-1].rank != arr[i].rank) continue;
		if (arr[i-1].origi_order > arr[i].origi_order) {
			stable = 0;
			break;
		}
	}
	if (stable) puts("Stable");
	else puts("Not stable");

	for (i = 0; i < n; i++) {
		printf("%c %d\n", arr[i].suit, arr[i].rank);
	}
	return 0;
}

Measured memory_bytes: 1784
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
  int n,q;
  cin>>n>>q;
  char str[n+2];
  cin>>str;
  int value[n+1];
  memset(value,0,sizeof(value));
  value[1]=0;
  for(int i=2;i<=n;i++)
  {
    value[i]=value[i-1];
    if(str[i-1-1]=='A'&&str[i-1]=='C')
      value[i]++;
  }
  while(q--)
  {
    int l,r;
    cin>>l>>r;
    int answer=value[r]-value[l-1];
   if(str[l-1-1]=='A'&&str[l-1]=='C')
     answer--;
    cout<<answer<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N = input()
    M = [int(c) for c in N]

    lm=len(M)
    cnt=0
    if lm==1:
        print(M[0])
    elif set(M[1:])=={9}:
        for i in M:
            cnt+=i
        print(cnt)
    else:
        print(9*(lm-1)+M[0]-1)

resolve()

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        int K = cin.nextint;
        if (K == 0)
        {
            WriteLine((long)N * N);
            return;
        }
        long ans = 0;
        for (int i = 1; i <= N; i++)//割る数をiとして
        {
            if (i <= K) continue;
            int d = (N + 1) / i;
            int p = (N + 1) % i;

            int w = i - K;
            int s = i - w;

            ans += w * d;
            ans += Math.Max(p - s, 0);
            //WriteLine(ans);
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

auto chmin = [](auto&& a, auto b) { return b < a ? a = b, 1 : 0; };

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n * n);
  for (auto&& e : p) {
    cin >> e;
    --e;
  }
  vector d(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      d[i][j] = min({i, n - i - 1, j, n - j - 1}) + 1;
    }
  }
  auto in = [&](int i, int j) {
    return 0 <= i and i < n and 0 <= j and j < n;
  };
  array<int, 4> di{1, 0, -1, 0};
  array<int, 4> dj{0, 1, 0, -1};
  int res = 0;
  vector used(n, vector<bool>(n));
  vector<pair<int, int>> que;
  for (auto e : p) {
    int si = e / n, sj = e % n;
    used[si][sj] = true;
    que.clear();
    int bg = 0;
    res += --d[si][sj];
    que.emplace_back(si, sj);
    while (bg < (int)size(que)) {
      auto [i, j] = que[bg++];
      for (int k = 0; k < 4; ++k) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if (not in(ni, nj)) continue;
        if (chmin(d[ni][nj], d[i][j] + not used[ni][nj])) {
          que.emplace_back(ni, nj);
        }
      }
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 7168
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

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

  if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


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

main() {
    int N,M,X,Y; cin >> N >> M >> X >> Y; bool can =false;
    int A[N]; rep(i,N) cin >> A[i];
    int B[M]; rep(i,M) cin >> B[i];
    sort(A,A+N);
    sort(B,B+M);
    if(A[N-1]<B[0]){
        for(int i=A[N-1]+1;i<=B[0];i++){
            if(i>X && i<=Y)can=true;
        }
    }
    else can =false;
    cout << (can ? "No War" : "War") << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
l =  input()
s= l.split(" ")
for i in range(len(s)):
    s[i] = int(s[i])
v = dict()
sumi = 0
for i in s:
    if not i in v:
        v[i] = 1
    else:
        v[i]+=1
for i in v:
    if v[i]>=2:
        sumi+=v[i]*(v[i]-1)/2
for i in s:
    if v[i]>=2:

        if v[i]==2:
            print(int(sumi-1))
        else:
            print(int(sumi-v[i]*(v[i]-1)/2+(v[i]-2)*(v[i]-1)/2))
    else:
        print(int(sumi))
    


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

int main(){
    int n;
    bool pr[105000]={0};
    for(int i=2;i<400;i++)
        for(int j=i;j*i<105000;j++)
            pr[j*i]=1;
    while(cin>>n,n){
        int ans=0,cu=2;
        while(n--){
            while(pr[cu])cu++;
            ans+=cu++;
        }
        cout<<ans<<endl;
    }
}

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

using ll = long long;

const ll MOD = 1e9 + 7;

int N, M;
string S;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M >> S;
	if (S[0] == 'B') {
		for (char& c : S) {
			c ^= 'B' ^ 'R';
		}
	}
	assert(S[0] == 'R');

	if (S == string(M, S[0])) {
		// there are no consecutive Bs
		array<array<ll, 2>, 2> dp = {};
		dp[0][0] = dp[1][1] = 1;
		for (int i = 1; i < N; i++) {
			array<array<ll, 2>, 2> ndp = {};
			for (int a = 0; a < 2; a++) {
				for (int b = 0; b < 2; b++) {
					for (int c = 0; c < 2; c++) {
						if (b || c) {
							ndp[a][c] = (ndp[a][c] + dp[a][b]) % MOD;
						}
					}
				}
			}
			swap(dp, ndp);
		}

		ll ans = 0;
		for (int a = 0; a < 2; a++) {
			for (int b = 0; b < 2; b++) {
				if (a || b) {
					ans = (ans + dp[a][b]) % MOD;
				}
			}
		}
		cout << ans << endl;
		return 0;
	}

	if (N % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}

	bool foundBlue = false;
	int maxRed = N-1;
	int cntRed = 0;
	for (char c : S) {
		if (c == 'R') {
			cntRed++;
		} else {
			assert(c == 'B');
			if (foundBlue) {
				if (cntRed % 2 == 1) {
					maxRed = min(maxRed, cntRed);
				}
			} else {
				maxRed = min(maxRed, cntRed + 1);
			}
			foundBlue = true;
			cntRed = 0;
		}
	}

	assert(maxRed >= 1);
	maxRed = (maxRed + 1) / 2;
	N /= 2;

	vector<ll> dp(N+1);
	dp[0] = 1;
	ll sum = dp[0];
	for (int i = 1; i <= N; i++) {
		if (i - maxRed - 1 >= 0) sum = (sum - dp[i - maxRed - 1] + MOD) % MOD;
		dp[i] = sum;
		sum = (sum + dp[i]) % MOD;
	}

	ll ans = 0;
	for (int i = 1; i <= maxRed; i++) {
		ans = (ans + i * dp[N - i]) % MOD;
	}
	ans = ans * 2 % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1360
#include<cstdio>
#include<algorithm>
#define re register
#define rep(i,s,t) for(re int i=s;i<=t;++i)
using namespace std;
const int N=1e6+11;
char s[N];
int k;
int main(){
	scanf("%s",s+1);
	scanf("%d",&k);
	for(re int i=1;s[i];i+=k)
		putchar(s[i]);
	return 0;
}

Measured memory_bytes: 128
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
a,b = iim()
P = iil()

p1 = []
p2 = []
p3 = []

for item in P:
    if item <= a:
        p1.append(item)
    elif item <= b:
        p2.append(item)
    else:
        p3.append(item)
print(min(len(p1),len(p2),len(p3)))

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

#define si(v) v.size()
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (n); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  char c; cin >> c;
  string s = "aiueo";

  rep(i, si(s)) {
    if (s[i] == c) {
      cout << "vowel\n";
      return (0);
    }
  }

  cout << "consonant\n";
  
  return (0);
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

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

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 7;

ll x; vii vec; ll dp[MAX];
ll go( ll i ){

    if ( i+1 == x ){
        return 0;
    }

    ll& ret = dp[i];
    if ( ~ret ) return ret;

    ll a = go(i+1) + abs(vec[i] - vec[i + 1]);
    if ( i+2 < x ){
        ll b = go(i+2) + abs(vec[i] - vec[i + 2]);
        return ret = min( a , b );
    }
    return ret = a;
}
int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> x; vec.resize(x); mem( dp , -1 );
    for ( ll& i : vec ) cin >> i;
    cout << go(0);
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 6528
n,k,*a=map(int,open(0).read().split());t,s=2**40,0
while t:
 c=sum((i&t)//t for i in a)
 if k<t or c*2>=n:s+=t*c
 else:s+=t*(n-c);k-=t
 t//=2
print(s)

Measured memory_bytes: 14108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    string s;cin>>s;
    ll ans=0;
    int n=s.size();
    
    for(int bit=0;bit<(1<<n-1);bit++){
        string ss="";
        for(int i=0;i<n;i++){
            ss+=s[i];
            if(bit>>i&1){
                ans+=stoll(ss);
                ss="";
            }
        }
        ans+=stoll(ss);
        ss="";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();


        int blowsA = (a + d - 1) / d;
        int blowsT = (c + b - 1) / b;

        System.out.println(blowsT <= blowsA ? "Yes" : "No");
    }
}


Measured memory_bytes: 35720
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n,m;
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0){
                break;
            }
            for(m = 0;m < H;m++){
                if( m%2 != 0){
                    for(n = 0; n < W ;n++){
                        if( n % 2 != 0){
                            System.out.print("#");
                        }
                        else{
                            System.out.print(".");
                        }
                    }
                    //System.out.println("");
                }
                else{
                    for(n = 0;n < W; n++){
                        if( n%2 != 0){
                            System.out.print(".");
                        }
                        else{
                            System.out.print("#");
                        }
                        //System.out.println("");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 35256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, K = map(int, readline().split())
    s = set()

    for i in range(A, A + K):
        if i > B:
            break
        s.add(i)

    for i in range(B, B - K, -1):
        if i < A:
            break
        s.add(i)

    res = sorted(list(s))

    for x in res:
        print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62380
from typing import List


class Node:
    parent = -1  # 親。親を持たない場合は-1
    sibling = -1  # 兄弟。兄弟を持たない場合は、-1
    degree = -99  # 子の数
    depth = -99  # 深さ
    height = -99  # 高さ
    node_type = 'Not set'  # 根(root)、内部節点(internal node)、葉(leaf)
    left = -99
    right = -99


num_of_node = int(input())
nodes = [Node() for i in range(num_of_node)]
for _i in range(num_of_node):
    node_id, left, right = map(int, input().split())
    # 子を持たない場合は、leftやrightは-1
    nodes[node_id].left = left
    nodes[node_id].right = right

    degree = 0
    if left != -1:
        degree += 1
    if right != -1:
        degree += 1
    nodes[node_id].degree = degree

# 親を設定
for i in range(num_of_node):
    if nodes[i].left != -1:
        nodes[nodes[i].left].parent = i
    if nodes[i].right != -1:
        nodes[nodes[i].right].parent = i

# 兄弟を設定
for i in range(num_of_node):
    if nodes[i].parent == -1:
        continue
    # 自分が左の場合
    if nodes[nodes[i].parent].left == i and nodes[nodes[i].parent].right != -1:
        nodes[i].sibling = nodes[nodes[i].parent].right
    # 自分が右の場合
    if nodes[nodes[i].parent].right == i and nodes[nodes[i].parent].left != -1:
        nodes[i].sibling = nodes[nodes[i].parent].left


def set_depth(node_id: int, depth: int):
    nodes[node_id].depth = depth
    if nodes[node_id].left != -1:
        set_depth(nodes[node_id].left, depth + 1)
    if nodes[node_id].right != -1:
        set_depth(nodes[node_id].right, depth + 1)


# 深さを設定
for i in range(num_of_node):
    if nodes[i].parent == -1:
        set_depth(i, 0)
        break


def set_height(node_id: int, height: int):
    if nodes[node_id].height < height:
        nodes[node_id].height = height
    if nodes[node_id].parent != -1:
        set_height(nodes[node_id].parent, height + 1)


# 高さを設定
for i in range(num_of_node):
    if nodes[i].degree == 0:
        set_height(i, 0)

# タイプを設定
for i in range(num_of_node):
    if nodes[i].parent == -1:
        nodes[i].node_type = 'root'
    elif nodes[i].degree != 0:
        nodes[i].node_type = 'internal node'
    else:
        nodes[i].node_type = 'leaf'


for i in range(num_of_node):
    out = f'node {i}: parent = {nodes[i].parent}, sibling = {nodes[i].sibling}'
    out += f', degree = {nodes[i].degree}, depth = {nodes[i].depth}'
    out += f', height = {nodes[i].height}, {nodes[i].node_type}'
    print(out)



Measured memory_bytes: 7196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

inline int d(P a, P b) { return abs(a.first - b.first) + abs(a.second - b.second); }

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

    int n, m; cin >> n >> m;
    vector<P> a(n), c(m);
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
    for (int i = 0; i < m; i++) cin >> c[i].first >> c[i].second;

    for (int i = 0; i < n; i++) {
        int now = inf;
        int ans = 0;
        for (int j = 0; j < m; j++) {
            if (d(a[i], c[j]) < now) now = d(a[i], c[j]), ans = j;
        }
        cout << ans + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	static Scanner sc = new Scanner(System.in);
	static int n = 0;
	static long k = 0;
	static int[] a = null;
	static int[] inner = null;
	static int[] outer = null;
	static long innerSum = 0;
	static long outerSum = 0;
	static long ans = 0;
	
	public static void main(String[] args) {
		n = sc.nextInt();
		k = sc.nextLong();
		a = new int[n];
		for(int i = 0; i < n; ++i) a[i] = sc.nextInt();
		
		inner = new int[n];
		for(int i = 0; i < n - 1; ++i) {
			for(int j = i + 1; j < n; ++j) {
				inner[i] += (a[i] > a[j]) ? 1 : 0;
			}
		}
		
		outer = new int[n];
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < n; ++j) {
				outer[i] += (a[i] > a[j]) ? 1 : 0;
			}
		}
		
		for(int i = 0; i < n; ++i) {
			innerSum += inner[i];
			innerSum %= MOD;
		}
		innerSum = innerSum * k % MOD;
		
		for(int i = 0; i < n; ++i) {
			outerSum += outer[i];
			outerSum %= MOD;
		}
		outerSum = k * (k - 1) / 2 % MOD * outerSum % MOD;
		ans = (innerSum + outerSum) % MOD;
		System.out.println(ans);
	}
}

Measured memory_bytes: 26972
///
// File:  0007.cpp
// Author: ymiyamoto
//
// Created on Wed Nov  8 22:11:50 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

#define DEBT_INIT 100000

int32_t main()
{
  uint32_t weeks;
  cin >> weeks;

  uint64_t debt = DEBT_INIT;
  for (uint32_t i = 0; i < weeks; i++) {
    uint64_t interest = ((uint64_t)(debt * 0.05 + 999) / 1000) * 1000;
    debt += interest;
  }

  cout << debt << endl;

  return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  cout << max(a+b,max(a-b,a*b)) << endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

vector<int> calc_divisor(int n) {
    vector<int> res;
    for (int i = 1; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            int j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

vector<int> box;
map<int, int> num;
int main(){

    int n;
    cin >> n;
    box.resize(n+1, 0);
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;

    for(int i = n; i >= 1; --i){
        if(a[i-1] != num[i]%2){
            ++cnt;
            box[i] = 1;
            for(int x : calc_divisor(i)){
                ++num[x];
            }
        }
    }
    ppp(cnt);
    for(int i = 1; i <= n; ++i){
        if(box[i]) cout << i << sp;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
int main()
{
    
    int n;
 
    int k,m,l;
    string o,e,p;
    cin>>o>>e;;
 
    n=o.size();
    k=e.size();
    l=0,m=0;
    p="";
    for(int i=1;i<=n+k;i++)
    {
        if(i%2==0)
        {
            p=p+e.at(m);
            m++;
        }
        else
        {
            p=p+o.at(l);
            l++;
        } 
    }
    cout<<p;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<math.h>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int a[205],b[205];
int main()
{
	int n,m,x,y;
	scanf("%d%d%d%d",&n,&m,&x,&y);
	int mx=-2e9,mn=2e9;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==y)
		{
			printf("War");
			return 0;
		}
		mx=max(mx,a[i]);
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
		if(b[i]==x)
		{
			printf("War");
			return 0;
		}
		mn=min(mn,b[i]);
	}
	//cout<<mn<<' '<<mx<<endl;
	if(mn>mx&&mn>x&&mx<y)
	{
		printf("No War");
	}
	else printf("War");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s,t;
  while(cin>>s,s!="."){
    cin>>t;
    if(s==t){
      cout<<"IDENTICAL"<<endl;
      continue;
    }
    string u,v;
    int n=s.size(),m=t.size();
    vector<string> vs,vt;
    for(int i=0;i<n;i++){
      if(s[i]=='\"'){
	u+=s[i];
	string x;
	i++;
	while(s[i]!='\"') x+=s[i++];
	vs.push_back(x);
	u+=s[i];
	continue;
      }
      u+=s[i];
    }
    for(int i=0;i<m;i++){
      if(t[i]=='\"'){
	v+=t[i];
	string x;
	i++;
	while(t[i]!='\"') x+=t[i++];
	vt.push_back(x);
	v+=t[i];
	continue;
      }
      v+=t[i];
    }
    if(u!=v||vs.size()!=vt.size()){
      cout<<"DIFFERENT"<<endl;
      continue;
    }
    int dif=0;
    for(int i=0;i<(int)vs.size();i++) dif+=(vs[i]!=vt[i]);
    if(dif==1){
      cout<<"CLOSE"<<endl;
      continue;
    }
    cout<<"DIFFERENT"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <cstdlib>  // abs() for integer

using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  int sum = 0;
  for(int i = 0; i < n-1; i++){
    sum += abs(a[i+1]-a[i]);
  }
  sum += abs(a[0]);
  sum += abs(a[n-1]);
  
  for (int i = 0; i<n; i++){
    int dis1,dis2,dis3;
    if (0<i && i<n-1){
    	dis1 = a[i+1]-a[i];
    	dis2 = a[i] - a[i-1];
    	dis3 = a[i+1]-a[i-1];
    }
    else if(i == 0){
      dis1 = a[0];
      dis2 = a[1]-a[0];
      dis3 = a[1];
    }
    else{
	  int b;
      b = a[n-1];
      dis1 = -b;
      dis2 = a[n-1]-a[n-2];  
      dis3 = a[n-2];  
    }
    
    
    if(dis1*dis2 < 0){
      int res1;
      res1 = sum- abs(dis1)-abs(dis2)+abs(dis3);
      cout << res1 << endl;
    }
    else{
      int res2;
	  res2 = sum;
      cout << res2 << endl;
    }
      
  }
    
    
}

Measured memory_bytes: 1664
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] abcd = scanner.nextLine().split(" ", 4);
        int a = Integer.parseInt(abcd[0]);
        int b = Integer.parseInt(abcd[1]);
        int c = Integer.parseInt(abcd[2]);
        int d = Integer.parseInt(abcd[3]);

        if ((Math.abs(a - b) <= d && Math.abs(b - c) <= d) || Math.abs(a - c) <= d) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 24020
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    vector<int>v(3);
    for(int i=0;i<3;i++)
    {
        cin>>v[i];
    }
    int result=0;
    sort(v.begin(),v.end());
    if(v[0]%2!=v[1]%2){
        v[0]++;
        v[2]++;
        result++;
    }
    result+=(v[2]-v[0])/2;
    if(v[2]%2!=v[0]%2){
        result++;
    }
    result+=(v[2]-v[1])/2;
    cout<<result;
}

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

int main(){
    ll H, W;
    cin>>H>>W;
    ll a, b, ans=LLONG_MAX;
    if(H>=3){
        if(H%3==0){
            ans=0;
        }else{
            ans=min(ans, W);
        }
    }
    if(W>=3){
        if(W%3==0){
            ans=0;
        }else{
            ans=min(ans, H);
        }
    }
    for(ll i=1; i<H; ++i){
        vector<ll> area(3);
        area[0]=i*W;
        area[1]=W/2*(H-i);
        if(W%2==0){
            area[2]=W/2*(H-i);
        }else{
            area[2]=(W/2+1)*(H-i);
        }
        sort(area.begin(), area.end());
        ans=min(ans, area[2]-area[0]);
    }

    for(ll i=1; i<W; ++i){
        vector<ll> area(3);
        area[0]=i*H;
        area[1]=H/2*(W-i);
        if(H%2==0){
            area[2]=H/2*(W-i);
        }else{
            area[2]=(H/2+1)*(W-i);
        }
        sort(area.begin(), area.end());
        ans=min(ans, area[2]-area[0]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    X, K, D = list(map(int, input().split()))
    right = X % D
    left = right - D
    if X in [left, right]:
        if K % 2 == 0:
            print(abs(X))
        else:
            if X == left:
                print(right)
            else:
                print(abs(left))
        return
    if X > right:
        to_right = (X - right) // D
        if to_right >= K:
            print(X - K * D)
        else: # to_right < K
            if (K - to_right) % 2 == 0:
                print(right)
            else:
                print(abs(left))
    else:  # X < left
        to_left = (left - X) // D
        if to_left >= K:
            print(abs(X + K * D))
        else: # to_left < K
            if (K - to_left) % 2 == 0:
                print(abs(left))
            else:
                print(right)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9228
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

# 負の数
nega = []
# 正の数
posi = []
# 0のカウンタ
zeros = 0

# Aの数をnega, posiに分配 & 0の数を数える
A.each do |ai|
  if ai < 0
    nega << ai
  elsif ai > 0
    posi << ai
  else
    zeros += 1
  end
end

# 正の数は昇順にソート
posi.sort!
# 負の数は降順にソート
nega.sort!.reverse!

# A_iの値の制約の最小値（最大値）同士の積よりわずかに小さい（大きい）値を設定する
ng = -(10 ** 18) - 1
ok = 10 ** 18 + 1

# 二分探索で「積がx以下になるペアの総数が、k以上であるようなxの最小値」を求める
while ok - ng > 1
  mid = (ok + ng) / 2
  cnt = 0

  if mid >= 0
    # 積が0になるペア数を加算
    # (0同士のペア + 0と0でない数のペア)
    cnt += zeros * (zeros - 1) / 2 + zeros * (N - zeros)
  end

  if mid > 0
    # 何も分からん
    cnt += nega.size * posi.size

    # 正の数の配列、負の数の配列それぞれに対して、
    # ある数を固定したときに、それとペアになりうる数を足していく
    [posi, nega].each do |a|
      l = 0
      r = a.size - 1
      while l < r
        while l < r && a[l] * a[r] > mid
          r -= 1
        end
        # ここに到達した時点で a[l] * a[r] <= mid
        # ex.)
        # 1. l = r ならばカウントされない
        # 2. a[3] * a[6] <= mid ならば a[3] * a[4], a[3] * a[5], a[3] * a[6] で 6 - 3 = 3 がカウントされる
        cnt += r - l
        l += 1
      end
    end
  else
    # 何も分からん
    r = nega.size - 1
    0.upto(posi.size - 1) do |l|
      while r >= 0 && posi[l] * nega[r] <= mid
        r -= 1
      end
      cnt += nega.size - r - 1
    end
  end

  if cnt >= K
    ok = mid
  else
    ng = mid
  end
end
puts ok

Measured memory_bytes: 22416
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
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; }

int x[10],y[10];

long double dis(int i,int j){
  return powl(powl(x[i]-x[j],2)+powl(y[i]-y[j],2),0.5);
}

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

  rep(i,0,n) cin>>x[i]>>y[i];
  long double sum=0;

  vector<int> v(n);
  rep(i,0,n) v[i]=i;

  do{
    rep(i,0,n-1) sum+=dis(v[i],v[i+1]);
  }while(next_permutation(v.begin(),v.end()));


  int stair=1;
  rep(i,2,n+1) stair*=i;

  double ans=sum/stair;
  printf("%9f",ans);
  //cout<<stair<<endl;
}

Measured memory_bytes: 256
import itertools
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

l=[]
for i in range(n):
    l.append(i+1)

nlist=[]
for i in itertools.permutations(l,r=n):
        nlist.append(list(i))

#po=0
#qo=0

for i in range(len(nlist)):
    if nlist[i]==p:
        po=i
    if nlist[i]==q:
        qo=i

print(abs(qo-po))

Measured memory_bytes: 10228
def main():
    A, B = map(int, input().split())
    
    if B == 1:
        print(0)
        exit()
        
    B -= A

    cnt = 1

    
    if B > 0:
        cnt += B // (A-1) + (1 if B % (A-1) > 0 else 0)

    print(cnt)
        

main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll = long long;

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

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    string s; cin >> s;
    string t; cin >> t;
    if (s == t.erase(t.size()-1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ b.cpp
./a.out
*/

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

int main()
{
  int n;
  cin >> n;
  
  if(n == 1)
  {
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3632
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        t: usize,
    }
    for _ in 0..t {
        input! {
            n: usize,
            klr: [(Usize1, isize, isize); n],
        }
        let mut left = vec![];
        let mut right = vec![];
        let mut s = 0;
        for i in 0..n {
            let (_, li, ri) = klr[i];
            if li > ri {
                left.push(i);
            } else if li < ri {
                right.push(i);
            } else {
                s += li;
            }
        }

        left.sort_by_key(|&i| klr[i].0);
        left.reverse();
        let mut left_heap = BinaryHeap::new();
        for t in 0..n {
            while let Some(i) = left.pop() {
                let (ki, li, ri) = klr[i];
                if ki <= t {
                    left_heap.push((Reverse(li - ri), i));
                } else {
                    left.push(i);
                    break;
                }
            }
            while left_heap.len() > t + 1 {
                let (_, i) = left_heap.pop().unwrap();
                s += klr[i].2;
            }
        }
        while let Some((_, i)) = left_heap.pop() {
            s += klr[i].1;
        }

        right.sort_by_key(|&i| klr[i].0);
        let mut right_heap = BinaryHeap::new();
        for t in (0..n).rev() {
            while let Some(i) = right.pop() {
                let (ki, li, ri) = klr[i];
                if ki >= t {
                    right_heap.push((Reverse(ri - li), i));
                } else {
                    right.push(i);
                    break;
                }
            }
            while right_heap.len() > n - t - 1 {
                let (_, i) = right_heap.pop().unwrap();
                s += klr[i].1;
            }
        }
        while let Some((_, i)) = right_heap.pop() {
            s += klr[i].2;
        }

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


Measured memory_bytes: 15332
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;


int main(){
	int a,b,c;
	cin>>a>>b>>c;
	long long ans = 0;
	if ((a == b) && (a == c)){
		if (a%2 == 0) cout<<-1;
		if (a%2 == 1) cout<<0;
		return 0;
	}
	while((a%2 == 0) &&(b%2 == 0) && (c%2 == 0)){
		ans++;
		int u, v, w;
		u = a;
		v = b;
		w = c;
		a += -a +(v+w)/2;
		b += -b +(u+w)/2;
		c += -c +(u+v)/2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int n,h,w;
int yes=0;
int a[1005],b[1005];
scanf("%d %d %d",&n,&h,&w);

for(int count=0;count<n;count++){
scanf("%d",&a[count]);
scanf("%d",&b[count]);
}

for(int count=0;count<n;count++){
if(a[count]>=h&&b[count]>=w){yes++;}
}
printf("%d",yes);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, T);
    CINS(int, t, N);

    int stopTime = t[0];
    int lastTime = t[0]+T;

    for (int i = 0; i < N; i++) {
        stopTime += max(t[i] -lastTime, 0);
        lastTime = t[i] + T;
    }

    cout << (t[N-1]+T-stopTime) << "\n";
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ac_count(N, 0);
  
  int W = 0, A = 0, a;
  string s;
  for (int i = 0; i < M; i++) {
    cin >> a >> s;
    
    if (ac_count.at(a - 1) == -1) continue;
    
    if (s == "AC") {
      W += ac_count.at(a - 1);
      ac_count.at(a - 1) = -1;
      A++;
    }
    
    else ac_count.at(a - 1)++;
    
  }
  
  cout << A << ' ' << W << endl;
  
}


Measured memory_bytes: 3684
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def solve():
    import fractions
    A,B = map(int, input().split())
    gcd = fractions.gcd(A,B)
    prime_factor = list(set(prime_factorize(gcd)))
    
    ans = int(len(prime_factor))
    for i in range(int(2**len(prime_factor))):
        i_temp = i
        j = 0
        composite = 1
        count = 0
        while i_temp != 0:
            if i_temp%2 == 0:
                pass
            elif i_temp%2 == 1:
                composite *= prime_factor[j]
                count += 1
            j += 1
            i_temp /= 2
        
        for j in prime_factor:
            if j == composite and count >= 2:
                ans -= 1

    print(ans + 1) 

solve()

Measured memory_bytes: 65900
n, m = map(int, input().split())

LL = []
RR = []

for i in range(m):
    l, r = map(int, input().split())
    LL.append(l)
    RR.append(r)

lmax = max(LL)
rmin = min(RR)

ans = rmin - lmax + 1

if ans > 0:
    print(ans)
else:
    print(0)


Measured memory_bytes: 10996
#include <iostream>
using namespace std;
int main(void){
    int N,k[10000],max;
    
    while(true){
        cin >> N;
        if(N==0) break;
        
        for(int i=0;i<N;i++){
            cin >> k[i];
        }
        max=0;
        for(int i=0;i<N;i++){
            if(k[i]>max)
                max=k[i];
        }
        if (max<2)
            cout<<"NA"<<endl;
        else{
            if(N==1)
                cout<<"2"<<endl;
            else{
                int t=0;
                for(int i=0;i<N;i++){
                    if(k[i]==0) t += 0;
                    else t += 1;
                }
                cout << t+1 << endl;
            }
                
        }   
    }
}



Measured memory_bytes: 3112
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

#define read(x) scanf("%d",&x)

int n,m,q;
int ans=0;
int a[55],b[55],c[55],d[55];
int rt[15];

void dfs(int th)
{
	if(th==n)
	{
		int now=0;
		for(int i=1;i<=q;i++)
		{
			if(rt[b[i]]-rt[a[i]]==c[i]) now+=d[i];
		}
		ans=max(ans,now);
		return;
	}
	for(int i=rt[th];i<=m;i++)
	{
		rt[th+1]=i;
		dfs(th+1);
	}
	return;
}

int main()
{
	read(n),read(m),read(q);
	for(int i=1;i<=q;i++) read(a[i]),read(b[i]),read(c[i]),read(d[i]);
	for(int i=1;i<=m;i++)
	{
		rt[1]=i;
		dfs(1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
unsigned int sixfeet(unsigned int n){
  unsigned int y = 0;
  while (n != 0){
    y += n % 6;
    n /= 6;
  }
  return y;
}
unsigned int ninefeet(unsigned int n){
  unsigned int y = 0;
  while (n != 0){
    y += n % 9;
    n /= 9;
  }
  return y;
}
int main(){
  int N;
  cin >> N;
  int rem = N % 3;
  int s = N / 3;
  if (s <= 1){
    cout << rem + s * 3 << endl;
  }
  else{
    int red = s;
    int t = 17777777;
    for (int i=0;i<=(red/2);i++){
      int tmp = red - 2 * i;
      if (tmp >= 0 && tmp % 3 == 0){
        unsigned int sf = sixfeet(i), nf = ninefeet(tmp/3);
        if (sf + nf + rem < t){
          t = sf + nf + rem;
        }
      }
    }
    cout << t << endl;
  }
}

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

int main(){
	int N;
	cin >> N;
	string S;
	cin >> S;
	int rui[N];
	if(S[0] == '#'){
		rui[0] = 1;
	}else rui[0] = 0;
	int num = 0;
	for(int i=0; i<S.size(); i++){
		if(S[i] == '#') num++;
	}
	for(int i=1; i<N; i++){
		if(S[i] == '#') rui[i] = rui[i-1] + 1;
		else rui[i] = rui[i-1];
	}
	int ans = 1e9;
	for(int i=0; i<=N; i++){
		int x = 0;
		if(i != N) x += rui[N-i-1];
		if(i != N) x +=  i - rui[N-1] + rui[N-i-1];
		else x += N - rui[N-1];
		if(ans > x) ans = x;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1412
hm=[[['0','0','0','0','0','0','0','0','0','0'],['0','0','0','0','0','0','0','0','0','0'],['0','0','0','0','0','0','0','0','0','0']],[['0','0','0','0','0','0','0','0','0','0'],['0','0','0','0','0','0','0','0','0','0'],['0','0','0','0','0','0','0','0','0','0']],[['0','0','0','0','0','0','0','0','0','0'],['0','0','0','0','0','0','0','0','0','0'],['0','0','0','0','0','0','0','0','0','0']],[['0','0','0','0','0','0','0','0','0','0'],['0','0','0','0','0','0','0','0','0','0'],['0','0','0','0','0','0','0','0','0','0']]]
ku=['#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#']
n=int(input())
for w in range(n):
    a,b,c,d=input().split()
    a=int(a)
    b=int(b)
    c=int(c)
    e=int(hm[a-1][b-1][c-1])
    hm[a-1][b-1][c-1]=str(e+int(d))
    
for i in range(4):
    for m in range(3):
        print("",' '.join(hm[i][m]))
    if i==3:
        break
    print(''.join(ku))


Measured memory_bytes: 5628
#include <stdio.h>
#define MAX 1000000
int prime_count[MAX];
int main(void){
  int n = 0, i, j;
 
  for(i = 2; i < MAX; ++i){
    if(prime_count[i] != -1){
      for(j = i * 2; j < MAX; j += i){
        prime_count[j] = -1;
      }
      prime_count[i] = ++n;
    }else{
      prime_count[i] = n;
    }
  }
 
  while(scanf("%d", &n) != EOF){
    printf("%d\n", prime_count[n]);
  }
  return 0;
}


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<int(n);i++)
using namespace std;
int main(){
int n, m;
cin >> n >> m;
int h[100010]={0};
rep(i,n) cin >> h[i+1];
int good[100010]={0};
for(int i=1; i<=m; i++) {
    int a, b;
    cin >> a >> b;
    if(h[a]<=h[b]) good[a]++;
    if(h[b]<=h[a]) good[b]++;
}
int ans=0;
for(int i=1; i<=n; i++) if(good[i]==0) ans++;
cout << ans << endl;
}

Measured memory_bytes: 4384
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
const int MAX_VALUE = 100000*5000*2;
int main(){

	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;

	int ans = MAX_VALUE;

	int t = max(x,y);
	for(int i = 0; i <= t; i++)
	{
		ans = min(ans, max(0,x-i)*a + max(0,y-i)*b + i*2*c);
	}

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int n,i;
  
  scanf("%d",&n);

long long int h[n],ans;
  ans=0;
  scanf("%lld",&h[0]);
  if(n>=2){
  for(i=1;i<n;i++)
  {
  scanf("%lld",&h[i]);
    if(h[i-1]>h[i]) {ans=ans+h[i-1]-h[i];
                     h[i]=h[i-1];
                    }
  }
  }
  printf("%lld",ans);
  
return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int cnt[2] = {0,0};
	for_(i,0,3) {
		int a; cin >> a;
		if (a == 5) cnt[0]++;
		if (a == 7) cnt[1]++;
	}
	puts(cnt[0] == 2 && cnt[1] == 1 ? "YES" : "NO");
}

Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>


const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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









int main(){
    int K; std::cin >> K;
    for(int i(0); i < K; ++i) std::cout << "ACL";
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 3596
//Volume5-0502
import java.util.*;

class Main {
	
	private static int[] dice;
	private static int   sum;
	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int n;
		String s;
		while((n=sc.nextInt())!=0){
			init();
			while(n-- > 0){
				s=sc.next();
				if     (s.equals("North")){north() ;}
				if     (s.equals("South")){south() ;}
				else if(s.equals("East")) {east()  ;}
				else if(s.equals("West")) {west()  ;}
				else if(s.equals("Right")){right() ;}
				else if(s.equals("Left")) {left()  ;}
				sum+=dice[2];
			}
			System.out.println(sum);
		}
	}

	private static void init(){
		sum  = 1;
		dice = new int[6];
		int[] init = {4,5,1,2,6,3}; 
		for(int i=0;i<6;i++){
			dice[i] = init[i];
		}
	}

	private static void north(){
		for(int i=1;i<4;i++){
			swap(i,i+1);
		}
	}
	private static void south(){
		for(int i=3;i>0;i--){
			swap(i,i+1);
		}
	}

	private static void east(){
		swap(2,5);swap(2,4);swap(0,2);
	}

	private static void west(){
		swap(0,2);swap(2,4);swap(2,5);
	}

	private static void right(){
		swap(0,1);swap(0,3);swap(3,5);
	}
	
	private static void left(){
		swap(3,5);swap(0,3);swap(0,1);
	}
	
	private static void swap(int i,int j){
		dice[j]  = dice[i] - dice[j];
		dice[i] -= dice[j];
		dice[j] += dice[i];
	}
}

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

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)
#define FOREACH(i,x) for (__typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

char buf[10000];

int main() {
  // ios_base::sync_with_stdio(0);

  scanf("%s", buf);
  printf(string(buf, min(4, (int)strlen(buf))) == "YAKI" ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256