akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn read_vec2(n: u32) -> Vec<Vec<char>> {
    let mut v2 = Vec::with_capacity(n as usize);
    use std::io::stdin;
    use std::io::BufRead;
    let stdin = stdin();
    let mut stdin = stdin.lock();
    for _ in 0..n {
        let mut s = String::new();
        stdin.read_line(&mut s).ok();
        let v = s.trim().chars().filter(|&c| c != ' ').collect();
        v2.push(v);
    }
    v2
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let S: String = read();
    let S: Vec<char> = S.chars().collect();
    let Q: usize = read();
    let query = read_vec2(Q as u32);
    use std::collections::VecDeque;
    let mut S: VecDeque<_> = S.into();
    S.reserve(Q);
    let mut reverse = false;

    for i in 0..Q {
        let q = &query[i];
        if q[0] == '1' {
            reverse = !reverse;
        } else {
            let f = q[1];
            let c = q[2];
            if (!reverse && f == '1') || (reverse && f == '2') {
                S.push_front(c);
            } else if (!reverse && f == '2') || (reverse && f == '1') {
                S.push_back(c);
            }
        }
    }
    let ans: String = if reverse {
        let mut S: Vec<_> = S.into();
        S.reverse();
        S.into_iter().collect()
    } else {
        S.into_iter().collect()
    };
    println!("{}", ans);
}


Measured memory_bytes: 16636
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		String[][] hw = new String[h][w];
		for (int i = 0; i < h; i++) {
			String tem[] = sc.next().split("");
			for (int j = 0; j < w; j++)
				hw[i][j] = tem[j];
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (hw[i][j].equals("#"))
					out.print(hw[i][j]);
				else {
					int ans = 0;
					if (i - 1 >= 0 && j - 1 >= 0 && hw[i - 1][j - 1].equals("#")) ans++;
					if (j - 1 >= 0 && hw[i][j - 1].equals("#")) ans++;
					if (i + 1 < h && j - 1 >= 0 && hw[i + 1][j - 1].equals("#")) ans++;
					if (i - 1 >= 0 && hw[i - 1][j].equals("#")) ans++;
					if (i + 1 < h && hw[i + 1][j].equals("#")) ans++;
					if (i - 1 >= 0 && j + 1 < w && hw[i - 1][j + 1].equals("#")) ans++;
					if (j + 1 < w && hw[i][j + 1].equals("#")) ans++;
					if (i + 1 < h && j + 1 < w && hw[i + 1][j + 1].equals("#")) ans++;
					out.print(ans);
				}
			}
			out.println("");
		}
		out.flush();
	}
}

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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  map<int, int> mp;
  ll ans = 0, mx = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    mp[t]++;
  }
  for (auto e : mp) {
    if (e.second >= 2) {
      ans = max(ans, mx * e.first);
      mx = e.first;
    }
    if (e.second >= 4) {
      ans = max(ans, (ll)e.first * e.first);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    string a, b, c;
    cin >> a >> b >> c;
    int t = 1; //abc > 123
    int ah = 0, bh = 0, ch = 0;
    for(;;){
      if(t == 1){
        if(a.size() == ah){
          pri("A");
          break;
        }
        if(a[ah] == 'a')t = 1;
        if(a[ah] == 'b')t = 2;
        if(a[ah] == 'c')t = 3;
        ++ah;
      }else if(t == 2){
        if(b.size() == bh){
          pri("B");
          break;
        }
        if(b[bh] == 'a')t = 1;
        if(b[bh] == 'b')t = 2;
        if(b[bh] == 'c')t = 3;
        ++bh;
      }else{
        if(c.size() == ch){
          pri("C");
          break;
        }
        if(c[ch] == 'a')t = 1;
        if(c[ch] == 'b')t = 2;
        if(c[ch] == 'c')t = 3;
        ++ch;
      }
    }


/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		if(x>=y && x% y ==0) {
			System.out.println(-1);
		}else if(x>y) {
			System.out.println(x);
		}else {
			System.out.println(x);
		}
		
	}

}


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

