akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  char a, b;
  cin >> a >> b;
  if (a == b) {
    cout << "H\n";
  }
  else {
    cout << "D\n";
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;

// ここから
int d[1000] = {};

// 負経路が存在する場合はtrue,そうでない場合はfalseを返す
bool bellmanFord(const int s, const int size, const graph &g)
{
  REP(i, size)
  {
    d[i] = INF;
  }
  d[s] = 0;

  int counter = 0;
  while (true)
  {
    counter++;
    bool update = false;
    REP(i, g.size())
    {
      for (auto e : g[i])
      {
        if (d[i] != INF && d[e.to] > d[i] + e.cost)
        {
          d[e.to] = d[i] + e.cost;
          update = true;
        }
      }
    }
    if (!update)
      break;
    if (update && counter >= size)
    {
      return true;
    }
  }
  return false;
}
// ここまで

int main()
{
  int v, e, r;
  cin >> v >> e >> r;
  graph g(v);
  REP(i, e)
  {
    int s, t, d;
    cin >> s >> t >> d;
    g[s].push_back({t, d});
  }
  bool cycled = bellmanFord(r, v, g);
  if (cycled)
  {
    cout << "NEGATIVE CYCLE" << endl;
  }
  else
  {
    REP(i, v)
    {
      if (d[i] == INF)
      {
        cout << "INF" << endl;
      }
      else
      {
        cout << d[i] << endl;
      }
    }
  }
}



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

#define FREP(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FREP(i,0,n)
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define endl "\n"
#define ll long long
#define vi vector<ll>
#define si set<ll>
#define mi map<ll,ll>
#define bs binary_search
#define pri(a,n) REP(i,n)cout<<a[i]<<" ";
#define all(x) x.begin(),x.end()
#define sz(a) (ll)a.size()
#define sa(a,n) sort(a,a+n)
#define sra(a,n) sort(a,a+n,greater<ll>())
#define sv(v) sort(all(v))
#define srv(v) sort(v.rbegin(),v.rend())
#define sp(x) setprecision(x)
#define mem(a) memset(a,-1,sizeof(a))
#define ff first
#define ss second
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void g_o_a_l()
{
	ll n, k, q;
	string s;
	cin >> n >> k;
	if (n <= k)
		cout << min(k - n, n);
	else
	{
		if (n % k == 0)
			cout << 0;
		else
		{
			cout << min(n % k, k - (n % k));
		}
	}
}

int main()
{
	FASTIO;

	int t = 1;
	// cin >> t;
	while (t--)
	{
		g_o_a_l();
	}

	return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll x,y; cin>>x>>y;
	int ret=0;
	while(x<=y)
		x<<=1, ret++;
	cout<<ret<<"\n";
	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

int MOD=1e9+7;
ll INF=8e18;

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

int main(){
    int n, m; cin>>n>>m;
    vector<ll> x(n), y(n), sortx, sorty;
    for(int i=0; i<n; i++){
        cin>>x[i]>>y[i];
        sortx.emplace_back(x[i]), sorty.emplace_back(y[i]);
    }
    sort(sortx.begin(), sortx.end());
    sort(sorty.begin(), sorty.end());
    
    ll MIN=(sortx[n-1]-sortx[0])*(sorty[n-1]-sorty[0]);
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=0; k<n; k++){
                for(int l=k+1; l<n; l++){
                    ll left=sortx[i], right=sortx[j], down=sorty[k], up=sorty[l];

                    int cnt=0;
                    for(int id=0; id<n; id++){
                        if(left<=x[id] && x[id]<=right && down<=y[id] && y[id]<=up) cnt++;
                    }
                    if(cnt >= m){
                        MIN=min(MIN, (up-down)*(right-left));
                    }
                }
            }
        }
    }
    cout << MIN << endl;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin >> n >> m;
  if(n<m) swap(n,m);
  ll ans = 1;
  if(n-m>1) cout << 0 << '\n';
  else{
    FOR(i,2,n+1) ans = (ans * (ll)i) % MOD;
    FOR(i,2,m+1) ans = (ans * (ll)i) % MOD;
  	if(n==m) ans = (ans * 2) % MOD;
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
s,t=map(int,input().split())

connection=[[] for i in range(3*n)]
for i in range(m):
  connection[l[i][0]-1].append(l[i][1]-1+n)
  connection[l[i][0]-1+n].append(l[i][1]-1+2*n)
  connection[l[i][0]-1+2*n].append(l[i][1]-1)

def bfs(v):
  distance=[-1]*(3*n)
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*(3*n)
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 and visitct!=3*n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

if bfs(s-1)[t-1]==-1 or bfs(s-1)[t-1]%3!=0:
  print(-1)
else:
  print(bfs(s-1)[t-1]//3)

Measured memory_bytes: 110332
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int digits(i64 x) {
  int res = 0;
  while (x) {
    x /= 10;
    res++;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 N;
  cin >> N;
  int ans = 100000000;
  for (i64 k = 1; k * k <= N; ++k) {
    if (N % k != 0) continue;
    ans = min(ans, max(digits(k), digits(N / k)));
  }
  cout << ans << endl;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	FAST
	ll t; cin>>t;
	while(t--){
		ll n,a,b,c,d;
		cin>>n>>a>>b>>c>>d;
		map<ll,ll> memo;
		function<ll(ll)>dp=[&](ll x){
			if(memo.count(x)) return memo[x];
			if(x<0) assert(0);
			if(x==0) return x;
			if(x==1) return d;
			ll ans=LLINF;
			if(ld(x)*d<ld(1e18)) ans=x*d;
			ans=min(ans,dp(x/2)+a+d*(x&1));
			if(x&1) ans=min(ans,dp(x/2+1)+a+d);
			ans=min(ans,dp(x/3)+b+d*(x%3));
			if(x%3) ans=min(ans,dp(x/3+1)+b+d*(3-x%3));
			ans=min(ans,dp(x/5)+c+d*(x%5));
			if(x%5) ans=min(ans,dp(x/5+1)+c+d*(5-x%5));
			return memo[x]=ans;
		};
		cout<<dp(n)<<'\n';
	}
}


Measured memory_bytes: 4460
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
ll mod = 1000000007;
cpp_int fac(ll n){
    cpp_int a=1;
    for(;n>0;n--){
        a*=n;
    }
    return a;
}
cpp_int n_ck(ll n,ll k){
    cpp_int a=fac(n)/(fac(k)*fac(n-k));
    a %= mod;
    return a;
}
ll n,k;
cpp_int ans,ifac;
int main(){
    cin>>n>>k;
    rep(i,k){
        ifac= n_ck(k-1,i);
        if(i==0){
            ans =n-k+1;
        }else{
            if(n-k>=i+2){
                ans = ifac*((n_ck(n-k-1,i-1))+(n_ck(n-k-1,i))*2+(n_ck(n-k-1,i+1)));
                ans %= mod;
            }else if(n-k>=i+1){
                ans = ifac*((n_ck(n-k-1,i-1))+(n_ck(n-k-1,i))*2);
                ans %= mod;
            }else if(n-k>=i){
                ans = ifac*((n_ck(n-k-1,i-1)));
                ans %= mod;
            }else {
                ans =0;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int):
    acc = 0
    for i in range(1, N+1):
        p = max(0, int(ceil(log2(K / i))))
        acc += (1 / N) * (1 / 2) ** p
    return acc 


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    result = solve(N, K)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5816
dish = [int(input()) for i in range(5)]
reeltime = [10 - (x%10) if x%10 != 0 else (x%10) for x in dish]
a, b = 0, 0
for i, j in zip(dish, sorted(reeltime)):
    a += i
    b += 1
    if b != len(dish):
        a += j
print(a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
    cin >> N;
    vector<long long> a(N);
    long long sum = 0;
    
    for(int i = 0; i < N; ++i) {
        cin >> a.at(i);
        sum += a.at(i) - 1;
    }
    
    cout << sum << endl;

}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k = inpm()
    ans = [1 for _ in range(n)]
    for _ in range(k):
        d = inp()
        a = inpl()
        for i in range(d):
            ans[a[i]-1] = 0
    print(sum(ans))    
if __name__ == "__main__":
    main()

Measured memory_bytes: 10860
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a,b;
		a=sc.nextInt();
		b=sc.nextInt();
		System.out.println(a/b);
		System.out.println(a%b);
		double f,x,z;
		x=a;
		z=b;
		f=x/z;
		System.out.format("%.5f",f);
		System.out.println();
	sc.close();
	}
}


Measured memory_bytes: 26468
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++)
    cin>>p.at(i);
  int c=0;
  int m=n;
  for(int i=0;i<n;i++){
    if(p.at(i)<=m)
      c++;
    m=min(m,p.at(i));
  }
  cout<<c<<endl;
}

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

using namespace std;
const long long INF = 1LL <<60;  

int main(void){
  long long tmp,res=0;
  long long i,j,k;
  long long n;
  long long n_max=200010;
  long long a[n_max]={};
  long long b[n_max]={};
  long long mo=pow(10,9)+7;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  b[n-1]=a[n-1]%mo;
  for(i=n-2;i>=0;i--){
    b[i]=(b[i+1]+a[i])%mo;
    //cout<<b[i]<<endl;
  }
  for(i=0;i<n-1;i++){
    res+=(a[i]%mo*b[i+1])%mo;
    res=res%mo;
    //cout<<(a[i]*b[i+1])%mo<<endl;;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 6756
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    int N;
    cin >> N;
    int D,X;
    cin >> D >> X;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        X++;
        X += (D-1)/A[i];
    }
    cout << X << enld;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
 int a,b,c,i,g=0;
 scanf("%d%d%d",&a,&b,&c);
 for(i=a;i<=b;i++)
 {
  if(c%i==0)
    g++;
 }
 printf("%d\n",g);
}


Measured memory_bytes: 2048
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<u32>();

    for i in 1..10 {
        for j in 1..10 {
            if n == i * j {
                yn(true);
                return;
            }
        }
    }
    yn(false);
}


Measured memory_bytes: 4476
#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,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vp = vector<Pii>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

  int n, x;
  cin >> n >> x;
  int ans = 1;
  vi l(n);
  rep(i, n) {
    cin >> l[i];
    if (i > 0) l[i] += l[i-1];
    if (l[i] <= x) ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();//ボード数
		String sample = s.next();//s.next();//元となる文字
		char[] samples = new char[sample.length()];//sample.length()];//[sample.length()];
		for(int i=0; i<samples.length; i++){
			samples[i] = sample.charAt(i);
			//System.out.println(samples[i]);
		}
		String[] board = new String[N];
		int count=0;
		int muri = 2;
		/*int iend = 0;
		int jend = 0;
		int kend = 0;*/
		int result = 0;
		do{
			board[0] = s.next();
			N--;
		end: for(int i=0; i<board[0].length(); i++){
			if(samples[0]!=board[0].charAt(i)) continue;
			//System.out.println("i="+i);
			//iend=i;
			for(int j=i; j<board[0].length(); j++){
				if(samples[1]!=board[0].charAt(j)) continue;
				//System.out.println("j="+j);
				count = j-i;
				int flag = 2;
				//jend = j;
				muri = 2;
				a:for(int k=j+count; k<board[0].length();k+=count){
					if(samples[muri]!=board[0].charAt(k)){
						k+=count;
						break a;
					}
					//System.out.println("k="+k);
					muri++;
					flag++;
					//kend = k;
					if(flag==sample.length()){
						result++;
						break end;
					}
				}
			}
		}
		}while(N>0);
		//System.out.println(iend+" "+jend+" "+kend);
		System.out.println(result);
	}
}

