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

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


void solve(long long X){
    ll a = X / 500;
    ll b = (X - 500*a) / 5;

    cout << 1000*a + 5*b << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    cin >> X;
    solve(X);
}


Measured memory_bytes: 256
#include <stdio.h>

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

    for (i = 1; i <= 9; i++)
    {
        if((n % i == 0) && (n / i <= 9)){
            break;
        }
    }
    if(i != 10){
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    
    
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll cnt = 2;
    ll sum = 1;
    vector<ll> suzu;
    suzu.push_back(1);
    while(suzu.back() <= 1000000){
        sum += cnt;
        int now = suzu.back() + sum;
        suzu.push_back(now);
        cnt++;
    }
    reverse(suzu.begin(),suzu.end());
    int N;
    int M = suzu.size();
    vector<ll> dp(1000100,inf);
    vector<ll> dp_odd(1000100,inf);
    dp[0] = 0;
    dp_odd[0] = 0;
    for(int i=0; i<M; i++){
        for(int j=0; j<=1000000; j++){
            if(j+suzu[i]<=1000000){
                chmin(dp[j+suzu[i]],dp[j]+1);
                if(suzu[i]%2){
                    chmin(dp_odd[j+suzu[i]],dp_odd[j]+1);
                }
            }
        }
    }
    while(cin >> N){
        if(N == 0) break;
        cout << dp[N] << " " << dp_odd[N] << enld;
    }
    return 0;
}



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

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A;
    vector<ll> B;
    for (int i = 0; i < N; ++i)
    {
        ll temp;
        cin >> temp;
        A.push_back(temp);
        B.push_back(temp);
    }

    sort(B.begin(), B.end());

    for (auto a : A)
    {
        if (a == B[N - 1])
        {
            cout << B[N - 2] << endl;
        }
        else
        {
            cout << B[N - 1] << endl;
        }
    }
}


Measured memory_bytes: 4964
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n; cin>>n;
  vector<ll> a(n,0);
  vector<ll> c(n,0);

  rep(i,n){
    int A; cin>>A;
    A--;a[A]++;
    c[i]=A;
  }
  ll ans=0;
  rep(i,n){
    if(a[i]<=1) continue;
    ans+=a[i]*(a[i]-1)/2;
  }
  // cout<<ans<<endl;
  rep(i,n){
    if(a[c[i]]<=1) cout<<ans<<endl;
    else{
      ll k=ans-a[c[i]]*(a[c[i]]-1)/2;
      if(a[c[i]]-2>0) k+=(a[c[i]]-1)*(a[c[i]]-2)/2;
      cout<<k<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, k, s;
	cin >> num >> k >> s;
	rep(i, k)
		cout << s << "\n";
	rep(i, num - k)
		cout << s / 2 + 10 << "\n";
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    int b=gi();



	   
	    //System.out.print(sb.toString());

        if (a>12) {
        	System.out.print(b);
        }else if(a>5){
        	System.out.print(b/2);
        } else {
        	System.out.print(0);
        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		Console.WriteLine((p[0]+p[1])%24);
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

ll MOD = 2019;

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

    vector<ll> cnt(2019, 0);
    cnt[0] = 1;
    ll ten = 1;
    ll cur = 0;
    ll ans = 0;

    for(int i = N - 1; i >= 0; i--) {
        int num = s[i] - '0';
        cur += num * ten;
        cur %= MOD;
        ten = (ten * 10) % MOD;

        ans += cnt[cur];
        cnt[cur]++;
    }

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

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll prev = -1;
    REP(i, n){
        cin >> a[i];
        if(prev + 1 < a[i]){
            cout << -1 << endl;
            return 0;
        }else{
            prev = a[i];
        }
    }
    ll cost = a[n - 1];
    for(int i = n - 2;i >= 0; i--){
        if(a[i] + 1 != a[i + 1]) cost += a[i];
    }
    cout << cost << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,a[100005],ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1,j;i<=n;i=j){
		for (j=i;a[j]==a[i];++j);
		if (j-i>=a[i]) ans+=j-i-a[i]; else ans+=j-i;
	}
	printf("%d\n",ans);
	return 0;
}

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

int n,k;
int a[200005];
map<int,int> mp;
vector<int> v;

int main(){

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

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    int td=mp.size()-k;
    if(td<=0){
        cout<<0<<endl;
        return 0;
    }
    for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
        v.push_back(it->second);
    }
    sort(v.begin(),v.end());
    int cnt=0;
    for(int i=0;i<td;i++){
        cnt+=v[i];
    }
    cout<<cnt<<endl;

    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    ll n; cin >> n;
    vector<ll> ans(n + 1);
    for(ll x = 1; x * x <= n; x++) {
        for(ll y = 1; y * y <= n; y++) {
            for(ll z = 1; z * z <= n; z++) {
                if(x*x + y*y + z*z + x*y + y*z + z*x > n)continue;
                ans[x*x + y*y + z*z + x*y + y*z + z*x]++;
            }
        }
    }
    for(ll i = 1; i <= n; i++)cout << ans[i] << endl;
}