int main()
{
    int i,j,k,n,r=0 ;
    char ch[5435],s[4234] ;
    scanf(" %[^\n]",s) ;
    if(s[0]!='R'&&s[1]!='R'&&s[2]!='R')r=0 ;
    else if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')r=3 ;
    else if(s[0]=='R'&&s[1]=='R')r=2 ;
    else if(s[1]=='R'&&s[2]=='R')r=2 ;
   else r=1 ;
    printf("%d",r) ;
    return 0  ;
}


Measured memory_bytes: 1736
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt();
    int W = sc.nextInt();
    if(S <= W){   
    System.out.println("unsafe");
    }else{
    System.out.println("safe");
    }
}
}

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

int main() {
  int n, m, p, x, total_time = 0;
  cin >> n;
  vector<int> t(n);
  rep(i, n) {
    cin >> t[i];
    total_time += t[i];
  }
  cin >> m;
  rep(i, m) {
    cin >> p >> x;
    p--;
    cout << total_time - t[p] + x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ALDS1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = getint();
            int[] A = new int[n +1];
            for (int i = 0; i < n; i++)
            {
                A[i] = getint();
            }
            int m = 0;
            int k = 1;
            for (int i = 0; i < int.MaxValue; i++)
            {
                m++;
                k = 3*k + 1;
                if (k >= n) break;
            }
            Console.WriteLine(m);
            int[] G = new int[m];
            G[m - 1] = 1;
            for (int  i = m-2; i >=  0; i--)
            {
                G[i] = 3 * G[i + 1] + 1;
            }
            




            for (int i = 0; i < m; i++)
            {
                if (i == m-1)
                {
                    Console.WriteLine(G[i]);
                    break;
                }
                else
                {
                    Console.Write(G[i] + " ");
                }  
            }
            
            
            for (int i = 0; i < m; i++)
            {
                A = insertionsort(A, n, G[i]);
            }

            






            
            Console.WriteLine(A[n]);
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(A[i]);
            }
         }








        static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
        static int[]  insertionsort(int[] A,int n,int g)
        {
            for (int i = g; i < n; i++)
            {
                int v = A[i];
                int j = i - g;
                while (j >=0 && A[j] >v)
                {
                    A[j + g] = A[j];
                    j = j - g;
                    A[n]++;
                }
                A[j + g] = v;
            }
            return A;
        }
    }
}

Measured memory_bytes: 16504
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#define debug printf("\n-------------\n")
using namespace std;
typedef long long ll;
const int INF1=(~0u>>2);
const ll INF2=(~0ull>>2),P1=10007,P2=998244353,P3=1000000007;
const int dx[6]={0,0,1,0,-1},dy[6]={0,1,0,-1,0};
char a[25][25];
int n,m,ans=0,vis[25][25];
void bfs(int ux,int uy)
{
	queue<pair<int,int> > q;
	vis[ux][uy]=0;
	q.push(make_pair(ux,uy));
	while(!q.empty())
	{
		ux=q.front().first;
		uy=q.front().second;
		q.pop();
		for(int i=1;i<=4;i++)
		{
			int vx=ux+dx[i],vy=uy+dy[i];
			if(vx<=0||vx>n||vy<=0||vy>m||a[vx][vy]=='#'||vis[vx][vy]!=-1)
				continue;
			vis[vx][vy]=vis[ux][uy]+1;
			q.push(make_pair(vx,vy));
		}
	}
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='#')
				continue;
			memset(vis,-1,sizeof(vis));
			bfs(i,j);
			int mx=0;
			for(int k=1;k<=n;k++)
				for(int l=1;l<=m;l++)
					if(a[k][l]!='#')
						mx=max(mx,vis[k][l]);
			ans=max(ans,mx);
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
s = input()
ans = 0
for i in range(10):
    ind = s.find(str(i))+1
    if ind == 0 or ind == len(s):
        continue
    for j in range(10):

        ind_j = ind + s[ind:].find(str(j))+1
        if ind_j == ind or ind_j == len(s):
            continue
        cnt = collections.Counter(s[ind_j:])
        ans += len(cnt)

print(ans)


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

using namespace std;

