akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int getGCD(int a, int b, int c){
    int temp = __gcd(a, b);
    return __gcd(temp, c);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k, i, j, l, sum = 0;
    cin >> k;
    for(i=1; i<=k; i++){
        for(j=1; j<=k; j++){
            for(l=1; l<=k; l++){
                sum += getGCD(i, j, l);
            }
        }
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    string ans;
    
    for(int i = 0;i < n;i++){
        cin >> S.at(i);
        sort(S.at(i).begin(),S.at(i).end());
    }
    
    map<char,int> al,bl;

    vector<char> alpha;

    alpha ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};


    for(int i = 0;i < 26;i++){
        al[alpha[i]] = 0;
        bl[alpha[i]] = 0;
    }

    int i = 0;

    int Ssize;

    while(i < n){
        if(i == 0){
            Ssize = S.at(i).size();
            for(int j = 0;j < Ssize;j++){
                al[S.at(i).at(j)]++;
            }
        }
        else{
            Ssize = S.at(i).size();
            for(int j = 0;j < Ssize;j++){
                bl[S.at(i).at(j)]++;
            }
            for(int j = 0;j < 26;j++){
                if(al[alpha[j]] >= bl[alpha[j]])
                    al[alpha[j]] = bl[alpha[j]];
                
                bl[alpha[j]] = 0;
            }
        }
        i++;

    }

    for(int j = 0;j < 26;j++){
        if(al[alpha[j]] > 0){
            for(int k = 0;k < al[alpha[j]];k++){
                cout << alpha[j];
            }
        }
    }

    cout << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

ll N,K;
vector<int> A;
bool check(ll x){
    vector<int> D(N);
    for(int i=0; i<N; i++){
        D[i] = A[i]%x;
    }
    sort(D.begin(),D.end());
    vector<ll> S(N+1,0);
    for(int i=0; i<N; i++){
        S[i+1] = S[i] + D[i];
    }
    for(int i=0; i<N; i++){
        ll pre = S[i];
        ll suf = ll(N-i)*x - (S[N]-S[i]);
        if(max(pre,suf) <= K) return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> K;
    A.resize(N);
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum += A[i];
    }
    int ans = 0;
    for(int i=1; i*i<=sum; i++){
        if(sum%i == 0){
            if(check(i)) chmax(ans,i);
            if(check(sum/i)) chmax(ans,sum/i);
        }
    }
    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

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

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n;
    ll ans=n;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0) ans= i;
    }
    ans= max(ans,n/ans);
    // cout << ans << endl;
    ll cnt= 1;
    while(ans/=10){
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
ll n,K[14][10],A[1000];
ll M[13];

void mkK(vector<int>zero,int idx){
  int cnt[10][7]={};
  cnt[0][0]=cnt[0][1]=cnt[0][2]=cnt[0][4]=cnt[0][5]=cnt[0][6]=1;
  cnt[1][2]=cnt[1][5]=1;
  cnt[2][0]=cnt[2][2]=cnt[2][3]=cnt[2][4]=cnt[2][6]=1;
  cnt[3][0]=cnt[3][2]=cnt[3][3]=cnt[3][5]=cnt[3][6]=1;
  cnt[4][1]=cnt[4][2]=cnt[4][3]=cnt[4][5]=1;
  cnt[5][0]=cnt[5][1]=cnt[5][3]=cnt[5][5]=cnt[5][6]=1;
  cnt[6][0]=cnt[6][1]=cnt[6][3]=cnt[6][4]=cnt[6][5]=cnt[6][6]=1;
  cnt[7][0]=cnt[7][2]=cnt[7][5]=1;
  cnt[8][0]=cnt[8][1]=cnt[8][2]=cnt[8][3]=cnt[8][4]=cnt[8][5]=cnt[8][6]=1;
  cnt[9][0]=cnt[9][1]=cnt[9][2]=cnt[9][3]=cnt[9][5]=cnt[9][6]=1;

  for(int i=0;i<10;i++)
    for(int j=0;j<=6;j++) cnt[i][j]*=zero[j];
  
  for(int i=0;i<10;i++)
    for(int j=0;j<=6;j++)K[idx][i]+=cnt[i][j];
}


int count(int num,int idx,int t){
  vector<int> B(t,0);
  while(num) B[--t]=num%10,num/=10;

  int res=0;  
  for(int i=0;i<(int)B.size();i++)res+=K[idx+i][B[i]];
  return res;
}

void mkA(){
  for(int i=0;i<24;i++)//h
    for(int j=0;j<60;j++)//m
      for(int k=0;k<60;k++)//s
	A[count(i,8,2)+count(j,10,2)+count(k,12,2)]++;
}

void mkM(){
  M[1] = M[3] = M[5] =M[7] =M[8] = M[10] = M[12] = 31;
  M[4] = M[6] = M[9] =M[11] = 30;
  M[2] = 28;
}

int uru(int n,int k){
  if(k!=2) return 0;
  if(n%400==0) return 1;
  if(n%100==0) return 0;
  if(n%4==0) return 1;
  return 0;
}


ll solve(){
  ll res=0;
  for(int i=0;i<10000;i++) //y
    for(int j=1;j<=12;j++) //m
      for(int k=1;k<=M[j]+uru(i,j);k++){//d
	ll sum=count(i,0,4)+count(j,4,2)+count(k,6,2);
	if(n-sum>=0)res+=A[n-sum];
      }
  return res;
}


main(){
  int m;
  cin>>n>>m;
  vector<int>A[14];
  for(int i=0;i<14;i++) A[i].resize(10,1);
  for(int i=0,id,pos;i<m;i++)cin>>id>>pos,A[id][pos] = 0;
  for(int i=0;i<14;i++) mkK(A[i],i);
  mkA();
  mkM();
  cout<<solve()<<endl;
  
}

Measured memory_bytes: 3160
def main():

    s=list(input())
    t=list(input())
    flg=True
    for i in range(len(s)):
        if s[i]!=t[i]:
            flg=False

    if flg==True and (len(s)+1)==len(t):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

using namespace std;

int main(void) {
    int N;
    float x, res = 0;
    string u;
    
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> x >> u;
        if (u == "JPY") res += x;
        else if (u == "BTC") res += x * 380000.0;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ls1 = []
ls2 = []
for i in range(N):
  ls1.append(list(map(int,input().split())))
for i in range(M):
  ls2.append(list(map(int,input().split())))
for i in range(N):
  minimum = 10**18
  check = 0
  for j in range(M):
    K = abs(ls1[i][0]-ls2[j][0])+abs(ls1[i][1]-ls2[j][1])
    if K < minimum:
      minimum = K
      check = j
  print(check+1)

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

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

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if (s[0] != 'A') {
        cout << "WA" << endl;
    } else {
        int c = 0, fg = 0, cPos = -1;
        for (int i = 1; i < s.length(); i++) {
            if (s[i] == 'C') {
                c++;
                cPos = i;
            } else if (s[i] >= 'A' && s[i] <= 'Z') {
                fg = 1;
            }
        }
        if (fg || c != 1 || cPos < 2 || cPos > s.length() - 2) {
            cout << "WA" << endl;
        } else {
            cout << "AC" << endl;
        }
    }

}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        double[] readDoubleArray(int n){double[] a=new double[n];for (int i=0; i<n; i++) a[i]=nextDouble();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static int getGcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static boolean isPrime(int n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        //System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        PrintWriter pw = new PrintWriter(System.out,true);
        int n=s.nextInt();
        long num,ans;
        if(getGcd(n,10)>1) System.out.println("-1");
        else{
            num=7%n;ans=1;
            while(num!=0){
                num*=10;
                num+=7;
                num%=n;
                ans++;
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 25932
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b = LI()

    return 1 / (1 / a + 1 / b)




print(main())



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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{	
	int n; cin >> n;
	vector<int> a(n);
	vector<bool> was(n, false);
	forn(i, n) cin >> a[i];
	int i = 0, cnt = 0;
	while (true)
	{
		cnt++;
		if (a[i] == 2)
		{
			cout << cnt;
			return;
		}
		if (was[i])
		{
			cout << -1 << endl;
			return;
		}
		else
		{
			was[i] = true;
			i = a[i] - 1;
		}
	}
}

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


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

#define ll long long int
#define li int64_t

int main()
{
	li a,b,c,d;
	cin>>a>>b>>c>>d;
	li prod[4];
	prod[0] = a*c;
	prod[1] = a*d;
	prod[2] = b*c;
	prod[3] = b*d;
	li max = prod[0];
	for(int i=0;i<4;i++)
	{
		if(prod[i]>max)max = prod[i];
	}
	cout<<max;
}

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

#define endl '\n'
#define fr first
#define sc second

using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;
const int NMAX = 1e5 + 1, INF = 1e9;
ll LINF = 1e18;
const double EPS = 1e-8;

vector<ii> g[NMAX];
ll d[NMAX];

main()
{
//    freopen("input.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v, c;
        scanf("%d%d%d", &u, &v, &c);
        --u, --v;
        g[u].push_back({v, c});
        g[v].push_back({u, c});
    }
    int q, k;
    fill(d, d + n, LINF);
    scanf("%d%d", &q, &k);
    --k;
    set<pair<ll, int>> kek;
    kek.insert({0, k});
    d[k] = 0;
    while (!kek.empty()) {
        int v = kek.begin()->sc;
        kek.erase(kek.begin());
        for (auto p : g[v]) {
            int to = p.fr;
            ll len = p.sc;
            if (d[v] + len < d[to]) {
                kek.erase({d[to], to});
                kek.insert({d[v] + len, to});
                d[to] = d[v] + len;
            }
        }
    }
    for (int i = 0; i < q; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u, --v;
        printf("%lld\n", d[u] + d[v]);
    }
}


Measured memory_bytes: 14580
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


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


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


    sort(a, a + n);
    double ans = (a[0] + a[1]) / 2;
    for (int i = 2; i < n; i++) {
        ans = (ans + a[i]) / 2;
    }

    cout << ans;




}



Measured memory_bytes: 256
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

a,b = read_int()

def solve(a,b):
    ans = 0
    ans += max(a,b)
    if ans == a:
        a -= 1
    else:
        b -= 1
    ans += max(a,b)
    return ans

if __name__ == "__main__":
    print(solve(a,b))


Measured memory_bytes: 3952
#include <ctype.h>
#include <stdio.h>

#define MAX_CH 11

int
main(void)
{
	char s1[MAX_CH], s2[MAX_CH], s3[MAX_CH];
	scanf("%s %s %s", s1, s2, s3);

	char f = toupper(s1[0]);
	char s = toupper(s2[0]);
	char t = toupper(s3[0]);

	printf("%c%c%c\n", f, s, t);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int n;
long long a[100010],inv[100010],pre[100010],ans,fac[100010];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	scanf("%lld",&a[i]);
	inv[1]=1;
	for(int i=2;i<=n;++i)
	inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=n;++i)
	pre[i]=(pre[i-1]+inv[i])%mod;
	for(int i=1;i<=n;++i)
	ans=(ans+pre[n-i+1]*a[i]%mod+(pre[i]-1)*a[i]%mod)%mod;
	fac[0]=1;
	for(int i=1;i<=n;++i)
	fac[i]=fac[i-1]*i%mod;
	ans=(ans*fac[n])%mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;

set<char> st={'a','e','i','o','u'};

// ll mod=1e9 +7;
ll mod=  998244353;

const int M=200006;
int f[M],inv[M];
int expo(int base,int exponent,int mod){
    int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(int i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
int C(int n,int r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

ll n,i;
ll dp[503][503];

vector<ll>a(503);
ll caldp(ll l,ll r)
{
    if(l+1==r)
    {
         dp[l][r]=a[l];
    }
    if(dp[l][r]!=0)
    return dp[l][r];
    
    dp[l][r]=-1;
    for(ll mid=l+1;mid<r;mid++)
    {
        ll lpart=caldp(l,mid);
        ll rpart=caldp(mid,r);
        if(lpart>0 && lpart==rpart)
         dp[l][r]=lpart+1;
    }
    return dp[l][r];
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //compute();
    
    ll tests=1;
   // cin>>tests;
    while(tests--)
    {
        int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k;
        cin>>k;
        cout<<a[k-1];
       
    }
    
    return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout
input = stdin.readline
print = stdout.write
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] += a[i - 1]
for i in range(1, m + 1):
    b[i] += b[i - 1]
i, j, z = 0, m, 0
while i <= n and a[i] <= k:
    while b[j] > k - a[i]:
        j -= 1
    z = max(z, i + j)
    i += 1
print(str(z))

Measured memory_bytes: 40912
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{

	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		Vector2 beginPoint = new Vector2(decimal.Parse(input[0]), decimal.Parse(input[1]));
    Vector2 endPoint = new Vector2(decimal.Parse(input[2]), decimal.Parse(input[3]));
		long q = long.Parse(Console.ReadLine());

    for(long i = 0; i < q; i++)
    {
      string[] inputSub = Console.ReadLine().Split(' ');
      Vector2 QuestionPoint = 
        new Vector2(decimal.Parse(inputSub[0]), decimal.Parse(inputSub[1]));
      Vector2.WhereVector(beginPoint, endPoint, QuestionPoint);
    }
	}
}

class Vector2//2次元ベクトル
{
static decimal verySmallDecimal = 1e-10m;//小数比較

  public Vector2 (decimal X, decimal Y)
  {
    this.x = X;
    this.y = Y;
  }

  public decimal x {private set; get;}
  public decimal y {private set; get;}

  public static Vector2 operator + (Vector2 ob1, Vector2 ob2)//ベクトルの基本演算
  {
    return new Vector2 (ob1.x + ob2.x, ob1.y + ob2.y);
  }
  public static Vector2 operator - (Vector2 ob1, Vector2 ob2)
  {
    return new Vector2 (ob1.x - ob2.x, ob1.y - ob2.y);
  }
  public static Vector2 operator * (Vector2 ob, decimal scalar)
  {
    return new Vector2 (ob.x * scalar, ob.y * scalar);
  }
  public static Vector2 operator * (decimal scalar, Vector2 ob)
  {
    return new Vector2 (ob.x * scalar, ob.y * scalar);
  }

  public decimal Length()//ベクトルの長さ
  {
    return x * x + y * y;
  }
  public static decimal DotProduct(Vector2 ob1, Vector2 ob2)//内積
  {
    return ob1.x * ob2.x + ob1.y * ob2.y;
  }
  public static decimal CrossProduct(Vector2 ob1, Vector2 ob2)//内積
  {
    return ob1.x * ob2.y - ob1.y * ob2.x;
  }

  public static Vector2 Projection(Vector2 beginPoint, Vector2 endPoint, Vector2 point)//点の射影
  {
    Vector2 segment = endPoint - beginPoint;
    decimal ratio = Vector2.DotProduct(point - beginPoint, segment) / segment.Length();
    return beginPoint + segment * ratio;//始点にたす
  }

  public static void WhereVector(Vector2 beginPoint, Vector2 endPoint, Vector2 point)
  {
    Vector2 segment = endPoint - beginPoint;
    Vector2 aimVec = point - beginPoint;
    if(Vector2.CrossProduct(segment, aimVec) > verySmallDecimal)
      Console.WriteLine("COUNTER_CLOCKWISE");
    else if(Vector2.CrossProduct(segment, aimVec) < -verySmallDecimal)
      Console.WriteLine("CLOCKWISE");
    else if(Vector2.DotProduct(segment, aimVec) < -1+verySmallDecimal)
      Console.WriteLine("ONLINE_BACK");
    else if(segment.Length() < aimVec.Length())
      Console.WriteLine("ONLINE_FRONT");
    else
      Console.WriteLine("ON_SEGMENT");
  }
  
}



Measured memory_bytes: 16024
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        M: usize,
    }
    let mut ans = 1_usize;
    let modulo = 1_000_000_007;
    if N==M{
        for i in 0..N{
            ans *= i+1;
            ans %= modulo;
            ans *= i+1;
            ans %= modulo;
        }
        ans *= 2;
        ans %= modulo;
    }else{
        let maxMN = max(M,N);
        let minMN = min(M,N);
        if maxMN-minMN == 1{
            for i in 0..N{
                ans *= i+1;
                ans %= modulo;
            }
            for i in 0..M{
                ans *= i+1;
                ans %= modulo;
            }
        }else{
            ans = 0;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;


public class Main {


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

		Map<String, Integer> dict = new HashMap<String, Integer>();

		String line = br.readLine();
		String[] words = line.split("\\s");
		for (int i = 0 ; i < words.length ; i++) {
			if (!dict.containsKey(words[i])) {
				dict.put(words[i], 1);
			} else {
				dict.put(words[i], dict.get(words[i])+1);
			}
		}


		String longest = "";
		String max_word = "";
		long max = 0;
		for (String key : dict.keySet()) {
			if (key.length() > longest.length()) longest = new String(key);
			if (max < dict.get(key)) {
				max = dict.get(key);
				max_word = new String(key);
			}
		}
		System.out.println(max_word+" "+longest);

	}
}

Measured memory_bytes: 16912
#include<cstdio>
#define MAX 10000000
int main(){
        int n,tmp,max,min;
        long long sum=0;
        max=-MAX;
        min=MAX;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
                scanf("%d",&tmp);
                sum+=tmp;
                max=max>=tmp?max:tmp;
                min=min<=tmp?min:tmp;
        }
        printf("%d %d %lld\n",min,max,sum);
        return 0;
}

Measured memory_bytes: 2732
N, B = map(int, input().split())
R = N-B
MOD = 10**9+7

paskal3 = [[1]]
for i in range(1, N+5):
    l = [1]
    for j in range(1, i):
        l.append((paskal3[i-1][j-1]+paskal3[i-1][j]) % MOD)
    l.append(1)
    paskal3.append(l)


def comb(n, r):
    try:
        return paskal3[n][r]
    except:
        return 0


for i in range(1, B+1):
    print((comb(R+1, i) * comb(B-1, i-1)) % MOD)


Measured memory_bytes: 83988
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> as = new ArrayList<>();
    
    for(int i = 0; i < N; i++) {
        as.add(sc.nextInt());
    }
    List<Integer> as2 = new ArrayList<>(new HashSet<>(as));
    System.out.println(as2.size());
  }
}


Measured memory_bytes: 21588
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        HashSet<String> dictionary = new HashSet<String>();

        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            String command = scanner.next();
            if (command.equals("insert")) {
                String word = scanner.next();
                dictionary.add(word);
            } else if (command.equals("find")) {
                String word = scanner.next();
                System.out.println(dictionary.contains(word) ? "yes" : "no");
            }
        }
        scanner.close();
    }
}



