akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,ll>;
using Graph= vector<vector<P>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 
 vector<bool> seen ;
  ll dist[100005] ;
 void dfs(const Graph&G,int v){
  seen[v]=true ;
  for(auto u :G[v]){
    if(seen[u.first]) continue ;
     dist[u.first] = (dist[v]+u.second)%2ll ;
    dfs(G,u.first) ;
 }
 }
int main(){
   int n ;cin>>n ;
  Graph G(n) ;
  rep(i,n-1){
    int a,b ;ll c ;
    cin>>a>>b>>c ;
    a--; b--;
    G[a].eb(mpa(b,c)) ;
    G[b].eb(mpa(a,c)) ;
  }
  dist[0]=0 ;
  seen.assign(n,false) ;
  dfs(G,0) ;
  rep(i,n){
  cout<<dist[i]<<endl ;
  }
  return 0;
  }

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

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

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

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	ll power = 1;
	for(int i = 1; i <= N; i++) {
		power = power * i % mod;
	}
	cout << power << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=200005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll n,m,k;

int main(){
	Init();
	cin>>n>>m>>k;
	cout<<Div(((n-1)*(n+1)*m+(m-1)*(m+1)*n)%mod*nCk(n*m,k)%mod*k%mod*(k-1)%mod,6*(n*m-1))<<endl;
}

Measured memory_bytes: 2300
#include <iostream>

using namespace std;

int S[4];

int main(){
  string str;
  cin >> str;
  for(int i = 0; i < (int)str.size(); ++i){
    S[i] = int(str[i]);
  }

  bool k = true;
  if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]){
    k=false;
  }
  if(k) cout<<"Good"<<endl;
  else cout<<"Bad"<<endl;
}


Measured memory_bytes: 888
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,K;
std::string S;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>K>>S;
	S[K - 1] += -'A' + 'a';
	out << S << endl;

	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M;
	int32_t npow = 1;
	for (int32_t i = 0; i < N; i++)
	{
		npow *= 2;
	}
	
	if (npow-1 <= M) {
		out << "-1" << endl;
		return 0;
	}

	out << M;
	for (int32_t i = 0; i < npow; i++)
	{
		if (i == M) { continue; }
		out << ' ' << i;
	}
	out << ' ' << M;
	for (int32_t i = npow-1; i >= 0; --i)
	{
		if (i == M) { continue; }
		out << ' ' << i;
	}
	out << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
// 2014/07/25 Tazoe

#include <iostream>
#include <string>
using namespace std;

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

	s = s+s;

	if(s.find(p)==string::npos){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N, M = map(int, input().split())
XYZs = []
for n in range(N):
    x, y, z = map(int, input().split())
    XYZs.append((x,y,z))

ans = 0
for i in (1,-1):
    for j in (1,-1):
        for k in (1,-1):
            scores = []
            for x, y, z in XYZs:
                val = x * i + y * j + z * k
                scores.append(val)
            scores.sort()
            scores.reverse()
            ans = max(ans, sum(scores[:M]))
print(ans)



Measured memory_bytes: 8132
#include<iostream>
#define INF 2000000000;
void merge(int*,int,int,int);
void mergeSort(int*,int,int);
int cnt=0;
int main(){
  int n;
  std::cin>>n;
  int A[n];
  for(int i=0;i<n;i++) std::cin>>A[i];
  mergeSort(A,0,n);
  for(int i=0;i<n;i++){
    std::cout<<A[i];
    if(i!=n-1) std::cout<<" ";
  }
  std::cout<<"\n"<<cnt<<"\n";
  return 0;
}
void merge(int *A,int l,int m,int r){
  int n1=m-l,n2=r-m, i, j;
  int L[n1+1];
  int R[n2+1];
  for(i=0;i<n1;i++) L[i]=A[l+i];
  for(i=0;i<n2;i++) R[i]=A[m+i];
  L[n1]=R[n2]=INF;
  i=j=0;
  for(int k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
      cnt++;
    }
    else{
      A[k]=R[j];
      j=j+1;
      cnt++;
    }
  }
}
void mergeSort(int *A,int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    mergeSort(A,l,m);
    mergeSort(A,m,r);
    merge(A,l,m,r);
  }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    cout << (1000 - N % 1000) % 1000 << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()