int main(){
    string s;
    cin >> s;
    vector<char> str;
    for(int i=0;i<s.size();i++){
        str.push_back(s[i]);
    }

    bool check[26];
    for(int i=0;i<26;i++)check[i] = false;
    for(int i=0;i<str.size();i++){
        for(int j=0;j<26;j++){
            if(str[i]==char(int('a')+j))check[j] = true;
        }
    }
    for(int i=0;i<26;i++){
        if(!check[i]){
            cout << char(int('a')+i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>

using namespace std;

int main() {
    

    
    int n;
    cin >> n;
    
    int ret = 0;
    int a = 0;
    int b = 0;
    int ab = 0;
    
    for(int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        
        for (int j = 0; j < s.size() - 1; ++j)
        {
            if (s[j] == 'A' && s[j + 1] == 'B')
            {
                ret++;
            }
        }
        
        if (s[0] == 'B' && s[s.size() - 1] == 'A')
        {
            ab++;
        }
        else if (s[0] == 'B')
        {
            b++;
        }
        else if (s[s.size() - 1] == 'A')
        {
            a++;
        }
    }
    
    int minab = min(a, b);
    minab = min(minab, ab);
    a -= minab;
    b -= minab;
    ab -= minab;
    
    ret += (minab * 2);
    
    if (ab > 0)
    {
        if (minab > 0 || a > 0 || b > 0)
        {
            ret += ab;
        }
        else
        {
            ret += (ab - 1);
        }
    }
    else if (a > 0)
    {
        if (b > 0)
        {
            ret += min(a, b);
        }
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

N, T = [int(x) for x in stdin.readline().rstrip().split()]
keiro = [[0] * 2 for i in range(N)]
keiro = []
check = 0

for i in range(N):
    c, t = [int(x) for x in stdin.readline().rstrip().split()]
    if t <= T:
        keiro.append([c,t])

if keiro == []:
    print("TLE")
    exit()

keiro_s = sorted(keiro)

print(keiro_s[0][0])

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

int main(){
  string s;
  cin>>s;
  char c=s[0];
  for(int i=1;i<4;i++){
		if(c==s[i]){
          cout<<"Bad"<<endl;
          return 0;
        }
    c=s[i];
  }
  cout<<"Good"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N, K;
    cin >> N >> K;

    vector< vs64 > dp(K + 1, vs64(K + 1));
    vs32 V(N + 2);
    V[0] = V[N + 1] = 0;
    rep (i, N) cin >> V[i + 1];

    s64 ans = 0;
    s64 temp = 0;
    for (int l = 0; l <= MIN(N, K); ++l)
    {
        for (int r = 0; l + r <= MIN(N, K); ++r)
        {
            temp = 0;
            priority_queue<int> pq;
            rep (i, l)
            {
                if (V[i + 1] < 0) pq.push(-V[i + 1]);
                temp += V[i + 1];
            }
            rep (i, r)
            {
                if (V[N - i] < 0) pq.push(-V[N - i]);
                temp += V[N - i];
            }
            for (int i = 0; i < K - l - r && !pq.empty(); ++i)
            {
                temp += pq.top();
                pq.pop();
            }
            ans = MAX(ans, temp);
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

signed main()
{
    int N, D, A; cin >> N >> D >> A;
    vpii monsters(N);
    rep(i, N) cin >> monsters[i].fst >> monsters[i].scd;

    sort(all(monsters));

    ll current_damage = 0;

    queue<pair<int, ll>> damages;

    ll ans = 0;

    rep(i, N) {
        int pos = monsters[i].fst, hp = monsters[i].scd;

        while (damages.size() and damages.front().fst < pos) {
            current_damage -= damages.front().scd;
            damages.pop();
        }

        int zan = max(hp - current_damage, 0ll);

        int t = (zan + A - 1) / A;
        ans += t;
        current_damage += t * A;
        damages.emplace(pos + 2 * D, t * A);
    }

    cout << ans << endl;
}


Measured memory_bytes: 8024
#include<iostream>
#include<iomanip>
#include<complex>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using pos = complex<double>;

const double EPS = 1e-9;

struct circle {
    pos center_;
    double r_;
    circle(pos center, double r):center_(center), r_(r) {}
};

pos times(const pos& p1, const pos& p2) {
    double x = p1.real() * p2.real() - p1.imag() * p2.imag();
    double y = p1.real() * p2.imag() + p1.imag() * p2.real();
    return pos(x, y);
}

vector<pos> getCrossPoint(const circle& c1, const circle& c2) {
    double d = abs(c1.center_ - c2.center_);
    if (d < EPS) {
        return vector<pos>();
    }
    if (d > c1.r_ + c2.r_ + EPS) {
        return vector<pos>();
    }
    if (d < abs(c1.r_ - c2.r_) - EPS) {
        return vector<pos>();
    }
    double rc = (d * d + c1.r_ * c1.r_ - c2.r_ * c2.r_) / (2 * d);
    double rs = c1.r_ - abs(rc) < EPS ? 0 : sqrt(c1.r_ * c1.r_ - rc * rc);
    pos diff = (c2.center_ - c1.center_) / d;
    pos p1 = c1.center_ + diff * pos(rc, rs);
    pos p2 = c1.center_ + diff *  pos(rc, -rs);
    vector<pos> res;
    res.push_back(p1);
    res.push_back(p2);
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<double> X(N), Y(N), C(N);
    rep(i, 0, N) {
        cin >> X[i] >> Y[i] >> C[i];
    }
    double l = 0.0, r = 1000000.0;
    rep(_, 0, 100) {
        double mid = (l + r) / 2;
        vector<circle> CC;
        rep(i, 0, N) {
            CC.emplace_back(pos(X[i], Y[i]), mid / C[i]);
        }
        vector<pos> target_points;
        rep(i, 0, N) {
            target_points.emplace_back(X[i], Y[i]);
        }
        rep(i, 0, N) rep(j, i + 1, N) {
            vector<pos> cross_points = getCrossPoint(CC[i], CC[j]);
            for (auto p : cross_points) {
                target_points.push_back(p);
            }
        }
        bool is_ok = false;
        for (auto p : target_points) {
            int cnt = 0;
            rep(i, 0, N) {
                double d = abs(p - CC[i].center_);
                if (d <= CC[i].r_ + EPS) {
                    ++cnt;
                }
            }
            if (cnt >= K) {
                is_ok = true;
                break;
            }
        }
        if (is_ok) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    cout << fixed << setprecision(10) << r << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
#include<stdint.h>
#include<limits.h>
#include<sstream>
#include<iomanip>
#include<cmath>
using namespace std;


int main() {
	int n, b[101],sum=0,c1=-1;
	cin >> n;
	cin >> b[0];
	sum = sum = b[0];
	c1 = b[0];
	for (int i = 1;i < n - 1;i++)
	{
		cin >> b[i];

			if (c1 < b[i])
				sum += c1;
			else
				sum += b[i];
		
		c1 = b[i];
	}
	sum += b[n - 2];
	cout << sum;
	return 0;
}

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

// Problem https://atcoder.jp/contests/arc094/tasks/arc094_a
// Reference1 https://atcoder.jp/contests/abc093/submissions/2359516
// Reference2 https://atcoder.jp/contests/arc094/submissions/2403322
// Comment: 今度は不変量に着目します
// CommentRef:https://qiita.com/drken/items/fd4e5e3630d0f5859067#%E7%AC%AC-10-%E5%95%8F--abc-086-c---traveling-300-%E7%82%B9

int solver(int A,int B,int C){
    int result=0;
    int maxValue=0;
    // 下限の候補となる3つの数の最大値を求める
    maxValue=max(A,max(B,C));
    int coverValue;
    // 下限まで埋め合わせるのに必要な値
    coverValue=maxValue*3-(A+B+C);
    // 一度に埋め合わせ可能な値は2(偶数)しかないのでもし埋め合わせ数が奇数ならば
    // 下限をmaxValue+1とする
    if(coverValue % 2 == 1){
        coverValue=((maxValue+1)*3)-(A+B+C);
    }
    result = coverValue/2;
    return result;
}

int main(void){
    int A,B,C;
    int answer=0;
    cin >> A >> B >> C;
    answer = solver(A,B,C);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import logging
import time


class Solver:
    def __init__(self):
        self.r = 0

    # 入力
    def input_value(self):
        # self.n = int(input())
        # self.A, self.B = map(int, input().split())
        # self.A = list(map(int, input().split()))
        # self.a, self.b, self.c = map(int, [input() for i in range(4)])
        # self.t = [None] * self.n
        self.r = int(input())

    @staticmethod
    def run(r):
        if r < 1200:
            return 'ABC'
        elif r < 2800:
            return 'ARC'
        # logging.debug(str(count))
        return 'AGC'

    # @staticmethod
    # def test():
    #     a = []
    #     for i in range(10 ** 5):
    #         a.append(1000001)
    #
    #     start_time = time.time()
    #
    #     assert Solver.run(2, [4, 1, 5]) == 3, 'Error.'
    #     assert Solver.run(17, [29, 7, 5, 7, 9, 51, 7, 13, 8, 55, 42, 9, 81]) == 6, 'Error.'
    #     assert Solver.run(400000000, [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, ]) == 25, 'Error.'
    #
    #     assert Solver.run(10, a) == 0, 'Error.'
    #
    #     elapsed_time = time.time() - start_time
    #     logging.debug('elapsed_time: {0}'.format(elapsed_time) + '[sec]')


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    solver = Solver()

    # Solver.test()

    solver.input_value()
    ans = solver.run(solver.r)
    # print(str(ans))
    print(ans)


Measured memory_bytes: 4212
#include<stdio.h>
#define INF (1 << 21)
#define N 100

int min(int, int);

int main(){
  int i,j,l,k,m,n,a[N+1],b[N+1][N+1];
  scanf("%d",&n);
  for(i=1;i <= n;i++){
    scanf("%d %d",&a[i-1],&a[i]);
  }
  for(i=1;i<=n;i++){
    b[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=0;i <=n-l+1;i++){
      m = i+l-1;
      b[i][m]=INF;
      for(k=i;k<=m-1;k++){
        b[i][m]=min(b[i][m],b[i][k] + b[k+1][m] + a[i-1] * a[k] * a[m]);
      }
    }
  }
  printf("%d\n",b[1][n]);
  return 0;
}
int min(int x,int y){
  return x < y ? x : y;
}



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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int n = Integer.parseInt(sc.nextLine()), res = 0;
        for (int i = 0; i < n; i++) {
            String ring = sc.nextLine();
            ring += ring;
            if (ring.contains(s)) {
                res += 1;
                continue;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 17404
#include<stdio.h>
#include<math.h>
int main(){
	double x[23],y[23],d[5],ans,s;
	int i=0;
	while(scanf("%lf,%lf",&x[i],&y[i])!=EOF){
		if(i==1){
			d[2]=sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
		}else if(i>1){
			d[0]=d[2];
			d[1]=sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
			d[2]=sqrt((x[i]-x[0])*(x[i]-x[0])+(y[i]-y[0])*(y[i]-y[0]));
			s=(d[0]+d[1]+d[2])/2;
			ans+=sqrt(s*(s-d[0])*(s-d[1])*(s-d[2]));
			//printf("%lf\n",ans);
		}
		i++;
	}
	printf("%lf\n",ans);
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+1
const ll mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
vector<VL> adj;
map<ll,ll> mp,mp2;
ll ans,too,node;
void dfs(ll i,ll step)
{
    //cout<<i<<" "<<step<<endl;
    if(!mp.count(i))
    {
        mp[i]=step;
        for(auto to:adj[i])
        {
            if(!mp.count(to))
            {
                dfs(to,step+1);
            }
            else
            {
                node=to;
                too=mp[to];
                ans=step+1-mp[to];
                return;
            }
        }
    }
    else
    {
        node=i;
        too=mp[i];
        ans=step-mp[i];
        return;
    }
    return;
}
void dfs2(ll i,ll step)
{
    if(step==0)
    {
        cout<<i+1<<endl;
        return;
    }
    else
    {
        mp2[i]=step;
        for(auto to:adj[i])
        {
            if(!mp2.count(to))
            {
                dfs2(to,step-1);
            }
        }
    }
    return;
}
void solve()
{
    ll n,k;
    cin>>n>>k;
    ans=-1,node=-1,too=-1;
    adj.assign(n,VL());
    fr(i,0,n)
    {
        ll x;
        cin>>x;
        x--;
        adj[i].pb(x);
    }
    dfs(0,0);
    //cout<<too<<" "<<ans<<" "<<node<<endl;
    if(k<too)
    {
        dfs2(0,k);
    }
    else
    {
        ll rem=k-too;
        rem=rem%ans;
        //cout<<rem<<" : \n";
        dfs2(node,rem);
    }
    
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 53804
n, m = gets.chomp.split.map(&:to_i)
arr = Array.new(n, 0)

m.times{
    a, l = gets.chomp.split.map(&:to_i)
    l.times{|i| arr[(a + i) % n] = 1}
}

zero = arr.index(0)
if zero.nil?
    puts "#{n} 1"
else
    h = Hash.new{|h, k| h[k] = 0}
    l = 0
    zero.upto(zero + n - 1){|i|
        case arr[i % n]
        when 0
            if l != 0
                h[l] += 1
                l = 0
            end
        when 1
            l += 1
        end
    }
    h[l] += 1 if l != 0
    h.sort_by{|k, v| -k}.each{|k, v| puts "#{k} #{v}"}
end


Measured memory_bytes: 8912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

LL dp[110][5][2] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    string N; cin >> N;
    int K; cin >> K;
    int len = N.length();

    VI sN(len);
    REP(i,len){
        sN[i] = N[i]-'0';
    }
    if(sN[0] == 1){
        dp[0][1][0] = 1;
        dp[0][0][1] = 1;
    }else{
        dp[0][1][0] = 1;
        dp[0][1][1] = sN[0] - 1;
        dp[0][0][1] = 1;
    }

    FOR(i,1,len){
        FOR(j,0,K+1){
            if(sN[i] == 0){
                dp[i][j][0] = dp[i-1][j][0];
                if(j == 0) dp[i][j][1] = dp[i-1][j][1];
                else dp[i][j][1] = dp[i-1][j][1] + dp[i-1][j-1][1] * 9 ;
            }else{
                if(j != 0) dp[i][j][0] = dp[i-1][j-1][0];
                if(j == 0) dp[i][j][1] = dp[i-1][j][1]  + dp[i-1][j][0];

                else dp[i][j][1] = dp[i-1][j][1] + dp[i-1][j-1][1] * 9 + dp[i-1][j][0] + dp[i-1][j-1][0]*(sN[i]-1);
            }

        }
    }

    //REP(i,len) REP(j,K){
    //    cout << "dp[i][j] "<<i << " " << j << endl;
    //    cout << dp[i][j][0] << " " << dp[i][j][1] << endl;
    //}

    LL ans = 0;
    REP(i,2){
        ans += dp[len-1][K][i];
    }
    cout << ans << endl;



}


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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int s = 0, t = 0;
  rep(i,n) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      if (s<x) s=x;
    }
    if (a == 2) {
      if (w>x) w=x;
    }
    if (a==3) {
      if (t<y) t=y;
    }
    if (a==4) {
      if (h>y) h=y;
    }
  }
  if (w-s <= 0 || h-t <= 0) {
    cout << 0 << endl;
    return 0;
  }
  int ans = (w-s)*(h-t);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline

def main():
    N, P = map(int, input().split())
    A = list(map(int, input().split()))

    pre = [1, 0]

    for i, a in enumerate(A):
        if a&1:# 奇数
            tmp = [sum(pre), sum(pre)]
        else:# 偶数
            tmp = [pre[0] * 2, pre[1] * 2]
        pre = tmp
    
    print(pre[P])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define REP(i,n) for(i=0;i<n;i++)
using namespace std;
 
int main(){
  long int i,j;
  long int n;
  cin >> n;
  int a[n];
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  int b[n+1], m=0, mnum[n+1];
  for(i=n-1;i>=0;i--){
    if((i+1)*2>n){
      b[i+1] = a[i]; m += b[i+1]; mnum[i+1] = (i+1)*b[i+1];
    }
    else{
      b[i+1] = a[i];
      for(j=2;j*(i+1)<=n;j++){
        b[i+1] = b[i+1]^b[j*(i+1)];
      }
      m += b[i+1]; mnum[i+1] = (i+1)*b[i+1];
    }
  }
  printf("%d\n",m);
  for(i=1;i<=n;i++){
    if(mnum[i]!=0){
      printf("%d ",mnum[i]);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll n,s;
    cin >> n >> s;
    vector<ll> z(3000);
    for (int i = 0; i < n; i++) {
        cin >> z.at(i);
    }
    vector<ll> dp(3001);
    dp.at(0) = 1;
    for (int i = 0; i < n; i++) {
        vector<ll> c(3001);
        for (int i = 0; i < 3001; i++) {
            c.at(i)=dp.at(i);
        }
        for (int j = 0; j < 3001; j++) {
            dp.at(j) *= 2;
            if (j >= z.at(i))dp.at(j) += c.at(j-z.at(i));
            dp.at(j) %= 998244353;
        }
    }
    cout << dp.at(s) << endl;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N;
ll h[100010];
ll dp[100010];

int main() {
    cin >> N;
    rep(i, N) cin >> h[i];

    // initialization
    rep(i, N) dp[i] = INF;
    dp[0] = 0;

    // DP loop
    for (int i = 0; i < N; i++) {
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class CAttackSurvival {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k, q; cin >> n >> k >> q;
      vector<int> cnt(n);
      rep(i, q) {
        int a; cin >> a; a--;
        cnt[a]++;
      }

      rep(i, n) {
        if (k-(q-cnt[i])<=0) {
          cout << "No" << '\n';
        } else {
          cout << "Yes" << '\n';
        }
      }
    }
};

signed main() {
  CAttackSurvival solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int n,sum=0,i;
    int a[102];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<n-1;i++)
    {
        sum+=a[i];
    }
    if(sum>a[n-1])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
//Δ_A
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
int main()
{
	int n,k;
	cin>>n>>k;
	if(k==1)
		cout<<0;
	else
		cout<<n-k;
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;
int s1[N], s2[N];
LL dp[N][4][2][2][2];
int cnt = 0;
LL dfs(int pos, int s,
	bool up1 = true, bool lead1 = true,
	bool up2 = true, bool lead2 = true)
{
	if (lead1 ^ lead2) return 0;
	if (s == 1) return 0;
	if (pos == -1) return 1;
	if (dp[pos][s][up1][up2][lead1 && lead2] != -1) return dp[pos][s][up1][up2][lead1 && lead2];
	//cnt++;
	LL& res = dp[pos][s][up1][up2][lead1 && lead2] = 0;
	int l1 = 0, r1 = up1 ? s1[pos] : 1;
	int l2 = 0, r2 = up2 ? s2[pos] : 1;
	for (int i = l1; i <= r1; i++)
	{
		for (int j = l2; j <= r2; j++)
		{
			res += dfs(pos - 1, i * 2 + j,
				up1 && i == s1[pos], lead1 && i == 0,
				up2 && j == s2[pos], lead2 && j == 0);
		}
	}
	res %= INF;
	return res;
}
LL solve(LL l, LL r)
{
	MEM(dp, -1);
	MEM(s1, 0);
	MEM(s2, 0);
	int len1 = 0;
	int len2 = 0;
	while (r)
	{
		s1[len1++] = r % 2;
		r /= 2;
	}
	while (l)
	{
		s2[len2++] = l % 2;
		l /= 2;
	}
	return dfs(len1 - 1, 0);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	MEM(dp, -1);
	LL l, r;
	cin >> l >> r;
	int ans2 = solve(r, r);
	int ans1 = solve(l - 1, r);
	//cout << cnt << endl;
	int ans = ans2 - ans1;
	if (ans < 0) ans += INF;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int snake = Integer.parseInt(sc.next());
        Integer[] sticks = new Integer[n];
        for (int i = 0; i < n; i++) {
            sticks[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(sticks, Comparator.reverseOrder());
        int sum = 0;
        for (int i = 0; i < snake; i++) {
            sum += sticks[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
N = gets.to_i - 1
H = gets.split(" ").map(&:to_i)

i = 0
prev = -1
no = false

while i < N do
  tmp = H[i] - H[i + 1]
  if tmp == 0
    if prev <= -1
      H[i] = H[i] - 1
      tmp = prev - 1
    end
  elsif tmp < 0
  elsif tmp == 1 && prev < 0 
    H[i] = H[i] - 1
    tmp = 0
  else
    no = true
    break
  end
  prev = tmp
  i = i + 1
end

puts no ? "No" : "Yes"


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

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int n, m, r, g[201][201], a, b, c, ans;
long long d[201][201];
vector<int> p;
map<int, bool> mp;

int main() {
    init();
    cin >> n >> m >> r;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i != j) d[i][j] = INF;
            else d[i][j] = 0;
        }
    }

    p.resize(r);
    for (int i = 0; i < r; ++i) {
        cin >> p[i];
        p[i]--;
        //mp[p[i]] = true;
    }

    for (int i = 0; i < m; ++i) {
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = d[b][a] = c;
    }

    rep(k,n) rep(i,n) rep(j,n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    sort(p.begin(), p.end());
    ans = INF;
    do {
        int tmp = 0;
        for (int i = 0; i < r - 1; ++i) {
            tmp += d[p[i]][p[i + 1]];
        }
        ans = min(ans, tmp);
    } while (next_permutation(p.begin(), p.end()));

    cout << ans << endl;

    return 0;
}

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

int gcd(int a, int b, int & step){
    return b ? step++, gcd(b, a%b, step) : a;
}

int main(int argc, char ** argv) {
    int a, b;
    while (scanf("%d%d", &a, &b), a != 0){
        if (a < b) swap(a, b);
        int g, k = 0;
        g = gcd(a, b, k);
        printf("%d %d\n", g, k);
    }
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct topological_sort{
    vector<vector<int>> graph;
    vector<bool> done,open;
    vector<int> res;
    bool success;
    topological_sort(vector<vector<int>> &graph):graph(graph),done(graph.size()),open(graph.size()),success(true){
        int size=graph.size();
        vector<int> in(size);
        for(int i=0; i<size; ++i) for(int j:graph[i]) ++in[j];
        priority_queue<int,vector<int>,greater<int>> que;
        for(int i=0; i<size; ++i) if(!in[i]) que.push(i);
        while(!que.empty()){
            int x=que.top();
            que.pop();
            res.push_back(x);
            for(int y:graph[x]){
                --in[y];
                if(!in[y]) que.push(y);
            }
        }
        if(res.size()!=size) success=false;
    }
};

void solve(){
    int v,e;
    cin >> v >> e;
    vector<vector<int>> graph(v);
    rep(i,0,e){
        int s,t;
        cin >> s >> t;
        graph[s].push_back(t);
    }
    topological_sort ts(graph);
    cout << int(!ts.success) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  pair<int,int> a[3][3];
  int n,b,c=0,d,e;
  rep(i,0,3) rep(j,0,3) cin>>a[i][j].first;
  rep(i,0,3) rep(j,0,3) a[i][j].second=0;
  
  cin>>n;
  rep(i,0,n){
    cin>>b;
    rep(j,0,3) rep(k,0,3) if(a[j][k].first==b) a[j][k].second++;
  }
  rep(i,0,3) if(a[i][0].second==1 && a[i][1].second==1 && a[i][2].second==1) c++;
  rep(i,0,3) if(a[0][i].second==1 && a[1][i].second==1 && a[2][i].second==1) c++;
  if(a[0][0].second==1 && a[1][1].second==1 && a[2][2].second==1) c++;
  if(a[2][0].second==1 && a[1][1].second==1 && a[0][2].second==1) c++;
  
  if(c>0) co("Yes");
  else co("No");
  
  
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;


int main(){
    int N,a,zero=0,one=0,two=0;
    cin>>N;
    
    rep(i,0,N){
        cin>>a;
        if(a%2==1)zero++;
        else if(a%2==0 && a%4!=0)one++;
        else if(a%4==0)two++;
    }

    if(two>=zero)cout<<"Yes"<<endl;
    else if(one==0&&two+1>=zero)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
typedef long long int ll;
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 EFOR(i,a,b) for (int i=(a);i<=(b);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

    int N;

int main(){
    scanf("%d",&N);
    if(N<1200)cout<<"ABC";
    else cout<<"ARC";
    return 0;
}


Measured memory_bytes: 256