akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int a, b, c, x, y;
    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
    if (x == y)
    {
        if (a + b >= c * 2)
        {
            printf("%d\n", c * 2 * x);
        }
        else
        {
            printf("%d\n", (a + b) + x);
        }
    }
    else if (x > y)
    {
        if (a + b >= c * 2)
        {
            if (a >= c * 2)
            {
                printf("%d\n", c * 2 * x);
            }
            else
            {
                printf("%d\n", c * 2 * y + a * (x - y));
            }
        }
        else
        {
            printf("%d\n", a * x + b * y);
        }
    }
    else
    {
        if (a + b >= c * 2)
        {
            if (b >= c * 2)
            {
                printf("%d\n", c * 2 * y);
            }
            else
            {
                printf("%d\n", c * 2 * x + b * (y - x));
            }
        }
        else
        {
            printf("%d\n", a * x + b * y);
        }
    }
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
void field(void);
void move(void);
void clear(void);

  int w,h;
  char mass[103][103]={'\0'};
char now;

int main(){

  while(1){

    scanf("%d %d",&h,&w);

    if(w==h && h==0){
      break;
    }

    field();
    move();
    clear();

  }

  return 0;
}

void field(){

  int i,j;
  
  for(i=0;i<h;i++){
    scanf("%s",mass[i]);
  }

}

void move(){

  now=mass[0][0];
  int end=1,fw=0,fh=0,cnt=0;

  while(end){

    if(cnt==w*h){
      printf("LOOP\n");
      end=0;
    }

    else if(now=='.'){
      printf("%d %d\n",fw,fh);
      end=0;
    }

    else if(now=='>'){
      fw++;
    }

    else if(now=='v'){
      fh++;
    }

    else if(now=='^'){
      fh--;
    }

    else if(now=='<'){
      fw--;
    }

    now=mass[fh][fw];
    cnt++;

  }

}

void clear(){

  int i,j;

  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      mass[i][j]='\0';
    }
  }

}

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

string Transition(string Word){
	for(int i = 0; i < Word.size(); i++){
		if('a' <= Word[i] && Word[i] <= 'z') Word[i] += 'A' - 'a';
	}
	return Word;
}

vector<string> ReadWords(vector<string> Sentence){
//	?????????????????????????????????END_OF_TEXT??§???????????°??§???????????´?????????????????????????????????
	while(1){
		string Go;
		cin >> Go;
		if(Go == "END_OF_TEXT") break;
		for(int i = 0; i < Go.size(); i++){
			if('a' <= Go[i] && Go[i] <= 'z') Go[i] += 'A' - 'a';
		}
		Sentence.push_back(Go);
	}
	return Sentence;
}

int Count(string Word, vector<string> Sentence){
//	?????????????????????????????????????????????????????°?????????
	int C = 0;
	for(int i = 0; i < Sentence.size(); i++){
		if(Sentence[i] == Word) C++;
	}
	return C;
}

int main(){
//	??????????????????????????§???????????´??????
	string Word;
	cin >> Word;
	Word = Transition(Word);
//	????????????????????????
	vector<string> Sentence;
	Sentence = ReadWords(Sentence);
//	for(int i = 0; i < Sentence.size(); i++){
//		cout << Sentence[i];
//	}
//	?????????????????????????????????????????°??????????????????
	int X = Count(Word, Sentence);
	cout << X << endl;
	
//	system("pause");
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	string s;
	cin >> s;

	int n = s.size();

	string s1;
	rep(i, n) {
		if (i % 2)
			s1 += '1';
		else
			s1 += '0';
	}
	string s2;
	rep(i, n) {
		if (i % 2)
			s2 += '0';
		else
			s2 += '1';
	}
	int c1 = 0, c2 = 0;
	rep(i, n) {
		if (s[i] != s1[i])
			c1++;
		if (s[i] != s2[i])
			c2++;
	}
	cout << min(c1, c2) << endl;
}

Measured memory_bytes: 720
from collections import Counter
h, w, m = map(int, input().split())
cr = Counter()
cc = Counter()
s = set()
for _ in range(m):
    hi, wi = map(int, input().split())
    s.add((hi, wi))
    cr[hi] += 1
    cc[wi] += 1