Measured memory_bytes: 20884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  int cnt=0, cnt2=0;
  int a=s.size(), b=t.size();
  for(int i=0; i<a; i++) {
    cnt=0;
    for(int j=0; j<b; j++) {
      if(i+b<=a) {
        if(s.at(i+j)==t.at(j)) {
          cnt++;
        }
        if(cnt2<cnt) {
          cnt2=cnt;
        }
      }
    }
  }
  cout << b-cnt2 << endl;
  return 0;
}

Measured memory_bytes: 3560
string = str(input())

num = int(input())

for a in range(num):
    order = input()
    if "replace" in order: #strのa文字目からb文字目までをpに置き換える
        order,header,footer,p = order.split()
        header = int(header)
        footer = int(footer)
        
        string = string[:header] + p + string[footer+1:]
        
        
    elif "reverse" in order:#strのa文字目からb文字目までを逆順にする。
        order,header,footer = order.split()
        
        header = int(header)
        footer = int(footer)
        
        reverse = string[header:footer+1]  
        reverse = reverse[::-1]
        string = string[:header] + reverse + string[footer+1:]
        

    elif "print" in order:#strのa文字目からb文字目までを出力する
        order,header,footer = order.split()
        header = int(header)
        footer = int(footer)
        print(string[header:footer+1])


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string s;
  cin>>s;
  int ans=0;
  int idx=-1;
  REP(i, 3){
    if(s[i]=='R'){
      idx=i;
      break;
    }
  }
  if(idx==-1){
    cout<<ans<<'\n';
    return 0;
  }
  FOR(i, idx, 3){
    if(s[i]=='R'){
      ++ans;
    }
    else{
      break;
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
int main() 
{
  int n;
  cin >> n;
  long long h[n+10], dp[n+10];
  for (int i = 0; i < n; ++i) cin >> h[i];
  for (int i = 0; i < n+10; ++i) dp[i] = INF;
  dp[0] = 0;
  for(int i = 0; i < n; ++i){
    dp[i + 1] = min(dp[i] + abs(h[i + 1] - h[i]), dp[i + 1]);
    dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 2]);
  }  
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;
const int maxn=15;
int a[maxn][maxn];
int main() {
	int n,m,tot=0;
	scanf("%d %d",&n,&m);
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1; i<n; i++) {
		for(int j=i+1; j<=n; j++) {
			double dis=0;
			for(int k=1; k<=m; k++) {
				dis+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			dis=sqrt(dis);
			if(dis==(int)dis)tot++;
		}
	}
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var A = items[0];
            var B = items[1];
            var C = items[2];
            var D = items[3];
            string answer;
            while (true)
            {
                // 高橋
                C -= B;
                if (C <= 0)
                {
                    answer = "Yes";
                    break;
                }

                // 青木
                A -= D;
                if (A <= 0)
                {
                    answer = "No";
                    break;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28100
#include <bits/stdc++.h>
using namespace std;
int A[21];
int lan[30];
int m,n;

vector<int>ans,used;

void dfs(int dep,int member,int use){
  if(member == (1<<n)-1) {
    if(ans.size()==0 || ans.size()> used.size()) ans = used;
    return ;
  }
  
  if(dep >= m || dep>=5)return;
  
  for(int i=0;i<m;i++){
    if(use&&(use>>i&1)==0) continue;
    
    int nmember = member | lan[i];
    int nuse = use;
    for(int j=0;j<n;j++)
      if(lan[i]>>j&1) nuse |= A[j];
    
    used.push_back(i);
    dfs(dep+1,nmember,nuse);
    used.pop_back();
  }
}

int main(){
  int flg = 0;
  while(1){
    
  cin>>m>>n;
  if(!m&&!n)break;
  if(flg++) cout<<endl;
  map<string,int> M;
  string name[30];
  for(int i=0;i<m;i++){
    string str;
    cin>>str;
    M[str] = i;
    name[i] = str;
  }

  memset(lan,0,sizeof(lan));
  memset(A,0,sizeof(A));
  
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      string str;
      cin>>str;
      A[i] |= 1<<M[str];
      lan[M[str]] |= 1<<i;
    }
  }

  ans.clear();used.clear();
  dfs(0,0,0);
  if(ans.size()==0) cout<<"Impossible"<<endl;
  else {
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++)cout<<name[ans[i]]<<endl;
  }
  }
  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
double m = 0.00000001;
int main(void){
    // Your code here!
    int X;
    cin >> X;
    set<int> all;
    all.insert(1);
    for(int i = 2; i <= 1000; i++){
        for(int j = 2; j < 100; j++){
            if(pow(i, j) > 1000)continue;
            else{
                all.insert(pow(i, j));
            }
        }
    }
    vector<int> ans(0);
    for(int i = 0; i <= 1000; i++){
        if(all.count(i)){
            ans.push_back(i);
        }
    }
    int a  = 0;
    for(int i = 0; i < ans.size(); i++){
        if(a < ans.at(i) && ans.at(i) <= X){
            a = ans.at(i);
        }
    }
    cout << a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int comp(const void * px, const void * py){
    const char* x = *(const char**)px;
    const char* y = *(const char**)py;

    return strcmp(x,y);
}

int main(void){
    int N,L;
    char **S;
    scanf("%i %i", &N,&L);

    S = (char**)malloc(sizeof(char*)*N);
    for (int i=0; i<N; i++){
        S[i] = (char*)malloc(sizeof(char)*(L+1));
        scanf("%s",S[i]);
    }
    qsort(S,N,sizeof(char**),comp);
    
    for(int i=0; i<N; i++){
        printf("%s",S[i]);
    }


    free(S);

    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define mem(a, x) memset(a, x, sizeof a)
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/*
	----------------------------------------------------------------------
	Things to remember : check for coners n = 1, pass references instead
*/
/* -------------------------------Solution Sarted--------------------------------------*/

//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5
const int INF = 100000000000005; // 1e15 +5

int power(int x, int y){
	int ans = 1;
	while(y > 0){
		if(y&1){
			ans = (ans * x)%MOD;
			--y;
		}else{
			x = (x * x)%MOD;
			y /= 2;
		}
	}
	return ans;
}

void solve(){
	int n, res = 1;
	cin >> n;
	if(n < 2){
		cout << "0\n";
		return;
	}
	cout << ((power(10, n) - (2*(power(9, n)) % MOD) + MOD) % MOD + power(8, n)) % MOD << endl;
}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs 
dfs
fenwik - BIT
binary_search
segment_tree
*/
	

Measured memory_bytes: 3632
#include <iostream>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int n, m;
int t[1000001], p[101], x[101];

int sum(int num)
{
  int sum = 0;
  for(int i = 1; i <= n; i++) {
    if(i == p[num]){
      sum += x[num];
      // cout << p[num] << " " << x[p[num]] << endl;
    }else{
      sum += t[i];
    }
    //cout << "x" << sum << endl;
  }
  return sum;
}

int main()
{
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> t[i];
  cin >> m;
  for(int i = 1; i <= m; i++) cin >> p[i] >> x[i];
  for(int i = 1; i <= m; i++) cout << sum(i) << endl;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=int(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
using namespace std;
typedef long long LL;

const int maxn = 1005;
int a[maxn], n, L, R, p;
LL mx = -1e9, sum1, sum2;
vector<int> ans;

void solve0(int p) {
	per (k, n, p+1) ans.push_back(k);
	rep (k, 1, p-1) ans.push_back(1);
}

void solve1(int p) {
	int i = p, cnt = 0;
	while (i >= 1) {
		if (a[i] >= 0) {
			if (!R) R = i;
			L = i;
		} 
		i -= 2;
	}
	per (k, n, R+1) ans.push_back(k);
	i = R;
	while (i >= L) {
		if (a[i] < 0) ans.push_back(i);
		else cnt++;
		i -= 2;
	}
	rep (k, 1, cnt-1) ans.push_back(L+1);
	rep (k, 1, L-1) ans.push_back(1);
}

int main() {
	scanf("%d", &n);
	rep (i, 1, n) {
		scanf("%d", &a[i]);
		if (a[i] > mx) mx = a[i], p = i;
		if (a[i] >= 0) {
			if (i&1) sum1 += a[i];
			else sum2 += a[i];
		}
	}
	if (mx <= 0) solve0(p);
	else if (sum1 > sum2) solve1(n&1?n:n-1);
	else solve1(n&1?n-1:n);
	if (mx > 0) mx = max(mx, max(sum1, sum2));
	printf("%lld\n%d\n", mx, ans.size());
	rep (k, 0, ans.size()-1)
		printf("%d\n", ans[k]);
	return 0;
}

Measured memory_bytes: 256
import numpy as np

h, w = map(int, input().split())
grid = np.array(['*'*(w+2)] + ['*'+input()+'*' for _ in range(h)] + ['*'*(w+2)])

cnt = np.full((h+3, w+3), h+w, dtype=np.int)
MAX = h + w
for i in range(1, h+2):
    for k in range(1, w+2):
        if i == k == 1:
            cnt[i+1][k+1] = 1 if grid[i][k] == '#' else 0
        else:
            if grid[i][k] == '#':
                if grid[i-1][k] == '#':
                    a = cnt[i][k+1]
                elif grid[i-1][k] == '.':
                    a = cnt[i][k+1] + 1
                else:
                    a = MAX
                if grid[i][k-1] == '#':
                    b = cnt[i+1][k]
                elif grid[i][k-1] == '.':
                    b = cnt[i+1][k] + 1
                else:
                    b = MAX
                cnt[i+1][k+1] = min(a, b)
            else:
                cnt[i+1][k+1] = min(cnt[i][k+1], cnt[i+1][k])

print(cnt[h+1][w+1])


Measured memory_bytes: 12500
#include<stdio.h>

int main(void) {
int i,j;
int num[4];

scanf("%d %d %d", &num[0], &num[1], &num[2]);

for(i = 0; i < 2; i++) {
for(j = 0; j < 2; j++) {
if(num[j] > num[j+1]) {
num[3] = num[j];
num[j] = num[j+1];
num[j+1] = num[3];
}
}
}
printf("%d %d %d\n", num[0], num[1], num[2]);

return (0);
}

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

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

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

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

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

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

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

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    q: usize,
    s: chars,
    query: [(usize, usize); q],
  }
  let mut dp = vec![0; n + 1];
  let mut prev_a = false;
  for (i, &c) in s.iter().enumerate() {
    dp[i + 1] = dp[i];
    if c == 'C' && prev_a {
      dp[i + 1] += 1;
    }
    prev_a = c == 'A';
  }
  for &(l, r) in &query {
    puts!("{}\n", dp[r] - dp[l]);
  }
}


Measured memory_bytes: 8956
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using uint1024_t = mp::uint1024_t;
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	int ans = 0;
	rep(i, n) {
		cin >> a[i];
		ans += a[i] - 1;
	}
	cout << ans << endl;
}

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

int main(){
   int a,b ;
   cin >> a>>b;
   if (2*b>=a)cout <<0 << endl;
   else cout << a -2*b << endl;
   }

Measured memory_bytes: 256
s=input()
def c(b):
  return b=='A' or b=='G' or b=='T' or b=='C'

suc=[]
ct=0
for let in s:
  if c(let):
    ct+=1
  else:
    suc.append(ct)
    ct=0
suc.append(ct)
print(max(suc))

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

const int maxn = 100010;
int n, m, L[200010], R[200010], D[200010];
long long ans[maxn];
vector<pair<int, int>> G[maxn];
bool used[maxn];

void dfs(int v) {
    used[v] = 1;
    for (auto p : G[v]) {
        if (used[p.first]) continue;
        ans[p.first] = ans[v] + p.second, dfs(p.first);
    }
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d %d %d", &L[i], &R[i], &D[i]);
        G[L[i]].push_back({R[i], D[i]});
        G[R[i]].push_back({L[i], -D[i]});
    }
    for (int i = 1; i <= n; i++) {
        if (!used[i]) dfs(i);
    }
    for (int i = 1; i <= m; i++) {
        if (ans[R[i]] - ans[L[i]] != D[i]) printf("No\n"), exit(0);
    }
    printf("Yes\n");
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int h,w,k;
  cin >> h >> w >> k;

  vector<string> b(h);
  rep(i,h) cin >> b[i];

  int ret = 0;
  rep(j, 1 << h){
    rep(i, 1 << w){
      int cnt = 0;
      rep(y, h){
        rep(x, w){
          if( (j & (1 << y)) || (i & (1 << x)) ) continue;
          if(b[y][x] == '#')cnt++;
        }
      }
      if(cnt == k)ret++;
    }
  }

  cout << ret << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
 
 
//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP( a, b) make_pair( a, b )
 
//#define MOD 1000000007ll
#define INF 1000000000
#define endl "\n"
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= ed; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)   
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
// const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const ll N=1e5+5,K=105;
const int si=(1<<20);
const ll M=50+5;
const ll oo=1e18+5;
const double INFdb=1e10;

int n,W;
ll dp[100005]; 
int w[105],val[105];

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
    #endif
    cin>>n>>W;
    for(int i=0;i<100005;++i) dp[i]=oo;
    for(int i=1;i<=n;++i){
		cin>>w[i]>>val[i];
	}
	ll maxval=0;
	for(int i=1;i<=n;++i) maxval+=val[i];
	dp[0]=0;
	for(int i=1;i<=n;++i){
		for(int j=maxval-val[i];j>=0;--j){
			dp[j+val[i]]=min(dp[j+val[i]],dp[j]+w[i]);
		}
	}
	int ans=0;
	for(int i=0;i<100005;++i){
		if(dp[i]<=W){
			ans=i;
		}
	}
	cout<<ans;
	
    cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";                                                                          
    return 0;
}



Measured memory_bytes: 1024
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	if (abs(X - A) > abs(X - B)) {
		OUT("B");
	}
	else {
		OUT("A");
	}
}

