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

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n), dp(n);
    for(int i=0; i<n; i++)
    {
        cin >> vec[i];
    }

    dp[0] = 0;
    dp[1] = abs(vec[1] - vec[0]);
    for(int i=0; i<n-2; i++)
    {
        dp[i+2] = min(dp[i+1] + abs(vec[i+2] - vec[i+1]), dp[i] + abs(vec[i+2] - vec[i]));
    }

    cout << dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    string s;cin>>s;
    //cout<<s<<endl;
    //cout<<s.size()<<endl;
    
    ll ans=INF;
    
    rep(i,27){
        string ins=s;
        string see;
        ll cnt=0,sum=0;
        while(1){
            bool all_same = true;
            rep(j, ins.size()){
                if (ins[j] != (char)('a' + i))
                    all_same = false;
            }

            if (sum > 1e3)
                break;
            if (all_same){
                break;
            }

            rep(j,ins.size()-1){
                if(ins[j+1]==(char)('a'+i)){
                    see.push_back(ins[j+1]);
                }else{
                    see.push_back(ins[j]);
                }
            }
            ins = see;
            see = {};
            sum++;
        }
        
        chmin(ans, sum);
    }

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

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
    int N,D,X;
    std::cin >> N >> D >> X;
    std::vector<int> A(N);
    for(int i=0;i<N;i++){
        std::cin >> A[i];
    }
    int sum=X,j=0;
    for(int i=0;i<N;i++){
        j=0;
        while(j*A[i]+1<=D){
            sum++;
            j++;
        }

    }
    std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
 
using namespace std;
typedef long long int lli;
 
