akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, K;
    cin >> N >> M >> K;
    rep(i, N + 1) {
        int k = M * i;
        rep(j, M + 1) {
            int c = k + (N - i) * j - i * j;
            if(c == K) {
                //cout << i << " " << j << " " << endl;
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <numeric>
using namespace std;
typedef long long int ll;

vector<int> g[210];

struct UnionFind{
    vector<int> par,num;
    vector<bool> done;
    UnionFind(int n):par(n),num(n,1),done(n,false){
        iota(par.begin(),par.end(),0);  //include<numeric>
    }
    int find(int v){
        return (par[v]==v)?v:(par[v]=find(par[v]));
    }
    void unite(int u,int v){
        u=find(u),v=find(v);
        if(u==v)return;
        if(num[u]<num[v])swap(u,v);
        num[u]+=num[v];
        par[v]=u;
        done[u]=done[u]|done[v];
    }
    bool same(int u,int v){
        return find(u) == find(v);
    }
    bool ispar(int v){
        return v=find(v);
    }
    int size(int v){
        return num[find(v)];
    }
};

int d[210];

void dfs(int s,int cnt){
	d[s]=min(d[s],cnt);
	for(int t:g[s]){
		if(d[t]>d[s]+1){
			dfs(t,cnt+1);
		}
	}
	return ;
}

int main(){
	int n; cin >> n;
	UnionFind uf(2*n);
	for(int i=0;i<n;i++){
		string s; cin >> s;
		for(int j=0;j<n;j++){
			if(s[j]=='1'){
				g[i].push_back(j);
				uf.unite(i,j+n);
			}
		}
	}
	if(uf.same(0,n)){
		cout << -1 << endl;
		return 0;
	}
	int ma=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			d[j]=1e5;
		}
		d[i]=0;
		dfs(i,0);
		for(int j=0;j<n;j++){
			ma=max(ma,d[j]);
		}
	}
	cout << ma+1 << endl;
}

Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val d = sc.nextInt()
    val c = (0 until 26).map { sc.next().toInt() }
    val s = (0 until d).map {
        (0 until 26).map { sc.next().toInt() }
    }
    println(problemintroduction_to_heuristics_contest(d, c, s))
}

fun problemintroduction_to_heuristics_contest(
    D: Int,
    c: List<Int>,
    s: List<List<Int>>
): String {
    val last = LongArray(26) { 0 }
    val satisfactions = LongArray(26) { 0 }
    val ans = IntArray(D) { 1 }
    for (d in 0 until D) {
        var max = -Long.MAX_VALUE
        var maxIndex = 0
        for (i in 0 until 26) {
            val tmp = max
            max = Math.max(max, c[i] * ((d + 1) - last[i]))
            if (tmp != max) maxIndex = i
        }
        val selected = maxIndex
        ans[d] = selected + 1
        satisfactions[selected] += s[d][selected].toLong()
        last[selected] = d + 1L
        for (j in 0 until 26) {
            satisfactions[j] -= c[j] * ((d + 1) - last[j])
        }
    }
//    debugLog(satisfactions.sum())
    return ans.joinToString("\n")
}

Measured memory_bytes: 47520
N=int(input())
ans=float("inf")
for A in range(1,N):
    B=N-A
    num=0
    for i in range(4,-1,-1):
        a=A//10**i
        num+=a
        A%=10**i
        b=B//10**i
        num+=b
        B%=10**i
    ans=min(ans,num)
print(ans)

Measured memory_bytes: 41324
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()


int main (void) {

  int H, W;
  std::cin >> H >> W;

  std::vector<std::vector<int>> S (H, std::vector<int>(W));
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      char a;
      std::cin >> a;
      if ( a == '.' ) S[i][j] = 1;
      if ( a == '#' ) S[i][j] = 0;
    }
  }

  std::vector<std::vector<int>> S1 (H, std::vector<int>(W));
  for(int i=0; i<H; i++) {
    int sum = 0;
    for(int j=0; j<W; j++) {
      if ( S[i][j] == 0 ) sum = 0;
      sum += S[i][j];
      S1[i][j] = sum;
    }

    int kk = 0;
    for(int j=W-1; j>=0; j--) {
      if ( S1[i][j] == 0 ) kk = 0;
      else {
        if ( kk < S1[i][j] ) kk = S1[i][j];
        S1[i][j] = kk;
      }
    }
  }



  std::vector<std::vector<int>> S2 (H, std::vector<int>(W));
  for(int i=0; i<W; i++) {
    int sum = 0;
    for(int j=0; j<H; j++) {
      if ( S[j][i] == 0 ) sum = 0;
      sum += S[j][i];
      S2[j][i] = sum;
    }

    int kk = 0;
    for(int j=H-1; j>=0; j--) {
      if ( S2[j][i] == 0 ) kk = 0;
      else {
        if ( kk < S2[j][i] ) kk = S2[j][i];
        S2[j][i] = kk;
      }
    }
  }

  int ans = 0;
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) if(S[i][j] == 1) ans = std::max(ans, S1[i][j]+S2[i][j]-1);
  std::cout << ans << std::endl;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int a, b, c;
  cin >> a >> b >> c;

  swap(a, b);
  swap(a, c);

  cout << a << " "
       << b << " " << c << endl;

  return 0;
}

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

