akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;

int r(string t) {
    vector<bool> vis('C' + 1, 0);
    for(int i = 0; i < 2; i++) vis[t[i]] = 1;
    for(int i = 'A'; i < 'D'; i++) {
        if(!vis[i]) return i;
    }
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int n; scanf("%d", &n);
        vector<int> v('C' + 1, 0);
        for(int i = 'A'; i < 'D'; i++) scanf("%d", &v[i]);
        vector<char> res;
        string s[n];
        for(int i = 0; i < n; i++) {
            cin >> s[i];
        }
        for(int i = 0; i < n; i++) {
            if(v[s[i][1]] < v[s[i][0]]) swap(s[i][0], s[i][1]);
            if(v[s[i][1]] == 0) return puts("No"), 0;
            if(v[s[i][1]] == v[s[i][0]] && v[s[i][0]] == 1 && !v[r(s[i])] && !(i == n - 1 || (i < n - 1 && r(s[i + 1]) == r(s[i])))) {
                if(r(s[i + 1]) == s[i][0]) {
                    v[s[i][0]]--;
                    v[s[i][1]]++;
                    res.push_back(s[i][1]);
                } 
                else {
                    res.push_back(s[i][0]);
                    v[s[i][0]]++;
                    v[s[i][1]]--;
                }
            }
            else {
                res.push_back(s[i][0]);
                v[s[i][0]]++;
                v[s[i][1]]--;
            }
        }
        puts("Yes");
        for(auto c : res) putchar(c), puts("");
    }  
    return 0;
}

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


using namespace std;


int main(void) {
    map<long long, long long> res;
    for (long long i = 0; i < 1000; i++) {
        long long t = i * i * i * i * i;
        res[i] = t;
    }
    for (long long i = -1; i > -1000; i--) {
        long long t = i * i * i * i * i;
        res[i] = t;
    }

    long long X;
    cin >> X;
    long long A, B;
    for (auto pa : res) {
        for (auto pb : res) {
            if (pa.second - pb.second == X) {
                A = pa.first;
                B = pb.first;
            }
        }
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  vector<int> v_e(100010);
  vector<int> v_o(100010);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    if (i%2==0)
      v_e.at(v)++;
    else
      v_o.at(v)++;
  }
 
  vector<int>::iterator maxItVE = max_element(v_e.begin(), v_e.end());
  int maxVE = *maxItVE;
  int iVE = distance(v_e.begin(), maxItVE);
  v_e[iVE] = 0;
  int maxVE2 = *max_element(v_e.begin(), v_e.end());
  
  vector<int>::iterator maxItVO = max_element(v_o.begin(), v_o.end());
  int maxVO = *maxItVO;
  int iVO = distance(v_o.begin(), maxItVO);
  v_o[iVO] = 0;
  int maxVO2 = *max_element(v_o.begin(), v_o.end());
  
  if (iVE != iVO) {
    cout << n - maxVE - maxVO << endl;
  } else {
    cout << n - max(maxVE2+maxVO, maxVE+maxVO2) << endl;
  } 
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

int n,m,a,b;
bool r[710][710];
int cl[710],vi[710];
bool dp[710][710];
vector<int>cg[710];
vector<P>v;

P dfs(int now,int color){
	vi[now]=1;
	cl[now]=color;
	P ret=P(0,0);
	if(color==1)ret.fr++;
	else ret.sc++;
	for(int u:cg[now]){
		if(vi[u]&&cl[u]==cl[now])return P(-1,-1);
		else if(!vi[u]){
			int c;
			if(color==1)c=2;
			else c=1;
			P p=dfs(u,c);
			if(p.fr<0)return P(-1,-1);
			ret.fr+=p.fr;
			ret.sc+=p.sc;
		} 
	}
	return ret;
}

void set_up(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		r[a][b]=true;
		r[b][a]=true;
	}	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(!r[i][j]&&i!=j)cg[i].eb(j);
		}
	}
}