int main(){
	int N;
	cin>>N;
	int l[200];
	rep(i,2*N)cin>>l[i];
	sort(l,l+2*N);
	int ans=0;
	for(int i=0;i<2*N;i+=2)ans+=l[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
//Addition.cpp (A)
#include <iostream>
using namespace std;

int main(){
  int N,A;
  int total = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A;
    if(A%2 == 1) ++total;
  }
  if(total%2 == 0) printf("YES\n");
  else printf("NO\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    int m;
    cin >> n >> m;
    
    vector<int> c = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    vector<int> a(m);
    
    for ( int i = 0; i < m; i++ )
        cin >> a[i];
    
    sort(a.begin(), a.end(), greater<int>());
    
    vector<ll> dp(n+1);
    dp[0] = 1;
    
    for ( auto x: a ){
        for ( ll i = 0; i <= n; i++ ){
            if ( i < c[x] ) continue;
            dp[i] = max(dp[i], dp[i-c[x]] + 1 );
        }
    }

    
    ll pos = n;
    vector<ll> ans;
    for(; pos > 0; ){
        for ( auto x: a ){
            if ( pos - c[x] < 0 ) continue;
            else if ( dp[pos - c[x]] + 1 == dp[pos] ){
                ans.push_back(x);
                pos -= c[x];
                break;
            }else{
                continue;
            }
        }
    }
    
    for (auto x: ans)
        cout << x;
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[4];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int n;
	cin >> n;
	while (n--) {
		string s;
		cin >> s;
		if (s == "AC") a[0]++;
		if (s == "WA") a[1]++;
		if (s == "TLE") a[2]++;
		if (s == "RE") a[3]++;
	}
	cout << "AC x " << a[0] << '\n';
	cout << "WA x " << a[1] << '\n';
	cout << "TLE x " << a[2] << '\n';
	cout << "RE x " << a[3] << '\n';
}


Measured memory_bytes: 3664
#include<stdio.h>

int main() {
    int n;
    int max = -1000000100, min = 1000000100;
    int i, j;
    int r;

    scanf("%d", &n);
    scanf("%d", &min);
    for(i = 1; i < n; i++) {
        scanf("%d", &r);
        if (max < r - min) max = r - min;
        if (min > r) min = r;
    }

    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 1852
# みんなのプロコン 2019: B – Path
a, b = [], []
for _ in range(3):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

paths = a + b
passed_cities = []

for city in range(1, 5):
    passed_cities.append(paths.count(city))

print('NO' if max(passed_cities) == 3 else 'YES')

Measured memory_bytes: 9132
#pragma GCC optimize("Ofast")
#include<stdio.h>
int x;
char c;
inline int read()
{
	x=0; c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return x;
}
int main()
{
	long n = read(), ans = n;
	for (int i = 1; i < n; ++i)
	{
        int u = read(), v = read();
		if (u > v) ans += i * (n - i + 1) - v * (n - u + 1);
        else ans += i * (n - i + 1) - u * (n - v + 1);
	}
	printf("%ld", ans);
  
    return 0;
}


Measured memory_bytes: 1604
def main():
    from collections import namedtuple
    from operator import attrgetter

    Dish = namedtuple('Dish', 'time deliciousness')

    N, T = map(int, input().split())
    dishes = []
    for _ in range(N):
        a, b = map(int, input().split())
        d = Dish(time=a, deliciousness=b)
        dishes.append(d)

    dishes.sort(key=attrgetter('time'))

    dp = [0] * T
    ma = 0
    ret = 0
    for d in dishes:
        ret = max(ret, ma + d.deliciousness)
        for t in range(T - 1, d.time - 1, -1):
            dp[t] = max(dp[t], dp[t - d.time] + d.deliciousness)
            ma = max(ma, dp[t])
    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 46956
import pprint
N = int(input())
A = list(map(int, input().split()))

def student_sorting(N, A):
    student_list = [0] * N

    for initial_pos, activity in enumerate(A):
        student_list[initial_pos] = (activity, initial_pos)

    return sorted(student_list, reverse = True)

def DP(N, student_list):
    DP_map = list(list(0 for row in range(N + 1 - column)) for column in range(N + 1))
    ans_list = []
    ans = 0

    for left in range(N): #初期値設定 right = 0
        activity = student_list[left][0]
        distance_l = abs(left - student_list[left][1])
        DP_map[left + 1][0] = DP_map[left][0] + activity * distance_l

    for right in range(N): #初期値設定 left = 0
        activity = student_list[right][0]
        distance_r = abs((N - 1 - right) - student_list[right][1])
        DP_map[0][right + 1] = DP_map[0][right] + activity * distance_r

    for left in range(1, N + 1):
        for right in range(1, N - left + 1):
            activity = student_list[left + right - 1][0]
            distance_l = abs((left - 1) - student_list[left + right - 1][1])
            distance_r = abs((N - right) - student_list[left + right - 1][1])
            score_if_appended_to_left = DP_map[left - 1][right] + activity * distance_l
            score_if_appended_to_right = DP_map[left][right - 1] + activity * distance_r
            DP_map[left][right] = max(score_if_appended_to_left, score_if_appended_to_right)

    for left in range(N + 1):
        row = N - left
        column = left
        ans_list.append(DP_map[column][row])

    ans = max(ans_list)

    return ans

student_list = student_sorting(N, A)
ans = DP(N, student_list)
print(ans)


Measured memory_bytes: 122204
#include <iostream>
using namespace std;
int main(void){
    int cnt = 1;
    long long x,y,a;
    cin >> x >> y;
    
    a = x;
    
    while(a <= y){
        a *= 2;
        cnt++;
        if(a > y){
            cnt--;
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,k,x,y;
    cin >> n >> k >> x >> y;
    int64_t res = 0;
    rep(i,n){
        if(i<=k-1) res += x;
        if(i>k-1) res += y;
    }
    cout << res << endl;
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    string s;
    cin >> s;
    int len = s.size();

    int l = 0, r = len-1;
    int ans = 0;
    while(l < r) {
        if(s[l] == s[r]) {
            l++; r--;
        } else if(s[l] == 'x') {
            l++; 
            ans++;
        } else if(s[r] == 'x') {
            r--; 
            ans++;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


/*atcoder*/


Measured memory_bytes: 3776
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"--->"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here
char mat[100][100];
ll n,m;
ll check(ll r,ll c){
    ll cnt = 0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if (r & (1 << i)){
                continue;
            }
            if (c & (1 << j)) continue;
            if(mat[i][j]=='#') cnt++;
        }
    }
    // cout<<cnt<<NL;
    return cnt;
}                                


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,T; //basic variables

    cin>>n>>m>>k;
    ll ans = 0;

    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>mat[i][j];
        }
    }

    for(i=0;i<(1<<n);i++){
        for(j=0;j<(1<<m);j++){
            ll x = check(i,j);
            if(x==k) ans++;
        }
    }
    cout<<ans<<NL;

    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 3612
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def f(start, end, n):
    if n == 1:
        for i in range(start, end + 1):
            yield [i]
        return
    for i in range(start, end + 1):
        for nn in f(i, end, n - 1):
            yield [i] + nn


def main():
    # N = int(input())
    N, M, Q = [int(a) for a in input().split()]
    abcd = [
        [int(a) for a in input().split()]
        for _ in range(Q)
    ]


    res = 0
    for v in f(1, M, N):

        total = 0
        for a, b, c, d in abcd:
            if v[b - 1] - v[a - 1] == c:
                total += d

        res = max(res, total)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10164
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a[1001],sum=0;
    cin>>n>>k;

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }

    sort(a,a+n);

    for(int i=0;i<k;i++)
    {
        sum += a[i];
    }

    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

int n;
int x[100000];
int y[100000];
int p[100000];
PP e[200000 - 2];

int find(int a){
    return p[a] == a ? a : p[a] = find(p[a]);
}

bool same(int a, int b){
    return find(a) == find(b);
}

void unite(int a, int b){
    int x = find(a);
    int y = find(b);
    p[x] = y;
}

void make(int* x, PP* e){
    vector<P> v;
    rep(i, n){
        v.push_back(P(x[i], i));
    }
    sort(v.begin(), v.end());
    rep(i, n - 1){
        e[i] = PP(v[i + 1].first - v[i].first, P(v[i].second, v[i + 1].second));
    }
}

int main(){
    cin >> n;
    rep(i, n){
        cin >> x[i] >> y[i];
    }

    make(x, e);
    make(y, e + n - 1);

    rep(i, n){
        p[i] = i;
    }
    sort(e, e + 2 * n - 2);
    int ans = 0;
    rep(i, 2 * n - 2){
        if(!same(e[i].second.first, e[i].second.second)){
            unite(e[i].second.first, e[i].second.second);
            ans += e[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5220
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    s = input()
    a = False
    b = False
    for i in range(3):
        if s[i] == 'A':
            a = True
        if s[i] == 'B':
            b = True
    if a and b:
        print('Yes')
    else:
        print('No')
    
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 66156
//42
#include<iostream>
#include<cstring>

using namespace std;

#define ISEOB(X) !strcmp(X,"END_OF_TEXT")

int main(){
  char g[101][1002]={{}};
  char buf[sizeof(g[0])]={};
  for(int i=0;cin.getline(g[i],sizeof(g[0])),!ISEOB(g[i]);i++);
  int x=0,y=0;
  for(char c;cin>>c,c!='-';){
    switch(c){
    case 'a':
      x=0;
      break;
    case 'e':
      x=strlen(g[y]);
      break;
    case 'p':
      if(y){
	y--;
      }
      x=0;
      break;
    case 'n':
      if(!ISEOB(g[y+1])){
	y++;
      }
      x=0;
      break;
    case 'f':
      if(g[y][x]!='\0'){
	x++;
      }else if(!ISEOB(g[y+1])){
	x=0;
	y++;
      }
      break;
    case 'b':
      if(x){
	x--;
      }else if(y){
	y--;
	x=strlen(g[y]);
      }
      break;
    case 'd':
      if(g[y][x]!='\0'){
	memmove(g[y]+x,g[y]+x+1,strlen(g[y]+x));
      }else if(!ISEOB(g[y+1])){
	strcpy(g[y]+x,g[y+1]);
	memmove(g[y+1],g[y+2],(101-y-2)*sizeof(g[0]));
      }
      break;
    case 'k':
      if(g[y][x]=='\0'){
	if(!ISEOB(g[y+1])){
	  strcpy(g[y]+x,g[y+1]);
	  memmove(g[y+1],g[y+2],(101-y-2)*sizeof(g[0]));
	  buf[0]='\n';
	}
      }else{
	strcpy(buf,g[y]+x);
	g[y][x]='\0';
      }
      break;
    case 'y':
      if(buf[0]=='\0'){
      }else if(buf[0]=='\n'){
	memmove(g[y+2],g[y+1],(101-y-2)*sizeof(g[0]));
	strcpy(g[y+1],g[y]+x);
	g[y][x]='\0';
	y++;
	x=0;
      }else{
	char tmp[sizeof(g[0])];
	strcpy(tmp,g[y]+x);
	strcpy(g[y]+x,buf);
	strcat(g[y],tmp);
	x+=strlen(buf);
      }
      break;
    }
  }
  for(int i=0;!ISEOB(g[i]);i++){
    cout<<g[i]<<endl;
  }
  return 0;
}
      
	
	
    

Measured memory_bytes: 1272
#include<algorithm>
#include<iostream>
#include<map>

using namespace std;

map<int, int> cnt;
int res, n, x;
int main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x;
		cnt[x]++;
	}
	for(map<int,int>::iterator it = cnt.begin();it != cnt.end();it++){
		if(it->first <= it->second){
			res += (it->second - it->first);
		}
		else{
			res += it->second;
		}
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4736
N, K = map(int, input().split())
H = list(map(int, input().split()))

INF = 10**9 + 1
L = [INF]*N
L[0] = 0
for i in range(1, N):
    minLi = L[i]
    H_i = H[i]
    for k in range(1, K+1):
        if i - k >= 0:
            minLi = min(minLi, L[i-k] + abs(H_i - H[i-k]))
    L[i] = minLi
print(L[N-1])


Measured memory_bytes: 84724
/* ex 9_2
   yumizmiz */

#include <stdio.h>
#include <stdlib.h>
//最大要素数
#define SIZE 100000
//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    //リストの先頭
    node *first = NULL;
    //キューブの配列,最大文字数10^5+1
    char cubes[SIZE+1], *ptr;
    ptr = cubes;
    scanf("%s",cubes);
    
    int pop_count = 0;
    while(*ptr){
        //空だったら無条件にpushする．または同じ色なら取り除かずpush
        if(first == NULL || first->elem == *ptr){
            push(&first,*ptr);
        }
        else{
            pop(&first);
            //取り除く数は2つ
            pop_count+=2;
        }
        ptr++;
    }
    printf("%d",pop_count);
    return 0;
}

Measured memory_bytes: 4880
from bisect import bisect_left

def solve():
    N,M = map(int, input().split())
    cities_in_prefecture = [[] for _ in range(N)]
    city_ids = []
    PYs = []
    for _ in range(M):
        P,Y = map(int, input().split())
        PYs.append((P,Y))
        cities_in_prefecture[P-1].append(Y)
    for p in range(N): cities_in_prefecture[p].sort()
    for P, Y in PYs:
        x = bisect_left(cities_in_prefecture[P-1], Y)
        # print(x, cities_in_prefecture[P-1])
        print('{0:06d}{1:06d}'.format(P, x+1), flush=True)
        
solve()

Measured memory_bytes: 32760
#!/usr/bin/env python
# coding: utf-8

import sys


def is_rectangle(side_a, side_b, diagonal):
    if side_a == side_b:
        return False
    return (side_a ** 2 + side_b ** 2) == diagonal ** 2


def is_rhombus(side_a, side_b, diagonal):
    if side_a != side_b:
        return False
    elif (side_a ** 2 + side_b ** 2) == diagonal ** 2:
        return False
    else:
        return True


def main():
    params = [[int(x) for x in line.split(",")] for line in sys.stdin.readlines()]
    rectangles = 0
    rhombuses = 0
    for param in params:
        if is_rectangle(*param):
            rectangles += 1
        elif is_rhombus(*param):
            rhombuses += 1

    print rectangles
    print rhombuses


if __name__ == '__main__':
    main()

Measured memory_bytes: 5672
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
  int N;
  while (cin >> N) {
    double s = 0;
    for (int i = 0; i < N; ++i) {
      double a;
      cin >> a;
      s += 1/a;
    }
    printf("%0.8f\n", 1/s);
  }
}


Measured memory_bytes: 256
//look at my code
//my code is amazing
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define vc vector
#define pb push_back
#define ar array
#define all(a) (a).begin(), (a).end()
#define ms(v,n,x) fill(v,v+n,x);
#define init(c,a) memset(c,a,sizeof(c))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
// const int N=;

int32_t main()
{
    
	fast
	
	ll n;
	cin>>n;
	
	// ll m=(ll)(log(ceil((float)n/(float)100))/log(1.01));
	ll p=100;
	for(ll i=1;;i++){
		ll r=p/100;
		p+=r;
		if(p>=n)
		{
			cout<<i;
			return 0;
			
		}
		
	}
	



    

	return 0;
    
}

Measured memory_bytes: 3588
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    int E = sc.nextInt();
    int F = sc.nextInt();
    System.out.println((E-A<=F)?"Yay!":":(");
  }
}


Measured memory_bytes: 22868
def solve(N, Y):
    r = [5000 for _ in range(N)]
    for i in range(N + 1):
        s = sum(r)
        if s == Y:
            return (
            len([d for d in r if d == 10000]), len([d for d in r if d == 5000]), len([d for d in r if d == 1000]))
        elif s < Y and i < N:
            r[i] = 10000
        elif s > Y and i < N:
            r[i] = 1000
    return (-1, -1, -1)


if __name__ == "__main__":
    N, Y = tuple(map(int, input().split(" ")))
    print(" ".join(map(str, list(solve(N, Y)))))


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a <= 0 && b >= 0){
        cout << "Zero" << endl;
        return 0;
    }
    if(a > 0 && b > 0){
        cout << "Positive" << endl;
        return 0;
    }
    if(a < 0 && b < 0){
       cout << ((b-a+1)%2 ? "Negative" : "Positive") << endl;
       return 0;
    }
    return 0;
}

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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    string o, e;
    read(o, e);
    
    FOR(e.size()) {
        write(o[i]);
        write(e[i]);
    }
    
    if (o.size() > e.size()) {
        print(o.back());
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        
        solve();
        
    }
    
}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int a, b; cin >> a >> b;
	if (b%a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class program{
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        var t = new int[N+1];
        var x = new int[N+1];
        var y = new int[N+1];
        t[0] = 0;
        x[0] = 0;
        y[0] = 0;

        for(int i=0; i<N; i++){
            var line = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
            t[i+1] = line[0];
            x[i+1] = line[1];
            y[i+1] = line[2];
        }

        bool can = true;
        for(int i=1; i<=N; i++){
            if(isReachable(t[i] - t[i-1], getDistance(x[i], x[i-1]), getDistance(y[i], y[i-1])) == false){
                can = false;
                break;
            }
        }
        if(can) Console.WriteLine("Yes");
        else    Console.WriteLine("No");
    }

    public static bool isReachable(int t, int x, int y){
        return t >= x+y && (x + y - t) % 2 == 0;
    }

    public static int getDistance(int a, int b){
        var dif = a - b;
        return dif >= 0 ? dif : -dif;
    }
}


