akhauriyash/Code-Regression huggingface dataset:
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  if(k >= x/d){
    ll c = k-x/d;
    if(c%2==0){
      print(x%d);
    }else{
      print(abs(x%d-d));
    }
  }else{
    print(x-d*k);
  }
}


Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

vector<int> g[128000];
int dist[128000];
int color[128000];

void solve(ll N, ll M, vector<ll> a, vector<ll> b, ll Q, vector<ll> v, vector<ll> d, vector<ll> c) {
  REP(i,M) g[a[i] - 1].push_back(b[i] - 1);
  REP(i,M) g[b[i] - 1].push_back(a[i] - 1);
  reverse(ALL(v));
  reverse(ALL(d));
  reverse(ALL(c));
  REP(i,Q) {
    queue<pair<int,int>> que;
    que.push(make_pair(v[i] - 1, d[i]));
    while (!que.empty()) {
      int v, d;
      tie(v, d) = que.front();
      que.pop();
      if (color[v] == 0) color[v] = c[i];
      if (d == 0) continue;
      if (dist[v] >= d) continue;
      dist[v] = d;
      for (int i: g[v]) {
        que.push(make_pair(i, d - 1));
      }
    }
  }
  REP(i,N) cout << color[i] << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll M;
	ll Q;
	ll N;
	scanf("%lld", &N);
	scanf("%lld", &M);
	vector<ll> b(M-1+1);
	vector<ll> a(M-1+1);
	for (int i = 0 ; i <= M-1 ; i++) {
	  scanf("%lld", &a[i]);
	  scanf("%lld", &b[i]);
	}
	scanf("%lld", &Q);
	vector<ll> d(Q-1+1);
	vector<ll> c(Q-1+1);
	vector<ll> v(Q-1+1);
	for (int i = 0 ; i <= Q-1 ; i++) {
	  scanf("%lld", &v[i]);
	  scanf("%lld", &d[i]);
	  scanf("%lld", &c[i]);
	}
	solve(N, M, a, b, Q, v, d, c);
	return 0;
}


Measured memory_bytes: 16284
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    string s;
    cin >> n >> s;
    string ans = "";
    string memo = "";
    int a = 0;
    int ma = 0;
    int b = 0;
    int mb = 0;
    rep(i, n)
    {
        if (s[i] == '(')
        {
            a++;
        }
        if (s[i] == ')')
        {
            b++;
            if (b > a)
            {
                mb++;
                b--;
            }
        }
    }
    
    if (a - b > 0)
    {
        rep(i, mb)
        {
            cout << "(";
        }
        cout << s;
        rep(i, a - b)
        {
            cout << ")";
        }
    }
    else
    {
        rep(i, b - a)
        {
            cout << "(";
        }
        rep(i, mb)
        {
            cout << "(";
        }
        cout << s;
    }
    cout<<endl;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n = i()
a = hi(n)
maxa = max(a)
b = sorted(a, reverse=True)
snda = b[1]
if maxa == snda:
    for i in range(n):
        print(maxa)
else:
    for i in range(n):
        if maxa == a[i]:
            print(snda)
        else:
            print(maxa)

Measured memory_bytes: 16576
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	char c;
	cin >> c;

	cout << (char)(c+1) << '\n';
	return 0;
}



Measured memory_bytes: 256
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

struct UnionFind {
	int fa[1 << 17];
	void inline init() {memset(fa, -1, sizeof(fa));}
	UnionFind() {init();}
	int inline root(int x) {return fa[x] < 0 ? x : fa[x] = root(fa[x]);}
	bool inline conn(int a, int b) {
		a = root(a); b = root(b);
		if(a == b) return 0;
		if(fa[a] < fa[b]) swap(a, b);
		return fa[b] += fa[a], fa[a] = b, 1;
	}
} dsu;

int n, m;

int main() {
	scanf("%d%d", &n, &m);
	dsu.init();
	cont(i, m) {
		int a, b; scanf("%d%d", &a, &b);
		dsu.conn(a, b);
	}
	int bl = 0;
	cont(i, n) if(dsu.root(i) == i) bl++;
	printf("%d\n", bl - 1);
	return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a <= c && c <= b) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3620
import java.util.Scanner;

