akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        sx: i32,
        sy: i32,
        tx: i32,
        ty: i32,
    }
    let dx = tx - sx;
    let dy = ty - sy;
    for _ in 0..dx { print!("R"); }
    for _ in 0..dy { print!("U"); }
    for _ in 0..dx { print!("L"); }
    for _ in 0..dy { print!("D"); }
    print!("D");
    for _ in 0..dx + 1 { print!("R"); }
    for _ in 0..dy + 1 { print!("U"); }
    print!("LU");
    for _ in 0..dx + 1 { print!("L"); }
    for _ in 0..dy + 1 { print!("D"); }
    println!("R");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int A[N];
    int B[N];
    rep(i,N){
        cin>>A[i];
        B[i]=A[i]-1-i;
    }
    sort(B,B+N);
    int ans=0;
    int av=0;
    if(N%2==1){
        av=B[N/2];
    }
    else{
        av=(B[N/2]+B[N/2-1])/2;
    }
    rep(i,N){
        ans+=abs(B[i]-av);
    }
    cout << ans << endl;




}


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

using namespace std;
typedef long long int ll;

void solve()
{
	string s;cin>>s;
	if(s.compare("ABC")==0) cout<<"ARC"; else cout<<"ABC";
	
}

int main()
{
	ll t;t=1;
	while(t--)
	solve();
}


Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

public class Main {
  private static long solve(char[] s) {
    int index = 0;
    long answer = 0;
    long countA = 0;
    while (index + 1 < s.length) {
      if (s[index] == 'A') {
        countA++;
        index++;
      } else if (s[index] == 'B' && s[index + 1] == 'C') {
        answer += countA;
        index += 2;
      } else {
        countA = 0;
        index++;
      }
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] s = reader.next().toCharArray();
    out.println(solve(s));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 25992
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static final int P = 924844033;

	int[] go(int a, int b) {
		// 0 - can't take prev
		// 1 - can
		int[][] dp = new int[1][2];
		dp[0][1] = 1;
		for (int i = 1; i <= a; i++) {
			int[][] nxt = new int[i + 1][2];
			for (int j = 0; j < i; j++) {
				for (int k = 0; k < 2; k++) {

					// skip
					int delta = dp[j][k];
					nxt[j][1] += delta;
					if (nxt[j][1] >= P) {
						nxt[j][1] -= P;
					}

					// take prev
					if (k == 1 && (a < b || i != 1)) {
						nxt[j + 1][1] += delta;
						if (nxt[j + 1][1] >= P) {
							nxt[j + 1][1] -= P;
						}
					}

					// take next
					nxt[j + 1][0] += delta;
					if (nxt[j + 1][0] >= P) {
						nxt[j + 1][0] -= P;
					}
				}
			}
			dp = nxt;
		}
		int[] ret = new int[a + 1];
		for (int i = 0; i <= a; i++) {
			ret[i] = (dp[i][0] + dp[i][1]) % P;
		}
		// System.err.println(a + " " + b + " " + Arrays.toString(ret));
		return ret;
	}

	int[] go(int n) {
		int[] tmp = go(n / 2, (n + 1) / 2);
		return mult(tmp, tmp);
	}

	int[] mult(int[] a, int[] b) {
		int[] c = new int[a.length + b.length - 1];
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < b.length; j++) {
				c[i + j] += (int) ((long) a[i] * b[j] % P);
				if (c[i + j] >= P) {
					c[i + j] -= P;
				}
			}
		}
		return c;
	}

	void solve() throws IOException {
		int n = nextInt();
		int k = nextInt();

		int[] dp = { 1 };

		for (int rem = 0; rem < k; rem++) {
			int cnt = (n - rem + k - 1) / k;
			dp = mult(dp, go(cnt));
		}

//		System.err.println(Arrays.toString(dp));

		int[] fact = new int[n + 1];
		fact[0] = 1;
		for (int i = 1; i <= n; i++) {
			fact[i] = (int) ((long) fact[i - 1] * i % P);
		}

		int ans = fact[n];
		for (int i = 1; i <= n && i < dp.length; i++) {
			int delta = (int) ((long) dp[i] * fact[n - i] % P);
			if ((i & 1) == 1 && delta != 0) {
				delta = P - delta;
			}
			ans += delta;
			if (ans >= P) {
				ans -= P;
			}
		}

		out.println(ans);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23172
#include<iostream>
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h,w,i,j;
	char x;
	cin>>h>>w;
	bool a[h+1][w+1];
	for(i=1; i<=h;i++) {
		for(j=1; j<=w; j++){
			cin>>x;
			if(x == '.')
				a[i][j] = true;
			else
				a[i][j] = false;
		}
	}

	int dp[h+1][w+1];
	for(i=0; i<=h;i++) {
		for(j=0; j<=w; j++){
			dp[i][j] = -1;
			if(i == 0 || j == 0)
				a[i][j] = false;
		}
	}

	dp[1][1] = 1;

	for(i=1; i<=h;i++) {
		for(j=1; j<=w; j++){
			if(i == 1 && j == 1)
				continue;
			if(a[i][j]){
				if(a[i][j-1] && dp[i][j-1] > 0){
					dp[i][j] = (dp[i][j-1] % MOD);
				}
				if(a[i-1][j]){
					if(dp[i-1][j] > 0){
						if(dp[i][j] < 0)
							dp[i][j] = 0; 
						dp[i][j] = ((dp[i][j] + dp[i-1][j] ) % MOD);
					}
				}
			}
		}
	}

	// for(i = 1; i<=h;i++){
	// 	for(j=1;j<=w;j++)
	// 		cout<<dp[i][j]<<"  ";
	// 	cout<<'\n';
	// }

	if(dp[h][w] <= 0)
		cout<<0<<'\n';
	else
		cout<<dp[h][w]<<'\n';
	return 0;
}

