akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}

double get_angle(int x, int y) {
    double a = atan2(y, x) * 180 / M_PI;
    return a < 0.0 ? a + 360.0 : a;
}

void solve() {
    int n;
    cin >> n;
    vector<tuple<double, int, int>> v(n);
    int x, y;
    REP(i, n) {
        cin >> x >> y;
        v[i] = make_tuple(get_angle(x, y), x, y);
    }
    sort(ALL(v));
    double d;
    double ans = 0.0;
    REP(i, n) {
        double ax = 0.0;
        double ay = 0.0;
        REP(j, n) {
            tie(d, x, y) = v[(i + j) % n];
            ax += x;
            ay += y;
            chmax(ans, sqrt(ax * ax + ay * ay));
        }
    }
    cout << ans << EOL;
}



Measured memory_bytes: 256
gets
while vals = gets
  x1, y1, x2, y2, x3, y3 = vals.split.map(&:to_f)
  a = ( x3 - x2 ) ** 2.0 + ( y3 - y2 ) ** 2.0
  b = ( x1 - x3 ) ** 2.0 + ( y1 - y3 ) ** 2.0
  c = ( x2 - x1 ) ** 2.0 + ( y2 - y1 ) ** 2.0
  s = a * ( b + c - a ) + b * ( c + a - b ) + c * ( a + b - c )
  rx = ( a * ( b + c - a ) * x1 + b * ( c + a - b ) * x2 + c * ( a + b - c ) * x3 ) / s
  ry = ( a * ( b + c - a ) * y1 + b * ( c + a - b ) * y2 + c * ( a + b - c ) * y3 ) / s
  radius = ( ( rx - x1 ) ** 2.0 + ( ry - y1 ) ** 2.0 ) ** 0.5
  printf( "%5.3f %5.3f %5.3f\n", rx, ry, radius )
#puts "#{rx} #{ry} #{radius}"
end

Measured memory_bytes: 8808
/* test */
#include <bits/stdc++.h>
using namespace std;
 
static const int N = 1000;
 
int lcs(string X,string Y){
    int c[N+1][N+1];  
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X; 
    Y = ' ' + Y;
    for(int i=0;i<=m;i++) c[i][0] = 0;
    for(int k=1;k<=n;k++) c[0][k] = 0;
 
    for(int i=1;i<=m;i++){
        for(int k=1;k<=n;k++){
            if(X[i]==Y[k]){
                c[i][k] = c[i-1][k-1] + 1;
            } else {
                c[i][k] = max(c[i-1][k],c[i][k-1]);
            }
            maxl = max(maxl,c[i][k]);
        }
    }
 
    return maxl;
}
 