cr = sorted(cr.items(), key=lambda x: x[1], reverse=True)
cc = sorted(cc.items(), key=lambda x: x[1], reverse=True)
mxr = cr[0][1]
mxc = cc[0][1]
ans = mxr + mxc - 1
cr = list(filter(lambda x: x[1] == mxr, cr))
cc = list(filter(lambda x: x[1] == mxc, cc))
for i, _ in cr:
    for j, _ in cc:
        if (i, j) not in s:
            print(ans + 1)
            exit()
print(ans)

Measured memory_bytes: 187812
#include<iostream>
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int32_t main()
{
int n,i;
  cin>>n;
  vector<int> a(n),b(n);
  for(i=0;i<n;i++)
    cin>>a[i];
  int res=a[0];
  for(i=1;i<n;i++)
    res^=a[i];
  for(i=0;i<n;i++)
  {
    b[i]=res^a[i];
    cout<<b[i]<<" ";
  }
  cout<<"\n";
}


Measured memory_bytes: 6328
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif
    

// -------------------------------------Code starts here--------------------------------------------------------------------- 

    int n;
    cin>>n;
    int z=n/100;
    int mod=n%100;
    if(mod<=5*z)
    {
        cout<<1;
    }
    else
    {
        cout<<0;
    }
    


// -------------------------------------Code ends here------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

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

int main(){
    int n;int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    cin>>n;int b[n];
    for(int k=0;k<n;k++){
        cin>>b[k];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(b[k]==a[i][j]) a[i][j]=0;
            }
        }
    }
    if(a[0][0]+a[0][1]+a[0][2]==0||a[1][0]+a[1][1]+a[1][2]==0||a[2][0]+a[2][1]+a[2][2]==0||a[0][0]+a[1][0]+a[2][0]==0||a[0][1]+a[1][1]+a[2][1]==0||a[0][2]+a[1][2]+a[2][2]==0||a[0][0]+a[1][1]+a[2][2]==0||a[0][2]+a[1][1]+a[2][0]==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
  int  a,b;
  string s;
  cin>>a>>s>>b;
  
  
  if(s=="+"){
    cout<< a+b <<endl;
  }
  
  else if (s=="-"){
    cout<< a-b <<endl;
  }
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a1 = (1..n).map { sc.nextInt() }.toIntArray()
  val a2 = (1..n).map { sc.nextInt() }.toIntArray()

  val ans = mutableListOf<Int>()
  for (i in 0 until n) {
    var count = 0
    for (j in 0..i) {
      count += a1[j]
    }
    for (j in i until n) {
      count += a2[j]
    }
    ans.add(count)
  }

  println(ans.max())
}

Measured memory_bytes: 29608
#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 ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) (x).begin(),(x).end()


int main()
{

ll n;
cin>>n;
string s="";

while(n--)
{

s+="ACL";
}

cout<<s<<endl;

}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define N 600005
#define ll long long
#define MOD 998244353
using namespace std;
ll n,a,b,k,inv[N],fact[N];
ll qpow(ll x,ll y){
	ll ans=1;
	for (;y;y>>=1,x=x*x%MOD){
		if (y&1) ans=ans*x%MOD;
	}
	return ans;
}
ll cc(ll a,ll b){
	//printf("%lld %lld %lld\n",a,b,fact[a]*inv[a-b]%MOD*inv[b]%MOD);
	//system("pause");
	return fact[a]*inv[a-b]%MOD*inv[b]%MOD;
}
int main(){
	cin>>n>>a>>b>>k;
	fact[0]=fact[1]=1; for (int i=2;i<=n;i++) fact[i]=fact[i-1]*i%MOD;
	inv[0]=inv[1]=1; for (int i=2;i<=n;i++) inv[i]=qpow(fact[i],MOD-2);
	ll ans=0;
	for (ll i=0;i<=n;i++){
		if (a*i>k) break;
		ll l=0,r=k/b+1;
		while (r-l>1){
			ll mid=l+r>>1;
			if (mid*b+a*i<=k) l=mid; else r=mid;
		}
		//printf("%lld %lld\n",l*b+a*i,k);
		if (l*b+a*i==k&&(l<=n)){
			ans=(ans+cc(n,l)*cc(n,i))%MOD;
			/*for (ll c=max(l+i-n,0ll);c<=min(i,l);c++){
				ans=(ans+cc(n,c)*cc(n-c,i-c)%MOD*cc(n-i,l-c)%MOD)%MOD;
			}*/
		}
	}
	cout<<ans<<endl;
}

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

