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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;

  int res=0;
  for(int A=0; A <= a; A++){
    for(int B=0; B <= b; B++){
      for(int C=0; C <= c; C++){
        if( (500*A + 100*B + 50*C) == x )res++;
      }
    }
  }
  
  cout << res << endl;
}

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

int main() {
  int n,l;
  cin>>n>>l;
  int ans=0;
  int x=l;
  for(int i=1;i<=n;i++){
    ans+=l+i-1;
    if(abs(x)>abs(l+i-1)) x=l+i-1;
  }
  cout<<ans-x<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N, K;
int H[100001];

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

  cin >> N >> K;
  int cnt = 0;
  rep(i, N) cin >> H[i];

  rep(i, N){
    if (H[i]>=K) cnt++;
  }

  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    int i, n,t,w[109],a[109],s[109],s1,s2;
    scanf("%d",&n);
    memset(a,0,sizeof(a));
    memset(s,0,sizeof(s));
    a[0]=0;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&w[i]);
        a[i]=w[i]+a[i-1];
    }
    for(i=1;i<=n;i++)
    {
        s1=a[i];
        s2=a[n]-a[i];
        s[i]=abs(s1-s2);
    }
    sort(s,s+n);
    printf("%d\n",s[1]);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N);
    vvec<P> Q(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        for(int j=0;j<A[i];j++){
            int x,y;
            cin >> x >> y;
            x--;
            Q[i].emplace_back(x,y);
        }
    }
    int ans = 0;
    
    auto check = [&](int S){
        bool ok = true;
        for(int i=0;i<N;i++){
            if(S&(1<<i)){
                for(auto& x:Q[i]){
                    if(x.second && !(S&(1<<x.first))) ok = false;
                    if(!x.second && (S&(1<<x.first))) ok = false;
                }
            }
        }
        return ok;
    };

    for(int S=0;S<(1<<N);S++){
        if(check(S)) ans = max(ans,__builtin_popcount(S));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
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());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        String str = s.next();
        
        int n = str.length();
        if(str.charAt(n-1)=='s'){
            System.out.println(str+"es");
        }else{
            System.out.println(str+"s");
        }
    }
}

Measured memory_bytes: 36436
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def dfs(ind, l):
    if ind == 4:
        if sum(l) ==7:
            for i, num in enumerate(l):
                if num >= 0 and i != 0:
                    print('+', end='')
                print(num, end='')
        else:
            return
        print('=7')
        exit()
    dfs(ind+1, l+[A[ind]])
    dfs(ind+1, l+[(-1)*A[ind]])

A = list(map(int, list(input())))
dfs(1, [A[0]])

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

long long int f(long long int x)
{
    if (x % 2)
        return x % 4 == 1;
    return x + (x % 4 == 2);
}

