akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <atcoder/all>
using namespace atcoder;
//using mint = modint998244353;
//using mint = modint1000000007;
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//using i128 = __int128_t;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
constexpr char ln = '\n';
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
inline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);}
inline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);}
inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}
inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
inline int kthbit(long long x, int k) {return (x>>k)&1;}
inline void print() {cout << "\n";}
template<class T>
inline void print(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << " ";
    print();
}
template<class T, class... Args>
inline void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
#ifdef MINATO_LOCAL
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
inline void debug() {cerr << endl;}
template<class T>
inline void debug(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << " ";
    debug();
}
template<class T, class... Args>
inline void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
#else
#define dump(x) void(0)
inline void debug() {}
template<class T> inline void debug(const vector<T> &v) {}
template<class T, class... Args> inline void debug(const T &x, const Args &... args) {}
#endif
struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    string S; cin >> S;
    auto SA = suffix_array(S);
    auto LCP = lcp_array(S,SA);
    ll ans = (ll)(SZ(S))*(SZ(S)+1)/2;
    for (auto i : LCP) ans -= i;
    cout << ans << ln;
}


Measured memory_bytes: 15564
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};

int main() {
    int a,b;
    cin >> a>>b;
    if (a==1 || a==3 || a==5 || a==7 || a==8 || a==10 || a==12){
        a=31;
    }
    else if(a==2){
        a=28;
    }
    else{
        a=30;
    }
        if (b==1 || b==3 || b==5 || b==7 || b==8 || b==10 || b==12){
        b=31;
    }
    else if(b==2){
        b=28;
    }
    else{
        b=30;
    }
    if (a==b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;


int main(){
	long long a,b,c,d,e;
	cin>>a>>b;
	c=a+b;
	d=a-b;
	e=a*b;
	c=max(c,max(e,d));
	cout<<c<<endl;
	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

using Tup = tuple<ll, ll, ll, ll>;

void solve() {
    ll H, W;
    cin >> H >> W;
    vector<Vi> cell(H, Vi(W));
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            cin >> cell[i][j];
        }
    }
    vector<Tup> ans;
    for (ll i = 0; i < H; i++) {
        if (!(i & 1)) {
            for (ll j = 0; j < W - 1; j++) {
                if (cell[i][j] & 1) {
                    --cell[i][j];
                    ++cell[i][j + 1];
                    ans.emplace_back(i, j, i, j + 1);
                }
            }
            if (i < H - 1 && cell[i][W - 1] & 1) {
                --cell[i][W - 1];
                ++cell[i + 1][W - 1];
                ans.emplace_back(i, W - 1, i + 1, W - 1);
            }
        }
        else {
            for (ll j = W - 1; j >= 1; j--) {
                if (cell[i][j] & 1) {
                    --cell[i][j];
                    ++cell[i][j - 1];
                    ans.emplace_back(i, j, i, j - 1);
                }
            }
            if (i < H - 1 && cell[i][0] & 1) {
                --cell[i][0];
                ++cell[i + 1][0];
                ans.emplace_back(i, 0, i + 1, 0);
            }
        }
    }

    cout << ans.size() << "\n";
    for (const auto& v : ans) {
        ll a, b, c, d;
        tie(a, b, c, d) = v;
        cout << a + 1 << " " << b + 1 << " " << c + 1 << " " << d + 1 << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 7412
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC146
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string ans = "";
            for(int i = 0; i < s.Length; i++)
            {
                int a = abc.IndexOf(s[i]);
                ans += abc[a + n];
            }
            Console.WriteLine(ans);
        }

    }
}

Measured memory_bytes: 34772
using System;
using System.Linq;

namespace _4_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int kosuu = Int32.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(x);
            long Sum = 0;
            for (int i = 0; i < kosuu; i++)
            {
                Sum += x[i];
            }
            Array.Sort(x);
            Console.WriteLine(x[0] + " " + x[kosuu - 1] + " " + Sum);
        }
    }
}

Measured memory_bytes: 10540
a, b = map(int, input().split())

if (a ** 2) * b % 2 != 0 or a * (b ** 2) % 2 != 0:
    print("Yes")
elif (a ** 2) * b % 2 == 0 or a * (b ** 2) % 2 == 0:
    print("No")

Measured memory_bytes: 9060
/*
 * 2657.cc: Books
 */

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

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

