akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll inputLValue(){
    ll a;
    cin >> a;
    return a;
};

int main()
{
    int N = inputValue();
    set<int> list1;
    set<int> list2;
    set<int> list3;
    string S;
    cin >> S;
    REP(i, S.length()-2){
        int m = (S[i] - '0');
        if(list1.find(m) != list1.end()){
            continue;
        }
        list1.insert(m);
        FOR(j, i+1, S.length()-1){
            int n = (S[i] - '0') * 100 + (S[j] - '0') * 10;
            if(list2.find(n) != list2.end()){
                continue;
            }
            list2.insert(n);
            FOR(k, j+1, S.length()){
                int p = (S[i] - '0') * 100 + (S[j] - '0') * 10 + (S[k] - '0');
                if(list3.find(p) != list3.end()){
                    continue;
                }
                list3.insert(p);
            }
            if(list3.size()==1000){
                break;
            }
        }
        if(list3.size()==1000){
            break;
        }
    }

    cout << list3.size() << endl;
}


Measured memory_bytes: 384
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]

right = [A[0][0]]
for i in range(1, N):
    tmp = right[-1]
    right.append(tmp + A[0][i])

maxv = 0
for i in range(N):
    ans = right[i]
    for j in range(i, N):
        ans += A[1][j]
    maxv = max(ans, maxv)
print(maxv)


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
#define FOR(i, m, n) for(llong i = m;i < n;i++)
int MAX_N = 100000;
#define REP(i, n) for(llong i = 0;i < n;i++)
int MAX_W = 100000;


int N;
vector<long long> A;
 
void solve() {
    vector<long long> plus, minus;
    for (int i = 0; i < N; ++i) {
        if (A[i] >= 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }
    sort(plus.begin(), plus.end(), greater<long long>());
    sort(minus.begin(), minus.end());
    if (minus.empty()) minus.push_back(plus.back()), plus.pop_back();
    if (plus.empty()) plus.push_back(minus.back()), minus.pop_back();
 
    vector<pair<long long, long long> > res;
    long long cur = minus[0];
    for (int i = 0; i+1 < plus.size(); ++i) {
        res.push_back({cur, plus[i]});
        cur -= plus[i];
    }
    res.push_back({plus.back(), cur});
    cur = plus.back() - cur;
 
    for (int i = 1; i < minus.size(); ++i) {
        res.push_back({cur, minus[i]});
        cur -= minus[i];
    }
 
    cout << cur << endl;
    for (auto p : res) cout << p.first << " " << p.second << endl;
}
 
int main() {
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    solve();
}

Measured memory_bytes: 5872
n = int(input())
t = input()

count = 1
if n % 2 == 1:
  count = 0
else:
  h = int(n/2)
  for i in range(h):
    if t[i] != t[i+h]:
      count = 0
if count == 0:
  print('No')
else:
  print('Yes')


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

using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string s;
    cin >> s;
    ll n = stol(s);
    string ans;
    while (n >= 1) {
        ans += char('a' + (n - 1) % 26);
        n = (n - 1) / 26;
    }
    reverse(all(ans));
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3628
macro_rules! input {
     (source = $s:expr, $($r:tt)*) => {
         let mut iter = $s.split_whitespace();
         input_inner!{iter, $($r)*}
     };
     ($($r:tt)*) => {
         let s = {
             use std::io::Read;
         let mut s = String::new();
         std::io::stdin().read_to_string(&mut s).unwrap();
         s
     };
     let mut iter = s.split_whitespace();
     input_inner!{iter, $($r)*}
     };
}
     
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap,};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    input!{
        q: i64,
        h: i64,
        s: i64,
        d: i64,
        n: i64,
    }
    let mono = [4*q,2*h, s].iter().cloned().min().unwrap();
    let bi = min(2*mono, d);
    println!("{}", bi * (n / 2) + mono * (n % 2));
}


Measured memory_bytes: 4352
S = list(input())

