akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int a,b,c;
  while(cin>>a>>b>>c){
    if(a==0) break;
    bool possible = false;
    FOR(r,1,a+1){
      int p = a/r;
      if(a%r!=0) continue;
      if(r*r>a) break;
      for(int q=1;q<=abs(c);q++){
        if(abs(c)%q!=0) continue;
        int s=c/q;
        if(p*s+q*r==b&&p*r==a&&q*s==c){
          if(p==r&&q<s) swap(q,s);
          printf("%d %d %d %d\n",p,q,r,s);
          possible = true;
          goto END;
        }
        q*=-1; s*=-1;
        if(p*s+q*r==b&&p*r==a&&q*s==c){
          if(p==r&&q<s) swap(q,s);
          printf("%d %d %d %d\n",p,q,r,s);
          possible = true;
          goto END;
        }
        q*=-1;
      }
    }
    if(c==0){
      int p = a;
      int r = 1;
      int q = b;
      int s = 0;
      if(a==1&&q<s) swap(q,s);
      printf("%d %d %d %d\n",p,q,r,s);
      possible = true;
    }
END:;
    if(!possible){
      cout<<"Impossible"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 904
// AOJ 0182: Beaker

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int n;
int c[52];
char used[52], t[52];

int cmp(int *a, int *b) { return *a - *b; }

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(int k, int r)
{
	if (!r) return 1;
	if (k < 0) return 0;
	if (t[k] && c[k] <= r) {
		t[k] = 0;
		if (calc(k-1, r-c[k])) return 1;
		t[k] = 1;
	}
	return calc(k-1, r);
}

int rec(int k, int r)
{
	int i;

	if (!r) {
		memcpy(t, used, sizeof(t));
		for (i = 0; i < n; i++) {
			if (t[i]) continue;
			if (!calc(i-1, c[i])) return 0;
			t[i] = 1;
		}
		return 1;
	}
	if (r < c[k]) return 0;
	used[k] = 1;
	if (rec(k+1, r-c[k])) return 1;
	used[k] = 0;
	return rec(k+1, r);
}

int main()
{
	int i;

	while (n = in()) {
		for (i = 0; i < n; i++) c[i] = in();
		if (n == 1) { puts("YES"); continue; }
		qsort(c, n, sizeof(int), cmp);
		memset(used, 0, sizeof(used));
		used[0] = 1;
		puts(rec(1, c[n-1]-c[0])? "YES": "NO");
	}
	return 0;
}



Measured memory_bytes: 2032
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        while (true) {
            String op = s.nextLine();
            if (op.equals("=")) break;
            int arg = Integer.parseInt(s.nextLine());
            if (op.equals("+")) n += arg;
            if (op.equals("-")) n -= arg;
            if (op.equals("*")) n *= arg;
            if (op.equals("/")) n /= arg;
        }
        System.out.println(n);
    }
}



Measured memory_bytes: 26480
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, d, x; cin >> n >> d >> x;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  int cnt = 0;
  for(int i=0; i<d; i++){
    for(int j=0; j<n; j++){
      if(i%a[j] == 0) cnt += 1;
    }
  }
  cout << cnt + x << endl;

  return 0;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
 
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");
 
T lread(T = long)()
{
    return readln.chomp.to!T();
}
 
T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}
 
void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a,b;
    scan(a,b);
    (a%b?1:0).writeln();
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

int odd(vector<int> vec) {
    int cnt = 0;
    rep (i, 3)
        if (vec[i] % 2 == 1) cnt++;

    return cnt;
}

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

    vector<int> vec(3);
    rep (i, 3)
        cin >> vec[i];

    int cnt = 0;

    if (odd(vec) == 1) {
        rep (i, 3)
            if (vec[i] % 2 == 0) vec[i]++;
        cnt++;
    } else if (odd(vec) == 2) {
        rep (i, 3)
            if (vec[i] % 2 == 1) vec[i]++;
        cnt++;
    }

    sort(all(vec));
    print((vec[2] * 2 - vec[1] - vec[0]) / 2 + cnt);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const inf = math.MaxInt64