Measured memory_bytes: 16352
#include <iostream>
using namespace std;
int n, m, c, s, ans, a, b[25];
int main() {
	int i;
	cin>>n>>m>>c;
	for(i=0; i<m; i++) cin>>b[i];
	while(n--) {
		for(i=s=0; i<m; i++) {
			cin>>a;
			s += a * b[i];
		}
		if(s + c > 0) ans++;
	}
	cout<<ans;
	return 0;
}

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

int w[11];
int a,b,c,aa,bb,cc,ans=1e9;
int sz[4],n;
void dfs(int pos)
{
    if(pos==n+1)
    {
        if(sz[1]==0||sz[2]==0||sz[3]==0)return ;
        int res=abs(a-aa)+abs(b-bb)+abs(c-cc)+(sz[1]+sz[2]+sz[3]-3)*10;
        ans=min(ans,res);
        return ;
    }
    else
    {
        for(int i=0;i<4;i++)
        {
            if(i==1) aa+=w[pos];
            if(i==2) bb+=w[pos];
            if(i==3) cc+=w[pos];
            sz[i]++;
            dfs(pos+1);
            if(i==1) aa-=w[pos];
            if(i==2) bb-=w[pos];
            if(i==3) cc-=w[pos];
            sz[i]--;
        }
    }
}
int main()
{
  scanf("%d%d%d%d",&n,&a,&b,&c);
  for(int i=1;i<=n;i++)
    scanf("%d",&w[i]);
    dfs(1);
    cout<<ans;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
p=[int(x) for x in input().split()]
#さいころの出目の和を集計
for i in range(n):
    p[i]+=1

sdict={}
sdict[0]=p[0]

for i in range(n-1):
	sdict[i+1]=sdict[i]+p[i+1]
j=0
ans=0
if n!=k:
	while (j+k <n):
		dif=sdict[j+k]-sdict[j]
		ans=max(dif,ans)
		j+=1
else:
	ans=sum(p)
print(ans/2)


Measured memory_bytes: 43460
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;//最下位ビットが立っているときにx^(2^i)をかける
        x = x * x % mod; //xを順次二乗していく
        n >>= 1;
    }
    return res;
}

