akhauriyash/Code-Regression huggingface dataset:
#include<iostream>//C
#include<cstdio>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    long long temp_1,temp_2;
    scanf("%lld",&temp_1);
    int sum=0,maxs=0;
    for(int i=1;i<n;i++)
    {
        scanf("%lld",&temp_2);
        if(temp_2<=temp_1) sum++;
        else sum=0;
        if(sum>maxs) maxs=sum;
        temp_1=temp_2;
    }
    printf("%d\n",maxs);
    return 0;
}

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

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

    vector<vector<int>> v;

    int x, n = 20;
    cin >> x;

    for (int i = 0; i < n - 1; i++) {
    	v.push_back({i, i + 1, 0});
    }

    vector<int> anime;

    while (x > 0) {
    	for (int i = 0; ; i++) {
    		if ((x >> i) & 1) {
    			anime.push_back(i);
    			x ^= (1 << i);
    			break;
    		}
    	}
    }

    reverse(all(anime));

    for (int i = n - 1 - anime[0]; i + 1 < n; i++) {
    	v.push_back({i, i + 1, 1 << (n - 2 - i)});
    }

    int pref = 1 << anime[0];
    anime.erase(anime.begin());

    for (int x : anime) {
    	if ((n - 1 - x) != 0) {
    		v.push_back({0, n - 1 - x, pref});
    	}
    	pref |= 1 << x;
    }

    cout << n << " " << v.size() << "\n";
    for (auto e : v) {
    	cout << e[0] + 1 << " " << e[1] + 1 << " " << e[2] << "\n";
    }

    return 0;   
}

Measured memory_bytes: 256
ipt=input()
lst=ipt.split()
A=int(lst[0])
B=int(lst[1])
if A>=B and A-1>=B:
    print(A+A-1)
elif A>=B and A-1<B:
    print(A+B)
elif A<B and A<B-1:
    print(B+B-1)
else:
    print(A+B)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
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)*}};}
#[allow(unused_macros)]
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)*}};}
#[allow(unused_macros)]
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")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
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()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{n:usize, d:[i64;n], m:usize, t:[i64;m]};
    let mut map = HashMap::new();

    for i in 0..n {
        let count = map.entry(d[i]).or_insert(0i64);
        *count += 1;
    }

    for i in 0..m {
        let count = map.entry(t[i]).or_insert(0);
        if *count == 0 {
            println!("NO");
            return();
        }
        *count -= 1;
    }

    println!("YES");

}


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

//create arrays outside of main()

int a[100];

