akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int c = 0, m = 0;
		long[] a = new long[n];
		a[0] = sc.nextLong();
		for(int i = 1; i < n; i++) {
			a[i] = sc.nextLong();
			if(a[i-1] >= a[i]) {
				c++;
			}else {
				if(c > m) m = c;
				c = 0;
			}
		}
		if(c>m) m = c;
		System.out.println(m);
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 46916
def sieve(n):
    a = [1] * (n + 1)
    for i in range(2, n):
        if i * i > n: break
        if a[i]:
            for j in range(2 * i, n + 1, i):
                a[j] = 0
    return a[2:]

while True:
    try:
        n = int(raw_input())
        print len(filter(lambda x: x, sieve(n)))
    except (EOFError):
        break

Measured memory_bytes: 63020
#include<bits/stdc++.h>
using namespace std;
int n,m,x;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x;
		n-=x;
	}
	if(n>=0){
		cout<<n;
	}
	else{
		cout<<-1;
	}
	return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>

int main(void){
	long long int a,b,c,d,max;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	max= a*c > b*d ? a*c : b*d ;
	max= a*d > max ? a*d : max ;
	max= b*c > max ? b*c : max ;
	printf("%lld",max);
	return 0;
}

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

int R;

int main () {
	cin >> R;
	if (R < 1200) {
		cout << "ABC" << endl;
	} else if (R >= 1200 && R < 2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
#define watch(x) cout << (#x)<<" = "<<x<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	file();
	fast();
	string a, b; cin >> a >> b;
	int cnt = 0;
	for (int i = 0; i < sz(a); i++) {
		if (a[i] != b[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3784
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int frontNum = scanner.nextInt();
			int sideNum = scanner.nextInt();
			if (frontNum == 0) {
				scanner.close();
				break;
			}

			// 優先度つきキュー（小さい方から出てくる
			PriorityQueue<Integer> front = new PriorityQueue<Integer>();
			PriorityQueue<Integer> side = new PriorityQueue<Integer>();

			for (int i = 0; i < frontNum; i++) {
				front.add(scanner.nextInt());
			}

			for (int i = 0; i < sideNum; i++) {
				side.add(scanner.nextInt());
			}

			int ans = 0;
			while (!front.isEmpty() || !side.isEmpty()) {
				if (front.peek() == side.peek()) {
					// 両方のキューの先頭が一緒なら両方出す
					ans += front.poll();
					side.poll();
				} else if (side.isEmpty()
						|| (!front.isEmpty() && front.peek() < side.peek())) {
					// どちらかが空か、小さい数字が残っていたらそれを出す
					ans += front.poll();
				} else if (front.isEmpty() || front.peek() > side.peek()) {
					ans += side.poll();
				}
			}

			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	int ans = 0;
	map<int, int> mp;
	rep(i,N){
		int a;
		cin >> a;
		ans += a;
		mp[a]++;
	}
	int Q;
	cin >> Q;
	rep(i,Q){
		int a, b;
		cin >> a >> b;
		int z = mp[a];
		ans += (b-a)*z;
		mp[b] += mp[a];
		mp[a] = 0;
		cout << ans << endl;
	}
}

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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = head[b]; a; a = edge[a].nxt)

inline int rd () {
	int x = 0; char IO = getchar();
	bool f = 0;
	while ((IO < '0' || IO > '9') && IO != '-') IO = getchar();
	if (IO == '-') f = 1, IO = getchar();
	while (IO >= '0' && IO <= '9') x = (x << 3) + (x << 1) + (IO ^ 48), IO = getchar();
	return f ? -x : x;
}

int a, b;

int main () {
   cin >> a >> b;

   cout << (a + b - 3) / (a - 1) << endl;
	return 0;
}


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

using namespace std;

int main(){
    int N, K, ans = 0;
    cin >> N >> K;
    for (int i = 0; i < N; ++i){
        int h;
        cin >>h;
        if(K <= h ) ans += 1; 
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int mod=1e9+7;
typedef  long long ll;
ll ppow(ll b,ll a){
    ll ans=1;
    ll base=b;
    while(a){
        if(a%2==1){
            ans=ans*base;
            ans=ans%mod;
        }
        base=base*base;
        base=base%mod;
        a=a/2;
    }
    return ans%mod;

}
int main(){
    ll a;
    cin>>a;
    cout<<(ppow(10,a)-2*ppow(9,a)+ppow(8,a)+2*mod)%mod<<endl;
    system("pause");

}

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

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i) a[i] += a[i - 1];
  }
  ll ans = 0, base = 0, ans1 = 0, base1 = 0;
  for (int i = 0; i < n; ++i) {
    if (i & 1) {
      if ((a[i] + base) * -1 <= 0) {
        ans += a[i] + base + 1;
        base -= a[i] + base + 1;
      }
    } else {
      if ((a[i] + base) * -1 >= 0) {
        ans += -a[i] - base + 1;
        base += -a[i] - base + 1;
      }
    }

    if (!(i & 1)) {
      if ((a[i] + base1) * -1 <= 0) {
        ans1 += a[i] + base1 + 1;
        base1 -= a[i] + base1 + 1;
      }
    } else {
      if ((a[i] + base1) * -1 >= 0) {
        ans1 += -a[i] - base1 + 1;
        base1 += -a[i] - base1 + 1;
      }
    }
  }
  cout << min(ans, ans1) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<math.h>

using namespace std;




int main()
{
    int N;
    long long int ll[100];

    ll[0] = 2;
    ll[1] = 1;

    cin >> N;

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

    cout << ll[N] << "\n" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scan(&S)
	diff1 := make([]int, len(S))
	diff2 := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if i%2 == 0 {
			diff1[i] = 0
			diff2[i] = 1
		} else {
			diff1[i] = 1
			diff2[i] = 0
		}
	}
	diff1_diff := 0
	diff2_diff := 0
	for i := 0; i < len(S); i++ {
		tmp, _ := strconv.Atoi(string(S[i]))
		if diff1[i] != tmp {
			diff1_diff++
		}
		if diff2[i] != tmp {
			diff2_diff++
		}
	}
	if diff1_diff > diff2_diff {
		fmt.Println(diff2_diff)
	} else {
		fmt.Println(diff1_diff)
	}
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, t;
    cin >> n >> t;
    int ans = INF<int>;
    for (int i = 0; i < n; ++i) {
        int c, x;
        cin >> c >> x;
        if(x <= t){
            ans = min(ans, c);
        }
    }
    if(ans == INF<int>){
        cout << "TLE\n";
    }else {
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c;
    do{
    scanf("%d %d %d",&a,&b,&c);
    }while((a<1||a>9)||(b<1||b>9)||(c<1||c>9));
    if((a==b)&&(a==c)&&(c==b)){
      printf("No");
    }
    else if((a!=b)&&(b!=c)&&(c!=a)){
      printf("No");
    }
    else{
      printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 128
cn = gets.to_i
ary = gets.chomp.split.map(&:to_i).sort

ary.unshift 0  if cn.odd?
add = cn.odd? ? 0 : 1
ary.each_slice(2).with_index do |item, idx|
  unless item[0] == item[1] && item[0] == (idx * 2 + add) then
    puts 0
    exit
  end
end
puts 2 ** (cn / 2) % 1000000007


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int n, m, x;
vector<int> c;
vector<vector<int>> a;

ll total(vector<bool> &aa) {
//  rep(i, aa.size()) {
//    cout << (aa.at(i) ? "true" : "false") << " ";
//  }
//  cout << endl;
  ll res = 0;
  vector<int> sum(m, 0);
  rep(i, n) {
    if (!aa.at(i)) {
      continue;
    }
    vector<int> aaa = a.at(i);
    rep(j, m) {
      sum.at(j) += aaa.at(j);
    }
    res += c.at(i);
  }
  // どれかが x に満たないケース
  rep(i, m) {
    if (sum.at(i) < x) {
      return INT_MAX;
    }
  }
//  cout << "total: " << res << endl;
  return res;
}

ll dfs(vector<bool> &aa) {
  if (aa.size() == n) {
    return total(aa);
  }
  ll res = INT_MAX;
  aa.push_back(true);
  res = min(res, dfs(aa));
  aa.pop_back();

  aa.push_back(false);
  res = min(res, dfs(aa));
  aa.pop_back();
  return res;
}

int main() {
  cin >> n >> m >> x;
  c.resize(n);
  a.resize(n);

  vector<int> sum(m, 0);
  rep(i, n) {
    int cc;
    cin >> cc;
    c.at(i) = cc;
    vector<int> aa(m);
    rep(j, m) {
      int aaa;
      cin >> aaa;
      aa.at(j) = aaa;
      sum.at(j) += aaa;
    }
    a.at(i) = aa;
  }
  // どれかが x に満たないケース
  rep(i, m) {
    if (sum.at(i) < x) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<bool> aa;
  ll res = dfs(aa);
  cout << res << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)3e2+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        
        vpll a(n);
        for(i=0;i<n;i++){
                cin>>a[i].ss>>a[i].ff;
        }
        
        sort(all(a));
        ll sum=0;
        for(i=0;i<n;i++){
                sum+=a[i].ss;
                if(sum>a[i].ff){
                        cout<<"No\n";
                        return;
                }
        }
        cout<<"Yes\n";
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[110];
int main() {
    ll ans=INT_MAX;
    int n;
    cin>>n;
    int maxn=0;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        maxn=max(maxn,a[i]);
    }
    for(int i=1;i<=maxn;i++) {
        ll s=0;
        for(int j=0;j<n;j++) {
            if(i==a[j]) continue;
            int x=abs(i-a[j]);
            s+=x*x;
        }
        ans=min(s,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long long sum=0,m=1000000000;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        long long a;
        cin >> a;
        if(a<0)
        {
            a=-a;
            cnt++;
        }
        sum+=a;
        m=min(m,a);
    }
    if(cnt&1) cout << sum-2*m << endl;
    else cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
n,x=map(int,raw_input().split())
l=map(int,raw_input().split())
ans=chk=0
for i in range(1,n):
    chk=(l[i-1]+l[i])-x
    if chk>0:
        if l[i]>=chk:
            l[i]-=chk
        else:
            l[i-1]-=chk-l[i]
            l[i]=0
        ans+=chk
print ans

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

typedef long long ll;

#define all(x) x.begin(), x.end()
#define sz(x) (ll) x.size()
#define deb(x) cout << (#x) << " is " << (x) << "\n";
#define debv(v) for (auto usb: v) cout << usb << " "; cout << "\n";

// n == (1 || 0) ???? memory?


void solve(){
	ll n,x,t;
	cin >> n >> x >> t;
	ll cnt = 0LL, ans = 0LL;
	
	while(cnt < n){
		cnt += x;
		ans += t;
	}
	cout << ans << "\n";
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.precision(20);	
	solve();
	return 0;
}


Measured memory_bytes: 3644
$<.readlines.map {|l| l.split(",").map(&:to_r)}.each do |given|
  f = (given + given.first(4)).each_slice(2).each_cons(3).map do |a, b, c|
    (c[0] - a[0]) * (b[1] - a[1]) - (c[1] - a[1]) * (b[0] - a[0]) > 0
  end
  puts((f.all? or f.none?) ? "YES" : "NO")
end


Measured memory_bytes: 6924
//package cp;
import java.util.*;
import java.io.*;
public class Main {
	long gcd(long a,long b) {if(b==0)return a;else return gcd(b,a%b);}
	void swap(long a,long b) {long temp=a;a=b;b=temp;}
	StringBuilder sb=new StringBuilder();
	Integer[] ARR=new Integer[5];
	//Integer sort-TLE-Initialize object elements i.e a[0].
	long ceil(int n) {return (long)Math.ceil(1.0*n/2);}
	void divisor(long n,int start) {
		int cnt=0;for(int i=start;i<=Math.sqrt(n);i++) {
		if(n%i==0) {if(i==n/i)cnt++;else cnt+=2;}}}
	
	public static void main(String[] args) throws IOException {	
		PrintWriter out = new PrintWriter(System.out);
		Readers.init(System.in);
		Main obj=new Main();
		int x=Readers.nextInt();
		if(x<=599)System.out.println(8);
		else if(x<=799)System.out.println(7);
		else if(x<=999)System.out.println(6);
		else if(x<=1199)System.out.println(5);
		else if(x<=1399)System.out.println(4);
		else if(x<=1599)System.out.println(3);
		else if(x<=1799)System.out.println(2);
		else if(x<=1999)System.out.println(1);
		out.flush();
	}

}
class Readers {
 
    static BufferedReader reader;
 
    static StringTokenizer tokenizer;
 
 
 
    /** call this method to initialize reader for InputStream */
 
    static void init(InputStream input) {
 
        reader = new BufferedReader(
 
                     new InputStreamReader(input) );
 
        tokenizer = new StringTokenizer("");
 
    }
 
 
 
    /** get next word */
 
    static String next() throws IOException {
 
        while ( ! tokenizer.hasMoreTokens() ) {
 
            //TODO add check for eof if necessary
 
            tokenizer = new StringTokenizer(
 
                   reader.readLine() );
 
        }
 
        return tokenizer.nextToken();
 
    }
 
 
 
    static int nextInt() throws IOException {
 
        return Integer.parseInt( next() );
 
    }
 
	
 
    static double nextDouble() throws IOException {
 
        return Double.parseDouble( next() );
 
    }
    
    
    static long nextLong() throws IOException{
    	
		return Long.parseLong(next());
	}
 
}


Measured memory_bytes: 32852
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
bool compare_by_b(pair<int, string> a, pair<int, string> b) {
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return 0;
	}
}
bool compare_by_a(pair<int, string> a, pair<int, string> b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}
	else {
		return 0;
	}
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, k;
	cin >> a >> b >> k;
	cout << max(a - k, 0LL) << " " <<  max(b+min(a-k,0LL),0LL) << endl;
}





Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

const int SIZE = 1 << 18;
struct segtree {
    int node[2*SIZE];
    segtree() {
        memset(node, 0, sizeof(node));
    }
    void init() {
        memset(node, 0, sizeof(node));
    }
    void update(int x, int val) {
        x += SIZE - 1;
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }
    int query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        int vl = query(a, b, l, mid, 2*k+1);
        int vr = query(a, b, mid, r, 2*k+2);
        return vl + vr;
    }
};

segtree seg;
long long int solve(string lhs, string rhs) {
    seg.init();
    long long int ret = 0;
    vector<int> idx_array(rhs.size()), iter(26), appear[26];
    for(size_t i=0; i<rhs.size(); i++) {
        appear[ rhs[i] - 'a' ].push_back(i);
    }
    for(size_t i=0; i<lhs.size(); i++) {
        int c = lhs[i] - 'a';
        idx_array[ appear[c][iter[c]++] ] = i;
    }

    int len = rhs.size();
    for(int i=len-1; i>=0; i--) {
        int idx = idx_array[i];
        ret += seg.query(0, idx);
        seg.update(idx, 1);
    }
    return ret;
}

int main() {
    string s; cin >> s;

    vector<int> cnt(26), tmp(26);
    for(size_t i=0; i<s.length(); i++) {
        cnt[ s[i] - 'a' ]++;
    }

    int odd = 0;
    for(int i=0; i<26; i++) {
        odd += (cnt[i] % 2);
    }
    if(odd > 1) {
        cout << -1 << endl;
        return 0;
    }

    long long int ans = 0;
    string left = "", mid = "", right = "";
    for(size_t i=0; i<s.length(); i++) {
        int c = s[i] - 'a';
        if(2 * tmp[c] + 1 < cnt[c]) {
            left += s[i];
        }
        if(2 * tmp[c] + 1 > cnt[c]) {
            right += s[i];
        }
        if(2 * tmp[c] + 1 == cnt[c]) {
            mid += s[i];
        }
        tmp[c]++;
    }

    ans += solve(left+mid+right, s);
    reverse(left.begin(), left.end());
    ans += solve(left, right);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> B(M);
	for (int i = 0; i < M; i++) cin >> B[i];

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < M; j++) {
			int A;
			cin >> A;
			sum += A * B[j];
		}
		sum += C;
		if (sum > 0) cnt++;
	}

	cout << cnt << endl;
}

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

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

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

fastio _fast_io;

int n, m;

int main() {
    cin >> n >> m;
    m /= 1000;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j + i <= n; ++j) {
            int k = n - i - j;
            int t = 10 * i + 5 * j + k;
            if (t == m) {
                cout << i << ' ' << j << ' ' << k << endl;
                exit(0);
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

using namespace std;

#define For(i , j , k) for (register int i = (j) , i##_end_ = (k) ; i <= i##_end_ ; ++ i)
#define Fordown(i , j , k) for (register int i = (j) , i##_end_ = (k) ; i >= i##_end_ ; -- i)
#define Set(a , b) memset(a , b , sizeof(a))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define Mod (1000000007)
typedef long long LL;

template <typename T> inline bool chkmax(T &a , T b) { return a < b ? (a = b , 1) : 0; }
template <typename T> inline bool chkmin(T &a , T b) { return b < a ? (a = b , 1) : 0; }

int _ , __;
char c_;
inline int read()
{
	for (_ = 0 , __ = 1 , c_ = getchar() ; !isdigit(c_) ; c_ = getchar()) if (c_ == '-') __ = -1;
	for ( ; isdigit(c_) ; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
	return _ * __;
}

inline void File()
{
#ifdef hany01
	freopen("tree_game.in" , "r" , stdin);
	freopen("tree_game.out" , "w" , stdout);
#endif
}

const int maxn = 3010;

int n, a[maxn], v[maxn << 1], nex[maxn << 1], beg[maxn], dp[maxn], e;

inline void add(int uu, int vv) { v[++ e] = vv; nex[e] = beg[uu]; beg[uu] = e; }

inline void Init()
{
	int uu, vv;
	n = read();
	For(i, 1, n) a[i] = read();
	For(i, 2, n) uu = read(), vv = read(), add(uu, vv), add(vv, uu);
}

void dfs1(int u, int fa)
{
	for (int i = beg[u] ; i ; i = nex[i])
	{
		if (fa == v[i]) continue;
		dfs1(v[i], u);
		if (!dp[v[i]] && a[u] > a[v[i]]) dp[u] = 1;
	}
}

void dfs2(int u, int fa)
{
	if (u != 1 && !dp[fa] && a[u] > a[fa]) dp[u] = 1;
	for (int i = beg[u] ; i ; i = nex[i]) if (v[i] != fa) dfs2(v[i], u);
}

int main()
{
	File();
	Init();
	dfs1(1, 0);
	dfs2(1, 0);
	For(i, 1, n) if (dp[i]) printf("%d ", i);
	return 0;
}

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

int main()
{
    int H, N;
    cin >> H >> N;
    int64_t sum = 0;
    for (int i = 0; i < N; i++)
    {
        int A_i;
        cin >> A_i;
        sum += A_i;
    }
    if (sum >= H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    
    if(a+b==c)
    	System.out.println("Yes");
    else if(a+c==b)
    	System.out.println("Yes");
    else if(c+b==a)
    	System.out.println("Yes");
    else
    	System.out.println("No");

	}
}


Measured memory_bytes: 21844
n,a,b,c=map(int,input().split())
l=[0]*n
for i in range(n):
    l[i]=int(input())

inf=10**9

def dfs(cur,aa,bb,cc):
    if cur==n:
        if min(aa,bb,cc)>0:
            return abs(a-aa)+abs(b-bb)+abs(c-cc)-30
        else:
            return inf
    ret0=dfs(cur+1,aa,bb,cc)
    ret1=dfs(cur+1,aa+l[cur],bb,cc)+10
    ret2=dfs(cur+1,aa,bb+l[cur],cc)+10
    ret3=dfs(cur+1,aa,bb,cc+l[cur])+10
#    print(cur,l[cur],aa,bb,cc,ret0,ret1,ret2,ret3)
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0)) 
    

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

struct Edge {
    ll to, cost;
    Edge(ll t, ll c) : to(t), cost(c) {}
};
struct Elem {
    ll dist, speed, cur;
    Elem(ll a, ll b, ll c) : dist(a), speed(b), cur(c) {}
};
bool operator>(const Elem& a, const Elem& b) {
    return a.dist != b.dist ? a.dist > b.dist : a.speed > b.speed;
}

typedef vector< vector<Edge> > Graph;
ll const INF = 1LL << 60;

int main() {
    ll dist[510][60][2];
    ll ans = INF;
    for(int i=0; i<510; i++)
        for(int j=0; j<60; j++)
            for(int k=0; k<2; k++)
                dist[i][j][k] = INF;

    int n, m; cin >> n >> m;
    Graph G(n);
    for(int i=0; i<m; i++) {
        ll a, b, t; cin >> a >> b >> t;
        a--; b--;
        G[a].push_back(Edge(b,t));
        G[b].push_back(Edge(a,t));
    }
    ll v, a, b, c;
    cin >> v >> a >> b >> c;
    priority_queue< Elem, vector<Elem>, greater<Elem> > q;

    ll cur = 0, speed = v;
    dist[0][v][0] = 0;
    q.push(Elem(0, speed, cur));
    while(!q.empty()) {
        Elem temp = q.top(); q.pop();
        cur = temp.cur, speed = temp.speed;
        ll nsp = (a * speed + b) % c;
        for(size_t i=0; i<G[cur].size(); i++) {
            Edge e = G[cur][i];
            ll d1 = dist[cur][speed][0] + e.cost * speed;
            ll d2 = dist[cur][speed][1] + e.cost * speed;
            // home to university
            if(dist[e.to][nsp][0] > d1) {
                dist[e.to][nsp][0] = d1;
                if(e.to == n-1) dist[e.to][nsp][1] = dist[e.to][nsp][0];
                q.push(Elem(d1, nsp, e.to));
            }
            // university to home
            if(dist[e.to][nsp][1] > d2) {
                dist[e.to][nsp][1] = d2;
                q.push(Elem(d2, nsp, e.to));
            }
        }
    }

    for(int i=0; i<c; i++) ans = min(ans, dist[0][i][1]);
    cout << ans << endl;
}

Measured memory_bytes: 9692
#include <iostream>
#include <cmath>

using namespace std;

int main(void){
  double A, B;
  cin >> A >> B;

  for(double i=0; i<=1000; i++){
    if(floor(i*0.08) == A)
      if(floor(i*0.1) == B){
	cout << i << endl;
	return 0;
      }
  }
  
  cout << -1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
long long counting(long long N) {
	int dp[11][10] = {{0}}, ok[11];	
	vector<int> digits;
	while(N > 0) {
		digits.push_back(N % 10);
		N /= 10;
	}
	reverse(digits.begin(), digits.end());
	ok[0] = 1;
	for(int k = 1; k < digits.size(); ++k) {
		if(abs(digits[k] - digits[k - 1]) <= 1)
			ok[k] = ok[k - 1];
		else
			ok[k] = 0;
	}
	for(int i = 1; i <= digits[0]; ++i)
		dp[0][i] = 1;
	for(int k = 1; k < digits.size(); ++k) {
		int d = digits[k];
		for(int i = 0; i <= d; ++i) {
			dp[k][i] += dp[k - 1][i];
			if(i) 
				dp[k][i] += dp[k - 1][i - 1];
			if(i < 9) 
				dp[k][i] += dp[k - 1][i + 1];
		}
		for(int i = d + 1; i <= 9; ++i) {
			dp[k][i] += dp[k - 1][i];
			if(i == digits[k - 1] && ok[k - 1])
				--dp[k][i]; 
			if(i) {
				dp[k][i] += dp[k - 1][i - 1];
				if(i - 1 == digits[k - 1] && ok[k - 1])
					--dp[k][i]; 
			}
			if(i < 9) {	
				dp[k][i] += dp[k - 1][i + 1];
				if(i + 1 == digits[k - 1] && ok[k - 1])
					--dp[k][i]; 
			}
		}
	}
	int tot = 0;
	for(int i = 0; i <= 9; ++i) 
		tot += dp[(int)digits.size() - 1][i];
	for(int n = (int)digits.size() - 1; n > 0; --n) {
		for(int k = 0; k < n; ++k)
			for(int i = 0; i <= 9; ++i)
				dp[k][i] = 0;
		for(int i = 1; i <= 9; ++i)
			dp[0][i] = 1;
		for(int k = 1; k < n; ++k) {
			for(int i = 0; i <= 9; ++i) {
				dp[k][i] += dp[k - 1][i];
				if(i) dp[k][i] += dp[k - 1][i - 1];
				if(i < 9) dp[k][i] += dp[k - 1][i + 1];
			}
		}
		for(int i = 0; i <= 9; ++i)
			tot += dp[n - 1][i];
	}
	return tot;
}
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int K;
	long long low = 1, high = 1e10;
	cin >> K;
	while(low < high) {
		long long mid = (low + high) / 2;
		if(counting(mid) >= K) high = mid;
		else low = mid + 1;
	}
	cout << high << '\n';
	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *
def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1/f

def solve():
    a, v = getList()
    b, w = getList()
    t = getN()
    if w >= v:
        print("NO")
    else:
        if abs(a - b) <= t * (v - w):
            print("YES")
        else:
            print("NO")

def main():
    # n = getN()
    # for _ in range(n):
    solve()
if __name__ == "__main__":
    solve()


Measured memory_bytes: 72504
#include<iostream>

using namespace std;

int main(void){
  int x[5] = {};
  
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
  
  for(int i = 0; i < 5; i++){
	if(x[i] == 0)cout << i + 1;
  }
}

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

#define ll long long

void swap(int *a, int *b) {
	int c;
	c = *a;
	*a = *b;
	*b = c;
}

int main() {
	int x, y, z;

	cin >> x >> y >> z;
	swap(&x, &y);
	swap(&x, &z);

	cout << x << ' ' <<  y << ' ' << z;
	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
struct data{
	ll v;
	int n;
}b[510001];
ll ans,s[510001];
int i,j,k,n,m,a[510001],c[510001],p[510001];
bool cmp(data x,data y){
	return x.v<y.v;
}
void change(int x,int v){
	for (;x<=n+1;x+=x&(-x)) c[x]+=v;
}
int query(int x){
	int res=0;
	for (;x;x-=x&(-x)) res+=c[x];
	return res;
}
int main(){
	scanf("%d%d",&n,&m);memset(c,0,sizeof(c));
	for (i=1,s[0]=0;i<=n;i++) scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	for (i=0;i<=n;i++) b[i+1].n=i,b[i+1].v=s[i]-(ll)m*(ll)i;
	sort(b+1,b+2+n,cmp);
	for (i=1,k=0;i<=n+1;i++){
		if (i==1||b[i-1].v!=b[i].v) k++;
		p[b[i].n]=k;
	}
	for (ans=i=0;i<=n;i++){
		ans+=query(p[i]);
		change(p[i],1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

    ll n;
    cin>>n;
    string s[n];
    ll ar[n];
    for(ll i=0;i<n;++i)
    {
        cin>>s[i]>>ar[i];
    }
    string x;
    cin>>x;
    ll ans=0;
    int f=0;
    for(ll i=0;i<n;++i)
    {
        if(f){
            ans+=ar[i];
        }
        if(s[i]==x){f=1;}
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 256
import sys
import copy

N, M, L = list(map(int, sys.stdin.readline().strip().split(" ")))
INF = 10**10

def warshall_floyd(g_mat):
    dp = copy.copy(g_mat)
    
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])
    return dp

graph = [[INF for _ in range(N)] for _ in range(N)]

for _ in range(M):
    a, b, c = list(map(int, sys.stdin.readline().strip().split(" ")))
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

dist_graph = warshall_floyd(graph)
bool_graph = [[INF for _ in range(N)] for _ in range(N)]

for i in range(N):
    for j in range(N):
        if dist_graph[i][j] <= L:
            bool_graph[i][j] = 1

ans_graph = warshall_floyd(bool_graph)

Q = int(sys.stdin.readline().strip())
for _ in range(Q):
    s, t = list(map(int, sys.stdin.readline().strip().split(" ")))
    ans = ans_graph[s-1][t-1]
    print(ans-1 if ans != INF else -1)

    


Measured memory_bytes: 57308
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vp ans;
    for (int i = 1; i <= n; ++i) {
        for (int j = i+1; j <= n; ++j) {
            if (n % 2 == 0) {
                if (i + j == n + 1) continue;
            } else {
                if (i + j == n) continue;
            }
            ans.eb(i, j);
        }
    }
    int m = sz(ans);
    cout << m << endl;
    rep(i, m) cout << ans[i].fi << " " << ans[i].se << endl;
}

Measured memory_bytes: 3724
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	string str; cin >> str;

	int ans = INTINF;
	rep(i, 26){
		char target = 'a' + i;
		int res = 0;
		int cnt = 0;
		string t = str;
		t.push_back(target);
		rep(j, t.size()){
			if(t[j] == target){
				chmax(res, cnt);
				cnt = 0;
			}
			else{
				cnt++;
			}
		}
		// print( res);
		chmin(ans, res);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    string A, B, C; cin >> A >> B >> C;
    cout << ((A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let w: usize = input();
    let wv: Vec<(usize, usize)> = (0..n).map(|_| (input(), input())).collect();

    let mx: usize = wv.iter().map(|&(_, v)| v).sum();
    let mut v = vec![vec![usize::max_value(); mx + 1]; n + 1];
    for i in 1..n + 1 {
        let (wi, vi) = wv[i - 1];
        v[i][vi] = wi;
        for j in 0..mx + 1 {
            if v[i - 1][j] < usize::max_value() {
                v[i][j] = std::cmp::min(v[i][j], v[i - 1][j]);
                v[i][j + vi] = std::cmp::min(v[i][j + vi], v[i - 1][j] + wi);
            }
        }
    }

    for j in (0..mx + 1).rev() {
        if v[n][j] <= w {
            println!("{}", j);
            break;
        }
    }
}


Measured memory_bytes: 106748
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

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

typedef long long ll;

int main()
{
    string s;
    cin>>s;
    
    ll n=s.length();
    
    for(int i=1;i<n;i++)
    {
        if(s[i]=='?' && s[i-1]=='P')
        s[i]='D';
    }
    for(int i=0;i<n-1;i++)
    {
        if(s[i]=='?' && s[i+1]=='?')
        {
            s[i]='P';
            s[i+1]='D';
        }
        else if(s[i]=='?' && s[i+1]=='D')
        s[i]='P';
    }
    for(int i=0;i<n;i++)
    {
        if(s[i]=='?')
        s[i]='D';
    }
    
    cout<<s;
    

    return 0;
}


Measured memory_bytes: 3752
main();

sub main{
	my $length = <STDIN>;
	my @data;
	my $tmp = <STDIN>;
	@data = split(/ /, $tmp);

	my $re   = 0;	
	my $cnt  = 0;
	my $flag = 0;

	while(1){
		foreach my $n (0..$length){	
			$re = $data[$n]%2;
			if($re == 0){
				$data[$n] = int($data[$n]/2);
				# printf "%f\n", $data[$n]; 
			}
			else{
				$flag = 1;
				last;
			}
		}
		if($flag == 1){last}		
		$cnt++;
	}
	
	print "$cnt\n"
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

main(){
  int n;
  while(cin>>n,n){
    vector<int> app[n];
    string name[n];
    map<int,int> po;
    rep(i,n){
      int m;
      cin>>name[i]>>m;
      rep(j,m){
        int d;
        cin>>d;
        app[i].pb(d);
        po[d]++;
      }
               
    }
    vector<pair<int,string> > ch;

    rep(i,n){
      int tp=0;
      FOR(it,app[i])tp+=n+1-po[*it];
      ch.pb(mp(tp,name[i]));
    }
    pair<int,string> ans=*min_element(ALL(ch));
    cout<<ans.F<<' '<<ans.S<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    string S;
    cin >> S;

    int64_t s_ = S.size();
    while (true) {
        S.erase(s_-1);
        s_ = S.size();
        bool is_guumozi = true;
        if (s_ % 2 != 0) {
            continue;
        }

        for (int i=0; i<s_/2; i++) {
            if (S[i] != S[s_/2+i]) {
                is_guumozi = false;
                break;
            }
        }

        if (is_guumozi) {
            break;
        }
    }

    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
  	long long int N;
  	cin >> N;
  	long long int A[N];
  	for (int i = 0; i < N; i++) cin >> A[i];
  
  	for (int i = 0; i < N; i++) A[i] -= i + 1;
  
  	sort(A, A + N);
  	long long int a = A[N / 2], b = 0;
	
  	for (int i = 0; i < N; i++) b += abs(a - A[i]);
  
  	cout << b << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
  int d;
  string s="Christmas";
  cin >> d;
  if(d<25){
    s+=" Eve";
    if(d<24){
      s+=" Eve";
      if(d<23){
        s+=" Eve";
      }
    }
  }
  cout << s << endl;
}


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

using namespace std;
const int N = 1e5 + 5;

int n, w, h;
struct edge { int u, v, w; } e[N];
int fa[N << 1];
bool ring[N << 1];

int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}

signed main() {
    ios::sync_with_stdio(false);
    cin >> n >> h >> w;
    for (int i = 1; i <= w + h; i++)
        fa[i] = i, ring[i] = false;
    for (int i = 1; i <= n; i++)
        cin >> e[i].u >> e[i].v >> e[i].w;
    
    sort(e + 1, e + 1 + n, [](const edge& x, const edge& y) {
        return x.w > y.w;
    });

    long long ans = 0ll;
    for (int i = 1; i <= n; i++) {
        int u = e[i].u, v = e[i].v + h, w = e[i].w;
        u = find(u), v = find(v);

        if (u == v) {
            if (!ring[u]) ring[u] = 1, ans += w;
        } else {
            if (!ring[u] || !ring[v]) {
                ring[u] = ring[v] = ring[u] | ring[v];
                fa[u] = v, ans += w;
            }
        }
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6356
#include<iostream>
#include<stack>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    long long n;
    cin >> n;
    stack<char>st;
    if(n <= 26){
        char a = 'a' + n - 1;
        cout << a << endl;
        return 0;
    }else{
        rep(i,10000){
            long long a;
            a = n % 26;
            if(a == 0) st.push('z');
            else st.push('a' + a - 1);
            n /= 26;
            if(n % 26 == 0 && n > 26 && st.top() != 'z'){
                rep(i,1000){
                    st.push('z');
                    n /= 26;
                    if(n == 1) break;
                    if(n == 1) break;
                    long long m = n - 1;
                    if(m % 26 == 0) continue;
                    else break;
                }
                if(n == 1) break;
            }
            if(st.top() == 'z') n -= 1;
            if(n == 0) break;
        }
    }
    while(!st.empty()){
        cout << st.top();
        st.pop();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << ((A+D-1)/D>=(C+B-1)/B?"Yes":"No") << endl;
    
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.nextLine();

    int result = Integer.MAX_VALUE;
    for(int i = 0; i < n; i++) {
      int val = sc.nextInt();
      if(val % 2 > 0) {
        result = 0;
        break;
      }
      
      int times = 0;
      while(val % 2 == 0) {
        times++;
        val /= 2;
      }
      result = (times < result) ? times : result;
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 21972
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
int n,m,q,a[100005],b[100005],x,y,c,ans,mina=INT_MAX,minb=INT_MAX;
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m>>q;
	for(int i=1;i<=n;i++) cin>>a[i],mina=min(mina,a[i]);
	for(int i=1;i<=m;i++) cin>>b[i],minb=min(minb,b[i]);
	ans=mina+minb;
	while(q--){
		cin>>x>>y>>c;
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024