Measured memory_bytes: 256
def gcd(x,y):
    if x==0 or y==0:
        return max(x,y)
    if x<y:
        x,y=y,x
    if x%y==0:
        return y
    return gcd(y,x%y)
n=int(input())
a=list(map(int,input().split()))
L=[a[0]]*n
R=[a[-1]]*n
for i in range(n-1):
    L[i+1]=gcd(L[i],a[i+1])
    R[-i-2]=gcd(R[-i-1],a[-i-2])
ans=1
L=[0]+L
R=R+[0]
for i in range(n):
    ans=max(ans,gcd(L[i],R[i+1]))
print(ans)

Measured memory_bytes: 20604
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    vector<string> w(n);
    set<string> s;
    cin >> w[0];
    s.insert(w[0]);

    for (int i = 1; i < n; i++)
    {
        cin >> w[i];

        if (s.find(w[i]) != s.end() || *w[i - 1].rbegin() != *w[i].begin())
        {
            cout << "No" << endl;
            return 0;
        }

        s.insert(w[i]);
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    res = N // 2
    if N % 2 != 0:
      res += 1
    print(res)


main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long 
#define pb push_back
#define fo(i,N) for(int i = 0 ; i < N ; i++)
#define foo(i,x,N) for (int i = x; i < N ; i++)
#define fill(a,val) memset(a,val,sizeof(a))
#define fastio()  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define MAX 1234567
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define all(a) a.begin(),a.end()

long long int KnapSack(long long int wt[],ll val[],int N,long long int W)
{
    ll dp[W+1] = {0};

    for (int  i=0;i<N;i++)
    {
        for (long long int w = W;w>=wt[i];w--)
        {
            dp[w] = max(dp[w],val[i]+dp[w-wt[i]]);
        }
    }

    return dp[W];
}


int main()
{  
   
   int N;
   long long int W;
   cin >> N >> W;
   long long int wt[N];
   ll val[N];
   
   for (int i=0;i<N;i++)
   {
       cin >> wt[i] >> val[i] ;
       
   }
   cout << KnapSack(wt,val,N,W)  <<endl;
 
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<vector>
#include<tuple>
using namespace std;

int main(){
  int n,x,y;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }else{
    cin >> x >> y;
    cout << x + y << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
struct rbtree: tree<T,null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>{};
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define mp make_pair
#define pb push_back
#define lowb lower_bound
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mem0(a) memset((a), 0, sizeof(a))
#define mem(a, b) memset((a), (b), sizeof(a))
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;

int main(){
    IOS;
    int a, b; cin>>a>>b;
    cout<<6-a-b;



    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    long long int a,ansa;
    double b;
    int  c;
    //c=(double)100*b;
    
    scanf("%lld %lf",&a,&b);
    c=(double)100*b +0.001;
    //c=(double)100.00*b;
    //printf("%d",c);
    ansa=(a*c)/100;
    
    printf("%lld\n",ansa);
    return 0;
}

Measured memory_bytes: 1752
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string O, E;
    cin >> O >> E;
    rep(i, E.size()) cout << O[i] << E[i];
    if (O.size() > E.size()) cout << O[E.size()];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

ke=[a,b,c,d,e]
m=min(ke)
if n%m==0:
  print(n//m+4)
else:
  print(n//m+5)

Measured memory_bytes: 3064
# Initializing variables
monsterHP, specialMoves = map(int, input().split())
a = list(map(int, input().split()))
sum = 0

# Calculating if the raccoon can win without using the same move twice or more.
for i in range(specialMoves):
    sum += a[i]

if sum >= monsterHP:
    print("Yes")
else:
    print("No")

# Check out my Youtube channel! https://www.youtube.com/channel/UCMOKVyAbTZOpKikTrX5dy_A







Measured memory_bytes: 13964
def main():
    N = int(input())
    S = input()
    le, ri = 0, 0
    addle, addri = 0, 0
    for s in S:
        if s == ")":
            le += 1
            if le <= ri:
                le -= 1
                ri -= 1
            else:
                le -= 1
                addri += 1
        elif s == "(":
            ri += 1
    addle = ri
    print("("*addri + S + ")"*addle)


if __name__ == '__main__':
    main()


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

int main() {
  int n;cin>>n;
  vector<int> h(n);
  rep(i,n)cin>>h[i];
  int ans=0,cnt=0;
  rep(i,n-1){
    if(h[i]>=h[i+1])cnt++;
    else cnt=0;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3784
h,w = map(int,input().split())
s = [input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            if i-1 >= 0 and i+1 < h and j-1 >= 0 and j+1 < w:
                if s[i-1][j] != "#" and s[i+1][j] != "#" and s[i][j-1] != "#" and s[i][j+1] != "#":
                    print("No")
                    exit()
print("Yes")

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vi p(n); rep(i, n) std::cin >> p[i];
  int ans = 0;
  rep(i, n) {
    if (p[i] == i+1) i++, ans++;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 640
#include <stdio.h>

int main (void) {
    int m, f, r;

    for (;;) {
        char g;
        scanf ("%d %d %d", &m, &f, &r);
        if (m==-1 && f==-1 && r==-1) break;
        if (m==-1 || f==-1) g='F'; 
        else if (m+f>=80) g='A';
        else if (m+f>=65) g='B';
        else if (m+f>=50) g='C';
        else if (m+f>=30 && r>=50) g='C';
        else if (m+f>=30) g='D';
        else if (m+f>=0) g='F';  
        printf ("%c\n", g);
    }
    
    return 0;
}


Measured memory_bytes: 2044