akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
const int inf   = 1<<29;
const ll  mod = 998244353;
ll fact[500001],invfact[500001];

int main(){
  int n;cin>>n;
  string s;cin>>s;
  char ans[n+1];
  ans[0]='S';ans[1]='S';
  rep(i,n){
    if(ans[i]==ans[i+1]^s[i]=='x')
      ans[i+2]='S';
    else ans[i+2]='W';
    }
  if(ans[0]==ans[n]&&ans[1]==ans[n+1]){
    rep(i,n)cout<<ans[i+1];
    cout<<endl;
    return 0;
    }
  ans[0]='S';ans[1]='W';
  rep(i,n){
    if(ans[i]==ans[i+1]^s[i]=='x')
      ans[i+2]='S';
    else ans[i+2]='W';
    }
  if(ans[0]==ans[n]&&ans[1]==ans[n+1]){
    rep(i,n)cout<<ans[i+1];
    cout<<endl;
    return 0;
    }
  ans[0]='W';ans[1]='S';
  rep(i,n){
    if(ans[i]==ans[i+1]^s[i]=='x')
      ans[i+2]='S';
    else ans[i+2]='W';
    }
  if(ans[0]==ans[n]&&ans[1]==ans[n+1]){
    rep(i,n)cout<<ans[i+1];
    cout<<endl;
    return 0;
    }
  ans[0]='W';ans[1]='W';
  rep(i,n){
    if(ans[i]==ans[i+1]^s[i]=='x')
      ans[i+2]='S';
    else ans[i+2]='W';
    }
  if(ans[0]==ans[n]&&ans[1]==ans[n+1]){
    rep(i,n)cout<<ans[i+1];
    cout<<endl;
    return 0;
    }
  cout<<-1<<endl;
  return 0;
  }

Measured memory_bytes: 640
output = function() {
	console.log.apply( console, arguments );
};

(function kuku( a, b ) {
	if ( a > 9 )
		return;
	if ( b > 9 )
		return kuku( a + 1, 1 );
	output( '%dx%d=%d', a, b, a * b );
	return kuku( a, b + 1 );
})( 1, 1 );

Measured memory_bytes: 8568
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
let ( *^ ) x y = (x * y) mod m
let ( /^ ) x y = power ( *^ ) x y (m - 2)

let () = Scanf.scanf "%d %s" @@ fun k s ->
  (* comb.(i) = (|S| - 1 + i)C(|S| - 1) *)
  let comb = Array.make (k + 1) 0 in
  comb.(0) <- 1;
  for i = 1 to k do
    comb.(i) <- (String.length s - 1 + i) *^ comb.(i - 1) /^ i
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( +^ ) 0 @@
  Array.init (k + 1) @@ fun i ->
    power ( *^ ) (power ( *^ ) comb.(k - i) 25 (k - i)) 26 i


Measured memory_bytes: 22904
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int ans = 0;
    REP(i,5){
        int t; cin >> t;
        if(t == 0){
            ans = i+ 1;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int k[10000000];
int main(){
  string s;
  int n,ans=1;
  cin>>n>>s;
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1]) ans++;
  }
  cout<<ans<<"\n";
  return(0);
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//解説ガン見

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[5001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

ll B[200][5001], C[5002][5002];
int daishou[5002];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), M = getint();
	rep1(i, N - 1) C[i][i + 1] = -getint();
	rep1(i, N) rep(j, M) B[j][i] = ((ll)i << 32) + getint();

	const ll m = (1ll << 32) - 1;
	rep(i, M) {
		memset(daishou, 0, sizeof(daishou));
		pakuri_sort(N, B[i] + 1);
		rep1(j, N) {
			int b = B[i][j] & m;
			int x = B[i][j] >> 32;

			daishou[x] = x;
			int shou = daishou[x - 1];
			if (!shou) shou = x;
			int dai = daishou[x + 1];
			if (!dai) dai = x;

			C[x][x] += b;
			C[shou - 1][dai + 1] += b;
			C[x][dai + 1] -= b;
			C[shou - 1][x] -= b;
			daishou[dai] = shou;
			daishou[shou] = dai;
		}
	}
	ll kotae = 0;
	rep1(i, N) if (kotae < C[i][i]) kotae = C[i][i];
	rep1(i, N) for (int j = i + 1; j <= N; j++) {
		C[i][j] += C[i][j - 1];
	}
	rep1(j, N) for (int i = j - 1; i >= 1; i--) {
		C[i][j] += C[i + 1][j];
		if (kotae < C[i][j]) kotae = C[i][j];
	}
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 203648
n,m = map(int,input().split())
s = []
k = []
p = []
count = 0
for i in range(m):
    q = input().split()
    k.append(int(q[0]))
    q.remove(q[0])
    s.append(q)
    #print(q)
    for j in range(k[i]):
        s[i][j] = int(q[j])
        #print(s)
    