int main(){
    string s1,s2;
    int n; cin >> n;
    for(int i=0;i<n;i++){
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
 
    return 0;
}

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

long long n, k;

int main(){
    cin >> n >> k;
    long long div = k;
    int cnt = 0;
    while(n > 0){
    	n = n - (n % div);
    	cnt++;
	div *= k;
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 256
/*
设从左往右球的编号为i(1 <= i <= N)；对于第i个球，它左边的洞的编号是i，右边的洞的编号是i + 1
考虑每次操作之后，把球和洞按照相对顺序重新按照以上规则标号。对于每一时刻，D[2i - 1]表示第i个球到第i个洞距离，D[2i]表示第i个球到第i + 1个洞的距离
初始时，D的值就是球和洞的真实距离。考虑新的D'是什么
考虑D'[2k] 
(1)如果推的球 = k + 1且向左，那么D'[2k] = D[2k] + D[2k + 1] + D[2k + 2]
(2)如果推的球 >= k + 1，那么D'[2k] = D[2k]
(3)不是以上2种情况，D'[2k] = D[2k + 2]
考虑D'[2k - 1]
(1)如果推的球 = k且向右，那么D'[2k - 1] = D[2k - 1] + D[2k] + D[2k + 1]
(2)如果推的球 > k，那么D'[2k - 1] = D[2k - 1]
(3)不是以上2种情况，D'[2k - 1] = D[2k + 1] 
综上，E(D'[x]) = (E(D(x + 2)) * x + E(D[x]) + E(D(x + 1)) + E(D(x + 2)) + (2 * n - 1 - x) * E(D(x))) / 2N
若E(D(x))可以表示成一个一次函数的形式，设E(D(x)) = kx + b，代入得
E'(D(x)) = b + b / N + (3 * k) / (2 * N) + x * (k + (2 * k) / N)，那么E'(D(x))也可以表示成一次函数的形式
所以直接推即可 
*/

#include <iostream>

using namespace std;
typedef long double LD;

int N;
LD Ans, K, B;

int main()
{
	cin >> N >> B >> K, B -= K;
	for (LD _K, _B;N;--N)
	{
		Ans += ((K * 1.0 + B) + (K * (2 * N) + B)) / 2.0;
		_B = B + B / N + (3.0 * K) / (2.0 * N);
		_K = K + (2.0 * K) / N;
		K = _K, B = _B;
	}
	printf("%.10lf", static_cast<double>(Ans));
	return 0;
}

Measured memory_bytes: 256
<?php

(new Main)->excute();

class Main
{
    public function excute()
    {
        while (true) {
            fscanf(STDIN, '%d %d', $height, $width);
            if ($height == 0 && $width == 0) { break; }
            
            $rentangle = (new Rectangle($height, $width, '#', '.'))->make();
            Self::draw($rentangle);
        }
    }
    
    public static function draw($object)
    {
        echo $object, PHP_EOL;
    }
}


class Rectangle
{
    private $height;
    private $width;
    private $frameChar;
    private $insideChar;
    
    
    public function __construct($height, $width, $frameChar, $insideChar)
    {
        $this->height = $height;
        $this->width  = $width;
        $this->frameChar  = $frameChar;
        $this->insideChar  = $insideChar;
    }
    
    public function make()
    {
        $rentangle = [];
        for ($i = 1; $i <= $this->height; $i++) {
            if ($i == 1 || $i == $this->height) {
                $rentangle[] = $this->makeTopAndBottomLine();
            } else {
                $rentangle[] = $this->makeMiddleLine();
            }
        }
        
        return implode(PHP_EOL, $rentangle).PHP_EOL;
    }
    
    public function makeTopAndBottomLine()
    {
        return str_repeat($this->frameChar, $this->width);
    }
    
    public function makeMiddleLine()
    {
        return $this->frameChar.str_repeat($this->insideChar, $this->width - 2).$this->frameChar;
    }
}

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




int main()
{

    string s;
    cin>>s;
    int n = s.length()-1;
    // cin>>n;

    long int sum = 0;
    while(n>=0)
    {
      int tmp = s[n--] - '0';
      // cout<<tmp<<" ";
      sum += tmp;
    }


    if(sum %9 == 0)
    cout<<"Yes\n";
    else cout<<"No\n";





}


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

typedef long long ll;
typedef long double ld;

using namespace std;

const ll maxn = 200 * 1001;
const ll INF = 1e18;
const ll mod = 1e9+7;

vector<ll> g[maxn];
ll a[maxn], b[maxn];
ll n , m , k;

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

    cin>> n; ll sum = 0, sum1 = 0;
    for(ll i = 1; i <= n; i++)
    {
        cin>> a[i];
        sum += a[i];
        a[i] *= 2;
        if(i%2 == 0)
            sum1 += a[i];
    }

    b[1] = sum - sum1;
    cout<< b[1] <<" ";
    for(ll i = 2; i <= n; i++)
    {
        b[i] = a[i-1] - b[i-1];
        cout<< b[i] <<" ";
    }
}







Measured memory_bytes: 8320
class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n)
        for i in range(len(A)):
            self.__node[i + n] = A[i]
        for i in range(n - 1, 0, -1):
            self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])
    
    def update(self, i, c):
        i += self.__n
        node = self.__node
        node[i] = c
        while i > 0:
            i //= 2
            node[i] = self.__dot(node[2 * i], node[2 * i + 1])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n
        r += self.__n
        while (l < r):
            if l & 1:
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l //= 2
            if r & 1:
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r //= 2
        return self.__dot(vl, vr)


def solve():
    import sys
    from operator import add
    N = int(input())
    S = list(input())
    Q = int(input())
    Query = sys.stdin.readlines()

    a = ord('a')
    A = [[0] * N for _ in range(26)]
    for i, s in enumerate(S):
        s = ord(s) - a
        A[s][i] = 1
    seg = [SegmentTree(A[i], add, 0) for i in range(26)]

    for i in range(Q):
        t, x, y = Query[i].split()
        t = int(t)
        x = int(x) - 1
        if t == 1 and S[x] != y:
            c = S[x]
            S[x] = y
            seg[ord(c) - a].update(x, 0)
            seg[ord(y) - a].update(x, 1)
            continue
        elif t == 2:
            y = int(y) - 1
            ans = 0
            for j in range(26):
                ans += (seg[j].get(x, y + 1)) > 0
            print(ans)


solve()


Measured memory_bytes: 382288
#include <bits/stdc++.h>
#define N 300001
using namespace std;
int n;
int A[N],ans[N];

bool check(int i){
  int l = (i+n-1)%n,r = (i+1)%n;
  if(ans[i]==0){
    if(A[i] == 1) return ans[l]==ans[r];
    if(A[i] == 0) return ans[l]!=ans[r];
  }
  if(ans[i]==1){
    if(A[i] == 1) return ans[l]!=ans[r];
    if(A[i] == 0) return ans[l]==ans[r];
  }
}

bool check(){
  for(int i=0;i<n;i++)if(!check(i))return 0;
  return 1;
}