using ll = long long;

#define MOD 1000000007

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

    if (abs(N-M) > 1) {
        cout << 0 << endl;
        return 0;
    }

    vector<ll> fact(max(N, M) + 1);
    
    fact[0] = fact[1] = 1;
    for (int i = 2; i < fact.size(); i++) {
        fact[i] = fact[i-1] * i % MOD;
    }

    ll ans = fact[N] * fact[M] % MOD;
    if (M == N) {
        ans = ans * 2 % MOD;
    }

    cout << ans << endl;
}


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

int main(void)
{
    int m, n;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end(), greater<int>());

    bool flag = true;
    for (int i = 0; i < m; i++)
    {
        if (a[i]*4*m < sum)
        {
            flag = false;
        }
    }
    
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#pragma warning (disable:4996)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double average(double *data, int *n){
	double sum = 0.0;
	int i;
	for (i = 0; i < *n; i++)sum += data[i];
	sum /= *n;
	return sum;
}
double* input(int *n){
	int i;
	scanf("%d", n);
	double *data = (double*)calloc(*n, sizeof(double));
	if (!*n)exit(0);
	for (i = 0; i < *n; i++)scanf("%lf", &data[i]);
	return data;
}
double calc(double *data, int *n){
	double sq_of_alpha = 0.0, ave;
	unsigned short int i;
	ave = average(data, n);
	for (i = 0; i < *n; i++)sq_of_alpha += (pow(data[i] - ave, 2) / *n);
	return fabs(sqrt(sq_of_alpha));
}
int main(void){
	int n;
	double *p;
	while (1){
		p = input(&n);
		printf("%lf\n", calc(p, &n));
	}
	return 0;
}

Measured memory_bytes: 672
import numpy as np

#入力
n = int(input())

#3の倍数をFに変更
def multiples_3(matrix):
    #列ベクトルを削除(3列目)
    m_de = np.delete(fizzbuzz_list,2, axis=1)
    #Fの列ベクトルを作成
    f_list = np.zeros(j).reshape(-1, 1)
    #結合
    result = np.concatenate([m_de, f_list], 1)
    return result