q = input().split()
for j in range(m):
        p.append(int(q[j]))
        #count.append([0])
#入力終了

       
for i in range(pow(2,n)):
    list = []
    for o in range(n):
        list.append(i%2)
        i = i // 2
    #print(list)
    q = 0
    for j in range(m):
        wa = 0
        for l in range(k[j]):
            wa += list[s[j][l]-1]
        #print(wa)
        if wa%2 == p[j]:
            q += 1
            #print(q)
        else:
            break
    if q == m:
        count += 1

#kotae = count[0]
#for i in range(1,m):
    #kotae *= count[i]

#print(kotae)
print(count)


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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}


int main(){
  int n,m;
  cin >> n >> m;
  int a,b;
  pair<int ,int> v[1000000];
  FOR(i,m){
    cin >> a >> b;
    v[i]=make_pair(b,a);
  }
    sort(v,v+m);
    int maxi=-1;
    int ans=0;
    FOR(i,m){
      if(v[i].second>maxi){maxi = v[i].first-1;ans++;}
    }

    cout << ans << endl;

  }


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <cmath>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    ll t;
    cin >> t;
    vector<ll> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    vector<ll> a(n, 0LL);
    for (int i = 0; i < n; i++) {
        a[i] = (i == 0 ? 0 : a[i - 1]) + h[i];
    }
    vector<ll> b(n, 0LL);
    vector<ll> head(n, 0LL);
    for (int i = 0; i < n; i++) {
        if (i == 0 or b[i - 1] <= a[i]) {
            head[i] = i;
            b[i] = a[i] + h[i];
        } else {
            head[i] = head[i - 1];
            b[i] = b[i - 1] + h[i];
        }
    }
    for (int i = 0; i < n; i++) {
        const ll period = h[head[i]];
        if (t < a[i]) {
            cout << 1 << endl;
        } else {
            const ll tim = t - a[i];
            cout << (tim / period) + 2LL << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 5996
def solve():
    N = int(input())
    xy_l = [None] * N
    invxy_l = [None] * N
    for _ in range(N):
        _x, _y = map(int, input().split())
        xy_l[_] = _x + _y - 2
        invxy_l[_] = _y - 1 - (_x - 1)

    ans_a = max(xy_l) - min(xy_l)
    ans_b = max(invxy_l) - min(invxy_l)

    if ans_a > ans_b:
        print(ans_a)
    else:
        print(ans_b)


solve()


Measured memory_bytes: 24700
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 max = 0;
        for (int i = 0; i < n; i++) {
            int count = 0;
            for (int j = 0; j < m; j++) {
                count += sc.nextInt();
            }
            max = Math.max(max, count);
        }
        System.out.println(max);
    }
    
}


Measured memory_bytes: 27056
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using i64=long long int;