void solve(){
	for(int i=0;i<n;i++){
		if(vi[i])continue;
		P p=dfs(i,1);
		if(p.fr==-1){
			cout<<-1<<endl;
			return;
		}
		v.eb(p);
	}
	int ans=1e9;
	dp[0][0]=true;
	for(int i=0;i<v.size();i++){
		for(int j=0;j<n;j++){
			if(dp[i][j]){
				dp[i+1][j+v[i].fr]=true;
				dp[i+1][j+v[i].sc]=true;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(dp[v.size()][i])ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
	}
	cout<<ans<<endl;
}

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


Measured memory_bytes: 3072
s = input()
left = 0
right = len(s)-1
ans = 0
while left < right:
    if s[left] == s[right]:
        left += 1
        right -= 1
    elif s[left] == "x" and s[right] != "x":
        ans += 1
        left += 1
    elif s[left] != "x" and s[right] == "x":
        ans += 1
        right -= 1
    else:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 40020
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("20 30 70 90");
            WillReturn.Add("3");
            //150
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("10000 1000 100 10");
            WillReturn.Add("1");
            //100
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("10 100 1000 10000");
            WillReturn.Add("1");
            //40
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("12345678 87654321 12345678 87654321");
            WillReturn.Add("123456789");
            //1524157763907942
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();
        long Q = wkArr[0];
        long H = wkArr[1];
        long S = wkArr[2];
        long D = wkArr[3];

        long N = long.Parse(InputList[1]);

        //1リットルの最安値を求める
        long Min1 = Math.Min(Q * 4, H * 2);
        Min1 = Math.Min(Min1, S);

        //2リットルの最安値を求める
        long Min2 = Math.Min(Min1 * 2, D);

        //Nが奇数なら1リットル購入
        long Answer = 0;
        long RestN = N;
        if (RestN % 2 == 1) {
            Answer += Min1;
            RestN--;
        }

        //残りを購入
        if (RestN > 0) {
            Answer += (RestN / 2) * Min2;
        }

        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;

const ll NMAX = 2010;
using namespace std;

ll dp[3005][3005];

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

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= 0; j++){
            dp[i][j] = 0;
        }
    }

    for(int l = 1; l <= n; l++){
        for(int i = 0; i <= n-l; i++){
            int j = i+l;
            if((n-l)%2==0){
                dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1]);
            } else {
                dp[i][j] = min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1]);
            }
        }
    }

    cout << dp[0][n] << endl;

    return 0;
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = LLONG_MAX;

int main(){
  int N,count = 0;
  string v;

  cin>>N;

  REP(i,N){
    cin>>v;
    if(v == "A") count++;
    else if(v == "Un") count--;

    if(count < 0){
      cout<<"NO"<<endl;
      return 0;
    }
  }

  if(count == 0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}

Measured memory_bytes: 3160
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                int A=sc.nextInt();
                int B=sc.nextInt();
                System.out.println((A-1)*(B-1));


                
                


                
        }
        
        
        

		
	
}


Measured memory_bytes: 21716
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int n;
    cin >> n;

    vll a(n);
    REP(i, n) cin >> a[i];

    sort(ALL(a), greater<>());

    priority_queue<ll, vector<ll>, greater<>> q;
    q.push(0);
    q.push(0);
    REP(i, n - 1) {
        if (a[i] == a[i + 1]) {
            if (q.top() < a[i]) {
                q.pop();
                q.push(a[i]);
            }
            ++i;
        }
    }

    ll a1 = q.top(); q.pop();
    ll a2 = q.top(); q.pop();

    print(a1 * a2);
}


Measured memory_bytes: 4004
h, w = map(int, input().split())
s = ["." * (w + 2)]
for i in range(h):
    s.append("." + input() + ".")
s.append("." * (w + 2))

def count_bomb(h_i, w_i):
    sq = ""
    for i in range(3):
        sq += s[h_i + i - 1][w_i - 1: w_i + 2]
    return sq.count("#")