int main()
{
    long long int a, b;
    cin >> a >> b;
    cout << (f(a - 1) ^ f(b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int A[45];

int f(int n){
  if(n==1||n==0) return A[n]=1;
  if(A[n]!=-1) return A[n];
  return A[n]=f(n-1)+f(n-2);
}

int main(){

  int n,i;

  scanf("%d",&n);

  for(i=0;i<45;i++) A[i]=-1;

  printf("%d\n",f(n));

  return 0;
}



Measured memory_bytes: 2112
package main

import (
	"fmt"
	//"math"
	//"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := scanNums(n)
	sum := 0.0
	for i := 0;i<n;i++{
		sum += 1/float64(a[i])
	}
	fmt.Print(1/sum)
}

func scanNums(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

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

int main(){
    int N, C, K;
    int t[110000];
    cin >> N >> C >> K;
    for(int i = 0;i < N; i++) cin >> t[i];

    sort(t,t+N);
    bool flag = true;
    int standard = 0;
    int ans = 1;
    int passengersNum = 0;
    for(int i = 0;i < N; i++){
        if(flag){
            standard = t[i];
            // cout << "over time, index is " << i << endl;
        }
        passengersNum++;

        flag = false;
        if(standard + K < t[i+1]){
            // cout << "success into over standard and index is " << i << endl;
            passengersNum = 0;
            ans++;
            flag = true;
            continue;
        }

        if(passengersNum >= C){
            if(t[i+1] == 0) break;
            // cout << "capacity over index is " << i << "and the number of passengers are " << passengersNum << endl;
            passengersNum = 0;
            flag = true;
            ans++;
            continue;
        }
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

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

    ll sum = 0;
    rep(i, n){
        sum += (ll)cnt[i] * (ll)(cnt[i]-1) / 2;
    }

    rep(i, n){
        ll ans = sum - (ll)cnt[a[i]] * (ll)(cnt[a[i]]-1) / 2 + (ll)(cnt[a[i]]-1)* (ll)(cnt[a[i]]-2) / 2;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


// 個数制限付き部分和問題
// 蟻本 p62

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

    int X; cin >> X;
    vector<int> a(6), m(6);
    rep(i, 6) a[i] = 100 + i;
    rep(i, 6) m[i] = 1e7;


    vector<vector<int>> dp(10, vector<int>(X+5, -1));
    dp[0][0] = 0;
    rep(i, 6) rep(j, X+1){
        if(dp[i][j]>=0) dp[i+1][j] = m[i];
        else if(j < a[i] || dp[i+1][j-a[i]]<=0) dp[i+1][j] = -1;
        else dp[i+1][j] = dp[i+1][j-a[i]]-1;
    }
    
    cout << (dp[6][X]>=0) << endl;
    
    return 0;
}

Measured memory_bytes: 4608
def resolve():
    N = int(input())
    a = list(map(int,input().split()))
    DP = [[2 ** 63 -1  for _ in range(N+1)] for _ in range(N)]
    SUM = [[0 for _ in range(N+1)] for _ in range(N+1)]
    RANGE = [[0 for _ in range(N+1)] for _ in range(N+1)]

    SUM[0][0] = 0
    for i in range(N):
        for j in range(i,N):
            SUM[i][j+1] = SUM[i][j] + a[j]
            if i < j:
                SUM[i+1][j] = SUM[i][j] - a[i]

    for i in range(N):
        j = i+1
        DP[i][j] = 0
        RANGE[i][j] = i

    for w in range(2,N+1):
        for i in range(N+1-w):
            j = i + w
            for k in range(RANGE[i][j-1],RANGE[i+1][j]+1):
                s = DP[i][k]+DP[k][j]+SUM[i][j]
                if DP[i][j] > s:
                    DP[i][j] = s
                    RANGE[i][j] = k
    print(DP[0][N])
resolve()

Measured memory_bytes: 47344
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int Mod=1e9+7;
int n,t[500];ll ans=1;
char s[100010];
int main(){
	n=gi();scanf("%s",s+1);
	for(int i=1;i<=n;i++)t[s[i]-'a']++;
	for(int i=0;i<26;i++)if(t[i])ans=1ll*ans*(t[i]+1)%Mod;
	printf("%lld\n",(ans+Mod-1)%Mod);
	return 0;
}


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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    int N; cin >> N;
    vector<int> A(N); cin >> A;
    sort(A.begin(), A.end(), greater<int>());

    ll ans = 0;

    for (int i = 1; i < N; i++) {
        ans += A[i/2];
    }

    cout << ans << endl;
}


Measured memory_bytes: 4052
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll n,ans=0,c=0;
  cin>>n;
  vll a(n),b(n);
  rep(i,0,n){
    cin>>a[i];
    if(a[i]<0){c++;}
    b[i]=abs(a[i]);
    ans+=b[i];
  }
  if(c%2==1){
    sort(b.begin(),b.end());
    ans-=b[0]*2;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 1792
n,m = map(int, input().split())
a = list(map(int, input().split()))

bc = [tuple(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(key=lambda x:x[1], reverse=True)

idx = 0
res = 0
flag = False
for b,c in bc:
    for _ in range(b):
        if idx < n and a[idx] < c:
            res += c
            idx += 1
        else:
            flag = True
    if flag:
        break

if idx < n:
    res += sum(a[idx:])

print(res)

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

using namespace std;

double p[3005], dp[3005][3005];

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

    for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);

    dp[0][0] = 1.0;

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (j >= 0)
            dp[i][j] += p[i] * dp[i - 1][j - 1];
            dp[i][j] += (1 - p[i]) * dp[i - 1][j];
        }
    }

    double res = 0.0;

    for (int i = n / 2 + 1; i <= n; i++) res += dp[n][i];

    printf("%.12lf\n", res);
}


Measured memory_bytes: 68992
use std::cmp::max;
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let mut a: Vec<(u64, usize)> = a.iter().copied().enumerate().map(|(i, x)| (x, i)).collect();
    a.sort();
    a.reverse();
    let a = a;

    let mut solve = Solve {
        n,
        a,
    };
    solve.solve();
}

struct Solve {
    n: usize,
    a: Vec<(u64, usize)>,
}

impl Solve {
    fn solve(&mut self) {
        let n = self.n;
        let a = &self.a;
        // dbg!(a);

        let mut dp = vec![vec![0u64; n + 1]; n + 1];

        for s in 0..n {
            let (a_i, origin_i) = a[s];
            // dbg!(a[s]);
            for i in 0..n {
                if s + 1 < i {
                    break;
                }
                let j = s + 1 - i;
                if i > 0 {
                    dp[i][n - j] = max(dp[i][n - j], dp[i - 1][n - j] + a_i * (origin_i as i64 - (i - 1) as i64).abs() as u64);
                    // dbg!(dp[i][n - j]);
                }
                if j > 0 {
                    dp[i][n - j] = max(dp[i][n - j], dp[i][n - (j - 1)] + a_i * (origin_i as i64 - (n - j) as i64).abs() as u64);
                    // dbg!(dp[i][n - j]);
                }
            }
        }
        // dbg!(&dp);

        let mut ans = 0u64;
        for i in 0..n {
            ans = max(ans, dp[i][i]);
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 33420
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)

using namespace std;
typedef long long ll;
const int N = 102;

int n, a[N], f[N][N*N];
int x[N][N*N], g[N][N*N];

int main(){
    ios_base::sync_with_stdio(0);

    memset(x, 0x3f3f3f, sizeof(x));
    memset(f, 0x3f3f3f, sizeof(f));
    memset(g, 0x3f3f3f, sizeof(g));

    cin >> n;
    f1(i, n){
        cin >> a[i];
        if(i==1){
            for(int j = 1; j <= 10000; j++){
                if(j==a[i]) x[i][j] = 0;
                else x[i][j] = x[i][j - 1];
            }
            for(int j = 10000; j >= 0; j--){
                if(j==a[i]) g[i][j] = 0;
                else g[i][j] = g[i][j + 1];
            }
            continue;
        }
        int add;
        for(int j = 1; j <= 10000; j++){
            add = 1;
            if(j==a[i]) add = 0;
            f[i][j] = min(f[i][j], min(x[i - 1][j - 1], g[i - 1][j + 1]) + add);
        }
        for(int j = 1; j <= 10000; j++){
            x[i][j] = min(f[i][j], x[i][j - 1]);
        }
        for(int j = 10000; j >= 1; j--){
            g[i][j] = min(f[i][j], g[i][j + 1]);
        }
    }
    cout << x[n][10000];
}



Measured memory_bytes: 12672
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <unordered_map>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    char N;
    scanf("%c", &N);
    if (N <= 'Z')
        printf("A\n");
    else
    {
        printf("a\n");
    }
}


Measured memory_bytes: 3764
import java.util.*;

public class Main {
    public static void main(String args[]) {
        //ArrayList<Integer> array = new ArrayList<Integer>();
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int sum = 0;
        
        Integer[] array = new Integer[n];
        for(int i = 0; i < n; ++i) {
            int item = sc.nextInt();
            array[i] = item;
            
            // 要素の総和を求める
            sum += item;
        }
        
        // 読み込んだ配列を降順にソートする
        Arrays.sort(array, Collections.reverseOrder()); 
        
        double item_v = sum / (4d * m);
        
        if(array[m - 1] < item_v ) System.out.println("No");
        else System.out.println("Yes");
    }
}

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

int main() {
	int n;
	cin >> n;
	bool flag = false;
	for(int i = 0; i<n; i++){
		string s;
		cin >> s;
		if (s=="Y"){
			flag = true;
		}
	}
	cout << ( flag ? "Four" : "Three" ) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    vector<ll> a(n),d;
    map<ll,ll> p;
    vector<P> q;
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    rep(i,m){
        ll b,c;
        cin >> b >> c;
        q.push_back({c,b});
    }
    sort(q.begin(),q.end());
    reverse(q.begin(),q.end());
    int cnt=0,cnt1=0;
    bool ok=false;
    while(1){
        int x=q[cnt1].second;
        while(1){
            d.push_back(q[cnt1].first);
            --x;
            ++cnt;
            if(cnt==n){
                ok=true;
                break;
            }
            if(x==0) break;
        }
        if(ok) break;
        ++cnt1;
    }
    ll ans=0;
    rep(i,n){
        ans+=max(a[i],d[i]);
    }
    cout << ans << "\n";
    return 0;
}   

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

bool cond(int a, int b, int c) {
    if(b > a && b < c || b < a && b > c) {
        return true;
    } else {
        return false;
    }
}
int main () {

    int n;
    std::cin >> n;

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

    int ans = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if(cond(p[i-1], p[i], p[i+1])) {
            ans++;
        }
    }

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

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unordered_map>
# include <unordered_set>
//#include <bits/stdc++.h>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
#define forn(i, n) for (int i = 0; i < (n); i++)
#define forx(i,x,n) for (int i = x; i < (n); i++)
#define form(i, n) for (int i = n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define pf push_front
#define mp make_pair
#define ll long long
#define ld long double
#define ull unsigned ll
#define srt(a) sort(a.begin(), a.end());
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pld pair<ld,ld>
#define ar array
#define endl '\n';
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }
 
const ll MAXN = 32005, K = 200043, M = 1000043, INF = 1e18 + 7;
// the good way to get PI number
const ld PI = acos(-1.0);
ll MOD = 1e9 + 7;

template <class T> T sqr(T a) {
    return a * a;
}

ll mul(ll a, ll b) {
    return ((a % MOD) * (b % MOD)) % MOD;
}

ll sum(ll a, ll b) {
    return ((a % MOD) + (b % MOD)) % MOD;
}

ll sub(ll a, ll b) {
    return sum(a, MOD - b);
}

ll bin_pow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n >>= 1;
    }
    return res;
}

void solve() {
    string s;
    cin >> s;
    
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) {
            cout << i << ' ' << i + 1 << endl;
            return;
        }
    }
    
    for (int i = 2; i < s.size(); ++i) {
        if (s[i] == s[i - 2]) {
            cout << i - 1 << ' ' << i + 1 << endl;
            return;
        }
    }
    
    cout << "-1 -1" << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