string ts[MAX_N], as[MAX_N];
int ds[MAX_N];

/* subroutines */

inline int ymd2n(string &s) {
  int y = atoi(s.substr(0, 4).c_str());
  int m = atoi(s.substr(5, 2).c_str());
  int d = atoi(s.substr(8, 2).c_str());
  return y * 10000 + m * 100 + d;
}

bool match(int i, string &t, string &a, string &fd, string &td) {
  if (t != "*" && ts[i].find(t) == string::npos) return false;
  if (a != "*" && as[i].find(a) == string::npos) return false;
  if (fd != "*") {
    int fdn = ymd2n(fd);
    if (fdn > ds[i]) return false;
  }
  if (td != "*") {
    int tdn = ymd2n(td);
    if (tdn < ds[i]) return false;
  }
  return true;
}

/* main */

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

  for (int i = 0; i < n; i++) {
    string ymd;
    cin >> ts[i] >> as[i] >> ymd;
    ds[i] = ymd2n(ymd);
  }

  int q;
  cin >> q;

  for (int i = 0; i < q; i++) {
    string t, a, fd, td;
    cin >> t >> a >> fd >> td;

    if (i > 0) putchar('\n');
    
    for (int i = 0; i < n; i++)
      if (match(i, t, a, fd, td)) cout << ts[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
n,k,l = map(int,input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf1 = UnionFind(n+1)
uf2 = UnionFind(n+1)
for i in range(k):
    a,b = map(int,input().split())
    uf1.union(a,b)
for i in range(l):
    a,b = map(int,input().split())
    uf2.union(a,b)
root1 = [uf1.find(i) for i in range(1,n+1)]
root2 = [uf2.find(i) for i in range(1,n+1)]
check = [[root1[i],root2[i],i] for i in range(n)]
check.sort(key=lambda x: (x[0],x[1]))
ans = [0]*n
cnt = 1
wait = []
for i in range(n-1):
  if cnt == 1:
    wait.append(check[i][2])
  if check[i][:2] == check[i+1][:2]:
    cnt += 1
    wait.append(check[i+1][2])
  else:
    for j in wait:
      ans[j] = cnt
    wait = []
    cnt = 1
if cnt == 1:
  ans[check[n-1][2]] = 1
else:
  for j in wait:
    ans[j] = cnt
print(*ans)

Measured memory_bytes: 59968
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 5/5/2020
 
 10:48-
 
 */

const int MAX_N=1e3+1;
LL A[MAX_N][3];
int N,M;

const LL Inf=1e18;
void solve() {
  LL res=-Inf;
  REP(mask,8) {
    vector<LL> B(N);
    REP(i,N)REP(j,3) {
      LL sign=((mask>>j)&1)?1:-1;
      B[i]+=A[i][j]*sign;
    }
    sort(ALL(B)),reverse(ALL(B));
    SMAX(res,accumulate(B.begin(),B.begin()+M,0LL));
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,N)REP(j,3) cin>>A[i][j];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    ans = max(0, A - (2 * B))
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll x,a,b;cin>>x>>a>>b;
  if(a>=b)cout<<"delicious"<<endl;
  else if(b-a<=x)cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;


  return 0;
}

Measured memory_bytes: 256
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let s = get_line();
    if s == "ABC" {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


Measured memory_bytes: 2080
// Problem : D - Bouquet
// Contest : AtCoder Beginner Contest 156
// URL : https://atcoder.jp/contests/abc156/tasks/abc156_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inf LLONG_MAX
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,a,b;cin>>n>>a>>b;
int x=2000005;
factorial(x);
inverse(x);
int ans=(Pow(2,n)-1+md)%md;
int calc1=1,calc2=1;
for(int i=0;i<a;i++)
calc1=(calc1*(n-i))%md;
for(int i=0;i<b;i++)
calc2=(calc2*(n-i))%md;
calc1=(calc1*inv[a])%md;
calc2=(calc2*inv[b])%md;
ans=(ans-calc1-calc2+2*md)%md;
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 31488
#include <iostream>

using namespace std;

int N, M, Q, X[501][501] = {{0}};
pair<int, int> pq[100001];

int main()
{
    cin >> N >> M >> Q;
    for (int i = 1; i <= M; i++) {
        int tmpL, tmpR;
        cin >> tmpL >> tmpR;
        X[tmpL][tmpR]++;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            X[i][j] += X[i][j - 1];
        }
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            X[i][j] += X[i - 1][j];
        }
    }


    for (int i = 1; i <= Q; i++) {
        int p, q;
        cin >> pq[i].first >> pq[i].second;
    }

    for (int i = 1; i <= Q; i++) {
        cout << X[pq[i].second][pq[i].second] - X[pq[i].first - 1][pq[i].second]
             << endl;
    }

    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
const int maxn = 123456;
vector<int> e[maxn];
int dis[maxn], par[maxn], good[maxn];
void dfs(int u, int v){
	par[u] = v;
	for(int nxt : e[u]){
		if(nxt == v) continue;
		dis[nxt] = dis[u] + 1;
		dfs(nxt, u);
	}
}
int main(){
	int n; cin >> n;
	for(int i = 0; i < n - 1; i++){
		int u, v; cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	auto bad = [](){
		cout << -1 << endl;
		exit(0);
	};
	dis[1] = 0; dfs(1, 0);
	int mx = max_element(dis + 1, dis + 1 + n) - dis;
	dis[mx] = 0; dfs(mx, 0);
	int mn = max_element(dis + 1, dis + 1 + n) - dis;
	{
		int tail = mn;
		while(tail){
			good[tail] = 1;
			tail = par[tail];
		}
	}
	for(int i = 1; i <= n; i++){
		int sum = good[i];
		for(int v : e[i]) sum += good[v];
		if(sum == 0) bad();
	}
	auto get = [&](int head){
		vector<int> path;
		int id = 1, lhead = -1;
		while(head != -1){
			int nxt = -1, sum = 0;
			for(int v : e[head]){
				if(v == lhead) continue;
				if(good[v]) nxt = v;
				else {
					sum++;
				}
			}
			int me = id++;
			for(int j = 0; j < sum; j++) path.push_back(id++);
			path.push_back(me);
			lhead = head;
			head = nxt;
		}
		return path;
	};
	vector<int> res = min(get(mn), get(mx));
	for(int i = 0; i < n; i++) cout << res[i] << " "; cout << endl;
	return 0;
}


Measured memory_bytes: 13432
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  bool check = false;
  for(int i = 0; i < N; i+=2){
    if(S.at(i) == 'L'){
      check = true;
    }
  }
  for(int i = 1; i < N; i+=2){
    if(S.at(i) == 'R'){
      check = true;      
    }
  }
  if(check){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


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

using namespace std;

int main()
{
  int n, p;
  while(cin >> n >> p, n || p){
    int wan = p, te[50] = {0};
    for(int s = 0; s < 10000000; s++){
      if(wan > 0){
	te[s%n]++, wan--;
	if(wan == 0 && te[s%n] == p){
	  cout << s%n << endl;
	  break;
	}
      } else {
	wan = te[s%n], te[s%n] = 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }
const int INF = 1000100100;

int main() {
    ll N;
    cin >> N;

    vector<ll> T(N);
    ll sum = 0;
    REP(i, T.size()) {
        cin >> T[i];
        sum += T[i];
    }

    ll M;
    cin >> M;

    vector<ll> P(M), X(M);
    REP(i, M) {
        cin >> P[i] >> X[i];
    }

    REP(i, M) {
        ll dif = T[P[i] - 1] - X[i];
        cout << sum - dif << endl;
    }

    return 0;
}

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

int abs(int a){
  if(a>0) return a;
  else return -a;
}

int main(void){
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a) < abs(x-b)) cout << "A" << endl;
  else cout << "B" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std ;

int n , m ;
int t ;
int main()
{
    cin >> n >> m ;
    cin >> t ;
    int mx = max(n,m) ;
    int ans = t / mx ;
    if(t % mx != 0 )
        ans ++ ;
    cout << ans << endl;


    return 0 ;
}

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

// ?????£?????????????????°?????? E ?????¢??????????????????????????????
// O(N + M) N: ????????°, M: ?????°
vector<int> enumerate_articulations(const EdgeList &E) {
    int N = E.size();
    vector<int> ord(N, -1), low(N);
    int cnt = 0;
    vector<int> articulations;
    function<void(int, int)> dfs = [&] (int now, int pre) {
        ord[now] = cnt++;
        low[now] = ord[now];
        
        bool is_articulation = false;
        int dfs_children = 0;
        
        for(int nxt : E[now]) {
            if(ord[nxt] < 0) {
                // not visited
                dfs_children++;
                dfs(nxt, now);
                low[now] = min(low[now], low[nxt]);
                if(pre >= 0 and ord[now] <= low[nxt]) {
                    is_articulation = true;
                }
            } else if(nxt != pre) {
                // visited
                low[now] = min(low[now], ord[nxt]);
            } 
        }
        if(pre < 0 and dfs_children > 1) is_articulation = true;
        if(is_articulation) articulations.push_back(now);
    };
    // ??£?????°????????????dfs(0)????????§OK?????????
    rep(i, N) if(ord[i] < 0) dfs(i, -1);
    return articulations;
}

#define all(v) v.begin(),v.end()

class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        EdgeList E(N);
        rep(i, M) {
            int a, b; cin >> a >> b;
            E[a].push_back(b);
            E[b].push_back(a);
        }
        auto ans = enumerate_articulations(E);
        sort(all(ans));
        for(int a : ans) cout << a << endl;
        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}

Measured memory_bytes: 4876
from math import gcd

n = map(int, input().split())
A = list(map(int, input().split()))

m = 10**6
D = [-1]* (m+1)
for i in range(2, m+1):
    if D[i] == -1:
      for j in range(i, m+1, i):
          if D[j] == -1:
              D[j] = i


wa_set = set()
cnt = 0
for a in A:
    a_set = set()
    while a > 1:
        a_set.add(D[a])
        a //= D[a]
    wa_set |= a_set
    cnt += len(a_set)

if cnt == len(wa_set):
    print("pairwise coprime")
else:
    t = A[0]
    for a in A:
        t = gcd(a, t)
    if t == 1:
        print("setwise coprime")
    else:
        print("not coprime")

Measured memory_bytes: 205252
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long y1,y2,m1,m2,d1,d2,ans=0,mon,day;
  int noturuu[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},uruu[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
  bool f=true;
  while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2){
    if(y1<0 or m1<0 or d1<0 or y2<0 or m2<0 or d2<0){
      break;
    }
    ans=0;
    mon=m1;
    day=d1;
    for(int i=y1;i<=y2;i++){
      f=true;
      if(i%4==0){
        if(i%100==0){
          if(i%400==0){
            f=true;
          }else{
            f=false;
          }
        }else{
          f=true;
        }
      }else{
        f=false;
      }
      if(f){//うるう
        for(int j=mon;j<=12;j++){
          if(y2==i and m2==j){
            ans+=d2-day;
            break;
          }
          if(y1==i and m1==j){
            ans+=uruu[j]-day+1;
          }else{
            ans+=uruu[j];
          }
          day=1;
        }
      }else{//notうるう
        for(int j=mon;j<=12;j++){
          if(y2==i and m2==j){
            ans+=d2-day;
            break;
          }
          if(y1==i and m1==j){
            ans+=noturuu[j]-day+1;
          }else{
            ans+=noturuu[j];
          }
          day=1;
        }
      }
      mon=1;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstring>
namespace fuck
{
	const int N=100100,M=N*2;
	int begin[N],next[M],to[M];
	int siz[N],fa[N];
	int n,e;
	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	void dfs(int p,int h=0)
	{
		siz[p]=1;
		for(int i=begin[p];i;i=next[i])
			if(to[i]!=h)
			{
				fa[to[i]]=p;
				dfs(to[i],p);
				siz[p]+=siz[to[i]];
			}
	}
	int dis()
	{
		int ret=0,p=n;
		while(p!=1)p=fa[p],ret++;
		return ret;
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,u,v;i<n;i++)
			scanf("%d%d",&u,&v),add(u,v);
		dfs(1);
	}
	void solve()
	{
		initialize();
		int k=(dis()-1)/2,p=n;
		while(k--)p=fa[p];
		int x=siz[p],y=n-siz[p];
		if(y-1>=x)printf("Fennec\n");
		else printf("Snuke\n");
	}
}
int main()
{
	fuck::solve();
	return 0;
}


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

int main(){
	//nyuryoku
	int n;
	string s;
	cin >> n;
	cin >> s;
	int count = 0;
	for(int i=0;i<n-1;i++){
		if(s.at(i) != s.at(i+1)){
			count++;
		}
	}
	cout << count +1 <<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
int kk;
bool is(long double x) 
{   
  if(x<0) return 0;
  long double sr = sqrt(x);
  kk=sr; 
  return ((sr - floor(sr)) == 0); 
} 
void solve(){
      int n;
      cin>>n;
     
      for(int i=1;i<=n;i++){
      	ll ans=0;
      	for(ll j=1;j*j<=n;j++)
      	{
      		for(ll k=1;k*k<=n;k++){
      			ll c=j*j+k*k-i+j*k;
      			
      			if(is((j+k)*(j+k)-4*c) && (kk-(j+k))%2==0){
      				ll x=(-(j+k)+kk)/2;
      				ll y=(-(j+k)-kk)/2;
      				if(x>=1||y>=1)ans++;
      				
      			}
      		}
      	}
      	cout<<ans<<"\n";
      }
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


Measured memory_bytes: 3572
open System

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let N = read int ()
let A = reads int64 ()

let T = Array.create N 0
A |> Array.iteri (fun i x -> if (int64 i)-x>=0L then do Array.modify T (i-(int x)) inc)

seq {
  for i in 0..(N-1) do
    let x=A.[i]
    if (int64 i)+x<(int64 N) then
      yield T.[i+(int x)]
}
|> Seq.sumBy int64
|> printfn "%d"



Measured memory_bytes: 47160
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1e9+7;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗 1*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*n乗 2*/ll modpow(ll x,ll n,ll m){ll ans=x,tmp=x,t1=1;i=1; while(i<n){if(i*2<n){ans*=ans;ans%=m;i*=2;}else{t1=1;tmp=x;while(t1*2<n-i){tmp*=tmp;tmp%=m;t1*=2;}ans*=tmp;ans%=m;i+=t1;}}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x){ans*=(x-i);ans%=mod;}return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1,l=2;rep(i,0,min(n-r,r)){ans*=(n-i);ans%=mod;while(ans%l==0&&l<=min(r,n-r)){ans/=l;l++;}}return ans;}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}//素数の時true
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n; 
 cin>>n;
 
 map<ll,ll>m;
 ll p=0;
 ll b,f=0;
 rep(i,0,n){
  cin>>b;
  if(b>=3200){
   f++;
   continue;
  }
  else if(m[b/400]==0)p++;
  m[b/400]++;
 }
 if(p>0)cout<<p<<" "<<p+f<<endl;
 else cout<<1<<" "<<f<<endl;
return 0;}

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

int main() {
  int n;
  cin>>n;
  string s[n];
  for (int i=0; i<n; i++) cin>>s[i];

  int d[n][n];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      if (i == j) {
        d[i][j] = 0;
      } else if (s[i][j] == '1') {
        d[i][j] = 1;
      } else {
        d[i][j] = 200;
      }
    }
  }
  for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        if (d[i][k] == 200 || d[k][j] == 200) {
          continue;
        }
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      for (int k=0; k<n; k++) {
        if (d[i][j] % 2 == 1 && d[j][k] % 2 == 1 && d[k][i] % 2 == 1) {
          cout<<-1<<endl;
          return 0;
        }
      }
    }
  }
  int ans = 0;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      ans = max(d[i][j], ans);
    }
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h> 
using namespace std; 
#define MOD 1000000007
int main() {
  int N; 
  int T[200000]; 
  cin >> N; 
  for (int i = 0; i < N; i ++)
    cin >> T[i]; 
  sort(T, T+N); 
  long res = 0;
  int i= 2; 
  int p = N-1; 
  res += T[p];
  while (i < N) {
    p --; 
    res += T[p]; 
    i ++; 
    if (i < N) {
      res += T[p];
      i ++; 
    }
  }
  cout << res; 
  return 0; 
}

Measured memory_bytes: 4404
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	long long N, P, Q; vector<long long> C;

	cin >> N >> P >> Q;

	C = vector<long long>(N);

	long long zenbugaishoku = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> C[i];

		zenbugaishoku += C[i];
	}
	
	vector<long long> A(N);

	for (int i = 0; i < N; i++)
	{
		A[i] = C[i] - (Q - i) * P;
	}

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

	long long Answer = zenbugaishoku;

	long long sum = zenbugaishoku;

	for (int i = 0; i < N; i++)
	{
		sum -= A[i];

		sum += 2 * i * P;

		Answer = max(sum, Answer);
	}

	cout << Answer << endl;

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int count_0 = 0,count_1 = 0;
  for (int i=0;i<s.size();i++){
    if (s[i] == '0') count_0 += 1;
    else count_1 += 1;
  }
  cout << 2*min({count_0,count_1}) << endl;
  return 0;
}


