akhauriyash/Code-Regression huggingface dataset:
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18+5;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    ll x, a, b;
    
    cin >> x;
    
    bool f = 0;
    for(ll K=-1000; K<=1000; K++){
		for(ll L=-1000; L<=1000; L++){
			//cout << K << ' ' << L << "\n";
			a = K*K*K*K*K;
			b = L*L*L*L*L;
			if(a-b==x){
				cout << K << ' ' << L << "\n";
				f = 1;
				break;
			}
			else if(a-b<x) break;
		}
		if(f) break;
	}
}


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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}


Measured memory_bytes: 3656
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int[] candyPack = {sc.nextInt(), sc.nextInt(), sc.nextInt()};

		Arrays.sort(candyPack);

		if((candyPack[0] + candyPack[1]) == candyPack[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}


Measured memory_bytes: 21716
def search(i,d,run,md,mrun):
    if d==md:
        run[0]+=1
        if run[0]==mrun:
            return str(i)
        else:
            return -1

    elif i==0:
        s=search(0,d+1,run,md,mrun)
        if s !=-1:
            return(str(i)+s)
        s=search(1,d+1,run,md,mrun)
        if s !=-1:
            return(str(i)+s)
    elif i==9:
        s=search(8,d+1,run,md,mrun)
        if s !=-1:
            return(str(i)+s)
        s=search(9,d+1,run,md,mrun)
        if s !=-1:
            return(str(i)+s)
    else:
        s=search(i-1,d+1,run,md,mrun)
        if s !=-1:
            return(str(i)+s)
        s=search(i,d+1,run,md,mrun)
        if s !=-1:
            return(str(i)+s)
        s=search(i+1,d+1,run,md,mrun)
        if s !=-1:
            return(str(i)+s)
    
    return -1

N=int(input())

digit=1
run=[0]

# max digit = 10
for d in range(1,11):
    for i in range(1,10):
        a=search(i,1,run,d,N)
        if a !=-1:
            print(a)
            break



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

int main()
{
	string strInput, strTemp;
	int nCount;
	int i, j;
	cin >> strInput;
	cin >> nCount;
	while (nCount--)
	{
		cin >> strTemp >> i >> j;
		if ("reverse" == strTemp)
		{
			reverse(strInput.begin() + i, strInput.begin() + j + 1); //j+1
		}
		else if ("replace" == strTemp)
		{
			cin >> strTemp;
			for (int ii = 0; ii < j - i + 1; ii++)
			{
				strInput[i + ii] = strTemp[ii];
			}
		}
		else
		{
			cout << strInput.substr(i, j - i + 1) << endl;
		}
	}
	//system("pause");
	return 0;
}

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

const long int MAX = 510000;
const long int MOD = pow(10,9)+7;

vector<long long int> fac(MAX);
vector<long long int> finv(MAX);
vector<long long int> inv(MAX);

void COMinit() {
    fac.at(0) = fac.at(1) = 1;
    finv.at(0) = finv.at(1) = 1;
    inv.at(1) = 1;
    for (int i = 2; i < MAX; i++){
        fac.at(i) = fac.at(i - 1) * i % MOD;
        inv.at(i) = MOD - inv.at(MOD%i) * (MOD / i) % MOD;
        finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
}

long long int COM(long int n,long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac.at(n) * (finv.at(k) * finv.at(n - k) % MOD) % MOD;
}

int main(){
    const long int mod = pow(10,9)+7;
    int S;
    cin >> S;

    int nmax = S/3;

    long long int ans = 0;

    COMinit();

    for(int i=1;i<=nmax;i++) {
        long int res = S - i*3;
        if(res<0){
            continue;
        }

        long int n = res + i -1;
        long int k = res;

        ans += COM(n,k);
        ans %= mod;

    }

    cout << ans%mod << endl;
}

Measured memory_bytes: 14936
import java.util.Scanner;

// Problema atcoder

public class Main {


	public static void main(String args[])  {
		
		
		int n;
		String result = "No";
		Scanner input = new Scanner(System.in);
		
		n = input.nextInt();
		
		
	    input.close();
	    
	    if(n>=30)
	    	result="Yes";
		System.out.println(result);
	
}
}



Measured memory_bytes: 35412
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pil;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

template<class T> struct heap{
    vector<T> node;
    function<bool(T, T)> cmp;

    heap(function<bool(T, T)> cmp_):cmp(cmp_){};

    void insert(T v){
        node.push_back(v);
        int now = node.size()-1;
        while(now > 0){
            int par = (now-1)/2;
            if(!cmp(node[par], node[now])){
                swap(node[par], node[now]);
                now = par;
            }
            else break;
        }
    }

    void del(){
        node[0] = node[node.size()-1];
        node.pop_back();
        int now = 0;
        while(true){
            int lch = now*2+1;
            int rch = now*2+2;
            if(lch > node.size()-1 && rch > node.size()-1) break;
            int chi = cmp(node[lch], node[rch]) ? lch : rch;
            if(!cmp(node[now], node[chi])){
                swap(node[now], node[chi]);
                now = chi;
            }
            else break;
        }
    }
};

int main(){
    auto cmp = [](const int &a, const int &b){return a > b;};
    int n;
    scanf("%d", &n);
    heap<int> myheap(cmp);
    rep(i, n){
        int a;
        scanf("%d", &a);
        myheap.insert(a);
    }

    int ans = 0;
    rep(i, n){
        ans += (1 - i%2*2) * myheap.node[0];
        myheap.del();
    }
    printf("%d\n", ans);
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 998244353
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))
ll fastPowMod(ll a, ll p,ll mod){ if(p==0) return 1; ll z = fastPowMod(a,p/2,mod); z = (z*z)%mod; if(p%2) z = (z*a)%mod; return z; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}

string s,t;
void print(int a, int b, int dp[][3001])
{
    if(a==0 || b==0) return;
    if(s[a-1]==t[b-1])
    {
        print(a-1,b-1,dp);
        cout<<s[a-1];
    }
    else if(dp[a-1][b]>dp[a][b-1])
    print(a-1,b,dp);
    else print(a,b-1,dp);
}

void solve()
{
    
    cin>>s;
    cin>>t;
    int sLen = s.length(), tLen = t.length();
    int dp[sLen+1][3001];
    set0(dp);
    srep(i,1,sLen)
    {
        srep(j,1,tLen)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            } 
        }
    }
    print(sLen,tLen,dp);
}