Measured memory_bytes: 3624
let cnt = ref 0
let (g : int list ref) = ref []

let insertion_sort (a : int array) n g =
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j+g) <- v
    else (a.(j+g) <- a.(j); incr cnt; insert (j - g) v)
  and doit i =
    if i < n then (insert (i - g) a.(i); doit (i + 1))
  in doit g

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc)
  in doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  g := generate_g n;
  let rec doit = function
    | [] -> ()
    | hd :: tl -> (insertion_sort a n hd; doit tl)
  in doit !g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  shell_sort a n;
  Printf.printf "%d\n" (List.length !g);
  List.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) !g;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

Measured memory_bytes: 12568
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'
#define f(i, n) for (int i = 0; i < n; ++i)

using namespace std;
void solve() {
    int s, w;
    cin >> s >> w;
    cout << ((w >= s) ? "unsafe" : "safe") << nl;
}

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

Measured memory_bytes: 3652
while True:
    n = int(input())
    ans = 0
    if n == 0:
        break
    count = n
    for i in range(1, n):
        a = 0
        for j in range (i, n):
            a += j
            if a == n:
                ans += 1
                break
            if a > n:
                break
    print(ans)

Measured memory_bytes: 6720
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  int c[3][3];
  int a[3],b[3];
  for ( int i = 0; i < 3; i++ ) {
    for ( int j = 0; j < 3; j++ ) {
      cin >> c[i][j];
    }
  }
  int x = 0;
  a[0] = x;
  b[0] = c[0][0] - x;
  b[1] = c[0][1] - x;
  b[2] = c[0][2] - x;
  a[1] = c[1][1] - b[1];
  a[2] = c[2][2] - b[2];
  bool f = true;
  for ( int i = 0; i < 3; i++ ) {
    for ( int j = 0; j < 3; j++ ) {
      if ( a[i] + b[j] != c[i][j] ) f = false;
    }
  }

  if (f ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

#define INF (1<<26)
int A[1000] , B[1000];
int dp[1001][1001];

int N;

int main(){
	cin >> N;
	for(int i = 0 ; i < N ; i++){
		cin >> A[i] >> B[i];
	}
	for(int i = 0 ; i < N ; i++)
		for(int j = 0 ; j < N-1 ; j++)
			if(B[j] > B[j+1]){
				swap(A[j],A[j+1]);
				swap(B[j],B[j+1]);
			}
	for(int i = 0 ; i < 1001 ; i++){
		for(int j = 0 ; j < 1001 ; j++){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for(int i = 0 ; i < N ; i++){
		for(int j = 0 ; j <= N ; j++){
			dp[i+1][j] = dp[i][j];
		}
		for(int j = 0 ; j < N ; j++){
			if(dp[i][j] + A[i] <= B[i]){
				dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+A[i]);
			}
		}	
	}
	int ans = 0;
	for(int j = 0 ; j <= N ; j++){
		if(dp[N][j] != INF) ans = max(ans,j);
	}
	cout << ans << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e18;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n, k;
    cin >> n >> k;
    vl a(n+2);
    a[0] = 0;
    for(ll i=1;i<=n;i++){
        cin >> a[i];
    }
    if(k>=100){
      for (ll i = 1; i <= n;i++){
        cout << n << " ";
      }
      cout << endl;
      return 0;
    }
    vl dp(n + 1, 0);
    rep(i,k){
      for (ll j = 1; j <= n;j++){
        ll in = j - a[j];
        if(in<=0)in = 1;
        ll out = j + a[j]+1;
        if(out>n)out = n + 1;
        dp[in]++;
        dp[out]--;
      }
      ll count = 0;
      for (ll j = 1; j <= n; j++){
        count += dp[j];
        a[j] = count;
        dp[j] = 0;
      }
    }
    for (ll i = 1; i <= n;i++){
      cout << a[i] << " ";
    }
    cout << endl;
}

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

int main(){
    int N;
    int d[110];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> d[i];
    }
    
    int num[110]={0};
    for(int i=0; i<N; i++){
        num[d[i]]++;
    }
    int res=0;
    for(int j=0; j<=100; j++){
        if(num[j]>0){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int a[9],used[9],n;
int s1[9],s2[9];
int num[2],count = 0;
void dfs(int dep)
{
    int i;
    if(dep == n + 1){
        count++;
        for(i = 1; i <= n; i++) if(s1[i] != a[i]) break;
        if(i > n) num[0] = count;
        for(i = 1; i <= n; i++) if(s2[i] != a[i]) break;
        if(i > n) num[1] = count;
    }
    for(i = 1; i <= n; i++)
    {
        if(!used[i]){
            used[i] = 1;
            a[dep] = i;
            dfs(dep + 1);
            used[i] = 0;
        }
    }
}

int main()
{
    scanf("%d",&n);
    int i;
    for(i = 1; i <= n; i++) scanf("%d",&s1[i]);
    for(i = 1; i <= n; i++) scanf("%d",&s2[i]);
    dfs(1);
    printf("%.0lf\n",fabs(num[1] - num[0]));
    return 0;
}

Measured memory_bytes: 128
D, N = map(int, input().split(' '))

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(100*N)
elif D == 2:
    if N == 100:
        print(1010000)
    else:
        print(10000*N)


Measured memory_bytes: 3060
## coding: UTF-8

N = int(input())
A = list(map(int,input().split()))


ans = 0
now_max = A[0]

for i in range(1, N):
    #print(A[i])
    if(now_max < A[i]):
        now_max = A[i]
    else:
        ans += now_max - A[i]

print(ans)


Measured memory_bytes: 94116
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <string>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (LL i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<LL> VI;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 400040	;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL * 1000 * 1000 + 7;

int n,k;
LL arr[500];
LL dpT[500][500];
LL dp(int l, int r)
{
	if(l==r)
		return 0;
	if(dpT[l][r]!=-1LL)
		return dpT[l][r];
	LL ans=LINF;
	LL sum=0;
	FOR(i,l,r)
	{
		ans =min(ans,dp(l,i)+dp(i+1,r));
		sum+=arr[i];
	}
	return dpT[l][r]=ans+sum+arr[r];
}



int main()
{
	//freopen("input.tXXt", "r", stdin);
	ios_base::sync_with_stdio(0);
	FILL(dpT,-1);
	cin >> n;
	FOR(i,0,n)
		cin >> arr[i];
	cout<<dp(0,n-1);
	return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
#define INF (1 << 29)
bool prime(int x){
  if(x == 1)return false;
  for(int i = 2;i * i <= x;i++){
    if(x % i == 0)return false;
  }
  return true;
}

int edge[300][300];

int n, x;
map<int, int> cnt;
vector<int> odd, even;

void add_edge(int u, int v, int f){
  edge[u][v] = f;
}


bool come[300];
int flow(int s, int t){
  if(come[s])return 0;
  come[s] = true;
  if(s == t)return 1;
  for(int i = 0;i < 300;i++){
    if(edge[s][i] == 0)continue;
    if(flow(i, t)){
      edge[s][i]--;
      edge[i][s]++;
      return 1;
    }
  }
  return 0;
}

int max_flow(int s, int t){
  int res = 0;
  while(flow(s, t)){
    res++;
    for(int i = 0;i < 300;i++)come[i] = false;
  }
  return res;
}


int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> x;
    cnt[x]^=1;
    cnt[x-1]^=1;
  }
  map<int, int>::iterator it;
  for(it = cnt.begin();it != cnt.end();it++){
    if(it->second == 0)continue;
    x = it->first;
    if(x % 2 == 0)even.push_back(x);
    if(x % 2 == 1)odd.push_back(x);
  }
  int s = even.size() + odd.size() + 1;
  int t = s + 1;
  for(int i = 0;i < even.size();i++)add_edge(s, i, 1);
  for(int i = 0;i < odd.size();i++)add_edge(even.size() + i, t, 1);
  
  for(int i = 0;i < even.size();i++){
    for(int j = 0;j < odd.size();j++){
      int dif = abs(even[i] - odd[j]);
      if(prime(dif))add_edge(i, even.size() + j, 1);
    }
  }

  int mxf = max_flow(s, t);
  cout << mxf + (even.size() - mxf) / 2 * 2 + (odd.size() - mxf) / 2 * 2 + (even.size() - mxf) % 2 * 3 << endl;
  return 0;
}

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

using ll = long long;

int n;
ll a[111111]; // +,-
ll b[111111]; // -,+

void pa() {
   for (int i = 0; i < n; i++) { cout << a[i] << ", "; } cout << endl;
}

ll f() {
   // +, -
   ll ans = 0;
   ll sum = a[0];
   if (sum <= 0) {
      ll diff = abs(1-sum);
      a[0] += diff;
      ans += diff;
      sum = 1;
   }
   for (int i = 1; i < n; i++) {
      sum += a[i];
      if (i&1) { // -にしたい
         if (sum >= 0) {
            ll diff = abs(-1-sum);
      // printf("diff(-): %lld, sum: %lld\n", diff, sum);
            a[i] -= diff;
            ans += diff;
            sum -= diff;
         }
      } else { // +にしたい
         if (sum <= 0) {
            ll diff = abs(1-sum);
      // printf("diff(+): %lld, sum: %lld\n", diff, sum);
            a[i] += diff;
            ans += diff;
            sum += diff;
         }
      }
      // pa();
      // printf("ans: %lld, sum: %lld\n", ans, sum);
      // puts("-----------------------------------");
   }

   return ans;
}

ll t() {
   // -, +
   ll ans = 0;
   ll sum = b[0];
   if (sum >= 0) {
      ll diff = abs(-1-sum);
      b[0] -= diff;
      ans += diff;
      sum = -1;
   }
   for (int i = 1; i < n; i++) {
      sum += b[i];
      if (i&1) { // -にしたい
         if (sum <= 0) {
            ll diff = abs(1-sum);
      // printf("diff(+): %lld, sum: %lld\n", diff, sum);
            b[i] += diff;
            ans += diff;
            sum += diff;
         }
      } else { // +にしたい
         if (sum >= 0) {
            ll diff = abs(-1-sum);
      // printf("diff(-): %lld, sum: %lld\n", diff, sum);
            b[i] -= diff;
            ans += diff;
            sum -= diff;
         }
      }
      // pa();
      // printf("ans: %lld, sum: %lld\n", ans, sum);
      // puts("-----------------------------------");
   }

   return ans;
}

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

   cout << min(f(), t()) << endl;

   return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s,t;
  cin >> s >> t;
  if(s.size() < t.size()){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  if(s.size() == 1 && t.size() == 1){
    if(s == t || s == "?")cout << t << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
  }
  vector<string> res;
  for(int i = 0;i <= s.size() - t.size();i++){
    bool now = true;
    for(int j = 0;j < t.size();j++){
      if(s[i + j] != '?' && s[i + j] != t[j])now = false;
    }
    if(now){
      string in;
      in += s.substr(0,i);
      //cout << i << " " << in << endl;
      in += t;
      //cout << i << " " << in << endl;
      //cout<<i+t.size()+1<<" "<<s.size()-i-t.size()<<endl;
      in += s.substr(i + t.size(),s.size() - i - t.size());
      //cout << i << " " << in << endl;
      for(int k = 0;k < in.size();k++){
        if(in[k] == '?')in[k] = 'a';
      }
      res.push_back(in);
      //cout << i << " " << in << endl;
    }
    //cout << i << endl;
  }
  sort(res.begin(),res.end());
  if(res.size() == 0)cout << "UNRESTORABLE" << endl;
  else cout << res[0] << endl;
}

Measured memory_bytes: 256
-- modules to import
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as DataByStrChr8



-- functions for input

read_Integer      = fst . fromJust . DataByStrChr8.readInteger
read_list_Integer = map read_Integer . DataByStrChr8.words

get_Integer      = read_Integer      <$> DataByStrChr8.getLine
get_list_Integer = read_list_Integer <$> DataByStrChr8.getLine



-- functions for ABC 064, Task A

calculate_target :: [Integer] -> Integer
calculate_target [red, green, blue] = 100 * red + 10 * green + blue

is_multiple :: Integer -> Integer -> Bool
is_multiple target base
	| mod target base == 0 = True
	| otherwise            = False



-- main process is below

main :: IO ()
main = do

	-- STEP.01
	-- read out the given integers
	[red, green, blue] <- get_list_Integer

	let target = calculate_target [red, green, blue]
	
	putStrLn $ if (is_multiple target 4) then "YES" else "NO"

-- End of this source code

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main()
{
	int counter[26] = {0};
	char c;
	while (cin >> c) {
		c = tolower(c);
		int num = c - 'a';
		if (0 <= num && num < 26) {
			counter[num]++;
		}
	}
	for (int i = 0; i < 26; i++) {
		cout << static_cast<char>(i + 'a') << " : " << counter[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n ;
    int a[n], b[n], c[n + 1];
    c[0] = 0;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
        c[i + 1] = ((a[i] == b[i])? 1 : 0);
        if(c[i + 1] == 1)c[i + 1] += c[i];
    }
    bool maki = false;
    for(int i=1;i<=n;i++){
        if(c[i] >= 3) maki = true;
    }
    if(maki)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  x -= z;
  y += z;
  int cnt = 0;
  while(x>0){
    if(x>=y) cnt++;
    x -= y;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	int ans = 0;
	while (ans < 100000) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
			cout << ans << endl;
			return 0;
		}

		int x = (b + c) / 2;
		int y = (c + a) / 2;
		int z = (a + b) / 2;
		a = x;
		b = y;
		c = z;

		ans++;
	}

	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
n,m,*a=map(int,open(0).read().split())
c=[0,2,5,5,4,5,6,3,7,6]
d=[0]+[-1]*n*9
for i in range(n):
 for j in a:
  if d[i]>=0:d[i+c[j]]=max(d[i+c[j]],d[i]*10+j)
print(d[n])

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> L(M);
  vector<int> R(M);
  
  for (int i=0;i<M;i++) {
    cin>>L.at(i)>>R.at(i);
  }
  
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  
  sort(R.begin(),R.end());
  
  int a=R.at(0)-L.at(0);
  
  if (a>=0) {
    cout<<a+1<<endl;
  }
  else if (a<0) {
    cout<<0<<endl;
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define se second
#define fi first
#define mp make_pair
#define pb push_back
#define ll long long
const int MAXN = (int)1e7 + 1000;
const int N = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
const int INF = (int)1e9;
ll arr[N];
int main(){
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll a,b;
    cin >> n >> a >> b;
    for(int i = 1;i <= n;i++)cin >> arr[i];
    ll ans = 0;
    for(int i = 2;i <= n;i++){
        ans += min((arr[i] - arr[i - 1]) * a, b);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4400
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTollGates solver = new BTollGates();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTollGates {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt(), x = in.nextInt();
            int[] a = IntStream.range(0, m).map(i -> in.nextInt()).toArray();
            out.println(Math.min(
                    Arrays.stream(a)
                            .filter(i -> i > x)
                            .count(),
                    Arrays.stream(a)
                            .filter(i -> i < x)
                            .count()
            ));

        }

    }
}



Measured memory_bytes: 27092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
typedef long long lint;
const int N=5e4+5;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	for(int T=nxi(); T; --T){
		const int a=nxi(),b=nxi();
		lint prod=(lint)a*b;
		int mx=sqrt(prod),ans=(mx-1)*2-(a<mx)-(b<mx);
		if((lint)mx*(mx+1)<prod)
			ans+=(a!=mx)+(b!=mx);
		else if((lint)mx*mx<prod)
			ans+=(a!=mx&&b!=mx);
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0, i_l = (int)n; i < i_l; i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)
 
int main() {
    int a, b, t;;
    cin >> a >> b >> t;
    int count = (t / a) * b;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[100010];
    a[0] = 0;
    rep(i, n) cin >> a[i + 1];
    a[n + 1] = 0;
    int sum = 0;
    rep(i, n + 1) {
        sum += abs(a[i + 1] - a[i]);
    }
    //cout << sum << endl;
    rep(i, n) {
        int x1 = abs(a[i + 1] - a[i]);
        int x2 = abs(a[i + 2] - a[i + 1]);
        int add = abs(a[i + 2] - a[i]);
        cout << sum - x1 - x2 + add << endl;
    }

    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  ll n, k; std::cin >> n >> k;
  ll ans = k;
  rep(i, n-1) ans *= k-1;
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

int in() { int x; scanf("%d", &x); return x; }

int digitsum(int digit) {
  int res=0;
  while (digit>0) {
    res+=digit%10;
    digit=digit/10;
  }
  return res;
}

int main() {
  int N = in();

  int res = 100001;
  for (int A = (int)N/2; A > 0; A--) {
    int DS = digitsum(A) + digitsum(N-A);
    if (res > DS){ res = DS; }
  }

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



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <tuple>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

vector<int> E[110000];

int maxD[110000] = {}, vCol[110000] = {};

void func(int pos, int d, int col){
    if(maxD[pos] >= d){
        return;
    }
    if(maxD[pos] == 0){
        vCol[pos] = col;
    }
    maxD[pos] = d;
    for(int to : E[pos]){
        func(to, d - 1, col);
    }
}

int main(){
    int N, M, Q;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    cin >> Q;
    vector<T> v;
    for(int i = 0; i < Q; i++){
        int x, d, c;
        cin >> x >> d >> c;
        v.push_back(T(x, d + 1, c));
    }
    reverse(v.begin(), v.end());
    for(T t : v){
        func(get<0>(t), get<1>(t), get<2>(t));
    }
    for(int i = 1; i <= N; i++){
        cout << vCol[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 9072
//#define MYDEBUG
#define _CRT_SECURE_NO_WARNINGS
#define TASK "c1"
#pragma comment(linker, "/STACK:67108864")
#include <cstdio>
#include <iostream>
#include <iomanip> 
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <cassert>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>

const int MOD = 1000000007;
const int INF = 1000000001;
const double EPS = 1e-6;
const int HASH_POW = 29;
const double PI = acos(-1.0);

using namespace std;

double workTime()
{
	return double(clock()) / CLOCKS_PER_SEC;
}

void my_return(int code)
{
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int main()
{
	cin.sync_with_stdio(0);
	cin.tie(0);
	mt19937 mt_rand(time(0));
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "rt", stdin);
	freopen(TASK".out", "wt", stdout);*/
	/*freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);*/
#endif
	
	string s;
	cin >> s;
	set <char> used;
	for (int i = 0; i < s.length(); ++i)
		used.insert(s[i]);
	if (used.find('N') != used.end() && used.find('S') == used.end())
		cout << "No\n";
	else if (used.find('S') != used.end() && used.find('N') == used.end())
		cout << "No\n";
	else if (used.find('E') != used.end() && used.find('W') == used.end())
		cout << "No\n";
	else if (used.find('W') != used.end() && used.find('E') == used.end())
		cout << "No\n";
	else
		cout << "Yes\n";

	my_return(0);
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    char buf;
    int cnt = 0;
    int result = 0;
    while(std::cin >> buf)
    {
        buf == 'S' ? ++cnt : --cnt;
        if(cnt < 0)
        {
            cnt = 0;
            result++;
        }
    }
    std::cout << result + cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int S;
	long MOD = 1000000007L;
	long[] memo;

	Main(BufferedReader in) throws IOException {
		S = Integer.parseInt(in.readLine());
		int size = Math.max(6, S + 1);
		memo = new long[size];
		Arrays.fill(memo, -1);
		// 初期化
		memo[0] = 0;
		memo[1] = 0;
		memo[2] = 0;
		memo[3] = 1;
		memo[4] = 1;
		memo[5] = 1;
	}

	long getPattern(int val) {
		if (memo[val] >= 0) {
			return memo[val];
		} else {
			long result = 1L;
			for (int i = 3; i + 3 <= val; ++i) {
				result += getPattern(i);
				result %= MOD;
			}
			memo[val] = result;
			return memo[val];
		}
	}

	void calc() {
	}

	void showResult() {
		long result = getPattern(S);
		System.out.println(result);
	}
}

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

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  char s[3010], t[3010];
  scanf("%s", s);
  scanf("%s", t);

  int N, M;
  N = strlen(s);
  M = strlen(t);

  int dp[N+1][M+1];
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      dp[i][j] = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j]+1;
      else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
    }
  }

  char ans[3010];
  int num = 0;
  while(N > 0 && M > 0){
    if(dp[N][M] == dp[N-1][M]) N--;
    else if(dp[N][M] == dp[N][M-1]) M--;
    else{
      N--, M--;
      ans[num++] = s[N];
    }
  }

  for (int i = num-1; i >= 0; i--) {
    printf("%c", ans[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 35328
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces546B
from collections import Counter
gi = lambda : list(map(int,input().strip().split()))
a, b = gi()
a = a*3 + b
print(a//2)

Measured memory_bytes: 3316
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct S{
  int x, y, o, s, t;
  S(int x, int y, int o, int s, int t) : 
    x(x), y(y), o(o), s(s), t(t) {}
  bool operator < (const S& st) const {
    if(t != st.t) return t > st.t; // reverse
    if(x != st.x) return x < st.x;
    if(y != st.y) return y < st.y;
    if(o != st.o) return o < st.o;
    return s < st.s;
  }
};

int W, H;
int F, M, O;
int A[10][10];

bool update(S s, int dist[10][10][51][1 << 10]){
  assert(valid(s.x, s.y, W, H));
  assert(s.o >= 0 && s.o <= 50);
  assert(s.s >= 0 && s.s < (1 << W));
  int& d = dist[s.y][s.x][s.o][s.s];
  if(d > s.t){
    d = s.t;
    return true;
  }else{
    return false;
  }
}
void move(S& s, int dx){
  s.x += dx;
  s.o --;
  if(dx == 0){
    s.s = 0;
    s.y ++;
  }
  if(!(s.s >> s.x & 1)){
    s.s |= 1 << s.x;
    assert(valid(s.x, s.y, W, H));
    if(A[s.y][s.x] < 0){
      s.t += abs(A[s.y][s.x]);
    }else{
      s.o = min(s.o + abs(A[s.y][s.x]), M);
    }
  }
}
void print(S s){
  printf("x = %d y = %d o = %d s = %04X t = %d\n", s.x, s.y, s.o, s.s, s.t);
}

int main(){
  while(cin >> W >> H && W){
    cin >> F >> M >> O;
    REP(y, H) REP(x, W) cin >> A[y][x];
    static int dist[10][10][51][1 << 10];
    REP(y, H) REP(x, W) REP(o, M + 1) REP(s, 1 << W) dist[y][x][o][s] = INF;
    if(O < 2) {
      cout << "NA" << endl;
      continue;
    }
    priority_queue<S> que;
    REP(sx, W){
      S start(sx, -1, O, 0, 0);
      move(start, 0);
      update(start, dist);
      que.push(start);
    }
    int ans = -1;
    while(!que.empty()){
      S s = que.top(); que.pop();
      //print(s);
      if(s.y == H - 1){
        ans = s.t;
        break;
      }
      if(dist[s.y][s.x][s.o][s.s] < s.t) continue;
      if(s.o <= 1) continue;
      for(int dx = -1; dx <= 1; dx ++){
        if(!(s.x + dx >= 0 && s.x + dx < W)) continue;
        S next = s;
        move(next, dx);
        if(update(next, dist)){
          que.push(next);
        }
      }
    }
    if(ans == -1 || ans > F) cout << "NA" << endl;
    else cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 20760
import collections
n=int(input())
v=list(map(int, input().split()))
a=[]
b=[]
for i in range(n):
  if i%2==0:
    a.append(v[i])
  else:
    b.append(v[i])
a_cnt=collections.Counter(a)
b_cnt=collections.Counter(b)
a_cnt_sort=sorted(a_cnt.items(),key=lambda x:x[1],reverse=True)
b_cnt_sort=sorted(b_cnt.items(),key=lambda x:x[1],reverse=True)
if a_cnt_sort[0][0]!=b_cnt_sort[0][0]:
  print(n-a_cnt_sort[0][1]-b_cnt_sort[0][1])
else:
  if len(a_cnt_sort)>1 and len(b_cnt_sort)>1:
    ans1=n-a_cnt_sort[1][1]-b_cnt_sort[0][1]
    ans2=n-b_cnt_sort[1][1]-a_cnt_sort[0][1]
    print(min(ans1,ans2))
  elif len(a_cnt_sort)>1 and len(b_cnt_sort)==1:
    print(n-a_cnt_sort[1][1]-b_cnt_sort[0][1])
  elif len(a_cnt_sort)==1 and len(b_cnt_sort)>1:
    print(n-b_cnt_sort[1][1]-a_cnt_sort[0][1])
  else:
    print(n-min(a_cnt_sort[0][1],b_cnt_sort[0][1]))

Measured memory_bytes: 27880
import java.util.Scanner;

public class Main {
	static int A;
	static int B;
	static int C;
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		A=sc.nextInt();
		B=sc.nextInt();
		C=A*B;
		System.out.println(C);
		}

}

Measured memory_bytes: 35792
import sys
import math
import collections
import heapq
import queue
import itertools
import functools
import operator
import time

readline = sys.stdin.readline
 
IPS = lambda: readline().rstrip()
IP = lambda: int(readline().rstrip())
MP = lambda: map(int, readline().split())
LS = lambda: list(map(int, readline().split()))

def solve():
    for _ in range(1):
        s = IPS()
        t = IPS()
        cnt = 0
        for i in range(len(s)):
            if s[i]!=t[i]: cnt+=1
        
        print(cnt)
       
if __name__ == "__main__":
    solve()

Measured memory_bytes: 9968
def main():
    Num = int(input())
    Days, RemeinChoco = [int(i) for i in input().split()]
    
    A =[]
    for i in range(Num):
        A.append(int(input()))
    
#    print(A)
    
    EatChocoNum = Num + RemeinChoco
    for i in range(Num):
        EatChocoNum += int((Days - 1)/A[i])
    
    print(EatChocoNum)
if __name__=="__main__":
    main()

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

using namespace std;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_M = 100005;

int N, M;
int P[MAX_M];
string S[MAX_M];

bool used[MAX_M];
int wa[MAX_M];

signed main()
{
  cin >> N >> M;
  int ac = 0;
  REP(m,M) {
    cin >> P[m] >> S[m];
    if(S[m] == "AC") {
      if(!used[P[m]]) {
        used[P[m]] = true;
        ac++;
      }
    } else {
      if(!used[P[m]]) {
        wa[P[m]]++;
      }
    }
  }

  int waSum = 0;
  FOR(n,1,N+1) {
    if(used[n]) {
      waSum += wa[n];
    }
  }

  cout << ac << " " << waSum << endl;

  return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint W; cin >> W;
  V<lint> v(n), w(n); for (int i = 0; i < n; ++i) cin >> v[i] >> w[i];
  int n0 = n >> 1, n1 = n - n0;
  struct S { lint v, w; };
  V<S> a0(1 << n0);
  for (int bit = 0; bit < 1 << n0; ++bit) for (int i = 0; i < n0; ++i) if (bit & 1 << i) a0[bit].v += v[i], a0[bit].w += w[i];
  V<S> a1(1 << n1);
  for (int bit = 0; bit < 1 << n1; ++bit) for (int i = 0; i < n1; ++i) if (bit & 1 << i) a1[bit].v += v[i + n0], a1[bit].w += w[i + n0];
  sort(begin(a1), end(a1), [](const S& lhs, const S& rhs) { return lhs.w < rhs.w; });
  V<lint> mx(1 << n1 | 1);
  for (int bit = 0; bit < 1 << n1; ++bit) mx[bit + 1] = max(mx[bit], a1[bit].v);
  lint res = 0;
  for (int bit = 0; bit < 1 << n0; ++bit) if (a0[bit].w <= W) res = max(res, a0[bit].v + mx[distance(begin(a1), lower_bound(begin(a1), end(a1), W - a0[bit].w + 1, [](const S& lhs, lint rhs) { return lhs.w < rhs; }))]);
  cout << res << '\n';
}


Measured memory_bytes: 43804
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

const int N = 10000 + 5;
int cnt[N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,p;
	cin >> n >> p;
	string s;
	cin >> s;
	ll ans = 0;
	if(p == 2){
		rep(i,0,n){
			if((s[i]-'0') % 2 == 0){
				ans += i + 1;
			}
		}
	}
	else if(p == 5){
		rep(i,0,n){
			if(s[i] == '0' || s[i] == '5'){
				ans += i + 1;
			}
		}
	}
	else {
		int mul = 1, rsum = 0;
		++cnt[0];
		for(int i = n-1;i >= 0; --i){
			rsum = (mul * (s[i] - '0') + rsum) % p;	
			ans += cnt[rsum]++;
			mul = (10 * mul) % p;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 720
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define INT_MAX 2147483647

int main(void){
    int N;
    scanf("%d", &N);
    int j;
    int count = 0;
    for(j=1; j<=N; j++) {
        int H[201] = {0};
        int x = j;
        int i = 3;
        while(i <= x && i != 1) {
            if(i % 2 != 0) {
                if(x % i == 0) {
                    H[i]++;
                    x = x / i;
                }
                else{
                    i++;
                }
            }
            else{
                i++;
            }
        }

        int sum = 1;
        for(i=1; i <= j; i++){ 
            if(H[i] != 0) {
                sum *= H[i] + 1;
            }
        }
        if(j % 2 != 0 ) {
            if(sum == 8) {
                count++;
            }
        }

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

    return 0;
}

Measured memory_bytes: 128
n = int(input())
s = int((-1 + (1+8*n)**(1/2) ) /2)
if s*(s+1)/2 == n:
    ans = [i  for i in range(1,s+1)]
elif s*(s+1)/2 < n:
    tmpans = [i for i in range(1,s+2)]
    #print(tmpans)
    #print(sum(tmpans) - n + 1)
    del tmpans[sum(tmpans) - n - 1]
    ans = tmpans
else:
    tpmans = [i for i in range(1,s+1)]
    #print(tmpans)
    #print(sum(tmpans) - n + 1)
    del tmpans[sum(tmpans) - n - 1]
    ans = tmpans
    
for i in ans:
    print(i)

Measured memory_bytes: 3572