//    cin >> t;
    
    while (t --> 0)
        solve();
    return 0;
}


Measured memory_bytes: 3760
import fractions
A, B, C, D = map(int, input().split())


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


A = A - 1

ans = B - (B // C) - (B // D) + (B // (lcm(C, D)))
p = (A - (A // C) - (A // D) + (A // (lcm(C, D))))

print(ans - p)

Measured memory_bytes: 5048
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
XY = []
for _ in range(N):
    A = int(input())
    xy = [list(mapint()) for _ in range(A)]
    XY.append(xy)

ans = 0
for i in range(1<<N):
    honest = [-1]*N
    cnt = 0
    ok = True
    for j in range(N):
        if (i>>j)&1:
            honest[j]=1
        else:
            honest[j]=0
    for j in range(N):
        if (i>>j)&1:
            cnt += 1
            for x, y in XY[j]:
                if honest[x-1]!=y:
                    ok = False
                    break
    if ok:
        ans = max(ans, cnt)

print(ans)


Measured memory_bytes: 74360
package main

import (
	"fmt"
	"math"
	"sort"
)

func contain(s []int, e int)bool{
	for _, v := range s{
		if e == v{
			return true
		}
	}
	return false
}

func main() {
	var x, n int
	fmt.Scan(&x, &n)
	nums := make([]int, n)
	for i:=0; i<n; i++{
		fmt.Scan(&nums[i])
	}

	sort.Ints(nums)

	ans := -1
	if len(nums)>0{
		for i:=0; i<102; i++{
			if math.Abs(float64(x) - float64(i)) < math.Abs(float64(x) - float64(ans)) && !contain(nums, i){
				ans = i
			}
		}
	}else{
		ans = x
	}

	fmt.Println(ans)
}

Measured memory_bytes: 1828
#include <stdio.h>
 
int main(void)
{
    float a, b, c, d, e, f, x, y;
     
    while (scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF){         
        y = (c * d - f * a) / (b * d - e * a);
        x = (c - b * y) / a;
         
        printf("%.3f %.3f\n", x, y);
    }
     
    return (0);
}

Measured memory_bytes: 648
x,k,d = map(int, input().split())
if x>=0:
  a = x//d
  if a>=k:
    ans = x-k*d
  elif (k-a)%2==0:
    ans = x-a*d
  else:
    ans = x-(1+a)*d
else:
  y = 0-x
  a = y//d
  if a>=k:
    ans = x+k*d
  elif (k-a)%2==0:
    ans = x+a*d
  else:
    ans = x+(a+1)*d
if ans>0:
  print(ans)
else:
  print((-1)*ans)
  

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n;  cin >> n;
    long long ans = 0;
    string *s;
    s = new string[n];
    map<string, int> q;
    int i;
    for (i = 0; i < n; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        ans += q[s[i]];
        q[s[i]]++;
    }

    cout << ans << endl;

    delete[] s;

    return 0;
}

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

int main(){
    int a,b,c,i;
	for(int j=0;j<200;j++){
		if(!(cin >> a >> b))break;
		c = a+b;
		for(i=1;true;i++){
			c = c/10;
			if(c==0)break;
		}
		cout << i << endl;
	}

    
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] lettrs = scanner.nextLine().toCharArray();
		boolean[] exits = new boolean[26];
		
		for (int i = 0; i < exits.length; i++) {
			exits[i] = false;
		}
		for (int i = 0; i< lettrs.length; i++) {
			exits[lettrs[i]-'a'] = true;
		}
		String ans = "None";
		for (int i = 0; i < exits.length; i++) {
			if (!exits[i]) {
				char c = (char)(i+'a');
				ans = String.valueOf(c);
				break;
			}
		}
		
		System.out.println(ans);
		
		
		scanner.close();

	}

}