Measured memory_bytes: 5120
n=int(input())
h=[int(x) for x in input().split()]
z=t=0
for c in range(n-1):
    if h[c+1]<=h[c]:
        t+=1
    else:
        if z<t:
            z=t
        t=0
    if c==n-2 and z<t:
        z=t
print(z)

Measured memory_bytes: 14252
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int num[505][505];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m, q;
	cin >> n >> m >> q;
	rep(i, 505) rep(j, 505) num[i][j] = 0;
	rep(i, m){
		int l, r;
		cin >> l >> r;
		num[l][r]++;
	}
	repn(i, 1, 501){
		repn(j, i + 1, 501){
			num[i][j] += num[i][j - 1];
		}
	}
	repn(i, 1, 501) repn(j, i, 501){
		repn(k, i + 1, j + 1) num[i][j] += num[k][j];
	}
	rep(i, q){
		int l, r;
		cin >> l >> r;
		cout << num[l][r] << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1920
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

N = k()
if N % 2 == 0: print((N//2)**2)
else: print((N//2)*(N//2+1))


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


void solve(long long K){
    queue<unsigned long long> q;
    
    for(int i = 1;i < 10; i++){
        q.push(i);
    };

    unsigned long long tmp = 0;

    while(K != 0){
        tmp = q.front();
        q.pop();
        if(tmp % 10 != 0) q.push(tmp * 10 + tmp % 10 - 1); 
        q.push(tmp * 10 + tmp % 10);
        if(tmp % 10 != 9) q.push(tmp * 10 + tmp % 10 + 1);
        K --;
    }
    cout << tmp << 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 K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}
 
 
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;
 
	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}
 
	return num;
}
*/
ll n;
ll dp[MAX][14],done[MAX][14];
string s;
ll solve(ll i,ll j,ll _10){
	if(i == n){
		if(j == 5){
			return 1;
		}
		return 0;
	}
	if(done[i][j])return dp[i][j];
	ll ans=0;
	if(s[i]!='?'){
		ll x = s[i]-'0';
		ll rem = (j+(_10*x)%13)%13;
		ans=(ans+solve(i+1,rem,(_10*10)%13))%MOD;
	}
	else{
		for(ll k=0;k<=9;k++){
			ll x = k;
			ll rem = (j+(_10*x)%13)%13;
			ans=(ans+solve(i+1,rem,(_10*10)%13))%MOD;
		}
	}
	done[i][j]=1;
	return dp[i][j]=ans;
}
int main(){FAST;
	cin>>s;
	n = s.length();
	reverse(all(s));
	cout<<solve(0,0,1);
return 0;
}

Measured memory_bytes: 31696
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	string str;
	cin >> str;
	for (char x : str) {
		if (x == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n,m,tmp;
    cin >> n >> m;
    vector<int> x(m, 0);
    vector<int> dist(m-1, 0);
    for(int i=0;i<m;++i)
    {
        cin >> tmp;
        x[i] = tmp;
    }

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

    for(int i=1;i<m;++i)
    {
        dist[i-1] = x[i] - x[i-1];
    }
    sort(dist.rbegin(), dist.rend());

    int ans = 0;
    for(int i=0;i<m-1;i++)
    {
        if(i < n-1)
        {
            continue;
        }
        ans += dist[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = st[0];
            int B = st[1];
            int C = st[2];

            int cand_1 = 10 * A + B + C;
            int cand_2 = A + 10 * B + C;
            int cand_3 = A + B + 10 * C;

            Console.WriteLine(Math.Max(Math.Max(cand_1, cand_2), cand_3));
            
        }
    }
}


Measured memory_bytes: 13396
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main() {
  fast();
  cin >> n;
  map<int, int> mp;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    mp[i] = x;
  }
  vector<bool> vis(MXN);
  int ans = 0;
  for (auto& x : mp) {
    if (!vis[x.s] and !vis[x.f] and mp[x.s] == x.f) {
      ++ans;
      vis[x.s] = 1, vis[x.f] = 1;
    }
  }
  cout << ans;

  return 0;
}



Measured memory_bytes: 8312
#include <iostream>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <tuple>
using namespace std;
long long N, Q; vector<long long>C1, C2;
long long nex(long long E) {
	return (E - 1) / N;
}
int main() {
	cin >> N >> Q;
	for (int i = 0; i < Q; i++) {
		long long v, w; cin >> v >> w; v--; w--;
		if (N == 1) { cout << min(v, w) + 1 << endl; continue; }
		C1.clear(); C2.clear();
		while (v > 0) { C1.push_back(v); v = nex(v); }C1.push_back(0LL);
		while (w > 0) { C2.push_back(w); w = nex(w); }C2.push_back(0LL);
		long long minx = 0;
		for (int j = 0; j < C1.size(); j++) {
			for (int k = 0; k < C2.size(); k++) {
				if (C1[j] == C2[k])minx = max(minx, C1[j]);
			}
		}
		cout << minx + 1 << endl;
	}
	return 0;
}

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

int main(void) {
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	long long ans1 = 0;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 0 && sum <= 0) {
			ans1 += abs(sum) + 1;
			sum = 1;
		} else if (i % 2 == 1 && sum >= 0) {
			ans1 += abs(sum) + 1;
			sum = -1;
		}
	}

	long long ans2 = 0;
	sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 0 && sum >= 0) {
			ans2 += abs(sum) + 1;
			sum = -1;
		} else if (i % 2 == 1 && sum <= 0) {
			ans2 += abs(sum) + 1;
			sum = 1;
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int n, A[100];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	int p = 0, ans = 0;
	while (p < n) {
		int c = A[p],f=0;
		while (p < n&&A[p] == c) f++, p++;
		ans += f / 2;
	}
	cout << ans;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]
m1=max(a)
m2=-1
c=0
for x in a:
    if x==m1:c+=1
    if x!=m1:m2=max(m2,x)
if c>=2:m2=m1
if m2==-1:m2=m1
for x in a:
    if x==m1:print(m2)
    else:print(m1)

Measured memory_bytes: 12532
N = gets.to_i
b = []
b = gets.split.map(&:to_i)

a = []
# aの先頭
a[0] = b[0]
# aの末尾
a[N-1] = b[N-2]
if not N == 2
  1.upto(N-2) do |i|
    a[i] = [b[i], b[i-1]].min
  end
end
puts a.inject(:+)

Measured memory_bytes: 1788
def inpl(): return [int(i) for i in input().split()]

N,A,B = inpl()
C = A-B
h = [int(input()) for _ in range(N)]

lo = -(-sum(h)//((N-1)*B+A)) -1
hi = sum([-(-i//A) for i in h]) 
while hi - lo > 1:
    me = (hi+lo)//2
    hprime = [h[i]-me*B for i in range(N) if h[i]-me*B >0]    
    hans = 0
    for j in hprime:
            hans += -(-j//C)
    if hans <= me:
        hi = me
    else:
        lo = me
print(hi)

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

bool check( int A, int B, int i )
{
  int num = 0;
  while( i > 0 ) {
    num += i % 10;
    i /= 10;
  }

  if( A <= num && num <= B )
    return true;
  else
    return false;
}
    
  

int main( void )
{
  int N, A, B;
  cin >> N >> A >> B;
  int sum = 0;
  bool ok = false;
  
  for( int i = 0; i <= N; i++ ) {
    ok = check( A, B, i );
    if( ok )
      sum += i;
  }

  cout << sum << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long lli;

lli gcd(lli a, lli b) {
  if(b == 0) return a;
  return gcd(b,a%b);
}

lli lcm(lli a, lli b) {
  return a*b/gcd(a,b);
}

pair<lli,lli> irreducible(pair<lli,lli> p) {
  lli t = gcd(p.first,p.second);
  return make_pair(p.first/t,p.second/t);
}

pair<lli,lli> lcm(pair<lli,lli> a, pair<lli,lli> b) {
  a = irreducible(a);
  b = irreducible(b);
  lli t = lcm(a.second,b.second);
  return irreducible(make_pair(lcm(a.first*t/a.second,b.first*t/b.second),t));
}

const int MAX_N = 11;
int N;
lli D[MAX_N], V[MAX_N];

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) cin >> D[i] >> V[i];
    pair<lli,lli> tmp = make_pair(D[0],V[0]);
    for(int i = 1; i < N; ++i) tmp = lcm(tmp,make_pair(D[i],V[i]));
    for(int i = 0; i < N; ++i) {
      cout << V[i]*tmp.first/D[i]/tmp.second << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set A = new HashSet<Integer>();
		boolean prime = false;

		for (int i = 0; i < N; i ++) {
			A.add(sc.nextInt());
		}

		if (A.size() == N) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}

Measured memory_bytes: 98600
import java.math.BigInteger;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), count[] = new int[26];
        for (char c : scanner.next().toCharArray())
            count[c - 'a']++;
        BigInteger ans = BigInteger.ONE;
        for (int i = 0; i < 26; i++)
            ans = ans.multiply(BigInteger.valueOf(count[i] + 1));
        System.out.println(ans.subtract(BigInteger.ONE).remainder(BigInteger.valueOf(1000000007)));
    }
}

Measured memory_bytes: 25684
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, A;
  cin >> N >> A;
  vector<int> q(N);
  for(int i = 0; i < N; i++) {
    cin >> q.at(i);
  }
  sort(q.begin(), q.end());
  int ans = 0;
  for(int i = 0; i < A; i++) {
    ans += q.at(i);
  }
  cout << ans << endl;
}

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

int main()
{
  int n;
  cin>>n;
  int arr[n],cost[n]={0};
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }

  for(int i=0;i<n;i++)
  {
    if(i==0)
        cost[i]=0;
  else if(i==1)
        cost[i]=abs(arr[i-1]-arr[i]);
  else
    cost[i]=min(cost[i-1]+abs(arr[i]-arr[i-1]),cost[i-2]+abs(arr[i]-arr[i-2]));
  }

  cout<<cost[n-1];

}


Measured memory_bytes: 4372
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#define mod 3.1415926535897932384626 
using namespace std;
typedef long long ll;
  int main()
  {  double n;
      scanf("%lf",&n);
      printf("%.7f\n",2*n*mod);
   } 

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

using namespace std;
#define int int64_t
#define rep(i,a,n) for(int i=(a); i<(n); ++i)
#define reps(i,a,n) for(int i=(a); i>(n); --i)
#define all(x) (x).begin(),(x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod = 1e9 + 7;

signed main()
{
	cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    double n;
    cin>>n;
    cout<<Fixed(10)<<2*n*M_PI<<'\n';
    return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	for(int i=0; i<s.size(); i++) {
		if(s[i]=='C') {
			for(int j=i+1; j<s.size(); j++) {
				if(s[j]=='F') {
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1<<18;
using ll = long long;
using pll = pair<ll, ll>;
int h[200001];
struct LiChao{
	struct Node{
		int l=0,r=0;
		pll line = pll(0, (ll)1e18);
	} node[2*SIZE];
	int cnt;
	inline ll f(pll line, int x){
		return line.first*x + line.second;
	}
	void update(int nn, int ns, int ne, pll newLine){
		auto &cur = node[nn];
		pll l1 = cur.line, l2 = newLine;
		if(f(l1, ns) > f(l2, ns)) swap(l1, l2);
		if(f(l1, ne) <= f(l2, ne)){
			cur.line = l1;
			return;
		}
		int m = ns+ne>>1;
		if(f(l1, m) <= f(l2, m)){
			cur.line = l1;
			if(!cur.r) cur.r = ++cnt, node[cnt].line = l1;
			update(cur.r, m+1, ne, l2);
		}
		else{
			cur.line = l2;
			if(!cur.l) cur.l = ++cnt, node[cnt].line = l2;
			update(cur.l, ns, m, l1);
		}
	}
	ll query(int nn, int ns, int ne, int x){
		auto &cur = node[nn];
		if(ns==ne) return f(cur.line, x);
		int m = ns+ne>>1;
		if(m<x) return min(f(cur.line, x), cur.r?query(cur.r, m+1, ne, x):(ll)1e18);
		return min(f(cur.line, x), cur.l?query(cur.l, ns, m ,x):(ll)1e18);
	}
} L;
int N;
ll dp[200001], C;
int main(){
	scanf("%d%lld",&N,&C);
	for(int i=1; i<=N; ++i) scanf("%d",h+i);
	L.update(0, 0, 1e6, pll(-2ll*h[1], 1ll*h[1]*h[1]));
	for(int i=2; i<=N; ++i){
		dp[i] = 1ll*h[i]*h[i]+C+L.query(0, 0, 1e6, h[i]);
		L.update(0, 0, 1e6, pll(-2ll*h[i], 1ll*h[i]*h[i]+dp[i]));
	}
	printf("%lld",dp[N]);
	return 0;
}

Measured memory_bytes: 14848
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int N,n[200],d[200],x[200],y[200];
    
    while(true){
        scanf("%d",&N);
        
        if(N == 0) break;
        
        for(int i = 1;i < N;++i)
            scanf("%d %d",&n[i],&d[i]);
        
        x[0] = y[0] = 0;
        
        for(int i = 1;i < N;++i){
            if(d[i] == 0){
                x[i] = x[ n[i] ] - 1;
                y[i] = y[ n[i] ];
            }
            
            if(d[i] == 1){
                x[i] = x[ n[i] ];
                y[i] = y[ n[i] ] - 1;
            }
            
            if(d[i] == 2){
                x[i] = x[ n[i] ] + 1;
                y[i] = y[ n[i] ];
            }
            
            if(d[i] == 3){
                x[i] = x[ n[i] ];
                y[i] = y[ n[i] ] + 1;
            }
        }
        
        int mnx = x[0],mxx = x[0],mny = y[0],mxy = y[0];
        
        for(int i = 1;i < N;++i){
            mnx = min(mnx,x[i]);
            mxx = max(mxx,x[i]);
            
            mny = min(mny,y[i]);
            mxy = max(mxy,y[i]);
        }
        
        printf("%d %d\n",mxx - mnx + 1,mxy - mny + 1);
    }
    
    return 0;
}

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

using namespace std;

const int size = 1e5 + 7;
vector<int> graph[size];
int dp[size];

int check(int v){
	if(dp[v] != 0) return dp[v];
	for(int u: graph[v]){
		dp[v] = max(dp[v], check(u) + 1);
	}
	return dp[v];
}

int main(){
	int n, m;
	cin>>n>>m;
	for(int u, v, x=0;x<m;x++){
		cin>>u>>v;
		graph[u].push_back(v);
	}

	for(int x=0;x<=n;x++) dp[x] = 0;

	int ans =0; 
	for(int x=1;x<=n;x++){
		if(dp[x] == 0){
			ans = max(ans, check(x));
		}
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 7424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        WriteLine(n + n * n + n * n * n);
        ReadLine();
    }
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
 // c_p_c();
  int a,b;
  cin >> a >> b;
  if(min(a,b) <=8 && max(a,b) <= 8)
  {
    cout<<"Yay!"<<endl;
  }
  else
  {
    cout<<":("<<endl;  
  }

  return 0;
}



Measured memory_bytes: 256
//Chandigarh University
//author:- shivamkr21
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int maxcount=0,counts=0;
    char ar[10];
    
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
        {
            counts++;
            if(maxcount<counts)
            {
                maxcount=counts;
            }
        }
        else
        {
            counts=0;
        }
    }
    cout<<maxcount<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,k,i;
	int j;
	i=100;
	scanf("%d",&n);
	for(k=1;k<=n;k++){
		j=i*1.05;
		if(i*105==j*100){
			i=i*1.05;
		}else{
			i=i*1.05+1;
		}
	}
	printf("%d\n",i*1000);
	return 0;
}

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

int main() {
  int a, b, c, x;
  int cnt = 0;
  scanf("%d%d%d%d", &a, &b, &c, &x);
  for (int i=0; i <= a; i++) {
    for (int j=0; j <= b; j++) {
      for (int k=0; k <= c; k++) {
        cnt += (500*i + 100*j + 50*k == x ? 1 : 0);
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int res = 0;
    for(int a = 0;a <= A;++a){
        for(int b = 0;b <= B;++b){
            for(int c = 0;c <= C;++c){
                int total = 500*a + 100*b + 50*c;
                if(total == X) ++res;
            }
        }
    }
    cout << res;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
cnt=0
n=int(input())
l=list(map(int,input().split()))
m=0
for i in range(1,n):
    if l[i]<=l[i-1]:
        cnt+=1
    else:
        cnt=0
    if m < cnt:
        m=cnt

print(m)


Measured memory_bytes: 14252
#include <stdio.h>
//#include <>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail++;
  tail = tail % LEN;
}

P dequeue(){
  P ret;
  ret = Q[head];
  head++;
  head = head % LEN;
  return ret;
}


int main(){
  int elaps = 0, c , zan;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head =0;
  tail = n;
  zan = n;
  while ( head != tail)
    {
      u = dequeue();
      if (u.t <=  q){
 elaps+=  u.t;
	 printf("%s %d\n",u.name , elaps);

	 }
      else if ( u.t > q){ elaps += q;u.t -= q;enqueue(u);}
    }
  return 0;
}


Measured memory_bytes: 11852
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((int)(x).size())

using namespace std;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef long long ll;

int main() {
  ll N, M = 1000;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  REP(i, N-1) {
    ll tmp = 0;
    if (A[i] < A[i+1]) {
      tmp = M / A[i];
    }
    M += (A[i+1] - A[i]) * tmp;
  }
  cout << M << endl;
  return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << '\n';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//素集合データ構造
// ref:https://ei1333.github.io/luzhiled/snippets/structure/union-find.html
struct union_find {
    // parent[v]==w(>=0):vの親はw
    // parent[v]==k(<0):vは根&&vの属するグループの要素数は-k
    vector<long long int> parent;
    // dimH_0:連結成分の数
    long long int dimH_0;
    //コンストラクタ
    union_find(long long int n) {
        parent.assign(n, -1);
        dimH_0 = n;
    }
    // vの根を求める
    //求めると同時に親を根に置き換える(木の圧縮)
    long long int root(long long int v) {
        if (parent[v] < 0) {
            return v;
        } else {
            parent[v] = root(parent[v]);
            return parent[v];
        }
    }
    // vが属するグループの要素数を求める
    long long int size(long long int v) {
        return -parent[root(v)];
    }
    // vとwを繋げる
    void unite(long long int v, long long int w) {
        v = root(v);
        w = root(w);
        if (v == w) return;
        if (parent[v] < parent[w]) swap(v, w);
        parent[w] += parent[v];
        parent[v] = w;
        dimH_0--;
    }
    // vとwが同値か判定
    bool isSame(long long int v, long long int w) {
        return root(v) == root(w);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    union_find uf(n);
    int x, y, z;
    for (int i = 0; i < m; i++) {
        cin >> x >> y >> z;
        uf.unite(x - 1, y - 1);
    }
    cout << uf.dimH_0 << endl;
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root=NIL;
Node treeMinimum(Node x){
  if(x->left == NIL) return x;
  else treeMinimum(x->left);
}

Node treeMaximum(Node x){
  if(x->right == NIL) return x;
  else treeMaximum(x->right);
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;
  else if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

void treeDelete(Node z){
  Node y;
  Node x;
  Node a;
  if(z->left == NIL || z->right == NIL) y = z;

  else {
    while(1){
    if(z->right != NIL){
      y=treeMinimum(z->right);
      break;
    }

    a = z->parent;
    while(a != NIL && z->key == a->right->key){
      z = a;
      a = a->parent;
    }
    y=a;
    break;
  }
}

  if(y->left!=NIL) x = y->left;
  else x = y->right;

  if(x!=NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y!=z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;

  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}void preorder(Node u){
  if(u==NIL) return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      //if ( t != NIL ) printf("yes\n");
      //else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int H, W; cin >> H >> W;
  vector<string> C(H);
  rep(i,H) cin >> C[i];
  rep(i,H){
    cout << C[i] << endl;
    cout << C[i] << endl;
  }
  return 0;
}


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

using std::cerr;
using std::endl;

#define int long long

const int N = 650, P = 1e9 + 7;

int n, K, f[N][N], g[N], mat[N], ans;

signed main() {
//   freopen("data", "r", stdin);
  std::cin >> n >> K, n *= 2;
  g[0] = 1;
  for (int i = 2; i <= n; i += 2)
    g[i] = g[i - 2] * (i - 1) % P;
  for (int i = 1; i <= K; ++i) {
    int x, y; std::cin >> x >> y;
    mat[x] = y, mat[y] = x;
  }
  for (int l = 1; l <= n; ++l) {
    for (int r = l + 1; r <= n; r += 2) {
      int ok = 1;
      for (int i = l; i <= r; ++i)
        if (mat[i] && (mat[i] < l || mat[i] > r)) {
          ok = 0; break;
        }
      if (!ok) continue;
      int cnt = r - l + 1;
      for (int i = l; i <= r; ++i)
        cnt -= !!mat[i];
      f[l][r] = g[cnt];
      for (int i = r, tot = 0; i > l; --i) {
        tot += !mat[i];
        f[l][r] = (f[l][r] - f[l][i - 1] * g[tot]) % P;
      }
      ans = (ans + f[l][r] * g[n - K * 2 - cnt]) % P;
    }
  }
  ans = (ans % P + P) % P;
  std::cout << ans << std::endl;
  return 0;
}



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

#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl "\n"
const int MAX = 1e2+5;
const ll MAX2 = 11;
const ll MOD = 1000000000;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

short int n,cnt[12],dp[12][1<<23],x,z[1<<23];
int pre;

short int ret,ls;
inline short int hit(int msk){
	if(z[msk]!=-1)return z[msk];
	ret = 24;
	ls = -1;
	rep(i,0,22)if(msk&(1<<i)){
		if(ret>i-ls)ret = i-ls;
		ls = i;
	}
	if(ret>23-ls)ret = 23-ls;
	return z[msk] = ret;
}

short int f(short int pos,int msk){
	if(pos==12)return hit(msk);
	if(dp[pos][msk]!=-1)return dp[pos][msk];
	if(cnt[pos]!=1)return dp[pos][msk] = f(pos+1,msk);
	return dp[pos][msk] = max(f(pos+1,msk|(1<<pos)),f(pos+1,msk|(1<<(22-pos))));
}

int main(){
//	cout<<fixed<<setprecision(10);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    rep(i,1,n){
    	cin>>x;
    	if(x==0)return cout<<"0\n",0;
    	--x;
    	++cnt[x];
    	if(cnt[x]==2)pre|=(1<<x)|(1<<(22-x));
    	else if(cnt[x]==3)return cout<<"0\n",0;
	}
	memset(dp,-1,sizeof dp);
	memset(z,-1,sizeof z);
	cout<<f(0,pre)<<endl;
	return 0;
}

Measured memory_bytes: 213248
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String lineN = br.readLine();
    int n = Integer.parseInt(lineN);
		int[][] c = new int[4][13];
    for(int i = 0; i < n; i++){
      String[] lineA = br.readLine().split(" ");
      int num = Integer.parseInt(lineA[1]);
      if( lineA[0].equals("S") ) c[0][--num] =1;
      if( lineA[0].equals("H") ) c[1][--num] =1;
      if( lineA[0].equals("C") ) c[2][--num] =1;
      if( lineA[0].equals("D") ) c[3][--num] =1;
    }
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 13; j++){
				if( c[i][j] == 0 ){
					switch(i){
						case 0:
							sb.append("S ");
							break;
						case 1:
							sb.append("H ");
							break;
						case 2:
							sb.append("C ");
							break;
						case 3:
							sb.append("D ");
							break;
					}
					sb.append(j+1).append("\n");
				}
			}
		}
    System.out.print(sb);
	}
}

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

int main() {
  int X;
  cin >> X;
  
  int ten = (X % 100)/10;
  int one = X %10;
  int sum = (ten*10)/5;
  
  if(one > 5) sum += 2;
  else if(one > 0) sum += 1;
  
  if(sum*100 <= X) cout << 1 << endl;
  else cout << 0 << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
using namespace std;
/*
3
05:47:15 09:54:40
12:12:59 12:13:00
16:30:20 21:18:53
6
00:00:00 03:00:00
01:00:00 03:00:00
02:00:00 03:00:00
03:00:00 04:00:00
03:00:00 05:00:00
03:00:00 06:00:00
0
 */
int strtotime(string str){
	int hour = stoi(str.substr(0,2));
	int minute = stoi(str.substr(3,2));
	int second = stoi(str.substr(6,2));
	return(hour*3600+minute*60+second);
}

int main(int argc, char* argv[]){
	int n;
	vector<vector<string>> strarray;
	vector<int> answers;
	while(1){
		char tmp[100];
		scanf("%s", tmp);
		string str = tmp;
		if(str=="0") break;
		n = stoi(str);
		vector<tuple<int, int>> timearray;
		for(int i=0; i<n;i++){
			scanf("%s", tmp);
			string str1 = tmp;
			int start=strtotime(str1);
			scanf("%s", tmp);
			string str2 = tmp;
			int end=strtotime(str2);
			tuple<int, int> times = make_tuple(start, end);
			timearray.push_back(times);
		}
		sort(timearray.begin(), timearray.end());
		for(int i=0; i<n; i++){
//			printf("%d %d\n", get<0>(timearray[i]), get<1>(timearray[i]));
		}
		vector<int> train;
		train.push_back(0);
		int answer=1;
		for(int i=1; i<n; i++){
			bool flag=true;
			for(int j=0; j<(int)train.size(); j++){
				if(get<0>(timearray[i])>=get<1>(timearray[train[j]])){
//					printf("%d %d\n", get<0>(timearray[i]), get<1>(timearray[train[j]]));
					train[j] = i;
					flag=false;
					break;
				}
			}
			if(flag){
				train.push_back(i);
				for(int j=0; j<(int)train.size(); j++){
//				printf("input %d-%d %d\n", i,j, train[j]);
				}
				answer++;
			}
		}
		//			answers.push_back(timearray[0][0]);
		answers.push_back(answer);
		//		}
	}
	for(int i=0; i<(int)answers.size(); i++){
		printf("%d\n", answers[i]);
	}


	return 0;
}

/*
17
06:29:57 16:50:58
10:09:29 13:15:10
00:44:54 17:56:18
22:41:06 22:49:38
15:38:18 20:34:49
05:29:50 07:49:22
10:05:07 19:16:07
16:24:46 22:55:23
15:59:49 21:50:02
03:03:25 04:43:01
16:59:19 21:40:48
22:10:01 22:42:14
16:52:37 21:53:40
09:36:38 10:10:44
12:47:47 14:09:22
09:41:52 19:41:01
02:09:53 09:56:06
0
 */






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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, k; cin >> n >> k; 
    vector<int> h(n, 0), ans(n, INT_MAX);
    for(int i = 0; i < n ; i++) 
        cin >> h[i];
    ans[0] = 0;
    for(int i = 1; i < n; i++) {
        for(int j = 1; j <= k; j++) {
            if(i >= j) {
                ans[i] = min(ans[i-j] + abs(h[i] - h[i-j]), ans[i]);
            }   
        }
    }
    cout << ans[n-1] << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	set<int> S;
	int q;
	cin >> q;
	while( q-- > 0 ) {
		int a, b;
		cin >> a >> b;
		if( a == 0 ) {
			S.insert( b );
			cout << S.size() << '\n';
		}
		else if( a == 1 ) {
			cout << (S.find( b ) != S.end()) << '\n';
		}
	}

	return 0;
}



Measured memory_bytes: 12492
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a),end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while( scanf("%d", &n), n ){
        int ans = 0, sum = 1, start = 1, end = 2;
        while(start <= n / 2){
            if(sum >= n){
                if(sum == n) ans++;
                sum-=start;
                start++;
            }else if(sum < n){
                sum+= end;
                end++;
            }
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++) cin >> W[i];
    int ans = 1e9;
    for(int i = 0; i < N; i++){
        int temp1 = 0, temp2 = 0;
        for(int j = 0; j < N; j++){
            if(j <= i) temp1 += W[j];
            else temp2 += W[j];
        }
        ans = min(ans, abs(temp1 - temp2)) ;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
n = int(input())
s = input()

abc = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

l = []
ans = []
for i in range(len(s)):
    l.append(s[i])
    index_s = abc.index(s[i])
    index_n = (n + index_s) % 26
    ans.append(abc[index_n])
    
print(''.join(ans))

Measured memory_bytes: 3316
S = str(input())
year = int(S[0] + S[1])
month = int(S[2] + S[3])
if year <= 12 and year >= 1 and month >= 1 and month <= 12:
    print('AMBIGUOUS')
elif year >= 0 and year <= 99 and month >= 1 and month <= 12:
    print('YYMM')
elif year >= 1 and year <= 12 and month >= 0 and month <= 99:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 9136
#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] = {0};
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	ll flag = 0;
	sort(arr,arr+n);
	ll ans = 0;
	for(ll i=0;i<n;i++){
		ans = ans^arr[i];

		// if(i==0){
		// 	// cout<< (arr[i+1]^arr[n-1] )<<endl;
		// 	if((arr[i+1]^arr[n-1]) != arr[i]){
		// 		flag = 1;
		// 		cout<<"No"<<endl; 
		// 		break;
		// 	} 
		// }
		// else if(i==n-1){
		// 	if((arr[i-1]^arr[0]) != arr[i]){
		// 		flag = 1; 
		// 		cout<<"No"<<endl;
		// 		break;
		// 	}
		// }
		// else{
		// 	if((arr[i-1]^arr[i+1]) != arr[i]){
		// 		flag = 1;
		// 		cout<<"No"<<endl;
		// 		break;
		// 	} 
		// }
	}
	if(ans==0){
		cout<<"Yes"<<endl;
	} 
	else{
		cout<<"No"<<endl;
	}
    return 0;
}


Measured memory_bytes: 1024