Measured memory_bytes: 512
import math
K = int(input())

ans = 0
ab = []
for b in range(1, K+1):
    for a in range(1, K+1):
        ab.append(math.gcd(a, b))
        
for c in range(1, K+1):
    for i in ab:
        ans += math.gcd(c, i)
print(ans)

Measured memory_bytes: 9304
N = int(input())
dic = {}
for i in range(N):
    a = input()
    if a not in dic or dic[a] == 0:
        dic[a] = 1
    elif dic[a] == 1:
        dic[a] = 0
cnt = 0
for key,vol in dic.items():
    if vol == 1:
        cnt += 1
print(cnt)


Measured memory_bytes: 17888
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for ni in range(n):
    print(" ".join([str(s) for s in C[ni]]))

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int res = 0;
    for(char c : s)
    {
        if(c == '+') res++;
        else res--;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    char c11, c12, c13, c21, c22, c23, c31, c32, c33;
    cin >> c11 >> c12 >> c13 >> c21 >> c22 >> c23 >> c31 >> c32 >> c33;
    cout << c11 << c22 << c33;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define FD(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define pii pair<int,int>
#define reset(x,y) memset(x, y,sizeof(x))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EL putchar('\n');
#define mod 1000000007
#define oo 3003
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int n;
int a[1000006];
int f[oo][oo];
void ReadInPut()
{
    n=read();
    F(i,1,n)a[i]=read();
}
int tinh(int i,int j)
{
    if(i>j)return 0;
	if(f[i][j]!=-1) return f[i][j];
    int res;
    if((i-1+n-j)%2)res=min(tinh(i+1,j)-a[i],tinh(i,j-1)-a[j]);
    else res=max(tinh(i+1,j)+a[i],tinh(i,j-1)+a[j]);
    f[i][j]=res;
    return res;
}
void Solve()
{
    reset(f,-1);
    cout<<tinh(1,n);
}
main()
{
//    freopen("t.INP","r",stdin);
  //  freopen(".OUT","w",stdout);
    int sotest=1;
    //cin>>sotest;
    for(int i=1;i<=sotest;i++)
    {
        ReadInPut();
        Solve();
    }
}


Measured memory_bytes: 72064
import core.bitop;
import std.algorithm;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a,b;
    scan(a,b);
    auto s = sread();
    foreach (i, e; s)
    {
        if(i == b - 1)
        {
			write(toLower(e));
            continue;
        }
        write(e);
    }
    writeln();
}

Measured memory_bytes: 256
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var a = o.a();
  var b = o.a();
  return a * b % 2 ? "Yes":"No";
}

Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;