int bit[60];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        REP(j,60){
            if((a[i]>>j) & 1) bit[j]++;
        }
    }

    ll ans = 0;
    int rest = n-1;
    //REP(j,60) cout << bit[j] << " ";
    //cout << endl;
    REP(i,n){
        REP(j,60){
            if((a[i]>>j) & 1){
                bit[j]--;
                ans += (mod_pow(2, j, MOD) * (rest - bit[j]));
                ans %= MOD;
            }
            else{
                if(bit[j] > 0) ans += (mod_pow(2, j, MOD) * bit[j]);
            }
        }
        rest--;
    }
    cout << ans << endl;

}

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

using namespace std;

int main()
{
	map<string, int> red;
	map<string, int> blue;
	string strred[100];
	string strblue[100];
	int i, j;
	int n, m;
	int max = 0;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> strblue[i];
		blue[strblue[i]]++;
		red[strblue[i]] = 0;
	}

	cin >> m;

	for (i = 0; i < m; i++) {
		cin >> strred[i];
		red[strred[i]]++;
	}

	for (auto x : blue) {
		for (auto y : red) {
			if (x.first == y.first) {
				if (x.second - y.second > max) {
					max = x.second - y.second;
				}
			}
		}
	}

	if (max < 0) cout << "0" << "\n";
	else cout << max << "\n";

	return (0);
}


