akhauriyash/Code-Regression huggingface dataset:
import java.util.HashSet;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int k = s.nextInt();

		int m = 7 % k;
		int count = 1;
		HashSet<Integer> a = new HashSet<>();  //余りを格納
		a.add(m);

		if(m == 0) {
			System.out.println(count);
			return ;
		}

		while(m != 0) {

			m = (10 * m + 7) % k;
			count++;

			if(a.contains(m)) {
				System.out.println("-1");
				return ;
			}else {
				a.add(m);
			}

			if(m == 0) {
				System.out.println(count);
				return ;
			}



		}

	}

}


Measured memory_bytes: 102448
import itertools
N=int(input())
L=list(map(int,input().split()))

l= list(itertools.combinations_with_replacement(L, 3))
ans=0
for ll in l:
    if ll[0]!=ll[1] and ll[0]!=ll[2] and ll[1]!=ll[2]:
        if (ll[0]+ll[1])>ll[2] and (ll[1]+ll[2])>ll[0] and (ll[2]+ll[0])>ll[1]:
            ans+=1
                    
print(ans)

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

using namespace std;

const int N = 1e5 + 100;

int n;
int Arr[N];
int Seg[5 * N];

void Update (int idx, int val, int Node = 1, int L = 1, int R = n)
{
    if (idx > R || idx < L) return;
    if (L == R) {
        Seg[Node] = val;
        return;
    }

    int Mid = L + R >> 1;
    Update (idx, val, Node << 1, L, Mid);
    Update (idx, val, Node << 1 | 1, Mid + 1, R);

    Seg[Node] = max(Seg[Node << 1], Seg[Node << 1 | 1]);
}

int Query (int i, int j, int Node = 1, int L = 1, int R = n)
{
    if (i > R || j < L)    return -1e9;
    if (L >= i && R <= j)
        return Seg[Node];

    int Mid = L + R >> 1;
    int Q1 = Query (i, j, Node << 1, L, Mid);
    int Q2 = Query (i, j, Node << 1 | 1, Mid + 1, R);

    return max(Q1, Q2);
}

bool cmp (pair<int, int> a, pair<int, int> b) {
    if (a.first != b.first)
        return a.first > b.first;
    return a.second < b.second;
}

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

    vector <pair<int, int>> v;
    for (int i = 1; i <= n; i++) {
        cin >> Arr[i];
        v.push_back({Arr[i], i});
    }

    sort(v.begin(), v.end(), cmp);
 
    int Max = 0;
    for (int i = 0; i < n; i++)
    {
        int idx = v[i].second;
        int cur = (idx == 1 ? 0 : Query(1, idx - 1));
        Max = max(Max, cur + 1);
        Update(idx, cur + 1);
    }

    cout << Max << '\n';

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  set<int> s;
  rep(i,n) s.insert(a[i]);
  if (s.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

namespace TYC
{
	typedef long long ll;

	const int N = 1e6, mod = 998244353;

	int Fac[N + 5], Inv[N + 5];

	inline int inv(const int x) { return x == 1 ? 1 : int((ll)inv(mod % x) * (mod - mod / x) % mod); }

	inline int C(const int n, const int m)
	{ 
		return n < m ? 0 : (m < 0 ? 0 : int((ll)Fac[n] * Inv[m] % mod * Inv[n - m] % mod)); 
	}

	inline int calc(const int n, const int m, const int v)
	{
		return (C(n + m, m) - C(n + m, m - v - 1) + mod) % mod;
	}

	void work()
	{
		Fac[0] = 1;
		for (int i = 1; i <= N; i++)
			Fac[i] = int((ll)Fac[i - 1] * i % mod);
		Inv[N] = inv(Fac[N]);
		for (int i = N; i; i--)
			Inv[i - 1] = int((ll)Inv[i] * i % mod);
		int n, m, ans = 0;
		scanf("%d%d", &n, &m);
		for (int r = max((m + 1) >> 1, n), b; r <= m; r++)
		{
			b = m - r;
			if (r == b)
				ans = (ans + calc(r, b - 1, b - n)) % mod;
			else if (n - r + b < 0)
				ans = (ans + C(m, r)) % mod;
			else
				ans = (ans + calc(r, b, r - n)) % mod;
		}
		printf("%d\n", ans);
	}
}

int main()
{
	TYC::work();
	return 0;
}

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

using namespace std;

int main() {
	int a, b, h, m;
	cin>>a>>b>>h>>m;
	double h_angle = h*30.0 + (m/2.0);
	double m_angle = 6.0 * m;
	double diff = abs(h_angle-m_angle);
	diff = min(diff, 360.0-diff);
	double dist = sqrt(a*a + b*b - 2.0*a*b*cos(diff*(M_PI/180.0)));
	printf("%.20f\n",dist);
}


Measured memory_bytes: 4188
// ~maqsat~
/*    
**    “Anyone who has never made a mistake has never tried anything new.”
**    © Albert Einstein
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int dp[5010][5010];
int main() {
    fre("");
    ACCELERATE;
	
	int n;
	cin >> n;

	string s;
	cin >> s;

	int ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			if(s[i-1] == s[j-1] && j - i > dp[i-1][j-1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
				cmax(ans, dp[i][j]);
			}
		}
	}

	cout << ans;
    return 0;
}
/*
 
*/


Measured memory_bytes: 96896
#include<iostream>
int main(){
  long long int Q,H,S,D,N,min_2=0,sub_min;
  std::cin>>Q>>H>>S>>D>>N;
  min_2=std::min(Q*8,std::min(std::min(H*4,S*2),D));
  sub_min=std::min(Q*4,std::min(H*2,S));
  if(N%2==0){
    std::cout<<min_2*N/2<<std::endl;
  }else 
    std::cout<<sub_min+(min_2*((N-1)/2))<<std::endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))