p1 = ['0' if i % 2 == 0 else '1' for i in range(len(S))]
p2 = ['0' if i % 2 == 0 else '1' for i in range(1, len(S) + 1)]

d1, d2 = 0, 0
for k in range(len(S)):
    if S[k] == p1[k]:
        d1 += 1
    if S[k] == p2[k]:
        d2 += 1

res = min(d1, d2)
print(res)

Measured memory_bytes: 50828
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

typedef long long ll;
//最大公約数
ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
//最小公倍数
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}



const int NM = 200000;//ここを問題の制約を見ながらいじる．配列の確保に使う．
int A[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．

// Main program
void solve(){
  int N;
  int out=0;
  cin >> N;
  for (int i=0;i<N;i++){
    cin >> A[i];
  }
 
  int last=1;
  for(int i=0;i<N;i++){
    if(A[i] == last){
      last++;
    }
    else{
      out++;
    }
  }  

  if(out == N){
    out = -1;
  }
  cout << out;
  return;
}

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






Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int INF=1e9+5;
const int N=2e5+5;
const int mod=998244353;

int id[N];
int n;
vector<int> v[N];
vector<int> have[3];

void dfs(int u,int par){
	for(int& x:v[u]){
		if(x==par) continue;
		id[x]=3-id[u];
		dfs(x,u);
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;++i){
		int x,y;
		cin>>x>>y;
		--x;
		--y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	id[0]=1;
	dfs(0,-1);
	for(int i=0;i<n;++i){
		have[id[i]].push_back(i);
	}
	vector<int> cnt(3);
	for(int i=1;i<=n;++i) ++cnt[i%3];
	vector<int> group(n);
	vector<bool> used(n+1);
	if((int)have[1].size()<=cnt[0]){
		int beg=3;
		for(int x:have[1]){
			group[x]=beg;
			used[beg]=1;
			beg+=3;
		}
		int beg1=1;
		for(int i=0;i<n;++i){
			if(group[i]) continue;
			while(used[beg1]) ++beg1;
			group[i]=beg1;
			++beg1;
		}
	}
	else if((int)have[2].size()<=cnt[0]){
		int beg=3;
		for(int x:have[2]){
			group[x]=beg;
			used[beg]=1;
			beg+=3;
		}
		int beg1=1;
		for(int i=0;i<n;++i){
			if(group[i]) continue;
			while(used[beg1]) ++beg1;
			group[i]=beg1;
			++beg1;
		}
	}
	else{
		int beg=3;
		for(int i=0;i<cnt[1];++i){
			group[have[1][i]]=3*i+1;
		}
		for(int i=cnt[1];i<(int)have[1].size();++i){
			group[have[1][i]]=beg;
			beg+=3;
		}
		for(int i=0;i<cnt[2];++i){
			group[have[2][i]]=3*i+2;
		}
		for(int i=cnt[2];i<(int)have[2].size();++i){
			group[have[2][i]]=beg;
			beg+=3;
		}
	}
	for(int i=0;i<n;++i) cout<<group[i]<<" ";	
	return 0;
}


Measured memory_bytes: 22260
def main():
	w, h, *L = map(int, open(0).read().split())
	x, y, ans = w, h, 0
	for c in sorted(L[:w] + [-q for q in L[w:]], key=abs):
		if c > 0:
			if x:
				ans += c * (y + 1)
				x -= 1
		else:
			if y:
				ans -= c * (x + 1)
				y -= 1
		if x == y == 0:
			break
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 26468
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d;
  string s,ss,sss;
  long long ans = 0;
  string anss = "";
  
  cin >> s >> ss >> sss;

  anss += toupper(s[0]);
  anss += toupper(ss[0]);
  anss += toupper(sss[0]);
  
  cout << anss << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int S = sc.nextInt();

        int h = S / 3600;
        int mm = S / 60;
        int m = mm % 60;
        int s = S % 60;

        System.out.println( h + ":" + m  + ":" + s );


	}
}