for h_i in range(1, h + 1):
    for w_i in range(1, w + 1):
        if s[h_i][w_i] == ".":
            print(count_bomb(h_i, w_i), end="")
        else:
            print("#", end="")
    print()



Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int a,b;
  cin>>a>>b;
  cout << (a-1)*(b-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let mut n:usize=read!();
    let mut a:usize=0;
    let mut b:usize=0;
    for i in 0..n {
        let mut m:usize=read!();
        a+=m;
        if b<m {b=m}
    }
    println!("{}",if (a+1)/2>b {"Yes"}else{"No"});
}

Measured memory_bytes: 2100
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, m, c, ans;
        int[] a = new int[20];
        int[] b = new int[20];
        n = sc.nextInt();
        m = sc.nextInt();
        c = sc.nextInt();
        ans = 0;
        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[j] = sc.nextInt();
            }
            int sum;
            sum = 0;
            for (int j = 0; j < m; j++) {
                sum += a[j] * b[j];
            }
            if (sum + c > 0) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

typedef long long ll;

int main() {
  int N, K;
	std::string S;
	std::cin >> N >> K >> S;

  --K;
	switch(S[K]) {
		case 'A': S[K] = 'a'; break;
		case 'B': S[K] = 'b'; break;
		default : S[K] = 'c'; break;
	}
	std::cout << S << std::endl;
}



Measured memory_bytes: 256
from sys import stdin

H, W = [int(i) for i in stdin.readline().rstrip().split()]
a = [stdin.readline().rstrip() for _ in range(H)]

del_row = []

for i in range(len(a)):
    all_while = True
    s = a[i]
    for c in s:
        if c == '#':
            all_while = False
            break
    if all_while:
        del_row.append(i - len(del_row))

for i in del_row:
    a.pop(i)

a_t = []
for col in range(W):
    s = ''
    for row in range(len(a)):
        s += a[row][col]
    a_t.append(s)

del_row = []

for i in range(len(a_t)):
    all_while = True
    s = a_t[i]
    for c in s:
        if c == '#':
            all_while = False
            break
    if all_while:
        del_row.append(i - len(del_row))

for i in del_row:
    a_t.pop(i)

a = []
for col in range(len(a_t[0])):
    s = ''
    for row in range(len(a_t)):
        s += a_t[row][col]
    a.append(s)

for i in a:
    print(i)


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