ans = 0

for i in range(1, N-1):
  if (P[i-1] < P[i] and P[i] < P[i+1]) or (P[i-1] > P[i] and P[i] > P[i+1]):
    ans += 1
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin>>S;
int X=S.size();
vector<char>A((X-1)/2);
vector<char>B((X-1)/2);
for(int i=0; i<(X-1)/2; i++){
    A.at(i)=S.at(i);
}
for(int i=0; i<(X-1)/2; i++){
    B.at(i)=S.at(i+(X+1)/2);
}
bool a=true;
for(int i=0; i<(X-1)/2; i++){
    if(A.at(i)!=B.at(i)){
        a=false;
    }
}
if(a==true){
    if((X-1)/2%2==0){
      for(int i=0; i<(X-1)/2/2; i++){
        if(S.at(i)==S.at((X-1)/2-i-1)){
        }
        else{
          cout<<"No"<<endl;
        	break;
      }
      }
      cout<<"Yes"<<endl;
    }
      else{
        for(int i=0; i<((X-1)/2-1)/2; i++){
          if(S.at(i)==S.at((X-1)/2-i-1)){
          }
          else{
            cout<<"No"<<endl;
          break;
        }
      }   
                  cout<<"Yes"<<endl;
}
}
else
cout<<"No"<<endl;
}


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

#define VMAX 2000001
#define MAX 10000
int n;

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<VMAX;i++)
    C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
	       

  return 0;
}
  
    
    
    



Measured memory_bytes: 17476
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [f64; n]
    }
    let mut tab: Vec<Vec<f64>> = vec![vec![0.0; n + 1]; n];
    tab[0][0] = 1.0 - v[0];
    tab[0][1] = v[0];
    for i in 1..n {
        tab[i][0] = tab[i - 1][0] * (1.0 - v[i]);
        for j in 1..i + 2 {
            tab[i][j] = tab[i - 1][j - 1] * v[i] + tab[i - 1][j] * (1.0 - v[i]);
        }
    }
    println!("{}", tab[n - 1][(n + 1) / 2..].iter().map(|x| *x).sum::<f64>());
}