Measured memory_bytes: 26300
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int H, W;
vector<vi> c(10, vector<int>(10, 0));
vector<vi> A;

void input() {
  cin >> H >> W;
  rep(i, 0, 9) {
    rep(j, 0, 9) { cin >> c[i][j]; }
  }
  A.resize(H, vi(W));
  rep(i, 0, H - 1) {
    rep(j, 0, W - 1) { cin >> A[i][j]; }
  }
}
void solve() {
  // vector<vi> tb(10, vector<int>(10, 0));
  int tb[10][10];
  rep(i, 0, 9) rep(j, 0, 9) tb[i][j] = INF;
  tb[1][1] = 0;
  rep(i, 0, 9) {
    rep(j, 0, 9) { tb[i][j] = c[i][j]; }
  }
  rep(_, 0, 10) {
    rep(i, 0, 9) {
      rep(j, 0, 9) {
        rep(k, 0, 9) { tb[i][j] = min(tb[i][j], tb[i][k] + c[k][j]); }
      }
    }
  }
  int ans = 0;
  for (auto x : A) {
    for (auto y : x) {
      if (y != -1) ans += tb[y][1];
    }
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 512
fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val count = IntArray(n) { 1 }
    val may = BooleanArray(n)
    may[0] = true
    for (i in 1..m) {
        val (x, y) = readLine()!!.split(' ').map { x -> x.toInt() - 1 }
        may[y] = may[y] || may[x]
        count[x]--; count[y]++
        if (count[x] == 0) may[x] = false
    }
    println(may.count { it })
}


Measured memory_bytes: 29788
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int d  = sc.nextInt();
    int t = sc.nextInt();
    int s = sc.nextInt();
 
    double a = (double)d/s;

    if(a <= t){
    	System.out.println("Yes");
    }else{
    	System.out.println("No");
      }
}
}