int main()
{
  string s1,s2;
  int i,j,k,l,m,n,l1,l2;
  cin>>s1>>s2;
  l1=s1.length();
  l2=s2.length();
  int cnt=0,ans=100000;
  for(i=l2-1;i<l1;i++)
  {
    cnt=0;
    m=0;
    for(j=i-(l2-1);j<i-(l2-1)+l2;j++)
    {
      if(s1[j]!=s2[m])cnt++;
      m++;
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

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

int main(){
  ll n,a,b; cin >>n >>a >>b;
  if(a>b) {
    cout << 0 << endl;
    return 0;
  }
  if(n==1){
    if(a==b) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
  }
  ll M = a+(n-1)*b, m = (n-1)*a+b;
  cout << M-m+1 << endl;
  return 0; 
}

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

int arr[200200];
int sum,xornw,l;

main()
{
	int n;
	scanf("%d",&n);
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
		xornw^=arr[i];
		sum+=arr[i];
		while(sum!=xornw)
		{
			sum-=arr[l];
			xornw^=arr[l];
			l++;
		}
		long long len=i-l+1;
		ans+=len;
	}
	printf("%lld",ans);
}

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

int main()
{
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char last = s[0];
  int sum[n + 1];
  sum[0] = sum[1] = 0;
  for (int i = 1; i < n; i++)
  {
    sum[i + 1] = sum[i];
    if (last == 'A' && s[i] == 'C')
      sum[i + 1]++;
    last = s[i];
  }
  int ans[q];
  rep(i, q)
  {
    int l, r;
    cin >> l >> r;
    ans[i] = sum[r] - sum[l];
  }
  rep(i, q) cout << ans[i] << endl;
}

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

#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<21],*p1=buf,*p2=buf;

inline void readint(int &x)
{
    int f=1;x=0;
    char ch=getchar();
    while(!isdigit(ch))
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        x=(x<<3)+(x<<1)+ch-48;
        ch=getchar();
    }
    x*=f;
}

int n,a[200005];

int main()
{
    readint(n);
    for(int i=1;i<=n;i++)readint(a[i]);
    sort(a+1,a+n+1);
    puts((unique(a+1,a+n+1)-a-1==n)?"YES":"NO");
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> a(H);
  
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
  }
  
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  
  cout << endl ; // 改行
  
  for (int i = 0; i < H; i++) {
    cout << "#" << a.at(i) << "#" << endl;
  }
  
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }

  cout << endl ; // 改行
  
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
int n, m, cnt, fir[Maxn], ind[Maxn], f[Maxn];
struct
{
	int to, last;
} e[Maxn];
void con(int u, int v)
{
	e[++cnt].to = v;
	e[cnt].last = fir[u];
	fir[u] = cnt;
	ind[v]++;
}
void BFS(int x)
{
	queue<int> q;
	q.push(x);
	while (!q.empty())
	{
		x = q.front();
		q.pop();
		for (int next = fir[x], nx; next; next = e[next].last)
		{
			nx = e[next].to;
			f[nx] = x;
			ind[nx]--;
			if (!ind[nx])
				q.push(nx);
		}
	}
}
int main()
{
	int a, b;
	cin >> n >> m;
	for (int i = 1; i < n + m; i++)
	{
		scanf("%d%d", &a, &b);
		con(a, b);
	}
	for (int i = 1; i <= n; i++)
		if (!ind[i])
		{
			BFS(i);
			break;
		}
	for (int i = 1; i <= n; i++)
		printf("%d\n", f[i]);
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

struct Card{
  char c;
  int n;
};

void marge(Card a[],int left,int mid,int right){
  int n1=mid-left,n2=right-mid;
  Card* l=(Card*)malloc(sizeof(Card)*(n1+1));
  Card* r=(Card*)malloc(sizeof(Card)*(n2+1));
  int i,j,k;
  for(i=0;i<n1;i++){
    l[i]=a[left+i];
  }
  for(i=0;i<n2;i++){
    r[i]=a[mid+i];
  }
  l[n1].n=r[n2].n=1000000001;
  i=j=0;
  for(k=left;k<right;k++){
    if(l[i].n<=r[j].n){
      a[k]=l[i];
      i++;
    }
    else{
      a[k]=r[j];
      j++;
    }
  }
  return;
}

void margeSort(Card a[],int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    margeSort(a,left,mid);
    margeSort(a,mid,right);
    marge(a,left,mid,right);
  }
}

int partition(Card a[],int p,int r){
  int x=a[r].n,i,j=p;
  Card tmp;
  for(i=p;i<r;i++){
    if(a[i].n<=x){
      tmp=a[i];
      a[i]=a[j];
      a[j]=tmp;
      j++;
    }
  }
  tmp=a[r];
  a[r]=a[j];
  a[j]=tmp;
  return j;
}

void quickSort(Card a[],int p,int r){
  if(p<r){
    int q=partition(a,p,r);
    quickSort(a,p,q-1);
    quickSort(a,q+1,r);
  }
  return;
}

int main(void){
  int i,n;
  bool isStable=1;
  Card a[100000],b[100000];
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i].c;
    cin>>a[i].n;
  }

  memcpy(b,a,sizeof(a));

  margeSort(a,0,n);
  quickSort(b,0,n-1);

  for(i=0;i<n;i++){
    if(a[i].c!=b[i].c){
      isStable=0;
      break;
    }
  }

  if(isStable){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }

  for(i=0;i<n;i++){
    printf("%c %d\n",b[i].c,b[i].n);
  }

	return 0;
}


Measured memory_bytes: 22028
#n=int(input())
l,r,d=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
count=0
for i in range(l,r+1):
    if i%d==0:
        count+=1
print(count)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;

ll max3(ll a, ll b, ll c){
    return max(a, max(b, c));
}

ll min3(ll a, ll b, ll c){
    return min(a, min(b, c));
}