Measured memory_bytes: 256
import numpy as np
n, W = map(int, input().split())
dp = np.zeros((n,W+1), dtype='int64')
for i in range(n):
    w, v = map(int , input().split())
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.fmax(dp[i-1, w:], dp[i-1,:W-w+1]+v)
print(dp[n-1][W])


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

int ToInt(string str)
{
	int ret = 0;
	
	switch(str[0])
	{
		case 'S':
			ret = 0;
			break;
		case 'H':
			ret = 1;
			break;
		case 'D':
			ret = 2;
			break;
		case 'C':
			ret = 3;
			break;	
	}
	
	ret += (str[1] - '1') * 4;
	
	return ret;
}

string ToCard(int n)
{
	string ret = "";
	switch(n % 4)
	{
		case 0:
			ret += 'S';
			break;
		case 1:
			ret += 'H';
			break;
		case 2:
			ret += 'D';
			break;
		case 3:
			ret += 'C';
			break;
	}
	
	ret += (char)(n / 4 + '1');
	
	return ret;
}

int main()
{
	int N, a[100], b[100], c[9][4], d[9];
	string str;
	
	for(int i = 0; i < 9; ++i)
	{
		d[i] = 0;
	}
	
	cin >> N;
	for(int i = 0 ; i < N; ++i)
	{
		cin >> str;
		a[i] = ToInt(str);
		b[i] = a[i];
		
		c[a[i] / 4][d[a[i] / 4]] = a[i] % 4;
		++d[a[i] / 4];
	}
	
	for(int i = 0; i < N - 1; ++i)
	{
		for(int j = N - 1; j > i; --j)
		{
			if(a[j] / 4 < a[j - 1] / 4)
			{
				int temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
			}
		}
	}
	
	for(int i = 0; i < 9; ++i)
	{
		d[i] = 0;
	}
	
	bool as = true;
	for(int i = 0; i < N; ++i)
	{
		if(c[a[i] / 4][d[a[i] / 4]] != a[i] % 4)
		{
			as = false;
			break;
		}
		
		++d[a[i] / 4];
	}
	
	int m;
	for(int i = 0; i < N - 1; ++i)
	{
		int m = i;
		for(int j = i + 1; j < N; ++j)
		{
			if(b[j] / 4 < b[m] / 4)
			{
				m = j;
			}
		}
		
		if(m != i)
		{
			int temp = b[m];
			b[m] = b[i];
			b[i] = temp;
		}
	}
	
	for(int i = 0; i < 9; ++i)
	{
		d[i] = 0;
	}
	
	bool bs = true;
	for(int i = 0; i < N; ++i)
	{
		if(c[b[i] / 4][d[b[i] / 4]] != b[i] % 4)
		{
			bs = false;
			break;
		}
		
		++d[b[i] / 4];
	}
	
	for(int i = 0 ; i < N; ++i)
	{
		if(i != 0)
		{
			cout << " ";
		}
		cout << ToCard(a[i]);
	}
	cout << endl << (as ? "Stable" : "Not stable") << endl;
	
	for(int i = 0 ; i < N; ++i)
	{
		if(i != 0)
		{
			cout << " ";
		}
		cout << ToCard(b[i]);
	}
	cout << endl << (bs ? "Stable" : "Not stable") << endl;

    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
int cumsum_ac[100005];

int main() {
  int n,q;
  string s;
  cin>>n>>q>>s;
  cumsum_ac[0]=0;
  for(int i=1;i<n;i++){
    if(s[i-1]=='A' && s[i]=='C') cumsum_ac[i]=cumsum_ac[i-1]+1;
    else cumsum_ac[i]=cumsum_ac[i-1];
  }
  rep(_,q){
    int l,r;
    cin>>l>>r;
    l--;r--;
    cout<<cumsum_ac[r]-cumsum_ac[l]<<endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll n,a,b;cin>>n>>a>>b;
	if((b-a)%2==0){
		ll ans=(b-a)/2;
		cout<<ans<<"\n";
	}
	else{
		ll ans=min(a-1,n-b)+(b-a+1)/2;
		cout<<ans<<"\n";
	}
}

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

int main(void)
{
    char S[4];
    char T[4];
    int count = 0;

    scanf("%s %s", &S, &T);
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
            count++;
    }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int a[] = new int[n];
        
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);

        int ans = 0;

        for(int i = n-1; i > -1; i--){
            if(i%2==0) ans += a[i];
            else ans -= a[i];
        }
        
        if(n%2==0) ans *= -1;
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21588
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

a, b = na()

print(max(a + b, a - b, a * b))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    long long int c = 0, res = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] == 0) {
            res += c / 2 * 2;
            c = 0;
        } else {
            c += v[i];
        }
    }
    res += c / 2 * 2;
    cout << res / 2 << endl;
}




