akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, Y: int):
    matrix = [[float('inf')]*(N+1) for _ in range(N+1)]

    answer = [0]*N

    for i in range(1,N+1):
        for j in range(i+1,N+1):
            matrix[i][j] = min(j-i,abs(X-i)+1+abs(Y-j),abs(Y-i)+1+abs(X-j))
            answer[matrix[i][j]] += 1
    # print(matrix)

    for i in range(1,N):
        print(answer[i])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 164444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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 long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m; cin >> n >> m;
    vector<int> g(n + 2, 0);
    rep(i, m)
    {
        int l, r; cin >> l >> r; r++;// rを含みたいから開区間にするためのインクリメント
        g[l]++;
        g[r]--;
    }

    int CNT = 0;
    rep(i, n) g[i + 1] += g[i];
    // rep(i, g.size())
    // {
    //     COUT(g[i]);
    // }
    int ans = 0;
    rep(i, n + 1) if (g[i] == m) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 768
# AOJ 0174 Badminton
# Python3 2018.6.19 bal4u

f = True
while True:
	for k in range(3):
		p = list(input())
		if p[0] == '0':
			f = False
			break
		a, b = 0, 0
		del p[0]
		for x in p:
			if x == 'A': a += 1
			else: b += 1
		if a > b: a += 1
		else: b += 1
		print(a, b)
	if not f: break


Measured memory_bytes: 5556
#include<bits/stdc++.h>
using namespace std;
int n,m,p,dis[10010],cnt[100010];
struct node{
	int ed,v;
};
vector<node> P[10010];
vector<int> G[10010];
bool can[100010],vis[100010];
queue<int> Q;
void BFS(){
	Q.push(n);
	can[n]=true;
	while(!Q.empty()){
		int now=Q.front();
		Q.pop();
		for(int i=0;i<G[now].size();i++){
			int t=G[now][i];
			if(can[t])continue;
			can[t]=true;
			Q.push(t);
		}
	}
}
int SPFA(){
	while(!Q.empty())Q.pop();
	memset(dis,-63,sizeof(dis));
	Q.push(1);
	dis[1]=0;
	vis[1]=true;
	cnt[1]++;
	while(!Q.empty()){
		int now=Q.front();
		Q.pop();
		vis[now]=false;
		for(int i=0;i<P[now].size();i++){
			int t=P[now][i].ed,v=P[now][i].v;
			if(can[t]==false)continue;
			if(dis[t]<dis[now]+v){
				dis[t]=dis[now]+v;
				if(!vis[t]){
					vis[t]=true;
					cnt[t]++;
					if(cnt[t]>n)return -1;
					Q.push(t);
				}
			}
		}
	}
	return max(0,dis[n]);
}
int main(){
	scanf("%d %d %d",&n,&m,&p);
	for(int i=1;i<=m;i++){
		int x,y,v;
		scanf("%d %d %d",&x,&y,&v);
		G[y].push_back(x);
		P[x].push_back((node){y,v-p});
	}
	BFS();
	cout<<SPFA();
	return 0;
}

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