ll solve(ll h, ll w){
    ll ans = LLONG_MAX;

    //初めに縦に切ることを考える

    for(int i = 1; i < w; i++){
        ll piece1 = i * h;

        //残りの部分の横幅はw-i分だけある

        //縦に切る場合
        if(w - i > 1){
            ll w2 = (w - i) / 2;
            ll w3 = (w - i) - w2;

            ll piece2 = w2 * h;
            ll piece3 = w3 * h;

            ans = min(ans, max3(piece1, piece2, piece3) - min3(piece1, piece2, piece3));

        }
        
        //横に切る場合

        if(h > 1){

            ll h2 = h / 2;
            ll h3 = h - h2;
            ll piece2 = h2 * (w - i);
            ll piece3 = h3 * (w - i);

            ans = min(ans, max3(piece1, piece2, piece3) - min3(piece1, piece2, piece3));
        }
    }

    return ans;
}

int main(){

    //大きく分けて,チョコを置いたときに一回縦に切り、もう一度縦に切るか、残りを横に切るかの2パターン
    //一度切ったとき後の残りの部分は半分に切るようにすればよいことは自明のはず

    ll h,w;

    cin >> h >> w;
    ll ans = LLONG_MAX;

    ans = min(ans,solve(h,w));
    ans = min(ans,solve(w,h));
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
  ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))
print(ans)


Measured memory_bytes: 23744
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
B = III()

ans = 0
for i in range(N):
    if i==0:
        ans += B[i]
    elif i==N-1:
        ans += B[i-1]
    else:
        ans += min(B[i-1], B[i])

print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
int main(){
  int x,y,z,a;
  scanf("%d%d",&x,&y);
  if(y>x){
    z=x;
    x=y;
    y=z;
  }
  a=x%y;
  while(a!=0){
    x=y;
    y=a;
    a=x%y;
  }
  printf("%d\n",y);
}



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


def check(T, usable: set):
    for t in T:
        if t not in usable:
            return 0
    return len(T)


def main():
    S = input().rstrip("\n")
    usable = {"A", "C", "G", "T"}
    candidates = []
    for i in range(len(S)):
        for j in range(i, len(S)):
            T = S[i:j+1]
            res = check(T, usable)
            candidates.append(res)

    print(max(candidates))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9028
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& 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 modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

