akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b, c;
  cin >> a >> b >> c;
  if (a == b) cout << c << endl;
  else if (a == c) cout << b << endl;
  else cout << a << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b, c = [], []
s = [0] * (10 ** 5 + 2)
for i in a:
    if i == 0:
        s[i + 1] += 1
        s[i] += 1
    else:
        s[i + 1] += 1
        s[i] += 1
        s[i - 1] += 1
print(max(s))


Measured memory_bytes: 13964
#include<iostream>
#include <complex>
#include <vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<list>
#include <iterator>
#include <utility>
#include <numeric>
using namespace std;

#define intt long long


int main() {
	string S;
	cin >> S;

	if (S.length() == 2) {
		cout << S << endl;
	}
	else if (S.length() == 3) {
		cout << S[2] << S[1] << S[0] << endl;
	}

	return 0;




}

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

int main() {
	uint64_t i,j,k,c=0,n,x,y,w=0;
	cin>>x>>y;
	c=x%y;
	if(c==0)
		cout<<"-1";
	else
	{
		for(i=2;i<=100000000;i++)
		{
			w=x*i;
			if(w%y!=0)
			{
				cout<<w;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    string S;
    cin >> S;

    int ans = 0;
    int g_p = 0;
    rep(i, S.size()) {
        if (S[i] == 'p') ans--;

        if (g_p) {
            ans++;
            g_p--;
        }
        else {
            g_p++;
        }
    }
    write(ans);
}

Measured memory_bytes: 512
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

S = str(input())

print(S[:3])

Measured memory_bytes: 65472
N,M = list(map(int,input().split()))
PY = []
for i in range(M):
    PY.append(list(map(int,input().split())) + [i])

PY.sort(key=lambda x:x[1],reverse=False)

KEN = [0]*N
SHIs = []

for i in range(M):
    P = PY[i][0]
    ind = PY[i][2]
    KEN[P-1] += 1
    X = KEN[P-1]
    S = str(P).zfill(6) + str(X).zfill(6)
    SHIs.append([S,ind])

SHIs.sort(key=lambda x:x[1],reverse=False)
for s in SHIs:
    print(s[0])

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int T = Integer.parseInt(sc.next());

        int times = (2 * T + 1) / (2 * A);
        int num = B * times;
        out.printf("%d\n", num);
        out.flush();
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#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 print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long ll;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}


int main() {
	int n; cin >> n;
	cout << n*(n+1)/2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int64 A,B,C;
void Solve() {
	read(A);read(B);read(C);
	out(B + min(C,A + B + 1));enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int crossing[101] = {0};
	int start, end, num_odd, i;

	while (scanf("%d %d ", &start, &end) != EOF) {
		if (start || end) {
			crossing[start]++;
			crossing[end]++;
		} else {
			for (num_odd = 0, i = 1; crossing[i]; i++) {
				num_odd += crossing[i] % 2;
			}
			if (num_odd == 2 && crossing[1] % 2 && crossing[2] % 2) {
				puts("OK");
			} else {
				puts("NG");
			}
			for (i = 0; i < 101; i++) {
				crossing[i] = 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 588
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
ll cnt[100001];
int main(){
  int N;
  ll K;
  cin >> N >> K;
  REP(i,N){
    ll a,b;
    cin >> a >> b;
    cnt[a] += b;
  }
  REPS(i,100000) cnt[i] += cnt[i-1];
  REPS(i,100000){
    if(cnt[i] >= K){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <queue>
#include <iomanip>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

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

int main()
{
  int N; cin >> N;
  int sum = 0;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }

  int ans, mindist = INF;
  REP(i, N) {
    if (mindist > abs(sum - N*A[i])) {
      mindist = abs(sum - N*A[i]);
      ans = i;
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


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

    if(b - a <= 2 || k < a){
        cout << k << endl;
        return 0;
    }else{
        ll ans = a;
        k -= a;
        ans += (k / 2) * (b - a);
        ans += (k % 2);
        cout << ans << endl;
    }


    return 0;
}


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

int main () {
  int R;
  cin >> R;
  if(R < 1200) {
    cout << "ABC";
  } else if(R < 2800) {
    cout << "ARC";
  } else {
    cout << "AGC";
  }
  cout << endl;
  return 0;
}


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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int east_sum[300001] = {};
    for(int i = 0; i < S.length(); i++){
        east_sum[i+1] = east_sum[i];
        if(S[i] == 'E'){
            east_sum[i+1]++;
        }
    }
    int minimum = 1000000, minimum_idx = 0;
    for(int i = 0; i < S.length(); i++){
        int costl = i - east_sum[i];
        int costr = east_sum[N] - east_sum[i+1];
        if(costl + costr < minimum){
            minimum = costl + costr;
        }
    }
    cout << minimum << endl;
}


Measured memory_bytes: 1796
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.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;}


const long long INF = 1LL << 60;
long long c[30][10010];
long long dp[30][10010];


//bucket1
// bool ch[10] = {0};
// bool check(int n){
//     while(n!=0){
//         if(ch[n%10]) return false;
//         n /= 10;
//     }
//     return true;
// }



// --------write my code!!!!!----------//



int main(){
    bool flag = true;
    string s; cin >> s;
    int count[26]; for(int i=0; i<26; ++i) count[i]=0;
    for(int i=0; i<s.length(); ++i){
        count[s[i]-95]++;
    }
    
    for(int j=0; j<26; j++){
        if(count[j]%2!=0) flag = false;
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize
    }
    let mut v = vec![0usize, 2, 1];
    for i in 0..n - 1 {
        v.push(v[i + 1] + v[i + 2]);
    }

    println!("{}", v[n + 1]);
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    rep(i, N - 1) A[i + 1] += A[i];

    ll total = A[N - 1];
    ll ans = 1e18;
    For(i, 0, N - 1) {
        ans = min(ans, abs(A[i] - (total - A[i])));
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1792
name = ['A', 'B', 'C', 'D', 'E']
shop = []
  
while True:
    a,b = map(int, input().split())
    if a == 0 and b == 0:
        break
    shop.append(a+b)
    if len(shop) == 5:
        m = max(shop)
        print(name[shop.index(m)], m)
        shop = [] 


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

int main()
{
	int k;

	cin >> k;
	if (k % 2 == 0) cout << (k / 2 )*k / 2 << endl;
	else cout << (k / 2)*(k/2+1) << endl;

		return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

double N;

int main() {
    cin >> N;

    int ans = ceil(N / 1.08);

    if(floor((double)ans*1.08)==N)
    cout << ans << endl;
    else
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
    long long int attack = 0, H;
    cin >> H;
    long long int sum = 1;
    while(H > 0){
        attack += sum;
        sum *= 2;
        H /= 2;
    }
    cout << attack << '\n';
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[200005];
int main(void) {
    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum ^= a[i];
    }
    for (int i = 0; i < n; i++) {
        a[i] ^= sum;
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << endl;
    }
    return 0;
}




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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    sort(all(v),greater<int>());
    int sum=0;
    for(int i=0;i<k;i++)
        sum+=v[i];
    cout<<sum<<endl;

    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>

/*----------------------------------------------------------------*/

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using str = std::string;
using vstr = std::vector<str>;

/*----------------------------------------------------------------*/

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }
template<typename T> T rpow(T a, ll n) {
    if (n == 0) return 1;
    T k = 1;
    for (; n > 1; n >>= 1) {
        if (n & 1) k *= a;
        a *= a;
    }
    return k * a;
}

/*----------------------------------------------------------------*/

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

/*----------------------------------------------------------------*/

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; rpow(i, 2) <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*----------------------------------------------------------------*/

struct edge {
    ll to, cost;

    edge(ll t, ll d) {
        to = t, cost = d;
    }
};
void solve();

/*----------------------------------------------------------------*/

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

    solve();
}

void solve() {
    ll v, e, r;
    std::cin >> v >> e >> r;

    std::vector<std::vector<edge>> g(v);
    for (ll i = 0; i < e; i++) {
        ll s, t, d;
        std::cin >> s >> t >> d;
        g[s].push_back(edge(t, d));
    }

    vll dist(v, 1e12);

    auto dijkstra = [&](ll s) {
        dist[s] = 0;
        std::priority_queue<std::pair<ll, ll>,
                            std::vector<std::pair<ll, ll>>,
                            std::greater<std::pair<ll, ll>>> que;
        que.push({ 0, s });

        while (!que.empty()) {
            std::pair<ll, ll> p = que.top();
            que.pop();
            ll cur_v = p.second;
            if (dist[cur_v] < p.first) continue;
            for (edge i : g[cur_v])
                if (chmin(dist[cur_v] + i.cost, dist[i.to]))
                    que.push({ dist[i.to], i.to });
        }
    };

    dijkstra(r);

    for (ll i : dist)
        if (i < 1e12) std::cout << i << '\n';
        else std::cout << "INF" << '\n';
}



Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
////////////////////////////////////////////////
int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    long long ans = 0;
    for (int i = 0; i < n - 1; i++)
        for (int j = i + 1; j < n; j++)
            ans += d[i] * d[j];
    cout << ans << endl;
}

Measured memory_bytes: 3588
n=int(input())

ch=0
l=0

for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    l+=1
  else:
    l=0
  if l>=3:
    ch+=1
    

if ch>0:

  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int w[], v[];
		int c;
		int dp[][];
		int caseNumber;

		c = sc.nextInt();
		caseNumber = 1;
		while (c != 0) {
			n = sc.nextInt();
			w = new int[n];
			v = new int[n];
			dp = new int[n][c + 1];
			for (int i = 0; i < n; i++) {
				String s[] = sc.next().split(",");
				v[i] = Integer.valueOf(s[0]);
				w[i] = Integer.valueOf(s[1]);
			}
			for (int i = 0; i < c + 1; i++) {
				if (i < w[0]) {
					dp[0][i] = 0;
				} else {
					dp[0][i] = v[0];
				}
			}
			for (int i = 1; i < n; i++) {
				for (int j = 0; j < c + 1; j++) {
					if (j < w[i]) {
						dp[i][j] = dp[i - 1][j];
					} else if (j == w[i]) {
						if (dp[i - 1][j] < v[i]) {
							dp[i][j] = v[i];
						} else {
							dp[i][j] = dp[i - 1][j];
						}
					} else {
						if (dp[i - 1][j] < v[i] + dp[i - 1][j - w[i]]) {
							dp[i][j] = v[i] + dp[i - 1][j - w[i]];
						} else {
							dp[i][j] = dp[i - 1][j];
						}
					}
				}
			}
			System.out.println("Case " + caseNumber + ":");
			for (int i = c; 0 < i; i--) {
				if (dp[n - 1][i] != dp[n - 1][i - 1]) {
					System.out.println(dp[n - 1][c]);
					System.out.println(i);
					break;
				}
			}
			c = sc.nextInt();
			caseNumber++;
		}
	}
}

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

int main() {
  
  int N, x;
  
  std::cin >> N >> x;
  
  int a[N];
  
  for (int i = 0; i < N; i++) {
    std::cin >> a[i];
  }
  
  sort(a, a + N);
  
  int ans = 0;
  int now = 0;
  
  for (int i = 0; i < N; i++) {
    if (now + a[i] == x) {
      ans++;
      break;
    }
    now += a[i];
    if (now > x || i == N - 1) {
      break;
    }
    ans++;
  }
  
  std::cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
// 前回TLEなったらしいけどどこにそうなる要素があるんだこれ？
// 最初ので半分構築して次ので矛盾しなければlcmじゃねぇの
// -> 見事TLEなりました爆

package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	var S, T string
	fmt.Scan(&S, &T)
	SS, TT := make([]string, N), make([]string, M)
	for i, c := range S {
		SS[i] = string(c)
	}
	for i, c := range T {
		TT[i] = string(c)
	}
	L := lcm(N, M)
	ans := make(map[int]string)
	for i := 0; i < N; i++ {
		idx := i * (L / N)
		ans[idx] = SS[i]
	}
	for i := 0; i < M; i++ {
		idx := i * (L / M)
		if ans[idx] != "" && ans[idx] != TT[i] {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(L)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func gcd(a, b int) int {
	if a > b {
		a, b = b, a
	}
	for a > 0 {
		a, b = b%a, a
	}
	return b
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld ;
#define pb push_back
#define fi first
#define se second
const int N = 3e6+5;
ll a[N];
ll b[N];
void solve(){
    string s;
    cin>>s;
    int n  = s.size();
    ll ans  = 0;
    ll trt = 0;
    a[0] = 1;
    ll p10 = 1;
    for(int i=n-1;i>=0;i--){
        ll c = s[i]-'0';
        ll x = p10*c;
        p10*=10;
        p10%=2019;
        trt+=x;
        trt%=2019;
        ans+=a[trt];
        a[trt]++;
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    preprocess();
    int t =1;
 //   cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3808
import numpy as np
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

hw = []

for i, ai in enumerate(a):
    for j in range(ai):
        hw.append(i+1)
        
hw = np.asarray(hw)
HW = np.reshape(hw, (H, W))

for i in range(H):
#     print(*HW[i])
    if i % 2 == 1:
        print(*HW[i][::-1])
    else:
        print(*HW[i])

Measured memory_bytes: 21648
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
	int left = 0, right = n, mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid])return 1;
		if (key > A[mid])left = mid + 1;
		else if (key < A[mid])right = mid;
	}
	return 0;
}

int main() {
	int i, q, k, sum = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &k);
		if (binarySearch(k))sum++;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 984
n,k=map(int,input().split())
s=list(input())
ct=0
for i in range(n-1):
  if s[i]=='R' and s[i+1]=='L':
    ct+=1
if s[0]==s[n-1]:
  x=ct
  ct-=min(ct,k)
  ct*=2
  ct+=1
  print(n-ct)
else:
  x=ct
  ct-=min(ct,k)
  ct*=2
  if x<k:
    ct+=1
  else:
    if s[0]=='L':
      ct+=2
  print(n-ct)

Measured memory_bytes: 4084
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

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

	if ((n + 1) / 2 >= k) {
		puts("YES");
	}
	else {
		puts("NO");
	}

}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
using namespace std;

int main() {
    int a , b , c;
    scanf("%d%d%d" , &a , &b , &c);
    if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {
        printf("0\n");
    }
    else {
        if(a == b && b == c) {
            printf("-1\n");
        }
        else {
            int count = 0;
            while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
                int x = a / 2 , y = b / 2 , z = c / 2;
                count++;
                //cout << x << ' ' << y << ' ' << z << endl;
                a = (y + z);
                b = (x + z);
                c = (x + y);
                //cout << a << ' ' << b << ' ' << c << endl;
            }
            printf("%d\n" , count);
        }
    }
    return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


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

    int nt = 0;
    int nx = 0,ny = 0;
    REP(i,N) {
        int t,x,y;
        cin >> t >> x >> y;

        int dt,dx,dy;
        dt = t - nt;
        dx = x - nx;
        dy = y - ny;

        if ( dt < (dx + dy)) {
            cout << "No" << endl;
            return 0;
        }

        int left = abs(dt - ( dx + dy ));
        if ( (left%2) == 0) continue;
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define MIN(a, b)		((a) < (b) ? a : b)
#define MAX(a, b)		((a) > (b) ? a : b)
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)		(!IsOdd((x)))					/* 偶数 */
#define ArrayLength(x)	(sizeof(x) / sizeof(x[0]))
#define DWORD_MAX		(0xFFFFFFFF)

typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;
typedef pair<int, int> P;

#define N_MAX	(1000)
#define M_MAX	(1000)
#define H_MAX	(1000)
#define W_MAX	(1000)

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int H, W;
bool A[H_MAX][W_MAX];

// 操作対象かどうか
bool isOperateTarget(int i, int j)
{
	// 白は除く
	if (!A[i][j]) {
		return false;
	}

	// 黒でかつ4辺にシロアリ
	if ((0 < i && !A[i - 1][j]) ||
		(i < H && !A[i + 1][j]) ||
		(0 < j && !A[i][j - 1]) ||
		(j < W && !A[i][j + 1])) {
		return true;
	} else {
		return false;
	}
}

// キュークリア
void queClear(queue<P> &p)
{
	queue<P> empty;
	swap(p, empty);
}

// メイン
int main()
{
	int totalBlockCnt = 0;
	queue<P> queNext;
	queue<P> quePrev;

	// 黒はtrue
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			char ch;
			cin >> ch;
			if (ch == '#') {
				A[i][j] = true;
				totalBlockCnt++;
			}
		}
	}

	// 操作対象のみpush
	REP(i, H) {
		REP(j, W) {
			if (isOperateTarget(i, j)) {
				quePrev.push(P(i, j));
			}
		}
	}

	// 捜査対象を順番に操作
	int ret = 0;
	while (totalBlockCnt != (H * W)) {
		while (0 < quePrev.size()) {
			P p = quePrev.front(); quePrev.pop();
			int i = p.first;
			int j = p.second;
			if (0 < i && !A[i - 1][j]) {
				A[i - 1][j] = true;
				totalBlockCnt++;
				if (isOperateTarget(i - 1, j)) {
					queNext.push(P(i - 1, j));
				}
			}
			if ((i + 1) < H && !A[i + 1][j]) {
				A[i + 1][j] = true;
				totalBlockCnt++;
				if (isOperateTarget(i + 1, j)) {
					queNext.push(P(i + 1, j));
				}
			}
			if (0 < j && !A[i][j - 1]) {
				A[i][j - 1] = true;
				totalBlockCnt++;
				if (isOperateTarget(i, j - 1)) {
					queNext.push(P(i, j - 1));
				}
			}
			if ((j + 1) < W && !A[i][j + 1]) {
				A[i][j + 1] = true;
				totalBlockCnt++;
				if (isOperateTarget(i, j + 1)) {
					queNext.push(P(i, j + 1));
				}
			}
		}
		quePrev = queNext;
		queClear(queNext);
		ret++;
	}

	cout << ret;
	cout << endl;
}


Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	ll n,m; cin >> n >> m;
	vector<ll> s(n),t(m);
	rep(i,n) cin >> s[i];
	rep(j,m) cin >> t[j];
	vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
	vector<vector<ll>> sum(n+1,vector<ll>(m+1,0));
	dp[0][0]=1;
	rep(i,n+1) sum[i][0]=1;
	rep(j,m+1) sum[0][j]=1;
	rep2(i,1,n+1)rep2(j,1,m+1){
		if(s[i-1]==t[j-1]) dp[i][j] = sum[i-1][j-1];
		else dp[i][j]=0;
		sum[i][j] += sum[i-1][j]; sum[i][j] %= MOD;
		sum[i][j] += sum[i][j-1]; sum[i][j] %= MOD;
		sum[i][j] -= sum[i-1][j-1]; if(sum[i][j]<0)sum[i][j] += MOD;
		sum[i][j] += dp[i][j];sum[i][j] %= MOD;
	}
/* 	rep(i,n+1){
		rep(j,m+1) cout << dp[i][j] << " ";
		cout << endl;
	} */
	out(sum[n][m]);
}




Measured memory_bytes: 62976
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>
 
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;
 
typedef long long LL;
typedef double db;
 
const int N = 1e+5+5;
 
int n,q,k;
LL sta[N];
LL ad[N],cnt[N];
 
int main(){
	scanf("%d%d",&n,&q);
	sta[k=1]=n;
	fo(i,1,q){
		LL x;
		scanf("%lld",&x);
		while(k&&sta[k]>=x)k--;
		sta[++k]=x;
	}
	ad[k]=1;
	fd(i,k,1){
		LL x=sta[i];
		for(;x>sta[1];){
			int l=1,r=k,w=0;
			while(l<=r){
			int mid=(l+r)/2;
				if (sta[mid]<x)l=mid+1,w=mid;
				else r=mid-1;
			}
			ad[w]=ad[w]+ad[i]*(x/sta[w]);
			x%=sta[w];
		}
		cnt[x]=cnt[x]+ad[i];
	}
	fd(i,n,1)cnt[i]=cnt[i]+cnt[i+1];
	fo(i,1,n)printf("%lld\n",cnt[i]);
	return 0;
}

Measured memory_bytes: 4096
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a < in.txt > out.txt
*/

//  io
#include <iostream>
//#include <fineam> //http://www.cplusplus.com/reference/fineam/fineam/
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
#include <limits>
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//file input routed to stdinout
/*
std::ifineam inFile("input.txt");
std::ofineam outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

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

    string S, T;
    cin >> S >> T;

    int cnt = 0;
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
        {
            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  char string1[3];
  char string2[3];
  char string3[3];
  scanf("%s",string1);
  scanf("%s",string2);
  scanf("%s",string3);
  printf("%c%c%c\n",string1[0],string2[1],string3[2]);

  return 0;
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int cnt = 0;
            
            for(int i = 1; i < n-1; i++)
            {
                if (p[i - 1] < p[i] && p[i] < p[i + 1]) cnt++;
                //Console.WriteLine(p[i - 1] + " " + p[i] + " " + p[i + 1] + " " + cnt);
                if (p[i - 1] > p[i] && p[i] > p[i + 1]) cnt++;
                   
            }
            Console.WriteLine(cnt);

        }

       


           



        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }

        
       
    }
}


Measured memory_bytes: 13396
R(n,r){
	int p,c,t;
	if(r){
		scanf("%d%d",&p,&c);
		t=R(n,r-1);
		if(t>n-c)
			t-=p-1;
		else if(t>n-c-(p-1))
			t+=c;
		return t;
	}else{
		return n;
	}
}
main(){
	int n,r;
	for(;scanf("%d%d",&n,&r),n;){
		printf("%d\n",R(n,r));
	}
	exit(0);
}

Measured memory_bytes: 0
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
p, q = 0, 0

s = list(range(1, N+1))
for i in range(N):
    p += s.index(P[i]) * math.factorial(N-i-1)
    s.remove(P[i])

s = list(range(1, N+1))
for i in range(N):
    q += s.index(Q[i]) * math.factorial(N-i-1)
    s.remove(Q[i])

print(abs(p-q))

Measured memory_bytes: 3064
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{

static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
static final long LINF=Long.MAX_VALUE/2;
static int N;
static long[] sum;

public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
N=ir.nextInt();
int[] s=ir.toIntArray(N);
sum=new long[2*N+1];
sum[0]=0;
for(int i=1;i<=2*N;i++) sum[i]=sum[i-1]+(long)s[(i-1)%N];
long ans=0;
int l=0;
int m=1;
int r=2;
while(true){
if(r>=N) break;
long a=sum[l+N]-sum[r];
long b=sum[r]-sum[m];
long c=sum[m]-sum[l];
long res;
if(a<=b&&a<=c){
res=a;
if(m>l+1) l++;
else {
m++; l++;
}
}
else if(b<=a&&b<=c){
res=b;
r++;
}
else{
res=c;
if(r>m+1) m++;
else{
r++; m++;
}
}
ans=Math.max(ans,res);
}
out.println(ans);
out.flush();
}

static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;

public InputReader(InputStream in) {this.in=in;}
  
public int readByte() {
if(lenbuf==-1) throw new InputMismatchException();
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}
catch (IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0)
return -1;
}
return buffer[curbuf++];
}

public boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;}

public String next() {
int b=skip();
StringBuilder sb=new StringBuilder();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
 
public int nextInt() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

public long nextLong() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

public int[] toIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
}
}

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

int main(){
    //入力
    int W,a,b;
    cin >> W >> a >> b;

    //計算
    int ans;
    if(abs(b-a)<=W){
        ans=0;
    }else{
        ans=min(abs(b-a-W),abs(a-b-W));
    }

    //出力
    cout << ans <<endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    for(int i=1; i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                int sum = i*10001+j*1010+k*100;
                if(a<=sum && sum<=b) ans++;
            }
        }
    }
    cout << ans <<endl;
    
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int main()
{
  int N, K;
  N = in(), K = in();
  map<int, int> b2b;
  vector<vector<int>> boats(K);
  for (int i = 0; i < K; i++){
    inpt(boats[i], in(), in);
    for (int bunny : boats[i]) b2b[bunny] = i;
  }
  set<int> bbunny;
  for (int R = in(); R--;){
    int p, q;
    p = in(), q = in();
    if (b2b[p] == b2b[q]){
      bbunny.insert(p);
      bbunny.insert(q);
    }
  }
  cout << bbunny.size() << endl;
  return 0;
}

Measured memory_bytes: 1208
n = int(input())
a = [int(x) for x in input().split()]

a4 = 0
aodd = 0

for i in range(n):
    if a[i] % 4 == 0:
        a4 += 1
    elif a[i] % 2 == 1:
        aodd += 1

x = 0

if a4 >= n // 2:
    x += 1
elif aodd <= a4:
    x += 1

print('Yes' if x == 1 else 'No')


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

long long a[200000];
long long c[200000 + 1];
long long sum[200000 + 1];

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		c[a[i]]++;
	}
	long long s = 0;
	for (int i = 1; i <= N; i++) {
		sum[i] = c[i] * (c[i] - 1) / 2;
		s += sum[i];
	}
	
	for (int k = 0; k < N; k++) {
		cout << s + (sum[a[k]] * (c[a[k]] - 2) / c[a[k]]) - sum[a[k]] << endl;
	}
	return 0;
}

Measured memory_bytes: 6912
import sys
input = sys.stdin.readline
n, q = map(int, input().split())

size = 2**((n-1).bit_length())
tree = [None]*(size*2)
INF = (-1, 2**31-1)

def _find(i):
    ind = size+i
    s = INF
    while ind:
        if tree[ind]:
            s = max(s, tree[ind])
        ind = ind//2
    return s
def find(i):
    return _find(i)[1]

def update(s, t, v):
    L = s+size;R = t+size
    while L<R:
        if R&1:
            R-=1
            tree[R]=v
        if L&1:
            tree[L]=v
            L+=1
        L>>=1;R>>=1

ans = []
for i in range(q):
    a, *b = map(int, input().split())
    if a:ans.append(find(b[0]))
    else:update(b[0],b[1]+1,(i,b[2]))
print('\n'.join(map(str,ans)))


Measured memory_bytes: 16056
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, q, a;
  scanf("%lld%lld%lld", &n, &k, &q);
  ll ans[n];
  for(i = 0; i < n; ++i) ans[i] = k - q;
  for(i = 0; i < q; ++i) scanf("%lld", &a), ans[--a]++;
  for(i = 0; i < n; ++i) printf("%s\n", ans[i] > 0 ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>

using namespace std;

int main() {
	char str;
	cin >> str;
	switch (str) {
	case 'A':
		cout << "T" << endl;
		break;
	case 'T':
		cout << "A" << endl;
		break;
	case 'G':
		cout << "C" << endl;
		break;
	case 'C':
		cout << "G" << endl;
		break;
	}

}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
def worstdata():
    a=0
    return a
#solution:
def comp(x,y):
    dp=[0,max(act[0])]*(N+1) #[i]日目のActivity で得られる最大幸福量
    
    return 0

#input
S,T=pin(str)
A,B=pin()
U=input()
if U==S:
    A-=1
else:
    B-=1
print(A,B)
#print(solution(H,N))
#print(["No","Yes"][cond])



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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------


signed main(){
    SCIN(s);
    int ans=0,N=s.size();
    rep(i,N/2){
        if(s[i]!=s[N-1-i])ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        int length = s.length();
        char[] data = s.toCharArray();
        String answer = new StringBuilder().append(data[0]).append(length - 2).append(data[length-1]).toString();
        System.out.println(answer);
    }
}


Measured memory_bytes: 21972