int main() {
    int Q, H, S, D;
    cin >> Q >> H >> S >> D;
    i64 N;
    cin >> N;
    N *= 4;

    H = min(Q*2, H);
    S = min(H*2, S);
    D = min(S*2, D);

    i64 ans = 0;
    ans += (N / 8) * D;
    N = N % 8;
    ans += (N / 4) * S;
    N = N % 4;
    ans += (N / 2) * H;
    N = N%2;
    ans += N * Q;

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


Measured memory_bytes: 256
from collections import deque

def main():
    with open(0) as f:
        N, *Temp = map(int, f.read().split())
        T, V = Temp[:N], Temp[N:]
        del Temp
    #v-tグラフを仮定して、各区間の境界条件を求める
    v_left = deque([0]) #初期時刻から走査した結果
    v_right = deque([0]) #終了時刻から走査した結果
    #区間i(1<=i<=N)の境界条件は [min(vin[i-1], vout[i-1]), max(vin[i], vout[i])
    #走査処理
    now = 0
    for t,v in zip(T, V):
        now = min(now+t, v)
        v_left.append(now)
    now = 0
    for t, v in zip(reversed(T), reversed(V)):
        now = min(now+t, v)
        v_right.appendleft(now)

    BC = [min(x,y) for x,y in zip(v_left, v_right)] #境界条件
    #区間ごとに2倍の面積計算
    S = [squareMeasure(vin, vout, vsup, t) for vin, vout, vsup, t in zip(BC[:N], BC[1:], V, T)]
    ans = sum(S)/2
    print(ans)

def squareMeasure(vin, vout, vsup, t):
    vmax = (t+vout+vin)/2 #y=x+vinとy=-x+t+vout の交点のy
    if vmax > vsup:
        a, b = vsup-vin, t+vout-vsup #y=vsupと2直線の交点
        S = (vin+vsup)*a + 2*(b-a)*vsup + (vsup+vout)*(t-b)
    else:
        S = (vin+vmax)*(vmax-vin) + (vmax+vout)*(t+vin-vmax)
    return S #2倍の面積である

if __name__ == '__main__':
    main()

Measured memory_bytes: 9252
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	int i, j, n, k, x, y;
	vi a;

	cin >> n >> x;
	a.resize(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	y = 0;
	i = 0;
	while (x >= a[i] && i < n) {
		y++;
		x -= a[i];
		i++;
	}
	if (x != 0 && i >= n) {
		y--;
	}

	cout << y;

	return 0;
}

Measured memory_bytes: 256
// AOJ 2009: Area Separation
// 2017.10.30 bal4u@uu

#include <stdio.h>
#include <math.h>

#define EPS 1e-10

typedef struct { double x, y; } PP;
typedef struct { PP p1, p2; } SEG;
SEG sg[102]; int n;
PP pp[102]; int sz;

double dis(PP p1, PP p2)
{
	double dx = p1.x - p2.x;
	double dy = p1.y - p2.y;
	return sqrt(dx*dx + dy*dy);
}

int one(PP p1, PP p2)
{
	return p1.x == p2.x && p1.y == p2.y;
}

int intersection(PP *p, PP p1, PP p2, PP p3, PP p4)
{
   int t1, t2, t3, t4;
   double bo, ua;

   t1 = (p1.y-p3.y)*(p3.x-p4.x)-(p1.x-p3.x)*(p3.y-p4.y);
   t2 = (p2.y-p3.y)*(p3.x-p4.x)-(p2.x-p3.x)*(p3.y-p4.y);
   t3 = (p3.y-p1.y)*(p1.x-p2.x)-(p3.x-p1.x)*(p1.y-p2.y);
   t4 = (p4.y-p1.y)*(p1.x-p2.x)-(p4.x-p1.x)*(p1.y-p2.y);
   if ((t1 < 0 && t2 > 0 || t1 > 0 && t2 < 0) && (t3 < 0 && t4 > 0 || t3 > 0 && t4 < 0)) {
      bo = (p4.y-p3.y)*(p2.x-p1.x)-(p4.x-p3.x)*(p2.y-p1.y);
      ua = (p4.x-p3.x)*(p1.y-p3.y)-(p4.y-p3.y)*(p1.x-p3.x);
      p->x = p1.x + ua/bo * (p2.x-p1.x);
      p->y = p1.y + ua/bo * (p2.y-p1.y);
      return 1;
   } else return 0;
}

int main()
{
	int i, j, k, f, ans;
	PP p;

	while(scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++)
			scanf("%lf%lf%lf%lf", &sg[i].p1.x, &sg[i].p1.y, &sg[i].p2.x, &sg[i].p2.y);
		ans = 1;
		for (i = 0; i < n; i++) {
			sz = 0;
			for (j = 0; j < i; j++) {
				if (!intersection(&p, sg[i].p1, sg[i].p2, sg[j].p1, sg[j].p2)) continue;
				if (one(p, sg[i].p1) || one(p, sg[i].p2) || one(p, sg[j].p1) || one(p, sg[j].p2)) continue;
				
				for (f = 1, k = 0; k < sz; k++) {
					if (dis(p, pp[k]) < EPS) { f = 0; break; }
				}
				if (f) pp[sz++] = p;
			}
			ans += sz + 1;
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;

  vector<int> xc(n+1);
  vector<int> yc(m+1);

  xc[0] = x;
  yc[0] = y;

  for(int i=1; i<=n; i++) 
    cin >> xc[i];

  for(int i=1; i<=m; i++)
    cin >> yc[i];

  sort(xc.begin(),xc.end(), greater<int>());
  sort(yc.begin(), yc.end());

  if (xc[0] >= yc[0])
      cout << "War" << endl;
  else
    cout << "No War" << endl;
}

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

int main(){
  int N,A[100000];
  cin >> N;
  for(int i = 0 ;i < N;i++){
    cin >> A[i];
  }
   int num[100000] = {0};
   int t = 1;
    for (int i = 0; i < N; ++i) {
      num[t]++;
      if (num[t] >= 2){
        cout << -1 << endl;
        break;
      }
      t = A[t-1];
      if(t == 2){
        cout << i+1 << endl;       
        break; 
      }
    }
}
  


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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<ll,ll>

const int maxn=2e5+10;
const ll maxN=1e18+10;

ll ST[maxn],a[maxn];

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  map <ll,ll> dd;
  FOR(i,1,n) {
  	int h;
  	cin >> h;
  	if (dd[h]==1) {
  		cout << "NO";
  		exit(0);
  	}
  	dd[h]=1;
  }
  cout << "YES";
}
    

Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    out((a-1)*(b-1));

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool chkmax(int &x,int y){return x<y?x=y,true:false;}
bool chkmin(int &x,int y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,l;
ll t[3005];
const ld pi=acos(-1);

int main(){
	n=readint(); l=readint();
	for(int i=1;i<=n;i++) t[i]=readint();
	sort(t+1,t+n+1);
	ld ansx=0,ansy=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			ll num=n-2-2*(j-i-1);
			ld alp=pi*(t[i]+t[j])/l;
			ansx+=cos(alp)*num,ansy+=sin(alp)*num;
		}
	}
	printf("%.15Lf %.15Lf\n",ansx*6/n/(n-1)/(n-2),ansy*6/n/(n-1)/(n-2));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

/*int H,W;
vector<vector<int>> field;

void dfs(int h, int w){
   field[h][w] = 0;
   
   for(int dh = -1; dh <= 1; dh++){
      for(int dw = -1; dw <= 1; dw++){
         int nh = h + dh;
         int nw = w + dw;
      
         if(nh < 0 || nh >= H || nw < 0 || nw >= W)continue;
         if(field[nh][nw] == 0)continue;

         dfs(nh, nw);
      }
   }
}*/

int main(){
   int n,m; cin >> n >> m;
   vector<int> l(m);
   vector<int> r(m);
   rep(i,m) cin >> l[i] >> r[i];
   int left = 0;
   int right = INFINITY;
   rep(i,m){
      if(i == 0){
         left = l[i];
         right = r[i];
      }else{
         if(l[i] > left)left = l[i];
         if(r[i] < right)right = r[i];
      }
   }
   print(max(right - left + 1,0));
} 

Measured memory_bytes: 1024
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <queue>
using namespace std;

int main() {
	// 入力データからグラフを構築する //
	int NV, NE;
	cin >> NV >> NE;
	vector<int> inDeg(NV, 0); // 0>=:入力数, -1:探索キューに追加済み
	vector<vector<int> > graph(NV);
	for (int i = 0; i < NE; i++) {
		int s, t;
		cin >> s >> t;
		graph[s].push_back(t);
		inDeg[t]++;
	}

	// トポロジカルソートを実行する //
	list<int> ans;
	// 幅優先探索でグラフを探索する
	queue<int> q;
	// 探索用キューに始点を設定
	for (int i = 0; i < NV; i++) {
		if (inDeg[i] == 0) {
			q.push(i);
			inDeg[i] = -1;
		}
	}
	// 幅優先探索を実行する
	while (!q.empty()) {
		int u = q.front(); q.pop();
		ans.push_back(u);
		// 隣接リストを探索し、前処理が0になったら探索キュー追加
		for (unsigned int i = 0; i < graph[u].size(); i++) {
			int v = graph[u][i];
			if (inDeg[v] < 1) continue;
			if (--inDeg[v] == 0) {
				q.push(v);
				inDeg[v] = -1;
			}
		}
	}

	// グラフの頂点を, トポロジカルソートで表示する //
	for (list<int>::iterator it = ans.begin(); it != ans.end(); it++) {
		cout << *it << endl;
	}

	return 0;
}


Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c,d;
    cin>>a>>b>>c;
    d=a+b;
    d=min(d,a+c);
    d=min(d,b+c);
    cout<<d<<endl;

    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define REPS(i, n) for (int i = 1; i <= (n); i++)
#define RREPS(i, n) for (int i = (n); i > 0; i--)
#define mpa make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  REP(i,N) cin >> S[i];
  int ans = 0;
  REP(A,N){
    vector<string> T(N);
    REP(i,N) T[i] = S[(i+A)%N];
    bool flag = true;
    REP(i,N){
      REP(j,N){
        if(T[i][j] != T[j][i]) flag = false;
      }
    }
    if(flag) ans++;
  }
  cout << ans * N << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  char c;
  cin >> c;
  if ('A' <= c && c <= 'Z')
    cout << "A" << endl;
  else
    cout << "a" << endl;
  return 0;
}