Measured memory_bytes: 217124
loop_count = int(input())

ac_count = 0
wa_count = 0
tle_count = 0
re_count = 0

for i in range(loop_count):
    result = input()
    if result == 'AC':
        ac_count += 1
    elif result == 'WA':
        wa_count += 1
    elif result == 'TLE':
        tle_count += 1
    else:
        re_count += 1

print("AC x {0}".format(str(ac_count)))
print("WA x {0}".format(str(wa_count)))
print("TLE x {0}".format(str(tle_count)))
print("RE x {0}".format(str(re_count)))




Measured memory_bytes: 9152
#include<iostream>

using namespace std;

int main(void)
{
	int n,k;
	cin >> n >> k;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin >> a;
		ans+=min(a,abs(a-k));
	}
	cout << ans*2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int comp(const void* a,const void* b){
  int x=*((int *)a),y=*((int *)b);
  return x-y;
}

int main(){
  int n;
  scanf("%d",&n);
  int p[n],q[n],i,  ans=0;
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
    q[i]=p[i];
  }
  qsort(q,n,sizeof(int),comp);

  for(i=0;i<n;i++){
    if(p[i]-q[i])ans++;
  }

  printf("%s",ans<=2?"YES":"NO");
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    multiset<int>st;
    int n;
    cin >> n;
    f(1<<n) {
        int x;
        cin >> x;
        st.insert(x);
    }
    queue<int>q;
    q.push(*st.rbegin());
    st.erase(--st.end());
    //cout << "GG" << endl;
    while (q.size()) {
        int now = q.front();
        q.pop();
        if (st.size() && *st.begin() >= now) {
            cout << "No\n";
            exit(0);
        }
        if (!st.size()) continue;
        int x = *prev(st.lower_bound(now));
        //cout << x << endl;
        st.erase(st.find(x));
        q.push(now);
        q.push(x);
    }
    cout << "Yes\n";
}