int main()
{
    fastio;
    
    solve();
    cout<<"\n";
    
    return 0;
}

Measured memory_bytes: 35840
#include<stdio.h>

int main(void)
{

    int w, n, a, b, x[30], i, temp;

    for(i = 0; i < 30; i++)
        x[i] = i + 1;

    scanf("%d", &w);
    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        scanf("%d,%d", &a, &b);
        temp = x[a - 1];
        x[a - 1] = x[b - 1];
        x[b - 1] = temp;
    }

    for(i = 0; i < w; i++)
        printf("%d\n", x[i]);

    return 0;
}

Measured memory_bytes: 596
#[test]
fn test_solve() {
    assert_eq!(solve("14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n"), "No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n");
    assert_eq!(solve("24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n"), "No\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let t: usize = sc.read();

    let mut ret = String::new();
    use std::fmt::Write;
    for _ in 0..t {
        let a: u64 = sc.read();
        let b: u64 = sc.read();
        let c: u64 = sc.read();
        let d: u64 = sc.read();
        writeln!(&mut ret, "{}", if query(a, b, c, d) { "Yes" } else { "No" }).unwrap();
    }
    ret
}

fn query(a: u64, b: u64, c: u64, d: u64) -> bool {
    if b > a || b > d {
        return false;
    }
    if b <= c {
        return true;
    }

    let g = gcd(b, d);
    let ma = b - g + a % g;
    ma <= c
}

fn gcd(a: u64, b: u64) -> u64 {
    match b {
        0 => a,
        1 => 1,
        _ => gcd(b, a % b),
    }
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.get().chars().collect()
    }
}


Measured memory_bytes: 4352
N,M,X = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
table = [0]*M
ans = 10**9+7
cnt = 0
for bit in range(1<<N):
    table = [0]*M
    cnt = 0
    B = [(bit>>i)&1 for i in range(N)]
    for j in range(N):
        if B[j] == 1:
            for k in range(M):
                table[k] += A[j][k+1]
            cnt += A[j][0]
    if min(table) >= X:
        ans = min(ans,cnt)
if ans == 10**9+7:
    ans = -1
print(ans)

Measured memory_bytes: 69096
from collections import deque