Measured memory_bytes: 26152
#include <iostream>
#include <string>

using namespace std;

string reverse(string b) {
	if (b.size() == 1) {
		return b;
	} else {
		return reverse(b.substr(1))+b[0];
	}
}

int main() {
	string a;
	string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string zyx = "ZYXWVUTSRQPONMLKJIHGFEDCBAZYXWVUTSRQPONMLKJIHGFEDCBA";
	while (cin >> a) {
		if (a == ".") {
			break;
		}
		int counter = 0;
		string b;
		for (int i = 0; i < a.size(); i++) {
			if (a[i] == '+') {
				counter++;
			} else if (a[i] == '-') {
				counter--;
			} else if (a[i] != '[' && a[i] != ']') {
				if (counter > 0 && counter > 25) {
					counter %= 26;
				} else if (counter < 0 && counter < -25) {
					counter = -((-counter)%26);
				}
				if (counter == 0 || a[i] == '?') {
					b += a[i];
				} else if (counter > 0) {
					for (int j = 0; ; j++) {
						if (a[i] == abc[j]) {
							b += abc[j+counter];
							break;
						}
					}
				} else {
					for (int j = 0; ; j++) {
						if (a[i] == zyx[j]) {
							b += zyx[j-counter];
							break;
						}
					}
				}
				counter = 0;
			} else {
				b += a[i];
			}
		}
		while (b.find('[') != string::npos) {
			int f = 0;
			int t = b.size();
			t--;
			for (int i = 0; i < b.size(); i++) {
				if (b[i] == '[') {
					f = i;
				} else if (b[i] == ']') {
					t = i;
					break;
				}
			}
			b = b.substr(0, f) + reverse(b.substr(f+1, t-f-1)) + b.substr(t+1);
		}
		for (int i = 0; i < b.size(); i++) {
			if (b[i] == '?') {
				b[i] = 'A';
			}
		}
		cout << b << endl;
	}
	return 0;
}

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

