akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <ctime>
#include <cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

#define sz(x) (int)(x.size())

typedef long long ll;
typedef tuple<int, int, int> tri;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef __gnu_pbds::tree<
    int,
    __gnu_pbds::null_type,
    less<int>,
    __gnu_pbds::rb_tree_tag,
    __gnu_pbds::tree_order_statistics_node_update>
    ordered_set;

const ll MODULO = 1000000007;

void ftime()
{
#ifndef ONLINE_JUDGE
    cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
#endif
}

static int speed_increase = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    return 0;
}();

void solve()
{
    string s;
    cin>>s;
    int n = s.size();
    int mx = 0, curr;
    for(int i=0; i<n; ++i) {
        if(s[i] == 'S') continue;
        curr = 0;
        while(i < n && s[i] == 'R') {
            ++i, ++curr;
        }
        mx = max(curr, mx);
    }
    cout<<mx;
}

int main()
{
    solve();
    // ftime();
    return 0;
}

Measured memory_bytes: 3652
import math
a, b = map(int, input().split())
n = abs((b - a) / 2)
k = abs((b - a) // 2)
if n != k:
    m = "IMPOSSIBLE"
elif b > a:
    m = abs(int(b - n))
else:
    m = abs(int(n - a))
print(m)

Measured memory_bytes: 3060
import java.util.*;

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

        int ans = 0;
        int n, m;
        n = sc.nextInt();
        m = sc.nextInt();
        
        UnionFind uf = new UnionFind(n + 1);
        int[] p = new int[n + 1];
        int x, y;

        for (int i = 1; i <= n; i++) {
            p[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            x = sc.nextInt();
            y = sc.nextInt();

            uf.unite(p[x], p[y]);
        }

        for (int i = 1; i <= n; i++) {
            if (uf.same(i, p[i])) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}

class UnionFind {
    private int[] tree;

    public UnionFind(int size) {
        tree = new int[size];

        for (int i = 0; i < size; i++) {
            tree[i] = -1;
        }
    }

    public void unite(int x, int y) {
        x = root(x);
        y = root(y);

        if (x == y) {
            return;
        }
        else {
            tree[x] += tree[y];
            tree[y] = x;

            return;
        }
    }

    public int root(int node) {
        if (tree[node] < 0) {
            return node;
        }
        else {
            return tree[node] = root(tree[node]);
        }
    }

    public boolean same(int x, int y) {
        return root(x) == root(y);
    }

    public int size(int node) {
        return -1 * root(node);
    }
}


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

int n, m;
vector<int> G[5050];

bool f[5050];
vector<int> v;

void dfs(int x)
{
  for (int i = 0; i < G[x].size(); i++){
    if (f[G[x][i]]) continue;
    dfs(G[x][i]);
  }
  f[x] = true;
  v.push_back(x);
}

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

  for (int i = 1; i <= n; i++){
    if (f[i]) continue;
    dfs(i);
  }

  for (int i = 0; i < v.size(); i++){
    cout << v[i] << endl;
  }

  bool ans = false;
  for (int i = 1; i < n; i++){
    bool c = true;
    for (int j = 0; j < G[v[i]].size(); j++){
      if (G[v[i]][j] == v[i - 1]) c = false;
    }
    ans |= c;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll N, T, A;
    cin >> N >> T >> A;

    double diff = numeric_limits<double>::max();
    ll index    = 0;
    REP(i, N) {
        ll t;
        cin >> t;
        auto temperature = T - 0.006 * t;

        auto d = abs(A - temperature);
        if (diff > d) {
            diff  = d;
            index = i;
        }
    }

    cout << index + 1 << endl;
    return 0;
}

Measured memory_bytes: 3640
import heapq


N, M = map(int, input().split())
A = list(map(int, input().split()))
A_inv = [-a for a in A]
heapq.heapify(A_inv)
for _ in range(M):
    max_inv = heapq.heappop(A_inv)
    heapq.heappush(A_inv, -(-max_inv//2))

print(sum([-a for a in A_inv]))


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



int main(){
    long long n;
   cin>>n;
   
   long long ans = 0;
   long long i=1;
   while(i<=n){
       ans+=i;
     i = i<<1; 
   }
   cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
(* O(n log n) *)
let n = read_int () in
let rec sum n = if n <= 0 then 0 else n mod 10 + sum (n / 10) in
let ans = ref max_int in
for a = 1 to n - 1 do
  ans := min !ans @@ sum a + sum (n - a)
done;
Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

char s[200105];
int cur, a[200105], dp[1 << 26];

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

    for (int mask = 1 << 26; --mask; )
        dp[mask] = 1e9;

    cin >> s;
    for (int i = 0; s[i]; ++i) {
        cur ^= (1 << (s[i] - 'a'));
        int mn = 1e9;
        for (int j = 1 << 25; j; j >>= 1)
            mn = min(mn, dp[cur ^ j]);
        dp[cur] = min(dp[cur], mn + 1);
    }

    cout << max(1, dp[cur]) << endl;

    return 0;
}


Measured memory_bytes: 262656
# -*- coding: utf-8 -*-

def main(N,B):
    ans = 0
    for i in range(1,len(B)):
        ans += min(B[i-1], B[i])
    print(ans+B[0]+B[-1])    
    
if __name__ == '__main__':
    N = int(input())
    B = [int(b) for b in input().split()]
    main(N,B)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  int n, k;
  char str[51];
  
  scanf("%d %d", &n, &k);
  scanf("%s", str);
  
  if(str[k-1]=='A'){
  	str[k-1]='a';
  }else if(str[k-1]=='B'){
  	str[k-1]='b';
  }else{
  	str[k-1]='c';
  }
  
  printf("%s\n", str);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

long long dp[105][1000005];

//ミョ(-ω- ?)
int main() {
    ll n,w;
    cin >> n >> w;
    vector<ll> weight(n,0);
    vector<ll> value(n,0);
    ll max_value = 0;
    rep(i,n){
        cin >> weight[i] >> value[i];
        max_value = max(max_value , value[i]);
    }
    rep(i,n*max_value+1)dp[0][i] = (1LL << 60);
    //dp[i][j] = i番目の荷物　価値jまで詰めたときの重さの最小値
    dp[0][0] = 0;
    for(ll i = 0;i < n;i++){
        for(ll j = 0;j <= n*max_value;j++){
            if(j < value[i])dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = min(dp[i][j],dp[i][j - value[i]] + weight[i]);
        }
    }
    ll res = 0;
    rep(i,n * max_value+1){
        if(dp[n][i] <= w)res = i;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 82940
N = int(input())
A = [0] + list(map(int, input().split()))

baisuu = [[] for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        baisuu[j].append(i)


ans = []
lst = [0 for _ in range(N + 1)]
for i in reversed(range(1, N + 1)):

    lst[i] = (lst[i] + A[i]) % 2
    if lst[i] == 1:
        ans.append(i)

    for j in baisuu[i]:
        lst[j] = (lst[j] + lst[i]) % 2

print(len(ans))
if len(ans) != 0:
    print(" ".join([str(i) for i in ans]))


Measured memory_bytes: 66168
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
		    int n = sc.nextInt();
		    int x = sc.nextInt();
		    if (n == 0 && x == 0) {
		        break;
		    }
		    int count = 0;
		    for (int i = 1; i <= n; i++) {
		        for (int t = i + 1; t <= n; t++) {
		            for (int k = t + 1; k <= n; k++) {
		                if (i + t + k == x)
		                count++;
		            }
		        }
		    }
		    
		    
		    System.out.println(count);
		}
		
    }
}


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=1E5+10;
const int P=1E9+7;

template<typename T1,typename T2>
	void Inc(T1 &a,T2 b){a+=b;if(a>=P) a-=P;}

template<typename T1,typename T2>
	void Dec(T1 &a,T2 b){a-=b;if(a<0) a+=P;}

template<typename T1,typename T2>
	T1 Add(T1 a,T2 b){a+=b;return a>=P?a-P:a;}

template<typename T1,typename T2>
	T1 Sub(T1 a,T2 b){a-=b;return a<0?a+P:a;};

int f[MAXN],n,ban[MAXN],m;

int main()
{
	scanf("%d%d",&n,&m);
	f[0]=1;
	for(int i=1,x;i<=m;i++)
		scanf("%d",&x),ban[x]=1;
	for(int i=1;i<=n;i++)
	{
		if(ban[i])
			continue;
		f[i]=Add(f[i-1],i>1?f[i-2]:0);
	}
	printf("%d\n",f[n]);
}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (n, m) = i.read2::<usize, usize>();
    let mut xys = vec![Vec::new(); n];

    for _ in 0..m {
        let (x, y, _z) = i.read3::<usize, usize, usize>();
        let (x, y) = (x - 1, y - 1);
        xys[x].push(y);
        xys[y].push(x);
    }
    writeln!(o, "{}", solve(n, &xys)).unwrap();
}
fn solve(n: usize, xys: &[Vec<usize>]) -> usize {
    let mut vs = vec![false; n];
    let mut q = Vec::new();
    let mut ans = 0;
    for i in 0..n {
        if vs[i] {
            continue;
        }
        q.push(i);
        vs[i] = true;
        while let Some(i0) = q.pop() {
            for &i1 in &xys[i0] {
                if !vs[i1] {
                    vs[i1] = true;
                    q.push(i1);
                }
            }
        }
        ans += 1;
    }
    ans
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 12540
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE -2
#define TRUE -3
#define FALSE -4

int row[N], col[N], dpos[2*N-1], dneg[2*N-1], x[N][N];
//row: x = i
//col: x = j
//dpos: x = i + j
//dneg: x = i - j + (N - 1)

void putQueen(int);
void printBoard(void);


int main() {
  int k, i, j, r, c;

  for ( i=0; i<(2*N-1); i++ ) {
    row[i] = col[i] = dpos[i] = dneg[i] = FREE;
    for ( j=0; j<N; j++ ) x[i][j] = FALSE;
  }

  scanf( "%d" , &k );
  for ( i=0; i<k; i++ ) {
    scanf( "%d %d" , &r , &c );
    x[r][c] = TRUE;
  }

  putQueen(0);

  return 0;
}


void putQueen(int i) {
  int j;

  if ( i == N ) {
    printBoard();
    return;
  }

  for ( j=0; j<N; j++ ) {
    if ( (col[j] == NOT_FREE)
	 || (dpos[i+j] == NOT_FREE)
	 || (dneg[i-j+N-1] == NOT_FREE) ) continue;
    // put a queen at (i, j)
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    // try the next row
    putQueen(i+1);
    // remove the queen at (i, j) for backtracking
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

void printBoard(void) {
  int i, j;

  for ( i=0; i<N; i++ )
    for ( j=0; j<N; j++ )
      if((x[i][j] == TRUE) && (row[i] != j)) return;
   
  for ( i=0; i<N; i++ ) {
    for ( j=0; j<N; j++ ) {
      if ( row[i] == j ) printf( "Q" );
      else printf( "." );
    }
    printf( "\n" );
  }
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define INF 1000000001
#define ll long long
using namespace std;



int main()
{
  ll N, M;
  cin >> N >> M;
  vector<ll> X(M);
  for (ll i = 0; i < M; ++i)
  {
    cin >> X.at(i);
  }
  if (M <= N)
  {
    cout << 0 << endl;
    return 0;
  }
  sort(X.begin(), X.end());

  vector<ll> dist;
  ll ans = 0;
  for (ll i = 0; i < M - 1; ++i)
  {
    ll temp = X.at(i + 1) - X.at(i);
    ans += temp;
    dist.push_back(temp);
  }
  sort(dist.begin(), dist.end());
  for (ll i = 0; i < N - 1; ++i)
  {
    ans -= dist.at(dist.size() - 1 - i);
  }
  cout << ans << endl;
}


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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  ll a,b,c;
  cin>>a>>b>>c;
  ll ans = b + min(c,a+b+1);
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main() {
    ll M, N;
    cin >> N >> M;

  	ll ret = 1;
  	for(ll i = 1; i * i <= M; i++)
    {
      if(M % i == 0)
      {
        if((N * i) <= M) ret = max(ret, i);
        if (N <= i) ret = max(ret, M / i);
      }
    }
  	cout << ret << endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long M = 7ll + (long long) 1e9;

int main(){
    long long N, K;
    cin >> N >> K;

    long long ans=0;

    for(long long k=K; k<=N+1; k++){
        ans += ( k*N - (k-1)*k + 1 )%M;
        ans %= M;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
S=input()
N=len(S)
dp=[[0 for i in range(27)] for j in range(N+1)]

if N==1:
  print(0)
  exit()

for i in range(1,N):
  for j in range(N-i+1):
    s=list(set(S[j:j+i]))
    for ss in s:
      #print(ss,ord(ss)-96)
      dp[i][ord(ss)-96]+=1
    for k in range(1,27):
      if dp[i][k]==N-i+1:
        #1
        print(i-1)
        exit()


Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#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;

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();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int x, y;
	cin >> x >> y;

	int z = 0;
	if(abs(x) <= abs(y)){
		z += abs(abs(x) - abs(y));
		if(x != 0 && x / abs(x) < 0) z++;
		if(y != 0 && y / abs(y) < 0) z++;
	}
	else{
		z += abs(abs(x) - abs(y));
		if(x != 0 && x / abs(x) > 0) z++;
		if(y != 0 && y / abs(y) > 0) z++;
	}

	cout << z << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = i+1; j < n; j++)
        {
            for(int k = j+1; k < n; k++)
            {
                if(a[k] < a[i] + a[j] && a[i] != a[j] && a[j] != a[k]) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
N=int(input())
dp = [{} for _ in range(101)]

str = "ACGT"
mod = 10**9+7
for i in range(4):
  for j in range(4):
    for k in range(4):
      last3 = str[i] + str[j] + str[k]
      if last3 == "AGC" or last3 == "ACG" or last3 == "GAC":
        dp[3][last3] = 0
      else:
        dp[3][last3] = 1

for n in range(4,101):
  for last3 in dp[n-1]:
    for c in str:
      new_last3 = last3[1:]+c
      if new_last3 == "AGC" or new_last3 == "ACG" or new_last3 == "GAC":
        dp[n][new_last3] = 0
      else:
        if last3 == "AGC" or last3 == "ACG" or last3 == "GAC":
          if new_last3 not in dp[n]:
            dp[n][new_last3] = 0
        elif last3 == "AAG" or last3 == "AGA" or last3 == "AGG" or last3 == "AGT" or last3 == "ATG" or last3 == "CAG" or last3 == "CGA" or last3 == "GAG" or last3 == "GGA" or last3 == "TAG" or last3 == "TGA":
          if new_last3[2] != "C":
            if new_last3 not in dp[n]:
              dp[n][new_last3] = dp[n-1][last3]
            else:
              dp[n][new_last3] += dp[n-1][last3]
        elif last3 == "AAC" or last3 == "CAC" or last3 == "TAC":
          if new_last3[2] != "G":
            if new_last3 not in dp[n]:
              dp[n][new_last3] = dp[n-1][last3]
            else:
              dp[n][new_last3] += dp[n-1][last3]
        else:
          if new_last3 not in dp[n]:
            dp[n][new_last3] = dp[n-1][last3]
          else:
            dp[n][new_last3] += dp[n-1][last3]

sum = 0
for s in dp[N]:
  sum += dp[N][s]
  sum %= mod

print(sum)


Measured memory_bytes: 3956
n = int(input())
if n < 600:print(8)
elif n < 800:print(7)
elif n < 1000:print(6)
elif n < 1200:print(5)
elif n < 1400:print(4)
elif n < 1600:print(3)
elif n < 1800:print(2)
elif n < 2000:print(1)

Measured memory_bytes: 9172
from itertools import accumulate
from bisect import bisect_left

N, K = [int(i) for i in input().split()]

memo = [0] * 100010
for _ in range(N):
    a, b = [int(i) for i in input().split()]
    memo[a] += b

print(bisect_left(list(accumulate(memo)), K))

Measured memory_bytes: 10544
n,C=[int(i) for i in input().split()]
stc=[[int(i) for i in input().split()] for _ in range(n)]
time=[0]*(2*(10**5+1))
end=[[0]*(10**5+1) for _ in range(C)]   #チャンネル別の終わりの記録

for s,t,c in stc:
    end[c-1][t]+=1

for s,t,c in stc:
    if end[c-1][s]==0:
        time[2*s-1]+=1
    else:
        time[2*s]+=1
    time[2*t]-=1

for i in range(1,2*10**5+2):
    time[i]+=time[i-1]
print(max(time))

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

int N, Y;

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

  for(int i = 0; i <= N; i++) {
    for(int j = 0; j + i <= N; j++) {
      int k = N - i - j;
      if(10000*i + 5000*j + 1000*k == Y) {
        printf("%d %d %d\n", i, j, k);
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  vb v(n, true);
  ll ans = n;
  rep2(i, 1, n) {
    if(v[i - 1] && s[i - 1] == s[i]) {
      ans--;
      v[i + 1] = false;
      i++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

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

bool is_in_edge(int x, int y){
    return x == 0 || y == 0 || x == R || y == C;
}

vector<P> v[4];
vector<int> u;

void put_point(int x, int y, int idx){
    if(y == 0){
        v[0].push_back(P(x, idx));
    }else if(x == R){
        v[1].push_back(P(y, idx));
    }else if(y == C){
        v[2].push_back(P(x, idx));
    }else{
        v[3].push_back(P(y, idx));
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> R >> C >> N;
    for(int i = 0; i < N; i++){
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        if(is_in_edge(x1, y1) && is_in_edge(x2, y2)){
            put_point(x1, y1, i);
            put_point(x2, y2, i);
        }
    }
    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());
    sort(v[2].begin(), v[2].end(), greater<P>());
    sort(v[3].begin(), v[3].end(), greater<P>());
    for(int i = 0; i < 4; i++){
        for(P p : v[i]) {
            u.push_back(p.second);
        }
    }
    if(u.size() == 0){
        cout << "YES" << endl;
        return 0;
    }
    stack<int> st;
    for(int i : u){
        if(st.empty() || st.top() != i){
            st.push(i);
        }else{
            st.pop();
        }
    }
    cout << (st.empty()?"YES":"NO") << endl;
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
//k以上のものの数を数える関数
ll count(ll k, vector<ll> &a){
  ll n=a.size();
  ll ans=0;
  rep(i,n){
    ll res=k-a[i];
    //aのなかでres以上の値が出る最初の要素の順番を得る。
    ans+=a.end()-lower_bound(a.begin(),a.end(),res);
  }
  return ans;
}
int main(){
  ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  sort(a.begin(),a.end());
  ll l=0; ll r=200005;
  while(l+1<r){
    ll now=(l+r)/2;
    if(count(now,a)>=m) l=now;
    else r=now;
  }
  //l:l以上の幸福度の握手のみ含まれる
  ll sum=0;
  vector<ll> b(n+5);
  rep(i,n) b[0]+=a[i];
  rep(i,n-1) b[i+1]=b[i]-a[i];
  ll r_count=0;
  rep(i,n){
    ll res=l-a[i];
    //
    ll key=lower_bound(a.begin(),a.end(),res)-a.begin();
    sum+=b[key]; //右手の分としてkey以降のようそをたす
    sum+=(n-key)*a[i]; //左手の分
    r_count+=n-key; //握手はn-key回完了
  }
  sum-=(r_count-m)*l; //ぴったり値がlになるものをいくつか余分に足しちゃうので引く
  cout<<sum<<endl;
}

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

int main() {
	ll h, w;
	cin >> h >> w;
	ll ans = (h * w + 1) / 2;
	if(h == 1 || w == 1) ans = 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
yo=[]
for _ in range(n-1):
  a=list(map(int,input().split()))
  yo.append(a)
  
def ans(x):
  if x==n-1:
    return 0
  else:
    t=0
    for i in range(x,n-1):
      if t<=yo[i][1]:
        t=yo[i][1]+yo[i][0]
      else:
        s=t-yo[i][1]
        if s%yo[i][2]==0:
          t=t+yo[i][0]
        else:
          mo=s%yo[i][2]
          t=t+yo[i][2]-mo+yo[i][0]
    return t
    
for j in range(n):
  print(ans(j))
        
        

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string n;
    cin >> n;
    if (n[0] == '9' or n[1] == '9')cout  << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(n)]

b = [[0 for _ in range(w)] for _ in range(h)]
for x, y, a in xya:
    if a == 1:
        for i in range(h):
            for j in range(x):
                b[i][j] = 1
    elif a == 2:
        for i in range(h):
            for j in range(x, w):
                b[i][j] = 1
    elif a == 3:
        for i in range(y):
            for j in range(w):
                b[i][j] = 1
    elif a == 4:
        for i in range(y, h):
            for j in range(w):
                b[i][j] = 1
ans = 0
for i in range(h):
    for j in range(w):
        if b[i][j] == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3188
from enum import Enum
from queue import Queue
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

n,q = map(int,input().split())
que = Queue()#FIFOキュー作成
for i in range(n):
    name, time = input().split()
    que.put((name,int(time)))

total = 0
while que.qsize()>0:
    name,time = que.get()
    total += min(q,time)
    if q < time:
        que.put((name,time-q))
    else:
        print(name,total)



Measured memory_bytes: 13684
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// Dual Segment Tree
template <class OM> struct DST {
    int n, lev;
    vector<OM> lz;
    virtual OM h(OM, OM) = 0;
    const OM e0;

    DST(int n_, const OM& e0) : e0(e0) {
        for (n = 1, lev = 0; n < n_; n <<= 1, ++lev);
        lz.assign(n << 1, e0);
    }

    inline void push(int k) {
        for (int i = lev; i > 0; --i) {
            int j = k >> i;
            if (lz[j] == e0) continue;
            lz[(j << 1) | 0] = h(lz[(j << 1) | 0], lz[j]);
            lz[(j << 1) | 1] = h(lz[(j << 1) | 1], lz[j]);
            lz[j] = e0;
        }
    }

    // [l, r)
    // l, r: 0-indexed
    void update(int l, int r, const OM& x) {
        push(l += n);
        push(r += n - 1);
		for (++r; l < r; l >>= 1, r >>= 1) {
            if (l & 1) lz[l] = h(lz[l], x), l++;
            if (r & 1) --r, lz[r] = h(lz[r], x);
		}
    }

    // k: 0-indexed
    OM query(int k) {
        push(k += n);
        return lz[k];
    }
};

// Range Add Query (RAQ)
template <class OM> struct RAQ : DST<OM> {
    RAQ(int n, OM e0 = 0) : DST<OM>(n, e0) {}
    OM h(OM a, OM b) override { return a + b; }
};

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

    int n, q;
    cin >> n >> q;
    RAQ<int> raq(n);
    REP (i, q) {
        int c;
        cin >> c;
        if (c == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            s--; t--;
            raq.update(s, t + 1, x);
        } else {
            int j;
            cin >> j;
            j--;
            cout << raq.query(j) << endl;
        }
    }
}


Measured memory_bytes: 4948
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
const ll INF=1e18;
ll dp[1002][1002];
ll ans=0,t=0,p=0;
string s[1002];
int main(){
  ll n,m;
  cin>>n>>m;
  for(ll i=0;i<n;i++)
  cin>>s[i];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(ll i=0;i<n;i++){
    for(ll j=0;j<m;j++){
      if(s[i][j]=='#')
      continue;
      else{
        if(s[i+1][j]=='.'){
          dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
        }
        if(s[i][j+1]=='.')
        dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
      }
    }
  }
  cout<<dp[n-1][m-1]<<endl;
}

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int cutup(int a,int b){
    return (a+b-1)/b;
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s="",ss[220000];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
    }
    for(int i=n-1;i>-1;i-=2){
        cout<<aa[i]<<' ';
    }
    for(int i=n%2;i<n;i+=2){
        cout<<aa[i]<<' ';
    }
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  ll N;
  int K;
  cin >> N >> K;

  int ret = 0;
  while (N>0) {
    N /= K;
    ret++;
  }

  cout << ret << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <iterator>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int N;
char S[300][300];
bool check(int P){
  char C[300][300];
  FOR(i,0,N){
    FOR(j,0,N){
      C[i][(j+P)-(j+P>=N?N:0)]=S[i][j];
    }
  }
  FOR(i,0,N){
    FOR(j,i+1,N){
      if(C[i][j]!=C[j][i]){
        return false;
      }
    }
  }
  return true;
}
int main(){
  cin>>N;
  FOR(i,0,N){
    FOR(j,0,N){
      cin>>S[i][j];
    }
  }
  int ans=0;
  FOR(i,0,N){
    if(check(i)){
      ans+=N;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

class Solver {
};

int main() {
	while (true) {
		string s;
		cin >> s;
		if (s[0] == '#')break;

		map<string, int> ss;
		ss.emplace("", 0);
		for (int i = 0; i < s.size(); i++) {
			map<string, int>next;
			for (auto itr = ss.begin(); itr != ss.end(); itr++) {
				int num = 1 << (s[i] - 'a');
				if (num == 1 || (itr->second & num) > 0) {
					next.emplace(itr->first + s[i], itr->second);
				}
				if (num < (1 << 25) && (itr->second & (num << 1)) == 0) {
					next.emplace(itr->first + (char)(s[i] + 1),
						itr->second + (num << 1));
				}
			}
			ss = next;
		}

		vector<string> res;
		for (auto itr = ss.begin(); itr != ss.end(); itr++) {
			res.emplace_back(itr->first);
		}
		sort(res.begin(), res.end());
		cout << res.size() << endl;
		if (res.size() < 10) {
			for (int i = 0; i < res.size(); i++) {
				cout << res[i] << endl;
			}
		}
		else {
			for (int i = 0; i < 5; i++) {
				cout << res[i] << endl;
			}
			for (int i = res.size() - 5; i < res.size(); i++) {
				cout << res[i] << endl;
			}
		}
	}
}


Measured memory_bytes: 6808
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int k;
  cin >> k;

  unsigned long long ans = 0;
  for(int a = 1;a <= k;a++)
  for(int b = 1;b <= k;b++)
  for(int c = 1;c <= k;c++)
  {
    ans += GCD(GCD(a,b),c);
  }

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 3592
const inp = require('fs').readFileSync('/dev/stdin', 'utf8'); const l = inp.trim().split('\n'); var n = null; var ind = 0; while (li = l.shift()) { const isN = ind % 2 === 0; const nAr = li.split(' '); if(isN){ n = nAr[0]; } else { var sSc = null; for(var i = 0; i < nAr.length; i++){ for(var j = i+1; j < nAr.length; j++){ let sDi = Math.abs(nAr[i] - nAr[j]); if(sSc === null){ sSc = sDi; } else { if(sDi < sSc){ sSc = sDi; } } } } n = null; console.log(sSc); } ind ++; } 


Measured memory_bytes: 18180
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! {
        n: i64,
    }
    let a = (n - n % 3600) / 3600;
    let b = ( (n - a * 3600) - (n - a * 3600) % 60 ) / 60;
    let c = n - a * 3600 - b * 60;
    println!("{}:{}:{}", a, b, c);
}
//nを入力後ctrl+Z


Measured memory_bytes: 5036
n = int(input())
hl = list(map(int,input().split()))

dp = [float("inf") for i in range(n)]

dp[0] = 0
for idx, h in enumerate(hl):
    if idx + 2 < n:
        dp[idx+2] = min(dp[idx] + abs(hl[idx] - hl[idx+2]), dp[idx+2])
    if idx+1 < n:
        dp[idx+1] = min(dp[idx] + abs(hl[idx] - hl[idx+1]), dp[idx+1])

print(dp[n-1])

Measured memory_bytes: 13928
import static java.util.Arrays.*;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> toi = new HashMap<String, Integer>();
		toi.put("A", 0);
		toi.put("B", 1);
		toi.put("AB", 2);
		toi.put("O", 3);

		int[] ans = new int[4];
		for (;sc.hasNext();) {
			String[] s = sc.next().split(",");
			++ans[toi.get(s[1])];
		}
		for (int i = 0; i < 4; i++) {
			System.out.println(ans[i]);
		}
	}

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

Measured memory_bytes: 17164
import java.util.Scanner;

public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int n = nextInt();
        int[] arr = new int[n];

        for(int i=0;i<n;i++){
            arr[i] = nextInt();
        }

        int max;
        int con =0;
        int tmp = 0;
        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                for(int k=j+1;k<n;k++){
                    //print(k);
                    if(arr[i] != arr[j] && arr[i] != arr[k] && arr[k] != arr[j]){
                        //System.out.printf("%d %d %d\n", arr[i],arr[j],arr[k]);
                        max = Math.max(arr[i], Math.max(arr[j],arr[k]));
                        //print(max);
                        if(max == arr[i]) tmp = arr[j] + arr[k];
                        else if(max == arr[k]) tmp = arr[j] + arr[i];
                        else if(max == arr[j]) tmp = arr[k] + arr[i];
                        if(tmp > max){
                            con +=1;
                        }
                        tmp = 0;
                    }
                }
            }
        }
        print(con);
    }


    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }

    //print
    public static void print(Object a){
        System.out.println(a);
    }


    //gcd
    public static int gcd (int a, int b){
        int tmp;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return b;
    }


    //lcm
    public static int lcm(int a,int b){
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return (int)(c/b);
    }
}

Measured memory_bytes: 36348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int capacity = sc.nextInt();
		long[][] productInfo = new long[n][2];
		for(int i = 0;i < n;i++) {
			// 重さ
			productInfo[i][0] = sc.nextInt();
			// 価値
			productInfo[i][1] = sc.nextInt();
		}
		// その価値での最小の重さを記録する。
		long[] minimumWeightInfo = new long[100000 +1];
		minimumWeightInfo[0] =1;

		for(int i =0;i < productInfo.length;i++) {
			int weight = (int)productInfo[i][0];
			int value = (int)productInfo[i][1];
			for(int j = 100000; j >=0;j--) {
				if(minimumWeightInfo[j] != 0) {
					if(value + j <= 100000) {
						if(j != 0) {
							if(minimumWeightInfo[j + value] ==0) {
								minimumWeightInfo[j + value] = minimumWeightInfo[j] + weight;
							}else {
								if(minimumWeightInfo[j + value] > minimumWeightInfo[j] + weight) {
									minimumWeightInfo[j + value] = minimumWeightInfo[j] + weight;
								}
							}
						}else {
							if(minimumWeightInfo[value] == 0) {
								minimumWeightInfo[value] = weight;
							}else {
								if(minimumWeightInfo[value] > weight) {
									minimumWeightInfo[value] = weight;
								}
							}
						}
					}
				}
			}
		}
		int answer = 0;
		for(int i =1; i <=100000;i++) {
			if(minimumWeightInfo[i] != 0 && minimumWeightInfo[i] <= capacity) {
				if(i > answer) {
					answer = i;
				}
			}
		}
		System.out.println(answer);

	}
}

Measured memory_bytes: 37840
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Set;
import java.util.HashSet;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    Set s = new HashSet<String>();
    String[] str = in.readLine().split(" ");
    for(int i=0; i<n; i++) {
      s.add(str[i]);
    }
    System.out.println(s.size()==4?"Four":"Three");
  }
}

Measured memory_bytes: 32520
// A - Remaining Balls.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string S, T, U;
	int A, B;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
	if (S == U) {
		A -= 1;
	}
	else if (T == U) {
		B -= 1;
	}
	cout << A << " " << B << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
uli f(uli n, uli a,uli b){
  uli dif=b-a-1;
  uli ans=a+dif/2;
  return ans;
}
int main(){
  uli n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0)cout<<(b-a)/2<<endl;
  else{
    uli ans=min(f(n,a,b),f(n,n-b+1,n-a+1));
    cout<<ans<<endl;
  }
  return 0;
}


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

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

  bool c = false;
  int res = 0;
  for (int i = 2; i <= N; i++) {
    if (!c && a[i] == a[i-1]) {
      c = true;
      res++;
    } else {
      c = false;
    }
  }

  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i

if n==1
    a1 = gets.chomp.to_i
    a2 = gets.chomp.to_i
    puts a1+a2
    exit
end

a1 = gets.chomp.split(" ").map(&:to_i)
a2 = gets.chomp.split(" ").map(&:to_i)

arr1 =  Array.new(n, 0)
arr2 = Array.new(n, 0)
ans = 0
arr1[n-1] = a1.inject(:+)
arr2[0] = a2.inject(:+)

2.upto(n) do |i|
    arr1[n-i] = arr1[n-i+1] - a1[n-i+1]
    arr2[i-1] = arr2[i-2] - a2[i-2]
end

(n-1).times do |j|
    ans = [ans, arr1[j]+arr2[j]].max
end

puts ans

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

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int color[MAX], dp[MAX];
vector <int> adj[MAX];
vector <PP> qry;

void dfs(int v, int d, int c) {
    if (!color[v]) color[v] = c;
    if (d == 0 || dp[v] >= d) return;
    dp[v] = d;
    for (int nv : adj[v]) {
        dfs(nv, d-1, c);
    }
}

void solve(void){
    int N, M, Q;
    cin >> N >> M;
    rep(M, meaningless_) {
        int a, b;
        scanf("%d %d\n", &a, &b);
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    cin >> Q;
    rep(Q, meaningless_) {
        int v, d, c;
        scanf("%d %d %d\n", &v, &d, &c);
        P p = P(d, c);
        qry.pb(PP(v-1, p));
    }
    reverse(all(qry));

    for (PP p : qry) {
        dfs(p.first, (p.second).first, (p.second).second);
    }

    rep(N, i) {
        printf("%d\n", color[i]);
    }
    //cout << "yui(*-v・)yui" << endl;
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 8816
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //int a=int.Parse(Console.ReadLine());
        //string a = Console.ReadLine();
        Console.WriteLine((Math.Abs(input[1] - input[0]) <= input[3] && Math.Abs(input[2] - input[1]) <= input[3]) || Math.Abs(input[2] - input[0]) <= input[3] ? "Yes":"No");
        Console.ReadLine();
    }
}

Measured memory_bytes: 13268