int main()
{
	int n, res = 0, mx = 100; cin >> n;
	rep(i, 0, n - 1)
	{
		int p;
		cin >> p;
		res += p;
		mx = max(mx, p);
	}
	cout << res - mx / 2 << endl;
}

Measured memory_bytes: 256
use std::io;


fn main() {
    let s = read_one::<String>().chars().collect::<Vec<_>>();
    println!("{}", (s[0] as u8 + 1u8) as char);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    string s;
    cin>>s;
    int n=s.length();
    int i;
    for(i=0;i<n;){
        if(s.substr(i,8)=="dreamera")i+=5;
        else if(s.substr(i,7)=="dreamer")i+=7;
        else if(s.substr(i,5)=="dream")i+=5;
        else if(s.substr(i,6)=="eraser")i+=6;
        else if(s.substr(i,5)=="erase")i+=5;
        else break;
    }
    YN(i==n);
}


Measured memory_bytes: 3716
#import <Foundation/Foundation.h>
int main() {
    @autoreleasepool {
        NSMutableSet *a1 = [NSMutableSet set];
        NSMutableSet *aN = [NSMutableSet set];
        long N,M;
        scanf("%ld %ld",&N,&M);
        for(long i=0;i<M;i++){
            long a,b;
            scanf("%ld %ld",&a,&b);
            if (a==1) {
                [a1 addObject:@(b)];
            }
            if (b==N) {
                [aN addObject:@(a)];
            }
        }
        printf([a1 intersectsSet:aN] ? "POSSIBLE" : "IMPOSSIBLE");
    }
}


Measured memory_bytes: 18220
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin >> a >> b;
    if(a.length()>b.length()){
        cout << "GREATER" << endl;
    }else if(a.length()<b.length()){
        cout << "LESS" << endl;
    }else{
        for(int i = 0; i < a.length(); i++){
            if(a[i]>b[i]){
                cout << "GREATER" << endl;
                break;
            }else if(a[i]<b[i]){
                cout << "LESS" << endl;
                break;
            }else{
                if(i == a.length()-1){
                    cout << "EQUAL" << endl;
                }
            }
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    ll ac = 0, wa = 0, tle = 0, re = 0;
    for(ll i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s == "AC")ac++;
        else if(s == "WA")wa++;
        else if(s == "TLE")tle++;
        else re++;
    }
    cout << "AC x ";
    cout << ac << endl;
    cout << "WA x ";
    cout << wa << endl;
    cout << "TLE x ";
    cout << tle << endl;
    cout << "RE x ";
    cout << re << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<int>a(26);
  for(int i=0;i<s.length();i++)
  {
    a[s[i]-'a']++;
  }
  mint ans=1;
  for(auto y:a)ans=ans*(y+1);
  ans-=1;
  cout<<ans.x<<endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            
            if(x == 0 && y == 0){
                break;
            }else if(x > y){
                System.out.println(y + " " + x);
            }else{
                System.out.println(x + " " + y);
            }
        }

    }
}


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

int main(){
  int N;
  cin >> N;
  
  int fn = 0;
  int x=N;
  while(x>0){
   fn += x%10;
    x= x/10;
  }
  
  if(N % fn == 0){
  cout << "Yes" << endl;
  }
  
  if(N % fn != 0){
  cout << "No" << endl;
  }
  
}








Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
    bool[] usedVertexes = new bool[n];//使用済みの頂点
    List<int>[] nextList = new List<int>[n];//隣接リスト（リストの入った配列）
    List<int> firstList = new List<int>();
    List<int> secondList = new List<int>();
    for(int i = 0; i < n; i++) nextList[i] = new List<int>();//リストの宣言
    
    for(int i = 0; i < m; i++)
    {
      int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      if(i == 0)
      {
        firstList.Add(nums[0]-1);
        secondList.Add(nums[1]-1);
        usedVertexes[nums[0]-1] = true;
        usedVertexes[nums[1]-1] = true;
      }
      nextList[nums[0]-1].Add(nums[1]-1);//隣接リストへ追加。
      nextList[nums[1]-1].Add(nums[0]-1);
    }

    while(true)
    {
      bool continueBool = false;
      for(int i = 0; i < nextList[firstList[firstList.Count()-1]].Count(); i++)
      {
        //Console.WriteLine(firstList[firstList.Count()-1]+"a"+nextList[firstList[firstList.Count()-1]][i]);
        if(!usedVertexes[nextList[firstList[firstList.Count()-1]][i]])
        {
          usedVertexes[nextList[firstList[firstList.Count()-1]][i]] = true;
          firstList.Add(nextList[firstList[firstList.Count()-1]][i]);
          continueBool = true;
          break;
        }
      }
      if(!continueBool) break;
    }

    while(true)
    {
      bool continueBool = false;
      for(int i = 0; i < nextList[secondList[secondList.Count()-1]].Count(); i++)
      {
        if(!usedVertexes[nextList[secondList[secondList.Count()-1]][i]])
        {
          usedVertexes[nextList[secondList[secondList.Count()-1]][i]] = true;
          secondList.Add(nextList[secondList[secondList.Count()-1]][i]);
          continueBool = true;
          break;
        }
      }
      if(!continueBool) break;
    }

    int[] answers = new int[firstList.Count() + secondList.Count()];
    for(int i = 0; i < firstList.Count(); i++)
    {
      answers[i] = firstList[firstList.Count()-1-i]+1;
    }
    for(int i = 0; i < secondList.Count(); i++)
    {
      answers[firstList.Count()+i] = secondList[i]+1;
    }

		Console.WriteLine(firstList.Count() + secondList.Count());
    Console.WriteLine(string.Join(" ", answers));
	}
}

