akhauriyash/Code-Regression huggingface dataset:
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>

using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-11;
typedef long long ll;
const ll MOD = 1000000007;
const int N = 100000 + 7;
typedef unsigned long long ull;

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
void fast() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
}

/*                What if i lose? only losers think like that. But the answer is you will lose rate.                */

ll n;
vector<ll> arr;

int main() {
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
    fast();

    cin >> n;
    arr.resize(n);
    for (ll &i:arr)cin >> i;
    sort(arr.rbegin(), arr.rend());
    ll ans = arr[0];
    priority_queue<int> pq;
    pq.push(arr[1]);
    for (int i = 2, cnt = 0; i < n; i++, cnt++) {
        if (cnt == 2) {
            cnt = 0;
            pq.pop();
        }
        ans += pq.top();
        pq.push(arr[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N,M;
    cin >> N >> M;

    vector<vector<int>> vec(M, vector<int>(2));
    rep(i, M)rep(j,2) cin >> vec[i][j];

    int x;
    if(M == 0) x = 0;
    
    int keta1;
    int amari1;
    int keta2;
    int amari2;
    int keta3;
    bool ok = true;
    rep(i,1000){
        if(i == 700){
            int a = 0;
        }
        keta1 = i/100;
        amari1 = i%100;
        keta2 = amari1/10;
        amari2 = amari1%10;
        keta3 = amari2;

        if(N == 3 && 99 < i && i < 1000){
            rep(j,M){
                if(vec[j][0] == 1){
                    if(vec[j][1] == 0){
                        ok = false;
                        break;
                    }
                    else if(keta1 != vec[j][1]){
                        ok = false;
                        break;
                    }
                    else ok = true;
                }
                if(vec[j][0] == 2){
                    if(keta2 != vec[j][1]){
                        ok = false;
                        break;
                    }
                    else ok = true;
                }
                if(vec[j][0] == 3){
                    if(keta3 != vec[j][1]){
                        ok = false;
                        break;
                    }
                    else ok = true;
                }                        
            }
        }
        else if(N == 2 && 9 < i && i < 100){
            rep(k,M){
                if(vec[k][0] == 1){
                    if(vec[k][1] == 0){
                        ok = false;
                        break;
                    }
                    else if(keta2 != vec[k][1]){
                        ok = false;
                        break;
                    }
                    else ok = true;
                }
                if(vec[k][0] == 2){
                    if(keta3 != vec[k][1]){
                        ok = false;
                        break;
                    }
                    else ok = true;
                }
            }
        }
        else if(N == 1 && i < 10){
            rep(l,M){
                if(vec[l][0] == 1){
                    if(keta3 != vec[l][1]){
                        ok = false;
                        break;
                    }
                    else ok = true;
                }
            }
        }
        else continue;

        if(ok){
            cout << i << endl;
            return 0;
        }
    }

    cout << "-1" << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, C;
ll x[101010], v[101010];
ll vsum[101010];
ll vsumrev[101010];
ll vmax[101010], vmaxrev[101010];

int main() {
  cin >> N >> C;
  repe(i, 1, N) { cin >> x[i] >> v[i]; }
  repe(i, 1, N) {
    vsum[i] = vsum[i - 1] + v[i];
    vmax[i] = max(vmax[i - 1], vsum[i] - x[i]);
  }
  for (int i = N; i >= 1; --i) {
    vsumrev[i] = vsumrev[i + 1] + v[i];
    vmaxrev[i] = max(vmaxrev[i + 1], vsumrev[i] - (C - x[i]));
  }

  ll ansf = 0;
  ll ansb = 0;
  repe(i, 1, N) { chmax(ansf, vsum[i] - x[i]); }
  for (int i = N; i >= 1; --i) {
    chmax(ansb, vsumrev[i] - (C - x[i]));
  }

  ll ansf2 = 0;
  repe(i, 1, N) { chmax(ansf2, vsum[i] - 2 * x[i] + vmaxrev[i + 1]); }
  ll ansb2 = 0;
  for (int i = N; i >= 1; --i) {
    chmax(ansb2, vsumrev[i] - 2 * (C - x[i]) + vmax[i - 1]);
  }

  cout << max(ansf, max(ansb, max(ansf2, ansb2))) << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;
typedef long long ll;

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



int main(){

    int N,K;
    scanf("%d %d",&N,&K);
    int p[N];
    rep(i,N) {scanf("%d",p+i);}
    sort(p,p+N);
    int ans=0;
    for(int i=0;i!=K;++i){
        ans+=p[i];
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
string s; ll n; ll dp[N][13];
ll maxval(ll i,ll rem){
	if(i==n){
		if(rem==5) return 1;
		else return 0;
	}
	if(dp[i][rem]!=-1){
		return dp[i][rem];
	}
	if(s[i]=='?'){
		ll an=0;
		for(ll j=0;j<=9;j++){
			an=(an%mod+maxval(i+1,(rem*10+j)%13)%mod)%mod;
		}
		return dp[i][rem]=an%mod;
	}
	else{
		return dp[i][rem]=maxval(i+1,(rem*10+(s[i]-'0'))%13)%mod;
	}
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin>>s;
	n=s.length();
	ll i,j,k,l;
	cout<<maxval(0,0);
	return 0;
}

Measured memory_bytes: 319184
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <climits>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	string s;
	cin >> s;
	int a = 0;
	for (int i = 0; i < 4; ++i)
		if (s[i] == '2') ++ a;
	cout << a;
}

Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int t;
long long a,b,c,d;
long long gcd(long long x,long long y)
{
	if (!y)
	{
		return x;
	}
	else
	{
		return gcd(y,x%y);
	}
}
int main()
{
	scanf("%d",&t);
	while (t--)
	{
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if (a<b)
		{
			puts("No");
			continue;
		}
		if (d<b)
		{
			puts("No");
			continue;
		}
		if (c>b)
		{
			puts("Yes");
			continue;
		}
		a%=b;
		d%=b;
		long long g=gcd(b,d);
		long long x=(c-a+b)%b;
		x=x/g+1;
		x=(a+x*g)%b;
		if (x>c && x<b)
		{
			puts("No");
		}
		else
		{
			puts("Yes");
		}
	}
    return 0;
}

Measured memory_bytes: 256
arr1 = []
arr2 = []
for i in range(10):
    arr1.append(int(input()))
for i in range(10):
    arr2.append(int(input()))
arr1.sort()
arr2.sort()

print(str(arr1[9] + arr1[8] + arr1[7]) + " " + str(arr2[9] + arr2[8] + arr2[7]))



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n;
vector<int>v[100010];
bool used[100010];
int G[100010];
void dfs(int x){
    used[x]=true;
    if(x&&v[x].size()==1){
        G[x]=0;
        return;
    }
    if((x==0&&v[x].size()==1)||(x&&v[x].size()==2)){
        for(int i:v[x]){
            if(!used[i]){
                dfs(i);
                G[x]=G[i]+1;
            }
        }
        return;
    }
    for(int i:v[x]){
        if(!used[i]){
            dfs(i);
            G[x]^=(G[i]+1);
        }
    }
}
signed main(){
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(0);
    if(G[0]==0)puts("Bob");
    else puts("Alice");
    return 0;
}


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

int main(){
    int N,M; cin >> N >> M;
    int num[10]={2,5,5,4,5,6,3,7,6};
    int a[M];
    for(int i=0;i<M;i++) cin >> a[i];
    string dp[11000];
    for(int i=0;i<=N;i++) dp[i]="-";
    dp[0]="";
    for(int i=0;i<=N;i++){
        for(int j=0;j<M;j++){
            if(dp[i]=="-") continue;
            int x=dp[i+num[a[j]-1]].size();
            int y=(dp[i]+to_string(a[j])).size();
            if(dp[i+num[a[j]-1]]=="-"){
                dp[i+num[a[j]-1]]=dp[i]+to_string(a[j]);
            }else if(x<y){
                dp[i+num[a[j]-1]]=dp[i]+to_string(a[j]);
            }else if(x==y&&dp[i+num[a[j]-1]]<(dp[i]+to_string(a[j]))){
                dp[i+num[a[j]-1]]=dp[i]+to_string(a[j]);
            }
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 33024
use proconio::input;


fn main() {
    
    let mut a : i128;

    input!{

   a : i128 , 
 
   }

   let x : i128 =  a.pow(2);
   let s : i128 =  a.pow(3);
   let  ans = a + x + s ;
println!("{}",ans);

}



Measured memory_bytes: 2156
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll M = (1 + SQRT(1 + (8 * N))) / 2;
  if (M * (M - 1) / 2 != N) {
    cout << "No" << endl;
    return 0;
  }
  vvl ans = VVL(M, M - 1, 0);
  ll nowmax = 0;
  REP(i, M - 1) {
    ans[0][i] = i + 1;
    nowmax = i + 1;
  }
  REP(i, M - 1) {
    REP(j, i + 1) { ans[i + 1][j] = ans[j][i]; }
    FOR(j, i + 1, M - 1) {
      ans[i + 1][j] = nowmax + 1;
      nowmax++;
    }
  }
  cout << "Yes" << endl;
  cout << M << endl;
  REP(i, M) {
    cout << M - 1 << " ";
    REP(j, M - 1) { cout << ans[i][j] << " "; }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
n = int(input())
a = list(map(int, input().split()))

def beki(n):
    ans = 1
    for _ in range(int(n)):
        ans = (ans * 2) % (10 ** 9 + 7)
    return int(ans)

if n % 2 == 0:
    hikaku = []
    for i in range(1, n, 2):
        hikaku += [i, i]
    if sorted(a) == hikaku:
        print(beki(n / 2))
    else:
        print(0)

elif n == 1:
    if a == [0]:
        print(1)
    else:
        print(0)
else:
    hikaku = [0]
    for i in range(2, n, 2):
        hikaku += [i, i]
    if sorted(a) == hikaku:
        print(beki((n - 1) / 2))
    else:
        print(0)

Measured memory_bytes: 14008
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static ArrayList<ArrayList<Edge>> g = new ArrayList<>();

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		int[] P = new int[N];
		int[] C = new int[N];
		int[] J = new int[N];
		for (int i = 0; i < N; i++) {
			P[i] = Integer.parseInt(sc.next());
		}
		for (int i = 0; i < N; i++) {
			C[i] = Integer.parseInt(sc.next()) - 1;
		}
		for (int i = 0; i < N; i++) {
			J[i] = Integer.parseInt(sc.next());
		}
		for (int i = 0; i < N; i++) {
			g.add(new ArrayList<>());
		}
		for (int i = 0; i < M; i++) {
			int U = Integer.parseInt(sc.next()) - 1;
			int V = Integer.parseInt(sc.next()) - 1;
			int T = Integer.parseInt(sc.next());
			g.get(U).add(new Edge(V, T));
			g.get(V).add(new Edge(U, T));
		}
		long[] dist = new long[N];
		Arrays.fill(dist, Long.MAX_VALUE / 2);
		dist[0] = 0;
		PriorityQueue<Node> q = new PriorityQueue<>();
		q.add(new Node(0, 0));
		while (!q.isEmpty()) {
			Node n = q.poll();
			if (n.cost > dist[n.cur]) continue;
			for (Edge e : g.get(n.cur)) {
				long nc = n.cost + e.len;
				if (dist[e.to] > nc) {
					dist[e.to] = nc;
					q.add(new Node(e.to, nc));
				}
			}
		}
		long[] dist2 = new long[N];
		for (int i = 0; i < N; i++) {
			dist2[i] = dist[i] - P[i];
			q.add(new Node(i, dist2[i]));
		}
		while (!q.isEmpty()) {
			Node n = q.poll();
			if (n.cost > dist2[n.cur]) continue;
			for (Edge e : g.get(n.cur)) {
				long nc = n.cost + e.len;
				if (dist2[e.to] > nc) {
					dist2[e.to] = nc;
					q.add(new Node(e.to, nc));
				}
			}
		}
		long[] ans = new long[K];
		Arrays.fill(ans, Long.MIN_VALUE);
		for (int i = 0; i < N; i++) {
			ans[C[i]] = Math.max(ans[C[i]], J[i] - dist[i] - dist2[i]);
		}
		PrintWriter writer = new PrintWriter(System.out);
		for (int i = 0; i < K; i++) {
			writer.println(ans[i]);
		}
		writer.flush();
	}

	static class Node implements Comparable<Node> {
		int cur;
		long cost;

		public Node(int cur, long cost) {
			this.cur = cur;
			this.cost = cost;
		}

		@Override
		public int compareTo(Node o) {
			return Long.compare(this.cost, o.cost);
		}
	}

	static class Edge {
		int to, len;

		public Edge(int to, int len) {
			this.to = to;
			this.len = len;
		}
	}
}



Measured memory_bytes: 161848
#include<stdio.h>
#include<string.h>
char c[110];
int f(int i){
  int n=i,j;
  char s[110]={};
  for(;c[i];i++){
    if(c[i]=='[')i=f(i+1);
    else if(c[i]==']'){
      for(j=0;n<i-j;j++)s[j]=c[i-j-1];//printf(":%s %s\n\n",s,c+i+1);
      strcat(s,c+i+1);//printf("a%s\n",s);
      c[n-1]=0;
      strcat(c,s);//printf("b%s %c %c\n",c,c[i-2],c[i-1]);
      return i-2;
    }
  }
  return i-1;
}
int main(){
  int i,p=0,r;
  char s[100];
  while(scanf("%s",s),s[0]-'.'){
    for(i=r=0;s[i];i++){
      if('A'<=s[i]&&s[i]<='Z')c[r++]=(p+s[i]-'A'+80*26)%26+'A';
      if(s[i]=='['||s[i]==']')c[r++]=s[i];
      if(s[i]=='?')c[r++]='A';
      if     (s[i]=='+')p++;
      else if(s[i]=='-')p--;
      else              p=0;
    }
    c[r]=0;
    f(0);
    printf("%s\n",c);
  }
  return 0;
}

Measured memory_bytes: 536
# coding: UTF-8
import os

def remove_empty(target_list: list):
    empty_removed_list = [x for x in target_list if x]
    return empty_removed_list

def get_stdin_str_list():
    input_str = input().strip()
    input_str_list = input_str.split()
    return input_str_list

def get_stdin_int_list():
    input_str_list = get_stdin_str_list()
    input_int_list = list(map(input_str_list, int))
    return input_int_list


S = get_stdin_str_list()[0]
if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#define SIZE  100

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

int main(void) {
	int i, j, n, x[SIZE], y[SIZE], h[SIZE], xs, ys, hs, Cx, Cy, H, flg;

	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d%d%d", &x[i], &y[i], &h[i]);

	for (i = 0; i < n; i++) if (h[i] != 0) {
		xs = x[i]; ys = y[i]; hs = h[i];
		break;
	}

	int check() {
		int k, Ht;
		Ht = hs + abs(Cx - xs) + abs(Cy - ys);
		for (k = 0; k < n; k++) {
			if (h[k] != max(Ht - abs(Cx - x[k]) - abs(Cy - y[k]), 0)) return 0;
		}
		return Ht;
	}

	flg = 0;
	for (i = 0; i < 101; i++) {
		for (j = 0; j < 101; j++) {
			Cx = i; Cy = j; H = check();
			if (H != 0) {
				flg = 1;
				break;
			}
		}
		if (flg) break;
	}

	printf("%d %d %d\n", Cx, Cy, H);
	return 0;
}

Measured memory_bytes: 128
#C
while 1:
    r,n = map(int, input().split())
    if r == n == 0:break
    ans = [[float("inf") for i in range(100)] for j in range(100)]
    for y in range(100):
        for j in range(2*r):
            x = j-r
            if x < 0:
                x += 1
            ans[y][j] = r+y-(r**2-x**2)**0.5
    for i in range(n):
        a,b,h = map(int, input().split())
        for x in range(a,b):
            j = x+r
            for y in range(h):
                ans[y][j] = float("inf")
    a = float("inf")
    for i in ans:
        a = min(min(i),a)
    print(a)



Measured memory_bytes: 6336
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

int m,n;
string s,t;
int dp[2][2005][2005];

int main(void){
	scanf("%d%d",&m,&n);
	cin >> s;
	s+='G';
	cin >> t;
	t+='G';
	memset(dp[1],-1,sizeof(dp[1]));
	int res=0;
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<2;k++){
				if(dp[k][i][j]<0)continue;
				if(k==0){
					if(s[i]=='I'){
						dp[1][i+1][j]=max(dp[1][i+1][j],dp[k][i][j]+1);
						res=max(res,dp[1][i+1][j]);
					}
					if(t[j]=='I'){
						dp[1][i][j+1]=max(dp[1][i][j+1],dp[k][i][j]+1);
						res=max(res,dp[1][i][j+1]);
					}
				}else{
					if(s[i]=='O'){
						dp[0][i+1][j]=max(dp[0][i+1][j],dp[k][i][j]+1);
					}
					if(t[j]=='O'){
						dp[0][i][j+1]=max(dp[0][i][j+1],dp[k][i][j]+1);
					}
				}
			}
		}
	}
	printf("%d\n",res);
	return 0;
}

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

const long long mod =1e9+7 ;
const int N = 4e2+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(int i=l;i<m;i++)
# define vi vector<int>
#define vii vector<ll>
#define vpr vector<pair<int,int> >
#define dbg(x) cout << #x << " is " << x << endl;
#define spk(x) cout<<x<<endl;
#define inf INT_MAX
/*
stoi - sting to int;
stol - string to long;
stoll - string to ll;
*/

////
////
////

const ll oo = 1ll << 60;

ll dp[N][N];
ll a[N];

ll solve(int l, int r)
{
	if(l > r)
		return oo;

	if(l == r)
		return 0;

	if(l + 1 == r)
		return a[l] + a[r];

	ll &ans = dp[l][r];

	if(ans != -1)
		return ans;

	ans = oo;

	ll s = 0;
	for(int i = l; i <= r; i++)
		s += a[i];

	for(int i = l; i <= r; i++)
	{
		ll cur = solve(l, i) + solve(i + 1, r) + s;

		ans = min(ans, cur);
	}

	return ans;
}

////
///
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);

memset(dp, -1, sizeof(dp));

	int n;
	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> a[i];

	cout << solve(0, n - 1) << endl;


    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e16;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-18;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

bool visited[200010];
int a[200010];
vint edge[200010];
int parent[200010];

bool dfs(int pos) {
	visited[pos] = true;
	set<int> s;
	rep(i, edge[pos].size()) {
		int to = edge[pos][i];
		if (!visited[to]) {
			if (!dfs(to)) {
				visited[pos] = false;
				return false;
			}
		}
		s.insert(a[to]);
	}
	a[pos] = 0;
	while (s.count(a[pos]))	a[pos]++;
	visited[pos] = false;
	return true;
}

int main() {
	int n;	cin >> n;
	rep(i, n) {
		int p;	cin >> p;	p--;
		edge[p].push_back(i);
		parent[i] = p;
	}
	queue<int> q;
	rep(i, n)	if (edge[i].empty())	q.push(i);
	while (!q.empty()) {
		int pos = q.front();	q.pop();
		visited[pos] = true;
		set<int> s;
		rep(i, edge[pos].size())	s.insert(a[edge[pos][i]]);
		a[pos] = 0;
		while (s.count(a[pos]))	a[pos]++;
		bool flag = true;
		int p = parent[pos];
		rep(i, edge[p].size())	flag &= visited[edge[p][i]];
		if (flag)	q.push(p);
	}
	int start = 0;
	while (visited[start])	start++;
	visited[start] = true;
	set<int> s;
	rep(i, edge[start].size())	if (visited[edge[start][i]])	s.insert(a[edge[start][i]]);
	a[start] = 0;
	while (s.count(a[start]))	a[start]++;
	int to = 0;
	while (visited[edge[start][to]])	to++;
	to = edge[start][to];
	if (dfs(to) && a[to] != a[start]) {
		cout << "POSSIBLE" << endl;
		return 0;
	}
	do {
		a[start]++;
	} while (s.count(a[start]));
	if (dfs(to) && a[to] != a[start]) {
		s.insert(a[to]);
		rep(i, a[start]) {
			if (s.count(i) == 0) {
				cout << "IMPOSSIBLE" << endl;
				return 0;
			}
		}
		cout << "POSSIBLE" << endl;
		return 0;
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

dic = {}
list_town = []
set_town = set()
town = 1

for i, v in enumerate(A):
    dic[i+1] = v

for _ in range(K):
    list_town.append(town)
    set_town.add(town)
    town = dic[town]
    if town in set_town:
        stop_town = town
        break

if N <= K:
    list_first_split = list_town[:list_town.index(stop_town)]
    list_second_split = list_town[list_town.index(stop_town):]
    print(list_second_split[(K - (len(list_first_split))) % len(list_second_split)])
else:
    print(town)

Measured memory_bytes: 48244
#include <stdio.h>
#include <math.h>
int main() {
	int n,d;
	int x[10][10]={};
	scanf("%d%d", &n,&d);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			scanf("%d", &x[i][j]);
		}
	}
	int sum=0,ans=0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			for (int k = 0; k < d; k++) {
				sum+=pow(x[i][k]-x[j][k],2);
			}
			if((int)sqrt(sum)*(int)sqrt(sum)==sum){
				ans++;
			}
			sum=0;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;
int main(){
	int i,j,n,k,cnt = 0;
	cin >> n >> k;
	if(k>(n - 2)*(n - 1)/2){
		cout << -1 << endl;
		return 0;
	}
	cout << n*(n - 1)/2 - k << endl;
	for(i=0;i<n;i++){
		for(j=i + 1;j<n;j++){
			cout << i + 1 << " " << j + 1 << endl;
			cnt++;
			if(cnt==n*(n - 1)/2 - k) return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;++i)
#define repe(i,k,n) for(int i=k;i<=n;++i)

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n=s.size();


    while(s.size()>0){
        s = s.substr(0,s.size()-2);
        string s1 = s.substr(0,s.size()/2);
        string s2 = s.substr(s.size()/2);
        if (s1 == s2){
            cout << s.size();
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

struct DSU
{
	int S;
	
	struct node
	{
		int p; ll sum;
	};
	vector<node> dsu;
	
	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	void reset(int n)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}
	
	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(rand()&1) swap(u, v);
		dsu[v].p = u;
		dsu[u].sum = min(dsu[u].sum,dsu[v].sum);
	}
	
	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}
	
	ll getstat(int u)
	{
		return dsu[rt(u)].sum;
	}
};

int a[555][555];
int b[555][555];

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

int getid(int x, int y)
{
	return x*n+y;
}

bool valid(int x, int y)
{
	return (x>=0&&x<n&&y>=0&&y<n);
}

void dfs(int x, int y)
{
	for(int i=0;i<4;i++)
	{
		int x2=x+dx[i]; int y2=y+dy[i];
		if(valid(x2,y2))
		{
			if(b[x][y]+a[x][y]<a[x2][y2])
			{
				a[x2][y2]=b[x][y]+a[x][y];
				dfs(x2,y2);
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	ll ans = 0;
	DSU dsu(n*n);
	for(int i=0;i<n*n;i++)
	{
		int x=i/n; int y=i%n;
		a[x][y]=min(x,min(y,min(n-1-x,n-1-y)));
		b[x][y]=1;
	}
	for(int i=0;i<n*n;i++)
	{
		int v; cin>>v; v--;
		int x=v/n; int y=v%n;
		ans+=a[x][y];
		b[x][y]=0;
		dfs(x,y);
	}
	cout<<ans<<'\n';
}


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

int main() {
    int N;
    cin >> N;
    vector<long long> s(N);
    for(int i=0; i<N; ++i) cin >> s[i];

    long long res = 0;
    for(int c=1; c<N; ++c) {
        if((N - 1) % c) {
            long long cur = 0, tmpres = 0;
            for(int i=0, j=N-1; i<N-1 && j > c; i+=c, j-=c) {
                cur += s[i] + s[j];
                tmpres = max(tmpres, cur);
            }
            res = max(res, tmpres);
        } else {
            long long cur = 0, tmpres = 0;
            for(int i=0, j=N-1; i < j; i+=c, j-=c) {
                cur += s[i] + s[j];
                tmpres = max(tmpres, cur);
            }
            res = max(res, tmpres);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int sz=1e5+9;
int A,B,Q;
long long t[sz],s[sz];
long long x;
long long ans;

int bs_a_t(long long k){
    int st=0,en=B-1;
    while(st<en){
        int mid=(st+en)>>1;
        if(t[mid]>=k) en=mid;
        else st=mid+1;
    }
    if(t[st]>=k) return st;
    return -1;
}

int bs_a_s(long long k){
    int st=0,en=A-1;
    while(st<en){
        int mid=(st+en)>>1;
        if(s[mid]>=k) en=mid;
        else st=mid+1;
    }
    if(s[st]>=k) return st;
    return -1;
}

int bs_b_s(long long k){
    int st=0,en=A-1;
    while(st<en){
        int mid=(st+en+1)>>1;
        if(s[mid]<=k) st=mid;
        else en=mid-1;
    }
    if(s[st]<=k) return st;
    return -1;
}

int bs_b_t(long long k){
    int st=0,en=B-1;
    while(st<en){
        int mid=(st+en+1)>>1;
        if(t[mid]<=k) st=mid;
        else en=mid-1;
    }
    if(t[st]<=k) return st;
    return -1;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d %d %d",&A,&B,&Q);
    for(int i=0;i<A;i++) scanf("%lld",&s[i]);
    for(int i=0;i<B;i++) scanf("%lld",&t[i]);
    sort(s,s+A);
    sort(t,t+B);
    while(Q--){
        scanf("%lld",&x);
        ans=1e18;
        int s_b=bs_b_s(x);
        int s_a=bs_a_s(x);
        int t_b=bs_b_t(x);
        int t_a=bs_a_t(x);
        if(~s_b&&~t_b) ans=min(ans,x-min(s[s_b],t[t_b]));
        if(~s_a&&~t_a) ans=min(ans,max(s[s_a],t[t_a])-x);
        if(~s_a&&~t_b){
            long long d1=abs(x-s[s_a]);
            long long d2=abs(x-t[t_b]);
            ans=min(ans,d1+d1+d2);
            ans=min(ans,d1+d2+d2);
        }
        if(~s_b&&~t_a){
            long long d1=abs(x-s[s_b]);
            long long d2=abs(x-t[t_a]);
            ans=min(ans,d1+d1+d2);
            ans=min(ans,d1+d2+d2);
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>
#include <string.h>

int main (void)
{
    int n,i,ac=0,wa=0,tle=0,re=0,j;
    scanf("%d",&n);
    char jd[4][4]={"AC","WA","TLE","RE"};
    for(i=0;i<n;i++)
    {
        char s[5];
        scanf("%s",s);
        int key=0;
        for(j=0;j<4;j++)
        {
            if(!strcmp(s,jd[j]))
            {
                key=j;
                break;
            }
        }
        switch (key) {
            case 0:
                ac++;
                break;
            case 1:
                wa++;
                break;
            case 2:
                tle++;
                break;
            case 3:
                re++;
                break;
        }
    }
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
    return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define sortAl(v) sort(all(v))
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)

template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, m;
  cin >> n >> m;

  vector<ll> a(n);
  rep(i, n) { cin >> a[i]; }

  vector<ll> dp(n);
  map<ll, ll> rem_map;

  dp[0] = a[0] % m;
  rem_map[dp[0]]++;

  REP(i, n) {
    dp[i] = dp[i - 1] + a[i];
    dp[i] %= m;
    rem_map[dp[i]]++;
  }

  ll sum = 0;
  ll ans = 0;
  rep(i, n) {
#if 0
    for (ll k = i; k < n; k++) {
      if (dp[k] == sum) {
        ans++;
      }
    }
#else
    // keyが存在する場合
    auto itr = rem_map.find(sum);
    if (itr != rem_map.end()) {
      ans += itr->second;
    }
#endif
    rem_map[dp[i]]--;
    sum += a[i];
    sum %= m;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    ll n, x; cin>>n>>x;
    ll b[100010], l[100010], u[100010];
    int ind[100010];
    bool z=1;
    for(int i=0; i<n; i++){
        cin>>b[i]>>l[i]>>u[i];
        if(b[i]>0) z=0;
        ind[i]=i;
    }
    if(z){
        cout<<0<<endl; return 0;
    }
    sort(ind, ind+n, [&](int i, int j){
            return u[i]*(x-b[i])+l[i]*b[i]>u[j]*(x-b[j])+l[j]*b[j];
    });
    ll s1=0, s2=n*x;
    while(s2-s1>1){
        ll s=(s1+s2)/2;
        ll k=s/x, r=s%x;
        
        ll t=0;
        for(int i=0; i<n; i++){
            if(i>=k) t-=l[ind[i]]*b[ind[i]];
            else t+=u[ind[i]]*(x-b[ind[i]]);
        }
        ll mx=-1e18;
        for(int i=0; i<n; i++){
            ll m=max(u[ind[i]]*(r-b[ind[i]]), l[ind[i]]*(r-b[ind[i]]));
            if(i>=k){
                mx=max(mx, t+l[ind[i]]*b[ind[i]]+m);
            }else{
                mx=max(mx, t-u[ind[i]]*(x-b[ind[i]])+m+u[ind[k]]*(x-b[ind[k]])+l[ind[k]]*b[ind[k]]);
            }
        }
        if(mx>=0) s2=s;
        else s1=s;
    }
    cout<<s2<<endl;
    return 0;
}


Measured memory_bytes: 2944
#include<cstdio> 
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=3000+10,mo=1000000007;
int f[maxn][maxn],right[maxn],sum[maxn];
int i,j,k,l,r,t,n,m,ans,one,zero;
char get(){
    char ch=getchar();
    while (ch!='0'&&ch!='1') ch=getchar();
    return ch;
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,n) sum[i]=get()-'0';
    fo(i,1,n+1) sum[i]+=sum[i-1];
    fo(i,1,n+1) right[i]=i;
    fo(i,1,m){
        scanf("%d%d",&j,&k);
        right[j]=max(right[j],k);
    }
    fo(i,1,n) right[i]=max(right[i],right[i-1]);
    f[1][sum[right[1]]]=1;
    fo(i,1,n)
        fo(j,0,n)
            if (f[i][j]){
                l=right[i]+1;r=right[i+1];
                one=j;zero=right[i]-i+1-j;
                if (zero) (f[i+1][j+sum[r]-sum[l-1]]+=f[i][j])%=mo;
                if (one) (f[i+1][j-1+sum[r]-sum[l-1]]+=f[i][j])%=mo;
            }
    ans=f[n+1][0];
    (ans+=mo)%=mo;
    printf("%d\n",ans);
}

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

#define int long long

using namespace std;

int a[100001];

 main () {   
 	int n;
 	cin >> n;
 	int ans = 0;
 	for (int i = 1;i <= n;i ++) cin >> a[i];
 	for (int i = 1;i <= n;i ++) {
 		if (i + 2 <= n && a[i] == a[i + 1] && a[i + 1] == a[i + 2]) {
 			ans ++;
 			a[i + 1] = (a[i] % 10000) + 1;
 		}
 		else if (i + 1 <= n && a[i] == a[i + 1]) {
 			for (int j = 1;j <= 10000;j ++) {
 				if (j != a[i] && j != a[i + 2]) {
 					a[i + 1] = j;
 					break;
 				}
 			}
 			ans ++;
 		}
 	}
 	cout << ans;
    return 0;           		
}

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

const ll INF = 1LL << 60;
ll dist[15][15];
ll H, W;
ll A[210][210];

int main() {
    cin >> H >> W;
    rep(i, 10)rep(j, 10) {
        cin >> dist[i][j];
    }

    rep(i, H)rep(j, W) cin >> A[i][j];

    rep(k, 10)rep(i, 10)rep(j, 10) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    ll ans = 0;
    rep(i, H)rep(j, W) {
        if (A[i][j] == -1) continue;
        ans += dist[A[i][j]][1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;

int main(){
	uint16_t N,K;
	string S;
	cin >> N >> S >> K;
	char Letter = S[K - 1];
	for(uint16_t i = 0;i < N;i++){
		if(S[i] != Letter)
			S[i] = '*';
	}
	cout << S << endl;
	
	return 0;
}


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

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

  char a[100][100];
  
  for(int i=0;i < m;i++){
    for(int j=0;j < n;j++){
      cin >> a[i][j];
    }
  }

  int ans=0;
  int di,dj;
  bool flag;
  for(int i=1;i < m;i++){
    for(int j=0;j < n;j++){
      if( a[i][j] != '-' ) continue;
      flag = true;

      for(di=-1;di <= 1;di++){
	for(dj=-1;dj <= 1;dj++){
	  if( i+di >= 0 && i+di < m){
	    if( j+dj >= 0 && j+dj < n){
	      if( a[i+di][j+dj] == 'x' || (di == 0 && a[i+di][j+dj] == 'o') ){
		flag = false;
	      }
	    }
	  }
	}
      }
      if(flag)ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3116
#include <cstdio>
#include <vector>

using namespace std;

const int mod = 1'000'000'007;

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

const int N = 100'009;

int f[N];
int rf[N];

int choose(int n, int k) {
  return k > n ? 0 : mul(f[n], mul(rf[k], rf[n - k]));
}

int m;
vector<int> g[N];
int ans;

void dfs(int x, int pa) {
  int tot = m - 1 - (pa != -1);
  int cnt = (int)g[x].size() - (pa != -1);
  ans = mul(ans, mul(choose(tot, cnt), f[cnt]));
  for (int y : g[x]) {
    if (y != pa) {
      dfs(y, x);
    }
  }
}

int main() {
  f[0] = 1;
  rf[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    rf[i] = pw(f[i], mod - 2);
  }
  int n;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  ans = 1;
  dfs(0, -1);
  ans = mul(ans, m);
  printf("%d\n", ans);
}


Measured memory_bytes: 9984
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
#define P 1000000007
typedef long long ll;
int n , m;
int a , b , c;
int A[MAXN];
void solve() {
    cin >> n >> m;
    cout << min( n % m , m - n % m ) << endl;
}
signed main() {
//    freopen("2.in","r",stdin);
//    freopen("fuckout","w",stdout);
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


Measured memory_bytes: 256
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;
std::vector<int> g[N];
int f[N];

int go(int x) {
    int& res = f[x];
    if(res == -1) {
        res = 0;
        rep(it, g[x].begin(), g[x].end()) {
            res = std::max(res, 1 + go(*it));
        }
    }
    return res;
}

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
    int n, m;
    std::cin >> n >> m;
    while(m-- > 0) {
        int x, y;
        std::cin >> x >> y;
        g[y].emplace_back(x);
    }
    rep(i, 1, n + 1) {
        f[i] = -1;
    }
    int ans = 0;
    rep(i, 1, n + 1) {
        ans = std::max(ans, go(i));
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n;
  string s;
  cin >> n >> s;
for (auto & c:s)
    c = (((c - 'A') + n) % 26) + 'A';
  cout << s;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b;
    cin >> a >> b;
    if ( a == b ) cout << "Draw" << endl;
    else if ( a != 1 && a < b || b == 1 ) cout << "Bob" << endl;
    else                                  cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,x,i,j,k,cnt;
  while(1){
    cnt=0;
    cin >> n >> x;
    if(n==0&&x==0) break;
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	for(k=1;k<=n;k++){
	  if(i!=j&&j!=k&&k!=i&&i+j+k==x) cnt++;
	}
      }
    }
    cout << cnt/6 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int main(){
    int a,b; scanf(" %d %d",&a,&b);
  	printf("%d\n",max(0,a-2*b));
}


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

using namespace std;

int main()
{
  while (true)
  {
    int H, W;
    cin >> H >> W;
    if (!H)
      return 0;

    for (int i = 1; i <= H; i++)
    {
      for (int j = 1; j <= W; j++)
      {
        if ((i + j) % 2 == 0)
          cout << "#";
        else
          cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3104
M, D = map(int, input().split())

cnt = 0

for m in range(1, M + 1):
    for d in range(1, D + 1):
        decimal_1 = d // 10
        decimal_2 = d - (decimal_1 * 10)
        if decimal_1 > 1 and decimal_2 > 1 and m == decimal_1 * decimal_2:
            cnt += 1
            
print(cnt)

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

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

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    vector<char> m(n * 2);
    rep(i, n)
    {
        m.at(i * 2) = s.at(i);
        m.at(i * 2 + 1) = t.at(i);
    }
    cout << string(m.begin(), m.end()) << endl;
    return 0;
}


Measured memory_bytes: 256