d = deque(list(input()))
flag = 1
for _ in range(int(input())):
    a = input()
    if a[0] == '1':
        flag *= -1
    elif a[2] == '1' and flag == 1:
        d.appendleft(a[4])
    elif a[2] == '1' and flag == -1:
        d.append(a[4])
    elif a[2] == '2' and flag == 1:
        d.append(a[4])
    else:
        d.appendleft(a[4])
if flag == -1:
    d.reverse()
print(''.join(d))


Measured memory_bytes: 8676
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main ()
{
	long double w = 0;
  	int L = 0;
 	cin >> L;
  	w = L*L*L/(long double)27;
  	cout.precision(12);
  	cout<<showpoint<<w;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    int n, v;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> v;
        ans += v-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI (3.14159265359)

int main() {
  double a, b;
  cin >> a >> b;
  double r = a > b ? 2.0 / 3.0 * PI * a * a * b : 4.0 / 3.0 * PI * b * b * b;
  cout << fixed << setprecision(6) << r << endl;
}



Measured memory_bytes: 3272
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	int n;
	cin>>n;
	int y=(n*100)/108;
	for(int i=1;i<=n;i++)
	{
		int x=(i*108)/100;
		if(x==n){
		cout<<i;
		return 0;}
	}
	cout<<":(";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K; 
	cin >> N >> K; 
	int A[200010] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	int G[200010] = {}; 
	for(int i = 1; i < N; i++){
		if(A[i-1] < A[i]) G[i] = G[i-1]; 
		else G[i] = G[i-1] + 1; 
	} 
	int m[200010] = {}; 
	int M[200010] = {}; 
	int deq[200010] = {}; 
	int l = 0; int r = 0; // deq[l, r) の気持ち
	for(int i = 0; i < N; i++){
		while(l < r && A[deq[r-1]] >= A[i]) r--;  
		deq[r++] = i; 
		if(i - K + 1 >= 0) m[i - K + 1] = A[deq[l]]; 
		if(deq[l] == i - K + 1) l++; 
	}
	fill(deq, deq + N, 0); 
	l = 0; r = 0; 
	for(int i = 0; i < N; i++){
		while(l < r && A[deq[r-1]] <= A[i]) r--;  
		deq[r++] = i; 
		if(i - K + 1 >= 0) M[i - K + 1] = A[deq[l]]; 
		if(deq[l] == i - K + 1) l++; 
	}
	vector<int> change; 
	for(int i = 0; i <= N - K; i++){
		if(G[i] != G[i + K - 1]) change.push_back(i); 
	}
	int ans; 
	if(change.size() == N - K + 1) ans = change.size(); 
	else ans = 1 + change.size();  	
	for(int i = 0; i+1 < change.size(); i++){
		if(change.at(i+1) != change.at(i) + 1) continue;
		int p = change.at(i); 
		if(m[p] == A[p] && M[p+1] == A[p+K]) ans --; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  //input
  int h, w;
  cin >> h >>w;
  char a[h][w];
  for(int i(0);i<h;i++)
    for(int j(0);j<w;j++)
      cin >> a[i][j];
  //make_output
  int ch(h), cw(w);
  char b[h][w], c[h][w];
  
  //horizontal
  int count(0);
  for(int i(0);i<h;i++){
    bool p(true);
    for(int j(0);j<w;j++){
      if(a[i][j]=='#'){
        p=false;
        break;
      }
    }
    if(p)
      ch--;
    else{
      for(int j(0);j<w;j++)
        b[count][j] = a[i][j];
      count++;
    }	
  }
  
  //virtical
  count = 0;
  for(int j(0);j<w;j++){
    bool p(true);
    for(int i(0);i<ch;i++){
      if(b[i][j]=='#'){
        p=false;
        break;
      }
    }
    if(p)
      cw--;
    else{
      for(int i(0);i<ch;i++)
        c[i][count] = b[i][j];
      count++;
    }	
  }
  
  //output
  for(int i(0);i<ch;i++){
    for(int j(0);j<cw;j++)
      cout << c[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (c >= a && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  long long a[n],b[n],sub[n];
  long long subsum=0, amsum=0;
  pair<long long, int> amari[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
    sub[i]=max(0ll, b[i]-a[i]);
    amari[i]=make_pair(max(0ll, a[i]-b[i]), i);
    ans+=((sub[i]>0)?1:0);
    subsum+=sub[i];
    amsum+=amari[i].first;
  }
  if(subsum>amsum){
    cout << -1 << endl;
    return 0;
  }
  if(subsum==0){
    cout << 0 << endl;
    return 0;
  }
  sort(amari,amari+n);
  reverse(amari,amari+n);
  long long tmp=0;
  for(int i=0;i<n;i++){
    tmp+=amari[i].first;
    ans++;
    if(tmp>=subsum){
      cout << ans << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }


int main() {
    string s,t;
    cin >> s >> t;
    string ss = s;
    ss += s;

    ll n = s.length();
    ll chap[2*n+1][26];

    FOR(i,0,25){
      chap[2*n][i] = -1;
    }

    FORD(i,2*n-1,0){
      FOR(j,0,25){
        chap[i][j] = chap[i+1][j];
      }
      chap[i][ss[i]-'a'] = i+1;
    }

    ll sum = 0;
    ll back = 0;

    FOR(i,0,t.length()-1){
    //   cout << chap[back][t[i]-'a'] << " " << back << endl;
      if(chap[back][t[i]-'a']==-1){
        cout << -1 << endl;
        return 0;
      }
      sum += chap[back][t[i]-'a'] - back;
      back = chap[back][t[i]-'a'] % s.length();
    //   cout << sum << " " << back << endl;
    }

    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 41472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
}


Measured memory_bytes: 3652
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m = IL()
    war = [list(IL()) for _ in range(m)]
    war.sort(key=lambda x: x[1])
    pre = war[0][1]-2
    ans = 1
    for rep in war:
        if pre<rep[0]-1:
            pre = rep[1]-2
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    Main()

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

int main() {
	string s,t;
  	cin>>s;
  	t=s;
  	for (int i=0;i<s.size();i++){
    	t.at(s.size()-1-i)=s.at(i);
    }
  	if (s==t){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    A, B = mi()
    P = list(mi())
    diff_a = sum(1 for p in P if p <= A)
    diff_b = sum(1 for p in P if A < p <= B)
    diff_c = sum(1 for p in P if p > B)
    print(min(diff_a, diff_b, diff_c))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9580
/**************************
  * Writer : Leo101
  * Problem : 
  * Tags : 
**************************/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define File(s) freopen(#s".in", "r", stdin); freopen(#s".out", "w", stdout)
#define gi get_int()
const int Max_N = 2e5, Max_M = 3e5;
int get_int()
{
	int x = 0, y = 1; char ch = getchar();
	while ((ch < '0' || ch > '9') && ch != '-')
		ch = getchar();
	if (ch == '-') y = -1,ch = getchar();
	while (ch <= '9' && ch >= '0') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * y;
}

int From[Max_M], To[Max_M];

int Father[Max_N], Value[Max_N];
int Get_father(int u)
{ return Father[u] == u ? u : Father[u] = Get_father(Father[u]); }

long long Ans[Max_M];

int main()
{
	int n = gi, m = gi;
	for (int i = 0; i < m; i++)
		From[i] = gi, To[i] = gi;

	for (int i = 0; i < n; i++) Father[i] = i, Value[i] = 1;

	Ans[m] = (1ll * (n - 1) * n) / 2;
	for (int i = m - 1; i >= 0; i--) {
		int u = From[i], v = To[i], w = Value[i];
		int Fa_u = Get_father(u), Fa_v = Get_father(v);
		Ans[i] = Ans[i + 1];
		if (Fa_u == Fa_v) continue;
		Ans[i] -= 1ll * Value[Fa_u] * Value[Fa_v];
		Father[Fa_u] = Fa_v;
		Value[Fa_v] += Value[Fa_u];
	}

	for (int i = 1; i <= m; i++) printf("%lld\n", Ans[i]);

	return 0;
}


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

using namespace std;

namespace {
    int H, W, d;
    void input() {
        cin >> H >> W >> d;
    }

    void solve() {
        auto T = 2000;
        auto F = vector<string>(H, string(W, '0'));
        auto s = "RGBY";
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                auto j = x + y + T;
                auto i = x - y + T;
                F[y][x] = s[ (i / d) % 2 * 2 + (j / d) % 2 ];
            }
        }
        for (auto L : F) cout << L << endl;
    }
}

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



Measured memory_bytes: 768
import java.util.*;

public class Main {
	public static void main(String[] args) {
              Scanner sc = new Scanner(System.in);
                        
               String s = sc.next();
               
               int a = s.length();
               
               boolean flag = true;
               
               if(s.charAt(0) == s.charAt(a-1)){
                    if(a%2 == 1){
                        flag = false;
                    }else{
                        flag = true;
                    }
               }else{
                   if(a%2 == 1){
                       flag = true;
                   }else{
                       flag = false;
                   }                                      
               }                             
                                                                                    
               if(flag){
                   System.out.println("First");
               }else{
                   System.out.println("Second");
               }           
                            
        }       
}

        

Measured memory_bytes: 25888
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int sum = 0;
			for(int i = 0; i < n/4; i++){
				sum += sc.nextInt();
			}
			
			System.out.println(sum);
		}
		
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N;
	cin>>N;
	ll ans=0;
	int max=0;
	fx(N){
		int a;
		cin>>a;
		if(a>max){
			ans+=max;
			max=a;
		}else{
			ans+=a;
		}
	}
	ans+=max/2;
	ce(ans)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long D,T,S;
  cin >> D >> T >> S;
  
  if (D - S * T <= 0){
      cout << "Yes" <<endl;
  }else{
      cout << "No" <<endl;
  }
 
      
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll N, T, A;
    cin >> N >> T >> A;
    vector<ll> H(N);
    vector<ll> C(N);
    ll ans = 9000000000000;
    ll ansi = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
        C[i] = (T*1000-H[i]*6)-A*1000;
    }
    for (int i = 0; i < N;i++)
    {
        if(C[i] < 0){
            C[i] = -C[i];
        }
        if (ans >= C[i])
        {
            ans = C[i];
            ansi = i;
        }
    }
    cout << ansi + 1 << endl;
}


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

int main(){
    long long h,w;
    cin >> h >> w;
    long long res = 0;
    if (w == 1 || h == 1) {
        res = 1;
    } else if (h % 2 == 1 && w % 2 == 1) {
        res = h * w / 2 + 1;
    } else {
        res = h * w /2;
    }

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

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a, b, c;
	cin >> a >> b >> c;
	if (a.back() == b.front() && b.back() == c.front())cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n, m, k = map(int, input().split())

def is_able(n, m, k):
    res = defaultdict(bool)
    res[0] = True
    for i in range(1, n+1):
        for j in range(1, m+1):
            count = 0
            count += i*j
            count += (n-i)*(m-j)
            res[count] = True
    return res[k]


if is_able(n, m, k):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 30020
def main():
    N = input()
    len_N = len(N)
    ans = 0
    pre = 0
    for i in range(len_N-1,-1,-1):
        int_N = int(N[i]) + pre
        if int_N <= 4:
            ans += int_N
            pre = 0
        elif int_N >= 6:
            ans += 10 - int_N
            pre = 1
        elif int_N == 5:
            if i == 0:
                ans += int_N
                pre = 0
            else:
                if int(N[i-1]) <= 4:
                    ans += int_N
                    pre = 0
                else:
                    ans += int_N
                    pre = 1
    else:
        ans += pre
    print(ans)



if __name__ == "__main__":
    main()

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

int main(){
    ll N; cin >> N;
    if(N % 2){
        cout << 0 << endl;
        return 0;
    }
    N /= 10;
    ll ans = N;
    while(N){
        N /= 5;
        ans+= N;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+7,MOD=1e9+7;
typedef long long ll;
#define pb push_back
#define Y printf("Yes\n")
#define N printf("No\n")
#define O printf("-1\n")
bool f_2=false,vis[M]= {false},f=false;
vector<ll>v,v_1,v_2,v_3,v_4,v_5;
string s,p,q,ok,ch;
map<ll,ll>mp,mp_2;
set<ll>st,st_1;
ll arr[M],ar[M]= {0};
ll cnt=0,cost=0,mx=0,NODE,t;
deque<ll>Q;
//vector< pair<ll,ll > >v,v_1;
struct node
{
    ll pa,ran,visit;

};
//node X[M];

int main()
{
    ios::sync_with_stdio(false);//ISHWAR
    cin.tie(0);//Tourist_Twin
    ll a,b,c=1,n,sum=0,mx=0,l,x,y,i=0,j=0,result=0,e,sum_2,ans=0,d,k;
    cin>>t;
    for(i=0;i<t;i++)
    {
        cin>>b;
        v.pb(b);
    }
    c=-1;
    for(i=0;i<t-1;i++)
    {
        if(v[i]>v[i+1])
        {
           d=v[i];
           for(j=i;j>c;j--)
           {
               if(d==v[j])
                v[j]--;
                else
                break;
           }
           c=i;

        }
        else if(v[i]<v[i+1])
        {
            c=i;
        }

    }
    for(i=0;i<t-1;i++)
    {
        if(v[i]>v[i+1])
        {
            f=true;
            break;
        }
    }
    if(f)N;
    else Y;
        return 0;
    }


Measured memory_bytes: 1400
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a > b)
            System.out.println("a > b");
        else if (a < b)
            System.out.println("a < b");
        else
            System.out.println("a == b");
    }
}


Measured memory_bytes: 26184
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

const int N = 1e5 + 5, MOD = 1e9 + 7;

int dp[N], nxt[N][2], nd[N], n;
ll a[N], d[2];
bool vis[N];

int gdp(int st){
	if(!vis[st]){
		vis[st] = 1;	
		rep(c,0,2){
			if(nxt[st][c] != -1){
				dp[st] += gdp(nxt[st][c]);
			}
		}
		dp[st] %= MOD;
	}
	return dp[st];
}

void calc_nxt(){
	for(int i = n-2; i >= 0 ; --i)nxt[i][0] = nxt[i][1] = -1;
	nxt[n-1][0] = nxt[n-1][1] = n;
	for(int i = n-2; i >= 0 ; --i){
		// 0
		if(a[i+1] < a[i] + d[0]){
			if(!(i + 2 < n && a[i+2] < a[i] + d[0])){
				nxt[i][0] = nxt[i+1][1];
			}
		}
		else nxt[i][0] = i + 1;
		// 1
		if(nd[i] == -1)nxt[i][1] = -1;
		else{
			if(a[i] + d[1] <= a[nd[i]]){
				nxt[i][1] = i+1;
			}
			else if(nd[i] < n - 1){
				if(a[nd[i]] + d[0] > a[nd[i]+1]){
					if(!(nd[i] + 2 < n && a[nd[i]] + d[0] > a[nd[i]+2]))nxt[i][1] = nxt[nd[i]+1][1];
				}
				else{
					nxt[i][1] = nd[i] + 1;
				}
			}
			else nxt[i][1] = n;
		}
	}
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n >> d[0] >> d[1];
	if(d[1] < d[0])swap(d[0],d[1]);
	rep(i,0,n)cin >> a[i];
	dp[n] = vis[n] = 1;
	int rp = 0;
	fill(nd,nd+n,-1);
	rep(i,0,n){
		if(rp == i)++rp;	
		bool v = false;
		while(rp < n - 1 && a[rp+1] < a[i] + d[1]){
			if(a[rp + 1] - a[rp] < d[0]){
				i = rp - 1;
				v = 1;
				break;
			}
			++rp;
		}
		if(!v)nd[i] = rp;	
	}
	calc_nxt();
	cout << gdp(0) << '\n';
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n >> m;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    int dp[n][m];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0 ;j<m; j++){
            if(s[i][j]=='.'&&i!=0&&j!=0){
                dp[i][j]+=dp[i-1][j]+dp[i][j-1];
            }
            else if(s[i][j]=='.'&&i==0&&j!=0){
                dp[i][j]+=dp[i][j-1];
            }
            else if(s[i][j]=='.'&&j==0&&i!=0){
                dp[i][j]+=dp[i-1][j];
            }
            dp[i][j]%=mod;
        }
    }
    cout << dp[n-1][m-1] << el;
    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	int sz = s.size();

	vector<int> l_pos, r_pos;
	for (int i = 0; i < sz; ++i){
		if (s[i] == 'R') {
			r_pos.push_back(sz - i - 1);
		} else {
			l_pos.push_back(i);
		}
	}

	sort(r_pos.begin(), r_pos.end());

	vector<int> children(sz);
	for (int i = 0; i < sz; ++i) {
		if (s[i] == 'R') {
			vector<int>::iterator low = lower_bound(l_pos.begin(), l_pos.end(), i);
			int moves = *low - i;
			if (moves % 2 == 0) {
				++children[*low];
			} else {
				++children[*low - 1];
			}
		} else {
			vector<int>::iterator low = lower_bound(r_pos.begin(), r_pos.end(), sz - i - 1);
			int moves = *low - (sz - i - 1);
			if (moves % 2 == 0) {
				++children[sz - *low - 1];
			} else {
				++children[sz - *low];
			}
		}
	}

	cout << children;

	return 0;

}

Measured memory_bytes: 1612
from collections import defaultdict
N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)

for key in a:
    d[key] += 1

cnt = 0
for i in d:
    d1 = 0
    d2 = 0
    if (i - 1) in d:
        d1 = d[i - 1]
    if (i + 1) in d:
        d2 = d[i + 1]

    cnt = max(cnt, d[i] + d1 + d2)

print(cnt)

Measured memory_bytes: 14564
#include <stdio.h>

int main(void)
{
	double a[16];
	int i;
	double total;
	
	while (scanf("%lf", &a[0]) != EOF){
		total = a[0];
		for (i = 1; i < 10; i++){
			if (i % 2 == 0){
				a[i] = a[i - 1] / 3;
			}
			if (i % 2 == 1){
				a[i] = a[i - 1] * 2;
			}
			total += a[i];
		}
		printf("%lf\n", total);
	}
	return (0);
}

Measured memory_bytes: 1076
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;using ull=unsigned long long;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

class union_find{
private:
    vector<ll>par,sz,rank;
    ll cnt;
public:
    union_find  (ll n):par(n),sz(n,1),rank(n,0),cnt(n){iota(ALL(par),0);}
    ll   count  ()          {return cnt;}
    ll   find   (ll n)      {return par[n]==n?n:par[n]=find(par[n]);}
    ll   size   (ll n)      {return sz[find(n)];}
    bool is_same(ll x, ll y){return find(x)==find(y);}
    void unite  (ll x, ll y)
    {
        x=find(x);y=find(y);
        if (x!=y) {
            if (rank[x]<rank[y]){
                par[x]=y;
                sz[y]+=sz[x];
            }else{
                par[y]=x;
                sz[x]+=sz[y];
                if(rank[x]==rank[y])++rank[x];
            }
            --cnt;
        }
    }
};
int main()
{
    ll n=in();
    struct town{ll x,y,idx;};
    vector<town>t(n);
    REP(i,n){
        ll x=in(),y=in();
        t[i]=town{x,y,i};
    }

    struct edge{ll from,to,len;};
    vector<edge>e;
    auto dist=[](const town&t1,const town&t2){return min(abs(t1.x-t2.x),abs(t1.y-t2.y));};
    sort(ALL(t),[](const town&t1,const town&t2){return t1.x<t2.x;});
    REP(i,n-1)e.push_back(edge{t[i].idx,t[i+1].idx,dist(t[i],t[i+1])});
    sort(ALL(t),[](const town&t1,const town&t2){return t1.y<t2.y;});
    REP(i,n-1)e.push_back(edge{t[i].idx,t[i+1].idx,dist(t[i],t[i+1])});
    sort(ALL(e),[](const edge&e1,const edge&e2){return e1.len<e2.len;});

    ll ans=0;
    union_find uf(n);
    REPC(ei,e){
        if(uf.count()==1)break;
        if(!uf.is_same(ei.from,ei.to)){
            uf.unite(ei.from,ei.to);
            ans+=ei.len;
        }
    }
    cout<<ans<<endl;
}


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

int main ()
{
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    if(S.at(K-1)=='A'){
        S.at(K-1)='a';
    }
    if(S.at(K-1)=='B'){
        S.at(K-1)='b';
    }
    if(S.at(K-1)=='C'){
        S.at(K-1)='c';
    }
    cout << S << endl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , d , x ;
  cin >> n >> d >> x ;
  
  rep(i,n){
    int day = 1 ;
    int a ;
    cin >> a ;    
    while(day <= d ){
      x++;
      day += a ;
    }
  }
  
  cout << x ;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int h,a;
    cin >> h >> a;
    int ans = 0;
    while(h>0){
        ++ans;
        h -= a;
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define int ll
struct flower
{
   int h;
   int b;
};
signed main(void)
{
   int n;
   cin>>n;
   vector< flower >v(n+1);
   vector< int >dp(n+1);
   for(int  i = 1;i<=n;i++)
    cin>>v[i].h;
  for(int  i =1;i<=n;i++)
    cin>>v[i].b;
   map<int,int>mp;
   dp[1] = v[1].b;
   mp[v[1].h] = dp[1];
   int ans = dp[1];
   for(int  i = 2;i<=n;i++)
   {

       dp[i] = v[i].b;
       auto it = mp.lower_bound((v[i].h+1));
       if(it!= mp.begin())
       {
          it--;
          dp[i]+= (it->second);
       }

       mp[v[i].h] = dp[i];

       it = mp.upper_bound(v[i].h);

       while(it!=mp.end() && (it->second)<= dp[i])
       {
           auto temp = it;
           temp++;
           mp.erase(it);
           it = temp;
       }

       if(ans<dp[i])
        ans = dp[i];
   }
   cout<<ans<<endl;

}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);
  int a, b;
  // string s;
  cin >> a >> b;
  if (a == 1) a = 14;
  if (b == 1) b = 14;

  if (a > b) {
    print("Alice");
  } else if ( a == b) {
    print("Draw");
  } else {
    print("Bob");
  }

  return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

a = (W + 1) // 2
b = W // 2

if (H == 1 or W == 1):
    x = 1
elif H % 2 == 0:
    x = (a + b) * H // 2
else:
    x = a * ((H // 2) + 1) + b * (H // 2)

print(x)


Measured memory_bytes: 3060
n, k = map(int, input().split())
hn = list(map(int, input().split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
for i in range(0, n):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(hn[i+j]-hn[i]))
print(dp[-1])


Measured memory_bytes: 56928
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
#include <unordered_set>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL MAXN = 1e7 + 1;
const LD EPS = 1e-6;

inline int power(LL x)
{
	int i = 0;
	while ((1LL << i) < x)
		++i;
	return i;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	int n;
	cin >> n;
	VLL a(n);
	FOR(i, 0, n)
		cin >> a[i];

	LL ans = 0;
	int x = 0;
	int prev = 0;
	FOR(i, 0, n)
	{
		x = power(a[i]);
		if (prev >= x) 
		{
			prev = x;
			if ((1 << x) > a[i])
				--prev;
		}
		else
		{
			ans += (x - prev);
			prev = x;
		}
	}

	cout << ans;
	cin >> n;
	return 0;
}

Measured memory_bytes: 1024
// J4180449 三宅亮輔
// 問題名
// -
// 問題URL
// -
// 所要時間
// -
// 学んだこと
//
//
//

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

map<string, int> m;
string max_str, len_str;
int max_val, max_len;

string str;
int main() {
    while(cin >> str) {
        m[str] += 1;
    }
    for(auto itr = m.begin(); itr != m.end(); itr++) {
        if(itr->second > max_val) {
            max_val = itr->second;
            max_str = itr->first;
        }
        if(itr->first.length() > max_len) {
            max_len = itr->first.length();
            len_str = itr->first;
        }
    }
    cout << max_str << " " << len_str << endl;
}


Measured memory_bytes: 3156
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 500, MAX_Q = 100000;
    int N, M, Q;
    cin >> N >> M >> Q;
    int L, R, X[MAX_N + 1][MAX_N + 1] = {};
    REP(i, M) {
        cin >> L >> R;
        X[L][R]++;
    }
    int C[MAX_N + 1][MAX_N + 1] = {};
    FOR(i, 1, N + 1, 1) {
        FOR(j, 1, N + 1, 1) {
            C[i][j] = C[i][j - 1] + X[i][j];
        }
    }
    int p, q, res[MAX_Q] = {};
    REP(i, Q) {
        cin >> p >> q;
        FOR(j, p, q + 1, 1) {
            res[i] += C[j][q] - C[j][p - 1];
        }
    }
    REP(i, Q) {
        cout << res[i] << endl;
    }
    return 0;
}


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

int main(void){
  int n, pcs = 0;

  cin >> n;

  for(int i = 1; i <= n; i ++){
    if(i % 2){
      int cnt = 0;
      for(int j = 1; j <= i; j ++){
        if(i % j == 0)
          cnt ++;
      }
      if(cnt == 8)
        pcs ++;
    }
  }
  
  cout << pcs << endl;

  return 0;
}

Measured memory_bytes: 256