int main(){

    int a;
    int b;
    int c;
    
    cin >> a >> b >> c;

    int train = a*b;
    int taxi = c;

    if (train>taxi){
        cout << taxi;
    } else {
        cout << train;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  char a;
  
  cin >> a;
  
  switch(a){
    case 'A' :
      cout << 'T' << endl;
      break;
          case 'T' :
      cout << 'A' << endl;
      break;
          case 'G' :
      cout << 'C' << endl;
      break;
          case 'C' :
      cout << 'G' << endl;
      break;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  
  int a;
  int b1,b2;
  b1='S';
  b2='T';
  
  int count,length,catch;
  count=0; length=0; catch=0;
  for(;;){
    if((a=fgetc(stdin))=='\n'){break;}
    length++;
    if(count==0){
      if(a==b1){
        count++;
      }else if(a==b2){
      }
    }else if(count>0){
      if(a==b1){
        count++;
      }else if(a==b2){
        count=count-1;
        catch=catch+2;
      }
    }
  }
  printf("%d\n",length-catch);
  return 0;
}

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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int k;
    string st;
    cin >> k >> st;
    if((int)st.size()<=k)cout << st;
    else{
    	for(int i=0;i<k;i++)
    		cout << st[i] ;
    	cout << "...";
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
const ll MAXX = 1e18;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("INP.txt", "r", stdin);
    //freopen("OUT.txt", "w", stdout);
	vector<char> hold;
	ll n;
	cin >> n;
	string s;
	cin >> s;
	s = " " + s;
	while (s.back() != ' ') {
		ll p = s.back();
		s.pop_back();
		if (p != s.back()) {
			hold.push_back(p);
		}
	}
	cout << hold.size() << '\n';
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

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

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> A){
    vector<pair<int, int> > memo;
    REP(i, N) memo.PB(MP(A[i], i+1));
    sort(ALL(memo));
    REP(i, N) cout << memo[i].second << (i+1 == N ? "\n" : " ");
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500;
bool query(vector<int> a){
	cout << "?";
	for(int v : a) cout << " " << v;
	cout << endl;
	string r; cin >> r;
	return r == "Red";
}
int color[maxn], res[maxn];
int main(){
	int n; cin >> n;
	vector<int> a, b;
	for(int i = 1; i <= n; i++) a.push_back(i);
	color[1] = query(a);
	int lo = 2, hi = n + 1, ans = -1;
	while(lo <= hi){
		int mid = (lo + hi)>>1;
		b.clear();
		for(int j = 0; j < n; j++) b.push_back(mid + j);
		color[mid] = query(b);
		if(color[mid] != color[1]) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	assert(ans != -1);
	memset(res, -1, sizeof(res));
	res[ans - 1] = color[1];
	res[ans + n - 1] = !color[1];
	int l = ans, r = ans + n - 2;
	for(int i = 1; i <= 2 * n; i++){
		if(res[i] == -1){
			if(l <= i && i <= r){
				b.clear();
				b.push_back(ans - 1);
				b.push_back(ans + n - 1);
				for(int j = l; j <= r; j++) if(j != i) b.push_back(j);
				res[i] = !query(b);
			} else {
				b.clear();
				b.push_back(i);
				for(int j = l; j <= r; j++) b.push_back(j);
				res[i] = query(b);
			}
		}
	}
	cout << "! ";
	for(int i = 1; i <= 2*n; i++){
		if(res[i]) cout << "R";
		else cout << "B";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
    int N;
    int p[10];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    sort(p, p + N);

    int sum = 0;
    for (int i = 0; i < N-1; i++) {
        sum += p[i];
    }
    cout << sum + p[N-1]/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    int n,l;
    int a[100005];
    cin >> n >> l;
    rep(i,n) cin >> a[i];

    int maxi = 0, k;
    rep(i,n - 1){
        if(maxi < a[i] + a[i + 1]){
            maxi = a[i] + a[i + 1];
            k = i;
        }
    }

    if(maxi < l) cout << "Impossible" << endl;
    else{
        cout << "Possible" << endl;
        rep(i,k) cout << i + 1 << endl;
        for(int i = n - 2; i >= k + 1; i--){
            cout << i + 1 << endl;
        }
        cout << k + 1 << endl;
    }
}


Measured memory_bytes: 1152
#if loc||local
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
signed main(){

  ll a,b,c,d;
  cin>>a>>b>>c>>d;

  __int128_t ans = max({a*c,a*d,b*c,b*d});
  cout<<(ans)<<endl;

}


Measured memory_bytes: 3560
n, k = input().split()
n = int(n)
k = int(k)
ans = 1000000000000
lis = []
for i in range(n):
    lis.append(int(input())) 

lis.sort() #小さい順に並べ替え

for i in range(n-k+1):
    sa = lis[i+k-1] - lis[i]
    if sa <= ans:
        ans = sa

print(ans)

Measured memory_bytes: 7384
#include<stdio.h>
#include<string.h>
int main(void){
    char name[200][200];
    char tmp[200];
    int score[200],origin[200];
    int i,j,n,temp,max,max_i;
    for(i=0;i<200;i++){
        score[i]=0;
        origin[i]=i;
        for(j=0;j<200;j++){
            name[i][j]=0;
        }
    }
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%s %d",name[i],&score[i]);
    }
    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
            if(strcmp(name[i],name[j])>0){
                temp=score[j];
                score[j]=score[i];
                score[i]=temp;
                temp=origin[j];
                origin[j]=origin[i];
                origin[i]=temp;
                strcpy(tmp,name[j]);
                strcpy(name[j],name[i]);
                strcpy(name[i],tmp);
            }
        }
    }
      for(i=0;i<n;i++){
        for(j=1;j<=n;j++){
            if(name[j][0]!=0){
                strcpy(tmp,name[j]);
                break;
            }
        }
        max=-1;
        max_i=-1;
        for(j=1;j<=n;j++){
            if(strcmp(tmp,name[j])==0){
                if(max<score[j]){
                    max_i=j;
                    max=score[j];
                }
            }
        }
        printf("%d\n",origin[max_i]);
        score[max_i]=-1;
        name[max_i][0]=0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

vector<ll>ba(51, 0), pa(51, 0);

ll func(ll n, ll x) {

	if (n == 0) {
		return 1;
	}
	else if (x == 1) {
		return 0;
	}
	else if (x > 1 && x <= ba[n-1] + 1) {
		return func(n - 1, x - 1);
	}
	else if (x  == ba[n - 1] + 2) {
		return pa[n - 1] + 1;
	}
	else if (x > ba[n - 1] + 2 && x < ba[n]) {
		return pa[n - 1] + 1 + func(n - 1, x - ba[n - 1] - 2);
	}
	else if (x ==  ba[n]) {
		return pa[n];
	}


	return 0;
}


signed main() {
	int i, j;
	ll n, x;
	

	cin >> n >> x;

	ba[0] = 1;
	pa[0] = 1;

	for (i = 1; i <= n; i++) {
		ba[i] = ba[i - 1] * 2 + 3;
	}

	for (i = 1; i <= n; i++) {
		pa[i] = pa[i - 1] * 2 + 1;
	}

	cout << func(n, x) << endl;

	









	getchar();
	getchar();
	return 0;
}

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

using namespace std;

int main()
{
	// 入力
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < h.size(); i++)
	{
		cin >> h[i];
	}
	
	int answer = 0;
	for (int i = 0; i < N; i++)
	{
		// 身長がKcm以上
		if (K <= h[i])
		{
			answer++;
		}
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
	char S[27];
	int i, j,flag=1;

	scanf("%s", S);

	i = 0;

	while (S[i] != '\0')
	{
		for (j = i + 1; S[j] != '\0'; j++)
		{
			if (S[i] == S[j])
			{
				flag = 0;
				break;
			}
		}
		i++;
	}

	if (flag == 1)
		printf("yes\n");
	else
		printf("no\n");

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    String ans = (n + 1) / 2 >= k ? "YES" : "NO";
    System.out.println(ans);
  }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, a, b; cin >> n >> a >> b, --a, --b;
  V<> x(n), y(n);
  map< int, set<int> > ys, xs;
  map< pair<int, int>, int > xy2i;
  for (int i = 0; i < n; ++i) {
    int _x, _y; cin >> _x >> _y;
    x[i] = _x - _y;
    y[i] = _x + _y;
    ys[x[i]].insert(y[i]);
    xs[y[i]].insert(x[i]);
    xy2i[{x[i], y[i]}] = i;
  }

  lint d = max(abs(x[b] - x[a]), abs(y[b] - y[a]));
  V<> c(n);
  {
    map< int, V<> > ys, xs;
    for (int i = 0; i < n; ++i) {
      ys[x[i]].push_back(y[i]);
      xs[y[i]].push_back(x[i]);
    }
    for (auto&& e : ys) sort(begin(e.second), end(e.second));
    for (auto&& e : xs) sort(begin(e.second), end(e.second));
    for (int i = 0; i < n; ++i) {
      if (ys.count(x[i] + d)) {
        c[i] += upper_bound(begin(ys[x[i] + d]), end(ys[x[i] + d]), y[i] + d) - lower_bound(begin(ys[x[i] + d]), end(ys[x[i] + d]), y[i] - d);
      }
      if (ys.count(x[i] - d)) {
        c[i] += upper_bound(begin(ys[x[i] - d]), end(ys[x[i] - d]), y[i] + d) - lower_bound(begin(ys[x[i] - d]), end(ys[x[i] - d]), y[i] - d);
      }
      if (xs.count(y[i] + d)) {
        c[i] += lower_bound(begin(xs[y[i] + d]), end(xs[y[i] + d]), x[i] + d) - upper_bound(begin(xs[y[i] + d]), end(xs[y[i] + d]), x[i] - d);
      }
      if (xs.count(y[i] - d)) {
        c[i] += lower_bound(begin(xs[y[i] - d]), end(xs[y[i] - d]), x[i] + d) - upper_bound(begin(xs[y[i] - d]), end(xs[y[i] - d]), x[i] - d);
      }
    }
  }

  lint res = 0;
  bitset<100000> vis;
  auto dfs = [&](const auto& dfs, int i) -> void {
    assert(!vis[i]);
    vis[i] = true;
    res += c[i];
    ys[x[i]].erase(y[i]);
    if (ys[x[i]].empty()) ys.erase(x[i]);
    xs[y[i]].erase(x[i]);
    if (xs[y[i]].empty()) xs.erase(y[i]);
    while (ys.count(x[i] + d)) {
      auto itr = ys[x[i] + d].lower_bound(y[i] - d);
      if (itr == ys[x[i] + d].upper_bound(y[i] + d)) break;
      dfs(dfs, xy2i[{x[i] + d, *itr}]);
    }
    while (ys.count(x[i] - d)) {
      auto itr = ys[x[i] - d].lower_bound(y[i] - d);
      if (itr == ys[x[i] - d].upper_bound(y[i] + d)) break;
      dfs(dfs, xy2i[{x[i] - d, *itr}]);
    }
    while (xs.count(y[i] + d)) {
      auto itr = xs[y[i] + d].upper_bound(x[i] - d);
      if (itr == xs[y[i] + d].lower_bound(x[i] + d)) break;
      dfs(dfs, xy2i[{*itr, y[i] + d}]);
    }
    while (xs.count(y[i] - d)) {
      auto itr = xs[y[i] - d].upper_bound(x[i] - d);
      if (itr == xs[y[i] - d].lower_bound(x[i] + d)) break;
      dfs(dfs, xy2i[{*itr, y[i] - d}]);
    }
  };
  dfs(dfs, a);
  res >>= 1;
  cout << res << '\n';
}

Measured memory_bytes: 58880
N = int(input())
A = list(map(int, input().split()))
dic = {0:1}
sum_n = 0
count = 0


for a in A:
    sum_n += a
    if sum_n in dic:
        count += dic[sum_n]
        dic[sum_n] += 1
    else:
        dic[sum_n] = 1


print(count)

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define BR "\n"
#define SP " "
#define fcout cout << fixed << setprecision(18)

class point {
public:
  double x, y;
  point(double x0, double y0) {
    x = x0, y = y0;
  }
};

void kock(int d, point p1, point p2) {
  if (d == 0) return;

  double x0, y0, x1, y1, x2, y2;
  x0 = p1.x + (p2.x - p1.x) / 3;
  y0 = p1.y + (p2.y - p1.y) / 3;
  x2 = p2.x + (p1.x - p2.x) / 3;
  y2 = p2.y + (p1.y - p2.y) / 3;

  x1 = x0 + (x2 - x0) / 2 - (y2 - y0) / 2 * sqrt(3);
  y1 = y0 + (y2 - y0) / 2 + (x2 - x0) / 2 * sqrt(3);
  
  kock(d - 1, p1, point(x0, y0));
  fcout << x0 << SP << y0 << BR;

  kock(d - 1, point(x0, y0), point(x1, y1));
  fcout << x1 << SP << y1 << BR;

  kock(d - 1, point(x1, y1), point(x2, y2));
  fcout << x2 << SP << y2 << BR;

  kock(d - 1, point(x2, y2), p2);
}

int main() {

  int N; cin >> N;
  cout << "0 0" << BR;
  kock(N, point(0, 0), point(100, 0));
  cout << "100 0" << BR;
  return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

long long gcd(long long N, long long M){
    while (true){
        if (min(N,M)==0){
            return max(N,M);
        }else if (N>M){
            N%=M;
        }else{
            M%=N;
        }
    }
}

long long lcm(long long N, long long M){
    return N/gcd(N,M)*M;
}

int main(){
    int N;
    cin >> N;
    long long ans=1;
    for(int i=0; i<N; i++){
        long long T;
        cin >> T;
        ans=lcm(ans, T);
    }

    cout << ans << endl;

}

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

typedef long long ll;
typedef double ld;

#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll > 
#define pii pair< ll, ll > 
#define len length 
#define fi first
#define se second
#define dt cout<<"HEre\n";
#define sz size
const ll inf=1e18+1e17;
const ll mod = 1e9+7;


ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
const ll N = ( 1<<18);
void solve() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	int c=0,d=0;
	for ( int i=0;i<s.len();i++)
		if ( s[i]=='R')
			c++;
		else
			d++;
	int ans=min( c,d);
	int x=0,y=0;
	for ( int i=0;i<n-1;i++){
		if ( s[i]=='R')
			x++;
		else
			y++;
		int h=c-x,w=d-y;
		int xx=min( y,h);
		ans=min( xx + h - xx + y - xx,ans);
	}
	cout<<ans<<'\n';


}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	ll t=1;
//	cin>>t;
	for ( ll i=1;i<=t;i++){
	//	cout<<"Case #"<<i<<": ";
    	solve();
    }
    //	cout << clock() / double(CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 3708
from fractions import gcd

A,B = map(int,input().split())
C = gcd(A,B)
nse = set()

for i in range(1,int(C**0.5+1)):
  if C%i == 0:
    nse.add(i)
    nse.add(C//i)
    
nli = list(nse)
nli.sort()
size = len(nli)

for i in range(1,size):
  n = nli[i]
  for j in range(i+1,size):
    if nli[j]%n == 0 :
      nse.add(nli[j])
      nse.remove(nli[j])

print(len(nse))

Measured memory_bytes: 78328
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c&&c<=b){
		print("Yes");
		return 0;
	}
	print("No");

}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
for i in d.items():
    if i[0] != 0 and i[1] == 1:
        print(0)
        quit()
    elif i[1] > 2:
        print(0)
        quit()
print(pow(2,n//2,mod))
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

int main() {

ll a,b; cin>>a>>b;  
  int ans=-1;

  rep(i,10000){
   if( i*0.08>=a && i*0.08<a+1 && i*0.1>=b && i*0.1<b+1 )
   { ans=i; break; }  
  }
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll n, i, a[100001], sum=0, ans=0, ans2=INF;

    cin >> n;

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

    // 正からスタート
    if(a[1]<=0){
        sum = 1;
        ans += abs(a[1]-1);
    }
    else{
        sum = a[1];
    }
    for(i=2; i<=n; i++){
        if(sum>0){
            if(sum+a[i]<0){
                sum += a[i];
            }
            else{
                ans += abs(sum+a[i]+1);
                sum = -1;
            }
        }

        else{
            if(sum+a[i]>0){
                sum += a[i];
            }
            else{
                ans += abs(sum+a[i]-1);
                sum = 1;
            }
        }
    }
    chmin(ans2, ans);

    // 負からスタート
    sum = 0;
    ans = 0;
    if(a[1]>=0){
        sum = -1;
        ans += abs(a[1]+1);
    }
    else{
        sum = a[1];
    }
    for(i=2; i<=n; i++){
        if(sum>0){
            if(sum+a[i]<0){
                sum += a[i];
            }
            else{
                ans += abs(sum+a[i]+1);
                sum = -1;
            }
        }

        else{
            if(sum+a[i]>0){
                sum += a[i];
            }
            else{
                ans += abs(sum+a[i]-1);
                sum = 1;
            }
        }
    }
    chmin(ans2, ans);
    
    cout << ans2 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

int main(){
  string s;
  cin>>s;
  if(s=="RRR") cout<<3<<endl;
  else if(s=="SSS") cout<<0<<endl;
  else if(s=="RRS" || s=="SRR") cout<<2<<endl;
  else cout<<1<<endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

int main()
{
    int r, d, x;
    cin >> r >> d >> x;

    x = r * x - d;
    for (int i = 1; i <= 10; i++)
    {
        cout << x << endl;
        x = r * x - d;
    }

    return 0;
}

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

int main(){
  char c[3][3];
  char n;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> n;
      c[i][j] = n;
    }
  }
  cout << c[0][0] << c[1][1] << c[2][2] << endl;

  return 0;
}

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

int main(void){
	int i,j,n;
	double d,c[2][3];

	cin>>n;
	while(n--){
		for(i=0;i<2;i++) for(j=0;j<3;j++) cin>>c[i][j];

		d = sqrt( pow( c[1][0] - c[0][0], 2 ) + pow( c[1][1] - c[0][1], 2 ) );

		if(c[0][2] <= c[1][2] && d + c[0][2] < c[1][2]){
			cout<<"-2\n";
		}
		else if(c[0][2] >= c[1][2] && d + c[1][2] < c[0][2]){
			cout<<"2\n";
		}
		else if(d > c[0][2] + c[1][2]){
			cout<<"0\n";
		}
		else{
			cout<<"1\n";
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;

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

    String s = sc.next();

    String[] weather = {"Sunny", "Cloudy", "Rainy", "Sunny"};

    for(int i = 0; i < 3; i++){
      if(s.equals(weather[i])){
        System.out.println(weather[i + 1]);
        break;
      }
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  int AC = 0, WA = 0, TLE = 0, RE = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "AC") {
      AC++;
    }
    else if (s == "WA") {
      WA++;
    }
    else if (s == "TLE") {
      TLE++;
    }
    else if (s == "RE") {
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3624
import sys

def I(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))

#実家DPと気合い遷移式

def main():
    N = I()
    a = LI()
    t = [0, 0, 0]
    for ai in a:
        t[ai-1] += 1
    A, B, C = t
    E = B+C

    dp = [[0 if (not i|j) else N/(i+j) for j in range(E+1)] for i in range(N+1)]

    for k in range(C+1):
        for j in range(E+1-k):
            for i in range(N+1-k-j):
                z = i+j+k
                if (not z):
                    continue
                d = dp[i][j]
                if (i<N):
                    dp[i+1][j] += (i+1)*d/(z+1)
                if (i>0)&(j<E):
                    dp[i-1][j+1] += (j+1)*d/z
                if (j>0)&(k<C):
                    dp[i][j-1] = (k+1)*d/z + N/z

    print(dp[A][B])

if __name__ == "__main__":
    main()

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

int main() {
  ll n;
  cin >> n;
  vector<set<ll>>  tree(n);
  map<pll,ll> I;
  vector<pll> vp; 
  for(ll i=0;i<n-1;i++) {
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].insert(b);
    tree[b].insert(a);
    vp.push_back(pll(a,b));
  }
  ll k=0;
  queue<ll> q;
  q.push(0);
  vector<ll> color(n,0);
  vector<bool> al(n,false);
  al[0]=true;
  while(q.size()) {
    ll f=q.front();
    q.pop();
    ll cur=1;
    if(k<tree[f].size()) k=tree[f].size();
    for(ll t:tree[f]) {
      if(al[t]) {
        continue;
      }
      if(cur==color[f]) cur++;
        color[t]=I[pll(f,t)]=I[pll(t,f)]=cur++;
        al[t]=true;
        q.push(t);
    }
  }
  cout << k << endl;
  for(pll i:vp) {
    cout << I[i] << endl;
  }
}

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

class Main {

	void solve() {

		int a = inint(), b = inint(), c = inint(), d = inint();
		if (Math.abs(a-c)<=d || (Math.abs(a-b)<=d && Math.abs(b-c)<=d)) {
			out.println("Yes");
		}
		else out.println("No");

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int N;
    int M;

    int goal[100000];
    int i;
    cin>>N>>M;
    int sum=0;
    for(i=0;i<M;i++){
        cin>>goal[i];
        sum+=goal[i];
    }
    sort(goal,goal+M);
    int adjacent_length[100000];
    for(i=0;i<M-1;i++){
        adjacent_length[i]=goal[i+1]-goal[i];
    }
    sort(adjacent_length,adjacent_length+M-1);
    int answer;
    for(i=0;i<M-N;i++){
        answer+=adjacent_length[i];
    }
    cout<<answer<<endl;
}

Measured memory_bytes: 1024
N = int(input())
T = list(map(int, input().split()))
M = int(input())
ans = 0
for i in range(M):
    P, X = map(int, input().split())
    ans += sum(T[0:P-1])
    ans += X
    ans += sum(T[P:len(T)])
    print(ans)
    ans = 0


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

typedef pair<int, int> P;
int INF = 2'000'000'000;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n);
    int u, v;
    for (int i = 0; i < m; i++){
        cin >> u >> v;
        u--; v--;
        edge[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    vector<vector<int>> distance(n, vector<int>(3, INF));
    vector<vector<bool>> check(n, vector<bool>(3, false));
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, s});

    for (int i = 0; i < 3*m; i++){
        if (que.size() == 0) break;
        int x = que.top().first;
        int y = que.top().second;
        que.pop();
        if (y == t && x % 3 == 0){
            cout << x / 3 << endl;
            exit(0);
        }
        if (distance[t][2] != INF) break;
        for (int j = 0; j < 3; j++){
            if (distance[y][j] > x) {
                if (j == 0) {
                    distance[y][j] = x;
                    check[y][j] = true;
                    break;
                }
                else if (j == 1 && distance[y][0] % 3 != x % 3){
                    distance[y][j] = x;
                    check[y][j] = true;
                    break;
                }
                else if (j == 2 && distance[y][0] % 3 != x % 3 && distance[y][1] % 3 != x % 3){
                    distance[y][j] = x;
                    check[y][j] = true;
                    break;
                }
            }
        }
        int k = (int)edge[y].size();
        for (int pp = 0; pp < 3; pp++){
            if (!check[y][pp]) continue;
            int nx = distance[y][pp] + 1;
            for (int j = 0; j < k; j++){
                int ny = edge[y][j];
                que.push({nx, ny});
            }
        }

        for (int pp = 0; pp < 3; pp++){
            check[y][pp] = false;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 18176
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
#define EPS 1e-8
#define equals(a,b) fabs((a) - (b)) < EPS

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

struct Point {
	double x, y;

	Point(double x=0, double y=0) : x(x), y(y) {}

	Point operator+(const Point &o) const { return Point(x+o.x, y+o.y); }

	Point operator-(const Point &o) const { return Point(x-o.x, y-o.y); }

	Point operator*(const double m) const { return Point(x*m, y*m); }

	Point operator/(const double d) const { return Point(x/d, y/d); }

	bool operator<(const Point &o) const { return x != o.x ? x < o.x : y < o.y; }

	bool operator==(const Point &o) const { return fabs(x-o.x) < EPS && fabs(y-o.y) < EPS; }
};

ostream& operator << (ostream& os, const Point& p) {
	os << "(" << p.x << ", " << p.y << ")";
	return os;
}

double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
double atan(Point p) { return atan2(p.y, p.x); }
double norm(Point p) { return p.x * p.x + p.y * p.y; }
double abs(Point p) { return sqrt(norm(p)); }
double distancePP(Point p, Point o) { return sqrt(norm(o - p)); }

int ccw(Point a, Point b, Point c) {
	b = b-a;
	c = c-a;

	if(cross(b, c) > 0.0) return +1;	//conter clockwise
	if(cross(b, c) < 0.0) return -1;	//clockwise
	if(dot(b, c) < 0.0) return +2;	//a on Seg(b,c)
	if(norm(b) < norm(c)) return -2;	//b on Seg(a,c)
	return 0;	//c on Seg(a,b)
}

bool cmp_y(const Point& a,const Point& b) {
	if(a.y != b.y) return a.y < b.y;
	return a.x < b.x;
}

vector<Point> convex_hull(vector<Point> ps) {   
	int n = ps.size();
	sort(ps.begin(),ps.end(), cmp_y);

	int k = 0;
	vector<Point> convex(n*2);

	rep(i, n) {
		while (k > 1 && ccw(convex[k-2], convex[k-1], ps[i]) == -1 ) {
			k--;
		}
		convex[ k++ ] = ps[i];
	}

	for(int i = n - 2, t = k; i >= 0; i--) {
		while (k > t && ccw(convex[k-2], convex[k-1], ps[i]) == -1 ) {
			k--;
		}
		convex[ k++ ] = ps[i];
	}

	convex.resize(k-1);
	return convex;
}

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

	vector<Point> v(n);
	rep(i, n) cin >> v[i].x >> v[i].y;

	vector<Point> ret = convex_hull(v);

	cout << ret.size() << endl;
	rep(i, ret.size()) {
		cout << ret[i].x << " " << ret[i].y << endl;
	}

	return 0;
}

Measured memory_bytes: 7268
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int N, M, Q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A){
    //base case
    if(A.size() == N + 1){
        int now = 0;
        for(int i = 0; i < Q; ++i){
            if(A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)) now += d.at(i);
        }
        ans = max(ans, now);
        return;
    }
    //recursion step
    //make vector A
    A.push_back(A.back());
    //M: maximum of A.at(i)
    while(A.back() <= M){
        dfs(A);
        A.back()++;
    }
    return;
}

int main()
{
    cin >> N >> M >> Q;
    a = b = c = d = vector<int>(Q);
    for(int i = 0; i < Q; ++i){
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
  int N,T;
  cin>>N>>T;
  int c, t;
  int mini = 10000;
  int frag = 1;

  for(int ii=0; ii<N; ii++){
    cin>>c>>t;
    if(t<=T){
      mini = min(mini,c);
    }
  }

  if(mini == 10000){
    cout<<"TLE"<<endl;
  }
  else{
    cout<<mini<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,j,k,n,m,x,y,s;
    cin>>n;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;

}


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

int main(){
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int position = 0;
    for (int i = 0; i < Q; ++i){
        
        int T;
        cin >> T;
        if ( T == 1 ){
            if ( position == 0 ) {
                position = 1;
            } else if ( position == 1 ) {
                position = 0;
            };
        } else {
            int F;
            string C;
            cin >> F >> C;
            if ( (F == 1 and position == 0) or (F == 2 and position == 1) ){
                S.insert(0,C);
            } else {
                S.append(C);
            }
        }
    }
    if ( position == 1){
        reverse(S.begin(), S.end());
    }

    cout << S << endl;
    
    return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;


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

    map<char, vector<int>> position;
    rep(i,S.size()){
        position[S[i]].push_back(i);
    }

    ll ans = 0;
    int prev_index = 0;
    rep(i,T.size()){
        char t = T[i];

        if (position[t].empty()){
            cout << -1 << endl;
            return 0;
        }
        if (i == 0){
            prev_index = position[t][0];
            ans = prev_index;
        }
        else{
            int size = position[t].size();
            vector<int> c = position[t];
            int next_index;
            if (prev_index >= c[size-1]){
                next_index = c[0];
            }
            else{
                int ng = -1;
                int ok = c.size();
                while(abs(ok-ng) > 1){
                    int mid = (ok+ng)/2;
                    if (c[mid] > prev_index) ok = mid;
                    else ng = mid;
                }

                next_index = c[ok];
            }
            if (prev_index < next_index){
                ans += next_index-prev_index;
            }
            else{
                ans += next_index + (S.size() - prev_index);
            }
            prev_index = next_index;
        }

        
    }

    cout << ans+1 << endl;
}

Measured memory_bytes: 4432
#include <iostream>
#include <string>
using namespace std;
int main() {
    // INPUT
    string S, T;
    cin >> S >> T;

    // SOURCE
    int count = 0;
    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] != T[i]) ++count;
    }

    // OUTPUT
    cout << count << endl;

    return 0;
}


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

int main(){
  vector<uint64_t> vec(99);
  vec.at(0) = 2;
  vec.at(1) = 1;
  int N;
  cin >> N;
  if(N == 1)vec.at(N) = vec.at(1);
  if(N > 1)
    for(int i = 2; i <= N; i++)
      vec.at(i) = vec.at(i-1) + vec.at(i-2);
  
  cout << vec.at(N) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int H, N, a=0, b, t=0;
    cin>>H>>N;
    cout<<endl;
    a=N;
    while(a!=0){
        cin>>b;
        a=a-1;
        t=t+b;
    }
    if(t>H || t==H){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}


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

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


Measured memory_bytes: 256
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int a,b,c;
	sctd(a,b,c);
	int d=0;
	forin(i,a,b+1)
	{
		if(c%i==0)
		{
			d++;
		}
		
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

string S, T;

int main(){
	cin >> S >> T;
	for (int i = S.size() - T.size(); i >= 0; --i) {
		bool f = true;
		for (int j = 0; j < T.size(); ++j) {
			if (S[i + j] != T[j] && S[i + j] != '?') {
				f = false;
				break;
			}
		}
		if (f) {
			for (int j = 0; j < i; ++j) {
				if (S[j] == '?')cout << 'a';
				else cout << S[j];
			}
			cout << T;
			for (int j = i + T.size(); j < S.size(); ++j) {
				if (S[j] == '?')cout << 'a';
				else cout << S[j];
			}
			cout << endl;
			return 0;
		}
	}
	puts("UNRESTORABLE");
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
)

var scanner = bufio.NewScanner(os.Stdin)

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

func main() {
	input := nextLine()

	var n, x, t int
	if _, err := fmt.Sscanf(input, "%d %d %d", &n, &x, &t); err != nil {
		log.Fatalf("error reading input: %v", err)
	}

	fmt.Println(solve(n, x, t))
}

func solve(n, x, t int) int {
	return int(math.Ceil(float64(n)/float64(x))) * t
}


Measured memory_bytes: 1904