class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNextInt()){
long d=sc.nextLong();
long n=(600/d)-1;
long s=(long)((2*Math.pow(n,3)+3*Math.pow(n,2)+n)*Math.pow(d,3))/6;
System.out.println(s);
}
}
}

Measured memory_bytes: 17208
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(void)
{
    int m=0,n=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='0') m++;
        else n++;
    }
    cout<<2*min(m,n);
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int N, K;
  cin >> N >> K;
  vector<int> hp(N);
  long long ans = 0;
  for(int i = 0; i < N; i++){
    cin >> hp.at(i);
    ans += hp.at(i);
  }
  sort(hp.begin(), hp.end());
  for(int i = 0; i < N; i++){
    if(i < K){
      ans -= hp.at(N - i - 1);
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 1024
N = int(input())
X = list(map(int, input().split()))

X_copy = X.copy()
X_copy.sort()
medi_min = X_copy[N//2-1]
medi_max = X_copy[N//2]


for x in X:
    if x<=medi_min:
        print(medi_max)
    else:
        print(medi_min)

Measured memory_bytes: 26772
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
using namespace std;



int main()
{
	int n, m;
	cin >> n >> m;
	priority_queue<int> pq;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		pq.push(x);
	}
	while (m--) {
		int p = pq.top();
		pq.pop();
		p /= 2;
		pq.push(p);
	}
	long long sum = 0;
	while (!pq.empty()) {
		sum += pq.top();
		pq.pop();
	}
	cout << sum;
}


Measured memory_bytes: 892
/*
....................../´¯/)
....................,/¯../
.................../..../
............./´¯/'...'/´¯¯`·¸
........../'/.../..../......./¨¯\
........('(...´...´.... ¯~/'...')
.........\.................'...../
..........''...\.......... _.·´
............\..............(
..............\.............\...
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define pi 3.14159265358979323846
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> str;
		ans = 0;

		for (i = 0; i < 3; i++)
		{
			if (str[i] == 'R')
			{
				cnt = 0;
				while (i < 3 && str[i] == 'R')
				{
					cnt++;
					i++;
				}
				i--;
			}
			ans = max(ans, cnt);
		}

		cout << ans;



		ln
	}
	return 0;
}


Measured memory_bytes: 3608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class DColoringEdgesOnTree {
public:
    int n;
    vector<vector<int>> ab;
    map<pair<int,int>,int> m;
    vector<bool> f;
    int ma=0;
	void solve(std::istream& in, std::ostream& out) {
        in >> n;
        ab = vector<vector<int>>(n);
        m = map<pair<int,int>,int>();
        f=vector<bool>(n,true);
        vector<pair<int,int>> e(n-1);
        rep(i,n-1){
            in >> e[i].first >> e[i].second;
            e[i].first--;e[i].second--;
            ab[e[i].first].push_back(e[i].second);
            ab[e[i].second].push_back(e[i].first);
        }
        rep(i,n){
            ma=max(ma,(int)ab[i].size());
        }
        f[0]=false;
        dfs(0,-1);
        out << ma << endl;
        rep(i,n-1){
            if(m.find({e[i].first,e[i].second})!=m.end()){
                out << m[{e[i].first,e[i].second}]+1 << endl;
            }else{
                out << m[{e[i].second,e[i].first}]+1 << endl;
            }
        }
	}
	void dfs(int node,int c){
	    for(int i=0;i<ab[node].size();i++){
	        if(f[ab[node][i]]) {
                f[ab[node][i]]=false;
                c++;
                c %= ma;
                m[{node, ab[node][i]}] = c;
                dfs(ab[node][i],c);
            }
	    }
	}
};


int main() {
	DColoringEdgesOnTree solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
long long dp[4001][4001],mod=998244353;
int n;
string s;
long long ans(int b,int cn)
{
	if(cn==2*n)return 1;
	if(dp[b][cn]!=0)return dp[b][cn];
	int r;
	if(cn>=n)r=2*n-b-cn;
	else r=2*(cn+1)-b-cn;
	int nb=0;
	if(cn<n-1)nb=s[cn+1]-'0';
	if(b!=0)dp[b][cn]+=ans(b-1+nb,cn+1);
	if(r!=0)dp[b][cn]+=ans(b+nb,cn+1);
	if(dp[b][cn]>mod)dp[b][cn]-=mod;
	return dp[b][cn];
}
int main()
{
	cin>>s;
	n=s.size();
	s+=s;
	cout<<ans(s[0]-'0',0)<<'\n';
}


Measured memory_bytes: 64000
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	int n, d; cin >> n >> d;
	vector<int> x(n), y(n);
	rep(i,n) cin >> x[i] >> y[i];
	two_sat ts(n); // use x = true
	rep(i,n){
		rep(j,n){
			if(i == j) continue;
			if(abs(x[i] - x[j]) < d){
				ts.add_clause(i, false, j, false);
			}
			if(abs(x[i] - y[j]) < d){
				ts.add_clause(i, false, j, true);
			}
			if(abs(y[i] - x[j]) < d){
				ts.add_clause(i, true, j, false);
			}
			if(abs(y[i] - y[j]) < d){
				ts.add_clause(i, true, j, true);
			}
		}
	}
	if(ts.satisfiable()){
		cout << "Yes\n";
		auto ans = ts.answer();
		rep(i,n){
			if(ans[i]) cout << x[i] << endl;
			else cout << y[i] << endl;
		}
	}else{
		cout << "No\n";
	}
}


Measured memory_bytes: 3800
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, A, B) = Read3Longs();
            var total = 0;
            for (var i = 1; i <= N; i++)
            {
                var n = i.ToString().ToArray().Sum(x => int.Parse(x.ToString()));
                if (n >= A && n <= B)
                {
                    total += i;
                }
            }
            return total;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 30332
#include<bits/stdc++.h>
#include<vector>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,N) for(int i=0;i<N;i++)

using namespace std;

int main(void){
    int D,C;
    cin>>D>>C;
    cout<<D*C<<endl;
}




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

B = [1]*N
R=[False]*N

R[0]=True

for i in range(M):
    x, y = map(int, input().split())
    x-=1
    y-=1
    if R[x] == True:
        R[y] = True
    B[x] -= 1
    B[y] += 1
    if B[x] == 0:
        R[x] = False

print(sum(R))


Measured memory_bytes: 4596
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.next();
        String t = input.next();
        int ans = 0;
        for (int i = 0; i < s.length(); i++){
            if (s.charAt(i) != t.charAt(i)){
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 41356
#include <bits/stdc++.h>
#define inf (int)(1e8)
using namespace std;

struct dat {
  int x, y, cost;
  dat(int _x, int _y, int c = 0) : x(_x), y(_y), cost(c) {}
};

using P = pair<int, int>;
int h, w, sx, sy, gx, gy;
vector<string> s;
vector<vector<int>> dist;
int d[4] = {0, 1, 0, -1};

int solve();
bool isvalid(int x, int y) {
  return x >= 0 && x < h && y >= 0 && y < w && s[x][y] == '.';
}

int main() {
  cin >> h >> w >> sx >> sy >> gx >> gy;
  --sx, --sy, --gx, --gy;
  dist.assign(h, vector<int>(w, inf));
  s.resize(h);
  for (auto& p : s) cin >> p;
  cout << solve() << endl;
  return 0;
}

int solve() {
  auto f = [](dat l, dat r) { return l.cost > r.cost; };
  priority_queue<dat, vector<dat>, decltype(f)> pq(f);
  pq.push(dat(sx, sy, 0));
  dist[sx][sy] = 0;
  while (pq.size()) {
    auto [x, y, c] = pq.top();
    pq.pop();
    if (dist[x][y] != c) continue;

    for (int i = 0; i < 4; ++i) {
      int nx = x + d[i], ny = y + d[i ^ 1];
      if (!isvalid(nx, ny)) continue;
      if (dist[nx][ny] > c) {
        dist[nx][ny] = c;
        pq.push(dat(nx, ny, c));
      }
    }

    for (int i = -2; i <= 2; ++i)
      for (int j = -2; j <= 2; ++j) {
        int nx = x + i, ny = y + j;
        if (!isvalid(nx, ny)) continue;
        if (dist[nx][ny] > c + 1) {
          dist[nx][ny] = c + 1;
          pq.push(dat(nx, ny, c + 1));
        }
      }
  }
  if (dist[gx][gy] == inf) return -1;
  return dist[gx][gy];
}


Measured memory_bytes: 9456
S = input()
if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
   print(5)
elif S == "WED":
   print(4)
elif S == "THU":
   print(3)
elif S == "FRI":
   print(2)
else:    
    print(1)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {


	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int length	   = Integer.parseInt(sc.next());
		int breadth	   = Integer.parseInt(sc.next());
		Rectangle rec  = new Rectangle(length, breadth);
		
		System.out.println(rec.calculateArea() + " " + rec.calculatePerimeter());
		
		sc.close();
	}
	
	


}

class Rectangle{
	
	private int length;
	private int breadth;
	
	Rectangle(){
		throw new IllegalArgumentException("It is not acceptable.");
	}
	
	Rectangle(int length,int breadth){
		
		this.length = length;
		this.breadth = breadth;
		
	}
	
	public int getLength(){
		return this.length;
	}
	
	public int getBreadth(){
		return this.breadth;
	}
	
	public int calculatePerimeter(){
		return 2*this.length + 2* this.breadth;
	}
	
	public int calculateArea(){
		return this.length * this.breadth;
	}
	
}



Measured memory_bytes: 26200
import numpy as np

N = int(input())
S = np.array([list(input()) for i in range(N)])

ans = 0
for i in range(N):
  S_new = np.c_[S[:, i:], S[:, :i]]
  if (S_new == S_new.T).all():
    ans += N

print(ans)

Measured memory_bytes: 13920
from collections import deque

N, M = map(int, input().split())
AB = [map(int, input().split()) for _ in range(M)]
#print(AB)
links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)
#print(AB)
#print(links)
result = [-1] * (N + 1)
q = deque([1])
#print(q)
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
            #print(q)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))

Measured memory_bytes: 106392
///*
#include<iostream>
#include<algorithm>
using namespace std;

int main() {

	int *line, number;
	int longest, others = 0;
	
	cin >> number;
	line = new int[number];
	
	for (int i = 0; i < number; i++) {
		cin >> line[i];
	}

	sort(line, line + number);
	
	longest = line[number - 1];
	for (int i = 0; i < number - 1; i++) {
		others += line[i];
	}

	/*debug
	for (int i = 0; i < number; i++) {
		cout << line[i] << " ";
	}
	cout << longest << " " << others << endl;
	*/

	longest < others ? cout << "Yes" << endl : cout << "No" << endl;

	return 0;
	
}
//*/

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,j;
	char cards[] = {'S', 'H', 'C', 'D'};
	char e;
	int k;
	int no;
	int num;
	int v[4][13];
	
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			v[i][j] = 0;
		}
	}
	
	scanf("%d",&no);
	for(i=0;i<no;i++){
		scanf(" %c",&e);
		scanf("%d",&num);
		switch(e){
		case 'S' : k = 0; break;
		case 'H' : k = 1; break;
		case 'C' : k = 2; break; 
		case 'D' : k = 3; break;
		}
		v[k][num - 1] = 1;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(v[i][j] == 0){
				printf("%c %d\n",cards[i],j + 1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    two_factor = 1
    for d in range(60):
        even = 0
        odd = 0
        for i in range(n):
            if a[i] & (1 << d):
                odd += 1
            else:
                even += 1
        add = (odd * even) % Mod * two_factor % Mod
        ans += add
        ans %= Mod
        two_factor = (two_factor * 2) % Mod
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 124524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	// 入力
	int x = sca.nextInt();

	// 処理
	int count;
	for(int j = x; ; j++) {
		count = 0;
		for(int i = 2; i <= j/2; i++) {
			if(j % i == 0) {
				count++;
				break;
			}
		}
		if(count == 0) {
			System.out.println(j);
			return;
		}
	}

	// 出力

	// 後始末
	//sca.close();
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int pi = (int) 2 * acos(0.0);

int main() {
  int n;
  cin >> n;
  string a;
  cin >> a;
  bool ok = (a.size() % 2 == 0);
  for (int i = 0; i < a.size() / 2; i++) {
    ok &= (a[i] == a[a.size() / 2 + i]);
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
const int inf = 1e8;
vector<int>g[maxn];
int n, k, value[maxn];
int result[maxn];

int li[maxn], ri[maxn];

bool defined[maxn];
bool check;

void dfs(int node, int p) {
    int cnt[2] = {0, 0};
    if(value[node] != -1) {
        li[node] = ri[node] = value[node];
        defined[node] = true;
    }


    for(int i:g[node]) {
        if(i!=p) {
            dfs(i, node);

            if(defined[i]) {
                cnt[li[i]%2]++;
            }
        }
    }

    if(cnt[0] > 0 && cnt[1] > 0) {
        check = true;
        return;
    }

    if(value[node] == -1) {
        li[node] = INT_MIN;
        ri[node] = INT_MAX;
    }

    for(int i:g[node]) {
        if(i!=p) {
            if(defined[i]) {
                li[node] = max(li[node], li[i]-1);
                ri[node] = min(ri[node], ri[i]+1);
                defined[node] = true;
            }
        }
    }

    if(li[node] > ri[node]) {
        check = true;
        return;
    }
}

void dfs2(int node, int p) {

    if(value[node] == -1) {
        int x = value[p] - 1;
        if(x >= li[node] && x <= ri[node]) value[node] = x;

        x = value[p] + 1;
        if(x >= li[node] && x <= ri[node]) value[node] = x;


        if(value[node] == -1) {
            check = true;
            return;
        }
    }

    for(int i:g[node]) {
        if(i!=p) {
            dfs2(i, node);
        }
    }
}

int main() {
    cin>>n;

    int a, b;
    for(int i=0;i<n-1;i++) {
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);

    }

    cin>>k;
    memset(value, -1, sizeof(value));
    memset(result, -1, sizeof(result));
    for(int i=0;i<k;i++) {
        cin>>a>>b;
        value[a] = b + inf;
    }

    dfs(1, -1);

    if(check) {
        cout<<"No\n";
        return 0;
    }

    /*for(int i=1;i<=n;i++) {
        cout<<i<<": "<<li[i]<<" "<<ri[i]<<"\n";
    }*/

    value[1] = li[1];
    dfs2(1, -1);

    if(check) {
        cout<<"No\n";
        return 0;
    }

    cout<<"Yes\n";
    for(int i=1;i<=n;i++) {
        cout<<value[i] - inf<<"\n";
    }

    return 0;
}

Measured memory_bytes: 17408
#!/usr/bin/env python3
import sys
from collections import defaultdict
INF = float("inf")
MOD = 998244353  # type: int


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % MOD
    elif y % 2 == 0:
        return power(x, y//2)**2 % MOD
    else:
        return power(x, y//2)**2 * x % MOD


def solve(N: int, a: "List[int]"):

    S = sum(a)
    # dp = [defaultdict(int) for _ in range(N)]
    dp = [[0]*(S+1) for _ in range(N)]
    # dp2 = [defaultdict(int) for _ in range(N)]
    dp2 = [[0]*(S+1) for _ in range(N)]
    dp[0][0] = 2
    dp[0][a[0]] = 1
    dp2[0][0] = 1
    dp2[0][a[0]] = 1
    for i in range(1, N):     # i+1番目の数字まで使ったとき
        # for key in dp[i-1]:
        for key in range(S+1):
            dp[i][key] = 2*dp[i-1][key]+dp[i-1][key-a[i]]
            dp[i][key] %= MOD
            dp2[i][key] = dp2[i-1][key] + dp2[i-1][key-a[i]]
            dp2[i][key] %= MOD

    # ans = power(3, N) - sum([dp[N-1][i] for i in range(-(-S//2), S+1)])*3
    ans = power(3, N) - sum(dp[N-1][-(-S//2):])*3
    ans %= MOD
    if S % 2 == 0:              #
        ans += 3*dp2[N-1][-(-S//2)]
        ans %= MOD
    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


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

int n, c[200010], mod = 1e9+7, dp[200010], tmp[200010], ind[200010];
vector<int> v[200010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i) cin >> c[i+1];
	for(int i=1; i<=n; ++i){
		if(i == n || c[i] != c[i+1]){
			v[c[i]].push_back(i);
		}
	}
	dp[0] = 1;
	for(int i=1; i<n; ++i){
		if(c[i] != c[i+1]){
			++ind[c[i]];
			if(ind[c[i]] < v[c[i]].size()){
				int j = ind[c[i]];
				tmp[c[i]] += dp[i-1];
				tmp[c[i]] %= mod;
				dp[v[c[i]][j]] += tmp[c[i]];
				dp[v[c[i]][j]] %= mod;
			}
		}
		dp[i] += dp[i-1];
		dp[i] %= mod;
	}
	cout << (dp[n-1] + dp[n]) % mod << "\n";
//	for(int i=0; i<=n; ++i)
//		cerr << i << " " << dp[i] << "\n";
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int n, m;

int main() {
	while(scanf("%d %d", &n, &m) != EOF) {
		int ans = 0;
		if(m % n == 0) ans = m / n;
		else {
			int t = m / n;
			for(int i = 1; i <= t; i++) {
				if(m % i == 0 && i <= m / n) ans = max(ans, i);
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 100005;
string s[MAX_N];

int main() {
    int n;
    cin >> n;
    rep(i,n){
        string ss;
        cin >> ss;
        int x[10];
        rep(j,10){
            x[j] = (int)ss[j];
        } 
        sort(x,x+10);
        rep(j,10){
            s[i] += (char)x[j];
        }
    }

    sort(s,s+n);

    ll ans = 0;

    ll count = 0;
    rep(i,n){
        if(i==0){
            count++;
        }else{
            if(s[i]==s[i-1]){
                count++;
            }else{
                ans += (count-1)*count/2;
                count = 1;
            }
        }
        if(i==n-1){
            ans += (count-1)*count/2;
        }
    }

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


Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int main(){
    int a, p;
    cin >> a >> p;
    int res = (a * 3 + p) / 2;


    cout << res << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){

	int n,m;
	while(cin>>n>>m,n!=0||m!=0){
		vector<int> a(n);
		for(int i=0;i<n;i++)
			cin>>a[i];
		sort(a.begin(),a.end());
		int s=0;
		int k=1;
		for(int i=n-1;i>=0;i--){
			if(k!=m){
				s+=a[i];
				k++;
			}
			else
				k=1;
		}
		cout<<s<<endl;
	}
	
}

Measured memory_bytes: 1216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 10; i++)
                for (int j = 1; j < 10; j++)
                    Console.WriteLine("{0}x{1}={2}", i, j, i * j);
            
        }
    }
}

Measured memory_bytes: 5596
#include <iostream>
#define INF 1000000000000

using namespace std;
using llong = long long;

llong dist[100][100];
int main(){
  int N,M;
  cin >> N >> M ;
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      if(i!=j) dist[i][j] = INF;
    }
  }
  for(int i=0;i<M;++i){
    int s,t;
    llong d;
    cin >> s >> t >> d;
    dist[s][t] = d;
  }
  
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      for(int k=0;k<N;++k){
        if(dist[j][i]==INF || dist[i][k] == INF){
          dist[j][k] = dist[j][k];
        }else{
          dist[j][k] = min(dist[j][i]+dist[i][k],dist[j][k]); 
        }
      }
    }
  }
  
  for(int i=0;i<N;++i){
    if(dist[i][i] < 0){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }

  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      if(dist[i][j] != INF) cout << dist[i][j];
      else cout << "INF" ;

      if(j != N-1) cout << " " ;
      else cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main(void){
    while(1){
        int n,r,i,p,c;
        cin>>n>>r;
        if(n==0) break;
        valarray<int> deck(n);
        for(i=0;i<n;i++){
            deck[i]=n-i;
        }
        for(i=0;i<r;i++){
            int j;
            cin>>p>>c;
            valarray<int> top = deck[slice(0,p-1,1)];
            valarray<int> mid = deck[slice(p-1,c,1)];
            for(j=0;j<mid.size();j++){
                deck[j]=mid[j];
            }
            for(;j<mid.size()+top.size();j++){
                deck[j]=top[j-mid.size()];
            }
        }
        cout<<deck[0]<<endl;
    }
    return 0;
}


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

int n;
int memo[100005] = {0};

int solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++memo[max(0, x - 1)];
    --memo[x + 2];
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  for(int i = 0; i <= 100000; ++i) {
    if(i != 0) memo[i] += memo[i - 1];
    ans = max(ans, memo[i]);
  }
  return ans;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll; 
const ll INF = 1LL << 60;
const ll MOD = 998244353;
ll dp1[200000][16];
ll dp2[200000][16];
ll A[200000], B[200000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i] * 2;
	}
	fill((ll*)dp1, (ll*)(dp1 + N), INF);
	for (int i = 0; i <= 15; i++) dp1[N - 1][i] = i;
	for (int i = N - 2; i >= 0; i--) {
		if (A[i] <= A[i + 1]) {
			ll t = A[i];
			int k = 0;
			while (t <= A[i + 1]) {
				t *= 4;
				k++;
			}
			for (int j = 0; j <= 15; j++) {
				int x = max(j - k + 1, 0);
				dp1[i][j] = min(dp1[i][j], j + dp1[i + 1][x]);
			}
		}
		else {
			ll t = A[i + 1];
			int k = 0;
			while (t < A[i]) {
				t *= 4;
				k++;
			}
			for (int j = 0; j <= 15; j++) {
				int x = j + k;
				if (x >= 15) dp1[i][j] = min(dp1[i][j], j + dp1[i + 1][15] + (N - i - 1)*(x - 15));
				else dp1[i][j] = min(dp1[i][j], j + dp1[i + 1][x]);
			}
		}
	}
	fill((ll*)dp2, (ll*)(dp2 + N), INF);
	for (int i = 0; i <= 15; i++) dp2[0][i] = i;
	for (int i = 1; i < N; i++) {
		if (B[i] <= B[i - 1]) {
			ll t = B[i];
			int k = 0;
			while (t <= B[i - 1]) {
				t *= 4;
				k++;
			}
			for (int j = 0; j <= 15; j++) {
				int x = max(j - k + 1, 0);
				dp2[i][j] = min(dp2[i][j], j + dp2[i - 1][x]);
			}
		}
		else {
			ll t = B[i - 1];
			int k = 0;
			while (t < B[i]) {
				t *= 4;
				k++;
			}
			for (int j = 0; j <= 15; j++) {
				int x = j + k;
				if (x >= 15) dp2[i][j] = min(dp2[i][j], j + dp2[i - 1][15] + i * (x - 15));
				else dp2[i][j] = min(dp2[i][j], j + dp2[i - 1][x]);
			}
		}
	}
	ll ans = min(dp1[0][0] * 2, dp2[N - 1][0] * 2 + N);
	for (int i = 0; i + 1 < N; i++) {
		ans = min(ans, dp2[i][0] * 2 + (i + 1) + dp1[i + 1][0] * 2);
	}
	cout << ans << endl;
 }

Measured memory_bytes: 53376
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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;}

typedef long long lint;

using namespace std;
int main(){
	lint a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a*b,c*d)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static final int MOD = (int) (Math.pow(10, 9) + 7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] a = new long[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            long temp = Long.parseLong(sc.next());
            a[i] = temp;
            sum += temp;
        }
        long ans = Long.MAX_VALUE;
        long x = 0;
        for (int i = 0; i < n - 1; i++) {
            x += a[i];
            ans = Math.min(ans, Math.abs(sum - x - x));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 62276
#include <cstdio>
#include <cstring>
using namespace std;
char a[101];
int len;
int main()
{
	scanf("%s",a+1);
	len=strlen(a+1);
	for(int i=1;i<=len;i++)
	{
		if(a[i]=='C')
		{
			for(int j=i;j<=len;j++)
				if(a[j]=='F')
				{
					printf("Yes");
					return 0;
				}
			printf("No");
			return 0;
		}
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
			arr[i]=sc.nextInt();
		int c=0;
		for(int i=0;i<n-2;i++){
			if((arr[i+1]>arr[i]&&arr[i+1]<arr[i+2])||(arr[i+1]<arr[i]&&arr[i+1]>arr[i+2]))
				c++;
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 22732
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  int n;
  cin>>n;
  ll ara[n+5];
  ll sum=0;
  for(int i=0;i<n;i++)cin>>ara[i],sum+=ara[i];
  ll cur=0;
  ll mn=12345678901234567;
  for(int i=0;i<n-1;i++)
  {
    cur+=ara[i];
    ll left=sum-cur;
    mn=min(mn,abs(cur-left));
  }
  cout<<mn<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_end=(a);i>=i##_end;--i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef double ld;
typedef long long ll;
typedef long double lf;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f,mo=1e9+7;
template<typename A,typename B>inline bool upmx(A&x,const B&y){return x<y?x=y,1:0;}
template<typename A,typename B>inline bool upmn(A&x,const B&y){return x>y?x=y,1:0;}
template<typename T>inline T gcd(T x,T y){for(;y;swap(x,y))x%=y;return x;}
inline int Pow(int a,int b,int p=mo){int r=1;for(;b;b>>=1,a=1ll*a*a%p)if(b&1)r=1ll*r*a%p;return r;}
inline ll rd(){
	ll x;int f=1,c;for(;!isdigit(c=getchar());)f=c!='-';x=c-'0';
	for(;isdigit(c=getchar());)x=x*10+c-'0';return f?x:-x;
}
#ifdef flukehn
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
const int N=1e5+11;
int n;
ll a[N];
int b[N];
ll f[N],g[N],ff[N],gg[N];
ll C;
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	n=rd(),C=rd();
	rep(i,1,n)a[i]=rd(),b[i]=rd();
	ll ans=0;
	rep(i,1,n){
		f[i]=f[i-1]+b[i];
		
	}
	rep(i,1,n)f[i]-=a[i];
	rep(i,1,n){
		ff[i]=max(f[i],ff[i-1]);
	}
	ans=ff[n];
	per(i,1,n){
		g[i]=g[i+1]+b[i];
		
	}
	per(i,1,n){
		g[i]-=(C-a[i]);
		upmx(ans,g[i]);
		upmx(ans,g[i]-(C-a[i])+ff[i-1]);
	}
	per(i,1,n)gg[i]=max(gg[i+1],g[i]);
	rep(i,1,n){
		upmx(ans,f[i]-a[i]+gg[i+1]);
	}
	cout<<ans;
}


Measured memory_bytes: 4480
n = int(input())
a,b = map(int,input().split())
lis = list(map(int,input().split()))
pro1,pro2,pro3 = 0,0,0
for problem in lis:
  if problem <= a:pro1 += 1
  elif problem <= b:pro2 += 1
  else:pro3 += 1
print(min(pro1,pro2,pro3))

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

int main()
{
    int N;
    cin >> N;
    int a;
    int ans = 0;
    for (int i = 1; i < N + 1; i++) {
        cin >> a;
        if (i % 2 == 1 && a % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    ll n, x;
    cin >> n >> x;

    ll ans = n;
    ll w = x; // width
    ll h = n - x; // height

    while (true) {
        if (w > h) {
            if (w % h == 0) {
                ans += (w / h) * h * 2 - h;
                break;
            }
            ans += (w / h) * h * 2;
            w = w % h;
        } else {
            if (h % w == 0) {
                ans += (h / w) * w * 2 - w;
                break;
            }
            ans += (h / w) * w * 2;
            h = h % w;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
#define ll long long
using namespace std;
int n;
int op[200008];int inv[200008];
multiset<pair<int,int> >ms; 
int tree[65536*8+10];int nn=65536*4;
int pn[200008];
int ps[200008];
int bas=100408;
int _query(int a,int b,int l,int r,int id)
{
	if(l>=a and r<=b) return tree[id];
	if(a>r or b<l) return 0;
	return _query(a,b,l,(l+r)/2,id*2)+_query(a,b,(l+r)/2+1,r,id*2+1);
}
void _update(int x,int y)
{
	while(x)
	{
		tree[x]+=y;x=x/2;
	}
}
ll calc(int fix)
{
	memset(tree,0,sizeof(tree));
	for(int i=1;i<=n;i++)
	{
		if(op[i]<=fix) pn[i]=1;else pn[i]=-1;
	}
	for(int i=1;i<=n;i++)
		ps[i]=ps[i-1]+pn[i];
	ll ans=0;
	_update(0+bas+nn-1,1);
	for(int i=1;i<=n;i++)
	{
		ans+=(ll)_query(1,ps[i]+bas-1,1,nn,1);
		_update(ps[i]+bas+nn-1,1);
	}
	return ans;
}
int main()
{
	cin>>n;for(int i=1;i<=n;i++) scanf("%d",&op[i]),ms.insert(make_pair(op[i],i));
	int tot=0;//6162:51
	for(multiset<pair<int,int> >::iterator it=ms.begin();it!=ms.end();it++)
	{
		pair<int,int> p=*it;
		inv[++tot]=op[p.second];
		op[p.second]=tot;
	}
	int l=1,r=tot;int ans=1;
	ll pop=(ll)n*(ll)(n-1)/(ll)2+(ll)n;pop=pop/(ll)2;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(calc(mid-1)<=pop)
		{
			l=mid+1;ans=mid;
		}
		else 
		{
			r=mid-1;
		}
	}//cout<<calc(51-1);
	cout<<inv[ans];
	return 0; 
}

Measured memory_bytes: 10624