akhauriyash/Code-Regression huggingface dataset:
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<(type)> 
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/

/*
int prime[10000000] = {0} ;
void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 10000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*i ; j <= 10000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}
*/
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

ll fib(int n) 
{ 
  ll a = 0, b = 1, c, i; 
  if( n == 0) 
    return a; 
  for (i = 2; i <= n; i++) 
  { 
    c = (a + b); 
    a = b; 
    b = c; 
  } 
  return b; 
}


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



ll findgrouplcm(vector<int> &arr, int n) 
{ 
    ll ans = arr[0]; 
  
    for (ll i = 1; i < n; i++) 
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));
  
    return ans; 
}


ll powerwithmod(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
 

bool comp(const pair<ll,ll> &a , const pair<ll,ll> &b){
    return a.first > b.first;
}

void solve(){
    int n;
    in(n);
    int arr[n];
    ll sum = 0 ;
    f(i,n) {
        in(arr[i]);
        sum += arr[i];
    }
    int m;
    in(m);
    while(m--){
        int p,x;
        in(p)>>x;
        on(sum + x - arr[p-1]);
    }
}

int main() {
    fast();
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a);
        }

        b=b>>1;
        a=(a*a);
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli N,i;
    cin>>N;

    lli Value=Power(3LL,N);

    lli Value1=1;
    rep(i,0,N)
    {
        lli x;
        cin>>x;

        if(x%2==0)
        {
            Value1*=2;
        }
    }

    cout<<Value-Value1;




 return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c,d;
	
	scanf("%d %d %d",&a,&b,&c);

	if(a>b) {
	    d=a;
	    a=b;
	    b=d;
	}
	if(b>c) {
	    d=b;
	    b=c;
	    c=d;
	}
	if(a>b) {
	    d=a;
	    a=b;
	    b=d;
	}
	
	printf("%d %d %d\n",a,b,c);

	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   // ai + aj = j-i
   // ai+i = j - aj
   int n ;
   cin >> n ;
   map < ll ,  ll > mp ;
   vector < int  > a(n) ;
   for( int i = 0 ; i < n ; i++) cin >> a[i] ;
   for( int i = 0 ; i < n ; i++) mp[a[i]+i+1]++;
   ll ans = 0 ;
   for( int i = 0 ; i < n ; i++){
        ans += mp[i+1-a[i]] ;
   }
   cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << 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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  string s;cin>>s;
  if(s=="ABC")out("ARC");
  else out("ABC");

  return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int N;
    int a[10000];
    cin >> N;
    for (int i = 0; i < N; ++i) {
       cin >> a[i];
    }
    int totalcount =0;
    for (int i = 0; i < N; ++i) {
        int x = a[i];

        int count=0;
        for(;;){
            if(x%2 != 0){
                break;
            }
            x= x /2;
            count ++;
        }

        totalcount += count;

    }

    cout << totalcount;
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int MAX_N = 300;
int maxi,n,d[MAX_N];
bool reach[MAX_N][MAX_N];

int main(){
  while( cin >> maxi, maxi ){
    cin >> n;
    rep(i,n+10) d[i] = 0;
    REP(i,1,n+1) cin >> d[i];
    n += 2;
    rep(i,n) rep(j,n) reach[i][j] = false;
    rep(i,n) reach[i][i] = true;
    rep(i,n-1) {
      REP(j,1,maxi+1){
        int next = i + j;
        next = min(next,n-1);
        next += d[next];
        next = min(next,n-1);
        next = max(next,0);
        reach[i][next] = true;
      }
    }
    rep(k,n) rep(i,n) rep(j,n) if( reach[i][k] && reach[k][j] )reach[i][j] = true;
    bool success = true;
    rep(i,n) if( reach[0][i] && !reach[i][n-1] ) { success = false; break; }
    puts(success?"OK":"NG");
  }
  return 0;
}

Measured memory_bytes: 1192
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    k: i64,
    x: i64,
  }
  if k * 500 >= x {
    puts!("Yes\n");
  } else {
    puts!("No\n");
  }
}