int main() {
  int K,S; cin >> K >> S;
  int X,Y,Z;
  int cnt = 0;
  for ( int i = 0; i <= K; i++ ) {
    for ( int j = 0; j <= K; j++ ) {
      if ( S-i-j <= K && S-i-j >= 0 ) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 18;




void solve(int t)
{
	ll n;
	cin >> n;
	ll a[n];

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

	ll ans = 0 ;
	ll ma = a[0];

	for (int i = 1; i < n; i++)
	{
		if (a[i] < ma)
		{
			ans += (ma - a[i]);
		}
		else
		{
			ma = max(ma, a[i]);
		}
	}

	cout << ans << endl;

}


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





	int t = 1;
	//cin >> t;



	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 5192
#include<cstdio>
#include<algorithm>
using namespace std;
bool bo[1000000000];
int main() {
	long long a[2],k,ans[1000],cnt=0;
	scanf("%lld%lld%d",&a[0],&a[1],&k);
	sort(a,a+1);
	for(int i=0;i<k;i++) {
		if(a[0]+i<=a[1])
			ans[++cnt]=a[0]+i, ans[++cnt]=a[1]-i;
		else
			break;	
	}
	sort(ans+1,ans+1+cnt);
	for(int i=1;i<=cnt;i++)
		if(!bo[ans[i]])
			printf("%lld\n",ans[i]), bo[ans[i]]=1;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define INF 9999999999

int main(){
  ll x;
  cin >> x;
  ll ans;
  ans = x / 11;
  ans *= 2;
  x %= 11;
  if (x == 0){
    cout << ans << endl;
    return 0;
  }
  x -= 6;
  if (x <= 0){
    cout << (ans+1) << endl;
  }else{
    cout << (ans+2) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (W+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    ll tmp=INF,mid,now;
    Vi ans;
    rep(i,(ll)sqrt(n) + 2){
        if(i==0)continue;
        if(n%i==0){
            ans.pb(i);
            ans.pb(n/i);
        }
    }
    sort(all(ans));
    string s;
    s = to_string(ans[ans.size()/2]);
    print(s.size());
    return 0;
}

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

using namespace std;

int main(void){
    int n, a;
    cin >> n;
    vector<int> j(4, 0);
    for (int i = 0; i < n; i++) {
        cin >> a;
        j[a%4]++;
    }
    
    if (j[0] >= j[1]+j[3]) {
        cout << "Yes" << endl;
        return 0;
    }
    else if (j[0] == j[1]+j[3]-1 && j[2] == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static BufferedReader br;
    static StringTokenizer st;

    public static class Restaurant {
        final int index;
        final String city;
        final Integer score;

        public Restaurant(
                final int index,
                final String city,
                final Integer score
        ) {
            this.index = index;
            this.city = city;
            this.score = score;
        }

        public int getIndex() {
            return index;
        }

        public String getCity() {
            return city;
        }

        public Integer getScore() {
            return score;
        }
    }

    public static void main(final String[] args) {
        br = new BufferedReader(new InputStreamReader(System.in));

        try {
            final int N = readInt();

            final List<Restaurant> restaurants = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                final Restaurant r = new Restaurant(i + 1, next(), readInt());
                restaurants.add(r);
            }

            final Solver solver = new Solver();
            solver.solve(restaurants);

        } catch (final IOException e) {
            e.printStackTrace();
        }
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }

    static long readLong() throws IOException {
        return Long.parseLong(next());
    }

    static int readInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double readDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static char readCharacter() throws IOException {
        return next().charAt(0);
    }

    static String readLine() throws IOException {
        return br.readLine().trim();
    }
}

class Solver {
    public void solve(final List<Main.Restaurant> restaurants) {
        final Comparator<Main.Restaurant> compareByCity = Comparator.comparing(Main.Restaurant::getCity);
        final Comparator<Main.Restaurant> compareByScore = compareByCity.thenComparing(Main.Restaurant::getScore, Comparator.reverseOrder());
        Collections.sort(restaurants, compareByScore);

        for (final Main.Restaurant r : restaurants) {
            System.out.println(r.getIndex());
        }
    }
}


Measured memory_bytes: 26324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

typedef pair<ll,ll> P;

map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) res=res*x%m;
    return res;
}

int main(){
  ll N,M; cin>>N>>M;
  map<ll,ll> mp=prime_factor(M);
  ll ans=1;

  for(auto p:mp){
    if(p.second==1){
      ans=(ans*N)%mod;
    }
    else{
      ll s=p.second;
      ll cnt=1;
      for(ll i=0;i<s;i++) cnt=(cnt*(N+s-1-i))%mod;
      for(ll i=2;i<=s;i++) cnt=(cnt*mod_pow(i,mod-2,mod))%mod;
      ans=(ans*cnt)%mod;
    }
  }
  print(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int i, a, b, c;
	char s[4];

	scanf("%s", s);
	a = b = c = 0;
	for(i=0; i<3; i++){
		if(s[i] == 'a') a++;
		if(s[i] == 'b') b++;
		if(s[i] == 'c') c++;
	}

	if((a==1)&&(b==1)&&(c==1))
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {

    val (size, pos) = readLine()!!.split(" ").map { Integer.parseInt(it) }
    val str = readLine()!!
    val result = str.mapIndexed { index, char -> if (index == pos - 1) char.toLowerCase() else char }
    val buffer = StringBuilder()
    result.forEach {
        buffer.append(it)
    }
    print(buffer)
}

Measured memory_bytes: 38004
class SegTree:
    def __init__(self, a, func):
        self.n = 2**(len(a) - 1).bit_length()
        self.f = func
        self.d = [0] * (2 * self.n - 1)
        self.d[self.n - 1:self.n - 1 + len(a)] = a
        for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def update(self, i, v):
        i += self.n - 1
        self.d[i] = v
        while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def query(self, l, r):
        assert l <= r
        l += self.n
        r += self.n
        s = self.d[l - 1]
        while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
        return s

def main():
    N = int(input())
    S = [1 << (ord(s) - 97) for s in input()]
    T = SegTree(S, lambda x, y: x | y)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().split()
        if t == '1':
            T.update(int(a) - 1, 1 << (ord(b) - 97))
        else:
            print(bin(T.query(int(a) - 1, int(b))).count('1'))

main()


Measured memory_bytes: 48348
h, w = map(int, input().split())
s = [input() for _i in range(h)]
visit = [[float("inf") for _ in range(w)] for _j in range(h)]
visit[0][0] = 0
for i in range(h):
    for j in range(w):
        if i-1 >= 0:
            visit[i][j] = visit[i-1][j]+(s[i][j]!=s[i-1][j])
        if j-1 >= 0:
            visit[i][j] = min(visit[i][j], visit[i][j-1]+(s[i][j]!=s[i][j-1]))

if s[0][0]==s[h-1][w-1]==".":
    print(visit[h-1][w-1]//2)
elif s[0][0]==s[h-1][w-1]=="#":
    print(visit[h-1][w-1]//2 +1) 
else:
    print(visit[h-1][w-1]//2 +1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; cin >> n;
    int a[n]; inarray(a,n);
    int sum = 0;
    sort(a,a+n, greater<int>());
    for(int i = 0; i < n; i++){
        if(i%2 == 0) sum +=a[i];
        else sum -= a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    bool ans = 0;
    for(char c = 'a'; c <= 'z'; c++){
        ans = 0;
        REP(j, s.size()){
            if(s[j] == c) ans = 1; 
        }
        if(ans == 0){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int n,a[30],b[30],c[30];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> a[i];
  int sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> b[i];
    sum += b[i];
  }
  for(int i = 0; i < n-1; i++)
    cin >> c[i];
  
  for(int i = 0; i < n-1; i++) {
    if(a[i] + 1 == a[i+1]) sum += c[a[i]-1];
  }
  cout << sum << endl;  
}

Measured memory_bytes: 3568
N = int(input())


def ryu_memo(n):
  L = [0]*(n+1)
  L[0], L[1] = 2, 1
  
  def ryo(n):
    if n <= 1:
      return L[n]
    if L[n] != 0:
      return L[n]
    
    L[n] = ryo(n-1) + ryo(n-2)
    return L[n]
  return ryo(n)
  
print(ryu_memo(N))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, i_i> i_i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};


int main() {
    //cout.precision(10);
    UnionFind uni(200500);
    int n, m, k;
    vector<i_i_i> edges;
    cin >> n >> m >> k;
    if(k == 1){
        cout << 0 << endl;
        return 0;
    }
    int c[100200];
    for(int i = 1; i <= n; i++){
        cin >> c[i];
    }
    for(int i = 1; i <= m; i++){
        int a, b;
        ll w;
        cin >> a >> b >> w;
        edges.push_back({w, {a, b}});
    }
    ll ans = 0;
    sort(edges.begin(), edges.end());
    int components = k;
    for(int i = 0; i < edges.size(); i++){
        i_i_i now = edges[i];
        int ca = c[now.second.first];
        int cb = c[now.second.second];
        int cost = now.first;
        if(ca == 0){
            ca = now.second.first + 100000;
        }
        if(cb == 0){
            cb = now.second.second + 100000;
        }
        if(uni.issame(ca, cb)) continue;
        uni.merge(ca, cb);
        components--;
        ans += cost;
        if(components == 1){
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  ll X, A;
  I(X);
  I(A);

  P((X<A)?0:10);

}


Measured memory_bytes: 256
mod=10**9+7
import math

def co(n,r,mod):
    x=1
    y=1
    for i in range(1,r+1):
        x=(x*(n-i+1))%mod
        y=(y*i)%mod
    return (x*pow(y,mod-2,mod))%mod
    
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1-co(n,a,mod)-co(n,b,mod)
print(max(ans%mod,0))#ansにmod取らないと無理

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N 2000010
using namespace std;
int n,a[N];
int sm(int x,int y,int z){
	return a[x]<=z&&a[y]<=z;
}
int bd(int x,int y,int z){
	return a[x]>z&&a[y]>z;
}
int ck(int x){
	for(int i=0;i<n-1;i++){
		if(bd(n+i,n+i+1,x)||bd(n-i,n-i-1,x))return 0;
		if(sm(n+i,n+i+1,x)||sm(n-i,n-i-1,x))return 1;
	}
	return sm(1,1,x);
}
int main(){
	cin>>n;
	for(int i=1;i<2*n;i++)cin>>a[i];
	int l=1,r=1e7;
	while(l<r){
		int md=(l+r)/2;
		if(ck(md))r=md;
		else l=md+1;
	}
	cout<<r;
}

Measured memory_bytes: 1024
from math import *



class V:
    def __init__(self,si):
        self.si = si
        self.parent = self
    def isInnovator(self):
        return self.parent == self
    def findInnovator(self):
        re = self
        while True:
            if re.parent == re:
                self.parent = re
                return re
            re = re.parent


N,K = tuple(map(int,input().split()))
vs = [V(vi) for vi in range(N)]

for _ in range(K):
    ui,vi,w = tuple(map(int,input().split()))
    ui-=1
    vi-=1
    u = vs[ui]
    v = vs[vi]
    uInnov = u.findInnovator()
    vInnov = v.findInnovator()
    if uInnov == vInnov:
        continue
    vInnov.parent = uInnov

re = 0
for v in vs:
    if v.isInnovator():
        re += 1

print(re)


Measured memory_bytes: 25716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll r, c, n, val[3005][3005], memo[3005][3005][4];

ll dp(ll x, ll y, ll z) {
	if (x < 1 or y < 1 or z < 0) return -LLINF;
	if (memo[x][y][z] != -1) return memo[x][y][z];
	if (x == 1 and y == 1) {
		if (z == 0) return 0;
		else if (z == 1) return (val[x][y] ? val[x][y] : -LLINF);
		else return -LLINF;
	}
	ll res = -LLINF;
	res = max(dp(x, y-1, z), dp(x, y-1, z-1) + val[x][y]);
	FOR(i, 0, 3) res = max(res, dp(x-1, y, i));
	if (z == 1) FOR(i, 0, 3) res = max({res, dp(x-1, y, i) + val[x][y]});
	return memo[x][y][z] = res;
}

int main() {
	fastio; cin >> r >> c >> n;
	FOR(i, 1, n) {
		ll a, b, c; cin >> a >> b >> c;
		val[a][b] = c;
	}
	memset(memo, -1, sizeof memo);
	cout << max({0ll, dp(r, c, 1), dp(r, c, 2), dp(r, c, 3)});
}


Measured memory_bytes: 356544
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define all(v)          v.begin(), v.end()

#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a, 0, sizeof(a))
#define SET(a)          memset(a, -1, sizeof(a))

inline int setBit(int n, int pos) { return n = n | (1 << pos); }
inline int resetBit(int n, int pos) { return n = n & ~(1 << pos); }
inline bool checkBit(int n, int pos) { return (bool)(n & (1 << pos)); }

// int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
// int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// unsigned int num = rng();
// shuffle(V.begin(), V.end(), rng);

/******************************************************************************************/

const int MAX = 500010;
// const int INF = 0x3f3f3f3f;
// const int MOD = 998244353;

// inline int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
// inline int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }
// inline int mul(int a, int b) { return (a * 1LL * b) % MOD; }

int a[MAX];

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

    // freopen("in", "r", stdin); 
    // freopen("out", "w", stdout);
    
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    sort(a + 1, a + n + 1, greater <int> ());
    ll ans = a[1];
    int baki = n - 2;
    for(int i=2;baki>=1;i++) {
        ans += a[i];
        baki--;
        if(baki >= 1) {
            ans += a[i];
            baki--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.14159265358979323846;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int a, b, c, d, e;

signed main() {
    cin >> a >> b >> c >> d >> e;
    int ans = 0;
    ans += (a - 1) / 10 + 1;
    ans += (b - 1) / 10 + 1;
    ans += (c - 1) / 10 + 1;
    ans += (d - 1) / 10 + 1;
    ans += (e - 1) / 10 + 1;
    int hasuu = min({(a - 1) % 10, (b - 1) % 10, (c - 1) % 10, (d - 1) % 10, (e - 1) % 10}) + 1;
    cout << (ans - 1) * 10 + hasuu << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> R[N];
  bool A[N];
  int ans[N] = {0};
  ans[0] = 0;
  for (int i = 0; i < N; i++) {
    A[i] = false;
  }
  A[0] = true;
  vector<int> T[N];
  T[0].push_back(0);
  for (int i = 0; i < M; i++) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    R[a].push_back(b);
    R[b].push_back(a);
  }
  int res = 0;
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < (int)(T[i-1].size()); j++) {
      for (int k = 0; k < (int)(R[T[i-1][j]].size()); k++) {
        if (!A[R[T[i-1][j]][k]]) {
          T[i].push_back(R[T[i-1][j]][k]);
          A[R[T[i-1][j]][k]] = true;
          ans[R[T[i-1][j]][k]] = T[i-1][j];
          res++;
        }
      }
    }
  }
  if (res != N - 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
      cout << ans[i] + 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 14896
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		String N=sc.nextLine();
		String ans="";
		char t[]=N.toCharArray();
		int T[]=new int[t.length];
		for(int i=0;i<t.length;i++){
			T[i]=Character.getNumericValue(t[i]);
		}		
		for(int i=0;i<t.length;i++){
			switch(T[i]){
			case 1:
				T[i]=9;
				break;
			case 9:
				T[i]=1;
				break;
			}
		}
		System.out.println(T[0]*100+T[1]*10+T[2]);
	}

}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

int main() {
	int n;
	cin >> n;
	vi v(n);
	rep(i, n) {
		cin >> v[i];
	}
	sort(all(v));
	int count = 0;
	rep(i, n - 1) {
		if (v[i] == v[i + 1])count++;
	}
	count = (count + 1) / 2 * 2;
	cout << (n - count) << endl;
}

Measured memory_bytes: 640
#include<cstdio>
int main(void) {
	int n, p, k;
	bool v;
	int a[100];
	while (true) {
		scanf("%d %d", &n, &p);
		if (n == 0 && p == 0)return 0;
		for (int i = 0; i < n;i++) a[i] = 0;
		k = p;
		v = false;
		while (true) {
			for (int i = 0; i < n;i++) {
				if (k == 0) {
					k = a[i];
					a[i] = 0;
				}
				else {
					k--;
					a[i]++;
					if (a[i] == p) {
						printf("%d\n", i);
						v = true;
						break;
					}
				}
			}
			if (v)break;
		}

	}
	return 0;
}


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

int main()
{
	string s;
	cin >> s;
	int u = s.back() - '0';
	switch (u)
	{
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			cout << "hon" << endl;
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			cout << "pon" << endl;
			break;
		case 3:
			cout << "bon" << endl;
			break;
		default:
			break;
	}
}

Measured memory_bytes: 3620
A,B,C=map(int,input().split())

li=[A,B,C]

max_num=max(li)
max_num2=min(li)

for i in li:
    if max_num!=i and max_num2<i:
        max_num2=i
        
num1=int(str(max_num)+str(max_num2))
li.remove(max_num)
li.remove(max_num2)

print(int(num1)+li[0])

Measured memory_bytes: 3064
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
tmp=10**9
for i in range(n):
        air=t-h[i]*0.006
        diff=abs(a-air)
        if diff<tmp:
                tmp=diff
                idx=i+1
print(idx)

Measured memory_bytes: 3060
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    h = tuple(map(int, input().split()))

    ans, bef, cnt = 0, 0, 0

    for i in h:
        if i <= bef:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
        bef = i
    print(max(ans, cnt))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14352
using System;
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine((a[2] - a[1]) % 2 == 0 ? "Alice" : "Borys");
        }
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

const int N = (int) 1e5;
map<int, int> num[N];
int cnt[N];

int tryPairing(const map<int, int> &num) {
    int res = 0;
    for (auto x : num) res += x.second / 2;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int m; cin >> m;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        ++num[x % m][x];
        ++cnt[x % m];
    }
    int res = 0;
    for (int i = 0; i < m; ++i) {
        int oldres = res;
        int j = (m - i) % m;
        if (i > j) continue;
        if (i == j) {
            res += cnt[i] / 2;
        } else {
            int ni = tryPairing(num[i]);
            int nj = tryPairing(num[j]);
            int lefti = cnt[i] - 2 * ni;
            int leftj = cnt[j] - 2 * nj;
            int best = ni + nj + min(lefti, leftj);
            for (int cross = 1; cross <= min(cnt[i], cnt[j]); ++cross) {
                if (lefti < cross) {
                    lefti += 2;
                    ni -= 1;
                }
                if (leftj < cross) {
                    leftj += 2;
                    nj -= 1;
                }
                best = max(best, ni + nj + cross);
            }
            res += best;
        }
        //cout << i << ' ' << j << ' ' << res - oldres << endl;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

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

typedef long long LL;
typedef pair<int, int> Pii;

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int n;
  scanf("%d", &n);
  int ret = 0;
  For(i,1,n) if (to_string(i).length() % 2) ++ret;
  printf("%d\n", ret);

  return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;

  vector<ll> t(n+1);
  vector<pll> p(n+1);
  t[0] = 0;
  p[0] = make_pair(0, 0);
  REP1(i, n+1)
    cin >> t[i] >> p[i].FI >> p[i].SE;
  
  REP1(i, n+1){
    ll timediff = t[i] - t[i-1];
    ll pdiff = abs(p[i].FI - p[i-1].FI) + abs(p[i].SE - p[i-1].SE);
    if(timediff >= pdiff && timediff % 2 == pdiff % 2)
     ;
    else{
     cout << "No" << endl; 
     return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a>b){
      rep(i,a){
        cout << b;
      }
      cout << endl;
      return 0;
    }
    if(a<b){
      rep(i,b){
        cout << a;
      }
      cout << endl;
      return 0;
    }
    if(a==b){
      rep(i,a){
        cout << b;
      }
      cout << endl;
      return 0;
    }
}

Measured memory_bytes: 256
N = int(input())
Sn = [ ''.join(sorted(input())) for _ in range(N)]
Sn_key = {}
for s in Sn:
    if s not in Sn_key:
        Sn_key[s] = 1
    else:
        Sn_key[s] += 1
cnt = 0

for v in Sn_key.values():
    if v >= 2:
        cnt += v * (v-1) // 2
print(cnt)

Measured memory_bytes: 66776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    str t; cin >> t;
    int ans = 0;
    rep(i, t.size()){
        if(t[i] != '?') cout << t[i];
        else cout << 'D';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>

using namespace std;
int abs(int a)
{
    if(a>0) return a;
    else    return 0-a;
}
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int flag=0;
    if((abs(b-a)<d||abs(b-a)==d)&&(abs(c-b)<d||abs(c-b)==d))
    {
        cout<<"Yes"<<endl;
        flag=1;
    }
    else if((abs(c-a)<d||abs(c-a)==d)&&flag==0)  cout<<"Yes"<<endl;
    else cout<<"No"<<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);
		final int N = sc.nextInt();
		int a[] = new int[2];
		a[0] = 4;
		a[1] = 7;
		if(dfs(0, N, a)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	public static boolean dfs(int sum, int N, int a[]) {
		if(sum >= N) return sum == N;
		if(dfs(sum + a[0], N, a)) return true;
		if(dfs(sum + a[1], N, a)) return true;
		return false;
	}
}


Measured memory_bytes: 25044
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0000&lang=jp

QQ
"""

if __name__ == '__main__':
    # ???????????????
    for i in range(1, 10):
        for j in range(1, 10):
            print('{0}x{1}={2}'.format(i, j, i*j))

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

int main(){
    string s;
    cin >> s;
    bool a[30];
    for(int i = 0; i < 30; i++)
    {
        a[i] = true;
    }
    
    for(int i = 0; i < (int)s.size(); i++)
    {
        int n = s[i] - 'a';
        a[n] = false;
    }
    for(int i = 0; i < 26; i++)
    {
        if(a[i]){
            cout << (char)(i+'a') << endl;
            return 0;
        }
    }
    
    cout << "None" << endl;
    
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define N 210
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
int n;
char C[N];

int mem[N][N][N],used[N][N][N];
int dfs(int idx,int num,int num2){
  if(num < 0 || num2 < 0) return 0;
  if(idx == n) return (idx-num == 0) * (num2 == 0);
  if(used[idx][num][num2]++) return mem[idx][num][num2];
  int res = 0; 
  if(C[idx] == 'U'){
    res = dfs(idx+1,num,num2+1);
    res += num2 * dfs(idx+1,num+1,num2);
  }
  if(C[idx] == 'D'){
    if(idx - num > 0 )res = (idx - num) * num2 * dfs(idx+1,num+2,num2-1);
    res += (idx - num) * dfs(idx+1,num+1,num2);
  }
  return mem[idx][num][num2] = res %mod;
}

signed main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>C[i];
    if(C[i] == '-')n--,i--;
  }
  cout<<dfs(0,0,0)<<endl;
  return 0;
}

Measured memory_bytes: 37916
#include<cstdio>
#include<cstdlib>
#include<vector>


using namespace std;
using vi=vector<int>;


int gcd(int a, int b)
{
	int c;

	while((c=a%b))
	{
		a=b;
		b=c;
	}
	return b;
}


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		vi a(n);
		int t=0, a_max=0;

		for(int i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
			if(i==0)
			{
				t=a_max=a[0];
			}
			t=gcd(t, a[i]);
			a_max=max(a_max, a[i]);
		}
		int ans=1;
		if(k%t) ans=0;
		if(a_max<k) ans=0;
		printf("%s\n", ans?"POSSIBLE":"IMPOSSIBLE");
	}

	return 0;
}


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

int main() {
    int a[3][3];
    int l;
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> l;
            a[i][j] = l;
        }
    }

    int n;
    cin >> n;
    int b;
    for (int i=0; i<n; i++) {
        cin >> b;
        for (int i=0; i<3; i++) {
            for (int j=0; j<3; j++) {
                if (a[i][j] == b) {
                    a[i][j] = 0;
                }
            }
        }
    }

    string ans = "No";
    for (int i=0; i<3; i++) {
        if (a[i][0] + a[i][1] + a[i][2] == 0) {
            ans = "Yes";
            break;
        } else if (a[0][i] + a[1][i] + a[2][i] == 0) {
            ans = "Yes";
            break;
        } else if (a[0][0] + a[1][1] + a[2][2] == 0) {
            ans = "Yes";
            break;
        } else if (a[0][2] + a[1][1] + a[2][0] == 0) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

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

using ll = long long;
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	
    if((b-1) % (a-1) == 0) {
    	cout << (b-1)/(a-1) << endl;
    } else {
    	cout << (b-1)/(a-1)+1 << endl;
    }
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    rep(i, 0, N - 2) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], C = ip[2];
	if(C <= A + B) writeln(B + C);
	else writeln(A + 2*B + 1);	
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, q) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!
    val acs = IntArray(n){0}

    val regex = "AC".toRegex()
    regex.findAll(s).forEach { res ->
        acs[res.range.first+1] = 1
    }

    for (i in 1 until n) {
        acs[i] += acs[i-1]
    }

    repeat(q) {
        val (l, r) = readLine()!!.split(" ").map { it.toInt() }
        println(acs[r-1]-acs[l-1])
    }
}

Measured memory_bytes: 67536
n = int(input())
d = list(map(int,input().split()))
db = [0] * (max(d)+1)
MOD = 998244353

#距離iの頂点の数をdb[i]に保存
for i in range(n):
    db[d[i]] += 1

if (d[0] != 0)|(db[0] != 1):
    print(0)
    exit()

ans = 1

for i in range(len(db)-1):
    ans *= db[i]**db[i+1]%MOD

print(ans%MOD)


Measured memory_bytes: 14396