Measured memory_bytes: 13184
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define emb emplace_back

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

ostream &operator << (ostream &cout, vector <int> &a) {
	cout << "{";
	for (auto & it : a) cout << it << ", ";
	cout << "}";
	return cout;
}

ostream &operator << (ostream &cout, set <int> &a) {
	cout << "{";
	for (auto & it : a) cout << it << ", ";
	cout << "}";
	return cout;
}

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 18;
int n, q, a[1 << N];

multiset <int> dp[1 << N];

int mx[1 << N];

main() {
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	cin >> n;
	for(int i = 0; i < (1 << n); ++i) {
		cin >> a[i];
		dp[i].insert(a[i]);
	}
	for(int i = 0; i < n; ++i) {
		for(int mask = 0; mask < (1 << n); ++mask) {
			if(1 << i & mask)
				continue;
			for(int j : dp[mask])
				dp[1 << i | mask].insert(j);
			while(dp[1 << i | mask].size() > 2)
				dp[1 << i | mask].erase(dp[1 << i | mask].begin());
		}
	}
	for(int i = 0; i < (1 << n); ++i) {
		if(dp[i].size() == 2)
			mx[i] = *dp[i].begin() + *dp[i].rbegin();
		if(i)
			Max(mx[i], mx[i-1]);
	}
	for(int i = 1; i < (1 << n); ++i)
		cout << mx[i] << endl;
	return 0;
}