Measured memory_bytes: 4352
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 read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let n: usize = read();
	let mut a: Vec<i64> = read_vec();
	let mut b: Vec<i64> = read_vec();

	let mut kill: i64 = 0;
	for i in 0..n {
		let left = std::cmp::min(a[i], b[i]);
		kill += left;
		a[i] -= left;
		b[i] -= left;

		let mut right = std::cmp::min(a[i+1], b[i]);
		kill += right;
		a[i+1] -= right;
		b[i] -= right;
	}
	println!("{}", kill);
}


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

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    long long int c[n + 1], a[n + 1][m + 1];
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
    }
    long long int ans = 1e+18;
    for (int k = 0; k < (1 << n); k++)
    {
        long long int fans = 0;
        long long int cst[m + 1] = {0};
        for (int i = 0; i < n; i++)
        {
            // cout<<(1 << (i))<<" " ;
            if ((k & (1 << (i))) != 0)
            {
                fans += c[i];
                for (int j = 0; j < m; j++)
                    cst[j] += a[i][j];
            }
        }
        // cout<<k<<" ";
        int g = 1;
        for (int i = 0; i < m; i++)
        {
            // cout<<cst[i]<<" ";
            if (cst[i] < x)
            {
                g = 0;
                break;
            }
        }
        // cout<<"\n";
        if (g)
            ans = min(ans, fans);
    }
    if (ans == 1e+18)
        cout << -1;
    else
        cout << ans;
}

Measured memory_bytes: 3648
import sys

input = sys.stdin.readline

P = 998244353