signed main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) {
		cout << "No" << endl;
		cerr << "N" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
N = int(input())
array = list(map(int, input().split()))
sameNum = [0]*(N)
sum = 0
# kを削除していないlistでの組み合わせを調べる
for i in range(N):
    sameNum[array[i]-1] += 1
for i in range(N):
    sum += sameNum[i]*(sameNum[i]-1)//2

for k in range(1, N+1):
    sumT = sum
    print(sumT - sameNum[array[k-1]-1] + 1)

Measured memory_bytes: 81740
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S seconnd
#define int ll
#define PB push_back


int f(int n){

  int res=0;
  while(n){
    res+=n%10;
    n/=10;
  }

  return res;
}

signed main(){
  int n;

  cin>>n;

  int ans = INF;
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  FOR(i,1,n){
    int j=n-i;
    int a = f(i)+f(j);
    ans = min(ans,a);
  }

  cout<<ans<<endl;

}

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for (int i = 0; i < N; ++i)
  {
    int a,b;
    ans = min(ans*2, ans + K);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s=list(map(int,input().split()))
a=0
a=s[0]*s[1]
a=a/2
b=0
c=0
b=s[0]/2
c=s[1]/2
if s[2]==b and s[3]==c:
  print("{0:.10f}".format(a),1)
else:
  print("{0:.10f}".format(a),0)

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

int main()
{
	int a[4] = {}, b[4] = {};
	int hit = 0, blow = 0;

	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3])
	{
		hit = 0; blow = 0;
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				if (a[i] == b[j])
				{
					if (i == j) hit++;
					else blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}


Measured memory_bytes: 3044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll n,m; cin >>n>>m;
    vector<ll> x(n); rep(i,n) cin >> x[i];
    vector<ll> y(m); rep(i,m) cin >> y[i];

    ll h_ans = 0;
    for (ll i = 1; i < n; i++) {
        ll s = (x[i] - x[i-1]);
        s %= MODLL;
        s *= i;
        s %= MODLL;
        s *= (n-i);
        s %= MODLL;
        h_ans += s;
        h_ans %= MODLL;
    }

    ll ans = 0;
    for (ll i = 1; i < m; i++) {
        ll ss = (y[i] - y[i-1]);
        ss %= MODLL;
        ss *= i;
        ss %= MODLL;
        ss *= (m-i);
        ss %= MODLL;
        ss *= h_ans;
        ss %= MODLL;
        ans += ss;
        ans %= MODLL;
    }

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


Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int N;
	
	cin >> N;

	vector<int> P(N);

	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		P[i]--;
	}
	vector<int> idx(N);
	for (int i = 0; i < N; i++) {
		idx[P[i]] = i;
	}
	set<int> s;
	ll ans = 0;
	for (int x = N - 1; x >= 0; x--) {
		int i = idx[x];
		ll c = 0;
		s.insert(i);
		vector<int> l(2, -1);
		vector<int> r(2, N);
		auto it = s.find(i);
		for (int j = 0; j < 2; j++) {
			if (it == s.begin()) {
				break;
			}
			it--;
			l[j] = *it;
		}
		{
			auto it = s.find(i);
			for (int j = 0; j < 2; j++) {
				it++;
				if (it == s.end()) {
					break;
				}
				r[j] = *it;
			}
		}
		vector<int> ls(2);
		ls[0] = i - l[0]; ls[1] = l[0] - l[1];
		vector<int> rs(2);
		rs[0] = r[0] - i; rs[1] = r[1] - r[0];
		c = (ll) ls[0] * rs[1] + (ll) ls[1] * rs[0];

		ans += c * (x + 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main() {

  int a[4] = {0};
  int i,b,n;

  for(i=0;i<4;i++) {

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

    if(b == 1) a[i] = 6000 * n;
    else if(b ==2)a[i] = 4000 * n;
    else if(b == 3) a[i] = 3000 * n;
    else if(b == 4) a[i] = 2000 * n;

  }

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

  return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll N; cin >> N;
  vector<string> s(N);
  REP(i,N) cin >> s[i];
  ll ans = 0;
  REP(a,N) {
    bool ok = true;
    REP(i,N) REP(j,N){
      ll x = (a+i)%N;
      ll y = j%N;
      ll xx = (a+j)%N;
      ll yy =  i%N;
      if(s[x][y] != s[xx][yy]) 
        ok = false;
    }
    if(ok) ans += N;
  }
  cout << ans << endl;
}


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

int main(){

int a[4][13]={0};

int number,n;
char mark;
cin>>n;

for(int i=0;i<n;i++){

cin>>mark>>number;
    if(mark=='S'){
        a[0][number-1]=1;
    }else if(mark=='H'){
        a[1][number-1]=1;
    }else if(mark=='C'){
        a[2][number-1]=1;
    }else if(mark=='D'){
        a[3][number-1]=1;
    }

}

for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
        if(a[i][j]==0){

            if(i==0){
                cout<<"S "<<j+1<<endl;
            }else if(i==1){
                cout<<"H "<<j+1<<endl;
            }else if(i==2){
                cout<<"C "<<j+1<<endl;
            }else if(i==3){
                cout<<"D "<<j+1<<endl;
            }
            
        }
    }
}

    return 0;
}


Measured memory_bytes: 3092
/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

// ====== pbds begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== pbds ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
void speed_solve(){
    ll n;
    cin >> n;
    bool ok = false;
    while(n){
        if(n%10 == 7){
            ok = true;
        }
        n/=10;
    }
    cout << (ok ? "Yes" : "No" ) << nl;
}
int main()
{
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 3648
import math

N = int(input())
S = int(input())

def f(B, N):
    X, res = N, 0
    while 0 < X:
        res += X % B
        X //= B
    return res


if N == S:
    print(N + 1)
    exit()

i = 2
while i * i <= N:
    if f(i, N) == S:
        print(i)
        exit()
    i += 1

sqrtN = math.floor(math.sqrt(N))
i = 1
ans = -1
while i * i < N:
    if (N - S) % i != 0:
        i += 1
        continue
    b = (N - S) // i + 1
    if sqrtN < b and f(b, N) == S:
        ans = b
    i += 1

print(-1 if ans == -1 else ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void) {
	int N;
	scanf("%d", &N);
	int A[100000];
	int sum = 0;
	int a=0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		sum += A[i];
	}


	for (int i = 1; i < N; i+= 2) {
		a += A[i];
	}


	int x = sum -2* a;
	printf("%d\n", x);
	for (int i = 0; i < N-1; i++) {
		x = 2 * A[i] - x;
		printf("%d\n", x);
	}
	
	
	return 0;
}

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


int main() {
long long a,b,c;
  cin>>a>>b>>c;
  vector<long long> vec(3);
  vec[0]=a;
  vec[1]=b;
  vec[2]=c;
  sort(vec.begin(), vec.end()); 
if(a % 2 != 0 && c % 2 != 0 && b % 2 != 0 ){
  cout << vec[0] * vec[1] <<endl;
  
}
  else cout << "0" <<endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  string s; cin >> s;
  s[3] = '8';
  cout << s << endl;
  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define rer(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vi;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest) { 
	cout << arg << " "; Debug(rest...); }
template<class T>ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<< ", ";out<<v.back();}out << "]";return out;}
template<class S, class T>ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";return out;}
const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll phi(ll M) {
	ll A = M;
	for(ll i = 2; i * i <= A; i++) {
		if(A % i == 0) {
			M = M / i * (i - 1);
			while(A % i == 0) A /= i;
		}
	}
	if(A != 1) M = M / A * (A - 1);
	return M;
}

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