int main()
{
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (!(0 <= x - r && x + r <= W)) cout << "No" << endl;
	else if (!(0 <= y - r && y + r <= H)) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1160
n=int(input())
nil=-1
sn=[[-1,-1,-1]for _ in range(n)]
child=[[]for _ in range(n)]
def getdepth(u):
	d=0
	while sn[u][0] != nil:
		u=sn[u][0]
		d+=1
	return d
aa=[]
for i in range(n):
	a=list(map(int,input().split()))
	aa.append(a)
aa.sort()
for i in range(n):
	a=aa[i]
	for j in range(a[1]):
		sn[a[j+2]][0]=a[0]
		if j==0:
			sn[a[0]][1]=a[j+2]
		if j!=a[1]-1:
			sn[a[j+2]][2]=a[j+1]
		child[i].append(a[j+2])
for i in range(n):
	ans1="node "+str(i)+":"
	ans2="parent = "+str(sn[i][0])+","
	ans3="depth = "+str(getdepth(i))+","
	if sn[i][0]==nil:
		ans4="root"
	elif sn[i][1]==nil:
		ans4="leaf"
	else:
		ans4="internal node"
	ans4+=","
	print(ans1,ans2,ans3,ans4,child[i])



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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string n;
  cin >> n;

  ll total = 0;
  for(auto c:n){
    char value = c - '0';
    total += (ll)value;
  }
  if(total%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3748
/*  -*- coding: utf-8 -*-
 *
 * 2708.cc: ABC Gene
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 5000;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  string s;
  cin >> s;

  while (s.size() > 3) {
    int cs[3] = {0, 0, 0}, n = s.size(), m = 0;
    string t;

    for (int i = 0; i < n;) {
      if (i + 2 < n && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
	t += 'x';
	i += 3;
      }
      else {
	cs[s[i] - 'A']++;
	t += s[i];
	i++;
      }
      m++;
    }

    int zn = 0, zc = -1;
    for (int i = 0; i < 3; i++)
      if (cs[i] == 0) zn++, zc = i;

    if (zn != 1) {
      puts("No");
      return 0;
    }

    for (int i = 0; i < m; i++)
      if (t[i] == 'x') t[i] = 'A' + zc;
    swap(s, t);
    //cout << s << endl;
  }

  if (s == "ABC") puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 3236
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n,sum=0;
	cin>>n;
	vector<int> num,v;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		num.push_back(k);
		v.push_back(k);
		sum+=num[i];
	}
	sort(v.begin(),v.end());
	int a,b;
	a=v[n/2-1];
	b=v[n/2];
	for(int i=0;i<n;i++){
		if(a==b||a<num[i])
			cout<<a<<endl;
		else
			cout<<b<<endl;
	}
	return 0;
}

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

#define rep(n, i) for (size_t i = 0; i < (n); ++i)

using ll = long long;
using namespace std;

template <long long N>
class Modulo {
 public:
  using Type = decltype(N);
  // constructor
  constexpr Modulo (Type n = 0) : number_((N + n) % N) {}
  // unary operator
  constexpr auto operator - () const {
    return Modulo(-number_);
  }
  constexpr auto operator ~ () const {
    // Only if N is prime, and number_ and N are coprime
    return power(*this, N - 2);
  }
  // compound assign operator
  constexpr auto & operator += (const Modulo & m) {
    number_ = (number_ + m.number_) % N;
    return *this;
  }
  constexpr auto & operator -= (const Modulo & m) {
    return *this += -m;
  }
  constexpr auto & operator *= (const Modulo & m) {
    number_ = (number_ * m.number_) % N;
    return *this;
  }
  constexpr auto & operator /= (const Modulo & m) {
    return *this *= ~m;
  }
  // binary operator with type conversion
  constexpr friend auto operator + (Modulo lhs, const Modulo & rhs) {
    return lhs += rhs;
  }
  constexpr friend auto operator - (Modulo lhs, const Modulo & rhs) {
    return lhs -= rhs;
  }
  constexpr friend auto operator * (Modulo lhs, const Modulo & rhs) {
    return lhs *= rhs;
  }
  constexpr friend auto operator / (Modulo lhs, const Modulo & rhs) {
    return lhs /= rhs;
  }
  // friend function
  constexpr friend auto power (const Modulo & m, Type exponent) {
    constexpr auto unit = Modulo(1);
    if ( exponent == 0 ) return unit;
    return (exponent & 1 ? m : unit) * power(m*m, exponent >> 1);
  }
  constexpr friend auto number (const Modulo & m) {
    return m.number_;
  }
  // stream operator
  friend auto & operator << (std::ostream & os, const Modulo & m) {
    return os << number(m);
  }
 private:
  Type number_;
};

template <typename T>
class Combinatorics {
 public:
  explicit Combinatorics (int n) : fac_(n + 1), inv_(n + 1) {
    fac_[0] = 1;
    for (int i = 1; i <= n; ++i) {
      fac_[i] = fac_[i - 1] * i;
    }
    inv_[n] = ~fac_[n];
    for (int i = n; 1 <= i; --i) {
      inv_[i - 1] = inv_[i] * i;
    }
  }
  auto combination(int n, int r) {
    return fac_[n] * inv_[r] * inv_[n - r];
  }
 private:
  vector<T> fac_;
  vector<T> inv_;
};

int
main ()
{
    using Number = Modulo<1'000'000'007ll>;
    auto x = Combinatorics<Number>(200'000);
    auto c = [&x](int n, int r){ return x.combination(n, r); };

    int n; ll k;
    cin >> n >> k;

    auto max_allow_empty = (int)min(k, ll(n - 1));

    auto answer = Number(0);
    for (int i = 0; i <= max_allow_empty; ++i) {
      answer += c(n, i) * c(n - 1, i);
    }
    cout << answer << endl;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = 0;
		int min = 0;
		for(int i = 0; i < n-1; i++) {
			if(a[i] > a[i+1]) {
				ans += a[i] - min;
				min = a[i+1];
			}
		}
		ans += a[n-1] - min;
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32744
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int N = scanner.nextInt();
    long K = scanner.nextLong();
    long[][] a = new long[N][N];
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) a[i][j] = scanner.nextInt();

    long[][] b = matpow(a, K, M);
    long res = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        res += b[i][j];
        if (res > M) res -= M;
      }
    }
    System.out.println(res);
  }

  private static long[][] matpow(long[][] a, long n, long M) {
    if (n == 1) return a;
    if (n % 2 == 1) {
      return matmult(matpow(a, n - 1, M), a, M);
    } else {
      long[][] b = matpow(a, n / 2, M);
      return matmult(b, b, M);
    }
  }

  private static long[][] matmult(long[][] a, long[][] b, long M) {
    int n = a.length;
    long[][] res = new long[n][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < n; k++) {
          res[i][j] += (a[i][k] * b[k][j]) % M;
          if (res[i][j] > M) res[i][j] -= M;
        }
      }
    }
    return res;
  }
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
	bool flg = false;
	rep(i, 3){
		if(s[i] == '7') flg=true; 
	}

	if(flg){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7748
#include<iostream>
#include <vector>
#include <cstdlib>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
#include <list>
#define ll long long 
using namespace std;
ll md=1000000007;



class DisjSet { 
    int *rank, *parent, n; 
  
public: 
    // Constructor to create and 
    // initialize sets of n items 
    DisjSet(int n) 
    { 
        rank = new int[n]; 
        parent = new int[n]; 
        this->n = n; 
        makeSet(); 
    } 
  
    // Creates n single item sets 
    void makeSet() 
    { 
        for (int i = 0; i < n; i++) { 
            parent[i] = i; 
        } 
    } 
  
    // Finds set of given item x 
    int find(int x) 
    { 
        // Finds the representative of the set 
        // that x is an element of 
        if (parent[x] != x) { 
  
            // if x is not the parent of itself 
            // Then x is not the representative of 
            // his set, 
            parent[x] = find(parent[x]); 
  
            // so we recursively call Find on its parent 
            // and move i's node directly under the 
            // representative of this set 
        } 
  
        return parent[x]; 
    } 
  
    // Do union of two sets represented 
    // by x and y. 
    void Union(int x, int y) 
    { 
        // Find current sets of x and y 
        int xset = find(x); 
        int yset = find(y); 
  
        // If they are already in same set 
        if (xset == yset) 
            return; 
  
        // Put smaller ranked item under 
        // bigger ranked item if ranks are 
        // different 
        if (rank[xset] < rank[yset]) { 
            parent[xset] = yset; 
        } 
        else if (rank[xset] > rank[yset]) { 
            parent[yset] = xset; 
        } 
  
        // If ranks are same, then increment 
        // rank. 
        else { 
            parent[yset] = xset; 
            rank[xset] = rank[xset] + 1; 
        } 
    } 
}; 
  
int main() 
{ 
    ll n,m;
    cin>>n>>m;
    DisjSet obj(n); 
    //cout<<1<<endl;
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        obj.Union(x-1, y-1);

    }
    //cout<<2<<endl;
    vector <ll> arr (n+1);
    for( ll i=0;i<=n;i++)
    {
        arr[i]=0;
    }
   // cout<<4<<endl;
    ll ans=0;
    for( ll i=0;i<n;i++)
    {
        ll temp=obj.find(i);
     //  cout<<temp<<endl;
        arr[temp]++;
        if(arr[temp]>ans)
        {
            ans=arr[temp];
        }


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

Measured memory_bytes: 6320
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();
        int k = cin.nextInt();

        int trick = n;

        bool[] sunuke = new bool[n];

        for (int i = 0; i < k; ++i)
        {
            int d = cin.nextInt();

            int[] a = cin.ArrayInt(d);

            for (int j = 0; j < d; ++j)
            {
                if (sunuke[a[j]-1] == false)
                {
                    sunuke[a[j]-1] = true;
                    --trick;
                }
            }
        }

        WriteLine(trick);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

int main() {
    int n;
    cin >> n;
    double tot = 0;
    while (n--) {
        string u;
        double x;
        cin >> x >> u;
        if (u == "JPY") tot += x;
        else tot += (x * 380000);
    }
    cout << tot << '\n';
    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define pb push_back
#define mp make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<int>;
using vii=vector<vi>;
using pii=pair<int,int>;
const ll MOD=1e9+7;
const int MAX=1e5+1;
const ll INF=(1ll<<62)-1;
signed main(){
    int N,Q; cin>>N>>Q;
    vector<pair<pii,int>> Data(N);
    rep(i,0,N){
        int X,Y,Z; cin>>X>>Y>>Z;
        Data[i].first.second=Y-Z-1;
        Data[i].first.first=X-Z;
        Data[i].second=Z;
    }
    sort(ALL(Data));
    int memo=0;
    std::priority_queue<pii,vector<pii>,std::greater<pii>> que;
    std::map<int,int> Dist;
    rep(i,0,Q){
        int Time; cin>>Time;
        for(memo;memo<N;memo++){
            if(Data[memo].first.first<=Time){
                Dist[Data[memo].second]++;
                pii set=std::mp(Data[memo].first.second,Data[memo].second);
                que.push(set);
            }
            else break;
        }
        while(!que.empty()){
            pii Data_set=que.top();
            if(Data_set.first>=Time) break;
            que.pop();
            Dist[Data_set.second]--;
            if(Dist[Data_set.second]==0) Dist.erase(Data_set.second);
        }
        int ans;
        if(Dist.size()>0){
            auto small=*begin(Dist);
            ans=small.first;
        }
        else ans=-1;
        cout<<ans<<endl;
    }
}
 



Measured memory_bytes: 14576
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
char s[100010];
int r[100010];
bool flag;
int main()
{
	int n;
	while(scanf("%d",&n)==1)
	{
		scanf("%s",s);
		int num=0;
		while(num<4)
		{
			flag=true;
			if(num==0)
			{
				r[0]=1;
			    r[1]=1;
			}
			if(num==1)
			{
				r[0]=1;
			    r[1]=0;
			}
			if(num==2)
			{
				r[0]=0;
			    r[1]=1;
			}
			if(num==3)
			{
				r[0]=0;
			    r[1]=0;
			}
			//printf("%d %d\n",r[0],r[1]);
			for(int i=0;i<n;i++)
			{
				if(i==0)
				{
					if(s[i]=='o')
					{
						if(r[i]==1)
						r[n-1]=r[i+1];
						if(r[i]==0)
						r[n-1]=1-r[i+1];
					}
					if(s[i]=='x')
					{
						if(r[i]==1)
						r[n-1]=1-r[i+1];
						if(r[i]==0)
						r[n-1]=r[i+1];
					}
				}
				
				if(i==n-1)
				{
					if(s[i]=='o')
					{
						if(r[i]==1)
						if(r[i-1]!=r[0])
						flag=false;
						if(r[i]==0)
						if(r[i-1]==r[0])
						flag=false;
					}
					if(s[i]=='x')
					{
						if(r[i]==1)
						if(r[i-1]==r[0])
						flag=false;
						if(r[i]==0)
						if(r[i-1]!=r[0])
						flag=false;
					}
				}
				
				if(i>0&&i<n-2)
				{
					if(s[i]=='o')
					{
						if(r[i]==1)
						r[i+1]=r[i-1];
						if(r[i]==0)
						r[i+1]=1-r[i-1];
					}
					if(s[i]=='x')
					{
						if(r[i]==1)
						r[i+1]=1-r[i-1];
						if(r[i]==0)
						r[i+1]=r[i-1];
					}
				}
				
				if(i==n-2)
				{
					if(s[i]=='o')
					{
						if(r[i]==1)
						if(r[i-1]!=r[i+1])
						flag=false;
						if(r[i]==0)
						if(r[i-1]==r[i+1])
						flag=false;
					}
					if(s[i]=='x')
					{
						if(r[i]==1)
						if(r[i-1]==r[i+1])
						flag=false;
						if(r[i]==0)
						if(r[i-1]!=r[i+1])
						flag=false;
					}
				}
			}
			/*for(int i=0;i<n;i++)
			printf("%d",r[i]);
			cout<<endl;*/
			if(flag)
			break;
			num++;
		}
		if(flag)
		for(int i=0;i<n;i++)
		{
			if(r[i]==1)
			printf("S");
			else printf("W");
		}
		else printf("-1");
		printf("\n");
	}
	return 0;
} 