Measured memory_bytes: 3612
s = input()

for i, (e1, e2) in enumerate(zip(s, s[1:]), 1):
    if e1 == e2:
        print(i, i + 1)
        exit()

for i, (e1, e2, e3) in enumerate(zip(s, s[1:], s[2:]), 1):
    if e1 == e3:
        print(i, i + 2)
        exit()

print(-1, -1)


Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, M, X, Y; cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  rep(i,N) cin >> x[i];
  rep(i,M) cin >> y[i];
  sort(x.begin(), x.end(), greater<int>());
  sort(y.begin(), y.end());
  if (max(x[0], X) < min(y[0], Y)) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 3100
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 1001000
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    ll n;cin>>n;
    //3
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            for(ll k=1;k<=n;k++)
            {
                sum+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <list>
using namespace std;

int main() {
	list<int> ls;
	int n;
	scanf("%d", &n);

	for(int i = 0; i < n; i++) {
		char str[12];
		cin >> str;
		int num;
		if(str[0] == 'i') {
			scanf("%d", &num);
			ls.push_front(num);
		}
		else if(str[6] == 'F') {
			ls.pop_front();
		}
		else if(str[6] == 'L') {
			ls.pop_back();
		}
		else if(str[0] == 'd') {
			scanf("%d", &num);
			for(list<int>::iterator itr = ls.begin(); itr != ls.end(); itr++){
				if(*itr == num) {
					ls.erase(itr);
					break;
				}
			}
		}	
			//ls.erase(find(ls.begin(), ls.end(), num));
	}
	
	list<int>::iterator tmp;
 	
	for(list<int>::iterator itr = ls.begin(); itr != ls.end(); itr++) {
		if(itr != ls.begin()) {
			printf(" ");
		}
		printf("%d", *itr);
	}
	printf("\n");

	return 0;
}




Measured memory_bytes: 34444
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const double INF = 1e12;

typedef complex<double> P;

namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS;
}

