akhauriyash/Code-Regression huggingface dataset:
r_list = []
ans_list = []
N = int(input())
for i in range(1, N+1):
    Si, Pi = input().split()
    r_list.append((Si, int(Pi), i))
    
name_sorted_list = sorted(r_list, key=lambda x:x[0])

while len(name_sorted_list) > 0:
    test_list = []
    list_index = [i for i, x in enumerate(name_sorted_list) if x[0]  == name_sorted_list[0][0]]
    for i in list_index:
        test_list.append(name_sorted_list[i])
    for i in reversed(list_index):
        del name_sorted_list[i]
    test_list = sorted(test_list, key=lambda x:x[1], reverse = True)
    for item in test_list:
        ans_list.append(item)
    
for item in ans_list:
    print(item[2])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <climits>

using namespace std;

int n,x,ans;

int main() {
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> x;
        ans += x - 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr <<"\e[91m"<<__func__<<": "<< #x << " = " << x <<"\e[39m"<< "\n"
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;


int main()
{
#ifndef ONLINE_JUDGE
    //freopen("../io/in.txt", "r", stdin);
    //freopen("../io/out.txt", "w", stdout);
#endif // ONLINE_JUDGE
    int a;
    cin >> a;
    cout << a+(a*a)+(a*a*a) << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>

int month_consists_of(int year, int month);
int year_consists_of(int year);

int main(int argc, char const* argv[])
{
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    int year, month, day;
    std::cin >> year >> month >> day;
    int passed;
    if (day == 1) {
      passed = 0;
    } else {
      passed = 1 + month_consists_of(year, month) - day;
      ++month;
      if (month == 11) {
        ++year;
        month = 1;
      }
    }
    if (month != 1) {
      for (int m = month; m <= 10; ++m) {
        passed += month_consists_of(year, m);
      }
      ++year;
    }
    for (int y = year; y <= 999; ++y) {
      passed += year_consists_of(y);
    }
    std::cout << passed << std::endl;
  }
  return 0;
}

int month_consists_of(int year, int month) {
  if (year % 3 == 0)
    return 20;
  else if (month % 2 == 0)
    return 19;
  else
    return 20;
}

int year_consists_of(int year) {
  if (year % 3 == 0)
    return 20 * 10;
  else
    return (20 + 19) * 5;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  
  int bb=0,aa=0,ab=0,ba=0,ans=0;
  for(int i=0;i<n;i++){
    if(s[i][0]=='B'&&s[i][s[i].size()-1]!='A') bb++;
    else if(s[i][0]!='B'&&s[i][s[i].size()-1]=='A') aa++;
    else if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A') ba++;
  	for(int j=0;j<s[i].size();j++){
    	if(s[i][j]=='A'&&s[i][j+1]=='B') ab++;
    }
    ans+=ab;
    ab=0;
  }
  if(bb==0&&aa==0&&ba==0) ans=ans;
  else if(bb==0&&aa==0&&ba!=0) ans+=(ba-1);
  else ans+=min(bb+ba,aa+ba);
  cout<<ans<<endl;
  
}

Measured memory_bytes: 768
N, M = map(int, input().split())
s = [0] * M
c = [0] * M
for i in range(M):
    s[i], c[i] = map(int, input().split())

w = ""
ans = [-1] * N
f = True

if N == 1 and M == 0:
    print(0)
elif N == 1:
    for i in range(M):
        if ans[s[i] - 1] != -1:
            if ans[s[i] - 1] != c[i]:
                f = False
                break
        ans[s[i] - 1] = c[i]
    if f:
        if ans[0] == -1:
            ans[0] = 1
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        for i in range(N):
            w += str(ans[i])
        print(int(w))
    if not f:
        print(-1)

elif N == 2 or N ==3:
    for i in range(M):
        if s[i] == 1 and c[i] == 0:
            f = False
            break
        if ans[s[i] - 1] != -1:
            if ans[s[i] - 1] != c[i]:
                f = False
                break
        ans[s[i] - 1] = c[i]
    if f:
        if ans[0] == -1:
            ans[0] = 1
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        for i in range(N):
            w += str(ans[i])
        print(int(w))
    if not f:
        print(-1)


Measured memory_bytes: 3188
from sys import stdin
INF = float('inf')
WHITE, GRAY, BLACK = 0, 1, 2
n = int(stdin.readline())
M = [[INF] * n for _ in range(n)]
for i in range(0, n):
    for j, e in enumerate(list(map(int, stdin.readline().split()))):
        if e != -1: M[i][j] = e
d = [INF] * n
d[0] = 0
color = [0] * n
def prim():
    while True:
        minv = INF
        u = -1
        for i in range(0, n):
            if minv > d[i] and color[i] != BLACK:
                u = i
                minv = d[i]
        if u == -1: break
        color[u] = BLACK
        for v in range(0, n):
            if color[v] != BLACK and d[v] > M[u][v]:
                d[v] = M[u][v]
    return sum(d)
print(prim())

Measured memory_bytes: 7872
/**
*    author:  boutarou
*    created: 05.07.2020 21:01:33
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;

string s[4] = {"AC", "WA", "TLE", "RE"};
int cnt[4];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    rep(i, n) {
        string now;
        cin >> now;
        rep(j, 4) {
            if (s[j] == now) cnt[j]++;
        }
    }
    rep(i, 4) {
        cout << s[i] << " x " << cnt[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3660
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[101010];
int ans;
int main(){
	cin >> n;
	REP(i, n){
		cin >> a[i];
		if(!i)ans = a[i];
		else ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
}

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

#define st first
#define nd second
#define com make_pair 
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define mem(x, v) memset(x, v, sizeof(x))
#define rep(x, n) for (int x = 0      ; x <  (n); ++x)
#define per(x, n) for (int x = (n) - 1; i >= 0  ; --x)
#define exc(x, a, b) for (auto x = (a); x <  (b); ++x)
#define inc(x, a, b) for (auto x = (a); x <= (b); ++x)
#define cxe(x, a, b) for (auto x = (b) - 1; x >= (a); --x)
#define cni(x, a, b) for (auto x = (b)    ; x >= (a); --x)
#define debug(x) cerr <<__LINE__ << " " << #x << " = " << x << endl;

using namespace std;

const int mod = (int) 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef double dbl;
typedef pair<int, int> mti;

namespace math {
  inline void add(int &a, int b, int p = mod) {
    a + b >= p ? a = a + b - p : a = a + b;
  }
  inline void sub(int &a, int b, int p = mod) {
    a - b < 0 ? a = a - b + p : a = a - b;
  }
  inline int mul(int a, int b, int p = mod) {
    return (long long) a * b % p;
  }
  inline int modexp(int a, int x, int p = mod) {
    int res = 1;
    for (; x; x >>= 1) {
      if (x & 1) {
        res = mul(res, a, p);
      }
      a = mul(a, a, p);
    }
    return res;
  }
};
using namespace math;

namespace io {
  template <typename T = int>
  inline T read() {
    T x = 0;
    int f = 1;
    char ch = cin.get();
    for (; !isdigit(ch) && !cin.eof(); cin.get(ch)) {
      f = (ch == '-') ? -1 : 1;
    }
    for (; isdigit(ch) && !cin.eof(); cin.get(ch)) {
      x = x * 10 + ch - '0';
    }
    return f * x;
  }

  template <typename T = int>
  inline void write(T x, char ch = '\n') {
    static char stk[255];
    static int top = 0;
    if (x < 0) {
      cout.put('-');
      x = -x;
    }
    if (x == 0) {
      cout.put('0');
      cout.put(ch);
      return;
    }
    top = 0;
    while (x) {
      stk[top++] = x % 10 + '0';
      x /= 10;
    }
    while (top) {
      cout.put(stk[--top]);
    }
    cout.put(ch);
  }
}
using namespace io;

template <typename T>
vector<T>& operator << (vector<T> &v, T x) {
  return v.push_back(x), v;
}

const int N = 2e5 + 5;

int n;
int k;
int a[N];

long long sum[N];

bool cmp(const int &a, const int &b) {
  ll va = sum[a] - (long long) a * k;
  ll vb = sum[b] - (long long) b * k;
  return va == vb ? a < b : va < vb;
}

class fenwick {
public:

  int a[N];

  void add(int x) {
    ++x;
    for (; x <= n; x += x & -x) {
      a[x]++;
    }
  }

  int sum(int x) {
    int res = 0;
    ++x;
    for (; x; x -= x & -x) {
      res += a[x];
    }
    return res;
  }
} f;

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

  n = read();
  k = read();
  rep (i, n) {
    a[i] = read();
  }
  sum[0] = a[0];
  exc (i, 1, n) {
    sum[i] = sum[i - 1] + a[i];
  }
  vector<pair<long long, int> > id;
  rep (i, n) {
    id << com(sum[i] - (long long) i * k, i);
  }

  sort(all(id));

  ll ans = 0;

  rep (i, n) {
    int v = id[i].second;
    ans = ans + f.sum(v);
    if (sum[v] / (v + 1) >= k) {
      ++ans;
    }
    f.add(v);
  }
  write(ans);
  
  flush(cout);
  return 0;
}


Measured memory_bytes: 8816
import math
K,N=map(int,input().split())
A=list(map(int,input().split()))
A.append(A[0]+K)
maxi=0
max=0
dis=0
for i in range(len(A)-1):
    if A[i+1]-A[i]>max:
        max=A[i+1]-A[i]
        maxi=i
for i in range(0,maxi):
    dis+=A[i+1]-A[i]
for i in range(maxi+1,len(A)-1):
    dis+=A[i+1]-A[i]
print(dis)

Measured memory_bytes: 26444
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long n = sc.nextLong();
        StringBuilder sb = new StringBuilder();
        if(n == 0){
            System.out.println(0);
            return;
        }
        while(n != 0){
            long tmp = Math.abs(n);
            if(tmp % 2 != 0){
                sb.append(1);
            }else{
                sb.append(0);
            }
            n -= (tmp%2);
            n /= (-2);
        }
        System.out.println(sb.reverse().toString());
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

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

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
using namespace std;
 
void problemA()
{
    int N;
    vector<int> A, B;
 
    cin >> N;
    A.reserve(N);
    B.resize(N);
 
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }
 
    vector<int> inverseOrderOps;
 
    while (!B.empty()) {
        int maxV = -1, maxIdx = -1;
        for (int bi = int(B.size()) - 1; bi >= 0; bi--) {
            // Is this valid operation?
            if (bi + 1 != B[bi]) continue;
 
            // Find max value from B
            if (maxV < B[bi]) {
                maxV = B[bi];
                maxIdx = bi;
            }
        }
 
        if (maxV < 0) {
            cout << "-1" << endl;
            return;
        }
 
        inverseOrderOps.push_back(maxIdx+1);
        B.erase(B.begin() + maxIdx);
    }
 
    for (int i = int(inverseOrderOps.size()) - 1; i >= 0; --i) {
        cout << inverseOrderOps[i] << endl;
    }
}
 
int main()
{
    problemA();
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7, N = 1e6 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    string s ;
    cin >> s ;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '7') {
            cout << "Yes" ;
            return 0 ;
        }
    }
    cout << "No" ;

    return 0 ;
}


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

struct node{
    int value;
    node *p,*l,*r;
};

node *root, *NIL;

void insert(int value){
    node *y, *x;
    y = NIL;
    x = root;
    node *n = (node *)malloc(sizeof(node));
    n->value = value;
    n->l = n->r = NIL;
    while(x != NIL){
        y = x;
        if(n->value < x->value)
            x = x->l;
        else
            x = x->r;
    }
    n->p = y;
    if(y == NIL) root = n;
    else{
        //x = n;
        if(n->value < y->value) y->l = n;
        else y->r = n;
    }
}


void Preorder(node *u){
    if(u==NIL) return;
    printf(" %d",u->value);
    Preorder(u->l);
    Preorder(u->r);
}

void Inorder(node *u){
    if(u==NIL) return;
    Inorder(u->l);
    printf(" %d",u->value);
    Inorder(u->r);
}

void print(){
    Inorder(root);
    printf("\n");
    Preorder(root);
    printf("\n");
}

void find(int value){
    node *x = root;
    while(x != NIL){
        if(value == x->value){
            printf("yes\n");
            return;
        }
        else{
            if(value<x->value){
                x = x->l;
            }
            else x = x->r;
        }
    }
    printf("no\n");
    return;
}

int main(){
    int n, value;
    scanf("%d",&n);
    root = (node *)malloc(sizeof(node));
    root = NIL;
    //root->l = root->r = NIL;
    string cmd;
    for(int i=0;i<n;++i){
        cin >> cmd;
        if(cmd == "insert"){
            scanf("%d",&value);
            insert(value);
        }
        else if(cmd == "print"){
            print();
        }
        else if(cmd == "find"){
            scanf("%d",&value);
            find(value);
        }
    }
    return 0;
}



Measured memory_bytes: 22024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){ return y ? gcd(y, x%y): x;}
int main(){
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A,B);
  ll s = g;
  ll ans = 1;
  for(ll i=2; i*i<=s; i++){
    if(g%i==0){
      ans+=1;
      while(g%i==0){
        g/=i;
      }
    }
  }
  if(g>1){
    ans++;
  }
  cout << ans;
  
}


Measured memory_bytes: 256
<?php     
fscanf(STDIN,"%d",$N);
fscanf(STDIN,"%d",$K);

$num = 1;
for($i = 0; $i<$N; $i++){
    $num = ($num*2 <= $num+$K) ? $num*2 : $num+$K;
}
echo $num;
?>

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

lli gcd(lli a, lli b) {
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    lli r;
    r = a % b;

    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    lli a,b;
    cin2(a,b);
    lli g = gcd(a,b);
    cout << a*b/g << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	long long n, h, w;
	cin >> n >> h >> w;
	
	long long result = 0;
	
	for (long long i = 0; i < n; ++i) {
		long long a, b;
		cin >> a >> b;
	
		if (h <= a && w <= b)
			++result;
	}
	
	cout << result << endl;
}

Measured memory_bytes: 256
#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(){
    ll n;
    cin >> n;
    vector <int> ans(n,-1);
    ans[0]=0;
    vector <vector <ll>> m(n),d(n);

    ll u,v,w;
    rep(i,n-1){
        cin >> u >> v >> w;
        --u;
        --v;
        m[u].push_back(v);
        d[u].push_back(w);
        m[v].push_back(u);
        d[v].push_back(w);
    }

    ll l;
    queue <ll> q;
    ll qq;
    q.push(0);

    while(q.size()!=0){
        qq=q.front();
        q.pop();
        l=m[qq].size();
        rep(i,l){
            if(ans[m[qq][i]]==-1){
                ans[m[qq][i]]=(ans[qq]+d[qq][i])%2;
                q.push(m[qq][i]);
            }
        }
    }

    rep(i,n){
        cout << ans[i] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 15572
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,n;
	cin>>x>>n;
	int p[105];
	for(int i=0;i<n;i++) cin>>p[i];
	for(int d=0;d<=100;d++){
		bool found1=false;
		for(int i=0;i<n;i++) if(p[i]==x-d) found1=true;
		if(!found1){
			cout<<x-d<<endl;
			return 0;
		}
		bool found2=false;
		for(int i=0;i<n;i++) if(p[i]==x+d) found2=true;
		if(!found2){
			cout<<x+d<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


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

  int is = (2 * x == W && 2 * y == H ) ? 1 : 0;

  double ans = (double) W * (double) H / 2.0;

  cout << ans << " " << is << endl; 


}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;//xの数
    int x[10000];//元の位置
    int m;//aの数
    int a[10000];//移動させるこまが何番目のものであるか
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf(" %d",&x[i]);
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf(" %d",&a[i]);
        a[i]--;
    }

    for(int i=0;i<m;i++){
        if(x[a[i]]==2019){
            continue;
        }
        if(a[i]+1<n&&x[a[i]+1]==x[a[i]]+1){
		    continue;
        }
		x[a[i]]++;
    }

    for(int i=0;i<n;i++){
        printf("%d\n",x[i]);
    }
    return 0;
}


Measured memory_bytes: 2772
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

ll po(ll a, ll n) {
    if (!n) return 1;
    ll t = po(a,n/2);
    return t*t%MOD*(n%2?a:1)%MOD;
}

int n;
int D[4010][4010];
int A[200100], B[200100];
ll fac[8030], fnv[8030];
int bias = 2005;

ll comb (ll n, ll r) {return fac[n]*fnv[r]%MOD*fnv[n-r]%MOD;}

int main() {
    int i, j;

    scanf("%d",&n);
    for (i=0;i<n;i++) {
        scanf("%d%d",&A[i],&B[i]);
        D[bias-A[i]][bias-B[i]]++;
    }
    fac[0] = 1;
    for (i=1;i<bias*4;i++) fac[i]=fac[i-1]*i%MOD;
    for (i=0;i<bias*4;i++) fnv[i]=po(fac[i],MOD-2);
    for (i=1;i<bias*2;i++) for (j=1;j<bias*2;j++) D[i][j] = ((D[i-1][j]+D[i][j-1])%MOD+D[i][j])%MOD;
    ll sum = 0;
    for (i=0;i<n;i++) sum = (sum+D[bias+A[i]][bias+B[i]])%MOD;
    for (i=0;i<n;i++) sum = (sum-comb(2*(A[i]+B[i]),2*A[i]))%MOD;
    sum = sum*(MOD+1)/2%MOD;
    printf("%lld\n",(sum+MOD)%MOD);

    return 0;
}


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

using namespace std;

int main()
{
    map<string, int> sheet;
    int n;
    cin >> n;
    int sum=0;
    for (int i = 0; i < n; i++)
    {
        string x;
        cin >> x;
        sheet[x]++;
        if (sheet[x]%2 == 1)
        {
            sum++;
        } else
        {
            sum--;
        }
    }
    cout << sum << endl;
    return 0;
}


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

typedef  long long ll;

int main()
{
    ll k,i,j,x,n,m,sum=0,borogcd,gcd;
    cin>>n;
    ll a[n+10],b[n+10];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        b[a[i]]=i;
    }

    for(i=1;i<=n;i++)
    {
        cout<<b[i]<<" ";
    }

}


Measured memory_bytes: 2432
#include<stdio.h>

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

  int sum = 0;
  int input[100];
  int ans1 = 0;
  int ans2 = 0;
  for(int i=0; i<N; i++){
    scanf("%d", &input[i]);
    sum += input[i];
  }

  for(int j=0; j<N; j++){
    ans1 += (sum/N-input[j])*(sum/N-input[j]);
  }

  for(int j=0; j<N; j++){
    ans2 += (sum/N+1-input[j])*(sum/N+1-input[j]);
  }

  if(ans1<ans2){
    printf("%d\n", ans1);
  }else{
    printf("%d\n", ans2);
  }

  return 0;
}


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

const ll MOD = 1e9+7;

ll repsq(ll n,ll p){
    if(p == 0) return 1;
    if(p & 1) return n * repsq(n,p-1) % MOD;
    else {
        ll t = repsq(n,p/2) % MOD;
        return t * t % MOD;
    }
}

int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll ans = (repsq(2,n) -1) % MOD;

    ll x_a = 1,y_a = 1;
    ll x_b = 1,y_b = 1;
    ll dis_a = 1,dis_b = 1;

    for(ll i=0;i<a;i++){
        x_a = x_a * (n-i) % MOD;
        y_a = y_a * (i+1) % MOD;
    }
    dis_a = ( x_a * (repsq(y_a,MOD-2) % MOD) ) % MOD;

    for(ll i=0;i<b;i++){
        x_b = x_b * (n-i) % MOD;
        y_b = y_b * (i+1) % MOD;
    }
    dis_b = ( x_b * (repsq(y_b,MOD-2) % MOD) ) % MOD;
    

    ans = (ans - dis_a - dis_b + 3*MOD) % MOD;

    cout<< (ans + MOD) % MOD <<endl;
}

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

int main() {
    int n, m, a;
    while (cin >> n >> m >> a, n) {
        vector<int> amida(n);
        vector<pair<int, pair<int, int>>> yoko(m);
        for (auto& e : yoko) {
            cin >> e.first >> e.second.first >> e.second.second;
        }
        sort(yoko.begin(), yoko.end());
        int now = a;
        for (int i = m - 1; i >= 0; i--) {
            if (yoko[i].second.first == now) {
                now = yoko[i].second.second;
            } else if (yoko[i].second.second == now) {
                now = yoko[i].second.first;
            }
        }
        cout << now << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int rev=0,q,l,r;
char str[1000005],tmp[1000005];
int main(){
	scanf("%s%d",tmp+1,&q);
	int n=strlen(tmp+1);
	for(int i=500000-n+1;i<=500000;i++)str[i]=tmp[i-500000+n];
	l=500000-n+1,r=500000;
	for(int i=1;i<=q;i++){
		int opt,o;
		char s[2];
		scanf("%d",&opt);
		if(opt==1)rev^=1;
		else {
			scanf("%d%s",&o,s);
			if(o==1){
				if(rev)str[++r]=s[0];
				else str[--l]=s[0];
			}
			else {
				if(!rev)str[++r]=s[0];
				else str[--l]=s[0];
			}
		}
	}
	if(rev)for(int i=r;i>=l;i--)cout<<str[i];
	else for(int i=l;i<=r;i++)cout<<str[i];
}

Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-9;

void foo(double& x, double& y, double xo, double yo, double dx, double dy) {
	double _x = x - xo, _y = y - yo;
	double r = sqrt((double)dx * dx + dy * dy);
	x = _x * dx / r + _y * dy / r;
	y = _y * dx / r - _x * dy / r;
}

int main() {
	int T; cin >> T;
	while (T--) {
		double xa, ya, xb, yb;
		cin >> xa >> ya >> xb >> yb;
		int N; cin >> N;
		vector<double> xs(N), ys(N), xt(N), yt(N);
		vector<int> o(N), l(N);
		for (int i = 0; i < N; i++)
			cin >> xs[i] >> ys[i] >> xt[i] >> yt[i] >> o[i] >> l[i];
		double dx = xb - xa, dy = yb - ya, r = dx * dx + dy * dy;
		if (r == 0) {
			cout << 0 << endl;
			continue;
		}
		vector<d_i> v;
		for (int i = 0; i < N; i++) {
			foo(xs[i], ys[i], xa, ya, dx, dy);
			foo(xt[i], yt[i], xa, ya, dx, dy);
			if (ys[i] * yt[i] >= 0) continue;
			double x = (yt[i] * xs[i] - ys[i] * xt[i]) / (yt[i] - ys[i]);
			if (x < -EPS || x > sqrt((double)dx * dx + dy * dy) + EPS) continue;
			v.push_back(d_i(x, o[i] ^ l[i]));
		}
		sort(v.begin(), v.end());
		int cnt = 0;
		for (int j = 0; j + 1 < v.size(); j++)
			if (v[j].second ^ v[j + 1].second)
				cnt++;
		cout << cnt << endl;
	}
}

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

std::vector< int > A;

long long cut_num_calc(int length) {
    long long num = 0;
    for(int i=0; i<A.size(); i++){
        num += A[i] / length - (A[i] % length == 0);
    }
    
    return num;
}

int main(){
    long long N, K;
    std::cin >> N >> K;
    A.resize(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    
    int min = 0;
    int max = 1e9;
    
    while(max - min > 1){
        int mid = min + (max - min) / 2;
        
        long long cut_num = cut_num_calc(mid);
        if(cut_num > K){
            min = mid;
        }else{
            max = mid;
        }
    }
    
    std::cout << max << std::endl;
    
    return 0;
    
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

class Trie{
#define N_alphabet 2
#define begin_alphabet '0'
public:
    Trie *next[N_alphabet];
    bool exist = false;

    Trie(){
        fill(next, next + N_alphabet, (Trie *)0);
    }

    void insert(string &S, int i = 0){
        if(i == S.size()){
            this->exist = true;
            return;
        }
        if(this->next[S[i] - begin_alphabet] == NULL)
            this->next[S[i] - begin_alphabet] = new Trie();
        this->next[S[i] - begin_alphabet]->insert(S, i + 1);
    }

    void dfs(int L, map<int, int> &count, int i = 0){
        if(this->exist) return;
        REP(j, N_alphabet){
            if(this->next[j] == NULL) count[L - i] += 1;
            else this->next[j]->dfs(L, count, i + 1);
        }
    }
};

signed main(){

    int N, L; cin >> N >> L;
    vector<string> s(N);
    Trie trie;
    REP(i, N){
        cin >> s[i];
        trie.insert(s[i]);
    }
    map<int, int> count;
    trie.dfs(L, count);
    int g = 0;
    for(auto p: count){
        //cout << p.first << " " << p.second << endl;
        if(p.first > 0 && p.second % 2 == 1){
            int t = 1;
            while(p.first % (t * 2) == 0) t *= 2;
            g ^= t;
        }
    }
    if(g) cout << "Alice";
    else cout << "Bob";
    
    return 0;
}

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

#define fst first
#define snd second
#define mp make_pair
#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 all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {return (x>y ? (x=y,true):false);}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {return (x<y ? (x=y,true):false);}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = (int)1e6+3;
const int INF = (int)1e9+17;
const ll mod = (ll)1e9+7;
const ll LLINF = (ll)1e18+17;
const ld pi = (ld)acos(-1.0);


int n;
int a[N];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ll n, x;
    cin >> n >> x;
    cout << 3 * (n - __gcd(n, x)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	int res = 0;
	for (int b = K + 1; b <= N; b++) {
		int aa = (N / b) + 1;
		
		res += aa*(b - K);
		res -= min(b - K, (aa*b - N - 1));
		//cerr << b << " " << res << endl;
	}
	if (K == 0) {
		res -= N - K;
	}
	cout << res << endl;
}

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

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    if(s[0] == 'o') cnt++;
    if(s[1] == 'o') cnt++;
    if(s[2] == 'o') cnt++;
    cout << 700 + 100*cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

#define INT_MAX 2147483647

int main( void ){

	int n , m, c;
	cin >> n >> m >>c;

	vector<int> vb;
	for( int i = 0; i < m; i++){
		int tmp;
		cin >> tmp;
		vb.push_back(tmp);
	}
	int ans = 0;
	for( int i = 0; i < n; i++ ){
		int sum = 0;
		for(int j = 0; j < m; j++){
			int tmp;
			cin >> tmp;
			sum += vb[j] * tmp;
		}
		if(sum > -c) ans++;
	}

	cout << ans << endl;




	return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int K = int.Parse (str[0]);
            int N = int.Parse (str[1]);

            str = Console.ReadLine ().Split (' ');

            int ans = K;
            int A, B;
            for (int i = 1; i < N; i++)
            {
                A = int.Parse (str[i - 1]);
                B = int.Parse (str[i]);
                ans = Min (K - (B - A), ans);
            }

            A = int.Parse (str[N - 1]);
            B = int.Parse (str[0]);
            ans = Min (A - B, ans);

            Console.Write (ans);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 42284
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
#include<cmath>
using namespace std;
typedef long long ll;
// const ll maxn=1e18+1;
#define M 1000005
set<int> ans;
ll A[M];
inline void rd(ll &l){
	l=0;int f=0;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){l=l*10+ch-'0';ch=getchar();}
	if(f)l=-l;
}
int main(){
	ll n,m;
	int q,ct=0,rt=0;
	rd(n);
	if(n==2){puts("1");return 0;}
	q=sqrt(n);
	for(int i=2;i<=q;++i)if(n%i==0){
		A[++ct]=i;
		if(i!=q||i*i!=n)A[++ct]=n/i;
	}
	m=n-1;
	q=sqrt(m);
	ans.insert(m);
	ans.insert(n);
	for(int i=2;i<=q;++i)if(m%i==0){
		ans.insert(i);
		if(i!=q||i*i!=n)ans.insert(n/i);
	}
	for(int i=1;i<=ct;++i){
		m=n;
		while(m%A[i]==0)m/=A[i];
		if(m%A[i]==1)ans.insert(A[i]);
	}
	printf("%d\n",ans.size());
	// getchar();
	// getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using ll = int64_t;

int main() {
  int r,g,b,n;
  cin>>r>>g>>b>>n;
  int cnt = 0;
  REP(i,n+1)REP(j,n+1) {
    int sum=r*i + g*j;
    int rem = n - sum;
    if (rem < 0) break;
    if ((rem%b) == 0) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    int cnt = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        cnt += a[i];
    } 
    cnt /= 2;
    for(int i=1;i<n;i+=2) cnt -=a[i];
    for(int i=0;i<n;i++){
        cout << 2 * cnt << " ";
        cnt = a[i] - cnt;
    }
    cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
 
struct BinaryIndexedTree
{
  vector< int64 > data;
  int curr;
   
  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
    curr = 1;
    while(curr * 2 < data.size()) curr <<= 1;
    for(int i = 0; i < data.size(); i++) data[i] = i & -i;
  }
  inline int64 sum(int k)
  {
    int64 ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return(ret);
  }
  inline int upper_bound(int64 w)
  {
    int i = 0;
    for(int k = curr; k > 0; k >>= 1) {
      if(i + k < data.size() && data[i + k] <= w) {
        w -= data[i + k];
        i += k;
      }
    }
    return(i);
  }
  inline void add(int k, int64 x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
  
int N, Q;
int X[200000], D[200000], L[200000];
char buff[32];
 
int main()
{
  scanf("%d %d", &N, &Q);
  for(int i = 0; i < Q; i++) {
    scanf("%d %d %d", &X[i], &D[i], &L[i]);
  }
  BinaryIndexedTree xpy(N), xmy(N);
  for(int i = Q - 1; i >= 0; i--) {
    if(D[i] == 1) {
      xmy.add(0, -L[i] * 2);
      xmy.add(xpy.upper_bound(X[i]), L[i] * 2);
    } else {
      xpy.add(xmy.upper_bound(X[i]), L[i] * 2);
    }
  }
  for(int i = 0; i < N; i++) {
    printf("%lld\n", (xpy.sum(i) - xmy.sum(i)) / 2);
  }
}

Measured memory_bytes: 6548
object Main {
	def fact(n: Int) : BigInt = n match{
	  case 0 => 1
	  case _ => n * fact(n-1)
	}
	
    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        while(sc.hasNext){
            println(fact(sc.nextInt))
        }
    }
}

Measured memory_bytes: 44940
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>

constexpr long long int MOD = 998244353;
struct Robot {
	int id, position, distance;
	int right() const { return position + distance; }
};
int lower_bound(const std::deque<int>& deque, const std::vector<Robot> &robots, int position) {
	int min = 0;
	int max = deque.size();
	while (min < max) {
		const auto mid = (min + max) / 2;
		if (robots[deque[mid]].position < position) min = mid + 1;
		else max = mid;
	}
	return min;
}
int main() {
	int n; std::cin >> n;
	std::vector<Robot> robots(n);
	for (auto i = 0; i < n; ++i) {
		robots[i].id = i;
		std::cin >> robots[i].position >> robots[i].distance;
	}
	std::sort(robots.begin(), robots.end(), [](const Robot a, const Robot b) {return a.position < b.position; });
	std::vector<int> next(n);
	std::deque<int> deque; 
	for (int i = n - 1; i >= 0; --i) {
		const auto current = robots[i];
		const auto right = lower_bound(deque, robots, current.right());
		if (right == 0) {
			next[i] = i + 1;
		}
		else if (right == deque.size()) {
			next[i] = n;
		}
		else {
			next[i] = deque[right];
		}
		for (auto j = 0; j < right; ++j) 
			deque.pop_front();
		deque.push_front(i);
	}
	std::vector<long long int> dp(n + 1, 0); dp.back() = 1;
	for (int i = n - 1; i >= 0; --i) {
		dp[i] = (dp[i + 1] + dp[next[i]]) % MOD;
	}
	std::cout << dp.front() << '\n';
}

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

int main()
{
	int a,b,c,d,e,f,g;
	cin>>a>>b>>c>>d;
	e = a * b;
	f = c * d;
	if(e>f)
		cout<<e<<endl;
	else
		cout<<f<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll dp[5001][26];
const ll LL_INF = 2000000000000000000;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    set<string> st;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j <= min(n,i+k); j++){
            st.insert(s.substr(i,j-i));
        }
    }
    auto itr = st.begin();
    for(int i = 1; i < k; ++i){
        itr++;
    }
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	vector<vector<ll>> G(n);
	
	ll a, b; 
	rep(i, 1, n-1){
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	ll dst[n];
	memset(dst, -1, sizeof(dst));
	dst[0] = 0;
	queue<ll> q;
	q.push(0);
	ll l = 0;
	while(!q.empty()){
		ll at = q.front(); q.pop();
		zep(i, 0, G[at].size()){
			if(dst[G[at][i]] == -1){
				dst[G[at][i]] = dst[at]+1;
				l = G[at][i];
				q.push(G[at][i]);
			}
		}
	}
	
	memset(dst, -1, sizeof(dst));
	dst[l] = 0;
	q.push(l);
	ll lr = 0;
	while(!q.empty()){
		ll at = q.front(); q.pop();
		zep(i, 0, G[at].size()){
			if(dst[G[at][i]] == -1){
				dst[G[at][i]] = dst[at]+1;
				lr = dst[G[at][i]];
				q.push(G[at][i]);
			}
		}
	}
	
	if(lr%3 == 1){
		print("Second")
	}
	else{
		print("First")
	}
	return 0;
}

Measured memory_bytes: 15984
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
  while(x->left != NIL) x = x->left;
  return x;
}

Node * find(Node * u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }else{
    if(y == y->parent->left){
      y->parent->left = x;
    }else{
      y->parent->right = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }

  free(y);
}


void insert(int k){
  
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);

}

int main(){
  int n, i, x;
  string com;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    cin >> com;
    if(com[0] == 'f'){
      scanf("%d", &x);
      Node *t = find(root, x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    }else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(com == "delete"){
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}

    



Measured memory_bytes: 22008
import sys
import numpy as np

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

P = 200003
PROOT = 2


def calc_tables():
    prev = [None] * P
    val = 1
    for i in range(P):
        prev[val] = i
        val = (val * PROOT) % P
    return prev


def convolve(f, g):
    fft_len = 1
    alen = len(f) + len(g) - 1
    while fft_len < alen:
        fft_len *= 2

    fa = np.fft.rfft(f, fft_len)
    fb = np.fft.rfft(g, fft_len)

    h = np.fft.irfft(fa * fb)
    h = np.rint(h).astype(np.int64)
    return h


def solve():
    prev = calc_tables()

    _ = ini()
    a = [x for x in inl() if x != 0]
    b = [prev[x] for x in a]
    a = np.array(a, dtype=np.int64)
    m = len(a)

    b_counts = np.zeros(P, np.int64)
    for x in b:
        b_counts[x] += 1

    root_pow = np.ones(2 * P, dtype=np.int64)
    for i in range(1, 2 * P):
        root_pow[i] = root_pow[i - 1] * PROOT % P

    c = convolve(b_counts, b_counts)
    ans = 0
    for k in range(2 * P - 1):
        ans += c[k] * root_pow[k]
    for k in range(P):
        ans -= b_counts[k] * root_pow[2 * k]
    return ans // 2


print(solve())


Measured memory_bytes: 76632
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
ll x[N];
void solve(){
    ll n;
    cin >> n;
    ll mn = 1e18; 
    for(int i = 1; i <= n; ++i){
        cin >> x[i];
    }
    for(int i = 1; i <= 200; ++i){
        ll cnt = 0;
        for(int j = 1; j <= n; ++j){
            cnt += (x[j] - i)*(x[j] - i);
        }   
        mn = min(mn,cnt);
    }
    cout << mn;

}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  vector<int> b;
  
  b = a;
  sort(b.rbegin(),b.rend());
  
  rep(i,n){
    if(a[i]==b[0]){
      cout << b[1] << endl;
    }else{
      cout << b[0] << endl;
    }
  }
}

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

int main(){

string A;

cin>>A;

int b;
b=A.size();
int ans=0;

int c= b/2;

for(int j=0;j<c;j++){


	if(A.at(j)!=A.at(b-j-1))ans=999;}

for(int k=0;k<(c/2);k++){
	
	if(A.at(k)!=A.at(c-k-1))ans=999;

	if(A.at(b-k-1)!=A.at(c+1+k))ans=999;
}

if(ans==0){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}

}


Measured memory_bytes: 256
N = int(input())
S = list(input())
ans = 0
for i in range(N):
    a = S[:i]
    b = S[i:]
    aset = set(a)
    bset = set(b)
    count = 0
    for i in aset:
        if i in bset:
            count += 1
    ans = max(ans,count)
print(ans)

Measured memory_bytes: 9164
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n, h, w;
    cin >> n >> h >> w;

    cout << (n - h + 1) * (n - w + 1) << endl;

    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main()
{
	int a, b, c;
	int max, min,total;
	scanf("%d %d %d", &a, &b, &c);
	total=a+b+c;
	if(a>b && a>c)
	{
		max=a;
	}
	else if (b>c && b>a)
	{
		max=b;
	}
	else 
	{
		max=c;
	}
	if(a<b && a<c)
	{
		min=a;
	}
	else if (b<c && b<a)
	{
		min=b;
	}
	else
	{
		min=c;
	}
	printf("%d %d %d\n", min, total-max-min, max);
	return 0;
} 


Measured memory_bytes: 2144
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

int main(int argc, char **argv)
{
	char C[2];
	scanf("%s", C);
	printf("%c\n", C[0]+1);
	return 0;
}


Measured memory_bytes: 128