Measured memory_bytes: 90364
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    int N;
    cin >> N;
    vector<int> Hs(N);

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

    int canSee = 1;
    int maxHeight = Hs[0];

    for (int i = 1; i < N; i++) {
        if (maxHeight <= Hs[i]) {
            canSee++;
        }
        maxHeight = std::max(maxHeight, Hs[i]);
    }

    cout << canSee << endl;

    return 0;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, C: int, x: "List[int]", v: "List[int]"):
    mp1 = [0] * (N + 1)
    mp2 = [0] * (N + 1)
    cum = 0
    for i in range(N):
        cum += v[i]
        mp1[i + 1] = max(mp1[i], cum - x[i])
        mp2[i + 1] = max(mp2[i], cum - x[i] * 2)
    mn1 = [0] * (N + 1)
    mn2 = [0] * (N + 1)
    cum = 0
    for i in reversed(range(N)):
        cum += v[i]
        mn1[i] = max(mn1[i + 1], cum - (C - x[i]))
        mn2[i] = max(mn2[i + 1], cum - (C - x[i]) * 2)

    print(max(
        max(mp1[i] + mn2[i] for i in range(N + 1)),
        max(mp2[i] + mn1[i] for i in range(N + 1)),
    ))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, C, x, v)


if __name__ == '__main__':
    main()


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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<long long> as, bs; // 累積和
  as.push_back(0);
  bs.push_back(0);
  
  for (int i=0; i<n; i++) {
    int a;
    cin >> a;
    as.push_back(as[i] + a);
  }
  for (int i=0; i<m; i++) {
    int b;
    cin >> b;
    bs.push_back(bs[i] + b);
  }
  
  // aを固定してbを最大化する、を後方から行う
  int ans = 0;
  int j = 0;
  for (int i = n; i >= 0; i--) {
    if (as[i] > k) continue;
    
    for (; j <= m; j++) {
      if (as[i] + bs[j] > k) {
        break;
      }
      ans = max(ans, i + j);
    }
  }
  
  cout << ans;
}

Measured memory_bytes: 7996
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;

int main() {
				fast
                // #ifndef ONLINE_JUDGE
                // freopen("input.txt","r",stdin);
                // freopen("output.txt","w",stdout);
                // #endif
               ll x,y,z;
               cin>>x>>y>>z;
               cout<<z<<" "<<x<<" "<<y;

                return 0;
            }

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using v = vector<T>;
using P = pair<int, int>;

/*
 *  */
int inf = (int)1e18 + 1;
int n, k;
v<int> a;

bool check(int x){
  int tot = 0;
  rep(i, 0, n){
    if(a[i] < 0){
      int l = -1, r = n;
      while(r-l > 1){
        int m = (l+r)/2;
        if(a[m]*a[i] < x) r = m;
        else l = m;
      }
      tot += n-r;
    }else{
      int l = -1, r = n;
      while(r-l > 1){
        int m = (l+r)/2;
        if(a[m]*a[i] < x) l = m;
        else r = m;
      }
      tot += r;
    }
    if(a[i]*a[i] < x) tot--;
  }

  tot /= 2;
  return tot < k;
}

signed main() {
  cin >> n >> k;
  a.resize(n);
  rep(i, 0, n) cin >> a[i];
  sort(all(a));

  int l = -inf, r = inf;
  while(r-l > 1){
    int m = (l+r)/2;
    if(check(m)) l = m;
    else r = m;
  }

  cout << l << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int m = sc.nextInt();
			if (n == 0 && k == 0 && m == 0)
				break;
			List<Integer> list = new LinkedList<Integer>();
			for (int i = 0; i < n; i++) {
				list.add(i + 1);
			}
			int x = m - 1;
			while (list.size() > 1) {
				list.remove(x);
				x = (x + (k - 1)) % list.size(); 
			}
			System.out.println(list.get(0));
		}
	}
}

Measured memory_bytes: 43280
import java.util.Scanner;

public class Main 
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n,k;
		n=sc.nextInt();
		k=sc.nextInt();
		if(n%k==0)
		{
			System.out.println(0);
		}
		else
		{
			System.out.println(1);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}



signed main(void)
{
    ll n;
    cin >> n;
    ll r = 1e+13;
    
    if (isPrime(n) == 1) {
        mes(n-1);
        re0;
    }
    
    rrep(i, n) {
        if (i > n/i) break;
        if (n % i == 0) {
            r = min((i+n/i -2), r);
            
        }
        
    }
    mes(r);
    
    
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int a, b, t;
	scanf("%d%d%d", &a, &b, &t);
	printf("%d\n", (t/a) * b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);    
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << ((n>=a+b)?0:a+b-n) << endl;

}

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