class UnionFind {
public:
  vector<int> parent;
  vector<int> sizes;
  UnionFind(int n) : parent(n), sizes(n, 1) {
    for(int i=0; i<n; i++) parent[i] = i;
  }
  int find(int x) {
    if (x == parent[x]) return x;
    return parent[x] = find(parent[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(sizes[x] < sizes[y]) swap(x, y);
    parent[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sizes[find(x)]; }
};

int main(void) {

  int n, m; cin >> n >> m;
  vector<int> x(m);
  vector<int> y(m);
  vector<int> z(m);
  UnionFind uf(n);
  for(int i=0; i<m; i++) {
    cin >> x[i] >> y[i] >> z[i];
    x[i]--;
    y[i]--;
    z[i] %= 2;
    uf.unite(x[i], y[i]);
  }

  map<int, int> mp;
  for(int i=0; i<n; i++){
    mp[uf.find(i)]++;
  }
  cout << mp.size() << endl;

  

  return 0;
}



// EOF


Measured memory_bytes: 6784
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    n = N*(N-1)//2 if N >=2 else 0
    m = M*(M-1)//2 if M >=2 else 0
    print(n+m)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
dx,dy = [-1,0,1,0],[0,-1,0,1]
while 1:
	N = input()
	if N == 0: break
	x,y = [0]*N,[0]*N
	for i in range(1,N):
		n,d = map(int,raw_input().split())
		x[i] = x[n] + dx[d]
		y[i] = y[n] + dy[d]
	print max(x) - min(x) + 1, max(y) - min(y) + 1

Measured memory_bytes: 4248
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>


using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string S){
  // std::cout << S.substr(S.length()/2, S.length()) << std::endl;
  // std::cout << S.substr(0, S.length()/2) << std::endl;
  if(S.substr(0, S.length()/2)==S.substr(S.length()/2, S.length()))
    std::cout << YES << std::endl;
  else
    std::cout << NO << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}



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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 500 + 5;
int grid[MAX][MAX];
int n, m;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    fori(i, 1, n + 1) {
        fori(j, 1, m + 1) {
            cin >> grid[i][j];
        }
    }
    vector<ii> pos;
    fori(i, 1, n + 1) {
        if(i & 1) {
            fori(j, 1, m + 1) {
                pos.emplace_back(i, j);
            }
        }
        else {
            ford(j, m, 1) {
                pos.emplace_back(i, j);
            }
        }
    }
    vector<tuple<int, int, int, int>> ans;
    fori(i, 0, (int) pos.size() - 1) {
        int x, y;
        tie(x, y) = pos[i];
        int nx, ny;
        tie(nx, ny) =pos[i + 1];
        if(grid[x][y] & 1) {
            ans.emplace_back(x, y, nx, ny);
            grid[nx][ny]++;
            grid[x][y]--;
        }
    }
    cout << ans.size() << '\n';
    for(auto &each : ans) {
        int x, y, nx, ny;
        tie(x, y, nx, ny) = each;
        cout << x << " " << y << " " << nx << " " << ny << '\n';
    }
    return 0;
}


Measured memory_bytes: 7152
#include <string>
#include <time.h>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>

#define MOD 998244353
#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef long long ll;
using namespace std;
#define MAXN 1488228
ll x, y, n;
ll a[350005], b[150005], dp[200500][4];
ll ans;
int main() {
    ans = 1;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        ans = ans * i % MOD;
    }
    n *= 3;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        ll x;
        if (s[i] == 'R') {
            x = 1;
        } else if (s[i] == 'G') {
            x = 2;
        } else {
            x = 3;
        }
        ll mx = 300500;
        for (int j = 1; j <= 3; j++) {
            if (a[j] > a[x]) {
                mx = min(mx, a[j]);
            }
        }
        if (mx != 300500) {
            ans = ans * (mx - a[x]) % MOD;
        }
        a[x]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2692
import sys
INF = 1000000000

class Edge:
	def __init__(self, to, cost):
		self.to = to
		self.cost = cost


def bellman_ford(graph, start):
	V = len(graph)
	d = [INF for _ in xrange(V)]
	d[start] = 0
	