Measured memory_bytes: 41984
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9+5


int main(){
    int n;
    cin>>n;
    vector<int>s(n+1,0);
    vector<int>b(n+1,0);
    vector<int>h(n+1,0);
    
    for(int i=1;i<=n;i++){
        cin>>s[i]>>b[i]>>h[i];
    }
    int works = 3;
    
    vector<vector<int>> dp(n+1,vector<int>(works,0));
    
    int swim =0,bug=1,hw =2;
    
    for(int i=1;i<=n;i++){
        dp[i][swim] = s[i] + max(dp[i-1][bug],dp[i-1][hw]);
        dp[i][bug]  = b[i] + max(dp[i-1][swim],dp[i-1][hw]);
        dp[i][hw]   = h[i] + max(dp[i-1][swim],dp[i-1][bug]);
    }
    int ans = max(dp[n][swim],max(dp[n][bug],dp[n][hw]));
   cout<<ans<<endl;
   
   
}

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

class D {
    static ulong Hash(int a1, int a2) {
        return (ulong)a1 * 0x9ddfea08eb382d69 + (ulong)a2;
    }

    public static void Main() {
        var line = Console.ReadLine().Split();
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var n = int.Parse(line[2]);
        var blocks = new Dictionary<ulong, int>();
        for (int i = 0; i < n; ++i) {
            line = Console.ReadLine().Split();
            var x1 = int.Parse(line[0]) - 1;
            var x2 = int.Parse(line[1]) - 1;
            for (int j1 = x1 - 2; j1 <= x1; ++j1)
                if (0 <= j1 && j1 + 2 < h)
                    for (int j2 = x2 - 2; j2 <= x2; ++j2)
                        if (0 <= j2 && j2 + 2 < w) {
                            var hash = Hash(j1, j2);
                            var v = 0;
                            blocks.TryGetValue(hash, out v);
                            blocks[hash] = v + 1;
                        }
        }
        var answer = new long[10];
        foreach (var i in blocks) ++answer[i.Value];
        answer[0] = (long)(h - 2) * (w - 2) - answer.Sum();
        for (int i = 0; i < answer.Length; ++i) Console.WriteLine(answer[i]);
    }
}