def main():
    N = int(input())
    if N % 2 == 1:
        print(0)
    else:
        ans = 0
        tmp = 10
        while True:
            if tmp > N:
                break
            ans += N // tmp
            tmp *= 5
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i,n)cin >> h[i];
	sort(ALL(h),greater<ll>());
	ll ans = 0;
	for(int i=k;i<n;++i)

	{
		ans+=h[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
function main(input){
    inputI = input.split('\n');
    number = parseInt(inputI[0]);
    inputS = Array(number);
    max=0;
    count=1;
  ex=0;

    for(i=1;i<=number;i++){
        inputS[i-1]=inputI[i];
    }

    inputS=inputS.sort();

    for(i=1;i<=number;i++){
        if(inputS[i-1]==inputS[i]){
            count++;
        }
        else if(max<count){
            max=count;
            count=1;
        }
        else{
            count=1;
        }
    }
  	count=1;
    for(i=1;i<=number;i++){
        if(inputS[i-1]==inputS[i]){
            count++;
        }
        else if(max==count){
          console.log(inputS[i-1]);
          count=1;
          ex=1;
        }
        else{
            count=1;
        }
    }
  	if(ex==0){
      console.log(inputS[0]);
       }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 39424
S = list(input())
T = list(input())
ans = 0
for i in range(len(S)-len(T)+1):
    #print(S[i])
    tmp_count = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            tmp_count += 1
    ans = max(ans, tmp_count)
print(len(T)-ans)

Measured memory_bytes: 64940
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N;
	cin>>N;
	
	int mx;
	rep1(i,1e4){
		if(i*(i+1)/2>=N){
			mx=i;
			break;
		}
	}
	int sum=N;
	int prob=mx;
	while(sum>0){
		if(sum>=prob){
			cout<<prob<<endl;
			sum-=prob;
		}
		prob--;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll A[100010], mx=1000000000000000000;

int main(void){
    ll A;
    string B;
    cin >> A >> B;
    int bb=(B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');
    cout << (A*bb)/100 << endl;
    return 0;
}


Measured memory_bytes: 3620
N, x = map(int, input().split())

n=list(map(int, input().split()))
m = sorted(n)

ans=0
for i in range(N):
	x=x-m[i]
	if x < 0:
		break
	else:
		ans+=1
        
if x>0:
  ans-=1

print(max(ans,0))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String[] s = { scan.next(), scan.next(), scan.next() };
		int[] index = { 0, 0, 0 };

		int turn = 0;
		char next;
		while (true) {
			if (s[turn].length() == index[turn]) {
				break;
			}
			next = s[turn].charAt(index[turn]);
			index[turn]++;
			switch (next) {
			case 'a':
				turn = 0;
				break;
			case 'b':
				turn = 1;
				break;
			case 'c':
				turn = 2;
				break;
			}
		}
		switch (turn) {
		case 0:
			System.out.println("A");
			break;
		case 1:
			System.out.println("B");
			break;
		case 2:
			System.out.println("C");
			break;
		}
	}
}


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

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

  vector<vector<int>> vec(M);
  for (int i = 0; i < M; i++)
  {
    int k; cin >> k;
    for (int j = 0; j < k; j++)
    {
      int s; cin >> s;
      s--;
      vec[i].push_back(s);
    }
  }

  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p[i];
  
  int ans = 0;
  for (int i = 0; i < (1<<N); i++)
  {
    bool check = true;
    for (int j = 0; j < M; j++)
    {
      int cnt = 0;
      for (int k = 0; k < vec[j].size(); k++)
      {
        if (i / (1 << vec[j][k]) % 2 == 1) cnt++;
      }
      if (cnt % 2 != p[j]) {
        check = false;
        break;
      }
    }

    if (check) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
use std::collections::HashMap;

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 mut hashMap: HashMap<char, i32> = HashMap::new();

    for c in s.chars(){

        let count = hashMap.entry(c).or_insert(0);
        *count += 1;
    }

    let mut is_beautiful = true;

    for (c, v) in hashMap.iter() {
        if v % 2 == 1 {
            is_beautiful = false;
            break;
        }
    }

    if is_beautiful {
        println!("Yes")
    } 
    else {
        println!("No")
    }
}



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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  vector<int> a(3), b(3);
  a[0] = 0;
  b[0] = c[0][0];
  for (int i = 1; i < 3; i++) {
    b[i] = c[0][i] - a[0];
    a[i] = c[i][0] - b[0];
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (c[i][j] != a[i] + b[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
n,a=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0 for _ in range(50*n+1)] for j in range(n+1)] for _ in range(n+1)] #dp[n][n][n*50]=cnt
dp[0][0][0] = 1
for i in range(1, n+1):
    for j in range(i+1):
        for k in range(50*n+1):
            if i > 0:
                dp[i][j][k] = dp[i-1][j][k]
                if k >= x[i-1]:
                    dp[i][j][k] += dp[i-1][j-1][k-x[i-1]]

ans = 0
for j in range(1,n+1):
    ans += dp[n][j][a*j]
print(ans)


Measured memory_bytes: 95964
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   long long r,D,x;

   cin >> r >> D >> x;
   for(int i=0; i<10; i++){
      x = x*r-D;
      cout << x << endl;
   }
   
   return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        N: usize,
        XLs: [(i64, i64); N],
    }

    // 間違い
    // let mut sorted_XLs: Vec<(i64, i64, i64)> = XLs.iter().map(|&(x, l)| (x - l, l, x)).collect();

    let mut sorted_XLs: Vec<(i64, i64, i64)> = XLs.iter().map(|&(x, l)| (x + l, l, x)).collect();

    sorted_XLs.sort();

    // 正当性が示せてないけど、いったん貪欲でやってみるか。
    // 一番左のものは必ず使うことにする
    // 手が左のものから順に見ていくが、横幅が小さいものを優先

    // 貪欲法なのは正しかったが、進め方が間違いだった。
    // 右手でどこまでいったかを見つつ左手がひっかからないように進めた場合、敷き詰めるような形になるから効率的ではないね。できるだけ右手が前に進まないようなものを選ぶべき。
    let mut ans: i64 = 0;
    let mut right = sorted_XLs[0].0;
    ans += 1;

    for i in 1..N {
        let (this_right, l, x) = sorted_XLs[i];
        let left = x - l;
        if right <= left {
            // 採用
            ans += 1;
            right = this_right;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 8800
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<iomanip>
#define INF INT_MAX
using namespace std;

int a, b;

int main(){
	cin >> a >> b;
	a = a * b;
	a /= 2;
	cout << a << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
 int main(){
  int n, a; 
  int y=0;
  int l, m, k;
  scanf("%d", &n);
  int data[n];
  char c[12];
  int i;
 for(i=0;i<n;i++){
    scanf("%s %d",c,&a);
    if(c[0]=='i'){
    data[i]=a;
    }
 else if(c[6]=='F'){
    i-=2;
    n-=2;
    }
 else if(c[6]=='L'){
    i--;
    n--;
    y++;
  }
 else{
    i--;
    n--;
    l=0;
    int j;
    for(j=i;j>=0;j--){
    if(l>0) break;
    if(a==data[j]){
      k=0;
      m=i-j;
      l++;
      while(m!=k++)
    data[j+k-1]=data[j+1+k-1];
      i--;
      n--;
        }  
      }
    }
  }
  for(i=0;i<n-y;i++){
    if(i==n-y-1)
      printf("%d\n",data[n-1-i]);
    else
      printf("%d ",data[n-1-i]);
  }
  return 0;
}

Measured memory_bytes: 6056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> B[101010];
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        B[a].emplace_back(b);
    }
    priority_queue<int> pq;
    ll ans = 0;
    rep(i, m + 1) {
        for (auto b : B[i]) pq.emplace(b);
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}

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


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

using namespace std;

int main (){

    
    int N;
    cin >> N;
    vector<int> a(N+1), b(N+1);
    a[0] = 0, b[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        b[i] = a[i];
        
    }
    
   
    /*
    int N = 200000;
    
    vector<int> a(N+1), b(N+1);
    a[0] = 0, b[0] = 0;
    for (int i = 1; i <= N; i++) {
        a[i] = 1;
        b[i] = a[i];
        
    }
    
    */
    
    int ans = 0;
    
    
    for (int i = N/2; i >= 1; i--) {
        int aa = 0;
        b[i] = 0;
        for (int j = i; j <= N; j += i) {
            aa += b[j];
            if (aa%2 == a[i]) {
                b[i] = 0;
            }else{
                b[i] = 1;
            }
        }
        
    }
    
    for (int i = 1; i <= N; i++) {
        ans += b[i];
        
    }
    cout << ans << endl;
    
    if (ans != 0) {
        for (int i = 1; i <= N; i++) {
            if (b[i] == 1) {
                cout << i << " ";
            }
        }
        cout << endl;
    }

    
    
    

}


Measured memory_bytes: 2432
#include <stdio.h>
#include <stdlib.h>
int main() {
  int *a,n,j,i;
  int count=0,tmp=0;
  scanf("%d",&n);
  a=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
      scanf("%d",&a[i]);
  }
  for (i = 0; i < n; i++) {
    for (j = n-1 ; j >=1 ; j--) {
      if (a[j]<a[j-1]) {
        tmp=a[j-1];
        a[j-1]=a[j];
        a[j]=tmp;
        count++;
      }
    }
}
  for(i=0;i<n;i++){
    if (i!=n-1) printf("%d ",a[i]);
    else printf("%d\n",a[i]);
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll m,d;
	cin>>m>>d;
	ll ans=0;
	for(ll i=1;i<=m;i++)
	{
		for(ll j=1;j<=d;j++)
		{
			if((j%10)*(j/10)==i&&(j%10>=2)&&(j/10)>=2)
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

tmp = 1
a_arr.each do |a|
  if a == tmp then
    tmp += 1
  end
end

if tmp == 1 then
  puts -1
else
  puts a_arr.length - tmp + 1
end


Measured memory_bytes: 16772
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		String s = sc.next();
		char[] sa = s.toCharArray();
		int n = sa.length;
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			if(Integer.parseInt(s.substring(i, i + 1)) == i % 2) {
				cnt++;
			}
		}
		if(n - cnt < cnt) cnt = n - cnt;
		System.out.println(cnt);
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 29900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	
 ll n;
 cin>>n;
 ll a[n+1];
 ll k=1;
 std::vector<ll>v ;
 for(ll i=1;i<=n;i++)
 {
     cin>>a[i];
     if(a[i]==k)
     {
         v.push_back(k);
         k++;
     }
 }
 if(v.size()==0)
 {
     cout<<"-1\n";
 }
 else
 {
     cout<<n-v.size()<<"\n";
 }
}

Measured memory_bytes: 6648
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    int a, b, k;
    cin >> a>> b>>k;

    if(k>(b-a)/2){
        FOR(i,a,b){
            cout << i << "\n";
        }
        cout << b << "\n";
    }else{
        FOR(i,a,a+k){
            cout << i << "\n";
        }
        FOR(i,b-k+1,b+1){
            cout << i << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,ma;
    cin >> n >> ma;
    vi w(n),v(n);
    rep(i,n)cin >> w[i] >> v[i];
    vector<vi> dp(n+1,vi(ma+1));
    //dp[i][j] := 重さが j のときの価値の最大値
    rep(i,n)rep(j,ma+1){
        dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        if(j+w[i] <= ma)dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i]);
    }
    int ans = 0;
    rep(i,ma+1)ans = max(ans, dp[n][i]);
    cout << ans << endl;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const int INF = 1001001001;
const ll mod = 998244353;
const ll INFL = 1001001001001001000;

vector<ll> divisor(ll N) {
    vector<ll> RES;
    for (ll I = 1; I*I <= N; I++) {
        if (N%I == 0) {
            RES.push_back(I);
            if (I != N/I) RES.push_back(N/I);
        }
    }
    return RES;
}

ll gcd(ll A, ll B) {
    return B ? gcd(B,A%B) : A;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main() {
    ll n; cin >> n;
    if (n <= 100) {
        ll k = 1;
        while (1) {
            if ((k*(k+1)/2)%n == 0) {
                cout << k << endl;
                return 0;
            }
            k++;
        }
    }
    vector<ll> divi = divisor(2*n);
    ll ans = INFL;
    for (ll pp : divi) {
        ll p = pp;
        ll q = (2*n)/p;
        if (p > q) continue;
        ll g = gcd(p,q);
        if (g != 1) continue;
        ll a,b;
        extGCD(p,q,a,b);
        a = -a;
        //printf("%lld %lld\n", a,b);
        if (a == 0 || b == 0) continue;
        if (a < 0) {
            ll dd1 = (-a+q-1)/q;
            ll dd2 = (-b+p-1)/p;
            ll dd = max(dd1, dd2);
            a += q*dd;
            b += p*dd;
        }
        //printf("a = %lld, b = %lld\n", a,b);
        ans = min(ans, min(p*a, q*b-1));
        swap(p,q);

        extGCD(p,q,a,b);
        a = -a;
        //printf("%lld %lld\n", a,b);
        if (a == 0 || b == 0) continue;
        if (a < 0) {
            ll dd1 = (-a+q-1)/q;
            ll dd2 = (-b+p-1)/p;
            ll dd = max(dd1, dd2);
            a += q*dd;
            b += p*dd;
        }
        //printf("a = %lld, b = %lld\n", a,b);
        ans = min(ans, min(p*a, q*b-1));
        
    }
    cout << ans << endl;
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0.0;
    rep1(i, n) {
        double p = 1.0;
        for (int j=i; j<k; j*=2) p /= 2.0;
        ans += p / n;
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
a;b;main(t){
    scanf("%d%d",&a,&b);
    t=b;
    while(t)t/=10,a*=10;
    a+=b;    
    
    if( pow( (int)sqrt((float)a) ,2)==(float)a   )
        printf("Yes\n");
    else
        printf("No\n");
    
}

Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	string rank;
	cin >> rank;
	vector<string> res(n);
	for(int i=0;i<n;i++){
		if (a+b>0&&rank.at(i) == 'a') {
			res.at(i) = "Yes";
			(a>0) ? a-- : b--;
		}
		else if(b > 0 && rank.at(i) == 'b') {
			res.at(i) = "Yes";
			b--;
		}
		else res.at(i) = "No";
	}
	cout << res.at(0);
	for (int i = 1; i < n; i++)cout << endl << res.at(i);
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int A[100001][11][2];
int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int,int>> E;
	for (int i = 0; i < M; ++ i) {
		int a, b;
		cin >> a >> b;
		-- a; -- b;
		E.push_back({a,b});
	}
	int Q;
	cin >> Q;
	for (int i = 1; i <= Q; ++ i) {
		int v, d, c;
		cin >> v >> d >> c;
		-- v;
		A[v][d][0] = c;
		A[v][d][1] = i;
	}
	for (int d = 10; d >= 1; -- d) {
		for (auto p : E) {
			int a = p.first;
			int b = p.second;
			for (int k = 0; k < 2; ++ k) {
				if (A[a][d][1]) {
					if (A[b][d-1][1] < A[a][d][1]) {
						// cerr << a << " " << b << " " << d << endl;
						A[b][d-1][0] = A[a][d][0];
						A[b][d-1][1] = A[a][d][1];
					}
				}
				swap(a, b);
			}
		}
	}
	for (int i = 0; i < N; ++ i) {
		int c = 0;
		int t = 0;
		for (int d = 0; d <= 10; ++ d) {
			if (A[i][d][1] > t) {
				c = A[i][d][0];
				t = A[i][d][1];
			}
		}
		cout << c << endl;
	}
}


Measured memory_bytes: 10100
n,m = map(int,input().split())

def gcd(a, b):
  a, b = (a, b) if a >= b else (b, a)
  while b > 0:
    a, b = b, a % b
  return a

gc = gcd(n,m)
lcm = n * m // gc
s = input()
t = input()

if s[::n//gc] == t[::m//gc]:
  print(lcm)
else:
  print(-1)

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

long long n, W, dp[105][100005], w[105], v[105];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> W;
    for(int i=1; i<=n; i++)
        cin >> w[i] >> v[i];

    for(int i=1; i<=n; i++)
        for(int j=1; j<=W; j++) {
            if(j>=w[i]) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            }
            else dp[i][j] = dp[i-1][j];
        }
    cout << dp[n][W] << endl;

    return 0;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;

int n;
V<int> a;

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

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

    int x = *max_element(begin(a), end(a));
    int y = -1;

    auto shift = [&](int x, int y) {
        if (x % 2 == 0 || y < x/2) return abs(x/2-y);
        return abs((x+1)/2-y);
    };

    for (int i = 0; i < n; i++) {
        if (a[i] == x) continue;
        if (shift(x, a[i]) < shift(x, y)) {
            y = a[i];
        }
    }
    printf("%d %d\n", x, y);
    return 0;
}

Measured memory_bytes: 640
import sys

N = int(input())

list = []
for i in range(0, N):
    x, y, h = [int(x) for x in input().split()]
    list.append((x, y, h))
    # if (h != 0):
    # list.append((x, y, h))

for X in range(0, 101):
    for Y in range(0, 101):
        b = True
        H = 0
        for Cx, Cy, Ch in list:
            if Ch != 0:
                H = Ch + abs(X - Cx) + abs(Y - Cy)
        for Cx, Cy, Ch in list:
            h = max(H - abs(X - Cx) - abs(Y - Cy), 0)
            if Ch != h:
                b = False
        if b == True:
            print(X, Y, H)
            sys.exit(0)


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

int main() {
  int n,m; cin >>n >>m;
  vector<bool> from1(n+1,false), ton(n+1,false);
  for (int i=0; i<m; i++){
    int bufa, bufb;
    cin >>bufa >>bufb;
    if (bufa==1) from1.at(bufb) = true;
    if (bufb==n) ton.at(bufa) = true;
  }
  
  bool possible = false;
  for (int i=0; i<n+1; i++){
    if (from1.at(i) && ton.at(i)){
      possible = true;
      break;
    }
  }
  
  if(possible) cout <<"POSSIBLE" <<endl;
  else cout <<"IMPOSSIBLE" <<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool agct(char s){
    return s=='A'||s=='C'||s=='G'||s=='T';
}
int main() {
    string s;
    cin>>s;
    bool cont=true;
    int Max=0;
    int count=0;
    for(int i=0;i<s.length();i++){
        if(!agct(s[i])){Max=max(Max,count);cont=false;}
       else{
           if(!cont&&agct(s[i])){
            cont=true;count=0;
            }
            if(cont){count++;}
        }
    }
    Max=max(Max,count);
    cout<<Max<<endl;
    return 0;
}

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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//____________________


int32_t main()
{ 
  io;  

  int n,x;
  cin>>n;
  multiset<int> a,b;
  for(int i=0;i<n;i++)
  {
    cin>>x;
    a.insert(x);
  }

  while(true)
  {
    if(a.size()==1) break;
    auto it=a.begin();
    x=*it;
    ++it;
    for(;it!=a.end();++it)
    {
      int y=*it;
      if(y%x)
        b.insert(y%x);
    }
    b.insert(*a.begin());
    a.clear();
    a=b;
    b.clear();
  }
  cout<<*a.begin();
 return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int K, N; cin >> K >> N;
    vi v(N);
    rep(i, N) cin >> v[i];

    int ans = 0;

    rep(i, N){

        int tmp = 0;

        if (i == 0){
            tmp = max(K - v[N-1] + v[0], v[1] - v[0]);
        }
        else if (i == N-1) {
            tmp = max(v[N-1] - v[N-2], K - v[N-1] + v[0]);
        }
        else {
            tmp = max(v[i] - v[i-1], v[i+1] - v[i]);
        }

        ans = max(ans, tmp);
    }

    cout << K - ans << endl;
    return 0;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <iomanip>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std ;

inline LL read() {
	LL x = 0 , f = 1 ;
	char ch = getchar() ;
	while(ch<'0'||ch>'9') { if(ch=='-') f = -1 ; ch = getchar() ; }
	while(ch>='0'&&ch<='9') { x = x * 10+ch-48 ; ch = getchar() ; }
	return x * f ;
}

const int N = 1e5+11;
int n,x,y,S;
int a[N];
inline bool cmp(int a,int b) {
	return a > b;
} 

int main() {
	n=read();
	For(i, 1, n) a[i]=read();
	sort(a+1,a+n+1,cmp); 
	For(i, 1, n-1) 
		if(a[i]==a[i+1]) {
			x = a[i];
			S = i+2;
			break;
		}
	For(i, S, n-1) 
		if(a[i]==a[i+1]) {
			y = a[i];
			break;
		}
	printf("%lld\n",1ll*x*y);
}









Measured memory_bytes: 640
S = int(input())
s1 = (S-S%1000)/1000
k1 = S - s1*1000
s2 = (k1-k1%100)/100
k2 = k1 - s2*100
s3 = (k2-k2%10)/10
s4 = S - (s1*1000 + s2*100 + s3*10)
 
if s1 == s2 or s2 == s3 or s3 == s4:
    print("Bad")
else:
    print("Good")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  if(a+b>c+d){
    cout << "Left" << endl;
  }
  else if(a+b==c+d){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int main(void) {
	int K;
	cin >> K;
	queue<int> que;

	que.push(111);
	ll ans = 0;

	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int l = 1; l <= K; l++) {
				ans += gcd(gcd(i, j), l);
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=200005,mod=998244353;
char ch[N];
int ans,f[N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read();
	scanf("%s",ch);
	reverse(ch,ch+n);
	For(i,0,n-1)ch[i]-='0';
	For(a,1,2*n)if(2*n%a==0&&n%a){
		int d=a/2;
		int sum=0;
		Rep(i,d-1,0)sum=(sum*2+ch[n-d+i])%mod;
		int ff=1;
		For(j,0,n-1){
			int t=ch[n-d+j%d]^((n-d+j%d-j)/d%2);
			if(ch[j]>t)ff=1;
			else if(ch[j]<t)ff=0;
		}
		//cout<<a<<" "<<d<<" "<<sum<<" "<<ff<<endl;
		f[d]=sum+ff;
	}
	For(i,1,n)if(n%(2*i)==i){
		for(int j=i+i;j<=n;j+=i)f[j]=(f[j]-f[i]+mod)%mod;
		ans=(ans+(ll)f[i]*i*2)%mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1280
import java.util.Scanner;


public class Main {

    
    public static void main(String[] args) {
       Scanner input= new Scanner(System.in);
   String s =input.nextLine();
   if (s.equals("Sunny") ){
       System.out.println("Cloudy");
   }
   else if(s.equals("Cloudy")){
        System.out.println("Rainy");
   }
   else if(s.equals("Rainy")){
       System.out.println("Sunny");
   }
    }
    
}

Measured memory_bytes: 21844
PROGRAM piyo
      IMPLICIT NONE
      
      integer(16) :: n
      integer(16),allocatable :: a(:)
      integer(16) :: i
      
      read*,n
      allocate( a(n) )
      read*,a(:)
      do i = 1,n
        if( mod(a(i),2)==0 )then
          if( mod(a(i),3)==0 .or.mod(a(i),5)==0 )then
            cycle
          else
            print*,'DENIED'
            stop
          end if
        end if
      end do
      
      print*,'APPROVED'
      
     
      
      
      END PROGRAM

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


int main()
{
    set<string> st;
    string str;
    int n;
    cin >> n;
    for (int i=0; i<n; ++i)
    {
        cin >> str;
        st.insert(str);
    }
    cout << st.size();
    return 0;
}

Measured memory_bytes: 19124
N = int(input())
if N == 1:
    T = [int(input())]
else:
    T = [int(input()) for _ in range(N)]

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def lcm(a, b):
    return a * b // gcd(a, b)

ans = T[0]
for i in range(N):
    ans = lcm(ans, T[i])
print(ans)

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

int main() {
    string s;
    cin >> s;
    stack<char> st;
    int cnt = 0;
    for (char c : s) {
        if (c == 'S') st.push(c);
        else if (st.empty()) continue;
        else if (c == 'T') {
            st.pop();
            cnt++;
        }
    }
    cout << s.size() - 2 * cnt << endl;
}


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

int ret[80001];

int main(void) {
    for(int x=1;x<=100;x++) {
        for(int y=1;y<=100;y++) {
            for(int z=1;z<=100;z++) {
                ret[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        printf("%d\n",ret[i]);
    }
}

Measured memory_bytes: 4044
first = []
for _ in range(8):
    num, time = map(float, input().split())
    first.append([int(num), time])

second = []
for _ in range(8):
    num, time = map(float, input().split())
    second.append([int(num), time])

third = []
for _ in range(8):
    num, time = map(float, input().split())
    third.append([int(num), time])

loser = []

first_s = sorted(first, key=lambda x: x[1])
print(first_s[0][0], '{0:.2f}'.format(first_s[0][1]))
print(first_s[1][0], '{0:.2f}'.format(first_s[1][1]))
loser.append(first_s[2])
loser.append(first_s[3])

second_s = sorted(second, key=lambda x: x[1])
print(second_s[0][0], '{0:.2f}'.format(second_s[0][1]))
print(second_s[1][0], '{0:.2f}'.format(second_s[1][1]))
loser.append(second_s[2])
loser.append(second_s[3])

third_s = sorted(third, key=lambda x: x[1])
print(third_s[0][0], '{0:.2f}'.format(third_s[0][1]))
print(third_s[1][0], '{0:.2f}'.format(third_s[1][1]))
loser.append(third_s[2])
loser.append(third_s[3])

loser_s = sorted(loser, key=lambda x: x[1])
print(loser_s[0][0], '{0:.2f}'.format(loser_s[0][1]))
print(loser_s[1][0], '{0:.2f}'.format(loser_s[1][1]))



Measured memory_bytes: 5596