akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

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

int main(int argc, char *argv[])
{
    // input values
    int N;
    std::cin >> N;

    // dp table
    int dp[550000];

    // init dp table
    for (int i = 0; i < 550000; i++) {
        dp[i] = INF;
    }

    // init condition
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 3;
    dp[4] = 4;
    dp[5] = 5;
    dp[6] = 1;
    dp[7] = 2;
    dp[8] = 3;
    dp[9] = 1;

    // loop
    for (int i = 10; i <= N; i++) {
        chmin(dp[i], dp[i-1]+1);
        for (int pow6 = 6; pow6 <= N; pow6*=6) {
            if (i - pow6 < 0) {
                break;
            } else if (i - pow6 == 0) {
                dp[i] = 1;
            } else {
                chmin(dp[i], dp[i-pow6]+1);
            }
        }
        for (int pow9 = 9; pow9 <= N; pow9*=9) {
            if (i - pow9 < 0) {
                break;
            } else if (i - pow9 == 0) {
                dp[i] = 1;
            } else {
                chmin(dp[i], dp[i-pow9]+1);
            }
        }
    }

    std::cout << dp[N] << std::endl;
    return 0;
}

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


int p, q, r;

int main() {
  std::vector<int> v(3);
  std::cin >> v.at(0) >> v.at(1) >> v.at(2);
  sort(v.begin(), v.end());
  printf("%d\n", v.at(0) +v.at(1));

  return 0;
}

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

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll ans;
  if (x/d > k) {
    ans = x - d*k;
  } else {
    ll e = x/d;
    k -= e;
    x -= e*d;
    if (k%2 == 1) x = abs(x-d);
    ans = x;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

vector<int> List;
int main() {
  for(int i=2; i<55555; i++) if(i%10 == 7) {
    bool isCan = true;
    for(int j=2; j*j<=i; j++) if(i%j == 0) {isCan = false;}
    if(isCan) List.push_back(i);
  }
  int N; cin >> N;
  for(int i=0; i<N; i++) printf("%d ", List[i]);puts("");
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func chmax(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func chmax3(a int, b int, c int) int {
	return chmax(chmax(a, b), chmax(a, c))
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	plans := make([][]int, n)
	dp := make([][]int, n)

	for i := 0; i < n; i++ {
		plans[i] = nextInts(3)
		dp[i] = make([]int, 3)
	}

	for i := range dp {
		if i == 0 {
			dp[i][0] = plans[i][0]
			dp[i][1] = plans[i][1]
			dp[i][2] = plans[i][2]
		}

		if i == n-1 {
			break
		}

		dp[i+1][0] = chmax(dp[i][1], dp[i][2]) + plans[i+1][0]
		dp[i+1][1] = chmax(dp[i][0], dp[i][2]) + plans[i+1][1]
		dp[i+1][2] = chmax(dp[i][0], dp[i][1]) + plans[i+1][2]
	}

	fmt.Println(chmax3(dp[n-1][0], dp[n-1][1], dp[n-1][2]))
}


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

using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vll = vector<vl>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
ll n;
vll act;
int main() {
	cin >> n;
	act.resize(n, vl(3));
	REP(i, n){
		REP(j, 3){
			cin >> act[i][j];
		}
	}
	vll dp(n+1, vl(3, 0));
	REP(i, n){
		REP(j, 3){
			dp[i+1][j] = max(dp[i][(j+1)%3] + act[i][(j+1)%3], dp[i][(j+2)%3] + act[i][(j+2)%3]);
		}
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
	return 0;
}


Measured memory_bytes: 14328
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;	
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
bool can (int g, int n, int m) {
	if (g <= n) 
		return m >= 2 * g;
	int need = g - n;
	m -= 2 * need;
	return m >= 2 * g;
}
void solve() {
	int n, m;
	cin >> n >> m;
	int ans = 0;
	int lo = 1, hi = (int) 1e12;
	while (lo <= hi) {
		int mid = (lo + hi) >> 1;
		if (can(mid, n, m)) {
			ans = mid;
			lo = mid + 1;
		}
		else {
			hi = mid - 1;
		}
	}
	cout << ans;
}     	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		System.out.println((a + b > c + d)? "Left" : (a + b == c + d) ? "Balanced" : "Right");
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <cmath>
#include <set>
#include <cstring>
#include <queue>
using namespace std;

int ans[4] = {-1, -1, -1, -1};

int main(){
    int n, m, a, b;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        a--;
        if(ans[a] != -1 && ans[a] != b){
            cout << "-1\n";
            return 0;
        }
        ans[a] = b;
    }
    if(n == 1 && ans[0] <= 0){
        cout << "0\n";
        return 0;
    }
    bool zero = false;
    for(int i = 0; i < n; i++){
        if(ans[i] == 0 && !zero){
            cout << "-1\n";
            return 0;
        } else {
            if(ans[i] == -1 && !zero) ans[i] = 1;
            zero = true;
        }
    }
    for(int i = 0; i < n; i++){
        cout << max(ans[i], 0);
    }
    cout << '\n';
}


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

using namespace std;

const int INF = 1e9;

int main(void) {
  int n, k;
  cin >> n >> k;

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

  int l = 0, r = 0;
  int num = 0, ans = INF;
  map<int, int> mp;
  while (l < n) {
    while (r < n && num < k) {
      if (a[r] <= k && mp[a[r]]++ == 0) {
        num++;
      }
      r++;
    }
    if (num < k) break;

    ans = min(ans, r - l);
    if (a[l] <= k && --mp[a[l]] == 0) {
      num--;
    }
    l++;
  }

  cout << ((ans == INF) ? 0 : ans) << endl;

  return 0;
}


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

#define ll long long

int main(){
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if (abs(b-a)<=((v-w)*t)){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int a, b, c, x;
  scanf("%d %d %d %d", &a, &b, &c, &x);

  int ans = 0;
  for ( int fi = 0; fi <= min(x / 500, a); fi++) {
    int fr = x - 500 * fi;
    for ( int hi = 0; hi <= min(fr / 100, b); hi++ ) {
      int hr = fr - 100 * hi;
      if (hr / 50 <= c) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int answer = 0;
        if (a >= 13) {
            answer = b;
        } else if ((6 <= a) && (a <= 12)) {
            answer = b / 2;
        }
        System.out.println(answer);
        sc.close();
    }
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            int[] memo = new int[51];

            for (int i = 9; i >= 0; i--)
                for (int j = 9; j >= 0; j--)
                    for (int k = 9; k >= 0; k--)
                        for (int l = 9; l >= 0; l--)
                            memo[i + j + k + l]++;

            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                int n = int.Parse(input);
                sb.AppendLine(memo[n].ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int n;
int m[101][101];

void daiksutora(){
	int p[101];
	int d[101];
	int color[101];
	rep(i, n){
		d[i] = 1e8;
		color[i] = 0;
	}
	d[0] = 0;
	p[0] = -1;
	while(1){
		int mincost = 1e8;
		int u = -1;
		rep(i, n){
			if(color[i] != -1 && d[i] < mincost){
				mincost = d[i];
				u = i;
			}
		}
		if(u == -1) break;
		color[u] = -1;
		rep(v, n){
			if(color[v] != -1 && m[u][v] != -1){
				if(d[u]+m[u][v] < d[v]){
					d[v] = d[u]+m[u][v];
					color[v] = 1;
					p[v] = u;
				}
			}
		}
	}
	rep(i, n){
		cout << i << " " << d[i] << endl;
	}
}

int main(){
	cin >> n;
	rep(i, n){
		rep(j, n){
			m[i][j] = -1;
		}
	}
	rep(i, n){
		int u, k, v, c;
		cin >> u >> k;
		rep(i, k){
			cin >> v >> c;
			m[u][v] = c;
		}
	}
	daiksutora();
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;

int main() {
	// fios;
	string n;
	cin >> n;
	if(n.find("7") != string::npos) puts("Yes");
	else puts("No");

}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
// typedef tuple<int, int, int> T;
#define FOR(i, s, x) for (int i = s; i < (int)(x); i++)
#define REP(i, x) FOR(i, 0, x)
#define ALL(c) c.begin(), c.end()
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string S;
  std::cin >> S;
  int N = S.size();

  std::vector<int> dp(1 << 26, N);
  dp[0] = 0;
  int bit = 0;
  int ans;
  for (int i = 0; i < N; i++) {
    bit ^= 1 << (S[i] - 'a');
    ans = dp[bit] + 1;
    for (int j = 0; j < 26; j++) {
      ans = min(ans, dp[bit ^ (1 << j)] + 1);
    }
    dp[bit] = min(dp[bit], ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 262804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> s.at(i).at(j);
        }
    }
    vector<vector<int>> c(H, vector<int>(W, 0));
    for (int x = 0; x < H; x++) {
        for (int y = 0; y < W; y++) {
            if (s.at(x).at(y) == '#') c.at(x).at(y)++;
            for (int i = 0; i < 4; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (nx >= 0 && nx < H && ny >= 0 && ny < W && s.at(nx).at(ny) == '#') {
                    c.at(x).at(y)++;
                }
            }
        }
    }
    for (int x = 0; x < H; x++) {
        for (int y = 0; y < W; y++) {
            if (s.at(x).at(y) == '#' && c.at(x).at(y) < 2) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    map<char, int> ss, tt;
    for (int c : s) {
        ss[c]++;
    }
    for (int c : t) {
        tt[c]++;
    }
    multiset<int> sss, ttt;
    for (auto &p : ss) {
        sss.insert(p.second);
    }
    for (auto &p : tt) {
        ttt.insert(p.second);
    }

    cout << (sss == ttt ? "Yes" : "No") << endl;
}

Measured memory_bytes: 916
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int S[1000];
int top;

int pop() {
    top --;
    return S[top+1];
}

void push(int x) {
    top ++;
    S[top] = x;
}

int main() {
    top = 0;
    int a, b;
    char s[100];
    
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a+b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a-b);
        } else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        } else {
            push(atoi(s));
        }
    }
    
    printf("%d\n", pop());
    
    return 0;
}

Measured memory_bytes: 3204
from operator import itemgetter

n=int(input())
abList = [list(map(int,input().split())) for _ in range(n)]

abList.sort(key=itemgetter(1))
time = 0
ret = 'Yes'
for i in range(n):
    time += abList[i][0]
    if time > abList[i][1]:
        ret = 'No'
        break
print(ret)

Measured memory_bytes: 53732
n, m, x = map(int, input().split())
master = []
ans = 10 ** 18
for i in range(n):
    b = list(map(int, input().split()))
    master.append(b)

for i in range(2 ** n):
    kau = [0 for _ in range(m + 1)]
    for j in range(n):
        if (i >> j) & 1:
            # print(i)
            for k in range(m + 1):
                kau[k] += master[j][k]
    ng = 0
    for k in range(1, m + 1):
        if kau[k] < x:
            ng = 1
    if not ng:
        ans = min(ans, kau[0])
    # print(ans)
    # print(kau)
print(ans if ans != 10 ** 18 else -1)


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> ans(10010, 0);
    for(int i = 1; i <= 100; i++) {
        for(int j = 1; j <= 100; j++) {
            for(int k = 1; k <= 100; k++) {
                int x = i * i + j * j + k * k + i * j + j * k + k * i;
                if(x <= n) {
                    ans[x]++;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,M;
    cin >> N >> M;
    vector<int> a(M),b(M);
    for (int i=0;i<M;i++) {
        cin >> a[i] >> b[i];
    }
    vector<int> pa(N+1);
    vector<int> sz(N+1);
    map<int,int> sz_ct;
    for (int i=1;i<=N;i++) {
        pa[i] = i;
        sz[i] = 1;
    }
    sz_ct[1] = N;
    vector<long long> uc(M);
    vector<int> tmp;
    for (int j=M-1;j>=0;j--) {
        long long u = 0;
        for (auto ct : sz_ct) {
            u += (long long)ct.second * (N - ct.first) * ct.first;
        }
        uc[j] = u / 2;

        int ra=a[j],rb=b[j];
        while (ra != pa[ra]) {
            tmp.push_back(ra);
            ra = pa[ra];
        }
        tmp.push_back(ra);
        while (rb != pa[rb]) {
            tmp.push_back(rb);
            rb = pa[rb];
        }
        tmp.push_back(rb);
        int r;
        if (ra!=rb) {
            sz_ct[sz[ra]]--;
            sz_ct[sz[rb]]--;
            if (sz_ct[sz[ra]]==0) sz_ct.erase(sz[ra]);
            if (sz[ra]!=sz[rb] && sz_ct[sz[rb]]==0) sz_ct.erase(sz[rb]);

            r = min(ra,rb);
            sz[r] = sz[ra] + sz[rb];
            if (sz_ct.find(sz[r])==sz_ct.end()) {
                sz_ct[sz[r]] = 0;
            }
            sz_ct[sz[r]]++;
        } else {
            r = ra;
        }
        while (tmp.empty() == false) {
            pa[tmp.back()] = r;
            tmp.pop_back();
        }
    }

    for (int j=0;j<M;j++) {
        cout << uc[j] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3712
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cv: Vec<char> = n.chars().collect();
    let ans = if (cv[0] == cv[1] && cv[1] == cv[2]) || (cv[1] == cv[2] && cv[2] == cv[3]) {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


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

using namespace std;

int main()
{
    int n,k,l[52],i,j,sum=0;
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l,l+n);
    for(j=n-1;j>=n-k;j--){
        sum+=l[j];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  ll arr[n],brr[n];
  ll maxx=-1,maxx2=-1;
  for(ll i=0;i<n;i++){
    cin>>arr[i];
    brr[i]=arr[i];
  }
  
    
  sort(brr,brr+n);
  maxx=brr[n-1];maxx2=brr[n-2];
  for(ll i=0;i<n;i++){
    if(arr[i]==maxx) cout<<maxx2<<"\n";
    else cout<<maxx<<"\n";
  }
  return(0);
}

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

int main(){
    int a[101];
    int n;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    sort (a, a+n);
    cout << a[n-1]-a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define lli long long int
#define pb(a) push_back(a)
#define forr(a,n) for(lli i=a;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
lli power(lli x){
lli u=0;
while(x%2==0){
    u++;
    x=x/2;
}
return u;
}

lli powM(lli x,lli y,lli m)
{
    lli ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
lli dp[100001];

lli ans(lli x,lli a[]){
    // cout<<a[x]<<"\n";
    if(x==1){return dp[1]=0;}
    if(x==2){return dp[2]=abs(a[2]-a[1]);}
    if(dp[x]==-1){
dp[x]=min(ans(x-1,a)+abs(a[x]-a[x-1]),ans(x-2,a)+abs(a[x]-a[x-2]));
return dp[x];}
else{
return dp[x];
}
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset (dp,-1,sizeof(dp));
int t=1;
//cin>>t;
lli M=1e9+7;
while(t--){
lli n;
cin>>n;
lli a[n+1];
forr(1,n+1){cin>>a[i];}
//a[0]=LONG_LONG_MAX;
cout<<ans(n,a);

}
     return 0;
}


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if(N % 2 == 0){
        cout << N << endl;
    }
    else{
        cout << N*2 << endl;
    }
}


Measured memory_bytes: 256
using System;

class Program
{
    public static void Main()
    {
        double r = double.Parse(Console.ReadLine());
        
        double area = r * r * Math.PI;
        double circle = r * 2 * Math.PI;
        
        Console.WriteLine("{0:F6} {1:F6}",area,circle);
    }
}


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

int main() {
	int ans = 0;
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int j = 1; j < n - 1; j++) {
		if ((p[j] > p[j-1] && p[j] < p[j + 1]) || (p[j] < p[j-1] && p[j] > p[j + 1]))ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
l=[0]*4
l[0]=c+b-d
l[1]=d-(a-c)
l[2]=l[0]+a-c
l[3]=l[1]+(b-d) 
for i in range(3):
    print(l[i],end=' ')
print(l[3])


Measured memory_bytes: 3060
n = int(input())
h = list(map(int, input().split()))


h[0] = h[0] -1
for i in range(1,n):
    if(h[i-1] < h[i]):
        h[i] = h[i]-1

flag = True
for i in range(1,n):
    if(h[i-1]>h[i]):
        flag = False

if(flag):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll n,c,k;
vector<ll> t;

void input(){
    cin >> n >> c >> k;
    t.resize(n);
    for(ll i=0;i<n;i++) cin >> t[i];  
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    sort(t.begin(), t.end());
    ll ans = 1;
    ll start_time = t[0];
    ll cnt = 1;
    for(ll i=1;i<n;i++){
        cnt++;
        if((start_time + k < t[i]) || (cnt > c)){
            start_time = t[i];
            cnt = 1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    string m,n;
    cin>>m>>n;
    if (m.at(0)==n.at(2) && m.at(1)==n.at(1) && m.at(2)==n.at(0)) {
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
    return 0;
}

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

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

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    string s;
    cin >> s;
    int cnt = count(all(s), 'A');
    cout << (cnt && cnt != 3 ? "Yes" : "No");
}


Measured memory_bytes: 3612
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

N,d=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(100001){0}
gets.chomp.split(" ").map{|i| i.to_i}.each{|i|
	if(i>0) then A[i-1]+=1 end
	A[i]+=1
	if(i<100000) then A[i+1]+=1 end
}
puts A.max


Measured memory_bytes: 9724
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Main
{
    String str;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	int ans = 1;
	
	for(int i = str.length() - 1; i > 0; i--) {
	    if(i % 2 == 1) continue;
	    String s = str.substring(0, i);

	    String l = s.substring(0, i / 2);
	    String r = s.substring(i / 2, i);
	    if(l.equals(r)) {
		ans = i;
		break;
	    }
	}
	 	
	out(ans);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	str = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int ans)
    {
	System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x,int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/

int H, W;
char field[55][55];

int bfs()
{
	queue<int> X, Y, A;
	X.push(0);
	Y.push(0);
	A.push(0);
	field[0][0] = '#';

	int nx, ny, na;
	int tx, ty;
	int dx[4] = { 1,-1,0,0 };
	int dy[4] = { 0,0,1,-1 };

	while (X.size() > 0)
	{
		nx = X.front();
		ny = Y.front();
		na = A.front();
		X.pop();
		Y.pop();
		A.pop();

		for (int i = 0; i < 4; i++)
		{
			tx = nx + dx[i];
			ty = ny + dy[i];

			if (0 <= nx && nx < H && 0 <= ny && ny < W)
			{
				if (tx == H - 1 && ty == W - 1)
					return na + 1;

				if (field[tx][ty] == '.')
				{
					field[tx][ty] = '#';
					X.push(tx);
					Y.push(ty);
					A.push(na + 1);
				}
			}
		}
	}

	return -1;
}

int main()
{
	int count = 0;

	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> field[i][j];
			if (field[i][j] == '.')
				count++;
		}
	}

	int ans = bfs();

	if (ans == -1) cout << -1 << endl;
	else cout << count - (ans + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque,defaultdict
sys.setrecursionlimit(10**5)

H,W,K=map(int, sys.stdin.readline().split())
ichigo=[]
cnt=0   #イチゴに番号を振るための変数
h_visit=[0 for h in range(H)]  #縦軸にイチゴがない箇所は0、ある箇所は1

L=[ [] for h in range(H) ]
for h in range(H):
    s=sys.stdin.readline().strip()
    for w,x in enumerate(s):
        if x==".":
            L[h].append(0)
        elif x=="#":
            cnt+=1
            L[h].append(cnt)
            ichigo.append((h,w))
            h_visit[h]=1

D=(1,-1)

def yoko_dfs(h,w):  #縦座標、横座標
    for dw in D:
        if 0<=w+dw<=W-1 and L[h][w+dw]==0:
            L[h][w+dw]=L[h][w]
            yoko_dfs(h,w+dw)
    return

#横方向に空マスなら、自分のイチゴ番号で埋めていく
for h,w in ichigo:
    yoko_dfs(h,w)


def tate_dfs(h):  #縦座標
    for dh in D:
        if 0<=h+dh<=H-1:
            if h_visit[h+dh]==1: continue
            h_visit[h+dh]=1 #訪問済みにする
            L[h+dh]=L[h]
            tate_dfs(h+dh)

#縦方向にイチゴが1個もない行があれば、1行前を行ごとコピーする
for h,w in ichigo:
    tate_dfs(h)

for l in L:
    for x in l:
        print x,
    print

Measured memory_bytes: 47132
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	int n,k;
	cin >> n >> k;
	double pref[n+1];
	double p[n];
	pref[0] = 0;
	for(int i =1;i<=n;i++){
		cin >> p[i-1];
		p[i-1] = (1+p[i-1])/2;
		pref[i] = pref[i-1] + p[i-1];
	}

	double maxi = 0;
	for(int i =k;i<=n;i++){
		maxi = max(maxi,pref[i]-pref[i-k]);
	}
	cout << fixed << setprecision(9) << maxi << endl;


}

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

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 6884
import math
a, b, x = map(int, input().split())

# 半分より多い場合とそれ未満で分ける
if (x / a) >= (a * b / 2):
  ans = math.degrees(math.atan(2 * (b / a - x / (a ** 3))))
else:
  ans = math.degrees(math.atan((a * b ** 2) / (2 * x)))
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S;
	cin>>S;
	string SS = S;
	int N = S.length();
	for(int i = 0; i < N; i++){
		if(S[i] != S[N-i-1]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i = 0; i < (N-1)/2; i++){
		if(S[i] != S[(N-1)/2-i-1]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret

def isPrime(N):
    if N <= 1: return False
    return sum(primeFactor(N).values()) == 1

def findPrime(N):
    if N < 0: return -1
    i = N
    while True:
        if isPrime(i):
            return i
        i += 1

N = int(input())
print(findPrime(N))

Measured memory_bytes: 3188
n = int(input())
l=list(map(int ,input().split()))
ll=list(map(int ,input().split()))
ans=0
for i in range(n):
    if l[i]==ll[i]:
        ans+=ll[i]
    elif l[i]>ll[i]:
        ans+=ll[i]
    elif l[i]<ll[i]:
        if l[i+1]>=ll[i]-l[i]:
            l[i+1]=l[i+1]-(ll[i]-l[i])
            ans+=ll[i]
        elif l[i+1]<ll[i]-l[i]:
            ans+=(l[i])+(l[i+1])
            l[i+1]=0
print(ans)

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
        fastio;
        ll h;
        cin>>h;
        ll x=0;
        while(h!=0)
        {
            h=h/2;
            x++;

        }
        ll ans=pow(2,x)-1;
        cout<<ans<<endl;
    }

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

class Program{

  static int a, b, ans;
  static int[] c = new int[3];

  static int Main() {

    string[] nyu = new string[2];

    nyu = Console.ReadLine().Split(' ');
    a = int.Parse(nyu[0]);
    b = int.Parse(nyu[1]);

    c[0] = a + b;
    c[1] = a - b;
    c[2] = a * b;

    ans = c.Max();

    Console.WriteLine("{0}", ans);

    return 0;
  }

}


Measured memory_bytes: 13268
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int N,A[100],flag,count=0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    flag = 1;
    while(flag){
        flag = 0;
        for(int j=N-1;j>=1;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                count++;
                flag = 1;
            }
        }
    }
    for(int i=0;i<N;i++){
        cout << A[i];
        if(i!=N-1)  cout << " ";
    }
    cout << "\n" << count << "\n";
}



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

int main(){

    int i,n,taro_point=0,hanako_point=0,kachi;
    char taro[1001],hanako[1001];
    
    scanf("%d",&n);
    
    for(i=0;i<n;++i){
      scanf("%s",taro);
      scanf("%s",hanako);

      kachi=strcmp(taro,hanako);
      
      if (kachi>0) taro_point+=3;
      if (kachi<0) hanako_point+=3;
      if (kachi==0) {
		  taro_point+=1;
		  hanako_point+=1;
	  }
    }

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

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int 
#define pb   push_back
#define T int time;        scanf("%d", &time); while(time--)
  vector<ll>ad[1000000];
  ll vis[1000000]={};
  ll cnt=0;
  ll dfs(ll n){
  	vis[n]=1;
  	 cnt++;
  	  for(auto it: ad[n])if(vis[it]==0)dfs(it);
  	  	return cnt;
  }
int main(){
	ll n,m;
	cin>>n>>m;
	for(ll i=0; i<m; i++){
		ll u,v;
		cin>>u>>v;
		ad[u].pb(v);
		ad[v].pb(u);
	}
	vector<ll>v;

	for(ll i=1; i<=n; i++){
		if(vis[i]==0){
			ll r=dfs(i);
			cnt=0;
			v.pb(r);
		}
	}
	sort(v.begin(),v.end());
	ll ans=v[v.size()-1];
	cout<<ans<<endl;
}

Measured memory_bytes: 40928
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>

#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 998244353

using namespace std;

const int maxN = 1e5;
vector<int> adj[maxN + 1];

void solve()
{
    int N, M;
    cin >> N >> M;

    vector<int> H(N + 1);
    for (int i = 1; i < N + 1; i++)
    {
        cin >> H[i];
    }

    for (int i = 0; i < M; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int count = 0;
    for (int v = 1; v <= N; v++)
    {
        bool is_good = true;
        for (int u : adj[v])
        {
            if (H[v] <= H[u])
            {
                is_good = false;
                break;
            }
        }
        if (is_good)
        {
            count++;
        }
    }

    cout << count << endl;
}


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

    int T = 1;
    //cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 8804
#include <cstdio>
#define LOOP(index,times) for(int index=0;index<times;index++)
using namespace std;

int main(){

float l[6];
float x,y;

while(scanf("%f %f %f %f %f %f",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5]) != EOF){
	
	x=(l[2]*l[4]-l[1]*l[5])/(l[0]*l[4]-l[1]*l[3]);
	y=(l[2]*l[3]-l[0]*l[5])/(l[1]*l[3]-l[0]*l[4]);
	if(x==0)x=0;
	if(y==0)y=0;
	printf("%.3lf %.3lf\n",x,y);		

}

return 0;		
}

Measured memory_bytes: 1076
N = int(input())

print((((N-1)*N)//2) - N//2)


if N % 2 == 1:
  ban = N
else:
  ban = N + 1


for i in range(1,N):
  for j in range(i+1,N+1):
    if i + j != ban:
      print(i,j)

Measured memory_bytes: 9256
using System;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var S = new int[N, N * 2];
        for (int i = 0; i < N; i++)
        {
            var line = ReadLine();
            for (int j = 0; j < N; j++)
            {
                S[i, j] = line[j];
                S[i, N + j] = line[j];
            }
        }

        var c = 0;
        for (int b = 0; b < N; b++)
        {
            for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (S[i, b + j] != S[j, b + i]) goto a;
            c++;
        a:;
        }

        WriteLine(c * N);
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<limits.h>
typedef struct{
  int x;
  char c;
}card;
card B[100000];

int Partition(int p, int r){
  card t;
  int x,i,j;
  x = B[r].x;
  i = p-1;
  for( j = p; j< r;j++){
    if (B[j].x <= x){
      i = i+1;
      t=B[i];
      B[i]=B[j];
      B[j]=t;
    }
  }
    t = B[i+1];
    B[i+1] = B[r];
    B[r] = t;
  return i+1;
}

void Quicksort(int p,int r){
  int q;
  if( p < r){
     q = Partition( p, r);
     Quicksort( p, q-1);
     Quicksort( q+1, r);
      }
  }

void merge(int left,int mid,int right,card A[]){
  int i,j,k;
  int n1 = mid-left;
  int n2 = right-mid;
  card L[100000],R[100000];
  //printf("left=%d right=%d n1 = %d n2 =%d\n",left,right,n1,n2);

  for(i = 0;i<n1;i++){
    L[i]=A[left+i];
    //printf("L[%d]=%d %c ",i,L[i].x,L[i].c);
  }

  for(i = 0;i<n2;i++){
    R[i]=A[mid+i];
    //printf("R[i]=%d %c ",R[i].x,R[i].c);
  }
  
  L[n1].x=INT_MAX;
  R[n2].x=INT_MAX;
  i=0;
  j=0;
  for(k = left; k<right; k++){
    if(L[i].x<=R[j].x){
      A[k]=L[i++];
    }
    else {
      A[k]=R[j++];
     }
    //printf("%c %d\n",A[k].c,A[k].x);
 
  }
  
}
void mergeSort(int left,int right,card A[]){
  if(left+1 < right ){
  int mid = (left+right)/2;
  mergeSort(left,mid,A);
  mergeSort(mid,right,A);
  merge(left,mid,right,A);
  }
}

int main(){
  int i,p,n;
  char c;
  card C[100000];
  scanf("%d%c",&n,&c);

  for(i=0;i<n;i++){
    scanf("%c%d%c",&C[i].c,&C[i].x,&c);
    B[i]=C[i];
  }

  p=0;
  mergeSort(0,n,C);
  Quicksort(0,n-1);
  for(i=0;i<n;i++){
    if(C[i].c!=B[i].c){
      printf("Not stable\n");
      break;
    }
    if(i==n-1)printf("Stable\n");
  }

  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].c,B[i].x);
    }
  //   printf("\n");

    //  for(i=0;i<n;i++){
    //    printf("%c %d\n",C[i].c,C[i].x);
    //    }


  return 0;
}

Measured memory_bytes: 2776
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>=0 && a<=5){
		b=0;
	}
	else if(a>=6 &&  a<=12){
		b=b/2;
	}
	else{
	}
	printf("%d\n",b);
	return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 2e5 + 5;
const ll INF = (ll) 1e18;
ll arr[MAX], pref[MAX];
int n;

inline ll range_sum(int left, int right) {
	return max(0LL, pref[right] - pref[left - 1]);
}

int main() {
	scanf("%d", &n);
	fori(i, 1, n + 1) {
		scanf("%lld", arr + i);
		pref[i] = pref[i - 1] + arr[i];
	}

	ll ans = INF;

	int left = 1, middle = 2, right = 3;
	while(middle <= n - 2) {
		while(left + 1 < middle) {
			ll a = range_sum(1, left), b = range_sum(left + 1, middle);
			ll c = range_sum(1, left + 1), d = range_sum(left + 2, middle);
			if(abs(a - b) > abs(c - d)) left++;
			else break;
		}
		while(right + 1 < n) {
			ll a = range_sum(middle + 1, right), b = range_sum(right + 1, n);
			ll c = range_sum(middle + 1, right + 1), d = range_sum(right + 2, n);
			if(abs(a - b) > abs(c - d)) right++;
			else break;
		}
		ll minn = min({range_sum(1, left), range_sum(left + 1, middle), range_sum(middle + 1, right), range_sum(right + 1, n)});
		ll maxx = max({range_sum(1, left), range_sum(left + 1, middle), range_sum(middle + 1, right), range_sum(right + 1, n)});
		ans = min(ans, maxx - minn);
		middle++;
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <fstream>
#define inf INFINITY
#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ; 
#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define _3102_ main()
#define endl '\n'
typedef long long ll ;
typedef unsigned long long ull ; 
typedef long double ld ; 
using namespace std ;
const int N = 1e5+100  ; 
const ll mod = 1e9 + 7  ;



int _3102_ {
    Gamed
    ll n , k , arr[N] , dp[N] ; 
    cin >> n >> k ; 
    for ( int i = 0 ; i < n ; i ++){
        cin >> arr[i] ; 
    }
    dp[0] = 0 ;  
    for ( int i = 1 ; i < n ; i ++){
        ll ans = inf , cnt = k; 
        for ( int j = i - 1 ; j >= 0 && cnt > 0 ; j -- , cnt --){
            ans = min (ans, dp[j] + abs(arr[i]-arr[j])) ;
        }
        dp[i] = ans ; 
    }
    cout << dp[--n] << endl ; 
    return 0;
}

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

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

int main(){
        IOS;
        ll n;
        cin>>n;
        ll a[n];
        for(ll i=0;i<n;i++) cin>>a[i];
        ll ans=0;
        for(ll i=1;i<n;i++){
                if(a[i]<a[i-1]){
                        ans+=(abs(a[i]-a[i-1]));
                        a[i]=a[i-1];
                }
        }
        cout<<ans<<"\n";
}


Measured memory_bytes: 5176
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
 
  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
//   typedef string str;
//   typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 1000000007;
  // lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;
  


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


      int x,y,z;
      cin>>x>>y>>z;
      cout<<z<<" "<<x<<" "<<y<<endl;
}
  

Measured memory_bytes: 3192
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> a(n, 0);
  vector<int> ret(n, 0);
  for (int i = 0; i < n; i++)
    cin >> a[i];



  int k = n;
  while (k > 1){
    int l = k;
    k = k/2 + 1;

    for (int i = k; i <= l; i++){
      int bit = 0;
      for (int j = 2*i; j <= n; j += i){
        bit = (bit + ret[j-1]) % 2;
      }
      ret[i-1] = (bit + a[i-1]) % 2;
    }
    k--;
  }

  int bit = 0;
  int num = 0;
  for (int i = 0; i < n; i++){
    if (ret[i] == 1)
      num++;
    bit = (bit + ret[i]) % 2;
  }

  if (bit == a[0])
    ret[0] = 0;
  else {
    num++;
    ret[0] = 1;
  }




  cout << num << endl;
  for (int i = 0; i < n; i++){
    if (ret[i] == 1)
      cout << i + 1 << (i == n - 1 ?  "" : " ");
  }
  cout << endl;

}

Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <cmath>
#include <utility>
#include <vector>
using namespace std;

#define X first
#define Y second

int main() {
  int n;
  int cnt=0;
  
  while(cin>>n, n) {
    vector< pair<int,int> > v;
    for(int i = 0; i < n; i++) {
      int x,y; cin>>x>>y;
      v.push_back(make_pair(x,y));
    }
    double ans = 0.0;
    for(int i = 0; i < n; i++) {
      ans += (v[i].X-v[(i+1)%n].X)*(v[i].Y+v[(i+1)%n].Y);
    }
    ans/=2; ans=abs(ans);
    printf("%d %.1f\n", ++cnt, ans);
  }
  
  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

int main(){

  int n, m;
  vector<int> city(50, 0);
  int a, b;
  
  cin >> n >> m;
  
  rep(i, m){
    cin >> a >> b;
    city[a-1]++;
    city[b-1]++;
  }
  
  rep(i, n){
    cout << city[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	ll c=0;
	for(ll i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		{
		c=c+(a[i-1]-a[i]);
		a[i]=a[i-1];
		}
	}
	cout<<c<<"\n";
	return 0;
}

Measured memory_bytes: 5192
import sys
from itertools import accumulate
from collections import Counter
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
cumsum = [0] + [i % m for i in accumulate(a_ls)]
ct = Counter(cumsum)
res = 0
for k, v in ct.items():
    if v >= 2:
        res += v * (v-1) // 2
print(res)

Measured memory_bytes: 60184
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll maxi(ll a, ll b){
    return (a>b)? a : b;
}


int main(){
    ll n, m, e=1000000007; cin>> n>> m;
    char c[n+1][m+1];
    ll a[n+1][m+1];
    for(ll i=0; i<=n; i++){
        for(ll j=0; j<=m; j++){
            a[i][j]=0;
            c[i][j]='.';
            if(i && j) cin>> c[i][j];
        }
    }
    a[1][1]++;
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=m; j++){
            if(c[i][j]=='.') a[i][j]=a[i-1][j]+a[i][j-1];
            a[i][j]%=e;
            a[1][1]=1;
        }
    }
    cout<< a[n][m]<< endl;
}


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

int in[3];

int main() {
    for (int i = 0; i < 3; i++) {
        cin >> in[i];
    }

    sort(in, in+3);
    
    int ans = 0;
    if ((in[1]-in[0]) % 2 == 0) {
        ans += in[2] - in[1];
        ans += (in[1] - in[0]) / 2;
    }
    else {
        ans += in[2] - in[1];
        ans += (in[1] - in[0]) / 2;
        ans += 2;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

int abs(int a) {
    return (a < 0 ? -a : a);
}

int main() {
    int n = gi();
    int l = gi();

    int s = 0;
    for (int i = 0; i < n; i++)
        s += l+i;

    if (l > 0 || l+n-1 < 0)
        s -= (abs(l) < abs(l+n-1) ? l : l+n-1);

    printf("%d\n", s);

    return 0;
}


Measured memory_bytes: 256