int dfs(int pos,int cnt){
  if(cnt==n)return check();
  if(A[pos]){ //o
    if(ans[pos] == 0 ) ans[pos+1] = ans[pos-1];
    if(ans[pos] == 1 ) ans[pos+1] = !ans[pos-1];
    if(dfs(pos+1,cnt+1))return 1;
  }
  else {     //x
    if(ans[pos] == 0 ) ans[pos+1] = !ans[pos-1];
    if(ans[pos] == 1 ) ans[pos+1] =  ans[pos-1];
    if(dfs(pos+1,cnt+1))return 1;
  }
  return 0;
}

void pr(){
  char ch[]={'S','W'};
  for(int i=0;i<n;i++)cout<<ch[ans[i]];
  cout<<endl;
  exit(0);
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    char ch;cin>>ch;
    A[i] = ch=='o';
  }

  for(int i=0;i<2;i++)
    for(int j=0;j<2;j++){
      ans[0] = i;
      ans[1] = j;
      if(dfs(1,2)) pr();      
    }
  cout<<-1<<endl;
   return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int solve(vector<int> arr, int n, int k)
{
  vector<int> dp(n + 1);
  dp[1] = 0;
  for (int i = 2; i <= n; i++)
  {
    dp[i] = INT_MAX;
    for (int j = i - 1; j >= 1 && i - j <= k; j--)
    {
      dp[i] = min(dp[i], abs(arr[i] - arr[j]) + dp[j]);
    }
  }
  return dp[n];
}

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n + 1);
  for (int i = 1; i <= n; i++)
    cin >> v[i];
  cout << solve(v, n, k) << endl;
  return 0;
}

Measured memory_bytes: 3832
import math
n=int(input())
a=1;c={"R":0,"G":0,"B":0}
m=998244353
for i in input():
	s=sorted(c.values())
	c[i]+=1
	if c[i]>s[2]:pass
	elif c[i]>s[1]:a*=s[2]-s[1]
	else:a*=s[1]-s[0]
	a%=m
print(math.factorial(n)*a%m)

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

ll h,w,a;
ll c[10][10];