int main(void){
    int i,j,k;
    int N;
    unsigned int A[100000],answer[100000] = {0};
    unsigned int total = 0,temp;
    
  
    scanf("%d",&N);
    for(i = 0;i < N-1;i++){
        scanf("%ud\n",&A[i]);
    }
    scanf("%ud",&A[i]);

    total = A[0] * 2;
    for(i = 1;i < N;i++){
        if((i % 2) == 1){
            total -= A[i] * 2;
        }else{
            total += A[i] * 2;
        }
    }
    answer[0] = total / 2;
    
    for(i = 1;i < N;i++){
        answer[i] = A[i-1]*2 - answer[i-1];
    }
    
    for(i = 0;i < N-1;i++){
        printf("%d ",answer[i]);
    }
    printf("%d\n",answer[i]);
    
    return 0;
}



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

int main()
{
    int L,N;
    cin >> N >> L;

    int min = 10000;
    int minN = 0;

    for(int i = 1; i <= N; i++)
    {
        if(min >= abs(L + i - 1))
        {
            min = abs(L + i - 1);
            minN = i;
        }
    }

    int sum = 0;

    for(int i = 1; i <= N; i++)
    {
        if(i == minN)continue;
        sum += L + i -1;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 4294967295
int main(){
  long long a,b,c,x,y,ans=inf;
  cin>>a>>b>>c>>x>>y;
  long long r[3],p[3],e[3];
  if(x>y){
    r[0]=y*2*c+(x-y)*a;
    r[1]=x*2*c;
    r[2]=x*a+y*b;
    for(int i=0;i<3;i++)
        ans=min(ans,r[i]);
    }
  if(x<y){
    p[0]=x*2*c+(y-x)*b;
    p[1]=y*2*c;
    p[2]=x*a+y*b;
    for(int i=0;i<3;i++)
    ans=min(ans,p[i]);


  }
  if(x==y){
    e[0]=x*2*c;
    e[1]=x*a+b*y;
    ans=min(e[0],e[1]);}

cout<<ans;



return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Main main = new Main();
		main.solve();
	}

	private void solve() {

		Scanner sc = new Scanner (System.in);

		String A = sc.next();

		switch (A) {

		case "A":
			System.out.println("T");
			break;
		case "C":
			System.out.println("G");
			break;
		case "T":
			System.out.println("A");
			break;
		case "G":
			System.out.println("C");
			break;
		}
	}
}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,cnt=0,sum=0,b=0,k;
    cin >> n >> k;
    vll a(n),c;
    rep(i,n) cin >> a[i];
    sort(all(a));
    rep(i,n){
        b++;
        if(a[i]!=a[i+1] || i==n-1){
            c.pb(b);
            sum+=b;
            b=0;
        }
    }
    ll x=c.size();
    sort(rall(c));
    rep(i,min(k,x)) cnt+=c[i];
    cout << sum-cnt << endl;
	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define de(x)	cout <<#x <<" = "<< x <<"\n"
#define deb(x,y) cout<<#x <<" = "<<x<<" "<<#y<<" = "<<y<<"\n"
#define ff              first
#define ss              second
#define ll             	long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vector<int>>
#define mii             map<int,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define mk(arr,n,type)  type *arr=new type[n]



int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int x;
    cin >> x;
    int n;
    cin >> n;
    if(n == 0){
		cout << x;
		return 0;
	}
    vi a(n);
    for(int i = 0; i< n ;i++)cin >> a[i];
    sort(a.begin(),a.end());
    int i = 0;
    while(1){
		if(find(a.begin(),a.end(),x-i) == a.end()){
			cout << x-i;
			return 0;
		}
		if(find(a.begin(),a.end(),x+i) == a.end()){
			cout << x+i;
			return 0;
		}
		i++;
	}
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    string s[4] = {"AC", "WA", "TLE", "RE"};

    vector<int> ans(4, 0);
    rep(i, n)
    {
        string t;
        cin >> t;
        rep(j, 4) if (t == s[j])++ ans[j];
    }

    rep(i, 4)
    {
        cout << s[i] << " x " << ans[i] << endl;
    }
}