Measured memory_bytes: 56896
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
using int_t = long long int;
const int_t LARGE = 2e5;
char buf[LARGE * 10 + 1];
int_t prefix[2][LARGE + 1];
int main() {
    int n;
    cin >> n;
    scanf("%s", buf + 1);
    for (int_t i = 1; i <= n; i++) {
        prefix[0][i] = prefix[0][i - 1];
        prefix[1][i] = prefix[1][i - 1];

        if (buf[i] == '.')
            prefix[0][i]++;
        else
            prefix[1][i]++;
    }
    int_t result = 0x7ffffffff;
    for (int_t i = 0; i <= n; i++) {
        result =
            std::min(prefix[1][i] + prefix[0][n] - prefix[0][i], result);
        // cout << "at " << i << " = "
        //      << prefix[1][i] + prefix[0][n] - prefix[0][i - 1] << endl;
        // cout << prefix[1][i] << " " << prefix[0][n] - prefix[0][i - 1] << endl;
    }
    cout << result << endl;
    return 0;
}

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

using namespace std;

int main(){
  int a,b,c,d=0;
  cin >> a >> b >> c;
  if(a>=b){
    if(a>=c){
      d = (a*10) + b + c;
    }
    else{
      d = (c*10) + a + b;
    }
  }
  else if(b>=c){
    d = (b*10) + a + c;
  }
  else{
    d = (c*10) + a + b;
  }
  cout << d << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define F first
#define S second

int ar[200005];
int32_t main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	sort(ar+1,ar+n+1);
	int ans=0;
	for(int i=1;i<=n-k;i++){
		ans += ar[i];
	}
	cout<<ans;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main() {
    ll ans=0;
    ll n;
    cin >> n;
    for(int i=0;i<pow(4,10);i++){
        ll x=0,t=1;
        ll k=i,n3=0,n5=0,n7=0;
        while(k>0){
            if(k%4==1){
                x+=3*t;
                n3++;
            }
            if(k%4==2){
                x+=5*t;
                n5++;
            }
            if(k%4==3){
                x+=7*t;
                n7++;
            }
            if(k%4==0){
                k=-1;
                break;
            }
            k/=4;
            t*=10;
        }
        if(k==-1) continue;
        if(n3>0 && n5>0 && n7>0 && x<=n){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(void){
  char c[10];
  for(int i=0;i<10;i++)c[i]=0;
  int m,l,r;
  bool b;
  l=0;
  scanf("%d",&r);
  printf("0\n",m);
    fflush(stdout);
    scanf("%s",c);
    if(c[0]=='V')return 0;
    else if(c[0]=='M')b=true;
    else b=false;
  while(true){
    m=(l+r)/2;
    printf("%d\n",m);
    fflush(stdout);
    scanf("%s",c);
    if(c[0]=='V')return 0;
    else if(c[0]=='M'){
      if(b){
        if(m%2==0)l=(m+1);
        else r=m;
      }
      else{
           if(m%2==1)l=(m+1);
        else r=m;     
      }
    }
    else{
            if(!b){
        if(m%2==0)l=(m+1);
        else r=m;
      }
      else{
           if(m%2==1)l=(m+1);
        else r=m;     
      }
    }
  }
  return 0;
}
  
  

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
vector<int> as;
int cnt[114514];
set<int> ls[114514];

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin >> N;
  rep(i, N) {
    int a;
    cin >> a;
    --a;
    as.eb(a);
    cnt[a]++;
  }

  if (N == 2) {
    cout << "-1\n";
    return 0;
  }

  set<int> cand;
  rep(i, N) {
    cand.insert(i);
    ls[cnt[i]].insert(i);
  }

  vector<int> ans;
  auto Del = [&](int idx) {
    ans.eb(idx);
    cand.erase(idx);
    assert(ls[cnt[idx]].count(idx));
    ls[cnt[idx]].erase(idx);
    int a = as[idx];
    if (cand.count(a)) {
      assert(ls[cnt[a]].count(a));
      ls[cnt[a]].erase(a);
      cnt[a]--;
      assert(cnt[a] >= 0);
      ls[cnt[a]].insert(a);
    }
  };

  rep(i, N) {
    assert(cand.size()+i == N);
    int rem = N-1-i;
    if (!ls[rem].empty()) {
      int idx = *ls[rem].begin();
      Del(idx);
      continue;
    }

    int idx = *cand.begin();
    if (!ans.empty() && as[ans.back()] == idx) {
      assert(cand.size() > 1);
      auto itr = cand.begin();
      ++itr;
      idx = *itr;
    }
    Del(idx);
  }
  assert(cand.empty() && ans.size() == N);

  if (as[ans[N-2]] == ans[N-1]) {
    if (as[ans[N-4]] == ans[N-2]) {
      swap(ans[N-3], ans[N-1]);
      swap(ans[N-2], ans[N-1]);
    } else {
      swap(ans[N-3], ans[N-2]);
    }
  }

  rep(i, N) {
    if (i) cout << " ";
    cout << ans[i]+1;
  }cout << endl;
  rep(i, N-1) assert(ans[i+1] != as[ans[i]]);
}


Measured memory_bytes: 16376
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
  string N;
  int sum = 0;
  cin >> N;
  int n = (int)(N.length());

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

  if(sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3696
import math
 
a = list(map(int, input().split()))
a=a[0]

b=list(map(int, input().split()))

mini=999999999

for i in range(a-1):
    t=abs(sum(b[0:i+1])-sum(b[i+1:a]))
    if(t<mini):
        mini=t
        
print(mini)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

int main(){
    int A,B;
    char op;

    cin >> A >> op >> B;

    switch (op)
    {
    case '+':
        cout << A + B << endl;
        break;
    case '-':
        cout << A - B << endl;
        break;
    
    default:
        break;
    }
}

Measured memory_bytes: 256
N, x = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

if x == sum(A):
    print(N)
else:
    A.sort()
    ans = 0
    for a in A[:-1]:
        if x >= a:
            ans += 1
            x -= a
        else:
            break
    print(ans)


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  string s;
  cin>>s;
  for(auto& c:s)if(c=='?')c='D';
  cout<<s<<endl;

}

Measured memory_bytes: 3748
#include <cstdio>
#include <vector>
#include <cstddef>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

int main()
{
	while (true)
	{
		unsigned short N, A; size_t MAX = 15000;

		vector<char> D;

		scanf("%d", &N);

		if (N == 0) { break; }

		for (unsigned short i = 0; i < N; i++)
		{
			scanf("%d", &A);

			D.push_back(A);
		}

		for (unsigned short i = 0; i < N; i++)
		{
			for (char j = 1; j <= 3; j++)
			{
				if (D[i] != j)
				{
					vector<char> E(D.begin(), D.end());

					E[i] = j;

					for (unsigned short k = 0; k < E.size() - 3; k++)
					{

					loop:;

						if (E.size() <= 3)
						{
							break;
						}

						if (E[k] == E[k + 1] && E[k + 1] == E[k + 2] && E[k + 2] == E[k + 3])
						{
							for (char l = 0; l < 3; l++)
							{
								E.erase(E.begin() + k);
							}

							while (k < E.size() - 1 && E[k] == E[k + 1])
							{
								E.erase(E.begin() + k);
							}

							if (k < E.size())
							{
								E.erase(E.begin() + k);
							}

							k = 0;

							goto loop;
						}
					}

					MAX = min(E.size(), MAX);
				}
			}
		}

		printf("%d\n", MAX);
	}

	return 0;
}

// Time : O( 3n ^ 3 )

Measured memory_bytes: 2836
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	ll n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    vector<int> a(n+1);
    rep(i, n){
        int x;
        cin >> x;
        a[x] = i;
    }

    set<int> s;
    s.insert(-1);
    s.insert(n);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        s.insert(a[i]);
        auto it = s.find(a[i]);
        it++;
        int right = *it;
        it--;
        it--;
        int left = *it;
        ans += i * (right - a[i]) * (a[i] - left);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11768
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int s; cin >> s;
        set<int>dis;
        while(true){
            if(dis.count(s))break;
            dis.insert(s);
            if(s%2==1)s = 3*s + 1;
            else s/=2;
        }
        cout<<dis.size()+1<<endl;

return 0;
}




Measured memory_bytes: 256
def f1(a,b):
    if a%b==0:
        return a//b
    else:
        return a//b+1

n=int(input())
t=1
a=1
for i in range(n):
    ti,ai = map(int,input().split())
    k=max(f1(t,ti),f1(a,ai))
    t=ti*k
    a=ai*k
print(t+a)



Measured memory_bytes: 3064
# coding: utf-8
mylist=[]
for i in range(3) :
    line = input().split()
    mylist.append(int(line[0]))
    mylist.append(int(line[1]))
if mylist.count(1)<=2 and mylist.count(2)<=2 and mylist.count(3)<=2 and mylist.count(4)<=2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n;
    cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);
    vector<long long> c(n);
    for (long long i = 0; i < n; i++){
        cin >> a.at(i);
        cin >> b.at(i);
        cin >> c.at(i);
    }
    
    vector<long long> happya(n);
    vector<long long> happyb(n);
    vector<long long> happyc(n);
    
    happya.at(0) = a.at(0);
    happyb.at(0) = b.at(0);
    happyc.at(0) = c.at(0);
    
    for (long long i = 1; i < n; i++){
        happya.at(i) = max(happyb.at(i-1) + a.at(i), happyc.at(i-1) + a.at(i));
        happyb.at(i) = max(happya.at(i-1) + b.at(i), happyc.at(i-1) + b.at(i));
        happyc.at(i) = max(happyb.at(i-1) + c.at(i), happya.at(i-1) + c.at(i));
    }
    long long ans;
    ans = max(happya.at(n-1), max(happyb.at(n-1), happyc.at(n-1)));
    printf("%lld\n",ans);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> x(n);
	int sum = 0;
	rep(i, 0, n){
		cin >> x[i];
		sum += x[i];
	}
	sum = (sum + n / 2) / n;
	int ans = 0;
	rep(i, 0, n){
		ans += (x[i] - sum) * (x[i] - sum);
	}
	cout << ans << endl;
}

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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

using vqi=vector<queue<int>>;
using bs=bitset<60>;
using vbi=vector<bs>;
constexpr ll MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vi one(60), zero(60);

    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        bs ab(a);
        for (int j = 0; j < 60; j++) {
            if (ab[j] == 1) {
                one[j]++;
            } else {
                zero[j]++;
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < 60; i++) {
        ll tmp = (static_cast<ll>(pow(2, i)) % MOD);
        tmp %= MOD;
        tmp *= (one[i] % MOD);
        tmp %= MOD;
        tmp *= (zero[i] % MOD);
        tmp %= MOD;

        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892