Measured memory_bytes: 28676
#include <iostream>
#define ll long long int
using namespace std;
ll five(ll x){
    ll ans = x * x * x * x * x;
    return ans;
}
ll judge(ll &val){
    ll l, r;
    l = -1.3e3, r = -l;
    while(l < r){
        ll mid = (l + r) / 2;
        // cout << mid << endl;
        ll f = five(mid);
        if(f < val){
            l = mid + 1;
        }
        else if(f > val){
            r = mid - 1;
        }
        else{
            l = r = mid;
        }
    }
    if(five(l) == val){
        val = l;
        return true;
    }
    else if(five(l - 1) == val){
        val = l - 1;
        return true;
    }
    return false;
}
int main(){
    ll x;
    cin >> x;
    ll _A, _B;
    for(ll B = -1e3; B <= 1e3; ++B){
        // cout << B << endl;
        ll val = x + five(B);
        if(judge(val)){
            _A = val;
            _B = B;
            break;
        }
    }
    cout << _A << " " << _B << endl;
    return 0;
}


Measured memory_bytes: 3620
n=int(input())
s=input()
worddic={0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T",20:"U",21:"V",22:"W",23:"X",24:"Y",25:"Z"}
word=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
nowindex=0
ans=""

for i in range(len(s)):
  nowindex=word.index(s[i])
  if nowindex+n<=25:
    ans+=worddic[nowindex+n]
  else:
    ans+=worddic[nowindex+n-26]
print(ans)

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


int main()
{
	ll N;
	cin >> N;
	vector<ll> H(N), res(N);
	rep(i, N)cin >> H[i];
	rep(i, N - 1) {
		if (H[i] >= H[i + 1])res[i + 1] = res[i] + 1;
	}
	cout << *max_element(res.begin(), res.end()) << endl;

	return 0;
}


Measured memory_bytes: 1792
def main():
	n,m = map(int,input().split())
	a = list(map(int,input().split()))
	
	a_up = [i for i in a if i >= (sum(a)/(4*m))]
	if len(a_up) >= m:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <queue>
#include <tuple>

using namespace std;

using PII = pair<int, int>;

int main() {
	int n, m;
	cin >> n >> m;

	int a, b;
	vector<vector<int>> connect(n+1);

	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		connect[a].push_back(b);
		connect[b].push_back(a);
	}

	vector<int> froms(n+1, -1);
	queue<PII> que;

	que.emplace(1, 0);
	int pos, from;
	while (!que.empty()) {
		tie(pos, from) = que.front();
		que.pop();

		if (froms[pos] != -1) {
			continue;
		}

		froms[pos] = from;
		for (auto to: connect[pos]) {
			if (froms[to] == -1) {
				que.emplace(to, pos);
			}
		}
	}

	cout << "Yes" << endl;
	for (int i = 2; i <= n; i++) {
		cout << froms[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 10268
#include <cstdio>
#include <vector>
#include <queue>
#define INF 1LL<<60
using namespace std;

typedef long long Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    for(auto &f:g[e.dst]) {
      if (dist[f.dst] > e.weight+f.weight) {
        dist[f.dst] = e.weight+f.weight;
        Q.push(Edge(f.src, f.dst, e.weight+f.weight));
      }
    }
  }
}

int main(){
	int i,V,E,start,goal,s,t,e,f;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d",&V,&E);
		scanf("%d%d",&start,&goal);start--,goal--;
		Graph g(V),h(V);
		for(;E--;){
			scanf("%d%d%d%d",&s,&t,&e,&f);
			g[s-1].push_back(Edge(s-1,t-1,e)),g[t-1].push_back(Edge(t-1,s-1,e));
			h[s-1].push_back(Edge(s-1,t-1,f)),h[t-1].push_back(Edge(t-1,s-1,f));
		}
		vector<Weight> dist1,dist2;
		vector<int> prev;
		shortestPath(g,start,dist1,prev);
		prev.clear();
		shortestPath(h,goal,dist2,prev);
		vector<long long>r(V+1);
		for(i=V-1;i>=0;i--)r[i]=max(r[i+1],1000000000000000LL-dist1[i]-dist2[i]);
		for(i=0;i<V;i++)printf("%lld\n",r[i]);
	//}
}


Measured memory_bytes: 19268
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int N;
    cin >> N;
    vector<int> bank;
    map<int, int> check;

    vector<int> cost = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
    vector<ll> dp(N + 1, INF);
    dp[0] = 0;
    repd(i, 1, N + 1) {
        rep(j, cost.size()) {
            if (i >= cost[j]) chmin(dp[i], dp[i - cost[j]] + 1);
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  # j-i=Ai+Aj
  # Ai+i=j-Aj

  a=[]
  b={}
  for i in range(n):
    x=l[i]
    a.append(x+i)
    y=i-x
    if y in b:
      b[y]+=1
    else:
      b[y]=1

  ans=0
  for x in a:
    if x in b:
      ans+=b[x]

  return ans

# main()
print(main())


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

int main (int, char**) {
    int money;
    std::cin >> money;
    int m500 = money / 500;
    money = money % 500;
    int m5 = money /5;
    std::cout << 1000 * m500 + 5 * m5 << std::endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A.sort()

res = 0
count = 0
for i in range(1, 3 * N):
    if i%2 == 0:
        res += A[-i]
        count += 1
        
    if count == N:
        break
    
print(res)

Measured memory_bytes: 39492
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,z,k; cin>>x>>y>>z>>k;
int cnt=0;
while(x>=y){
y*=2;
cnt++;
}
while(y>=z){
z*=2;
cnt++;
}
if(cnt<=k)  cout<<"Yes\n";
else   cout<<"No\n";
}

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

int main(){
  int h,w;cin >> h >> w;
  vector<string> a(h);
  for(int i=0;i<h;++i) cin >> a.at(i);
  for(int i=0;i<h;++i){
    cout << a.at(i) << endl;
    cout << a.at(i) << endl;
  }
}

Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll h, w;
  char s[110][110];
  scanf("%lld%lld", &h, &w);
  for (int i = 0; i < h; i++)
  {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < h; i++)
  {
    printf("%s\n%s\n", s[i], s[i]);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >>n;
    int a[n];
    int co=0;
    int m;
    long long sum=0;
    for(int i=0;i<n;i++){
        cin >>a[i];
        if(a[i]<0){co++;
            a[i]*=-1;
        }
        if(i==0)m=a[i];
        else {
            m=min(m,a[i]);
        }
        sum+=a[i];

    }
    if(co%2!=0){
        sum-=m*2;
    }

    cout <<  sum<< endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>
#include<vector>
using namespace std;

vector<int> num(4);
vector<string> ans(3);

void set_array(int n){
    if(n < 10){
        num[0] = 0;
        num[1] = 0;
        num[2] = 0;
        num[3] = n;
    }
    else if(n < 100){
        num[0] = 0;
        num[1] = 0;
        num[2] = n / 10;
        num[3] = n % 10;
    }
    else if(n < 1000){
        num[0] = 0;
        num[1] = n / 100;
        num[2] = (n - num[1] * 100) / 10;
        num[3] = n - num[1] * 100 - num[2] * 10;
    }
    else{
        num[0] = n / 1000;
        num[1] = (n - num[0] * 1000) / 100;
        num[2] = (n - num[0] * 1000 - num[1] * 100) / 10;
        num[3] = n - num[0] * 1000 - num[1] * 100 - num[2] * 10;
    }
}

void cal(int a, int b, int c, int d){
    if(a + b + c + d == 7){
        ans[0] = "+";
        ans[1] = "+";
        ans[2] = "+";
    }
    else if(a + b + c - d == 7){
        ans[0] = "+";
        ans[1] = "+";
        ans[2] = "-";
    }
    else if(a + b - c + d == 7){
        ans[0] = "+";
        ans[1] = "-";
        ans[2] = "+";
    }
    else if(a - b + c + d == 7){
        ans[0] = "-";
        ans[1] = "+";
        ans[2] = "+";
    }
    else if(a - b - c - d == 7){
        ans[0] = "-";
        ans[1] = "-";
        ans[2] = "-";
    }
    else if(a - b - c + d == 7){
        ans[0] = "-";
        ans[1] = "-";
        ans[2] = "+";
    }
    else if(a - b + c - d == 7){
        ans[0] = "-";
        ans[1] = "+";
        ans[2] = "-";
    }
    else if(a + b - c - d == 7){
        ans[0] = "+";
        ans[1] = "-";
        ans[2] = "-";
    }
}

int main(){
    string str;
    cin >> str;
    int n = atoi(str.c_str());

    set_array(n);
    cal(num[0], num[1], num[2], num[3]);

    cout << num[0] << ans[0] << num[1] << ans[1] << num[2] << ans[2] << num[3] << "=7" << endl;

    //cout << num[0] << num[1] << num[2] << num[3] <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define rep(i,s,e) for ( int i = s; i <= e; i++)
#define MAX 15
#define TREE 1
#define JUMP 2
#define SNOW 0
int X, Y;
int G[MAX+2][MAX+2];

int compute(){
    int T[MAX+2][MAX+2];
    rep(y,0,Y+1) rep(x,0,X+1) T[y][x] = 0;

    rep(x,1,X){
	if ( G[0][x] == TREE || G[0][x] == JUMP ) continue;
	int s = -1, t = 1;
	if ( 0 == Y-1 ) s = t = 0;
	rep(dx,s,t){ // G[0][x] == SNOW
	    if ( G[1][x+dx] == SNOW ) T[1][x+dx]++;
	    if ( G[1][x+dx] == JUMP && dx == 0 ) T[1][x+dx]++;
	}
    }

    rep(y,1,Y-1) rep(x,1,X){
	if ( G[y][x] == SNOW ){
	    int s = -1, t = 1;
	    if ( y == Y-1 ) s = t = 0;
	    rep(dx,s,t){
		if ( G[y+1][x+dx] == SNOW ) T[y+1][x+dx] += T[y][x];
		if ( G[y+1][x+dx] == JUMP && dx == 0 ) T[y+1][x+dx] += T[y][x];
	    }
	} else if ( G[y][x] == JUMP ){
	    if ( G[y+2][x] != TREE ) T[y+2][x] += T[y][x];
	}
    }

    int sum = 0;
    rep(y,Y,Y+1) rep(x,1,X) sum += T[y][x];
    return sum;
}

main(){
    while( cin >> X >> Y && X && Y ){
	rep(y,0,Y-1) rep(x,0,X+1) G[y][x] = TREE;
	rep(y,Y,Y+1) rep(x,0,X+1) G[y][x] = SNOW;
	rep(y,0,Y-1) rep(x,1,X) cin >> G[y][x];
	cout << compute() << endl;
    }
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll N;
    int X,M;
    Scll(N);
    Scd2(X,M);

    vl c(M,-1);
    vl v(M,0);
    ll t = X;
    ll ans = 0;
    Rep(i,N){
        c[t] = i;
        v[t] = ans;
        ans += t;
        t = t*t%M;
        if( c[t] != -1 && i < N-1e6 ){
            int m = i-c[t]+1;
            ans += (N-i-1)/m*(ans-v[t]);
            i += (N-i-1)/m*m;
        }
    }

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

    return 0;
}



Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
const ll mod = 1000000007;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    for(ll i = K; i <= N + 1; i++) {
        ll K = i;
        ll mini = K * (K - 1) / 2;
        ll maxi = (N) * (N+1) / 2;
        maxi -= (N-K) * (N+1-K) / 2;
        //cerr << mini << " " << maxi << endl;
        ans += maxi - mini + 1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 238032
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
	double t , ans =0;
	int n , k , now;
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		t = 1.0 / n;
        now = i;
		while(now < k){
			now *= 2;
            t /= 2;
		}
		ans += t;
	}
    cout << fixed << setprecision(20) << ans << endl;
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int h, w;
void print(vector<string> &data) {
  REP(i, h) {
    REP(j, w) { cout << data[i][j]; }
    cout << endl;
  }
}

int main() {
  ll ans = 0;
  ll cnt = 0;
  vector<string> data;
  cin >> h >> w;
  REP(i, h) {
    string s;
    cin >> s;
    data.push_back(s);
  }
  queue<pair<int, int>> candidate;
  REP(i, h) {
    REP(j, w) {
      if (data[i][j] == '#') {
        candidate.push(make_pair(i, j));
        cnt++;
      }
    }
  }
  while (true && cnt != h * w) {
    ans++;
    queue<pair<int, int>> tmp;
    while (!candidate.empty()) {
      pair<int, int> p = candidate.front();
      candidate.pop();
      if (p.first - 1 >= 0 && data[p.first - 1][p.second] == '.') {
        data[p.first - 1][p.second] = '#';
        tmp.push(make_pair(p.first - 1, p.second));
        cnt++;
      }
      if (p.first + 1 < h && data[p.first + 1][p.second] == '.') {
        data[p.first + 1][p.second] = '#';
        tmp.push(make_pair(p.first + 1, p.second));
        cnt++;
      }
      if (p.second - 1 >= 0 && data[p.first][p.second - 1] == '.') {
        data[p.first][p.second - 1] = '#';
        tmp.push(make_pair(p.first, p.second - 1));
        cnt++;
      }
      if (p.second + 1 < w && data[p.first][p.second + 1] == '.') {
        data[p.first][p.second + 1] = '#';
        tmp.push(make_pair(p.first, p.second + 1));
        cnt++;
      }
    }
    candidate = tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12752
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,A=ilint()
B=[abs(a) for a in A]
if sum([a<0 for a in A])%2==0:
    print(sum(B))
else:
    print(sum(B)-2*min(B))

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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;
typedef vector<int> vi;
const int maxn = 100 + 10;

int main() {
    ll n;
    cin >> n;
    ll x;
    bool ok = false;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        if (x & 1) ok = true;
    }
    cout << (ok ? "first" : "second") << endl;
    return 0;
}


Measured memory_bytes: 256
# A - Diverse Word
import numpy as np

S = input()
alphabet = np.zeros(26, dtype=int)
for i in S:
    alphabet[ord(i)-97]=1
if len(S)<26:
    add = alphabet.argmin()
    ans = S + chr(add+97)
else:
    i = 24
    while(i>=0 and S[i]>S[i+1]):
        i -= 1
    if i==-1:
        ans = '-1'
    else:
        j = 25
        while(i+1<j and S[i]>S[j]):
            j -= 1
        ans = S[:i] + S[j]

print(ans)

Measured memory_bytes: 12488
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

#define INF 1000

pii dir4[2] = {
    {0, 1},
    {1, 0},
};

enum type {
    TYPE_NONE,
    TYPE_WALL,
    TYPE_PATH
};

typedef pair<int,int> pii;
typedef pair<int, pii> vertex;

#define breaks first
#define p second

int main(void) {
    int row, col;
    cin >> row >> col;
    vector<vector<int>> mat(row+2, vector<int>(col+2));
    for(int i = 1; i <= row; i++) {
        string str;
        cin >> str;
        for(int j = 1; j <= col; j++) {
            mat[i][j] = (str[j-1] == '.') ? TYPE_PATH : TYPE_WALL;
        }
    }
    pii start = make_pair(1, 1);
    pii goal = make_pair(row, col);
    vector<vector<int>> cnts(row+2, vector<int>(col+2, INF));
    // ##...##: 3
    // .....##: 1
    // ##.....: 2
    cnts[start.first][start.second] = (mat[start.first][start.second] == TYPE_WALL);

    priority_queue<vertex, vector<vertex>, greater<vertex>> queue;
    queue.push(make_pair(cnts[start.first][start.second], start));
    while(!queue.empty()) {
        vertex v = queue.top(); queue.pop();
        debug("%d, %d -> %d\n", v.p.first, v.p.second, v.breaks);
        int type = mat[v.p.first][v.p.second];
        if(v.p == goal) break;
        for(pii d: dir4) {
            pii np = make_pair(
                v.p.first + d.first,
                v.p.second + d.second
            );
            if(mat[np.first][np.second] == TYPE_NONE) continue;
            int nnew = cnts[v.p.first][v.p.second];
            if(mat[np.first][np.second] != type) nnew++;
            if(cnts[np.first][np.second] > nnew) {
                // update
                cnts[np.first][np.second] = nnew;
                queue.push(make_pair(nnew, np));
            }
        }
    }
    cout << (cnts[goal.first][goal.second]+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  const long long INF = LLONG_MAX / 10;
  long long mi[2] = {INF, INF}, ma[2] = {-INF, -INF};
  for (int i = 0; i < N; i++) {
    long long x, y;
    cin >> x >> y;
    mi[0] = min(mi[0], x + y);
    ma[0] = max(ma[0], x + y);
    mi[1] = min(mi[1], x - y);
    ma[1] = max(ma[1], x - y);
  }
  cout << max(ma[0] - mi[0], ma[1] - mi[1]) << '\n';
  return 0;
}


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

int main() {
  int a,b,c,d,e,f,k;
  cin >>a>>b>>c>>d>>e>>k;
  if (e-a>k) {
    cout << ":(";
  }
  else {
    cout << "Yay!";
  }
  cout << endl;
}


Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
if S[0] == S[1] == S[2]:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 5836
#include <bits/stdc++.h>
using namespace std;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int H, W;
vector<vector<char>> field;

bool is_valid_operation(int h, int w) {
    if (field[h][w] == '#') return false;
    return true;
}

int main() {
    cin >> H >> W;
    field.assign(H + 2, vector<char>(W + 2, '.'));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> field[i][j];
        }
    }
    vector<vector<int>> out(H + 2, vector<int>(W + 2, 0));

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (field[i][j] == '#') {
                for (int k = i - 1; k <= i + 1; k++) {
                    for (int l = j - 1; l <= j + 1; l++) {
                        if (is_valid_operation(k, l)) out[k][l]++;
                    }
                }
            }
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (field[i][j] == '#') {
                cout << '#';
            } else {
                cout << out[i][j];
            }
        }
        cout << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    if(A[0]!=0){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=0;
    bool flag=true;
    for(int i=N-1;i>0;--i){
        if(A[i]>A[i-1]+1){
            cout<<-1<<endl;
            return 0;
        }
        if(flag){
            ans+=A[i];
            flag=false;
        }
        if(A[i]!=A[i-1]+1){
            flag=true;
        }
    }
    cout<<ans<<endl;
}


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

int sumdigits(int n) {
  if (n<10) {
    return n;
  }
  return sumdigits(n/10)+(n%10);
}
int main() {
  int N;
  scanf("%d",&N);
  int f_N=sumdigits(N);
  if (N%f_N==0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef struct node{
  int p,lc,rc;
  
} node;

node tree[100];

int rootid;

void pre(int x){
  printf(" %d",x);
  if(tree[x].lc>-1){
    pre(tree[x].lc);
  } 
  if(tree[x].rc>-1){
    pre(tree[x].rc);
  } 
}

void in(int x){
  if(tree[x].lc>-1){
    in(tree[x].lc);
  } 
  printf(" %d",x);
  if(tree[x].rc>-1){
    in(tree[x].rc);
  }  
}

void post(int x){
  if(tree[x].lc>-1){
    post(tree[x].lc);
  }
  if(tree[x].rc>-1){
    post(tree[x].rc);
  } 
  printf(" %d",x);
}

int main(){

 
  int n,d,d2,k,l,id;
  int i,j;

  for(i=0;i<100;i++){
    tree[i].p=-1;
    tree[i].lc=-1;
    tree[i].rc=-1;

  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&tree[id].lc,&tree[id].rc);
    tree[tree[id].lc].p=id;
    tree[tree[id].rc].p=id;
  }


  for(rootid=0;rootid<n;rootid++)
    if(tree[rootid].p==-1)break;
  printf("Preorder\n");
  pre(rootid);
  printf("\nInorder\n");
  in(rootid);
  printf("\nPostorder\n");
  post(rootid);
  printf("\n");
  return 0;
}

Measured memory_bytes: 616