Measured memory_bytes: 3628
#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($(
            {
                 splits.next().unwrap().parse::<$t>().unwrap()
            },
        )*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (r, g, b, n) = input!(usize, usize, usize, usize);

    let mut count = 0;
    for i in 0..3001 {
        for j in 0..3001 {
            if n >= i * r + j * g {
                if (n - i * r - j * g) % b == 0 {
                    count += 1;
                }
            }
        }
    }

    println!("{}", count);
}

fn main() {
    solve();
}


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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  vector < int > a(3 * n + 1);
  vector < ll > lt(3 * n + 1), rt(3 * n + 1);
  for(int i = 1; i <= 3 * n; i++) cin >> a[i];

  priority_queue < int, vector < int >, greater < int > > q;
  ll sum = 0;
  for(int i = 1; i < n; i++){
    q.push(a[i]);
    sum += a[i];
  }

  lt[n] = sum;
  for(int i = n + 1; i <= 2 * n; i++){
    q.push(a[i - 1]);
    sum += a[i - 1];
    sum -= q.top();
    q.pop();
    lt[i] = sum;
  }

  priority_queue < int > qq;
  sum = 0;
  for(int i = 2 * n + 1; i <= 3 * n; i++){
    qq.push(a[i]);
    sum += a[i];
  }

  rt[2 * n] = sum;
  for(int i = 2 * n - 1; i >= n; i--){
    qq.push(a[i + 1]);
    sum += a[i + 1] - qq.top();
    qq.pop();
    rt[i] = sum;
  }

  ll ans = LLONG_MIN;
  for(int i = n; i <= 2 * n; i++){
    ans = max(ans, lt[i] + a[i] - rt[i]);
  }

  cout << ans << '\n';
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll A[1100];
ll B[1100];
ll C[1100];
int main(){
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    REP(i,X){
        ll a;
        cin >> a;
        A[i] = a;
    }
    REP(i,Y){
        ll b;
        cin >> b;
        B[i] = b;
    }
    REP(i,Z){
        ll c;
        cin >> c;
        C[i] = c;
    }

    sort(A, A+X, greater<ll>());
    sort(B, B+Y, greater<ll>());
    sort(C, C+Z, greater<ll>());

    priority_queue<ll> que;
    for(int x = 0; x < X; x++){
        for(int y = 0; y < Y; y++){
            if((x+1)*(y+1)-1 >= K) break;
            for(int z = 0; z < Z; z++){
                if((x+1)*(y+1)*(z+1)-1 >= K) break;
                ll tmp = A[x] + B[y] + C[z];
                que.push(tmp);
            }
        }
    }

    REP(i,K){
        ll ans = que.top();
        que.pop();
        cout << ans << endl;
    }
    return 0;
}


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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end());
    rep(i, m) {
        a[n - 1] /= 2;
        int num = a[n - 1];
        int ng = n - 1, ok = -1;
        while (ng - ok > 1) {
            int mid = (ng + ok) / 2;
            if (a[mid] <= num)
                ok = mid;
            else
                ng = mid;
        }
        a.erase(a.begin() + a.size() - 1);
        a.insert(a.begin() + (ok + 1), num);
    }

    ll ans = 0;
    rep(i, n) ans += a[i];

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int r=sc.nextInt();
		int D=sc.nextInt();
		int x=sc.nextInt();

		for(int i=0;i<10;i++){
			int next=r*x-D;
			System.out.println(next);
			x=next;
		}

		sc.close();
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n;
  print(48-n);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 1001
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main()
{
  int n,m,a[MAX];
  while(cin>>n && cin>>m && n){
    int ans = -1;
    FOR(i,0,n)cin>>a[i];
    FOR(i,0,n)
      FOR(j,i+1,n)
        if(a[i]+a[j]<=m)ans=max(ans,a[i]+a[j]);
    if(ans==-1)cout<<"NONE"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}



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

int int_sort(const void *a, const void *b)
{
	if (*(int *)a > *(int *)b){
		return -1;
	}
	else if (*(int *)a == *(int *)b){
		return 0;
	}
	return 1;
}

int main(void)
{
	int a, b, a_s, b_s;
	int team[100], N;
	int rank[100];
	int flag[100];
	int i, j, k;
	int tmp, count;
	
	for (i = 0; i < 100; i++){
		team[i] = flag[i] = 0;
	}
	
	scanf("%d", &N);
	k = N * (N - 1) / 2;
	
	for (i = 0; i < k; i++){
		scanf("%d %d %d %d", &a, &b, &a_s, &b_s);
		if (a_s == b_s){
			team[a - 1] += 1;
			team[b - 1] += 1;
		}
		else if (a_s > b_s){
			team[a - 1] += 3;
		}
		else if (a_s < b_s){
			team[b - 1] += 3;
		}
	}
	
	for (i = 0; i < N; i++){
		rank[i] = team[i];
	}
	
	qsort(team, N, sizeof(int), int_sort);
	
	for (i = 0; i < N; i++){
		for (j = 0; j < N; j++){
			if (flag[i] == 0 && rank[i] == team[j]){
				rank[i] = j + 1;
				flag[i] = 1;
			}
		}
	}
	
	for (i = 0; i < N; i++){
		printf("%d\n", rank[i]);
	}
	
	return (0);
}

Measured memory_bytes: 604
#include <iostream>
#define SIZE 30
using namespace std;
int cal(int h, int w, int k, int *c){
    int res = 0, pow = 1, num;
    while(pow > 0){
        for(int j=0;j<w;j++){
            int g = h-1;
            for(int i=h-1;i>=0;i--){
                if(*(c+i*SIZE+j) > 0){
                    if(i < g){
                        *(c+g*SIZE+j) = *(c+i*SIZE+j);
                        *(c+i*SIZE+j) = 0;
                    }
                    g--;
                }
            }
        }
        num = 0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(*(c+i*SIZE+j) == 0)continue;
                int p = j;
                while(*(c+i*SIZE+p) == *(c+i*SIZE+j)){
                    p++;
                    if(p == w)break;////
                }
                if(p - j >= k){
                    num += *(c+i*SIZE+j) * (p - j);
                    while(j < p){
                        *(c+i*SIZE+j) = 0;
                        j++;
                    }
                    j--;
                }
            }
        }
        if(num == 0){
            pow = 0;
        }else{
            res += num * pow;
            pow *= 2;
        }
    }
    return res;
}
void copy(int h, int w, int *res, int *ori){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            *(res+i*SIZE+j) = *(ori+i*SIZE+j);
        }
    }
}
int main(void){
    int h, w, k, ori[SIZE][SIZE], cpy[SIZE][SIZE], ans = 0;
    cin >> h >> w >> k;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char c;
            cin >> c;
            ori[i][j] = c - '0';
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            copy(h, w, &cpy[0][0], &ori[0][0]);
            cpy[i][j] = 0;
            ans = max(ans, cal(h, w, k, &cpy[0][0]));
        }
    }
    cout << ans << endl;
}


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