func main() {
	sc.Split(bufio.ScanWords)
	N, A, B, C := getInt(), getInt(), getInt(), getInt()
	l := make([]int, N)
	for i := 0; i < N; i++ {
		l[i] = getInt()
	}

	n := 1
	for i := 0; i < N; i++ {
		n *= 4
	}

	ans := inf

	for i := 0; i < n; i++ {
		a := [4]int{}
		mp := 0
		x := i
		cnt := [4]int{}
		for j := 0; j < N; j++ {
			p := x % 4
			x /= 4
			// fmt.Print(p)
			if a[p] != 0 && p != 0 {
				mp += 10
			}
			cnt[p]++
			a[p] += l[j]
		}
		if cnt[1] == 0 {
			continue
		}
		if cnt[2] == 0 {
			continue
		}
		if cnt[3] == 0 {
			continue
		}
		// out(a, A, B, C)
		mp += abs(a[1] - A)
		mp += abs(a[2] - B)
		mp += abs(a[3] - C)
		ans = min(ans, mp)
		// out(a, mp, "-")
	}
	out(ans)
}


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

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        // その結果を push
        res.push_back({a, ex});
    }
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
  ll N,P;
  cin >> N >> P;
  auto pf = prime_factorize(P);
  ll ans = 1;
  for ( auto p : pf) {
//    cout << " " << p.first << " " << p.second << endl;
    REP(i, p.second/N ) ans *= p.first;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
INF = 100000
while True:
  n = int(input())
  if not n: break
  lst = [int(input()) for _ in range(n)]

  def check(x):
    c1 = c2 = lst[x]
    l = r = x
    b = 0
    for i in range(r, n):
      if lst[i] != c2:
        r = i - 1
        break
    else:
      r = n - 1

    for i in range(l, -1, -1):
      if lst[i] != c1:
        l = i + 1
        break
    else:
      l = 0

    if r - l - b < 3:
      return n
    else:
      b = r - l

    while l > 0 and r < n - 1:
      c1 = lst[l - 1]
      c2 = lst[r + 1]
      if c1 != c2:
        break
      else:
        for i in range(r + 1,n):
          if lst[i] != c2:
            r = i - 1
            break
        else:
          r = n - 1
           
        for i in range(l - 1, -1, -1):
          if lst[i] != c1:
            l = i + 1
            break
        else:
          l = 0

        if r - l - b < 4:
          break
        else:
          b = r - l
    return n - (b + 1)

  ans = INF
  for i in range(n):
    lst[i] = (lst[i] + 1) % 3 + 1
    ans = min(ans, check(i))
    lst[i] = (lst[i] + 1) % 3 + 1
    ans = min(ans, check(i))
    lst[i] = (lst[i] + 1) % 3 + 1
  print(ans)


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

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

int N,K;
long long nd[3000];

int main() {

	cin >> N >> K;

	if(1<=N&&N<=9&&1<=K&&K<=9)
	{
	cout << N*K << endl;
	}
	else
	{
		cout << "-1" << endl;
	}

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
    
    int r;
    cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 384
import numpy as np

N = int(input())

arr = np.empty((N, 3), dtype='int64')
for i in range(N):
    arr[i, 0], arr[i, 1] = input().split()
    arr[i, 2] = arr[i, 0] + arr[i, 1]

arr = arr[np.argsort(arr[:, 2])][::-1]

print(np.sum(arr[::2, 0]) - np.sum(arr[1::2, 1]))

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

int main()
{
    int r ;
    scanf("%d",&r);
    double area1,area2,pi=3.14;
    area1=pi*1*1;
    area2=pi*r*r;
    int z=r*r;
    printf("%d",z);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
const int N=100005;
char a[N],b[N];
int main ()
{
	scanf("%s\n%s",&a,&b);
	int len=strlen(a),len1=strlen(b);
	for(int i=0;i<min(len,len1);i++)
		printf("%c%c",a[i],b[i]);
	if(len>len1) printf("%c",a[len-1]);
	if(len1>len) printf("%c",b[len1-1]);
	return 0;
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    int x,y;
    cin>>x>>y;
    ffor(i,0,x+1)
    {
        if(2*i+4*(x-i)==y)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    
    return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, K;

    cin >> N >> K;

    vector<int> P;

    for(int i = 0; i < N; i++) {
        int p;
        cin >> p;
        P.push_back(p);
    }

    sort(P.begin(), P.end());

    int ans = 0;

    for(int i = 0; i < K; i++) {
        ans += P[i];
    }

    cout << ans << endl;

    return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

ll xs[105],ys[105],hs[105];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n;
  cin>>n;

  for(ll i=0;i<n;i++){
    cin>>xs[i]>>ys[i]>>hs[i];
  }

  for(ll x=0;x<=100;x++){
    for(ll y=0;y<=100;y++){
      ll H = -1;
      ll maxh = -1;
      ll f = true;
      for(ll i=0;i<n;i++){
        ll diff = abs(x-xs[i])+abs(y-ys[i]);
        if(hs[i]==0){
          if(maxh==-1)maxh = diff;
          else maxh = min(maxh, diff);
        } else {
          if (H == -1){
            H = hs[i] + diff;
          }else if (H != -1){
            if (H != hs[i] + diff){
              f = false;
            }
          }
        }
      }
      if(maxh!=-1&&H>maxh)f = false;
      if(H<=0)f = false;
      if(H==-1){
        if(maxh==1)H = 1;
        else f = false;
      }
      if (f){
        cout<<x<<' '<<y<<' '<<H<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
! 2019.10.19
!
      program answer
      implicit none
      integer :: A
      integer :: B
      integer :: ans
!
      read(*,*) A,B
!
      ans = A - 2*B
      if(ans .lt. 0) then
        ans = 0
      end if
      write(*,*) ans
      end program answer


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    ll A,B;
    cin >> A >> B;
    A--;

    ll AA = 0;
    ll num = 0;
    for(int i = 0; i < 50; i++){
        bool bit = (A >> i) & 1;
        if(i == 0 && ((A+1)/2) % 2) AA += 1;
        if(!bit) continue;
        if(num%2 == 0 && i!= 0) AA += 1LL << i;
        num += 1LL << i;
    }

    ll BB = 0;
    num = 0;
    for(int i = 0; i < 50; i++){
        bool bit = (B >> i) & 1;
        if(i == 0 && ((B+1)/2) % 2) BB += 1;
        if(!bit) continue;
        if(num%2 == 0 && i!= 0) BB += 1LL << i;
        num += 1LL << i;
    }

    //cout << AA << endl;
    //cout << BB << endl;

    ll ans;
    if(A == -1) 
        ans = BB;
    else
        ans = AA ^ BB;
    cout << ans << endl;
    return 0;
}


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



int main()
{
	int A, B, C, sum;
	cin >> A >> B >> C;
	if (A > B){
		if (A > C)
			sum = A * 10 + B + C;
		else
			sum = C * 10 + A + B;
			
	}
	else if (B > A){
		if (B > C)
			sum = B * 10 + A + C;
		else
			sum = C * 10 + A + B;
	}
	else{
		if (A > C)
			sum = A * 10 + B + C;
		else
			sum = C * 10 + A + B;
	}
	cout << sum << endl;
}




Measured memory_bytes: 256
r, c, k = map(int, input().split())
item = [[0] * (c + 1) for _ in range(r + 1)]  # dp配列と合わせるために, 0行目, 0列目を追加している.
for _ in range(k):
  i, j, v = map(int, input().split())
  item[i][j] = v

dp = [[[0] * (c + 1) for _ in range(r + 1)] for _ in range(4)]
for i in range(r + 1):
  for j in range(c + 1):
    for k in range(4):
      here = dp[k][i][j]

      if i + 1 <= r:
        dp[0][i + 1][j] = max(dp[0][i + 1][j], here)
        dp[1][i + 1][j] = max(dp[1][i + 1][j], here + item[i + 1][j])

      if j + 1 <= c:
        dp[k][i][j + 1] = max(dp[k][i][j + 1], here)
        if k < 3:
          dp[k + 1][i][j + 1] = max(dp[k + 1][i][j + 1], here + item[i][j + 1])

ans = max(dp[k][-1][-1] for k in range(4))
print(ans)

Measured memory_bytes: 428952
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
char d[N];
long double x[N],y[N];
int n;
long double f(long double t){
	long double xmax = -inf , xmin=inf , ymax= -inf , ymin= inf;
	for(int i=0;i<n;i++){
		if(d[i]=='L') xmin=min(xmin,x[i]-t) , xmax=max(xmax,x[i]-t);
		else if(d[i]=='R') xmin=min(xmin,x[i]+t),xmax=max(xmax,x[i]+t);
		else
			xmax=max(xmax,x[i]),xmin=min(xmin,x[i]);
	}
	for(int i=0;i<n;i++){
		if(d[i]=='D') ymin=min(ymin,y[i]-t) , ymax=max(ymax,y[i]-t);
		else if(d[i]=='U') ymin=min(ymin,y[i]+t),ymax=max(ymax,y[i]+t);
		else
			ymax=max(ymax,y[i]),ymin=min(ymin,y[i]);
	}
	return (xmax-xmin)*(ymax-ymin);
 
}
signed main(){
  fast;
  cin>>n;
  for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>d[i];
 
  long double l = 0 , r = 1000000000,md1,md2;
  for(int j=1;j<=500;j++){
  	  md1=l+(r-l)/3 , md2= l+(r-l)*2/3;
  	  if(f(md1)<=f(md2)) r=md2;
  	  else l = md1;
  }
  cout<<fixed<<setprecision(12)<<f(r)<<endl;
}
  

Measured memory_bytes: 3456
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int a, b;
    scan(a, b);
    int ans = max(2*a - 1, 2*b - 1, a + b);
    writeln(ans);
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,m,c,a,cnt=0,s=0;
	cin>>n>>m>>c;
	vi b(m);
	REP(i,0,m-1)cin>>b[i];
	REP(i,0,n-1)
	{
		REP(j,0,m-1){
			cin>>a;
			s+=a*b[j];
		}
		if(s+c>0)cnt++;
		s=0;
	}
	cout<<cnt;
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 384
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#x = int(input())
#n, m = map(int, sys.stdin.readline().split())
s = input()
t = input()
#h = list(map(int, sys.stdin.readline().split()))

for i in range(len(s)):
    if s[i] != t[i]:
        print("No")
        sys.exit()

print("Yes")


Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n,m,a[N];
int main()
{
	scanf("%d%d",&n,&m);
	int odd=0;
	for (int i=1;i<=m;i++) scanf("%d",&a[i]),odd+=(a[i]&1);
	if (odd>2) return puts("Impossible"),0;
	if (m==1){
		printf("%d\n",n);
		if (n==1) printf("1\n1\n");
			else printf("2\n%d %d\n",n-1,1);
		return 0;
	}
	for (int i=1;i<=m;i++)
		if (a[i]&1) swap(a[1],a[i]);
	for (int i=2;i<=m;i++)
		if (a[i]&1) swap(a[i],a[m]);
	for (int i=1;i<=m;i++) printf("%d ",a[i]);
	puts("");
	if (a[1]==1) printf("%d\n",m-1);
		else printf("%d\n%d ",m,a[1]-1);
	for (int i=2;i<m;i++) printf("%d ",a[i]);
	printf("%d\n",a[m]+1);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,d,r;
  double f=0.0;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;
  printf("%d %d %f\n",d,r,f);
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) cout << c;
    if (b == c) cout << a;
    if (a == c) cout << b;
}


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

using GraphType = vector<vector<pair<int,int>>>;
template<typename Int>
bool Bellman_Ford(GraphType& Graph, vector<Int>& dist, int V, int start){
    dist[start] = 0;
    for(int i=0;i<V;++i){
        for(int v=0;v<V;++v){
            for(auto& e : Graph[v]){
                if(dist[v] == 1e18) continue;
                if(dist[e.first] > dist[v] + e.second){
                    dist[e.first] = dist[v] + e.second;
                    if(i == V-1) return true;
                }
            }
        }
    }
    return false;
}

int main(){
    i64 N, M, P;
    cin >> N >> M >> P;
    vector<int> A(M), B(M);
    vector<i64> C(M);
    rep(i, M) cin >> A[i] >> B[i] >> C[i], A[i]--, B[i]--;

    vector<i64> C_inv(M);
    rep(i, M) C_inv[i] = -(C[i] - P);
    
    vector<bool> visited(N, false);
    {   
        vector<vector<int>> Graph(N);
        rep(i, M) Graph[B[i]].emplace_back(A[i]);
        function<void(int)> dfs = [&](int v){
            visited[v] = 1;
            for(int nxt : Graph[v]){
                if(visited[nxt]) continue;
                dfs(nxt);
            }
        };
        dfs(N-1);
    }

    vector<vector<pair<int,int>>> Graph(N);
    vector<i64> dist(N, 1e18);

    rep(i, M){
        if(!visited[A[i]] || !visited[B[i]]) continue;
        Graph[A[i]].emplace_back(make_pair(B[i], C_inv[i]));
    }
    bool circle = Bellman_Ford(Graph, dist, N, 0);

    if(circle) cout << -1 << endl;
    else cout << max(-dist[N-1], (i64)0) << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
//using static Util;
class Program
{
    static int N;
    static void INPUT()
    {
        N = NextInt();
    }
    static void OUT()
    {
        var list = new List<long>() { 1,2,3,4,5,6,7,8,9};
        var ans = new List<long>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        if (N > 10)
        {
            N -= 9;
            while (true)
            {
                var nlist = new List<long>();
                foreach (var L in list)
                {
                    var left = L % 10;
                    for (var i = -1; i <= 1; i++)
                    {
                        var nn = left + i;
                        if (nn < 0 || nn >= 10) continue;
                        N --;
                        var nnn = L * 10 + nn;
                        nlist.Add(nnn);
                        if (N == 0)
                        {
                            Console.WriteLine(nnn);
                            return;
                        }
                    }
                }

                list.Clear();
                list = nlist;
            }
        }
        else
        {
            Console.WriteLine(N);
        }
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}




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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;


int main(){
    int n, x;
    cin >> n >> x;
    vector<vector<int>> cost(n, vector<int>(n, pow(10, 9)+5));
    rep(i, n)   cin >> cost[i][0];

    rep(i, n){
        for(int step = 1; step < n; step++){
            int m = (i+step) % n;
            if(cost[i][0] < cost[m][step])  cost[m][step] = cost[i][0];
        }
    }

    rep(i, n){
        int minv = cost[i][0];
        for(int step = 1; step < n; step++){
            if(minv < cost[i][step])    cost[i][step] = minv;
            else                        minv = cost[i][step];
        }
    }

    ull sum = 0;
    rep(i, n)   sum += cost[i][0];

    for(int step = 1; step < n; step++){
        ull newsum = 0;
        rep(i, n){
            newsum += cost[i][step];
            if(sum <= newsum)   break;
        }
        
        if(newsum + step*x < sum)   sum = newsum + step*x;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <cstdio> 
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
#define N 1000050
int read()
{
	int s=0,p=1;
	char st=getchar();
	while(st<'0' || st>'9')
	{
		if(st=='-')p=-1;
		st=getchar();
	}
	while(st>='0' && st<='9')
	{
		s=(s<<1)+(s<<3)+(st^48);
		st=getchar();
	}
	return s*p;
}
void print(int x)
{
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	if(x>9)
	{
		print(x/10);
	}
	putchar(x%10+'0');
}
int n,m,tot;
int a[N],sum[N],tong[N],nxt[N],ans[N],last[N];
struct node
{
	int l,r,id;
}ask[N*2];
int cmp(node aa,node bb)
{
	return aa.r<bb.r;
}
int lowbit(int x){return x&(-x);}
void add(int k,int zhi){for(int i=k;i<=n+1;i+=lowbit(i))sum[i]+=zhi;}
int query(int k){int ans=0;for(int i=k;i;i-=lowbit(i))ans+=sum[i];return ans;}
int main()
{
	n=read();
	m=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=m;i++)ask[i].l=read(),ask[i].id=i,ask[i].r=read();
	sort(ask+1,ask+m+1,cmp);
	int now=1;
	for(int i=1;i<=m;i++)
	{
		while(now<=ask[i].r)
		{
			if(last[a[now]])add(last[a[now]],-1);
			add(last[a[now]]=now,1);
			now++;
		}
		ans[ask[i].id]=query(ask[i].r)-query(ask[i].l-1);
	}
	for(int i=1;i<=m;i++)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 17412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353

ll gcd(ll A, ll B){
    if(A<B) swap(A,B);
    while(B){
        ll w = A%B;
        A = B;
        B = w;
    }
    return A;
}

ll lcm(ll A, ll B){return A*B/gcd(A,B);}

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

    // solution comes here

    ll N;
    cin >> N;
    vl a(N);
    rep(i, N) cin >> a[i];

    ll ans=0;
    rep(i, N) ans += a[i]-1;
    cout << ans << nl;
}


Measured memory_bytes: 256
A = input()
B = list(input().split())
import collections
C = collections.Counter(B)
list_after = {}
list_n = C.items()
total = 0
for i in list_n:
    total += i[1] * (i[1]-1) / 2
for i in list_n:
    list_after[i[0]] = total - (i[1] * (i[1]-1) / 2 - (i[1]-1) * (i[1]-2) / 2)
for i in B:
    print(int(list_after[i]))

Measured memory_bytes: 38948
N = int(input())

def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
 
if len(divisor(N)) < 3:
    print(N - 1)
else:
    divisor_list = divisor(N)
    tmp = N
    for i in divisor_list:
        A = i
        B = N / i
        if tmp > (A + B - 2):
            tmp = (A + B - 2)
    print(int(tmp))


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

typedef long long ll;

int main() {
    int N, a;
    cin >> N;
    set<int> s;
    rep(i, N) {
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 7748
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  string s;
  cin >> s;
  int n = s.size();
  if(s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << "-1\n";
    return 0;
  }
  else if(n < 26) {
    int cnt[26] = { 0 };
    for(char c: s)
      cnt[c - 'a']++;
    fi(0, 26) {
      if(!cnt[i]) {
        s += (char)(i + 'a');
        break;
      }
    }
  }
  else {
    string t = s;
    next_permutation(all(t));
    int i = 0;
    for(; t[i] == s[i]; i++);
    s = t.substr(0, i + 1);
  }
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		int K = Integer.parseInt(W);

		int indx = 0;
		long ans = 1;
		ArrayList<Long> list = new ArrayList<>();

		for(int i=1;i<10;i++){
			list.add((long)i);
		}
		long tmp ;
		int lastNum = 0;
		String tmpS ;
		while(list.size() < K){
			tmp = list.get(indx);
			//下一桁を取得
			tmpS = String.valueOf(tmp);
			lastNum=9-('9' - tmpS.charAt(tmpS.length()-1));
			if(lastNum!=0){
				list.add(tmp*10+lastNum-1);
			}
			list.add(tmp*10+lastNum);
			if(lastNum!=9){
				list.add(tmp*10+lastNum+1);
			}
			indx++;
		}

		Collections.sort(list);

		System.out.println(list.get(K-1));



//		HashMap<String,Boolean> map = new HashMap<String,Boolean>();
//		map.put("0", true);
//		map.put("00", true);
//		while(C < K){
//			String S=String.valueOf(ans);
//			if(S.length()==1){
//				C++;
//				map.put(S,true);
//				if(S.charAt(0)==1){
//					map.put("0"+S, true);
//				}
//			}else if(Math.abs(('9'-S.charAt(0))-('9'-S.charAt(1)))<=1){
//				if(map.containsKey(S.substring(1,S.length()))){
//					C++;
//					map.put(S, true);
//					if(S.charAt(0)==1){
//						map.put("0"+S, true);
//					}
//				}
////				}else{
////					if(S.charAt(1)=='0'&&(S.charAt(2)=='0'||S.charAt(2)=='1')){
////						//100の場合に00が存在しない扱いになるため
////						C++;
////						map.put(S, true);
////						map.put(S.substring(1,S.length()), true);
////
////					}
////
////				}
//			}
//			ans++;
//
//		}
//		System.out.println(ans-1);

	}
}


Measured memory_bytes: 29908
#include <iostream>
using namespace std;
int main()
{
    int a = 0;
    int b = 0;
    int c = 0;
    int ab = 0;
    int ac = 0;
    int bc = 0;
    cin >> a;
    cin >> b;
    cin >> c;
    ab = a + b;
    ac = a + c;
    bc = b + c;
    if(ab <= ac)
    {
        if(ab <= bc)
        {
            cout<<ab;
        }
        else if(bc < ab)
        {
            cout<<bc;
        }
    }
    else if(ac < ab)
    {
        if(ac <= bc)
        {
            cout<<ac;
        }
        else if(bc < ac)
        {
            cout<<bc;
        }
    }
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector <int> a(n + 1);
    vector <long long> cumulative_sum(n + 1, 0);
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];
        cumulative_sum[i] += a[i] + cumulative_sum[i - 1];
    }
    constexpr int MOD = 1000000007;
    long long sum = 0;
    for(int i = 1 ; i < n ; ++i){
        sum = (sum + (((cumulative_sum[n] - cumulative_sum[i]) % MOD) * a[i]) % MOD) % MOD;
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 110
using namespace std;
ll n,a[N],ans=LINF;
int main(){
	ll i,j,tmp;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<=101;i++)
	{
		tmp=0;
		for(j=0;j<n;j++)
		{
			tmp+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())

a=list(map(int,input().split()))

cnt=[0]*(n+1)
for i in range(n):
    cnt[a[i]]+=1 
aa=0
ans=[]
for i in range(n+1):
    aa+=(cnt[i]*(cnt[i]-1)//2)
for i in range(n):
    print(aa-(cnt[a[i]]*(cnt[a[i]]-1))//2 +((cnt[a[i]]-1)*(cnt[a[i]]-2))//2, end ="\n")
    
    

Measured memory_bytes: 26140
n, k = [int(i) for i in input().split()]
ans = 0
mod = 10 ** 9 + 7
for i in range(k, n + 2):
    ans += (n+1)*(n)//2-(n - i) * (n + 1 - i) // 2 - (i) * (i - 1) // 2+1
    ans %= mod
    #print(i, (n+1)*(n)//2, (n - i) * (n + 1 - i) // 2, (i) * (i - 1) // 2)

print(ans)


Measured memory_bytes: 9184
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int w, h, n;
  cin >> w >> h >> n;
  int x1 = 0;
  int y1 = 0;
  int x2 = w;
  int y2 = h;
  REP(i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1) {
      x1 = max(x1, x);
    } else if(a == 2) {
      x2 = min(x2, x);
    } else if(a == 3) {
      y1 = max(y1, y);
    } else if(a == 4) {
      y2 = min(y2, y);
    } else {
      assert(false);
    }
  }
  int xx = max(x2 - x1, 0);
  int yy = max(y2 - y1, 0);
  printf("%d\n", xx * yy);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int[] a = new int[m];
    for(int i = 0;i<m;i++){
      a[i] = sc.nextInt();
    }

    int mae = 0;
    int usiro = 0;
    for(int i = 0;i<m;i++){
      if(a[i] < x){
        mae++;
      }else{
        usiro++;
      }
    }
    int ans = Math.min(mae,usiro);
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
	
using namespace std;
 
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()

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

const int N = 2e5 + 10;

int a[N];

int main(){
	#ifdef HOME
	freopen("input.txt", "rt", stdin);
	#endif //HOME
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n; 	
	int ans = 0;
	int dig = 10;
	int cur = 1;
	for (int i = 1; i <= n; i++){
		if (i == dig) {
			cur++;
			dig *= 10;
		}
		if (cur % 2 == 1)
			ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] vals = reader.readLine().split(" ");
        long N = Long.parseLong(vals[0]);
        long K = Long.parseLong(vals[1]);
        Map<Long, Long> map = new TreeMap<>();
        for (int i = 0; i < N; i++) {
            vals = reader.readLine().split(" ");
            long a = Long.parseLong(vals[0]);
            long b = Long.parseLong(vals[1]);
            if (map.containsKey(a)) {
                map.put(a, map.get(a) + b);
            } else {
                map.put(a, (long) b);
            }
        }
        for (long key : map.keySet()) {
            long num = map.get(key);
            if (num >= K) {
                System.out.println(key);
                return;
            } else {
                K -= num;
            }
        }
    }
}


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

int K, a[210][210];
int ans = 0;
int main() {
    cin >> K;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++) a[i][j] = __gcd(i, j);
    }
    for(int i = 1; i <= K; i++) {
        for(int j = 1; j <= K; j++) {
            for(int k = 1; k <= K; k++) ans += a[a[i][j]][k];
        }
    }
    cout << ans;
}

Measured memory_bytes: 3792
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = []
    B = []
    C = []
    for _ in range(N):
        a, b, c = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)
        C.append(c)
    
    dp = [[0 for i in range(3)] for i in range(N)]
    dp[0][0] = A[0]
    dp[0][1] = B[0]
    dp[0][2] = C[0]
    for i in range(1, N):
        dp[i][0] = A[i] + max(dp[i - 1][1], dp[i - 1][2])
        dp[i][1] = B[i] + max(dp[i - 1][0], dp[i - 1][2])
        dp[i][2] = C[i] + max(dp[i - 1][1], dp[i - 1][0])
    
    print(max(dp[N - 1]))




if __name__ == '__main__':
    main()



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

int main() {
    int a[2],ans=0;cin>>a[0]>>a[1];
    sort(a,a+2);
    ans+=a[1];
    a[1]-=1;
    sort(a,a+2);
    ans+=a[1];
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
	
	int a, b, c;
	
	while( std::cin >>a >> b >> c ) {
	
	if( a < b && b < c)
	std::cout << "Yes\n";
	
	else
	std::cout << "No\n";
	
	}
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main(){
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s (D, vector<int>(26));
    vector<int> t(D);    

    /// 入力部分 ///
    REP(i, 26){
        cin >> c[i];
    }
    REP(i, D){
        REP(j, 26){
            cin >> s[i][j];
        }
    }
    REP(i, D){
        cin >> t[i];
    }

    int M;
    cin >> M;

    vector<int> d(M);
    vector<int> q(M);
    REP(i, M){
        cin >> d[i];
        cin >> q[i];
    }
    /////////

    /// 実行部分 ///
    REP(k, M){
        t[d[k]-1] = q[k];
        vector<int> last(26);
        ll st = 0, los = 0;
        REP(i, D){
            st += s[i][t[i]-1];
            last[t[i]-1] = i+1;
            //cout << st << endl;   //満足度の低下を考えない場合
            REP(j, 26){
                los += c[j]*(i+1 - last[j]);
            }
            //cout << st << endl;
        }
        cout << st - los << endl;
    }
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
   int n;
   cin >> n;
   ll a[n];
   ll max_size = 0;
   rep(i, n) { 
       cin >> a[i];
       max_size += a[i];
   }
   ll min_size = max_size, sum = 0;
   rep(i, n) { 
       sum += a[i];
       min_size = min(min_size, abs(sum - (max_size - sum)));
   }
   cout << min_size << endl;
   return 0;
}

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

char s[202020];

int main()
{
	scanf("%s", s);
	int len = strlen(s);
	
	long long ans = 0, sum = 0;
	
	for(int i = 0; i < len; i++)
	{
		if(s[i] == 'A')
			sum++;
		else if(s[i] == 'B' && s[i + 1] == 'C')
		{
			ans += sum;
			i++;
		}
		else
		{
			sum = 0;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c;
  cin>>k;

  int m=0;
  m=max(a,b);
  m=max(m,c);
  int x=m;
  for(int i=0;i<k;i++){
    m*=2;
  }
  cout<<m+a+b+c-x<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n;
    cin >> n;
    vector<pair<int,int>> arr(n);
    for(int i = 0; i < n; ++i){
        cin >> arr[i].first >> arr[i].second;
    }
    vector<ll> V(n);
    for(int i = 0; i < n; ++i){
        V[i] = arr[i].first + arr[i].second;
    }
    ll mn = *min_element(V.begin(), V.end());
    ll mx = *max_element(V.begin(), V.end());
    ll ans = mx - mn;

    for(int i = 0; i < n; ++i){
        V[i] = arr[i].first - arr[i].second;
    }
    mn = *min_element(V.begin(), V.end());
    mx = *max_element(V.begin(), V.end());
    ans = max(ans, mx - mn);

    for(int i = 0; i < n; ++i){
        V[i] = arr[i].second - arr[i].first;
    }
    mn = *min_element(V.begin(), V.end());
    mx = *max_element(V.begin(), V.end());
    ans = max(ans, mx - mn);
    cout << ans << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 6392