Measured memory_bytes: 35680
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sin=new Scanner(System.in);
	    String s1=sin.next();
		for (int i = 0; i < s1.length(); i++) {
			System.out.print('x');
		}
    }
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string n;
  cin >> n;

  for (auto c : n) {
    if (c == '1') {
      cout << 9;
    } else if (c == '9') {
      cout << 1;
    } else {
      cout << c;
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
#include<iomanip>

using namespace std;

typedef complex<double> P;

#define EPS 1e-9
#define shosu(x) fixed<<setprecision(x)

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
struct C{
  P c;double r;
  C(const P &c,double r):c(c),r(r){}
};

namespace std{//演算子の定義
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real() && a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c) {//3点の関係性
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;                               // a--c--b on line
}

P projection(L l, P p){//pの直線l上の射影
  double t=dot(p-l[0],l[0]-l[1])/norm(l[0]-l[1]);
  return l[0]+t*(l[0]-l[1]);
}

P reflection(L l, P p){//点pの直線lに関して対称な点
  return p+2.0*(projection(l,p)-p);
}

bool isOrthogonal(L l1, L l2){//2直線の直交判定
  return fabs(dot(l1[1]-l1[0],l2[1]-l2[0])) < EPS;
}

bool isParallel(L l1, L l2){//2直線の平行判定
  return fabs(cross(l1[1]-l1[0],l2[1]-l2[0])) < EPS;
}

int main(){
  double xp1,yp1,xp2,yp2;
  cin>>xp1>>yp1>>xp2>>yp2;
  P p1(xp1,yp1), p2(xp2,yp2);
  L l(p1,p2);

  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    double x,y;
    cin>>x>>y;
    P p(x,y);
    P ans=projection(l,p);
    cout<<shosu(10)<<ans.real()<<"  "<<ans.imag()<<endl;

  }
  
}



Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    int num[n+1];
    for(i=0; i<n; i++)
    {
        cin>>num[i];
    }
    sort(num,num+n);
    int cnt=0,ans=0,temp=num[0];
    for(i=0; i<n; i++)
    {
        if(temp==num[i])
        {
            cnt++;
        }
        else
        {

            if(cnt<temp)
            {

                ans+=cnt;
            }
            else
            {
                ans+=(cnt-temp);
            }
            temp=num[i];
            cnt=1;
        }
    }
    if(cnt<temp)
    {
        ans+=cnt;
    }
    else
    {
        ans+=(cnt-temp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define BASE 1000000007
using namespace std;

long mod_pow(long a, int r) {
    long ans = 1;
    for (; r > 0; r >>= 1) {
        if (r & 1)
            ans = (ans * a) % BASE;
        a = (a * a) % BASE;
    }
    return ans;
}

long mod_div(long a) {
    return mod_pow(a, BASE - 2);
}

long factorial(long n) {
    long ans = 1;
    for (; n > 0; n--) {
        ans = (ans * n) % BASE;
    }
    return ans;
}

long add(long x, long y) {
    return (x + y) % BASE;
}

long sub(long x, long y) {
    return (BASE + x - y) % BASE;
}

long mul(long x, long y) {
    return (x * y) % BASE;
}

int main() {
    int n;
    scanf("%d", &n);
    long fact_n = factorial(n), invs[n];
    invs[0] = 1;
    for (int i = 1; i < n; i++) {
        invs[i] = add(invs[i - 1], mod_div(i + 1));
    }
    long ans = 0;
    for (int i = 0; i < n; i++) {
        long a;
        scanf(" %ld", &a);
        ans = add(ans, mul(a, mul(fact_n, add(invs[i], sub(invs[n - 1 - i], invs[0])))));
    }
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int a, b;
  cin >> a >> b;
  if(a < b) cout << "a < b" << endl;
  else if( a == b) cout << "a == b" << endl;
  else cout << "a > b" << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    ll a[114514];
    bool ans=true;
    for(int i=0;i<n;i++)cin>>a[i];
    for(ll i=8589934592;i>0;i/=2){
        int c0=0,c1=0;
        for(int j=0;j<n;j++){
            if(a[j]/i==1){
                c1++;
                a[j]-=i;
            }else c0++;
        }
        if(!(c0==n||c0*2==c1)){
            ans=false;
            break;
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 1024
'use strict'

function main(s) {

  s = s.split('\n');

  const nums = s[0].split(' ').map(x => Number(x));
  nums.sort((a, b) => a - b);

  let k = Number(s[1]);

  while (k >= 1) {
    nums[2] = nums[2] * 2;
    k -= 1;
  }

  const ans = nums.reduce((a, b) => a + b );
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22464
n, k = map(int, input().split())
a = list(map(int, input().split()))

count = 0
for index, i in enumerate(a):
    for j in a[index+1:]:
        if i > j:
            count += k * (k + 1) // 2
        elif i < j:
            count += (k - 1) * k // 2

print(count % (10**9 + 7))


Measured memory_bytes: 3188
k,n = map(int,input().strip().split())
ls = list(map(int,input().strip().split()))
mini1 = abs(ls[-1]-ls[0])
if n>1:
    mini_cons = -1
    sind = -1
    for i in range(1,n):
        ans = ls[i]-ls[i-1]
        if ans>mini_cons:
            sind = i-1
            mini_cons = ans
    if sind!=-1:
        mini1 = min(ls[sind]+k-ls[sind+1],mini1)
print(mini1)
    


Measured memory_bytes: 26444
#include<iostream>
using namespace std;
int main(){
long long a[300002];
int x,y,z;
cin>>x;
for(int i=0;i<x;i++){
  cin>>a[i];
}
if(a[0]>=10&&a[x-1]>=10){
for(int i=1;i<x;i++){
  int f=0;
  if(a[i]<10){
  for(int j=i-1;j>=0;j--){
    if(a[j]>=(i-j)*10+10){
      break;
    }
    if(j==0){
      
      cout<<"no\n";
      return 0;
    }
    
  }
  for(int j=i+1;j<x;j++){
    if(a[j]>=(j-i)*10+10){
      break;
    }
    if(j==x-1){
      cout<<"no\n";
      return 0;
    }
    
  }
  
  
  
  }
}
  
}
else{
cout<<"no\n";
return 0;

}
cout<<"yes\n";
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

class UnionFind {
    using i64 = std::int64_t;

private:
    std::vector<i64> par;
    std::vector<i64> sz;

public:
    UnionFind(i64 N) : par(N), sz(N, 1) {
        for (i64 i = 0; i < N; ++i) par[i] = i;
    }
    i64 root(i64 x) {
        return par[x] == x ? x : par[x] = root(par[x]);
    }
    bool same(i64 x, i64 y) {
        return root(x) == root(y);
    }
    void unite(i64 x, i64 y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) std::swap(x, y);
        par[y] = x;
        sz[x] += sz[y];
    }
    i64 size(i64 x) {
        return sz[root(x)];
    }
    void reset(i64 N) {
        par.resize(N);
        for (i64 i = 0; i < N; ++i) par[i] = i;
        sz.assign(N, 1);
    }
};

int N, M;
using Graph = vector<Vi>;
Graph g;

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    cin >> N >> M;
    g.resize(N);
    vector<Pii> edges(M);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        edges[i] = make_pair(a, b);
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    ll ans = 0;
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        tie(a, b) = edges[i];
        uf.reset(N);
        for (int j = 0; j < N; j++) {
            for (const auto& to : g[j]) {
                if ((a == j && b == to) || (b == j && a == to)) continue;
                uf.unite(j, to);
            }
        }
        if (uf.size(0) != N) ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

int n;
int util[110000][3];
long long dp[110000][3];

int main() {
    cin >> n;
    rep(i,n) cin >> util[i][0] >> util[i][1] >> util[i][2];

    for (int i = 1; i <= n; ++i) {
        for (int today = 0; today < 3; ++today) {
            for (int yesterday = 0; yesterday < 3; ++yesterday) {
                if (today == yesterday) {
                    continue;
                }
                dp[i][today] = max(dp[i][today], dp[i-1][yesterday] + util[i-1][today]);
            }
        }
    }
    long long ans = 0;
    rep(i,3) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n;
int a[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    for(int i = 1; i < n; i++){
        if(s[i] != s[i - 1])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (1) {
		C-=B;
		if (C <= 0) {
			cout << "Yes" << endl;
			break;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    int count5 = 0;
    int count7 = 0;

    if(a == 7)
    	count7 ++;
    else if(a == 5)
    	count5 ++;
    if(b == 7)
    	count7 ++;
    else if(b == 5)
    	count5 ++;
    if(c == 7)
    	count7 ++;
    else if(c == 5)
    	count5 ++;

    if(count5 == 2 && count7 == 1)
    	cout << "YES" << endl;
    else
    	cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  if(a%3 && b%3 && (a+b)%3){
    cout << "Impossible" << endl;
  }else{
    cout << "Possible" << endl;
  }
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T1, typename T2>
inline auto mini(T1 a, T2 b) { return (a < b ? a : b); }
template<typename T, typename... Args>
inline auto mini(T a, Args... args) { return mini(a, mini(args...)); }
template <typename T1, typename T2>
inline auto maxi(T1 a, T2 b) { return (a > b ? a : b); }
template<typename T, typename... Args>
inline auto maxi(T a, Args... args) { return maxi(a, maxi(args...)); }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // use mt19937_64 for 64 bit

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    string s;
    cin>>s;
    for(int i=0; i<sz(s); i++) {
        if(s[i] == '?') {
            s[i] = 'D';
        }
    }
    // int ans = 0;
    // for(int i=0; i<n-1; i++) { 
    //     if(s[i] == 'P' and s[i+1] == 'D') {
    //         ans++;
    //     }
    //     if(s[i] == 'D') {
    //         ans++;
    //     }
    // }
    // if(s[n-1] == 'D') {
    //     ans++;
    // }
    cout << s << "\n";
    return 0;
}



Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[5];
		for (int i = 0; i < 5; i++) {
			num[i] = sc.nextInt();
		}

		for (int i = 1; i <= 5; i++) {
			if (num[i - 1] == 0) {
				System.out.println(i);
				break;
			}
		}

		sc.close();
	}

}

Measured memory_bytes: 35688
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  vector<int> vec;

  while (1) {
    int sum = 0;

    while (1) {
      char c;
      scanf("%c", &c);

      if (c == '\n') {
        break;
      }

      sum += c - '0';
    }

    if (sum == 0) {
      break;
    }

    vec.push_back(sum);
  }

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



Measured memory_bytes: 3144