int a, b, c, x, y;

int main()
{
    cin >> a >> b >> c >> x >> y;

    // abピザの枚数でループ
    int mincost = -1;
    for (int i=0; i<=max(x, y); i++)
    {
        // abピザを2i枚買うとき
        int ia = max(0, x - i);
        int ib = max(0, y - i);
        int cost = 2 * i * c + ia * a + ib * b;
        if (cost < mincost || mincost < 0) mincost = cost;
    }

    cout << mincost << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s, t;
  cin >> s >> t;
  ll n = s.size(), m = t.size();

  vector<vector<char>> dp1(n, vector<char>(m, ' '));
  vector<vll> dp2(n, vll(m, 0));

  for (ll i = 0; i < n; i++) {
    if (i > 0) {
      dp2[i] = dp2[i - 1];
      dp1[i] = dp1[i - 1];
    }
    for (ll j = 0; j < m; j++) {
      if (j > 0 && dp2[i][j] < dp2[i][j - 1]) {
        dp2[i][j] = dp2[i][j - 1];
        dp1[i][j] = dp1[i][j - 1];
      }
      if (s[i] == t[j]) {
        if (i > 0 && j > 0) dp2[i][j] = dp2[i - 1][j - 1] + 1;
        else dp2[i][j] = 1;
        dp1[i][j] = s[i];
      }
    }
  }

  /*for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < m - 1; j++) {
      cout << dp2[i][j] << " ";
    }
    cout << dp2[i][m - 1] << endl;
  }*/

  stack<char> ans;
  ll y = n - 1, x = m - 1;
  while (1) {
    if (dp2[y][x] == 0) break;
    if (y == 0 || x == 0) {
      ans.push(dp1[y][x]);
      break;
    }
    if (s[y] == t[x]) {
      ans.push(dp1[y][x]);
      y--;
      x--;
    }
    else if (dp1[y][x] == dp1[y][x - 1] && dp2[y][x] == dp2[y][x - 1]) x--;
    else if (dp1[y][x] == dp1[y - 1][x] && dp2[y][x] == dp2[y - 1][x]) y--;
    else break;
  }

  while (ans.size()) {
    cout << ans.top();
    ans.pop();
  }
  cout << endl;
}