Measured memory_bytes: 768
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- U.unfoldrN n (C.readInt.C.dropWhile isSpace) <$> C.getLine
    print $ solve n xs

solve :: Int -> U.Vector Int -> Int
solve n xs = U.foldl' max (maximum [g, rs U.! 1, ls U.! (n - 2)])
    $ U.zipWith gcd ls $ U.drop 2 rs
  where
    g = U.foldl1' gcd xs
    ls = U.scanl1 gcd xs
    rs = U.scanr1 gcd xs

-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

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

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

    int ans = b;
    if(a <= 5) ans = 0;
    else if(a <= 12) ans = b / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void change_fs(int num);

int main(void)
{
	int in;
	
	while (1){
		scanf("%d", &in);
		if (in == -1){
			break;
		}
		
		change_fs(in);
		printf("\n");
	}
	
	return (0);
}

void change_fs(int num)
{
	if (num > 3){
		change_fs(num / 4);
	}
	
	printf("%d", num % 4);
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
using namespace std;
 
int main()
{
	string a,b;
	int x;
	int zh(string s);
	
	cin>>a>>b;
	
	x=zh(a+b);
	
	if(int(sqrt(x))==sqrt(x))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	return 0;
}
 
int zh(string s)
{
	int tmp=0;
	
	for(int i=0;i<s.size();i++)
		tmp=tmp*10+(s[i]-'0');
	
	return tmp;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String str = "";
		String mei = "";
		String fro = "";
		String bac = "";
		String mew = "";
		String out = "";
		int q = 0;
		int a = 0;
		int b = 0;
		
		str = as.nextLine();
		q = as.nextInt();
		
		for(int i=0;i<q;i++){
			
			mei = as.next();
			
			switch(mei){
			case "print":
				a = as.nextInt();
				b = as.nextInt();
				
				out = str.substring(a,b+1);
				System.out.println(out);
				break;
			
			case "reverse":
				a = as.nextInt();
				b = as.nextInt();
				
				bac = str.substring(b+1,str.length());
				//System.out.println(bac);
				fro = str.substring(0,a);
				//System.out.println(fro);
				str = str.substring(a,b+1);
				//System.out.println(str);
				
				StringBuffer sb = new StringBuffer(str);
				str = sb.reverse().toString();
				
				str = fro+str+bac;
				//System.out.println("!!"+str);
				break;
				
			case "replace":
				a = as.nextInt();
				b = as.nextInt();
				mew = as.next();
				
				StringBuffer sc = new StringBuffer(str);
				str = sc.replace(a, b+1, mew).toString();
				//System.out.println(str);
				break;
			
			
			}
			
		}

	}

}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  int N, M, L, R, LL, RR;
  cin >> N >> M;
  LL = 0;
  RR = N + 1;
  REP(i, M){
    cin >> L >> R;
    if(LL < L) LL = L;
    if(RR > R) RR = R;
  }

  int ans = RR - LL + 1;
  if(ans < 0) ans = 0;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int X, A, B;
  cin >> X >> A >> B;

  int rest = X;
  rest = rest-A; //A円のケーキを買う

  rest = rest%B; //B円のドーナツをできるだけ買う

  cout << rest << endl;
  
  
  return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    string s; cin >> s;
    int a = s.size(), z = 0;
    rep(i, s.size()) {
        if (s[i] == 'A') a = min(a, i);
        else if (s[i] == 'Z') z = max(z, i);
    }
    cout << z - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF = 1000000007;