#列を計算(繰り上げ)
j = -(-n // 3)

#1からnまでの配列を作成
fizzbuzz_list = np.arange(1,n+1)
#要素数
before_size = fizzbuzz_list.size
#3*n行列に変更
fizzbuzz_list.resize((j,3))

#3の倍数をFに変更
fizzbuzz_list = multiples_3(fizzbuzz_list)

#5の倍数をBに変更
n_b_1 = np.arange(3,j,5)
n_b_2 = np.arange(1,j,5)

fizzbuzz_list[n_b_1,0] = 0
fizzbuzz_list[n_b_2,1] = 0

#15の倍数をFBに変更
n_fb = np.arange(4,j,5)
fizzbuzz_list[n_fb,2] = 0

print(int(np.sum(fizzbuzz_list)))

# np.where(fizzbuzz_list[:,2:3],fizzbuzz_list,"F")



Measured memory_bytes: 47584
/*
	Nishant Singh
	nishant.ns19
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}

inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

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

ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********

ll n;
// ******** GLOBAL VARIABLES ********

bool fun(ll f)
{
	ll n1=n;
	while((n1%f)==0)
	{
		n1=n1/f;
	}
	if((n1-1)%f==0)
		return true;
	return false;

}
void solve(){

	cin>>n;
	if(n==2)
	{
		cout<<1;
		return;
	}
	ll ans=2;
	ll n1=n-1;
	for(ll i=2;(i*i)<=n1;i++)
	{
		if(n1%i==0)
		{
			ans=ans+2;
		}
		if((i*i)==n1)
			ans--;
	}
	for(ll i=2;(i*i)<=n;i++)
	{
		if(n%i==0)
		{
			ans=ans+(fun(i));
			if((i*i)!=n)
			{
				ans=ans+fun(n/i);
			}

		}
	}
	cout<<ans;

}  

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
const int maxn = 15;
int a[maxn];

int main()
{
    string s;
    cin >> s;
    int p = 0;
    for (int i = 0; i < s.size(); i ++) {
        if (s[i] == '1') {
            a[p ++] = 1;
        }
        else if(s[i] == '0') a[p ++] = 0;
        else {
            if(p) p--;
        }
    }
    for (int i = 0; i < p; i ++) {
        cout << a[i];
    }cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] num = new int[n][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                num[i][j] = sc.nextInt();
            }
        }

        int[][] dp = new int[n + 1][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (j == k) {
                        continue;
                    }
                    dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j] + num[i][k]);
                }
            }
        }

        int ans = 0;
        for (int i = 0; i < 3; i++) {
            ans = Math.max(ans, dp[n][i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 99348
n = int(input())

t0, a0 = 1, 1

for i in range(n):
    t1, a1 = map(int, input().split())
    f0 = t0 // t1
    if t0 % t1 != 0:f0 += 1
    f1 = a0 // a1
    if a0 % a1 != 0:f1 += 1
    f = max(f0, f1)
    t0, a0 = t1*f, a1*f

print(t0 + a0)

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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> AB(M);
    for (int i = 0; i < M; i++){
        cin >> AB.at(i).first >> AB.at(i).second;
    }
    sort(AB.begin(), AB.end());

    int ans = 1;
    int MAX = 1e9;
    for (int i = 0; i < M; i++) {
        if (AB.at(i).first < MAX) {
            MAX = min(MAX, AB.at(i).second);
        }
        else {
            ans++;
            MAX = AB.at(i).second;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
require 'set'

n = gets.to_i
s = Set.new
l = ""
result = true
n.times do |i|
    w = gets.chomp
    cs = w.chars
    f = cs.first
    if !f.match l
        result = false
    end
    l = cs.last
    
    if s.include? w
        result = false
    else
        s.add w
    end
end

if result
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 2044
from sys import stdin
mod = 998244353
def main():
    N,S = map(int,stdin.readline().split())
    a = list(map(int,stdin.readline().split()))
    dp = [0]*(S+1)
    ans = 0
    for A in a:
        dp[0] += 1
        for i in reversed(range(A,S+1)):
            dp[i] += dp[i-A]    
            dp[i] %= mod
        ans += dp[S]
        ans %= mod
    print(ans)
if __name__ == "__main__":
    main()


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


int main(){
    int K,N;
    cin >> K >> N;
    vector<int> A(N);
    int a;
    for(int i =0;i<N;i++){
        cin >> A[i];
    }
    int max=0;
    int d,j;
    for(int i=0;i<N-1;i++){
        d = A.at(i+1)-A.at(i);
//        cout << d << endl;
        if(d > max){
            max=d;
            j=i;
        }
    }
    d = A.at(0)+K-A.at(N-1);
//    cout << d << endl;
     if(d > max){
        max=d;
        j=N-1;
     }
     cout << K-max << endl;

}

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

int main(){
  string N;
  cin>>N;
  int a,b,c,d;
  a=N.at(0)-'0';
  b=N.at(1)-'0';
  c=N.at(2)-'0';
  d=N.at(3)-'0';
  if(a+b+c+d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  }else if(a+b+c-d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  }else if(a+b-c+d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  }else if(a+b-c-d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  }else if(a-b+c+d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  }else if(a-b+c-d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  }else if(a-b-c+d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  }else{
    cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
}
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <queue>


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

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

    sort(vec.begin(), vec.end(), greater<ll>());
    ll ans = 0;
    rep(i, n) {
        if (i == 0) {
            ans += ll(vec[i] / 2);
        } else {
            ans += vec[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n,i,ans=0;
    cin>>n;
    int b[n-1];
    for(i=0;i<n-1;i++)cin>>b[i];
    ans=b[0]+b[n-2];
    for(i=0;i<n-2;i++)ans+=min(b[i],b[i+1]);
    cout<<ans<<endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}
ll modpow(ll a, ll p) {
    if(p == 0)
        return 1;
    if(p % 2 == 0) {
        ll halfp = p / 2;
        ll half = modpow(a, halfp);
        return half * half % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}
const int MAX = 1510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) { cin >> A[i]; }
    sort(A.begin(), A.end());
    COMinit();
    ll ans = 0;
    for(int i = K - 1; i < N; i++) {
        ans += A[i] * COM(i, K - 1) % MOD;
        // cout << A[i] << ":" << A[i] * calcComb(i, K - 1) << endl;
        ans %= MOD;
    }
    // cout << ans << endl;
    // min
    for(int i = 0; i <= N - K; i++) {
        ans += MOD;
        ans -= A[i] * COM(N - i - 1, K - 1) % MOD;
        // cout << A[i] << ":" << calcComb(N - K - i + 1, K - 1) << endl;
        ans %= MOD;
    }
    //有る数字A[i]がminになる回数
    //ある数字A[i]がmaxになる回数
    cout << ans << endl;
}

Measured memory_bytes: 36480
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int L, A[202020];

ll ls[202020], rs[202020], dp1[2][202020], dp2[2][202020];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> L;
    for (int i = 1; i <= L; ++i) cin >> A[i];

    for (int i = 1; i <= L; ++i) ls[i] = ls[i-1] + A[i];
    for (int i = L; i >= 1; --i) rs[i] = rs[i+1] + A[i];

    dp1[0][0] = dp1[1][0] = 0;
    dp2[0][L+1] = dp2[1][L+1] = 0;

    for (int i = 1; i <= L; ++i) {
        dp1[0][i] = min(ls[i], dp1[0][i-1] + (A[i] == 0 ? 2 : A[i] % 2));
        dp1[1][i] = dp1[1][i-1] + min(dp1[0][i-1], dp1[1][i-1]) + (A[i] + 1) % 2;
    }

    for (int i = L; i >= 1; --i) {
        dp2[0][i] = min(rs[i], dp2[0][i+1] + (A[i] == 0 ? 2 : A[i] % 2));
        dp2[1][i] = min(dp2[0][i+1], dp2[1][i+1]) + (A[i] + 1) % 2;
    }

    // for (int i = 1; i <= L; ++i) { printf("%5lld ", dp1[0][i]); } cout << endl;
    // for (int i = 1; i <= L; ++i) { printf("%5lld ", dp1[1][i]); } cout << endl;
    // for (int i = 1; i <= L; ++i) { printf("%5lld ", dp2[0][i]); } cout << endl;
    // for (int i = 1; i <= L; ++i) { printf("%5lld ", dp2[1][i]); } cout << endl;

    ll ans = 1LL << 60;
    for (int i = 0; i <= L; ++i) {
        ans = min(ans, dp1[0][i] + dp2[0][i+1]);
        ans = min(ans, dp1[1][i] + dp2[0][i+1]);
        ans = min(ans, dp1[0][i] + dp2[1][i+1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    string s;
    cin >> s;
    int ans = 0;
    int sz = s.size();
    vector<int> d(sz);
    rep(i, 0, sz){
        if(s[i] == '(') d[i] = 1;
        if(s[i] == ')') d[i] = -1;
        if(s[i] == 'i') d[i] = 2;
        if(s[i] == 'w') d[i] = 3;
    }
    rep(i, 0, sz / 2){
        if((d[i] > 1 && d[i] == d[sz - i - 1]) || d[i]*d[sz - i - 1] == -1) continue;
        ans++; 
    }
    if(sz % 2 == 1) if(s[sz / 2] == '(' || s[sz / 2] == ')') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1180
#include<iostream>
#include<vector>

int main() {
	int n;

	std::cin >> n;


	std::vector<int> v(n);
	for (int i = 0; i < n; i++) {
		int num;
		std::cin >> num;
		v[i] = num - 1;
	}

	int ans = 0;
	std::vector<bool> fri(n, false);
	for (int i = 0; i < n; i++) {
		if (fri[i] == false) {
			if (i == v[v[i]]) {
				ans++;
				fri[i] = true;
				fri[v[i]] = true;
			}
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  int year;
  char month[3] = {'\0'};
  char day[3] = {'\0'};

  scanf("%3d7/%2s/%2s%*[^\n]%*c", &year, month, day);
  getchar();

  printf("%3d8/%2s/%2s\n", year, month, day);

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		String[] labelStr = sc.nextLine().split(" ");

		int[] label = new int[6];
		for (int i=0; i < 6; i++) {
			label[i] = Integer.parseInt(labelStr[i]);
		}

		Dice d = new Dice(label);

		int q = sc.nextInt();
		for ( int i=0; i < q; i++) {
			int ul = sc.nextInt(); // upper label
			int fl = sc.nextInt(); // front label

			if (ul == d.ue) {}
			else if (ul == d.mae) d.kok('N');
			else if (ul == d.migi) d.kok('W');
			else if (ul == d.ushiro) d.kok('S');
			else if (ul == d.hidari) d.kok('E');
			else if (ul == d.shita) d.kok('N').kok('N');

			if (fl == d.mae) {}
			else if (fl == d.migi) d.kok('R');
			else if (fl == d.ushiro) d.kok('R').kok('R');
			else if (fl == d.hidari) d.kok('L');

			System.out.println(d.migi);
		}

	}

}

class Dice {
	int ue,mae,migi,hidari,ushiro,shita;

	Dice(int[] label) {
		ue = label[0];
		mae = label[1];
		migi = label[2];
		hidari = label[3];
		ushiro = label[4];
		shita = label[5];
	}

	Dice kok(char newsrl) { // korogasu or kaitenn saseru
		int temp = 0;

		switch (newsrl) {
		case 'N':
			temp = ue;
			ue = mae;
			mae = shita;
			shita =ushiro;
			ushiro = temp;
			break;
		case 'S':
			temp = ue;
			ue = ushiro;
			ushiro = shita;
			shita = mae;
			mae = temp;
			break;
		case 'E':
			temp = ue;
			ue = hidari;
			hidari = shita;
			shita = migi;
			migi = temp;
			break;
		case 'W':
			temp = ue;
			ue = migi;
			migi = shita;
			shita = hidari;
			hidari = temp;
			break;
		case 'R':
			temp = mae;
			mae = migi;
			migi = ushiro;
			ushiro = hidari;
			hidari = temp;
			break;
		case 'L':
			temp = mae;
			mae = hidari;
			hidari = ushiro;
			ushiro = migi;
			migi = temp;
			break;
		}

		return this;
	}

	boolean check(Dice d) {
		if (this.ue == d.ue && this.mae == d.mae &&
				this.migi == d.migi && this.hidari == d.hidari &&
				this.ushiro == d.ushiro && this.shita == d.shita) {
			return true;
		} else
			return false;
	}

}

Measured memory_bytes: 26164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int a;
	cin >> a;
	if(a == 1) cout << "Hello World" << endl;
	else{
		int b,c;
		cin >> b >> c;
		cout << b+c << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
int n;
int dist[510][510];
int occupied[510][510];
int perm[300100];
int q[1200100][2];
int qs, qe;
int getdist(int x, int y) {
	if (x < 0 || y < 0 || x >= n || y >= n)return 0;
	return dist[x][y];
}
void qpush(int x, int y) {
	int cdist = dist[x][y];
	if (cdist > getdist(x + 1, y)) {
		cdist = getdist(x + 1, y);
	}
	if (cdist > getdist(x - 1, y)) {
		cdist = getdist(x - 1, y);
	}
	if (cdist > getdist(x, y + 1)) {
		cdist = getdist(x, y + 1);
	}
	if (cdist > getdist(x, y - 1)) {
		cdist = getdist(x, y - 1);
	}
	cdist += occupied[x][y];
	if (cdist < dist[x][y]) {
		dist[x][y] = cdist;
		q[qe][0] = x;
		q[qe][1] = y;
		qe++;
	}
}
void unoccupy(int x, int y) {
	occupied[x][y] = 0;
	qpush(x, y);
}
void qpoll() {
	int x = q[qs][0];
	int y = q[qs][1];
	qpush(x + 1, y);
	qpush(x - 1, y);
	qpush(x, y + 1);
	qpush(x, y - 1);
	qs++;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n*n; i++) {
		scanf("%d", &perm[i]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			occupied[i][j] = 1;
			dist[i][j] = i + 1;
			if (dist[i][j] > j + 1)dist[i][j] = j + 1;
			if (dist[i][j] > n - i)dist[i][j] = n - i;
			if (dist[i][j] > n - j)dist[i][j] = n - j;
		}
	}
	int ans = 0;
	for (int i = 0; i < n*n; i++) {
		int x = (perm[i] - 1) / n;
		int y = (perm[i] - 1) % n;
		qs = 0;
		qe = 0;
		unoccupy(x, y);
		while (qs < qe) {
			qpoll();
		}
		ans += getdist(x, y);
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 6568
using System;
using System.Linq;
class Program{
  static void Main(){
    int[] nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    int[] l = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    if(nm[0] >= nm[1]){
      Console.Write("0");
      return;
    }
    int[] a = new int[nm[1]-1];
    Array.Sort(l);
    int len = l[nm[1]-1] - l[0];
    for(int i=1; i<nm[1];i++){
      a[i-1] = l[i] - l[i-1];
    }
    Array.Sort(a);
    for(int i = nm[1]-nm[0];i<a.Length;i++){
      len -= a[i];
    }
    Console.Write(len);
  }
}

Measured memory_bytes: 19680
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n;
set<int> s1, s2, s3;
char str[30002];

int main() {
    cin >> n;
    cin >> str;
    rep(i, n) {
        if (i >= 2) {
            rep(j, 100) {
                if (s2.count(j) != 0) {
                    s3.insert(j * 10 + (str[i] - '0'));
                }
            }
        }
        if (i >= 1) {
            rep(j, 10) {
                if (s1.count(j) != 0) {
                    s2.insert(j * 10 + (str[i] - '0'));
                }
            }
        }
        s1.insert(str[i] - '0');
    }
    cout << s3.size() << endl;
    return 0;
}

Measured memory_bytes: 384
#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;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define bits(n) __builtin_popcount(n)


void solve()
{
    int k;
    cin >> k;
    int cnt = 1;
    if (k % 2 == 0 || k % 5 == 0)
        cout<<"-1\n";
    else
    {
        int n = 7 % k;
        while (n)
        {
            n = (n * 10 + 7) % k;
            cnt++;
        }
        cout << cnt << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s,t;
    cin>>s>>t;
    int start;

    for(int i=s.size()-1;i>=0;i--){
        string u=s.substr(i,t.size());
        if(t.size()!=u.size())continue;
        bool flag=true;
        for(int j=0;j<t.size();j++){
            if(t[j]!=u[j]&&u[j]!='?'){
                flag=false;
                break;
            }
        }
        if(flag){
            for(int j=0;j<u.size();i++,j++){
                s[i]=t[j];
            }
            rep(j,s.size()){
                if(s[j]=='?')s[j]='a';
            }
            cout<<s<<endl;
            return 0;
        }
    }
    cout<<"UNRESTORABLE"<<endl;


    return 0;
}


Measured memory_bytes: 3592
a, b, k = map(int,input().split())
cnt = 0
while True:
    if cnt==k:
        break
    if a%2!=0:
        a-=1
    b+=a/2
    a = a/2
    cnt+=1
    if cnt==k:
        break
    if b%2!=0:
        b-=1
    a+=b/2
    b = b/2
    cnt+=1

print(int(a),int(b))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;

int main() {
    int n; cin >> n;
    if (n % 10 == 0) {
        cout << 10 << endl;
        return 0;
        //100000 -> 50000 + 50000
    }
    int sum = 0;
    while (n) {
        sum += n % 10;
        n /= 10;
    }
    cout << sum << endl;
}


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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }

int main(){
    int a, b, c;
    double fa, fb, fc;
    char S[128], sa[128], sb[128], sc[128];
    // int N = in();
    // int K = in();
    // scanf("%s", S);

    int N = in();

    int* aNumBuka = new int[N];
    for (int i = 0; i < N; ++i) {
        aNumBuka[i] = 0;
    }


    for (int i = 2; i <= N; ++i) {
        int nIn = in();
        ++aNumBuka[nIn - 1];
    }

    for (int i = 0; i < N; ++i) {
        printf("%d\n", aNumBuka[i]);
    }



    delete[](aNumBuka);
    return 0;
}







Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
int cnt[26];

int main(){
   string s;
   cin>>s;
   for(int i=0;i<s.size();i++){
      cnt[(int)(s[i]-'a')]++;
   }
   for(int i=0;i<26;i++){
      if(cnt[i]>1){
         cout<<"no"<<endl;
         return 0;
      }
   }
   cout<<"yes"<<endl;

   
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

dp = [[0] * 2 for _ in range(N)]
dp[0][0] = A[0] + A[1]
dp[0][1] = - A[0] - A[1]

for i in range(1, N - 1):
    dp[i][0] = max(dp[i - 1][0] + A[i + 1],
                   dp[i - 1][1] + A[i + 1])
    dp[i][1] = max(dp[i - 1][0] - 2 * A[i] - A[i + 1],
                   dp[i - 1][1] + 2 * A[i] - A[i + 1])

print(max(dp[N - 2]))

Measured memory_bytes: 24816
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner066
{
    public class ABC066C_pushpush
    {
        public static void Main(string[] args)
        {
            
            // データ数の入力
            int N = int.Parse(Console.ReadLine());

            // データの入力
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            LinkedList<int> putNums = new LinkedList<int>();
            for(int i = 0; i < N; i++)
            {
                if( i % 2 == N % 2 )
                {
                    putNums.AddLast(nums[i]);
                }
                else
                {
                    putNums.AddFirst(nums[i]);
                }
            }

            // 結果出力
            Console.WriteLine(string.Join(" ", putNums));

        }

    }
}

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

int main() {
  int N;
  cin >> N;
  map<pair<char, char>, int> MA;
  for (int i = 1; i <= N; i++) {
    char f = to_string(i).front();
    char b = to_string(i).back();
    MA[{f, b}]++;
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    char f = to_string(i).front();
    char b = to_string(i).back();
    ans += MA[{b, f}];
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3696
n = int(input())
A = list(map(int, input().split()))
count = 0
ans = 0
num = float("inf")

for i in range(n):
	a = A[i]
	if a < 0:
		count += 1
	ans += abs(a)
	num = min(num, abs(a))

if count % 2:
	print(ans - 2*(num))
else:
	print(ans)	

Measured memory_bytes: 14284
loop do
    n = gets.to_i
    break if n == 0
    a = (1..n).map { gets.split.map(&:to_i) }
    m = gets.to_i
    a += (1..m).map { gets.split.map(&:to_i) }

    a.sort!.uniq!

    hash = Hash.new(Float::INFINITY) # tab[k]: min r s.t num = k
    hash[[0, 0]] = 0
    a.each do |h, r|
        new_hash = Hash.new(Float::INFINITY)
        hash.each do |key, min_r|
            height, num = key #height <= h
            new_hash[key] = min_r if min_r < new_hash[key]
            if height < h and min_r < r
                new_hash[[h, num+1]] = r if r < new_hash[[h, num+1]]
            end
        end
        hash = new_hash
    end
    p hash.keys.map(&:last).max
end



Measured memory_bytes: 11708
#include <iostream>

int main() {
        int h, w;
        while (1) {
                std::cin >> h >> w;
                if (h == 0 && w == 0) break;
                for (int i = 0; i < h; i++) {
                        for (int j = 0; j < w; j++) {
                                int tmp = (i % 2) + (j % 2);
                                tmp = tmp % 2;
                                if (tmp == 0)
                                        std::cout << "#";
                                else
                                        std::cout << ".";
                        }
                        std::cout << std::endl;
                }
                std::cout << std::endl;
        }
        return 0;
}



Measured memory_bytes: 3104
fn main() {
    let (f, s) = {
        let n = read::<u32>();
        (n / 100, n % 100)
    };

    fn is_month(i: u32) -> bool{
        if 1 <= i && i <= 12 {
            true
        }
        else {
            false
        }
    };

    let s = match (is_month(f), is_month(s)) {
        (true, true) => "AMBIGUOUS",
        (true, false) => "MMYY",
        (false, true) => "YYMM",
        (false, false) => "NA",
    };

    println!("{}", s);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  s.push_back('R');
  vector<int> ans(s.size()-1, 0);
  bool mode = false;
  int co = 1, li;
  rep2(i, 1, s.size()){
    if(mode == false){
      if(s.at(i) == 'R') co++;
      else{
        mode = true;
        ans.at(i) += co/2;
        ans.at(i-1) += (co+1)/2;
        co = 1;
        li = i;
      }
    }else{
      if(s.at(i) == 'L') co++;
      else{
        mode = false;
        // cerr << li << " " << co << " " << i << endl;
        ans.at(li) += (co+1)/2;
        ans.at(li-1) += co/2;
        co = 1;
      }
    }
  }
  rep(i, ans.size()){
    if(i != 0) cout << " ";
    cout << ans.at(i);
  }
  cout << endl;
  return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long int x = 100, y;
	cin >> y;
	for(int i = 1; i <= 10000; i++) {
		long long int z = (x%100);
		x /= 100;
		x *= 101;
		x += z;
		if(x >= y) {
			cout << i << '\n';
			return 0;
		}
	}
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,K;
  cin>>N>>K;
  VI A(N);
  rep(i,N) cin>>A[i];
  ll en;
  ll st;
  ll st2;
  ll now=0;
  VI num(N,-1);
  num[0]=0;
  rep(i,min(K,N)){
    int nxt=A[now]-1;
    if(num[nxt]!=-1){
      en=i+1;
      st=num[nxt];
      st2=nxt;
      break;
    }
    num[nxt]=i+1;
    now=nxt;
  }
  ll ans=0;
  if(K<=N){
    rep(i,K) ans=A[ans]-1;
  }else{
    ans=st2;
    rep(i,(K-st)%(en-st)) ans=A[ans]-1;
  }
  cout<<ans+1<<endl;
}




Measured memory_bytes: 4840
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
from queue import Queue
# import numpy as np
INF = float("inf")


def solve(A: int, B: int):
    print((A-1)*(B-1))
    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: 4448
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int max_value = max(max(a, b), c);

  if ((max_value == a + b) || (max_value == b + c) || (max_value == a + c))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

int main(void){
    string s;
    cin >> s;
    rep(i,s.length()){
        if(s[i]=='?'){
            s[i] = 'D';
        }
    }
    cout << s << endl;
    return 0;
}

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

typedef struct node{
	struct node*oya,*ko[2];
	char key[30];
	int val,p,idx;
}node;

void rot(node*v,int d){
	node*nnn=v->ko[d];
	
	v->ko[d]=nnn->ko[d^1];
	if(v->ko[d])v->ko[d]->oya=v;
	
	v->oya->ko[v->oya->ko[1]==v]=nnn;
	nnn->oya=v->oya;
	
	nnn->ko[d^1]=v;
	v->oya=nnn;  
}
void ins(node*v,node*oya,int dir,node*n){
	if(!v){
		n->oya=oya;
		oya->ko[dir]=n;
	}else{
		int d=strcmp(v->key,n->key)<0||(strcmp(v->key,n->key)==0&&v->idx<n->idx);
		ins(v->ko[d],v,d,n);
		if(v->ko[d]->p > v->p)rot(v,d);
	}
}
void del(node*v){
	while(v){
		if(v->ko[0]){
			if(v->ko[1])rot(v,v->ko[1]->p > v->ko[0]->p);
			else rot(v,0);
		}else{
			if(v->ko[1])rot(v,1);
			else v=v->oya->ko[v->oya->ko[1]==v]=0;
		}
	}
}
void f(node*v,char*s,char*t,int mode){
	if(!v)return;
	if(strcmp(s,v->key)<=0)f(v->ko[0],s,t,mode);
	if(strcmp(s,v->key)<=0&&strcmp(v->key,t)<=0){
		if(mode==0)printf("%d\n",v->val);
		if(mode==2)printf("%s %d\n",v->key,v->val);
	}
	if(strcmp(v->key,t)<=0)f(v->ko[1],s,t,mode);
	if(mode==1&&strcmp(s,v->key)<=0&&strcmp(v->key,t)<=0)del(v);
}

node root;
int main(){
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		int t;
		char s[30];
		scanf("%d%s",&t,s);
		if(t==0){
			int x;
			scanf("%d",&x);
			node*v=calloc(1,sizeof(node));
			memcpy(v->key,s,20);
			v->val=x;
			v->idx=i;
			v->p=rand();
			ins(root.ko[0],&root,0,v);
		}else if(t==1){
			f(root.ko[0],s,s,0);
		}else if(t==2){
			f(root.ko[0],s,s,1);
		}else{
			char t[30];
			scanf("%s",t);
			f(root.ko[0],s,t,2);
		}
	}
}


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

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	int n, i, j, k, ans;
	vi h;
	
	cin >> n >> k;
	h.resize(n);

	rep(i, n) {
		cin >> h[i];
	}

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

	ans = -1;
	for (i = 0; i < n - k + 1; i++) {
		j = h[i + k - 1] - h[i];
		if (ans > j || ans == -1)
			ans = j;
		if (j == 0)
			break;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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;}
int h,w;
int f(int a,int b){
    return a*w+b;
}
bool in(int a,int b){
    if(a < 0 || a >= h || b < 0 || b >= w)return false;
    return true;
}
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
signed main(void) {
    cin >> h >> w;
    vs s(h);
    rep(i,h)cin >> s[i];
    int dp[30*30][30*30] = {};
    rep(i,30*30)rep(j,30*30)if(i != j)dp[i][j] = INF;
    rep(i,h)rep(j,w)if(s[i][j] != '#'){
        rep(k,4){
            int x = i + dx[k];
            int y = j + dy[k];
            if(!in(x,y))continue;
            if(s[x][y] == '#')continue;
            dp[f(i,j)][f(x,y)] = 1;
        }
    }
    rep(k,h*w)rep(i,h*w)rep(j,h*w){
        dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]);
    }
    int ans = 0;
    rep(i,30*30)rep(j,30*30)if(dp[i][j] != INF){
        ans = max(ans, dp[i][j]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,a[MN+5];long long ans=0;
int main()
{
    n=read();
    for(int i=1;i<=n;++i) a[i]=read();
    for(int i=1;i<=n;++i)
    {
        if((a[i]&1)&&a[i+1]) --a[i+1],++ans;
        ans+=a[i]>>1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
    double l;
	cin >> l;
	double ans = (l / 3)*(l / 3)*(l / 3);
	printf("%.7lf", ans);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[][]A = new int[N-1][];
		var list = new List<int[]>[N];
		for(var i=0;i<N;i++){
			list[i] = new List<int[]>();
		}
		for(var i=0;i<N-1;i++){
			string[] str = Console.ReadLine().Split();
			A[i] = new int[2]{int.Parse(str[0]),int.Parse(str[1])};
			list[A[i][0]-1].Add(new int[2]{A[i][1]-1,i});
			list[A[i][1]-1].Add(new int[2]{A[i][0]-1,i});
		}
		int max = 0;
		for(var i=0;i<N;i++){
			max = Math.Max(max,list[i].Count);
		}
		Console.WriteLine(max);
		int[]C = new int[N];
		var listA = new List<int>();
		listA.Add(0);
		int[]F = new int[N];
		int[]ans = new int[N];
		while(listA.Count>0){
			var listA2 = new List<int>(listA);
			listA.Clear();
			foreach(var i in listA2){
				F[i]=1;
				foreach(var j in list[i]){
					if(F[j[0]]==0){
						int a1 = C[i];
						int a2 = C[j[0]];
						int a3 = Math.Max(a1,a2)%max+1;
						ans[j[1]] = a3;
						C[i] = a3%max;
						C[j[0]] = a3%max;
						listA.Add(j[0]);
					}
				}
			}
		}
		for(var i=0;i<N-1;i++){
			Console.WriteLine(ans[i]);
		}
	}
}

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

int main(){
	int a[3],cnt=0;
	cin>>a[0]>>a[1]>>a[2];
	while(!(a[0]==a[1] and a[1]==a[2])){
		sort(a,a+3);
		if(a[1]==a[2]){
			a[0]+=2;
		}
		else{
			a[0]++;
			a[1]++;
		}
		cnt++;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
import static java.lang.Math.pow;
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int r = in.nextInt();
        int s = in.nextInt();
        if(r>=1&&r<=100&&s>=1&&s<=pow(10,5)){
            if(r*500>=s){
                System.out.println("Yes");
            }
            else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 21588
N=int(input())
cnt=0
T,X,Y=0,0,0
for i in range(N):
  t,x,y=map(int,input().split())
  if abs(X-x)+abs(Y-y)<=t-T and t%2==(x+y)%2:cnt+=1
  T,X,Y=t,x,y
print("Yes" if cnt==N else "No")

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

int main()
{
    int n,t,id,v,m=1005;
    cin>>n>>t;
    map<int,int>mp;
    for(int i=0;i<n;i++)
    {
        cin>>id>>v;
        mp[id]=v;
    }
    id=1005;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        if(it->second <= t)
        {
            id=min(id,it->first);
        }
    }

    if(id!=1005)cout<<id<<endl;
    else cout<<"TLE\n";


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 1001

char X[LEN], Y[LEN];

int LCS(){
  int m, n, i, j;
  m = strlen(X);
  n = strlen(Y);
  
  int c[m+1][n+1];
  for(i = 1; i <= m; i++){
    c[i][0] = 0;
  }
  for(j = 0; j <= n; j++){
    c[0][j] = 0;
  }
  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(X[i-1] == Y[j-1]){
	c[i][j] = c[i-1][j-1] + 1;
      }else if(c[i- 1][j] >= c[i][j-1]){
	c[i][j] = c[i-1][j];
      }else{
	c[i][j] = c[i][j-1];
      }
    }
  }
  return c[m][n];
}

main(){
  int n, i;
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s%s", X, Y);
    printf("%d\n", LCS());
  }
  return 0;
}

Measured memory_bytes: 4512