int main(){
	int n;
	cin>>n;
	vector<string>res;
	REP(i,n){
		P p1,p2,p3,p4;
		cin>>p1.real()>>p1.imag()>>p2.real()>>p2.imag()>>p3.real()>>p3.imag()>>p4.real()>>p4.imag();
		L l1(p1,p2),l2(p3,p4);
		if(!intersectLL(l1,l2))res.PB("YES");
		else res.PB("NO");
	}
	REP(i,n)cout<<res[i]<<endl;
	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define MAXN 102
#define INF 10000000
int dp[MAXN][MAXN];
int p[MAXN];
int main(){
    int n;
    scanf("%d", &n);
    scanf("%d", p);
    int x;
    for(int i = 1; i < n; i++)
        scanf("%d%d", &x, p + i);
    scanf("%d", p + n);
    for(int i = 1; i <= n; i++)
        dp[i][i] = 0;
    for(int l = 1; l < n; l++){
        for(int i = 1; i + l <= n; i++){
            int j = i + l;
            dp[i][j] = INF;
            for(int k = i; k < j; k++){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    printf("%d\n", dp[1][n]);
    return 0;
}



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

int main(){
	double W,H,x,y;	cin>>W>>H>>x>>y;

	double ans=W*H/2;
	//cout<<ans<<" ";
	printf("%.8lf %d\n",ans, x*2==W&&y*2==H);


	


	return 0;
}


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

//ABC118C
int compare_int(const void *a, const void *b) { //sort
  return *(int*) a-*(int*) b;
}
int main(void) {
  int a, b, n, k, i, cou=0, tmp;
  scanf("%d %d", &n, &b);

  for(i=1; i<n; i++){
    scanf(" %d", &a);

    if(a<b) tmp=a, a=b, b=tmp; //ユークリッドの互除法//gcd(a,b)=>b
    while(a%b!=0){
      a=a%b;
      if(a<b) tmp=a, a=b, b=tmp; //swap
    }
  }
  printf("%d",b);
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        int[] V = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] C = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] vc = new int[N];
        for(int i=0; i<N; i++){
            vc[i] = V[i] - C[i];
        }
        int[] dp = new int[N+1];
        dp[0] = 0;
        for(int i=0; i<N; i++){
            dp[i+1] = Math.max(dp[i], dp[i] + vc[i]);
        }
        System.out.println(dp[N]);
    }
}


Measured memory_bytes: 28628
class Unionfindtree:
    def __init__(self,number):
        self.par = [i for i in range(number)]
        self.rank = [0]*(number)

    def find(self,x):#親を探す
        if self.par[x] ==x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self,x,y):#x,yを繋げる
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return 
        if self.rank[px]<self.rank[py]:
            self.par[px]=py
        else:
            self.par[py]=px
        if self.rank[px]==self.rank[py]:
            self.rank[px] +=1
    
    def connect(self,x,y):#親が同じかみる
        return self.find(x)==self.find(y)
    