ll extgcd(ll a, ll b, ll& x, ll& y) { //get(ax + by = gcd(a, b))
	if(b == 0) {
		x = 1; y = 0;
		return a;
	}
	ll res = extgcd(b, a % b, y, x);
	y -= (a / b) * x;
	return res;
}

ll mod_pow(ll a, ll n, ll mod) { //get a^n mod
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2, mod);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll mod_inv(ll a, ll m) { //get x such that ax=gcd(a, m)(modm)
	ll x, y;
	extgcd(a, m, x, y);
	return (x % m + m) % m;
}

int Q;
ll A, M;

ll loop(ll A, ll M) {
	if(M == 1) return 10000;
	ll K = loop(A, phi(M));
	ll tK = mod_pow(A, K, M);
	return tK + (tK < 100 ? M : 0);
}

void solve() {
	cin >> Q;
	while(Q--) {
		cin >> A >> M;
		ll pM = phi(M);
		ll K = loop(A, M) % M;
		ll pK = loop(A, pM) % pM;
		ll pt = mod_inv(M, pM);
		ll g = gcd(M, pM), l = M * pM / g;
		ll t = ((pK - K) / g * pt) % pM;
		//debug(M, pM, K, pK, pt, g, l, t);
		ll pans = ((t * M % l + K) % l + l) % l;
		ll ans = pans < 100 ? pans + l : pans;
		cout << ans << "\n";
		//debug(mod_pow(A, ans, M), ans % M);
	}
}