int main(){
    string S,T;
    cin >> S >> T;
    int count=0,i;
    for(i=0;i<3;i++){
        if(S[i]==T[i]){
            count+=1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>
#include <set>
using namespace std;

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

#define max_n 100

int A, B;

int main() {
	
	cin >> A >> B;

	printf("%d", max(max( A + B,A - B),A*B ));

	return 0;
}

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

using namespace std;

int main(){
  string s,t,u;
  while(cin>>s>>t){
    u=(s.size()>t.size())?t:s;
    if(s==u) s=t;
    int c=s.size();
    int a=0,b=0;
    for(int i=0;i<c;++i){
      for(int j=0;j<c;++j){
	if(u[j]==s[(i+j)%c]){
	  ++b;
	  if(i+j==c-1){
	    a=max(a,b);b=0;
	  }
	}
	else{
	  a=max(a,b);b=0;
	}
      }
      a=max(a,b);b=0;
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch=' ';
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return f==1?x:-x;
}
const int N=2e5+5,M=4005,lim=2001,mod=1e9+7,inv2=(mod+1)/2;
int n,a[N],b[N];
int dp[M][M],vis[M][M];
LL ans,fac[N],inv[N],ifac[N];
inline LL C(LL n,LL m){
	if(n<m)return 0;
	return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main(){
	fac[0]=ifac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<N;++i)fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<N;++i)inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<N;++i)ifac[i]=ifac[i-1]*inv[i]%mod;
	n=read();
	for(int i=1;i<=n;++i)a[i]=read(),b[i]=read();
	for(int i=1;i<=n;++i){
		dp[lim-a[i]][lim-b[i]]++;
		ans=(ans-C(a[i]*2+b[i]*2,a[i]*2)+mod)%mod;
		vis[lim+a[i]][lim+b[i]]++;
	}
	for(int i=1;i<M;++i){
		for(int j=1;j<M;++j){
			dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod;
			ans=(ans+(LL)dp[i][j]*vis[i][j])%mod;
		}
	}
	printf("%lld\n",ans*inv2%mod);
	return 0;
}


Measured memory_bytes: 103168
using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.RegularExpressions;
    using Console = System.Console;

    namespace Atcoder
    {
        class Program
        {
            static void Main(string[] args)
            {
                var f = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var N = f[0];
                var K = f[1];
                var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Dictionary<int,int> dic = new Dictionary<int, int>();
                for (int i = 0; i < N; i++)
                {
                    if (!dic.ContainsKey(r[i]))
                    {
                        dic.Add(r[i],1);
                    }
                    else
                    {
                        dic[r[i]]++;
                    }
                }

                int ret = 0;
                if (dic.Keys.Count > K)
                {
                    var tmpList = dic.Values.OrderBy(x => x).ToList();
                    ret += tmpList.Take(dic.Keys.Count - K).Sum();
                }
                Console.WriteLine(ret);
            }
        }
    }

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

int main(){
    int x,y;
    for(int i=1;;i++){
        cin >> x >> y;
        if(x == 0 && y == 0) break;

        if(x < y){
            cout << x << " " << y << endl;
        }else{
            cout << y << " " << x << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define Graph vector<vector<ll>>
#define INF (ll)(1ll<<60)
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;}

int main(){
	int a,b;cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//??????

int main(void){
	int ans1[1000],ans2[1000],cnt=0;
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0)break;
		int a[100],b[100],dif=0;
		rep(i,n){
			cin>>a[i];
			dif+=a[i];
		}
		rep(i,m){
			cin>>b[i];
			dif-=b[i];
		}
		int first=-1,second=-1,sum=999999;
		rep(i,n){
			rep(j,m){
				if(2*(a[i]-b[j])==dif && sum>a[i]+b[j]){
					first=a[i];
					second=b[j];
					sum=a[i]+b[j];
				}
			}
		}
		ans1[cnt]=first;
		ans2[cnt]=second;
		cnt++;
	}
	rep(i,cnt){
		if(ans1[i]==-1){
			cout<<-1<<endl;
		}else{
			cout<<ans1[i]<<" "<<ans2[i]<<endl;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n >> m;
    if (m >= n)
        cout << n << endl;
    else
        cout << n - 1 << endl;
    return 0;
}


Measured memory_bytes: 3556
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 2e3 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int a[N][N];
int v[N][N];

int rh[N][N];
int rv[N][N];

main() {
#ifdef ziel
	freopen("input.in", "r", stdin);
#else
	fre("");
#endif
	ACCELERATE;

	int n, m, q;
	cin >> n >> m >> q;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			char x;
			cin >> x;

			x -= 48;
			a[i][j] = x;
			v[i][j] = v[i-1][j] + v[i][j-1] - v[i-1][j-1] + x;

			rv[i][j] = rv[i-1][j] + rv[i][j-1] - rv[i-1][j-1] + (x && a[i][j-1]);
			rh[i][j] = rh[i-1][j] + rh[i][j-1] - rh[i-1][j-1] + (x && a[i-1][j]);
		}
	}

	while (q--) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;

		int vs = v[x2][y2] - v[x2][y1-1] - v[x1-1][y2] + v[x1-1][y1-1];
		int rvs = rv[x2][y2] - rv[x2][y1] - rv[x1-1][y2] + rv[x1-1][y1];
		int rhs = rh[x2][y2] - rh[x2][y1-1] - rh[x1][y2] + rh[x1][y1-1];

		cout << vs - rhs - rvs << '\n';
	}

	return 0;
}
/*
 
*/


Measured memory_bytes: 71424
#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 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    char H, D;cin>>H>>D;

    if(H==D){
      cout<<"H"<<endl;
    }else{
      cout<<"D"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

//      C114 - 755 
//  DFSでシンプルに解く。
//  高々3^10なので、60000程度。

LL cnt;                     //答え  参照渡ししてvoidDFS内でカウントアップ
LL N;   
bool three = false;
bool five = false;
bool seven = false;
vector<int> keta;
int Nsize;

unsigned GetDigit(unsigned num){        //int,LLの桁拾い
    if(num == 0)return 1;
    return log10(num)+1;
}

void DFS(LL n,int nex,LL &cnt,vector<int> &k){  //DFS関数　voidにしてcntとvectorを参照渡しする。

    if(n*10+nex > N)return;     //基本的に下にあるnsizeの条件と被ってそう。一応保険的に。
    int nsize = GetDigit(n);    //桁GET

    if(n == 0){
        k[0] = nex;
    }
    else{
        k[nsize] = nex;
    }

    for(int i = nsize+1;i<Nsize;i++){
        k[i] = 0;
    }
    rep(i,Nsize){
        if(k[i] == 3)three = true;
        if(k[i] == 5)five = true;
        if(k[i] == 7)seven = true;
    }

    if(three && five && seven)cnt++;

    three = false;
    five = false;
    seven = false;


    
    DFS(n*10 + nex,3,cnt,keta);
    DFS(n*10 + nex,5,cnt,keta);
    DFS(n*10 + nex,7,cnt,keta);
    return;
}

int main(){
    cin >> N;
    Nsize = GetDigit(N);
    keta.resize(Nsize);
    DFS(0,3,cnt,keta);
    DFS(0,5,cnt,keta);
    DFS(0,7,cnt,keta);
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
using namespace std;
using pii = pair<int,int>;
signed main(){
    int n,k; cin >> n >> k;
    set<int>st;
    vector<pii>v(n);
    for(auto & p : v){
        cin >> p.second >> p.first;
    }
    vector<int>dp(k+1,0LL);
    sort(all(v),greater<pii>());
    priority_queue<pii,vector<pii>,greater<pii>>que;
    priority_queue<pii,vector<pii>>cnddt;
    int val = 0, p = 0;
    rep(i,k){
        pii top = v[i];
        val += top.first;
        if(st.count(top.second) == 0){
            st.insert(top.second);
            p++;
        } else {
            que.push(top);
        }
    }
    rep(i,n){
        if(i < k)continue;
        if(st.count(v[i].second) == 0)cnddt.push(v[i]);
    }
    dp[p] = val+p*p;
    while(p < k and (not cnddt.empty() and not que.empty())){
        auto ctop = cnddt.top(); cnddt.pop();
         if(st.count(ctop.second))continue;
        auto qtop = que.top(); que.pop();
        ++p;
        val -= qtop.first;
        val += ctop.first;
        st.insert(ctop.second);
        dp[p] = val +p*p;
    }
    cout << *max_element(all(dp)) << endl;
}






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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	string S, T;
	cin >> S >> T;

	int ans = 0;
	rep(i, 0, SZ(S) - SZ(T) + 1)
	{
		int res = 0;
		rep(j, 0, SZ(T))
		{
			if (S[i + j] == T[j])
			{
				res++;
			}
		}
		chmax(ans, res);
	}

	cout << SZ(T) - ans << endl;

	return 0;
}


Measured memory_bytes: 3644
import java.util.*;
public class Main {
  
  //////HELLO STALKER, SORRY BUT I HAD DONE IT AFTER TAKING HELP OF EDITORIAL
    public static void main(String[] args) {
        Scanner input=new Scanner (System.in);
        
        int n=input.nextInt();
        
        ArrayList <Integer>ind=new <Integer>ArrayList();
        
        int q=input.nextInt();
        
        System.out.flush();
        
        String str=input.next();
        
        int max=0;
        int co=0;
        int arr[]=new int[n];
        arr[0]=0;
        for(int i=1;i<n;i++)
        {
            if(str.charAt(i-1)=='A'&& str.charAt(i)=='C')
            {
                ind.add(i);
                co++;
                arr[i]=co;
//                if(ind.get(i)>max)
//                    max=ind.get(i);
                
            
            }
            else
                arr[i]=co;
        
        
        
        }
        
        
        for(int i=0;i<q;i++)
        {
            
            int l=input.nextInt();
            int r=input.nextInt();
            int count=arr[r-1]-arr[l-1];
//            if(l==1&&r==n)
//                System.out.println(ind.size());
//            else{
//            for(int j=0;j<ind.size();j++)
//            {
//                if(((ind.get(j)>=l-1)&&(ind.get(j)<=r-1))&&((ind.get(j)+1>=l-1)&&(ind.get(j)+1<=r-1)))
//                    count++;
//                if(ind.get(j)>r-1)
//                    break;
//                if(l-1>max)
//                    break;
//            }
            System.out.println(count);
            
            
        }
        
        
        
    }
    
}


Measured memory_bytes: 65472
//aoj0149
#include<iostream>
using namespace std;

int main() {
	double a, b;
	int left[4];
	int right[4];

	for (int i = 0; i < 4; i++) {
		left[i] = 0;
		right[i] = 0;
	}

	while (cin >> a >> b) {
		if (a >= 1.1) { left[0]++; }
		else if (a >= 0.6) { left[1]++; }
		else if (a >= 0.2) { left[2]++; }
		else { left[3]++; }

		if (b >= 1.1) { right[0]++; }
		else if (b >= 0.6) {right[1]++;}
		else if (b >= 0.2) { right[2]++; }
		else { right[3]++; }
	}

	for (int i = 0; i < 4; i++) {
		cout << left[i] << " " << right[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3184
import Control.Monad

merge xs [] = xs
merge [] ys = ys
merge (x:xs) (y:ys)
    | x < y     = x : merge xs (y:ys)
    | otherwise = y : merge (x:xs) ys

sort [x] = [x]
sort x = merge (sort (take h x)) (sort (drop h x))
    where
        h = length x `div` 2
{-
getAns :: Int -> [Int] -> Int
getAns n [] = 0
getAns n (x:xs)
  | sum xs `mod` 10 == 0 = getAns n xs
  | otherwise            = sum xs
-}
g n [] = n
g n (x:xs)
  | x `mod` 10 == 0 = g n xs
  | otherwise       = x

main = do
  num <- read <$> getLine
  nums <- replicateM num $ read <$> getLine
  let newNums = sort nums
  putStrLn $ show (if sum newNums `mod` 10 == 0 then sum newNums - g (sum newNums) newNums
                                                else sum newNums)


Measured memory_bytes: 1020
// https://atcoder.jp/contests/agc014/tasks/agc014_a

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long a, b, c;
    cin >> a >> b >> c;
    if (a > b)
        swap(a, b);
    if (a > c)
        swap(a, c);
    if (b > c)
        swap(b, c);

    if ((a == b) & (b == c))
    {
        cout << (a & 1 ? 0 : -1) << endl;
        return 0;
    }

    int ans = 0;
    while (((a | b | c) & 1) == 0)
    {
        long na, nb, nc;
        na = (b + c) / 2;
        nb = (c + a) / 2;
        nc = (a + b) / 2;
        a = na;
        b = nb;
        c = nc;
        ans++;
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> plus(N),minus(300000,0);
    rep(i,N){
        int A;
        cin>>A;
        plus[i]=i+1+A;
        if(i+1-A>0){
            minus.at(i+1-A)++;
        }
    }
    ll ans=0;
    rep(i,N){
        if(plus[i]<300000){
            ans+=minus[plus[i]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5108
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADiverseWord solver = new ADiverseWord();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADiverseWord {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            Character[] c = new Character[s.length()];
            NextPermutation<Character> np = new NextPermutation<>();
            for (int i = 0; i < s.length(); i++) {
                c[i] = s.charAt(i);
            }
            if (s.length() < 26) {
                for (char i = 'a'; i <= 'z'; i++) {
                    if (s.indexOf(i) == -1) {
                        out.println(s + i);
                        return;
                    }
                }
            } else {
                if (np.nextPermutation(c) == null) {
                    out.println(-1);
                } else {
                    for (int i = 0; i < 26; i++) {
                        out.print(c[i]);
                        if (s.charAt(i) != c[i]) break;
                    }
                    out.println();
                }
            }
        }

    }

    static class NextPermutation<T extends Comparable<T>> {
        public T[] nextPermutation(T[] array) {
            int k = -1;
            int i = array.length - 2;
            while (i >= 0) {
                if (array[i].compareTo(array[i + 1]) < 0) {
                    k = i;
                    break;
                }
                i--;
            }

            // 存在しない場合nullを返す
            if (k == -1) return null;
            int l = k + 1;
            i = array.length - 1;
            while (i > k + 1) {
                if (array[k].compareTo(array[i]) < 0) {
                    l = i;
                    break;
                }
                i--;
            }

            T tmp = array[k];
            array[k] = array[l];
            array[l] = tmp;
            int[] res = new int[array.length];
            // k+1 <-> n-1
            for (int j = k + 1; j < array.length + k - j; j++) {
                tmp = array[j];
                array[j] = array[array.length + k - j];
                array[array.length + k - j] = tmp;
            }
            return array;
        }

    }
}



Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int A, B, C;
int main()
{
	cin >> A >> B >> C;
	if (A != 0 && B != 0 && C != 0)
	{
		if ((A + B) - C >= 0)
			cout << "Yes\n";
		else 
			cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int x[200010],s[200010];
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	
	for(int j=1;j<=50&&j<=b;j++)
	{
		for(int i=1;i<=a;i++)
		{
			int L = i-x[i];
			int R = i+x[i];
			if(L<1) L = 1;
			if(R>a) R = a;
			s[L]++, s[R+1]--;
		}
		
		for(int i=1;i<=a;i++) x[i] = x[i-1] + s[i];
		for(int i=1;i<=a+1;i++) s[i] = 0;
	}
	for(int i=1;i<=a;i++) printf("%d ",x[i]);
}

Measured memory_bytes: 3292
import sys
input = sys.stdin.readline

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

distance = [[min(i, j, n - i - 1, n - j - 1) for i in range(n)] for j in range(n)]
check = [[1] * n for i in range(n)]
p = [((i - 1) // n, (i - 1) % n) for i in p]

def move(x,y,nx,ny):
    if distance[nx][ny] > distance[x][y] + check[x][y]:
        distance[nx][ny] = distance[x][y] + check[x][y]
        d.append((nx,ny))

ans = 0
for i, j in p:
    ans += distance[j][i]
    d=[]
    d.append((j,i))
    check[j][i] = 0
    while len(d):
        x, y = d.pop()
        if x!=0:
            move(x,y,x-1,y)
        if x!=n-1:
            move(x,y,x+1,y)
        if y!=0:
            move(x,y,x,y-1)
        if y!=n-1:
            move(x,y,x,y+1)

print(ans)

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

int main()
{
  char a,b,c,d;
  int count=0;

  cin>>a>>b>>c>>d;

  if(a=='+') count+=1;
  else count-=1;
  if(b=='+') count+=1;
  else count-=1;
  if(c=='+') count+=1;
  else count-=1;
  if(d=='+') count+=1;
  else count-=1;


  cout << count <<endl;



}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <set>
#include <cstdio>
#include <complex>

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

const double EPS = 1e-9;

typedef complex<double> P;

struct C {
  P p; double r;
  C(P p, double r) : p(p), r(r){}
};
pair<P, P> cc_cross(const C& c1, const C& c2) {
  double d = abs(c1.p - c2.p);
  double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
  double rs = sqrt(c1.r*c1.r - rc*rc);
  P diff = (c2.p - c1.p) / d;
  return make_pair(c1.p + diff * P(rc, rs), c1.p + diff * P(rc, -rs));
}

int main(){
  while(const int n = getInt()){
    vector<double> x(n);
    vector<double> y(n);
    vector<double> l(n);

    REP(i,n){
      x[i] = getInt();
      y[i] = getInt();
      l[i] = getInt();
    }

    double low  = 0.0;
    double high = 1000;

    REP(cc,100){
      const double med = (low + high) / 2;
      vector<double> w(n);
      vector<P> cand;

      bool ok = true;
      REP(i,n) if(l[i] < med){ ok = false; goto next; }

      REP(i,n) w[i] = sqrt(l[i] * l[i] - med * med);
      REP(i,n) cand.push_back(P(x[i], y[i]));
      REP(i,n) REP(j,i){
        if(std::abs(P(x[i], y[i]) - P(x[j], y[j])) + EPS > w[i] + w[j]){
          // printf("%.4f %d %d (%.4f %.4f)\n", med, i, j, std::abs(P(x[i], y[i]) - P(x[j], y[j])), w[i] + w[j]);
          ok = false; goto next;
        }
        if(std::abs(P(x[i], y[i]) - P(x[j], y[j])) > std::abs(w[i] - w[j])){
          pair<P, P> tmp = cc_cross(C(P(x[i], y[i]), w[i]), C(P(x[j], y[j]), w[j]));
          cand.push_back(tmp.first);
          cand.push_back(tmp.second);
        }
      }

      // REP(i,n) cand.push_back(P(x[i], y[i]));

      REP(j,cand.size()){
        bool tok = true;
        const P p = cand[j];
        REP(i,n){
          if(std::abs(P(x[i], y[i]) - p) > w[i] + EPS){
            tok = false;
          }
        }
        if(tok) goto next;
      }
      if(n != 1) ok = false;
      // puts("TEST");

    next:;
      if(ok){
        low = med;
      }else{
        high = med;
      }
    }

    printf("%.8f\n", low);
  }
  return 0;
}

Measured memory_bytes: 1100
#include <iterator>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>

using namespace std;

int main()
{
    int n, m;
    scanf("%d", &n);
    vector<int> arr;

    int tmp;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &tmp);
        arr.push_back(tmp);
    }

    scanf("%d", &m);
    vector<int> brr;
    for (int i = 0; i < m; i++)
    {
        scanf("%d", &tmp);
        brr.push_back(tmp);;
    }

    vector<int> dst;
    set_union(arr.begin(), arr.end(),
              brr.begin(), brr.end(), back_inserter(dst));

    for (auto &i : dst)
    {
        printf("%d\n", i);
    }

    return 0;
}



Measured memory_bytes: 6424
#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 mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=4e5+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

//~ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll inv[N],f1[N],f2[N];

void init(){
	inv[1]=1;
	for(int i=2;i<N;++i){
		inv[i]=mod-mod/i*inv[mod%i]%mod;
	}
	f1[0]=f2[0]=1;
	for(int i=1;i<N;++i){
		f1[i]=f1[i-1]*i%mod;
		f2[i]=f2[i-1]*inv[i]%mod;
	}
}

ll binomial(int n,int k){
	return f1[n]*f2[n-k]%mod*f2[k]%mod;
}

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n,k;
	init();
	cin>>n>>k;	
	ll ans=1; // 1 1 1 1 1
	if(k==1) ans=0;
	for(int i=1;i<=(min(k,n-1));++i){
		// chia keo euler
		//~ cout<<binomial(n,i)<<" "<<binomial(n-1,n-1-i)<<endl;
		//~ cout<<binomial(n,i)*binomial(n-1,n-1-i)%mod<<endl;
		ans+=binomial(n,i)*binomial(n-1,n-1-i);
		ans%=mod;
	}
	cout<<ans;
	return 0;	
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 3e3+3;
double pd[MAX][MAX];
double a[MAX];
int N;

double solve() {
	REP(i, 0, N) REP(j, 0, N/2) pd[i][j] = 1.0;
	REP(i, 1, N) REP(j, 0, N/2) {
		pd[i][j] = pd[i-1][j] * a[i];
		if(j) pd[i][j] += pd[i-1][j-1] * (1-a[i]);
	}
	return pd[N][N/2];
}

int main(int argc, char ** argv) {
	scanf("%d", &N);
	REP(i, 1, N) scanf("%lf", &a[i]);
	printf("%.10lf\n", solve());
	return 0;
}


Measured memory_bytes: 69760
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template <class T>
class CuSum {
private:
	vector<T> cusum;
public:
	// Constructors 
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)vec.size(); i++) cusum[i + 1] = cusum[i] + vec[i];
	}
	CuSum(int N) : cusum(N + 1) {}
	void add(int i, T x) { cusum[i + 1] += x; }
	void init() { for (int i = 0; i < (int)cusum.size() - 1; i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r) 
	T operator()(int l, int r) {
		if (r < l || r < 0) {
			assert(0);
			return T(0);
		}
		else return cusum[r] - cusum[l];
	}
	// 0-indexed
	T operator[](int i) { return cusum[i + 1]; }
	T back() { return cusum.back(); }
};

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

int main() {

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

	int N;
	cin >> N;

	vector<lint> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	CuSum<lint> suma(a);
	
	lint ans = (1LL << 60);
	for (int i = 1; i < N; i++) {
		DMP(suma(0, 1), suma(i, N));
		chmin(ans, abs(suma(0, i) - suma(i, N)));
	}

	cout << ans << "\n";

	return 0;
}

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

int main(int argc, char const *argv[])
{
    int d, n;
    cin >> d >> n;
    int out;
    out = n*pow(100, d);
    if (n == 100){
        out += out/100;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n , m = map( int, input().split() )
    Sets = []

    Dicto = [ -1 for i in range(n + 1)]

    for i in range( m ):
        a , b = map( int , input().split() )
        if Dicto[a] == -1 and Dicto[b] == -1:
            Sets.append( set( [a,b] ) )
            x_i = len(Sets)
            Dicto[ a ] = x_i - 1
            Dicto[ b ] = x_i - 1
        elif Dicto[ a ] != -1 and Dicto[ b ] == -1:
            Sets[ Dicto[a] ].add( b )
            Dicto[ b ] = Dicto[a]
        elif Dicto[ b ] != -1 and Dicto[ a ] == -1:
            Sets[ Dicto[b] ].add( a )
            Dicto[ a ] = Dicto[b]
        elif Dicto[ b ] != -1 and Dicto[ a ] != -1 and Dicto[ a ] != Dicto[ b ]:
            if Dicto[ b ] > Dicto[ a ]:
                set_x = Sets[Dicto[b]]
                Sets[ Dicto[a] ] |= ( set_x )
                l_set_x = list( set_x )
                for j in l_set_x:
                    Dicto[j] = Dicto[a]

            else:
                set_x = Sets[Dicto[a]]
                Sets[ Dicto[b] ] |= ( set_x )
                l_set_x = list( set_x )
                for j in l_set_x:
                    Dicto[j] = Dicto[b]

    #print(Sets)
    #print(Dicto)

    max_len = 1

    for i in range( len(Sets) ):
        if max_len < len( Sets[i] ):
            max_len = len( Sets[i] )

    print(max_len)


main()

Measured memory_bytes: 77720
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;

void B_146()
{
  int N;
  string S;
  cin >> N >> S;

  for (int i = 0; i < (int)S.size(); ++i)
  {
    if (S[i] + N > 'Z') S[i] = 'A' + (S[i] + N - 'Z' - 1);
    else S[i] = S[i] + N;
  }
  cout << S << endl;
}

int main()
{
  //C_140();
  //C_141();
  //C_142();
  //C_143();
  //C_144();
  //C_145();
  //C_146();
  //C_147();
  //C_148();
  //C_149();
  //A_149();
  //B_149();
  //A_148();
  //B_148();
  //A_147();
  //B_147();
  //A_146();
  B_146();
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int N,M,D,cnt=0,i,j,k;
	char x[101][101];
	scanf("%d%d%d",&N,&M,&D);
	for(i=0;i<N;i++){
		for(j=0;j<M;j++){
			scanf(" %c",&x[i][j]);
		}
	}
	/*for(i=0;i<N;i++){
		for(j=0;j<M;j++){
			printf("%c",x[i][j]);
		}
		printf("\n");
	}*/
	for(i=0;i<N;i++){
		for(j=0;j<M;j++){
			if(x[i][j]=='.'){
				for(k=0;k<D;k++){
					if(x[i+k][j]!='.') break;
					if(k==D-1) cnt++;
				}
				for(k=0;k<D;k++){
					if(x[i][j+k]!='.') break;
					if(k==D-1) cnt++;
				}
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 2744
import sys

N, M = map(int, input().split())
ab = [tuple(map(int, line.split())) for line in sys.stdin.readlines()]

first = dict()
for a, b in ab:
    if a == 1:
        first[b] = 1

for a, b in ab:
    if b == N:
        if a in first:
            print("POSSIBLE")
            exit()

print('IMPOSSIBLE')

Measured memory_bytes: 44324
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


D = []

for i in range(5):
    D.append(inp())

D = sorted(D, key=lambda d: 0 if d % 10 == 0 else ((d//10)+1)*10-d)

res = 0
for d in D[:4]:
    if d % 10 != 0:
        res += d + (((d//10)+1)*10-d)
    else:
        res += d
print(res+D[4])


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long ans = 1;
    for(long long i = 1; i <= n; i++){
        ans = ans*i%1000000007;
    }
    cout<<ans;

    return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long n = sc.nextLong();
		
		// 計算
		int result = Integer.MAX_VALUE;
		for(int i = 1; i <= sqrt(n); i++){
		    if(n%i != 0) continue;
		    long m = n/i;
		    result = min(result, Long.toString(m).length());
		}
		
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF INT_MAX/2
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;
typedef long long ll;

int a[100000];
int sum[100001];
int n, l;

int main(){
	scanf("%d%d", &n, &l);
	int cnt = 0;
	rep(i, n){
		sum[i] = cnt;
		scanf("%d", &a[i]);
		cnt += a[i];//a[i]までつないだ長さ
	}
	sum[n] = cnt;
	bool flag = false;
	int i;
	for (i = 0; i < n - 1; i++){
		if (sum[i + 2] - sum[i] >= l){
			flag = true;
			break;
		}
	}
	if (!flag){ printf("Impossible\n"); return 0; }
	printf("Possible\n");
	for (int j = 1; j <= i; j++){
		printf("%d\n", j);
	}
	for (int j = n - 1; j > i; j--){
		printf("%d\n", j);
	}
	return 0;
}

Measured memory_bytes: 1536
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

h,w = map(int,readline().split())
a = read().split()

color = [[0]*(w+2) for _ in range(h+2) ]
stack = []
for i in range(h):
    for j in range(w):
        if(a[i][j] == '#'):
            color[i+1][j+1] = 1
            stack.append((i+1,j+1))

for i in range(h+2):
    color[i][0] = 1
    color[i][-1] = 1

for j in range(w+2):
    color[0][j] = 1
    color[-1][j] = 1

ans = -1
while(stack):
    ans += 1
    new_stack = []
    while(stack):
        i,j = stack.pop()
        for x,y in zip([0,0,-1,1],[-1,1,0,0]):
            x += i
            y += j
            if(color[x][y]==0):
                color[x][y] = 1
                new_stack.append((x,y))

    stack = new_stack[::]

print(ans)

Measured memory_bytes: 123148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.*;
   
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] map=new char[h][w];
for(int i=0;i<h;i++){
map[i]=br.readLine().toCharArray();
}
Deque <Point> que=new  ArrayDeque<Point>();
int ans=0;
for(int m=0;m<h;m++){
for(int n=0;n<w;n++){
if(map[m][n]!='.'){
ans++;
Point p = new Point(n,m);
que.addLast(p);
while(que.peekFirst()!=null){
p=que.pollFirst();
int x=p.x;
int y=p.y;
char crop = map[y][x];
map[y][x]='.';
int [] dx ={0,1,0,-1};
int [] dy ={1,0,-1,0};                   
for(int i=0;i<4;i++){
int nx =x+dx[i];
int ny =y+dy[i];
if(nx>=0&&nx<w&&ny>=0&&ny<h&&map[ny][nx]!='.'&&map[ny][nx]==crop){
Point np = new Point();
np.x=nx;
np.y=ny;
que.addLast(np);                       
}
}
}
}
}
}System.out.println(ans);
}
}
}

Measured memory_bytes: 26964
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(std::string T){
  for (int i = 0; i < T.length(); i++) {
    if(T[i] == '?')T[i] = 'D';
  }
  cout << T << endl;
}

int main(){
    std::string T;
				std::cin >> T;
    solve(T);
    return 0;
}


Measured memory_bytes: 3868
#include <iostream>
using namespace std;
int main(void){
    int x,max=0;
    string s;
    cin>>x>>s;
    x=0;
    
    for(int i=0;i<s.length();i++){
        if(s[i]=='I')x++;
        else x--;
        
        if(max<x)max=x;
    }
    cout<<max<<endl;
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 100100;
int n, m;
int u[maxn], v[maxn], p[maxn], cn[maxn];
void init(){
    for(int e = 0; e < maxn; e++) p[e] = e, cn[e] = 0;
}
int find(int x){
    if(x == p[x]) return x;
    return p[x] = find(p[x]);
}
long long sol(int a, int b, int c){
    init();
    long long to[2] = {};
    for(int e = 0; e < m; e++) p[find(u[e])] = find(v[e]);
    for(int e = 0; e < n; e++) cn[find(e)]++;
    for(int e = 0; e < n; e++){
        if(e != find(e)) continue;
        if(find(e) == find(a)) to[0] += cn[find(e)];
        else if(find(e) == find(b)) to[1] += cn[find(e)];
        else to[c] += cn[find(e)];
    }
    long long good = 0;
    good += to[0] * (to[0] - 1) / 2;
    good += to[1] * (to[1] - 1) / 2;
    return good - m;
}
int main(){
    scanf("%d %d", &n, &m);
    for(int e = 0; e < m; e++) scanf("%d %d", u + e, v + e), u[e]--, v[e]--;
    cout << max(sol(0, 1, 0), sol(0, 1, 1)) << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;


int main(){
	double a, l, x;
	double temp1, temp2;
	double center, sides;


	while (cin >> a >> l >> x){
		temp1 = sqrt(pow(l, 2) - pow(a / 2, 2));
		center = a * temp1 / 2;
		
		temp2 = sqrt(pow((l + x) / 2, 2) - pow(l / 2,2));
		sides = temp2 * l;

		printf("%10.10f\n", center + sides);
	}
}

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

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

typedef long long ll;

//#define INF 0x3fffFFFF
//#define INF_NEG (INF * -1)

//int isFirst = 1;
//template <class T> void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

signed main()
{
    string s; cin >> s;
    if (s == "ABC") puts("ARC");
    else puts("ABC");
    return 0;
}


Measured memory_bytes: 3628
N, C = map(int, input().split())
stc = [[int(i) for i in input().split()] for _ in range(N)]
stc.append([float('inf')] * 3)

stc.sort()
stc.sort(key=lambda x: x[2])

imos = [0] * (10 ** 5 + 2)
ps, pt, pc = stc[0]
for i in range(1, N + 1) :
    if stc[i][0] == pt and stc[i][2] == pc :
        pt = stc[i][1]
    else :
        imos[ps] += 1
        imos[pt+1] -= 1
        ps, pt, pc = stc[i]
    
for i in range(1, 10 ** 5 + 2) :
    imos[i] += imos[i-1]

print(max(imos))

Measured memory_bytes: 65880
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}

		Map<Integer, Set<Integer>> map = new HashMap<>();
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			Set<Integer> aSet = map.getOrDefault(a, new HashSet<>());
			aSet.add(b);
			map.put(a, aSet);

			Set<Integer> bSet = map.getOrDefault(b, new HashSet<>());
			bSet.add(a);
			map.put(b, bSet);
		}
		sc.close();

		int count = 0;
		for (int i = 0; i < n; i++) {
			Integer h = list.get(i);
			Set<Integer> set = map.getOrDefault(i + 1, new HashSet<>());
			boolean flag = true;
			for (Integer e : set) {
				Integer hTemp = list.get(e - 1);
				if (h <= hTemp) {
					flag = false;
					break;
				}
			}
			if (flag) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 80056
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define mp make_pair
#define pb push_back
#define ld long double
#define ss(x) (int) x.size()
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl;
#define ios cin.tie(0); ios_base::sync_with_stdio(0)
 
using namespace std;
using namespace __gnu_pbds;
 
// order_of_key
// find_by_order
// tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ja;
const int nax = 2e5 + 111;
const ll INF = 1e18;

int n, x[nax], a, b, c;
vector <pair<int, int>> v[nax];
int p[nax];

int Find(int x) {
	if(x == p[x])
		return x;
	return p[x] = Find(p[x]);
}

int Com;
ll ans = 0;

void Onion(int x, int y, ll val) {
	x = Find(x);
	y = Find(y);
	if(x == y)
		return;
	//cout << x << " " << y << " " << val << endl;
	ans += val;
	Com -= 1;
	p[x] = y;
}

vector <pair<ll, int>> dp[nax][2], best[nax];

void init() {
	FOR(i, 0, n) {
		best[i].clear();
		dp[i][0].clear();
		dp[i][1].clear();
		FOR(j, 0, 1)
			FOR(g, 0, 1)
				dp[i][j].pb(mp(INF, -1));
	}
}
		
void reduce(vector <pair<ll, int>> &x, pair<ll, int> k) {
	if(x[0].se == k.se) {
		if(k.fi < x[0].fi)
			x[0] = k;
	}
	else if(x[1].se == k.se) {
		if(k.fi < x[1].fi)
			x[1] = k;
	}
	else if(k.fi < x[1].fi)
		x[1] = k;
	if(x[1].fi < x[0].fi)
		swap(x[0], x[1]);
}

void dfs1(int u, int p) {
	for(auto it: v[u]) {
		if(it.fi != p) {
			dfs1(it.fi, u);
			reduce(dp[u][0], mp(dp[it.fi][0][0].fi + it.se, dp[it.fi][0][0].se));
			reduce(dp[u][0], mp(dp[it.fi][0][1].fi + it.se, dp[it.fi][0][1].se));
			reduce(dp[u][0], mp(x[it.fi] + it.se, Find(it.fi)));
		}
	}
}

void dfs2(int u, int p, int C) {
	if(p != 0) {
		reduce(dp[u][1], mp(dp[p][1][0].fi + C, dp[p][1][0].se));
		reduce(dp[u][1], mp(dp[p][1][1].fi + C, dp[p][1][1].se));
		reduce(dp[u][1], mp(dp[p][0][0].fi + C, dp[p][0][0].se));
		reduce(dp[u][1], mp(dp[p][0][1].fi + C, dp[p][0][1].se));
		reduce(dp[u][1], mp(x[p] + C, Find(p)));
	}
	for(auto it: v[u])
		if(it.fi != p)
			dfs2(it.fi, u, it.se);
}

int main() {		
	ios;
	cin >> n;
	FOR(i, 1, n)
		cin >> x[i];
	
	FOR(i, 1, n - 1) {
		cin >> a >> b >> c;
		v[a].pb(mp(b, c));
		v[b].pb(mp(a, c));
	}
	
	Com = n;
	FOR(i, 1, n)
		p[i] = i;
	
	while(Com != 1) {
		init();
		
		dfs1(1, 0);
		dfs2(1, 0, 0);
		
		FOR(i, 1, n)
			FOR(j, 0, 1)
				FOR(g, 0, 1)
					dp[i][j][g].fi += x[i];
		
		FOR(i, 1, n) {
			int nr = Find(i);
			if(dp[i][0][0].se != nr)
				best[nr].pb(dp[i][0][0]);
			else
				best[nr].pb(dp[i][0][1]);
			if(dp[i][1][0].se != nr)
				best[nr].pb(dp[i][1][0]);
			else
				best[nr].pb(dp[i][1][1]);
		}
		
		FOR(i, 1, n) {
			sort(best[i].begin(), best[i].end());
			if(!ss(best[i]))
				continue;
			Onion(i, best[i][0].se, best[i][0].fi);
		}
		
	}
	
	cout << ans;
		
		
		
		
	
	
	
	return 0;
}
		


Measured memory_bytes: 146880