typedef long long ll;
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(){
  int n;
  cin>>n;
  cout << n * n << endl; 
  return 0;
}

Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e6 + 120;
 

int n ,a[maxn] ,k;
pii maxx;

int main(){FAST;
    
       forp(i,0,3){
           cin >> a[i];
           if(a[i] > maxx.first)
               maxx.first = a[i] ,maxx.second = i;
       }
       cin >> k;
     forp(i ,0 ,3)
         if(i != maxx.second)
             n += a[i];
        cout << n + (1 << k) * maxx.first;    
   return 0;
}	
 












Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, m;

    cin >> n;

    int t[n];
    int sum = 0;

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

    cin >> m;

    int p[m], x[m];

    for (int i=0; i<m; i++) {
        cin >> p[i] >> x[i];
    }

    for (int i=0; i<m; i++) {
        cout << sum-t[p[i]-1]+x[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)

vector<vector<ll>> vec(100001, vector<ll>(3));
vector<vector<ll>> dp(100001, vector<ll>(3));

int main() {
    ll n;
    cin >> n;
    rep(i,n){
        rep(j,3){
            cin >> vec.at(i).at(j);
        }
    }

    //dp配列だけ[1]は1日目。他は[0]が1日目
    for(ll i = 0; i < n; i ++){
        for(ll j = 0; j < 3; j++){
            for(ll k = 0; k < 3; k++){
                if(j == k) continue;
                chmax(dp.at(i + 1).at(k), dp.at(i).at(j) + vec.at(i).at(k));
            }
        }
    }

    ll res = 0;
    rep(i,3){
        chmax(res, dp.at(n).at(i));
    }
    cout << res << endl;

}


Measured memory_bytes: 11136
#include <iostream>
#include <string>

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

    int n = 0;
    std::string pp;
    std::string p;
    std::string c;
    for (int i=0; i<S.size(); ++i) {
        c += S[i];
        if (p == c) continue;
        n += 1;
        pp = p;
        p = c;
        c = "";
    }
    if (c != "") {
        if (p != c) {
            n += 1;
        }
    }
    std::cout << n << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;


int main()
{
  long long N,max,max2,maxidx;
  cin >> N;
  max = max2 = 0;
  for(int i=0;i<N;i++)
  {
    long long t;
    cin >> t;
    if(t > max)
    {
      max = t;
      maxidx = i;
    }
    else if(t > max2)
    {
      max2 = t;
    }
  }
  
  for(int i=0;i<N;i++)
  {
    if(i == maxidx)
    {
      cout << max2 << endl;
    }
    else
    {
      cout << max << endl;
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, T;
    cin >> N >> T;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<ll> B(N);
    B[0] = A[0];
    for (ll i = 1; i < N; i++) {
        B[i] = min(B[i-1], A[i]);
    }
    vector<ll> C(N);
    for (ll i = 0; i < N; i++) {
        C[i] = A[i] - B[i];
    }

    ll ma = 0;
    for (ll i = 0; i < N; i++) {
        ma = max(ma, C[i]);
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        if(ma == C[i]) ans++;
    }

    printf("%lld\n", ans);

}

Measured memory_bytes: 5624
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
s = input()

ans = 0
for i in range(1,n):
    res = 0
    r = 0
    for a,b in zip(s,s[i:]):
        if a == b:
            res += 1
            if res > r: r = res
        else:
            res = 0
#    print(r)
    if r > i: r = i
    if ans < r: ans = r

print(ans)



Measured memory_bytes: 44316