	for _ in xrange(V-1):
		for i, node in enumerate(graph):
			for edge in node:
				if d[i] != INF and d[i] + edge.cost < d[edge.to]:
					d[edge.to] = d[i] + edge.cost

	for i, node in enumerate(graph):
		for edge in node:
			if d[i] != INF and d[i] + edge.cost < d[edge.to]:
				print "NEGATIVE CYCLE"
				sys.exit()

	return d

def main():
	V, E, r = map(int, raw_input().split())

	graph = [[] for _ in xrange(V)]
	for i in xrange(E):
		_s, _t, _c = map(int, raw_input().split())
		graph[_s].append(Edge(_t, _c))


	distance = bellman_ford(graph, r)


	for d in distance:
		if d == INF:
			print "INF"
		else:
			print d

if __name__ == '__main__':
	main()

Measured memory_bytes: 5036
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int f = 0;
		int tmp = n;
		while (tmp > 0) {
			f += tmp % 10;
			tmp /= 10;
		}

		if (n % f == 0) {
			pr.println("Yes");
		} else {
			pr.println("No");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

int main()
{
  int k;
  cin >> k;
  int64_t ans;
  priority_queue<int64_t, vector<int64_t>, greater<int64_t>> pq;
  for (int i = 1; i < 10; i++) {
    pq.push(i);
  }
  for (int i = 0; i < k; i++) {
    ans = pq.top();
    pq.pop();
    for (int j = -1; j <= 1; j++) {
      int t = ans % 10 + j;
      if (0 <= t && t <= 9) {
        pq.push(ans * 10 + t);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2420