N,M = map(int,input().split())
tree = Unionfindtree(N)
P =[int(i) for i in input().split()]
for i in range(M):
    x,y = map(int,input().split())
    tree.union(x-1,y-1)
    
ans = 0
for i in range(N):
    if tree.connect(P[i]-1,i):
        ans +=1
print(ans)

Measured memory_bytes: 18608
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin >> n;
    vi x(n), y(n), h(n);
    int maxh = 0;
    rep(i, n){
        cin >> x[i] >> y[i] >> h[i];
        if(maxh < h[i]){
            maxh = h[i];
        }
    }

    rep(i, 101){
        rep(j, 101){
            for(int k = maxh; k < maxh + 201; k++){
                bool ok = true;
                rep(l, n){
                    if(h[l] != max(k - abs(i-x[l]) - abs(j-y[l]), 0)){
                        ok = false;
                    }
                }

                if(ok){
                    cout << i << " " << j << " " << k << "\n";
                }
            }
        }
    }

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
class BImissyou {
    static void Main(string[] args) {
        string s = System.Console.ReadLine();
        for (int i = 0; i < s.Length; i++){
            System.Console.Write("x");
        }
        System.Console.WriteLine("");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define For(i, s, e) for(int i = s; i <= e; ++i)
int n, v;
int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	int m = 1;
	For(i, 2, 9) {
		int k = floor(pow(double(n) + 0.01, 1.0 / double(i)));
		if (k < 2)
			break;
		v = pow(k, i);
		if (m < v)
			m = v;
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

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

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

int main() {
	int n; cin >> n;
	int maxx = 1000000000,a,b,temp1,temp2;

	for (int i = 1; i <= n-1; i++) {
		temp1 = 0; temp2 = 0;
		a = i;
		b = n - i;
		while (b) {
			temp1 += b % 10;
			b /= 10;
		}
		while (a) {
			temp2 += a % 10;
			a /= 10;
		}
		//cout <<"a:"<<a<< "," << "b:" << b<<" " <<temp1 << " " << temp2 << endl;;
		maxx = min(maxx, temp1+temp2);
	}
	cout << maxx;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
enough::Int -> Int -> [Int] -> Int -> Bool
enough a b xs n= let strong = ((filter (\x->x>0)).(map (\x -> x-(b*n)))) xs in
                 let need = (sum.(map (\x-> (div x (a-b))+if (mod x (a-b))> 0 then 1 else 0))) strong in
                  need<=n
--a以上　b　未満で探索、bがありえない事が保証され、aが成り立つ事が保証されるとする。
binary_Int_dec::(Int,Int)->(Int -> Bool)->Maybe Int
binary_Int_dec (a,b) f = if a+1 == b then if f a then Just a else Nothing
                                 else let mid = div (a+b) 2 in
                                      if  f mid then binary_Int_dec (mid,b) f
                                                else binary_Int_dec (a,mid) f


--aより大、b以下で探索、bがありえる事が保証され、aがありえない事が保証されるとする。
binary_Int_inc::(Int,Int)->(Int -> Bool)->Maybe Int
binary_Int_inc (a,b) f = if a+1 == b then if f b then Just b else Nothing
                                 else let mid = div (a+b) 2 in
                                      if  f mid then binary_Int_inc (a,mid) f
                                                else binary_Int_inc (mid,b) f

solver::Int -> Int -> Int -> [Int] -> Maybe Int
solver a b m xs = binary_Int_inc (0,(div m b)+1) (enough a b xs)

n_get_withmax::Int -> IO ([Int],Int)
n_get_withmax 0 =return ([],0)
n_get_withmax n = do
  dc<-getLine
  (rest,m)<-n_get_withmax (n-1)
  return ((read dc):rest,max (read dc) m)

main::IO()
main=do
  d<-getLine
  let n:a:b:[]=map read (words d)
  (dat,m)<-n_get_withmax n
  case solver a b m dat of
    Just x -> print x

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


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 10;
long long arr[N];
const int mod = (int)1e9 + 7;
int main(){
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)cin >> arr[i];
    long long s = 0,ans = 0;
    for(int i = 1;i <= n;i++){
        ans += (arr[i] * s);
        s += arr[i];
        ans %= mod;
        s %= mod;
    }
    cout << ans;
    return 0;
}

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

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


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

int main(void)
{
    int A,B,C;
    cin >> A >> B >> C;

    if(A == B)
        cout << C << endl; 
    if(B == C)
        cout << A << endl; 
    if(C == A)
        cout << B << endl; 
    

    return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
vector<vector<int>>v;
 
int n,d;
bool valid(int a,int b){
    int sum =0;
    int ans =0;
    for(int i=0;i<d;i++){
        sum+=(v[a][i]-v[b][i])*(v[a][i]-v[b][i]);
    }
    int sq=(int)(sqrt(sum)+0.5);
    return(sq*sq==sum);
    
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
   
    scanf("%d%d",&n,&d);
    v=vector<vector<int>>(n);
    for(int i=0;i<n;i++){
        int x;
        for(int j=0;j<d;j++){
            scanf("%d",&x);
            v[i].push_back(x);
        }
    }
    int cnt =0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(valid(i,j))cnt++;
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
char s[10];
int main(){
  rep(i,10)scan(s[i]);
  s[3]='8';
  rep(i,10)cout<<s[i];
  cout<<"\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		String[] ac = new String[N+1];
		int[] wa = new int[N+1];
		for( int i=0; i<N+1; i++ ){
			ac[i] = "Q";
		}
		int count1 = 0;      
		for( int i=0; i<M; i++ ){
			int a = sc.nextInt();
			String ss = sc.next();
			if( ss.equals("AC") ){
				ac[a] = "AC";
			}else{
				if( ac[a].equals("Q") ){
					wa[a]++;
				}
			}
		}
		int count2 = 0;      
		for( int i=0; i<N+1; i++ ){
			if( ac[i].equals("AC") ){
				count1++;              
            }else{
				wa[i] = 0;              
            }              
			count2 += wa[i];          
        }          
		System.out.println(count1+" "+count2);
	}
}


Measured memory_bytes: 63776
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      h: usize,
      w: usize,
      n: usize,
      a: [usize; n]
   }

   let mut color = vec![0; h * w];
   {
      let mut k = 0;
      for i in 0..n {
         for _ in 0..a[i] {
            color[k] = i + 1;
            k += 1;
         }
      }
   }

   for i in 0..h {
      if i % 2 == 0 {
         for j in 0..w {
            print!("{} ", color[w * i + j]);
         }
      } else {
         for j in (0..w).rev() {
            print!("{} ", color[w * i + j]);
         }
      }
      println!("");
   }
}


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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807
#define array(N, t) (t *)calloc(N, sizeof(t))

int main() {
  int N;
  scanf("%d", &N);

  int * f = array(N + 1, int);

  rep(i, 100) {
    int x = i + 1;
    rep(j, 100) {
      int y = j + 1;
      rep(k, 100) {
        int z = k + 1;
        int sum = (int)(((int)pow(x + y, 2) +
                         (int)pow(x + z, 2) +
                         (int)pow(y + z, 2)) / 2);
        if (sum <= N) {
          f[sum] += 1;
        }
      }
    }
  }

  rep(i, N) {
    printf("%d\n", f[i + 1]);
  }

  free(f);
  return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  vector<int> x(n), y(n), a(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> a[i];

  int y_max(h), y_min(0);
  int x_max(w), x_min(0);
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      x_min = max(x_min, x[i]);
    } else if (a[i] == 2) {
      x_max = min(x_max, x[i]);
    } else if (a[i] == 3) {
      y_min = max(y_min, y[i]);
    } else if (a[i] == 4) {
      y_max = min(y_max, y[i]);
    }
  }
  int ans = (x_max - x_min) * (y_max - y_min);
  if (x_max - x_min < 0 || y_max - y_min < 0) ans = 0;

  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <functional>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include <cmath>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define form(i,a,b) for(int i=(a);i<(b);i++)
#define sz(x) ((int)(x).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
int cmp( const void *p, const void *q ) {if( *(double*)p > *(double*)q ) return 1;if( *(double*)p < *(double*)q ) return -1;return 0;}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    //vi ad,bd,cd,dd;
    //vs as,bs,cs,ds;
    cin>>a>>b;
    printa((a*a)-b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0; i<n; i++)
#define out(x) cout<<(x)<<"\n"

int main(){
  string str1,str2,str3;
  cin>>str1>>str2>>str3;
  cout<<str1[0]<<str2[0]<<str3[0];
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vi A(N); 
    REP(i, N) {
        cin >> A[i];
        A[i]--;
    }
    vi B(N); REP(i, N) cin >> B[i];
    vi C(N); REP(i, N - 1) cin >> C[i];

    int ans = B[A[0]];
    FOR(i,1,N) {
        if (A[i] == A[i - 1] + 1) ans += C[A[i - 1]];
        ans += B[A[i]];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 102
#define MAX2 202

int main(void){

  char p[MAX], s[MAX], r[MAX2] = "";

  fgets(p, MAX, stdin);
  p[strlen(p) - 1] = '\0';

  strcat(r, p);
  strcat(r, p);


  fgets(s, MAX, stdin);
  s[strlen(s) - 1] = '\0';

  if(strstr(r, s) != NULL){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

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

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

    bool ok = false;

    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 != 0 && A[i] % 5 != 0) break;
        }
        if (i == N-1) ok = true;
    }

    if (ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import namedtuple
Vector=namedtuple("Vector","x y")

def square(a,b,c):
    return abs((a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y))

n=input()
for i in range(n):
    xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys=map(int,raw_input().split())
    A=Vector(x=xp1, y=yp1)
    B=Vector(x=xp2, y=yp2)
    C=Vector(x=xp3, y=yp3)
    K=Vector(x=xk, y=yk)
    S=Vector(x=xs, y=ys)
    ABC=square(A,B,C)
    ABCK=square(A,B,K)+square(A,K,C)+square(K,B,C)
    ABCS=square(A,B,S)+square(A,S,C)+square(S,B,C)
    print "NG" if (ABC==ABCK)==(ABC==ABCS) else	"OK"

Measured memory_bytes: 4944