int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(5);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}






Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll ans=0,res=0;
    int N;
    cin >> N;
    string S;
    cin >> S;
    rep(i,N){
        if(S[i]=='I'){
            res++;
        }
        else{
            res--;
        }
        chmax(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
a,b = gets.split.map(&:to_i)

n = 1
loop do
    break if (n * 0.08).to_i > a || n / 10 > b

    if (n * 0.08).to_i == a && n / 10 == b
        puts n
        exit
    end

    n += 1
end

puts -1

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

long long N;

int main() {
    cin >> N;
    vector<int> a(N);
    vector<long long> b;
    for (long long i = 0; i < N; i++) {
        cin >> a[i];
        if (i + 1 > N / 2 && a[i]) {
            b.push_back(i + 1);
        }
    }
    for (long long i = N / 2; i > 0; --i) {
        int t = 0;
        for (long long j = 2; j * i <= N; j++) {
            t ^= a[j * i - 1];
        }
        if (t ^ a[i - 1]) {
            b.push_back(i);
            a[i - 1] = 1;
        } else {
            a[i - 1] = 0;
        }
    }
    cout << b.size() << endl;
    for (int i = 0; i < b.size(); i++) {
        cout << b[i] << ' ';
    }
    cout << endl;
}


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

template <typename T>
class BIT_2D {
private:
  int nx; int ny;
  vector<vector<T>> bit;
public:
  BIT_2D(int _nx, int _ny);
  T sum(int i, int j);
  void add(int i, int y, T w);
};

template <typename T>
BIT_2D<T>::BIT_2D(int _nx, int _ny){
   nx = _nx; ny = _ny;
   bit = vector<vector<T>>(nx+1,vector<T>(ny+1,T(0)));
}

template <typename T>
T BIT_2D<T>::sum(int i, int j){
  T s = 0;
  for (int x = i; x > 0; x -= x & -x) {
    for (int y = j; y > 0; y -= y & -y) {
      s += bit[x][y];
    }
  }
  return s;
}

template <typename T>
void BIT_2D<T>::add(int i, int j, T w){
  for (int x = i; x <= nx; x += x & -x){
    for (int y = j; y <= ny; y += y & -y){
      bit[x][y] += w;
    }
  }
}

int main() {
  int n, k;
  cin >> n >> k;
  BIT_2D<int> bit(4*k+1,4*k+1);
  rep(i,n) {
    int x, y; char c;
    cin >> x >> y >> c;
    if(c == 'B') x += k;
    x %= 2*k; y %= 2*k;
    if(x == 0) x = 2*k; if(y == 0) y = 2*k;
    bit.add(x,y,1); bit.add(x,y+2*k,1); 
    bit.add(x+2*k,y,1); bit.add(x+2*k,y+2*k,1);     
  }
  int ans = 0;
  for(int i = 1; i <= 2*k; i++){
    for(int j = 1; j <= 2*k; j++) {
      int c = 0;
      c += bit.sum(k+i-1,k+j-1) - bit.sum(i-1,k+j-1) - bit.sum(k+i-1,j-1) + bit.sum(i-1,j-1);
      c += bit.sum(2*k+i-1,2*k+j-1) - bit.sum(k+i-1,2*k+j-1) - bit.sum(2*k+i-1,k+j-1) + bit.sum(k+i-1,k+j-1);
      ans = max(ans,c);  
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 63104
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        long x = in.nextLong();
        long t = (long)Math.ceil((1 + Math.sqrt(1 + 8 * x)) / 2);
        System.out.println(t - 1);
    }
}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Integer>{
    @Override public Integer get(Object key){return containsKey(key)?super.get(key):0;}
    public void add(T key,int v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final int v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Integer>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, kk, ii = 0;
	cin >> nn >> kk;
	while(nn > 0)
	{
		ii++;
		nn /= kk;
	}
	cout << ii << endl;
	return 0;
}


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

long long int GCD(long long int a, long long int b) {

    if(b > a)
        swap(a, b);

    int c = a % b;
    while(c != 0) {
        a = b;
        b = c;
        c = a % b;
    }

    return b;

}

int main() {

    long long int a, b;

    cin >> a >> b;


  //  cout << GCD(a, b) << endl;

    cout << a * b / GCD(a, b) << endl;

    return 0;

}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    char c;
    cin >> c;
    cout << char(c+1) << endl;
    return 0;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int nax = 2e5 + 100;

vector<int> g[nax];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	#endif
	ll x,y;
	cin>>x>>y;
	int cnt=0;
	while(x<=y){
		cnt++;
		if(x > (y+1)/2)break;
		x*=2;
	}
	cout<< cnt << endl;
}

Measured memory_bytes: 4992