Measured memory_bytes: 3756
from collections import Counter
def main():
    n = int(input())
    D = sorted(map(int, input().split()))
    m = int(input())
    T = sorted(map(int, input().split()))
    CD = Counter(D)
    CT = Counter(T).items()
    for i, c in CT:
        if CD[i] < c:
            print('NO')
            return
    print('YES')
main()

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

const int MAXN=1e5+5;
int N,K;
int dp[MAXN];
int a[150];
int solve(int k)
{
    if(k==0)
    return 0;
    if(dp[k]!=-1)
    return dp[k];
    int ans=0;
    for(int i=1;i<=N;i++)
    {
        if(k>=a[i])
        {
            if(solve(k-a[i])==0)
            ans=1;
        }
    }
    return dp[k]=ans;
}
    
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>N>>K;
    for(int i=1;i<=N;i++)
    cin>>a[i];
    if(solve(K)==1)
    cout<<"First\n";
    else
    cout<<"Second\n";
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int n;
   cin>>n;

   vector<int> a(n);
   rep(i,n){
      cin>>a[i];
   }
   int ans=0;
   int tmp=0;
   
   for(int i=0;i<n-1;i++){
      if(a[i]>=a[i+1]){
         tmp++;
      }
      else{
         tmp=0;
      }
      ans=max(ans,tmp);
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 3724
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int H, W, N; cin >> H >> W >> N;
    int m = max(H, W);
    cout << (N + m - 1) / m << endl;
    return 0;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int N, M, X;
  cin >> N >> M >> X;

  int sum0 = 0;
  int sumN = 0;
  rep(i, M) {
    int a;
    cin >> a;
    if (a < X) sum0++;
    else sumN++;
  }

  cout << std::min(sum0, sumN) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
 
typedef long long ll;
typedef pair<ll, int> P;
 
ll n,m,ans;
const ll MOD=1000000007;
 
ll calc(ll a) {
	ll sum=1;
	FOR(i,1,a+1) (sum*=i)%=MOD;
	return sum;
}
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	cin>>n>>m;
	if(abs(n-m)>=2) {
		cout<<'0'<<endl;
		return 0;
	}
	if(n==m) {
		ans=(((calc(n)*calc(n))%MOD)*2)%MOD;
	}
	else {
		ans=(calc(n)*calc(m))%MOD;
	}
	cout<<ans%MOD<<endl;
 
	return 0;
}

Measured memory_bytes: 256