akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


ll ma=1e15;
vector<vector<int> >g;
int n,m;
int v[100001];
vector<int>dp(100001,0);

int ans;

int dfs(int p){
v[p]=1;
int q=0;
for(int j=0;j<g[p].size();j++){
        int i=g[p][j];
        if(!v[i])
        q=max(dfs(i)+1,q);
        else{
            q=max(q,dp[i]+1);
        }
    }
    dp[p]=q;
    ans=max(ans,dp[p]);
return q;


}



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
g.resize(n+1);

for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    g[x].pb(y);
}


for(int i=1;i<=n;i++){
    if(!v[i])
        dfs(i);
}


cout<<ans<<endl;







}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int n,m,s,ans,C[55],D[55];
long long dis[55][2505];
bool vis[55][2505];
vector<pair<int,pair<int,int>>>mp[55];
priority_queue<pair<long long,pair<int,int>>,vector<pair<long long,pair<int,int>>>,greater<pair<long long,pair<int,int>>>>q;
int main()
{
    scanf("%d %d %d",&n,&m,&s);
    s=min(s,2500);
    while(m--)
    {
        int u,v,a,b;
        scanf("%d %d %d %d",&u,&v,&a,&b);
        mp[u].push_back({v,{a,b}});
        mp[v].push_back({u,{a,b}});
    }
    for(int i=1;i<=n;i++)scanf("%d %d",&C[i],&D[i]);
    for(int i=1;i<=n;i++)for(int i0=0;i0<=2500;i0++)dis[i][i0]=INT64_MAX;
    dis[1][s]=0;
    q.push({0,{1,s}});
    while(q.size())
    {
        auto t=q.top();
        q.pop();
        int now=t.second.first,s=t.second.second;
        long long d=t.first;
        if(vis[now][s])continue;
        vis[now][s]=1;
        if(dis[now][min(2500,s+C[now])]>d+D[now])
        {
            dis[now][min(2500,s+C[now])]=d+D[now];
            q.push({dis[now][min(2500,s+C[now])],{now,min(2500,s+C[now])}});
        }
        for(auto x:mp[now])
        {
            if(s>=x.second.first&&dis[x.first][s-x.second.first]>d+x.second.second)
            {
                dis[x.first][s-x.second.first]=d+x.second.second;
                q.push({dis[x.first][s-x.second.first],{x.first,s-x.second.first}});
            }
        }
    }
    for(int i=2;i<=n;i++)
    {
        long long ans=INT64_MAX;
        for(int i0=0;i0<=2500;i0++)ans=min(ans,dis[i][i0]);
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 6384
# Acceptance of input
import sys

file_input = sys.stdin

n = file_input.readline()

EP = []
l = -1000000001
u = 1000000001

for line in file_input:
    x1, y1, x2, y2 = (map(int, line.split()))
    if x1 == x2:
        if y1 < y2:
            EP.append((y1, l, x1))
            EP.append((y2, u, x1))
        else:
            EP.append((y1, u, x1))
            EP.append((y2, l, x1))
    else:
        if x1 < x2:
            EP.append((y1, x1, x2))
        else:
            EP.append((y1, x2, x1))

# Sweep
import bisect

EP.sort()
BT = []
cnt = 0

for p in EP:
    x1 = p[1]
    if x1 == l:
        bisect.insort(BT, p[2])
    elif x1 == u:
        i = bisect.bisect_left(BT, p[2])
        BT.pop(i)
    else:
        cnt += bisect.bisect(BT, p[2]) - bisect.bisect_left(BT, x1)

# Output
print(cnt)

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'
typedef long long ll;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int MXN = 1e5 + 5;


int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   // #ifndef  ONLINE_JUDGE
   // freopen("in", "r", stdin);
   // freopen("out", "w", stdout);
   // #endif
   int n, m; cin>>n>>m;
   cout<<n*m<<endl;
   return 0;
}

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

int main(){
    long long  int n,k;
    long long int sum = 0;
    long long int h[200002];

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

    sort(h,h+n);

    for(long int i = 0; i < k; i++){
        h[n-1-i] = 0;
    }

    sum = accumulate(h,h+n,0LL);

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    
    if (s=="SUN"){ cout<<7<<endl;
    }
    else if (s=="MON"){ cout<<6<<endl;
    }
    else if (s=="TUE"){ cout<<5<<endl;
    }
    else if (s=="WED"){ cout<<4<<endl;
    }    
    else if (s=="THU"){ cout<<3<<endl;
    }
    else if (s=="FRI"){ cout<<2<<endl;
    }
    else   {cout<<1<<endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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*y)/gcd(x, y);
}

//--------------------------

int main() {

  int n;  cin >> n;
  int p[n]; rep(i, n) cin >> p[i];
  int min = INF;
  int cnt = 0;

  rep(i, n) {
    if(min>=p[i]) {
      ++cnt;
      min = p[i];
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int x, y;
    cin >> x >> y;
    int ans = 0;
    if (abs(x) < abs(y)) {
        if (x < 0) {
            ans++;
        }
        ans += abs(y) - abs(x);
        if (y < 0) {
            ans++;
        }
    }
    else {
        if (x > 0) {
            ans++;
        }
        ans += abs(x) - abs(y);
        if (y > 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <cmath>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using ll = long long;
using pii = pair<int, int>;

int main(){
	ll w, a, b, result;
	cin >> w >> a >> b;
	result = max(a, b) - (min(a, b) + w);
	result = result < 0 ? 0:result;
	puts(result)
}


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

int main() {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    ll ans;
    if (x / d >= k) ans = x - d * k;
    else {
        ll e = x / d; //往復開始位置まで移動するのに必要な回数
        k -= e; //残りの操作回数
        x -= e * d; //往復開始位置
        if (k % 2 == 1) x = abs(x - d); //奇数の場合往復開始位置から1回移動させる必要があるためxからd引いて絶対値を取る。
        ans = x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int A, B;
		Scanner scan = new Scanner(System.in);
		
		A = scan.nextInt();
		B = scan.nextInt();
		
		System.out.print((B % A == 0) ? (A+B) : (B-A));
	}

}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int ans=0;
  int n,k; cin>>n>>k;
  for (int i=0; i<n; i++) {
    int x; cin>>x;
    ans += min(x,k-x);
  }
  ans*=2;
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
from itertools import product
import math
D,G=list(map(int, input().strip().split()))
pc=[list(map(int, input().strip().split())) for i in range(D)]

minCount=float("inf")
# Completeする数字を全パターン選択
for idx in product(*([0,1]for i in range(D))):
    ct=0
    score=0
    max_0=-1
    for i,ix in enumerate(idx):
        if ix:
            ct+=pc[i][0]
            score+=pc[i][1]+pc[i][0]*100*(i+1)
        else:
            max_0=i
    if score<G and max_0>=0:
        pt=(max_0+1)*100
        add=int(math.ceil((G-score)/pt))
        if add<pc[max_0][0]:
            ct+=add
            score+=add*pt
    if score>=G and ct<minCount:
        minCount=ct
print(minCount)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
	string S;
	cin>>S;
	int len = S.length();
/*	int s = atoi(S.c_str());
	if(S[0]=="0"){*/
	
	int model1=0;
	int model2=0;

	for(int i=0;i<len;i++){
		if(i%2==0){
			if(S[i]=='0')
				model1 += 1;
			else
				model2 += 1;
		}	
		else{
			if(S[i]=='1')
				model1 += 1;
			else
				model2 += 1;
		}
	}
	if(model1>model2)
		cout<<len-model1;
	else
		cout<<len-model2;
	return 0;
}	
			


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

using namespace std;

char s[1005];

int main() {
    scanf("%s", s);

    int res = 0;

    for (int i = 0; i < 3; i++) {
        if (s[i] == 'R') res++;
        else if (res) break;
    }

    printf("%d\n", res);
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

ll a, b, k;

int main(){
  cin >> a >> b >> k;
  if(a>k){
    a -= k;
  }else if(a+b>k){
    b -= (k-a);
    a = 0;
  }else{
    a = 0;
    b = 0;
  }
  cout << a << " " << b <<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int data[]={0, 1, 2, 3, 5, 7, 8, 9};
void solve(int);
main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) break;
    solve(n);
    cout << endl;
  }
  return 0;
}

void solve(int n){
  if(n>=8){
    solve(n/8);
  }
  printf("%d", data[n%8]);
}

Measured memory_bytes: 880
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a;
   scanf("%d",&a);
   int b[105];
   int i=1;
   int t=a;
   while(t--)
   {
   	scanf("%d",&b[i]);
   	i++;
   }
   int j,s=0;
   for(j=1;j<=a;j++)
   {
   	 if(j%2!=0)
   	 {
   	 	if(b[j]%2!=0)
   	 	{
   	 		s++;
			}
		}
   }
   printf("%d",s);
   return 0;
   }

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

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
  ll N,Max,Min,sum;
  cin>>N;
  Max = -1000001;
  Min = 1000001;
  sum = 0;
  for(int i=0; i<N; i++){
    ll n;
    cin>>n;
    Max = max(Max, n);
    Min = min(Min, n);
    sum+=n;
  }
  debug(Min,Max,sum);
}


Measured memory_bytes: 3116
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

long long dp[100];

void solve() {
    int N; cin >> N;
    vector<int> A(N+1);
    for (int i = 1; i <= N; i++) cin >> A[i];

    dp[0] = 1000;
    for (int i = 1; i <= N; i++) {
        dp[i] = dp[i-1];
        for (int j = 1; j < i; j++) {
            long long stock = dp[j] / A[j];
            long long money = dp[j] + (A[i] - A[j]) * stock;
            dp[i] = max(dp[i], money);
        }
    }

    cout << dp[N] << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3512
n = int(raw_input())
h = map(int,raw_input().split(" "))

min_cost = []

for i in xrange(0,n):
    if i == 0:
        min_cost.append(0)
    elif i == 1:
        min_cost.append(abs(h[0]-h[1]))
    else:
        candidate1 = min_cost[i-1]+abs(h[i]-h[i-1])
        candidate2 = min_cost[i-2] + abs(h[i]-h[i-2])
        min_cost.append(min(candidate1,candidate2))

print min_cost[-1]

Measured memory_bytes: 11168
#include <stdio.h>          // printf(), scanf()

long
power(long x, long n, long M)
{
	long res = 1;
	if (n > 0)
	{
		res = power(x, n / 2, M);
		if (n % 2 == 0)
			res = (res * res) % M;
		else
			res = (((res * res) % M) * x) % M;
	}

	return res;
}

int
main(int argc, char** argv)
{
	int n, m;

	scanf("%d %d", &n, &m);
	printf("%ld\n", power(n, m, 1000000007));
	return 0;
}

Measured memory_bytes: 596
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

fn main() {
    let (r, g, b, n): (usize, usize, usize, usize) = input_four();

    let mut ans = 0;
    for rr in 0..3003 {
        for gg in 0..(3003-rr+1) {
            if n >= rr * r + gg * g && (n - (rr * r + gg * g)) % b == 0 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>

#define MAX_N 50

using namespace std;

int C[MAX_N][26];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < s.size(); ++j) {
      ++C[i][s[j] - 'a'];
    }
  }
  string res = "";
  for (int i = 0; i < 26; ++i) {
    int t = MAX_N + 1;
    for (int j = 0; j < n; ++j) {
      t = min(t, C[j][i]);
    }
    for (int j = 0; j < t; ++j) {
      res += i + 'a';
    }
  }
  printf("%s\n", res.c_str());
}

Measured memory_bytes: 3060
main = do
  li <- getLine
  let [a,v] = map read $ words li
  li <- getLine
  let [b,w] = map read $ words li
  li <- getLine
  let [t] = map read $ words li
  let ans = compute a v b w t
  putStrLn $ if ans then "YES" else "NO"

compute :: Int -> Int -> Int -> Int -> Int -> Bool
compute a v b w t = v > w && abs (a-b) <= t * (v-w)

{-
何だかなぁ。
-}


Measured memory_bytes: 3872
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int n_digit(int k, int n) {
    int res = 0;
    int d = 1;
    while (k != 0) {
        res += d*(k%n);
        k /= n;
        d *= 10;
    }
    return res;
}

int sitigosan(int k,int d) {
    string tmp = to_string(k);
    while (tmp.size()<d) {
        tmp = '0'+tmp;
    }
    string res = "";
    REP(i,tmp.size()) {
        if (tmp[i]=='0') res += '3';
        else if (tmp[i]=='1') res += '5';
        else res += '7';
    }
    cerr<<res<<endl;
    return stoi(res);
}

bool check(int k,int d) {
    int cnt[3];
    REP(i,3) cnt[i]=0;
    REP(i,d) {
        cnt[((k%10)%3)]++;
        k /= 10;
    }
    REP(i,3) {
        if (cnt[i]==0) return false;
    }
    return true;
}

int check_digit(int k) {
    int d = 1;
    while (k/=10) d++;
    return d;
}
 
int main() {
    int N; cin>>N;
    int m = 1;
    int d = check_digit(N);
    REP(i,d) m *= 3;
    int ans = 0;
    REP(j,d+1) {
        REP(i,m) {
            int sansinsuu = n_digit(i,3);
            int d_tmp = check_digit(sansinsuu);
            if (d_tmp>j) break;
            if (check(sansinsuu,j) && N>=sitigosan(sansinsuu,j)) ans++;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(),A.end());
  string ans="YES";
  for(int i=0; i<N-1; i++){
    if(A.at(i)==A.at(i+1)){
      ans="NO";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())

lmax=1
rmin=n
for i in range(m):
    l,r = map(int,input().split())
    lmax = max(lmax,l)
    rmin = min(rmin,r)
if(lmax>rmin):
    print(0)
else:
    print(rmin-lmax+1)

Measured memory_bytes: 43736
import java.util.Scanner;

public class Main {
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		for(int i = 0;i < n;i++){
			int a[] = {0,0,0};
			for (int j = 0;j <3;j++){
				a[j] = (int) Math.pow(Integer.parseInt(scan.next()),2);
			}
			java.util.Arrays.sort(a);
			if(a[0]+a[1]==a[2]){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
		System.exit(0);
	}
}

Measured memory_bytes: 12000
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (100010)
int k;
vector<int>s{1};
void opt(int x);
signed main(){
	Rd(k);
	Frn1(i,2,k)opt(0);
	Frn_(i,s.size()-1,0)wr(s[i]);
	exit(0);
}
void opt(int x){
	if(x==s.size()-1){
		if(s[x]==9)s.push_back(1),s[x]=0;
		else ++s[x];
	}else if(s[x]<=s[x+1]&&s[x]<9)++s[x];
	else opt(x+1),s[x]=max(0,s[x+1]-1);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int a, b;
	cin>>a>>b;
	if(a<=b)
		cout<<"unsafe"<<endl;
	else
		cout<<"safe"<<endl;
	return 0;
}

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

int main()
{
  char S[5];
  cin >> S;

  int s1, s2;

  s1 = (S[0]-48)*10 + S[1]-48;
  s2 = (S[2]-48)*10 + S[3]-48;

  bool s1MM = s1 > 0 && s1 <= 12;
  bool s2MM = s2 > 0 && s2 <= 12;
  if(s1MM & s2MM) cout << "AMBIGUOUS" << endl;
  else if(!s1MM & s2MM) cout << "YYMM" << endl;
  else if(s1MM & !s2MM) cout << "MMYY" << endl;
  else cout << "NA" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N, M;
    cin >> N >> M;
    vector<P> ab(N);
    for(int i = 0;i < N;i++){
        int a, b;
        cin >> a >> b;
        ab[i] = P(a, b);
    }
    sort(ab.begin(), ab.end());
    for(int i = 0;i < N;i++)    ab[i] = P(ab[i].second, ab[i].first);
    priority_queue<P, vector<P>>    que;
    int ci = 0;
    int ans = 0;
    for(int i = 1;i <= M;i++){
        for(int j = ci;ci < N && ab[j].second <= i;j++){
            ci++;
            que.push(ab[j]);
        }
        if(!que.empty()){
            P p = que.top();que.pop();
            ans += p.first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n,m);
    vector<int> vec(n);
    int a,b;
    rep(i,m){
        in(a,b);
        vec[a-1]++;
        vec[a-1]%=2;
        vec[b-1]++;
        vec[b-1]%=2;
    }
    YN(count(all(vec),0)==n);
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}


struct edge{
    int to, cap, rev;
    edge(){}
    edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

vector<edge> G[210];
bool used[210];

void add_edge(int from, int to, int cap){
    G[from].push_back({to, cap, (int)G[to].size()});
    G[to].push_back({from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(auto& e : G[v]){
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(true){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, inf);
        flow += f;
        if(f == 0) break;
    }
    return flow;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int H, W;
    cin >> H >> W;

    int s = 0, t = H + W + 1;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            char c;
            cin >> c;
            if(c == 'S'){
                add_edge(s, i, inf);
                add_edge(s, H + j, inf);
            }
            if(c == 'T'){
                add_edge(i, t, inf);
                add_edge(H + j, t, inf);
            }
            if(c == 'o'){
                add_edge(i, H + j, 1);
                add_edge(H + j, i, 1);
            }
        }
    }
    int ans = max_flow(s, t);
    cout << (ans >= inf ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#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 all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
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() {
	int K, S; cin >> K >> S;
	int dp[4][10000] = {};
	dp[0][0] = 1;
	rep(h, 0, 3) {
		rrep(x, 0, K + 1) {
			rep(i, 0, S + 1) {
				dp[h + 1][i + x] += dp[h][i];
			}
		}
	}
	cout << dp[3][S] << endl;
	return 0;
}

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

int main(void)
{
	char str[100];
	char n;
	int one, two, three;
	int i,j;

	scanf("%s", str);

	//KAIBUN?
	one = 0;	//1 = no;
	n = strlen(str);
	i = 0;
	while(i < n / 2)
	{
		if(str[i] != str[n - 1 - i])
			one = 1;
		i++;
	}
	
	//TUYOI KAIBUN 1:
	two = 0;	//1 = no;
	i = 0;
	while(i < (n - 1) / 2)
	{
		if(str[i] != str[(n - 1) / 2 - 1 - i])
			two = 1;
		i++;
	}

	//TUYOI KAIBUN 2:
	three = 0;	//1 = no;
	i = (n + 3) / 2 - 1;
	j = 0;
	while(i < n)
	{
		if(str[i] != str[n - 1 - j])
			three = 1;
		i++;
		j++;
	}

	if(one == 0 && two == 0 && three == 0)
		printf("Yes\n");
	else
		printf("No\n");

	return (0);
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    string s; cin >>s;
    Yes((s[0]==s[1] && s[1]==s[2])
     || (s[1]==s[2] && s[2]==s[3])
     );
}


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

typedef unsigned long long ULL;

int main(){
	ULL ans = 0;
	ULL mask = 0;
	int cnt[65536];

	ULL x0;
	int n, k;
	cin >> n >> k >> x0;

	for(int i = 0; i < 4; ++i){
		ULL x = x0;
		memset(cnt, 0, sizeof cnt);

		int shift = (3 - i) * 16;

		for(int j = 0; j < n; ++j){
			if((x & mask) == ans){
				unsigned y = x >> shift & 0xFFFFull;
				if(i == 0){ y ^= 0x8000u; }
				++cnt[y];
			}

			x ^= x << 13;
			x ^= x >> 7;
			x ^= x << 17;
		}

		partial_sum(cnt, cnt + 65536, cnt);
		ULL p = lower_bound(cnt, cnt + 65536, k) - cnt;
		if(p > 0){ k -= cnt[p - 1]; }
		if(i == 0){ p ^= 0x8000ull; }
		ans |= p << shift;

		mask = mask >> 16 | 0xFFFF000000000000ull;
	}

	cout << (long long)ans << endl;
}

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

typedef long long ll;
const int mod = 1e9 + 7;
typedef pair<ll, ll> P;

ll N;
vector<ll> X, L;

int main() {
    cin >> N;
    X.resize(N);
    L.resize(N);

    rep(i, N) {
        cin >> X[i] >> L[i];
    }

    vector<P> v;
    rep(i, N) {
        P p = make_pair(X[i] + L[i], X[i] - L[i]);
        v.push_back(p);
    }
    sort(v.begin(), v.end());

    // 右端
    ll cur = -1e10;
    ll ans = 0;
    rep(i, N) {
        if (cur <= v[i].second) {
            ans++;
            cur = v[i].first;
        }
    }

    cout << ans << endl;
}

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

int inputdata(num){
	if (scanf("%d", &num) == 1);
  	else { 
  		printf("Failed to read integer.\n"); 
  	}
  	
  	return num;
}

int main(void){
  int a,b,t;
  int sum=0;

  a = inputdata(a);
  b = inputdata(b);
  t = inputdata(t);

  for(;a>20||a<1||b>20||b<1||t>20||t<1;){
  		printf("入力は1~20の範囲でおこなってください．\n"); 
  		a = inputdata(a);
  		b = inputdata(b);
  		t = inputdata(t);
  }

  
  for(int i=0; i < t/a; i++){
    sum += b;
  }
  printf("%d\n", sum);
 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll N, Y;
    cin >> N >> Y;
    for(int i=0; i<=N; ++i){
        for(int j=0; j<=N-i; ++j){
            ll yen = 10000*i+5000*j;
            int z;

            if((Y-yen)%1000==0) z = (Y-yen)/1000;
            else continue;
            if(i+j+z==N){
                cout << i << " " << j << " " << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


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

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

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

i64 n;
vector<vector<vector<f64>>> dp;

f64 dfs(i64 i, i64 j, i64 k) {
    if (i < 0 || i > n || j < 0 || j > n || k < 0 || k > n) return 0;
    if (i == 0 && j == 0 && k == 0) return 0;
    if (dp[i][j][k] >= 0) return dp[i][j][k];

    f64 res = (f64) n;
    res += (f64) i * dfs(i - 1, j , k);
    res += (f64) j * dfs(i + 1, j - 1, k);
    res += (f64) k * dfs(i, j + 1, k - 1);
    res /= (f64) (i + j + k);
    return dp[i][j][k] = res;
}

void solve() {
    cin >> n;

    i64 cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (i64 i = 0; i < n; i++) {
        i64 a;
        cin >> a;
        (a == 1 ? cnt1 : a == 2 ? cnt2 : cnt3)++;
    }

    dp.resize(n + 1, vector<vector<f64>>(n + 1, vector<f64>(n + 1, -1)));
    cout << dfs(cnt1, cnt2, cnt3) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 219940
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,A,B;
ll x[100010];
int main(){
    cin>>N>>A>>B;
    ll ans=0;
    for(ll i=0;i<N;i++){
        cin>>x[i];
        if(i>0){
            ans+=min(B,A*(x[i]-x[i-1]));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;
  
int a[4];
int c[8];
int k;
  
int calc(){
    int op = c[k++];
    int ret = 0;
    if(op >= 0){
        ret = op;
    }
    else if(op >= -3){
        int x = calc();
        int y = calc();
        if(op == -1){
            ret = x + y;
        }
        else if(op == -2){
            ret = x - y;
        }
        else{
            ret = x * y;
        }
    }
    else{
        throw 0;
    }
    return ret;
}
  
void print(){
    int op = c[k++];
    if(op >= 0){
        printf("%d", op);
    }
    else{
        char ch;
        if(op == -1){ ch = '+'; }
        else if(op == -2){ ch = '-'; }
        else{ ch = '*'; }
  
        putchar('(');
        print();
        printf(" %c ", ch);
        print();
        putchar(')');
    }
}

const int bnum = 40;
  
void solve(int i, int S, int oprem, int numrem){
    if(i == 6){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[6] = a[j];
            }
        }
        try{
            k = 0;
            if(calc() == 10 && k == 7){
                k = 0;
for(int j=0;j<bnum;++j)putchar('(');
                print();
for(int j=0;j<bnum;++j)putchar(')');
                puts("");
                throw "";
            }
        }catch(int){}
        return;
    }
  
    if(oprem > 0){
        for(int op = -1; op >= -3; --op){
            c[i] = op;
            solve(i + 1, S, oprem - 1, numrem + 1);
        }
    }
  
    if(numrem > 0){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[i] = a[j];
                solve(i + 1, S ^ 1 << j, oprem, numrem - 1);
            }
        }
    }
}
  
int main(){
    while(1){
        for(int i = 0; i < 8; ++i){
            c[i] = -9;
        }
        for(int i = 0; i < 4; ++i){
            scanf("%d", &a[i]);
        }
        if(a[0] == 0){ break; }
        try{
            solve(0, 15, 3, 0);
            puts("0");
        }catch(...){}
    }
}

Measured memory_bytes: 1128
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}

int main(){
	ll A, B;
	cin >> A >> B;
	ll kari = max(A + B, A - B);
	ll ans = max(kari,A*B);
	cout << ans << endl;
}

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

int main(){
    ll h, w; cin >> h >> w;
    if(h <= 1){
        cout << 1;
        return 0;
    }
    if(w <= 1){
        cout << 1;
        return 0;
    }
    if((h*w)%2==0) cout << (h*w)/2;
    else cout << ((h*w)/2) + 1;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const llint mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
int main(void){
	int n;cin>>n;
	cout<<48-n<<endl;
	RE;
}

Measured memory_bytes: 888
import sys
import itertools
 
class RMQ:
    def __init__(self, n):
        self.sz = 1
        self.inf = (1 << 31) - 1
        while self.sz <= n: self.sz = self.sz << 1
        self.dat = [self.inf] * (2 * self.sz - 1)
     
    def update(self, idx, x):
        idx += self.sz - 1
        self.dat[idx] = x
        while idx > 0:
            idx = (idx - 1) >> 1
            self.dat[idx] = min(self.dat[idx * 2 + 1], self.dat[idx * 2 + 2])
             
    def query(self, a, b):
        return self.query_help(a, b, 0, 0, self.sz)
             
    def query_help(self, a, b, k, l, r):
        if r <= a or b <= l:
            return sys.maxint
        elif a <= l and r <= b:
            return self.dat[k]
        else:
            return min(self.query_help(a, b, 2 * k + 1, l, (l + r)>>1),
                        self.query_help(a, b, 2 * k + 2, (l + r) >> 1, r))
     
     
if __name__ == '__main__':
    line = sys.stdin.readline()
    n, q = line.split()
    n, q = int(n), int(q)
    rmq = RMQ(n)
     
    for i in range(q):
        line = sys.stdin.readline()
        op, a, b = line.split()
        op, a, b = int(op), int(a), int(b)
        if op == 0: 
            rmq.update(a, b)
        else: 
            sys.stdout.write(str(rmq.query(a, b + 1)) + '\n')

Measured memory_bytes: 10376
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  int b[m];
  REP(i,m) cin >> b[i];
  int a[n][m];
  REP(i,n) REP(j,m) cin >> a[i][j];
  ll ans = 0;
  REP(i,n){
    ll score = c;
    REP(j,m) score += a[i][j]*b[j];
    if(score>0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
_a, _b, m = gets.split.map(&:to_i)
aa = gets.split.map(&:to_i)
ba = gets.split.map(&:to_i)
wa = Array.new(m){gets.split.map(&:to_i)}
ans = aa.min + ba.min
wa.each do |x, y, c|
  tmp = aa[x-1] + ba[y-1] - c  
  ans = tmp if (tmp < ans)
end
puts ans


Measured memory_bytes: 18844
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    cin>>n>>k;
    v32 a(n+1);
    forsn(i,1,n+1) cin>>a[i];
    v32 vis(n+1,0),dist(n+1,0);
    v32 ans(n+1,0);
    int curr=1;
    int len=0;
    forn(i,n+1){
      // dbg(curr);
      if(vis[curr]){
        len=i-dist[curr];
        break;
      }
      vis[curr]=1;
      dist[curr]=i;
      ans[i]=curr;
      curr=a[curr];
    }
    // dbg(len);
    if(k<=dist[curr]){
      cout<<ans[k]<<ln;
    }
    else{
      int rem=k-dist[curr];
      int i=rem%len;
      cout<<ans[dist[curr]+i]<<ln;
    }
}


Measured memory_bytes: 9472
#include <stdio.h>
#include <math.h>
int main(void){
   
    int len, ali, bor;
    
    scanf("%d%d%d", &len, &ali, &bor);
    
    len = abs(ali - bor) % 2;
    
    if(len == 0) printf("Alice\n");
    else printf("Borys\n");
    
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;

bool n[100];
char as;
string st;

int main(){
    cin>>st;
    for(int i=0;i<=int('z')-int('a')+1;i++)n[i]=true;
    for(int i=0;i<st.length();i++){
        n[int(st[i])-int('a')]=false;
    }
    for(int i=0;i<=int('z')-int('a')+1;i++){
        if(i==int('z')-int('a')+1){
            cout<<"None"<<endl;
            break;
        }
        else if(n[i]){
            as=char(i+int('a'));
            printf("%c\n",as);
            break;
        }
    }
    
}

Measured memory_bytes: 512
s = input()
t = input()
S = []
T = []
for i in range(len(s)):
    S.append(s[i])
for j in range(len(t)):
    T.append(t[j])
S.sort()
T.sort()
T.reverse()
a = ''
b = ''
for i in range(len(s)):
    a += S[i]
for j in range(len(t)):
    b += T[j]
if a < b:
    print('Yes')
else:
    print('No')


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

using namespace std;

const int N = 2e5 + 5;

int n, p[N], cnt[N], add[N], c[N];

set<int> st[N];

int get(int v) {
  int val = 0;
  for (auto it = st[v].begin(); it != st[v].end(); it++) {
    if (*it > val) return val;
    val++;
  }
  return val;
}

bool cek(int v, int val) {
  return (get(v) == val);
}

int main() {
  scanf("%d", &n);memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; i++) {
    scanf("%d", p+i);
    p[i]--;
    cnt[p[i]]++;
  }
  queue< int > que;
  for (int i = 0; i < n; i++) {
    if (cnt[i] == 0) {
      que.push(i);
    }
  } 
  while (!que.empty()) {
    int v = que.front(); que.pop();
    int val = get(v);
    st[p[v]].insert(val);
    cnt[p[v]]--;
    if (cnt[p[v]] == 0)
      que.push(p[v]);
  }
  memset(add, -1, sizeof add);
  memset(c, -1, sizeof c);
  int v = 0;
  for (int i = 0; i < n; i++) if (cnt[i] != 0) {
    v = i;
    break;
  }
  bool ok = 1;
  int u = v;
  c[v] = get(v);
  while (1) {
    // cerr << "cuk" << " " << u << endl;
    int pp = p[u];
    if (!st[pp].count(c[u])) {
      add[pp] = c[u];
      st[pp].insert(c[u]);
    }
    if (pp == v) {
      if (!cek(v, c[v]))
        ok = 0;
      break;
    }
    c[pp] = get(pp);
    u = pp;
  }
  if (ok) {
    puts("POSSIBLE");
    return 0;
  }
  u = v;
  while (1) {
    if (add[u] != -1)
      st[u].erase(add[u]);
    u = p[u];
    if (u == v)
      break;
  }
  if (add[v] != -1)
    st[v].erase(add[v]);
  memset(add, -1, sizeof add);
  memset(c, -1, sizeof c);
  ok = 1;
  u = v;
  int rem = get(v);
  st[v].insert(rem);
  c[v] = get(v);
  st[v].erase(rem);
  
  while (1) {
    int pp = p[u];
    if (!st[pp].count(c[u])) {
      add[pp] = c[u];
      st[pp].insert(c[u]);
    }
    if (pp == v) {
      if (!cek(v, c[v]))
        ok = 0;
      break;
    }
    c[pp] = get(pp);
    u = pp;
  }
  puts(ok ? "POSSIBLE" : "IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 21504