int main(){
    cin >> h >> w;
    for(ll i=0;i<10;i++){
        for(ll j=0;j<10;j++){
            cin >> c[i][j];
        }
    }
    for(ll i=0;i<10;i++){
        for(ll j=0;j<10;j++){
            for(ll k=0;k<10;k++){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    for(ll i=0;i<10;i++){
        for(ll j=0;j<10;j++){
            for(ll k=0;k<10;k++){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    for(ll i=0;i<10;i++){
        for(ll j=0;j<10;j++){
            for(ll k=0;k<10;k++){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    for(ll i=0;i<10;i++){
        for(ll j=0;j<10;j++){
            for(ll k=0;k<10;k++){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    ll res=0;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cin >> a;
            if(a>=0) res+=c[a][1];
        }
    }
    cout << res << endl;
}  


Measured memory_bytes: 3640
#include <iostream>
#include <map>
#include <string>
int main() {
	int n;
	std::cin >> n;
	std::map<std::string, int> map;
	for (auto i = 0; i < n; ++i) {
		int o, x;
		std::string str;
		std::cin >> o >> str;
		switch (o) {
		case 0: std::cin >> x; map[str] = x; break;
		default: std::cout << (*map.find(str)).second << std::endl;
		}
	}
}


Measured memory_bytes: 27848
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		int N = readInt(); int ans = Integer.MAX_VALUE; for(int i = 1; i<N; i++) {
			int A = i, B = N-i, sum = 0;
			while(A > 0) {sum += A%10; A/=10;}
			while(B > 0) {sum += B%10; B/=10;}
			ans = Math.min(sum, ans);
		}
		println(ans); exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 21588
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int a[12];
	for (int i = 0; i < 12; ++i)
		cin >> a[i];
	sort(a, a + 12);
	if (!(a[0] == a[1] && a[0] == a[2] && a[0] == a[3])) {
		no();
		return 0;
	}
	if (!(a[4] == a[5] && a[4] == a[6] && a[4] == a[7])) {
		no();
		return 0;
	}
	if (!(a[8] == a[9] && a[8] == a[10] && a[8] == a[11])) {
		no();
		return 0;
	}
	yes();

	return 0;
}

Measured memory_bytes: 3140
#include <stdio.h>

int main(){
    int a;
    int b;
    int c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    if(b - a == c - b){
        printf("YES""\n");
    }
    else{
        printf("NO""\n");
    }
    return 0;
}

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

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    bool flag = false;
    if (v > w) {
        if (a > b) {
            if ((a - b + v - w - 1) / (v - w) <= t)
                flag = true;
        } else {
            if ((b - a + v - w - 1) / (v - w) <= t)
                flag = true;
        }
    }

    flag ? cout << "YES" : cout << "NO";
    cout << endl;

    return 0;
}

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

int main(void){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++){
      cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  
  int rightNumber = n / 2;
  int leftNumber = rightNumber - 1;
  if(d.at(rightNumber) - d.at(leftNumber) >= 2){
      int start = d.at(leftNumber);
      int end = d.at(rightNumber);
      int ans = end - start;
      cout << ans << endl;
  }
  else if(d.at(rightNumber) - d.at(leftNumber) == 1){
    cout << 1 << endl;
  }
  else{
      cout << 0 << endl;
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    double sum =0;
    for(int i = 0; i < n; i++){
        cin >> x.at(i);
        sum += x[i];
    }
    int p = round(sum / n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += pow((x[i] - p), 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
int fans = 1e9;
const int C = 2000;
const int D = C * 2;

bool equal (char x, char y)
{return x == '?' || y == '?' || x == y;}

string a, b, c;
bool mat[3][10010];



int main() {
	ios::sync_with_stdio(false);
	cin >> a >> b >> c;
	//fix a, move b
	for (int i = -2 * C; i <= 2 * C; i ++) {
		mat[0][i + D] = true;
		for (int j = 0; j < b.size(); j ++)
			mat[0][i + D] &= (i + j < 0 || i + j >= a.size() || equal (a[i + j], b[j]));
	}

	//fix a, move c
	for (int i = -2 * C; i <= 2 * C; i ++) {
		mat[1][i + D] = true;
		for (int j = 0; j < c.size(); j ++)
			mat[1][i + D] &= (i + j < 0 || i + j >= a.size() || equal (a[i + j], c[j]));
	}

	//fix b, move c
	for (int i = -2 * C; i <= 2 * C; i ++) {
		mat[2][i + D] = true;
		for (int j = 0; j < c.size(); j ++)
			mat[2][i + D] &= (i + j < 0 || i + j >= b.size() || equal (b[i + j], c[j]));
	}



	for (int i = -2 * C; i <= 2 * C; i ++)
		for (int j = -2 * C; j <= 2 * C; j ++)
			if (abs (i - j) <= 2 * C) 
				if (mat[0][i + D] && mat[1][j + D] && mat[2][j - i + D]) {
					int st = min (0, min (i, j));
					int ed = max ((int)a.size(), max (i + (int)b.size(), j + (int)c.size()));
					fans = min (fans, ed - st);
					// if (ed - st == 3) {
						// cerr << ": " << i << " " << b.size() << " " << i + (int)b.size() << " " << j + c.size() << endl;
						// cerr << i << " " << j << " " << st << " " << ed << endl;
					// }
				}

	cout << fans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main() {
	int K;
	while (scanf("%d",&K)) {
		if (K == 0) break;
		int res = 0;
		for (int i=0; i<K*(K-1)/2; i++) {
			int in; scanf("%d",&in);
			res += in;
		}
		printf("%d\n",res/(K-1));
	}
}

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

using namespace std;

int main()
{
	int N;


	cin >> N;

	int* W = new int[N];
	for (int idx = 0; idx < N; ++idx)
	{
		cin >> W[idx];
	}

	auto get_sum = [&](int start, int end)
	{
		int sum = 0;
		for (int i = start; i <= end; ++i)
		{
			sum += W[i];
		}
		return sum;
	};

	int diff_min = 99999999;
	int best_t = 0;

	for (int T = 0; T < N - 1; ++T)
	{
		int s_1 =
		get_sum(0, T);
		int s_2 =
		get_sum(T + 1, N - 1);

		int diff = s_1 - s_2;
		if (diff < 0)
		{
			diff = -diff;
		}

		if (diff < diff_min)
		{
			diff_min = diff;
			best_t = T + 1;
		}
	}

	cout << diff_min;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int a[13];
int main ()
{
	int x=0,y=0;
	a[4]=1;a[6]=1;a[9]=1;a[11]=1;a[2]=4;
	scanf("%d%d",&x,&y);
	if(a[x]+a[y]==0||a[x]+a[y]==2)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
n,k,t,u,v,l = map(int,input().split())

time = 0
line = [0 for _ in range(l)]
carrots_line = [0 for _ in range(l)]
boost = False
carrots = 0
boost_dist = 0

for _ in range(n):
    carrots_line[int(input())-1] = 1

for i in range(l):
    if boost:
        line[i] = 1
        boost_dist -= 1
    else:
        pass

    if boost_dist == 0:
        if carrots_line[i] == 1:
            boost_dist = v*t
            boost = True
        else:
            if carrots > 0:
                carrots -= 1
                boost_dist = v*t
                boost = True
            else:
                boost = False
    else:
        if carrots_line[i] == 1:
            if carrots+1 > k:
                boost_dist = v*t
            else:
                carrots += 1
        boost = True

boost_run = sum(line)

ans = boost_run / v + (l - boost_run) / u

print(ans)


Measured memory_bytes: 5728
def gcd(a, b):
	if(a < b):
		a, b = b, a
	if(b == 0):
		return a
	else:
		return gcd(b, a % b)

import numpy as np
n, x = map(int, input().split())
a = np.abs(np.array(list(map(int, input().split())))-x)

if(a.shape[0] == 1):
	r = a[0]
else:
	r = gcd(a[0], a[1])
	for i in range(n-2):
		r = gcd(r, a[i+2])
print(r)

Measured memory_bytes: 23108
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			// solveB();
			// solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		String strA = next();
		String strB = next();
		String strC = next();

		out.println(strA.charAt(strA.length() - 1) == strB.charAt(0)
				&& strB.charAt(strB.length() - 1) == strC.charAt(0) ? "YES" : "NO");

		out.println("");
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 22612
#include<cstdio>
#include<algorithm>
using namespace std;
int n,sl,sr,ml,mr;
char s[10001];
int main(void){
	register int i=0,mid,x;
	scanf("%d",&n);
	sl=0,sr=n>>1;
	printf("%d\n",sl);
	fflush(stdout);  
	scanf("%s",s+1);
	switch(s[1]){
		case 'M':ml=0;break;
		case 'F':ml=1;break;
		case 'V':ml=2;break;
	}
	if(ml==2)return 0;
	printf("%d\n",sr);
	fflush(stdout); 
	scanf("%s",s+1);
	switch(s[1]){
		case 'M':mr=0;break;
		case 'F':mr=1;break;
		case 'V':mr=2;break;
	}
	if(mr==2)return 0;
	if((sr-sl&1)&&ml!=mr||(!(sr-sl&1))&&ml==mr){	
		sl=sr,sr=n;
		if(ml!=mr)swap(ml,mr);
	}
	while(++i<=19){
		mid=sl+sr+1>>1;
		printf("%d\n",mid);
        fflush(stdout);
        scanf("%s",s+1);
		switch(s[1]){
			case 'M':x=0;break;
			case 'F':x=1;break;
			case 'V':x=2;break;
		}
		if(x==2){
			return 0;
		}
		if((mid-sl&1)&&x!=ml||(!(mid-sl&1))&&x==ml){
			sl=mid,ml=x;
		}else sr=mid;
	}
	return 0;
}

Measured memory_bytes: 844
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  long a, b;
  readf("%s %s\n", &a, &b);
  writeln((a * b) / gcd(a, b));
}


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

int main() {

    string s;
    cin>>s;
    int n;
    bool D=true;
    n=s.size();
    for(int i=0;i<n;i=i+2) {
        if(s[i]=='L')   D=false;
    }
    for(int i=1;i<n;i=i+2) {
        if(s[i]=='R')   D=false;
    }
    if(D==true) {
       printf("Yes");
    }
    else
    {
        printf("No");
    }
    
  
 return 0;
}

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

int main() {
    int r, c, tab[102][102], i, j, sum=0;

    cin >> r >> c;
    for(i=0;i<102;i++){
        for(j=0;j<102;j++){
            tab[i][j]=0;
        }
    }

    for(i=1;i<=r;i++){
        for(j=1;j<=c;j++){
            cin >> tab[i][j];
            tab[i][c+1]=tab[i][c+1] + tab[i][j];
            tab[r+1][j]=tab[r+1][j] + tab[i][j];
            sum = sum + tab[i][j];
        }
    }

    tab[r+1][c+1] = sum;
    for(i=1;i<=r+1;i++){
        cout << tab[i][1];
        for(j=2;j<=c+1;j++){
            cout << " " << tab[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

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

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  string s, t; cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < s.length(); i++) ans += s[i] != t[i];
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




Measured memory_bytes: 3928
N, M, X = map(int, input().split())

nums = []

for i in range(N):
    a = list(map(int,input().split()))
    nums.append(a)

ans = 10000000000


for i in range(2**N):

    money = 0
    skill_point = [0]*M
    goal = [0]*M
    buy = []
    

    for k in range(N):
        if i>>k & 1:
            buy.append(nums[k])

    for d in buy:
        money += d[0]
        for e in range(M):
            skill_point[e] += d[e+1]

    for f in range(M):
        if skill_point[f] >= X:
            goal[f] = 1

    
    if (0 not in goal) and (money < ans) :
        ans = money

    

if ans != 10000000000:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 9168
#include<cstdio>
using namespace std;
int main(){
    int n;
    long a,mini=1,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%ld",&a);
        ans+=(a-1)/mini;
        if(a==mini||mini==1){
            mini++;
        }
    }
    printf("%ld\n",ans);
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long> t(n),a(n);
	for(int i=0;i<n;i++)
		cin >> t[i] >> a[i];
	
	long long x=t[0],y=a[0];
	for(int i=1;i<n;i++)
	{
		long long cou=max(x/t[i],y/a[i]);
		while(true)
		{
			if(t[i]*cou>=x and a[i]*cou>=y)
				break;
			cou++;
		}
		x=t[i]*cou;
		y=a[i]*cou;
	}

	cout << x+y << endl;


	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];

    rep(i, h)
    {
        cout << a[i] << "\n";
        cout << a[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
long long a,b;
scanf("%lld %lld",&a,&b);
//if (abs(c-a)<=d || abs (b-a)<=d && abs (c-b)<=d)
if ((a*b)%2==0)
printf("Even");
else
printf("Odd");
}


Measured memory_bytes: 1732
#include<stdio.h>

int main(void)
{
   int a[5][100],ap;
   int x,i,q;
   char str;
   
   for(i=0;i<4;i++){
      for(q=1;q<=13;q++){
         a[i][q] = 0;}}
   
   scanf("%d", &x);
   for(i=0;i<x;i++){
      scanf(" %c", &str);
      scanf("%d", &ap);
      if(str == 'S'){
         a[0][ap] = 1;}
      else if(str == 'H'){
         a[1][ap] = 1;}
      else if(str == 'C'){
         a[2][ap] = 1;}
      else if(str == 'D'){
         a[3][ap] = 1;}}
         
   for(i=0;i<4;i++){
      for(q=1;q<=13;q++){
         if(a[i][q] == 0){
         if(i == 0){
            printf("S ");}
         else if(i == 1){
            printf("H ");}
         else if(i == 2){
            printf("C ");}
         else if(i == 3){
            printf("D ");}
         printf("%d\n", q);}}}
         
   return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
enum { RED = 1, BLUE = 2 };
int query(vector<int>& A) {
    cout << "? ";
    for (auto a : A) cout << a << ' ';
    cout << endl;
    string s; cin >> s;
    if (s == "-1") exit(1);
    return s == "Red" ? RED : BLUE;
}
int query2(int N, int start) {
    vector<int> A(N);
    iota(begin(A), end(A), start);
    return query(A);
}
void answer(vector<int>& A) {
    cout << "! ";
    for (auto a : A) cout << "RB"[a == BLUE];
    cout << ' ' << endl;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    int type = query2(N, 1);
    int lo = 1, hi = N + 1;
    while (abs(lo - hi) > 1) {
        int mid = (lo + hi) / 2;
        if (query2(N, mid) == type) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    vector<int> even(N - 1); iota(begin(even), end(even), hi);
    vector<int> even2;
    for (int i = 1; i <= 2 * N; i++) {
        if (i < lo || hi + N - 1 < i) even2.push_back(i);
    }
    vector<int> ans(2 * N);
    for (int i = 1; i <= 2 * N; i++) {
        if (find(begin(even), end(even), i) == end(even)) {
            even.push_back(i);
            ans[i - 1] = query(even);
            even.pop_back();
        } else {
            even2.push_back(i);
            ans[i - 1] = query(even2);
            even2.pop_back();
        }
    }
    answer(ans);
    return 0;
}

Measured memory_bytes: 724
N, M = list(map(int, input().split()))
ACL = [0 for i in range(N)]
WAL = [0 for i in range(N)]
for i in range(M):
  p, s = input().split()
  p = int(p)-1
  if ACL[p] > 0:
    continue
  if s == "AC":
    ACL[p] = 1
    continue
  if s == "WA" and ACL[p] == 0:
    WAL[p] += 1
  
print(sum(ACL), sum([ACL[i] * WAL[i] for i in range(N)]))

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

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  string ans="No";
  if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]){ans="Yes";}
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::collections::BTreeSet;

fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let m: usize = s.next().unwrap().parse().unwrap();
	let p: Vec<usize> = s
		.by_ref()
		.take(n)
		.map(|a| a.parse::<usize>().unwrap() - 1)
		.collect();
	let mut edges = vec![vec![]; n];
	for _ in 0..m {
		let x: usize = s.next().unwrap().parse().unwrap();
		let y: usize = s.next().unwrap().parse().unwrap();
		edges[x - 1].push(y - 1);
		edges[y - 1].push(x - 1);
	}
	let mut visit = vec![false; n];
	let mut ans = 0;
	for i in 0..n {
		if visit[i] {
			continue;
		}
		let mut perm = BTreeSet::new();
		let mut pos = BTreeSet::new();
		dfs(&p, &edges, i, &mut visit, &mut perm, &mut pos);
		let int = perm.intersection(&pos).collect::<Vec<_>>();
		ans += int.len();
	}
	println!("{}", ans);
}

fn dfs(
	p: &Vec<usize>,
	edges: &Vec<Vec<usize>>,
	v: usize,
	visit: &mut Vec<bool>,
	perm: &mut BTreeSet<usize>,
	pos: &mut BTreeSet<usize>,
) {
	visit[v] = true;
	perm.insert(p[v]);
	pos.insert(v);
	for &to in edges[v].iter() {
		if !visit[to] {
			dfs(p, edges, to, visit, perm, pos);
		}
	}
}


Measured memory_bytes: 19356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;
int main(){
    int n, d;  cin >> n >> d;
    int ans = n/(2*d+1)+1;
    if(n%(2*d+1)==0)ans--;
    cout << ans;
    
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+5;

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

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll  z = c*d/__gcd(c,d);
    cout<<(b-a+1)-(b/c-(a-1)/c)-(b/d-(a-1)/d)+(b/z-(a-1)/z);
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,h,w = LI()
    x = LI()
    t = [0 for i in range(w*n+1)]
    for i in range(n):
        if not i%2:
            t[i*w+x[i]] += 1
            t[(i+1)*w+x[i]] -= 1
        else:
            t[i*w-x[i]] += 1
            t[(i+1)*w-x[i]] -= 1
    for i in range(w*n):
        t[i+1] += t[i]
    ans = 0
    for i in t[:-1]:
        if i == 0:
            ans += h
    print(ans)
    return

#B
def B():
    def dfs(d,x):
        for i in range(d):
            print(".",end = "")
        print(lis[x])
        for y in v[x]:
            dfs(d+1,y)

    n = I()
    v = [[] for i in range(n)]
    lis = [None for i in range(n)]
    for i in range(n):
        k = I()
        lis[i] = input()
        if k > 0:
            v[k-1].append(i)
    dfs(0,0)
    return

#C
def C():
    def dfs(d,k):
        if d == n:
            l.append(k)
        else:
            if sum(k[-2:]) == 0 and len(k) > 1:
                dfs(d+1,k+[1])
            elif d == n-1:
                dfs(d+1,k+[1])
            else:
                dfs(d+1,k+[0])
                dfs(d+1,k+[1])
    n = I()
    l = []
    dfs(0,[])
    print(len(l))
    return

#D
def D():
    def factorize(n):
        if n < 4:
            return {n:1}
        lis = {}
        i = 2
        m = n
        while i**2 <= m:
            if m%i == 0:
                lis[i] = 0
                while m%i == 0:
                    m //= i
                    lis[i] += 1
            i += 1
        if m != 1:
            lis[m] = 1
        return lis
    n,m = LI()
    if m == 1:
        print(1)
        quit()
    l = factorize(m)
    fact = [None for i in range(200001)]
    fact[0] = 1
    for i in range(200000):
        fact[i+1] = fact[i]*(i+1)
        if fact[i+1] >= mod:
            fact[i+1] %= mod
    inv = [None for i in range(200001)]
    inv[200000] = pow(fact[200000],mod-2,mod)
    for i in range(200000)[::-1]:
        inv[i] = inv[i+1]*(i+1)
        if inv[i] >= mod:
            inv[i] %= mod
    ans = 1
    for i in l.values():
        ans *= (fact[n+i-1]*inv[i]*inv[n-1])%mod
        if ans >= mod:
            ans %= mod
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    D()


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

signed main(void)
{
	int a;
	cin >> a;
	ll ans = a + a * a + a * a * a;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
   
  cin >> A >> B; 
  
  if(A - B >= A + B){
   if(A - B >= A * B){ 
     cout << A - B;
   }else if(A - B < A * B){
     cout << A * B;
   }
  }else if(A + B >= A * B){
   	cout << A + B;
  }else{
   	cout << A * B;
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int N=Integer.parseInt(br.readLine());
        String s=br.readLine();
        ArrayList<Integer> r=new ArrayList<Integer>();
        ArrayList<Integer> gr=new ArrayList<Integer>();
        ArrayList<Integer> bl=new ArrayList<Integer>();
        for(int i=0;i<N;i++){
            char ch=s.charAt(i);
            if(ch=='R') r.add(i);
            else if(ch=='G') gr.add(i);
            else bl.add(i);
        }
        int s1=r.size();
        int s2=gr.size();
        int s3=bl.size();
        long count=0;
        for(int i=0;i<s1;i++){
            for(int j=0;j<s2;j++){
                int a=r.get(i);
                int b=gr.get(j);
                if(a>b){
                    a=a+b;
                    b=a-b;
                    a=a-b;
                }
                int c=a+b;
                int d=b-a;
                int e=(c%2==0)?c/2:-1;
                int f=a-d;
                int g=b+d;
                int co=0;
                if(Collections.binarySearch(bl,e)>=0) co++;
                if(Collections.binarySearch(bl,f)>=0) co++;
                if(Collections.binarySearch(bl,g)>=0) co++;
                count+=(s3-co);
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 51688
def main():
    H,N = map(int,input().split())
    AB = [list(map(int,input().split())) for _ in range(N)]
    maxA = max(A for A,B in AB)
    dp = [0]*(H+maxA)
    for i in range(0,H+maxA):
        if i <= 0:
            dp[i] = 0
        else:
            dp[i] = min(dp[i-A]+B for A,B in AB)
    print(min(dp[H:]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3664
n = int(input());
list = list(map(int,input().split()))
zero = False
for i in list:
    if i==0:
        zero = True
        break
if zero:
    print(0)
else:
    ans = 1
    for i in list:
        ans *= i
        if ans>10**18:
            ans = -1
            break
    print(ans)


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


class Proc{
public:
    Proc *prev;
    Proc *next;
    string name;
    int remaining_time;
    Proc(char* n, int t) {
        prev = NULL;
        next = NULL;
        name = n;
        remaining_time = t;
    };
    int subtract_time(int t) {
        remaining_time -= t;
        return remaining_time;
    };
};

class Queue{
    Proc *head;
    Proc *tail;
public:
    Queue(){head = NULL; tail = NULL;};
    void enqueue(Proc* Proc) {
        if(head != NULL) {  // if Queue is not empty
            tail->next = Proc;
            Proc->prev = tail;
        } else {
            head = Proc;
        }
        tail = Proc;
    };
    Proc *dequeue(void) {
        Proc *ret = head;
        if(head != NULL) {
            head = head->next;
            if(head != NULL) head->prev = NULL;
            ret->prev = NULL;
            ret->next = NULL;
        }
        return ret;
    };
};


int main(void) {
    int n, q;

    char name[10];
    int remaining_time;

    int i;

    scanf("%d %d", &n, &q);

    Queue *queue = new Queue();
    for(i = 0; i < n; i++){
        scanf("%s %d", name, &remaining_time);
        Proc *p = new Proc(name, remaining_time);
        queue->enqueue(p);
    }

    int count = 0;
    while(true) {
        Proc *p = queue->dequeue();
        if(p == NULL) break;
        if(p->remaining_time > q) {
            p->subtract_time(q);
            queue->enqueue(p);
            count += q;
        } else {
            count += p->remaining_time;
            printf("%s %d\n", p->name.c_str(), count);
            delete p;
        }
    }
    return 0;
}

Measured memory_bytes: 7392
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

/*
int main(){
   int a,b;cin>>a>>b;
   if(a>=13) cout<<b<<endl;
   else if(a>=6 and a<=12) cout<<b/2<<endl;
   else cout<<0<<endl;
 //  //return 0;
    return 0;
}*/
map <int,int> box1;//(1000000000,0);
map  <int,int> box2;//(1000000000,0);
int main(){
    ll N,M; cin>>N>>M;
    vector <ll> A(N,0);
    ll amax=-1;
    ll ans = 0;
   set <int> zaatu;
    for(int i=0;i<N;i++) cin>>A[i];
    for(int i=0;i<N;i++){
        box1[A[i]]++;
        //amax = max(amax,A[i]);
        ans += A[i];
        zaatu.insert(A[i]);
    }
    for(int i=0;i<M;i++){
        int b,c; cin>>b>>c;
        box2[c] += b;
        zaatu.insert(c);
    }
     auto itr1 = zaatu.begin(); //int now1 = *itr1;
     auto itr2 = zaatu.end(); itr2--; //int now2 = *itr2;
    while(itr1 != itr2){
        if(box1[*itr1] == 0) {itr1++;continue;}
        if(box2[*itr2] == 0) {itr2--;continue;}
        box1[*itr1]--;
        box2[*itr2]--;
        ans = ans + *itr2 - *itr1;
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 26752
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
		String A = "CODEFESTIVAL2016";
		int count = 0;
		for(int i=0;i<S.length();i++){
			String s = S.substring(i,i+1);
			String a = A.substring(i,i+1);
			if(!s.equals(a)){
				count++;
			}
		}
		System.out.println(count);

	}
}

Measured memory_bytes: 10192
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100005;

int a[N],n;
bool sg;

inline void solve(){
	for(int i=1;i<=n;i++) if(i+1>a[i+1]){
		for(int j=i+1;a[j]==i;j++) sg^=1;
		sg|=(a[i]-i)&1,puts(sg?"First":"Second");
		break;
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	sort(a+1,a+n+1),reverse(a+1,a+n+1);
	
	solve();
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
using namespace std;

constexpr int INF = 1e+9 + 20;

template<typename VEC> inline void import_VEC(VEC& c, int n){
	typename VEC::value_type tmp;
	for(int i = 0; i < n; ++i){	cin >> tmp; c.push_back(tmp);} }

#define SPRE(x) setprecision(x) // 精度を指定

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;
	vector<int> a;
	import_VEC(a, n);

	int nowmin = INF;
	int d_nowmin = 1;
	int nowmax = -1;
	int count = 0;
	for(auto t : a)
	{
		if(t < nowmin){
			nowmin = t;
			d_nowmin = 1;
		}
		else if(t == nowmin)
			d_nowmin++;
		else if(t - nowmin >= nowmax)
		{
			if(nowmax == t - nowmin){
				count += d_nowmin;
			}
			else
			{
				nowmax = t-nowmin;
				count = d_nowmin;
			}

		}
	}
	cout << count << '\n';

}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
string s;
long long ans,cnt;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A') cnt++;
		else if(i+1<s.size()&&s[i]=='B'&&s[i+1]=='C') ans+=cnt,i++;
		else cnt=0;
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 640