Measured memory_bytes: 79616
n, y = map(int, input().split())

k = 0
for i in range(min(n,y//10000),-1,-1):
  for j in range(n+1-i):
    if 10000*i + 5000*j + 1000*(n-i-j) == y:
      print(i, j, n-i-j)
      k += 1
      exit()
      
if k == 0:
  print('-1 -1 -1')

Measured memory_bytes: 3064
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int, LL> IL;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	vector<IL> v;
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		v.push_back(IL(a, b));
	}
	sort(v.begin(), v.end());
	priority_queue<LL, vector<LL> > q;
	int pos = 0;
	LL ans = 0;
	for (int i = 0; i <= m; ++i) {
		while (pos < n && v[pos].first <= i) {
			q.push(v[pos].second);
			++pos;
		}
		if (q.size()) {
			LL t = q.top();
			q.pop();
			ans += t;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3568
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int long long
using namespace std;
const int maxn=100005,L=10005;
string a,b,c;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
inline void write(int a)
{
	if(a<0)
	{
		putchar('-');
		write(-a);
	}
	else
	{
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
	}
}
string mul(string a,string b)//高精度乘法a,b,均为非负整数
{
	string s;
	int na[L],nb[L],nc[L],La=a.size(),Lb=b.size();//na存储被乘数，nb存储乘数，nc存储积
	memset(na,0,sizeof(na));
	memset(nb,0,sizeof(nb));
	memset(nc,0,sizeof(nc));//将na,nb,nc都置为0
	for(int i=La-1; i>=0; i--) na[La-i]=a[i]-'0'; //将字符串表示的大整形数转成i整形数组表示的大整形数
	for(int i=Lb-1; i>=0; i--) nb[Lb-i]=b[i]-'0';
	for(int i=1; i<=La; i++)
		for(int j=1; j<=Lb; j++)
			nc[i+j-1]+=na[i]*nb[j];//a的第i位乘以b的第j位为积的第i+j-1位（先不考虑进位）
	for(int i=1; i<=La+Lb; i++)
		nc[i+1]+=nc[i]/10,nc[i]%=10;//统一处理进位
	if(nc[La+Lb]) s+=nc[La+Lb]+'0';//判断第i+j位上的数字是不是0
	for(int i=La+Lb-1; i>=1; i--)
		s+=nc[i]+'0';//将整形数组转成字符串
	return s;
}
string sub(string a,string b)//只限大的非负整数减小的非负整数
{
	string ans;
	int na[L]= {0},nb[L]= {0};
	int la=a.size(),lb=b.size();
	for(int i=0; i<la; i++) na[la-1-i]=a[i]-'0';
	for(int i=0; i<lb; i++) nb[lb-1-i]=b[i]-'0';
	int lmax=la>lb?la:lb;
	for(int i=0; i<lmax; i++)
	{
		na[i]-=nb[i];
		if(na[i]<0) na[i]+=10,na[i+1]--;
	}
	while(!na[--lmax]&&lmax>0)  ;
	lmax++;
	for(int i=lmax-1; i>=0; i--) ans+=na[i]+'0';
	return ans;
}
string add(string a,string b)//只限两个非负整数相加
{
	string ans;
	int na[L]= {0},nb[L]= {0};
	int la=a.size(),lb=b.size();
	for(int i=0; i<la; i++) na[la-1-i]=a[i]-'0';
	for(int i=0; i<lb; i++) nb[lb-1-i]=b[i]-'0';
	int lmax=la>lb?la:lb;
	for(int i=0; i<lmax; i++) na[i]+=nb[i],na[i+1]+=na[i]/10,na[i]%=10;
	if(na[lmax]) lmax++;
	for(int i=lmax-1; i>=0; i--) ans+=na[i]+'0';
	return ans;
}
int cmp(string str1,string str2)
{
	if(str1.size() != str2.size()) return str1.size() - str2.size();
	int i;
	for(i = 0; i < str1.size(); ++i)
		if(str1[i] != str2[i]) break;
	if(i < str1.size()) return (str1[i] - str2[i]);
	else return 0;
}
signed main()
{
/*
	cin>>a>>b>>c;
	string ans1,ans2="4";
	if(cmp(add(a,b),c)>0)
		ans1=sub(add(a,b),c);
	else
		ans1=sub(c,add(a,b));
	ans1=mul(ans1,ans1);
	ans2=mul(ans2,mul(a,b));
//	cout<<ans1<<' '<<ans2;
	if(cmp(ans2,ans1)<0)
		puts("Yes");
	else
		puts("No");
	*/
	int h=read(),w=read();
	if(h==1||w==1)
	write(1);
	else
	write((h*w+1)/2);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define ll long long
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;


int main() {
	ll a,b,c,k;cin>>a>>b>>c>>k;

	if(abs(a-b) > 1e18-1)
	{
		cout << "Unfair" <<endl;
		return 0;
	}

	if(k%2==0) cout << a-b << endl;
	else cout << b-a << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;


int H, W;
vector<vector<int>>sums;
int solve(vector<vector<vector<int>>>&memo,int nowx, int nowy, bool fst) {
	if (memo[nowy][nowx][fst] == 1e9 + 1) {
		if (nowx == W&&nowy == H) {
			memo[nowy][nowx][fst] = 0;
		}
		else {
			int nans = -1e9 - 1;
			if (fst) {
				if (nowx != W) {
					nans = max(nans, -solve(memo, nowx + 1, nowy, !fst) + sums[nowy][nowx]);
				}
				if (nowy !=H) {
					nans = max(nans, -solve(memo, nowx, nowy + 1, !fst));
				}
			}
			else {
				if (nowx != W) {
					nans = max(nans, -solve(memo, nowx + 1, nowy, !fst) - sums[nowy][nowx]);
				}
				if (nowy !=H) {
					nans = max(nans, -solve(memo, nowx, nowy + 1, !fst));
				}
			}
			memo[nowy][nowx][fst] = nans;
		}
		
	}
	return memo[nowy][nowx][fst];
}

int main() {
	cin >> W >> H;
	vector<vector<int>>field(H, vector<int>(W));
	int all_sum = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> field[i][j];
			all_sum += field[i][j];
		}
	}
	sums=vector<vector<int>>(H + 1, vector<int>(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			sums[i + 1][j] = sums[i][j] + field[i][j];

		}
	}
	vector<vector<vector<int>>>memo(H + 1, vector<vector<int>>(W + 1, vector<int>(2,1e9+1)));
	auto ans = solve(memo, 0, 0, true);
	cout << abs(2 * ans - all_sum) << endl;
	return 0;
}

Measured memory_bytes: 65664
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

from math import gcd

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

n = int(ri())
a = Ri()

pre = [0]*n
for i in range(n-1,-1,-1):
    if i == n-1:
        pre[i] = a[i]
    else:
        pre[i] = pre[i+1]+a[i]

ans=0
for i in range(n-1):
    ans += (a[i]*(pre[i+1]))%MOD
    ans=  ans%MOD
print(ans)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}
const int LIM=1000000000000000000;
signed main(){
	int N;
	cin>>N;
	vint A(N);
	rep(i,N)cin>>A[i];

	if(count(all(A),0)){
		cout<<0<<endl;
		return 0;
	}
	int m=1;
	rep(i,N){
		if((LIM+A[i])/A[i]<=m){
			cout<<-1<<endl;
			return 0;
		}
		m*=A[i];
	}
	cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 4048