akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  LL n,k; cin>>n>>k;
  if(k>=n ){
    cout<<min(n,k-n)<<endl;
    return 0;
  }
  LL z = n/k;
  n = n - z*k;
    cout<<min(n,k-n)<<endl;

  return 0;
}



Measured memory_bytes: 256
def main(n,m,r):
    ac = [0]*n
    wa = [0]*n
    for i in range(len(r)):
        seq = int(r[i][0])
        judge = r[i][1]
        if ac[seq-1] == 1:
            continue
        if judge == "WA":
            wa[seq-1] += 1
        else:
            ac[seq-1] = 1
    for i in range(len(ac)):
        if ac[i] == 0:
            wa[i] = 0
    return "{0} {1}".format(sum(ac), sum(wa))

n,m = map(int, input().split())
r = list(input().split() for _ in range(m))
print(main(n,m,r))

Measured memory_bytes: 33684
#include<cstdio>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	while(true){
		c-=b;
		if(c<=0){
			printf("Yes");
			break;
		}
		a-=d;
		if(a<=0){
			printf("No");
			break;
		}	
	}
	return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void solve(int n){
    int m,p;
    cin>>m>>p;
    --m;
    int s=0;
    int a[n];
    rep(i,n){
        cin>>a[i];
        s+=a[i];
    }
    if(a[m]==0)cout<<0<<endl;
    else {
        cout<<s*(100-p)/a[m]<<endl;
    }
}
int main(){
    int n;
    while(cin>>n,n!=0)solve(n);
    return 0;
}


Measured memory_bytes: 2992
using System;

class Program
{
    static void Main(string[] args)
    {
        int q = Input.nextInt();
        bool[] isprime = new bool[100000];
        isprime[1] = true;
        for (int i = 3; i < 100000; i += 2)
        {

            for (int j = 2; j <= Math.Sqrt(i); j++)
            {
                if (i % j == 0) goto flag;
            }
            isprime[i - 1] = true;
        flag:;
        }
        int[] sum = new int[100000];
        for (int i = 2; i < 100000; i++)
        {
            if (i % 2 == 1 || !isprime[i] || !isprime[i / 2])
            {
                sum[i] = sum[i - 1];
            }
            else
            {
                sum[i] = sum[i - 1] + 1;
            }
        }
        int tmpl;
        int tmpr;
        for (int i = 0; i < q; i++)
        {
            tmpl = Input.nextInt();
            tmpr = Input.nextInt();
            Console.WriteLine(sum[tmpr - 1] - sum[tmpl==1?0:tmpl - 2]);
        }



    }

}


class Input
{
    static string[] line = { };
    static int index = 0;
    static void readLine()
    {
        line = Console.ReadLine().Split(' ');
        index = 0;
    }
    public static int nextInt()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return int.Parse(line[index - 1]);
    }
    public static long nextLong()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return long.Parse(line[index - 1]);
    }
    public static string next()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return line[index - 1];
    }
}




Measured memory_bytes: 17604
from fractions import gcd

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

L = [0]*(n+1)
R = [0]*(n+1)

for i in range(1,n+1):
    L[i] = gcd(L[i-1],a[i-1])
for i in range(0,n)[::-1]:
    R[i] = gcd(R[i+1],a[i])
    
gcd_ans=[]
for i in range(n):
    gcd_ans.append(gcd(L[i],R[i+1]))
        
print(max(gcd_ans))

Measured memory_bytes: 16140
#include<bits/stdc++.h>
const int N=305;
int n,k,mo,i,j,l,C[N][N],f[N][N],g[N][N],ans;
int main(){
	scanf("%d%d%d",&n,&k,&mo);
	for(i=**C=1;i<N;++i)for(j=*C[i]=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	f[k+1][0]=1;
	for(i=k;i;--i){
		for(j=1;j<=n;++j)g[i][j]=(g[i+1][j]+f[i+1][j-1])%mo;
		f[i][0]=1;
		for(j=1;j<=n;++j)for(l=1;l<=j;++l)f[i][j]=(f[i][j]+1ll*f[i][j-l]*g[i][l]%mo*C[j-1][l-1])%mo;
	}
	printf("%d\n",f[1][n]);
	return 0;
}

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

const int INF = 1<<28;

int n;
vector<int> cs;

int chain(int p) {
    int up = 0, down = 0;
    int ub = p;
    while (ub < n && cs[++ub] == cs[p]);
    int lb = p;
    while (lb >= 0 && cs[--lb] == cs[p]);

    if (ub - lb < 5) return n;

    if (cs[ub] != cs[lb]) return n - (ub - lb) + 1;

    while (true) {
        if (lb < 0 || ub >= n) break;
        if (cs[ub] != cs[lb]) break;
        int dup = 2;
        int org = cs[ub];

        int org_ub = ub;
        int org_lb = lb;

        while (ub < cs.size() && cs[++ub] == org) dup++;
        while (lb >= 0 && cs[--lb] == org) dup++;
        //cout << "dup: " << dup << endl;
        if (dup < 4) {
            ub = org_ub;
            lb = org_lb;
            break;
        }
    }
    //cout << "ub: " << ub << " lb: " << lb << endl;
    return n - (ub - lb) + 1;
}

int main() {
    while (cin >> n, n) {
        cs.clear(); cs.resize(n);

        cs.push_back(5);
        for (int i = 0; i < n; i++) {
            cin >> cs[i];
            cs[i]--;
        }
        cs.push_back(5);

        int minLen = INF;
        for (int i = 0; i < cs.size(); i++) {
            int org = cs[i];
            cs[i] = (org+1) % 3;
            minLen = min(minLen, chain(i));
            cs[i] = (org+2) % 3;
            minLen = min(minLen, chain(i));
            cs[i] = org;
        }

        cout << minLen << endl;
    }
    return 0;
}

Measured memory_bytes: 1324
n, a, b = map(int, input().split())
mod = 10**9+7

#print(x*pow(y,(mod-2),mod)%mod)

def conv(n, x, mod):
    X = 1
    for i in range(x):
        k = i+1
        X *= (n-k+1)*pow(k,(mod-2),mod)%mod
        X %= mod
    return X

def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

#print(conv(n, a, mod))
#print(conv(n, b, mod))

ans = power_func(2, n, mod) - conv(n, a, mod) - conv(n, b, mod) - 1
ans %= mod
print(ans)

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

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int ans = 1000 - N % 1000;
        if(ans==1000)
            Console.WriteLine(0);
        else
            Console.WriteLine(ans);
    }
}

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

int main(){
  vector<int> vec(3);
  cin >> vec[0] >> vec[1] >> vec[2];
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int A,B,C;
  A = vec[0];
  B = vec[1];
  C = vec[2];
  
  int n,t;
  n = A-B;
  t = B-C;
  
  if(t%2 == 0) cout << n + t/2 << endl;
  else cout << n + t/2 + 2 << endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	string s;
	cin >>n >>s;
	if(n%2){ puts("No"); return 0;}
	if(s.substr(0, n/2) != s.substr(n/2, n/2)) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib> 
#include<sstream>
#include<cstdio>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
#define me(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define mod 1000000007
const int N = 1000005;
const int M = 500005;
int v[M],a[M];
int main()
{
    int i;
	std::ios::sync_with_stdio(false);
	int n;
    me(v,0);
	cin>>n;
	for(i=1;i<n;i++)
    {
        cin>>a[i];
        v[a[i]]++;
    }
    for(i=1;i<=n;i++)
    cout<<v[i]<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 5892
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[201],t[101],a[101];
    scanf("%s%s",s,t);
    strcpy(a,s);
    strcat(s,a);
    if(strstr(s,t)!=NULL)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int R;
  cin >> R;
  cout << setprecision(10) << 2 * 3.1415926535 * R << endl;
  return 0;
}


Measured memory_bytes: 3784
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        }

        String ans = "Yes";
        if (map.keySet().size() != 2) {
            ans = "No";
        }
        for (Character ch : map.keySet()) {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        }
        System.out.println(ans);
    }

}


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

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
    }

    rep(i, n/2) {
        int x = v[i];
        v[i] = v[n-i-1];
        v[n-i-1] = x;
    }

    rep(j, n) {
        cout << v[j];
        if(j!=n-1) cout << " ";
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<pair<string,int>>a(n),A(n);
for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
    A[i].first=a[i].first;
    A[i].second=a[i].second;
    a[i].second=-(a[i].second);
}
sort(a.begin(),a.end());
for(int i=0;i<n;i++){
    a[i].second=-(a[i].second);
}
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
       if(a[i].first==A[j].first&&a[i].second==A[j].second){
        cout<<j+1<<endl;
        A[j].first='0';
        A[j].second=0;
       }
    }
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------



int main() {

  string s;
  cin >> s;

  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) {
    cout << "Bad" << endl;
  }else {
    cout << "Good" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Circle_in_a_Rectangle
{
    class Program
    {
        static void Main(string[] args)
        {
            int W, H, x, y, r;
            String[] str = Console.ReadLine().Split(' ');
            W = int.Parse(str[0]);
            H = int.Parse(str[1]);
            x = int.Parse(str[2]);
            y = int.Parse(str[3]);
            r = int.Parse(str[4]);

            if (x - r >= 0 && y + r <= H && x + r <= W && y - r >= 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 9000
#include<bits/stdc++.h>
#define pb push_back
#define N 200000000

using namespace std;

void print(vector<int> v) {
    for (int i = 0; i < v.size(); i++) {
        if (i == v.size() - 1) cout << v[i] << "\n";
        else cout << v[i] << " ";
    }
}

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

    int n, o;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++) { cin >> o; v.pb(o); }
    print(v);

    for (int i = 1; i < n; i++) {
        int k = v[i];
        int j = i -1;
        while (j >= 0 && v[j] > k) {
            v[j + 1] = v[j];
            j--;
        }
        v[j + 1] = k;
        print(v);
    }


    return 0;
}



Measured memory_bytes: 3128
n, k, q = map(int,input().split())
a = [int(input()) for _ in range(q)]

cnt = [k-q]*(n+1)
for i in a:
    cnt[i] += 1

ans = []
for i in range(1, n+1):
    if cnt[i] > 0:
        ans.append('Yes')
    else:
        ans.append('No')
print('\n'.join(ans))

Measured memory_bytes: 17128
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def calc_score(hands, push):
  hands.sort()

  for i, v in enumerate(hands):
    if v > 0 or i >= push:
      return sum(hands[i:])

  return 0


def main():
  _, k = map(int, input().split())
  values = list(map(int, input().split()))
  score = 0

  for n in range(1, k + 1):
    if n < len(values):
      for i in range(n):
        score = max(calc_score(values[:i] + values[-n + i:], k - n), score)

      score = max(calc_score(values[:n], k - n), score)

    else:
      score = max(calc_score(values[:], k - n), score)

  print(score)


if __name__ == '__main__':
  main()



Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

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

    for (int i = b; i < c + 1; i++) {
        if (i % a == 0) {
            cout << "OK";
            return 0;
        }
    }

    cout << "NG";




    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int a, b, c; std::cin >> a >> b >> c;
    if (a == b && b == c) std::cout << (a&1 ? 0 : -1) << "\n";
    else {
        int ans = 0;
        while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
            int aa = a/2, bb = b/2, cc = c/2;
            a = bb + cc;
            b = aa + cc;
            c = aa + bb;
            ans++;
        }
        std::cout << ans << "\n";
    }
}


Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let bit: Vec<usize> = {
        let mut bit = vec![0; n];
        let mut b = 1;
        while b < n {
            let mut i = b;
            while i < n {
                bit[i] = b;
                i += 2 * b;
            }
            b *= 2;
        }
        bit
    };
    let s: String = scan(tokens);
    let mut s: Vec<usize> = s.bytes().map(|b| (b - b'a') as usize).collect();
    let mut count: Vec<Vec<usize>> = vec![vec![0; n]; 26];
    for mut i in 0..n {
        let c = s[i];
        while {
            count[c][i] += 1;
            i != 0
        } {
            i -= bit[i];
        }
    }
    let q: usize = scan(tokens);
    for _ in 0..q {
        let query_type: usize = scan(tokens);
        if query_type == 1 {
            let mut i: usize = scan(tokens);
            i -= 1;
            let c: String = scan(tokens);
            let c = (c.as_bytes()[0] - b'a') as usize;
            let d = s[i];
            s[i] = c;
            while {
                count[c][i] += 1;
                count[d][i] -= 1;
                i != 0
            } {
                i -= bit[i];
            }
        } else {
            let mut l: usize = scan(tokens);
            l -= 1;
            let mut cl = vec![0; 26];
            while l < n {
                for c in 0..26 {
                    cl[c] += count[c][l];
                }
                if l == 0 {
                    break;
                }
                l += bit[l];
            }
            let mut r: usize = scan(tokens);
            let mut cr = vec![0; 26];
            while r < n {
                for c in 0..26 {
                    cr[c] += count[c][r];
                }
                if r == 0 {
                    break;
                }
                r += bit[r];
            }
            let mut ans = 0;
            for c in 0..26 {
                if cl[c] > cr[c] {
                    ans += 1;
                }
            }
            println!("{}", ans);
        }
    }
}


Measured memory_bytes: 119036
while True:
    M,F,R = map(int,input().split())
    if M==-1 and F==-1 and R==-1:
        break
    if M==-1 or F==-1:
        print("F")
    elif M+F>=80:
        print("A")
    elif 65<=M+F:
        print("B")
    elif 50<=M+F:
        print("C")
    elif 30<=M+F:
        if R>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

int  main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	int cnt = 0;
	priority_queue<int> que;
	rep(i, n)
	{
		cin >> h[i];
		if (i > 0)
		{
			if(h[i-1] >= h[i])
				cnt++;
			else
			{
				que.push(cnt);
				cnt = 0;
			}
		}
		if (i == n -1)
			que.push(cnt);
	}
	cout << que.top() << endl;
	return (0);
}

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

const long long MOD = 1e9 + 7;
const int N = 2e5 + 100;

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

long long add(long long a, long long b) {
    a = a + b;
    if (a > MOD)
        a -= MOD;
    return a;
}

long long fac[N], rfac[N], inv[N];

void calc(int n) {
    inv[1] = 1;
    for (int i = 2; i <= n; i++) {
        inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
    }
    fac[0] = rfac[0] = 1;
    for (int i = 1; i <= n; i++) {
        fac[i] = mul(fac[i - 1], i);
        rfac[i] = mul(rfac[i - 1], inv[i]);
    }
}

long long comb(int k, int n) {
    return mul(fac[n], mul(rfac[k], rfac[n - k]));
}

void solve() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    calc(2 * max(h, w));

    long long ans = 0;

    for (int i = 1; i <= h - a; i++) {
        int x1 = i, y1 = b, y2 = b + 1, x2 = x1;

        int r1 = x1 - 1 + 1, c1 = y1 - 1 + 1;
        int r2 = h - x2 + 1, c2 = w - y2 + 1;

        ans = add(ans, mul(comb(r1 - 1, r1 + c1 - 2), comb(r2 - 1, r2 + c2 - 2)));
    }

    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF (1LL << 60)
typedef pair<long long, long long> P;

vector<P> valid_edge;
long long adist[105000], bdist[105000];
vector<P> edge[105000];
long long come[105000];
void dijkstra(long long start, long long *dist){
    fill(dist, dist + 103000, INF);
    priority_queue<P, vector<P>, greater<P> > pq;
    dist[start] = 0;
    pq.push(P(0, start));
    while(!pq.empty()){
	P tmp = pq.top();pq.pop();
	long long from = tmp.second, d = tmp.first;
	if(dist[from] < d)continue;
	for(long long i = 0;i < edge[from].size();i++){
	    long long to = edge[from][i].first, r = edge[from][i].second;
	    if(dist[from] + r >= dist[to])continue;
	    dist[to] = dist[from] + r;
	    pq.push(P(dist[to], to));
	}
    }
}

bool comp(const int &a, const int &b){
    return adist[a] < adist[b];
}

int main(){
    long long s, r, a, b, q, u[210000], v[210000], w[210000];
    cin >> s >> r;
    for(long long i = 0;i < r;i++){
	cin >> u[i] >> v[i] >> w[i];
	edge[u[i]].push_back(P(v[i], w[i]));
	edge[v[i]].push_back(P(u[i], w[i]));
    }
    cin >> a >> b >> q;
    dijkstra(a, adist);
    dijkstra(b, bdist);
    long long c[64], d[64];
    long long dp[105000];
    long long topo[105000];
    for(int i = 0;i < 105000;i++)topo[i] = i;
    sort(topo, topo + s, comp);
    for(long long i = 0;i < q;i += 50){
	fill(dp, dp + 105000, 0);
	for(long long j = 0;j < 50 && i + j < q;j++){
	    cin >> c[j] >> d[j];
	    dp[c[j]] |= (1ULL << j);
	}
	for(int j = 0;j < s;j++){
	    int p = topo[j];
	    if(adist[p] + bdist[p] != adist[b])continue;
	    for(int k = 0;k < edge[p].size();k++){
		int to = edge[p][k].first, d = edge[p][k].second;
		if(adist[to] + bdist[to] == adist[b] &&
		   adist[to] == adist[p] + d)
		    dp[to] |= dp[p];
	    }
	}
	for(long long j = 0;j < 50 && i + j < q;j++){
	    if(dp[d[j]] & (1ULL << j))cout << "Yes" << endl;
	    else cout << "No" << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 19912
import math

x = int(input())
maxans = 1
for i in range(1, int(math.sqrt(x))):
    tmp = 0
    while (i+1)**tmp <= x:
        b = (i+1)**tmp
        if maxans < (i+1)**tmp: maxans = (i+1)**tmp
        tmp += 1

print(maxans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	if(a==1||b==1){
		cout<<1;
		return 0;
	}
	cout<<(a/2+a%2)*(b/2+b%2)+(a/2)*(b/2);
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;
    int aa = stoi(s.substr(0, 2));
    int bb = stoi(s.substr(2, 2));

    int m1 = (1 <= aa and aa <= 12);
    int m2 = (1 <= bb and bb <= 12);

    if(m1 and m2) {
        cout << "AMBIGUOUS" << endl;
    }
    else if(m1) {
        cout << "MMYY" << endl;
    }
    else if(m2) {
        cout << "YYMM" << endl;
    }
    else {
        cout << "NA" << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    int n,k,q,a;
    vector<int> point,cnt;
    cin>>n>>k>>q;

    for(int i=0; i<n; i++){
        point.push_back(k);
        cnt.push_back(0);
    }

    for(int i=0; i<q; i++){
        cin>>a;
        cnt[a-1]++;
    }
    for(int i=0; i<n; i++){
        if(point[i]+cnt[i]-q<1){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	ll n, a, b;
	cin >> n >> a >> b;
	swap(a, b);
	ll ans = n / (a + b) * b;
	n %= (a + b);
	ans += min(n, b);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf 10000000000000000ll
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-9
#define endl "\n"
/*ll gcd(ll a,ll b)
{
    if(a==0){return b;}
    return gcd(b%a,a);
}
ll modexp(ll x,ll y,ll p)
{
    ll res=1;x%=p;
    while(y>0)
    {   if(y%2==1){res=(res*x)%p;}
        y=y>>1;x=(x*x)%p;
    }return res;
}*/

int a[27];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;cin>>s;
    rep(i,0,3)
    {
        a[s[i]-'A']++;
    }
    rep(i,0,25)
    {
        if(a[i]==2)
        {
            rep(j,i+1,25)
            {
                if(a[j]==2)
                {
                    cout<<"Yes"<<"\n";
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<"\n";



    return 0;

    /*check for long long or int*/
}


Measured memory_bytes: 256
def main():
    n,y = map(int, input().split())
    aa, ab, ac = -1, -1, -1
    a = y//10000
    b = (y-10000*a)//5000
    c = (y-10000*a-5000*b)//1000
    flag = False
    if n > a+b+c:
        no = n-a-b-c
        for s in range(b+1):
            for t in range(a+1):
                for t1 in range(t+1):
                    for t5 in range(t-t1+1):
                        if s*4 + t1*9 + t5 == no:
                            aa = a-t
                            ab = b-s+t5*2
                            ac = c+s*5+t1*10
                            flag = True
                            break
                    if flag:
                        break
                if flag:
                    break
            if flag:
                break
    elif n == a+b+c:
        aa, ab, ac = a, b, c
    print(aa,ab,ac)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
int main()
{    
    int N,K;
    cin >> N >> K;
    int x;
    int sum = 0;
    for(int i = 0;i < N;i++)
    {
        cin >> x;
        sum += min(x,abs(K - x));
    }
    cout << sum * 2 << '\n';
}



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

int main(void){
  string s;
  string ans="CODEFESTIVAL2016";
  int cnt=0;
  cin >> s;
  for(int i=0;i<ans.length();i++){
    if(s[i]!=ans[i]) cnt++;
  }
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for i in range(N):
        a = L[i]
        for j in range(i + 1, N):
            b = L[j]
            ans += max(bisect_left(L, a + b) - (j + 1), 0)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
<?php
$X = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($N,$M) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
//$H = array_map('intval',explode(" ",trim(fgets(STDIN))));

for($i=0;$i<1000;$i++) {
  $a[] = $i**5;
}

for($i=0;$i<1000;$i++) {
  for($j=$i+1;$j<1000-1;$j++) {
    if ($a[$j]-$a[$i]==$X) {
      printf("%d %d\n",$j,$i);
      break;
    }
    if (($a[$j]*-1)-$a[$i]==$X) {
      printf("%d %d\n",-$j,$i);
      break;
    }
    if ($a[$j]-$a[$i]*-1==$X) {
      printf("%d %d\n",$j,-$i);
      break;
    }
  }
}


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

int prime[10000];
bool is_prime[10001];

int sieve()
{
	int p = 0;
	rep(i,10001) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	
	for (int i=2; i<=10001; i++)
	{
		if (is_prime[i])
		{
			prime[p++] = i;
			for (int j=2*i; j<=10001; j+=i) is_prime[j] = false;
		}
	}

	return p;
}

signed main()
{
	int n;

	int p = sieve();

	while (true)
	{
		cin >> n;
		if (n == 0) break;

		int mx, mn;
		for (int i=0; i<p; i++)
		{
			if (prime[i + 1] > n) break;
			if (prime[i] + 2 == prime[i+1])
			{
				mx = prime[i + 1];
				mn = prime[i];
			}
		}

		cout << mn << " " << mx << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<double> VI;
typedef vector<VI> VVI;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

	int n, m, p, a, b;
	while (true)
	{
		cin >> n >> m >> p >> a >> b;
		if (n == 0)
			break;
		a--;
		b--;
		vector<double> t(n);
		for (int i = 0; i < n; i++)
			cin >> t[i];
		reverse(t.begin(), t.end());
		vector<P> e[30];
		for (int i = 0; i < p; i++)
		{
			int x, y, z;
			cin >> x >> y >> z;
			x--;
			y--;
			e[x].push_back(P(y, z));
			e[y].push_back(P(x, z));
		}
		VVI dis(1 << 8, vector<double>(m, INF));
		dis[0][a] = 0;
		queue<pair<double, P>> q; //����,P(�t���O�A���_)
		q.push(make_pair(0, P(0, a)));
		while (!q.empty())
		{
			pair<double, P> next = q.front();
			q.pop();
			double d = -next.first;
			int flag = next.second.first, vec = next.second.second;
			//cout << d << " " << flag << " " << vec << endl;
			if (dis[flag][vec] < d)
				continue;
			int tmp = flag;
			for (int i = 0; i < n; i++)
			{
				if (tmp % 2)
				{
				}
				else
				{
					int ftmp = flag | (1 << i);
					//cout << flag << " " << ftmp << endl;
					for (int j = 0; j < (int)e[vec].size(); j++)
					{
						int node = e[vec][j].first, w = e[vec][j].second;
						double dnow = dis[flag][vec], dnext = dis[ftmp][node];
						//cout << dnow << " " << dnext <<" "<< flag<<" "<<ftmp<<endl;
						if (dnext > dnow + double(w / t[i]))
						{
							dis[ftmp][node] = dnow + double(w / t[i]);
							q.push(make_pair(-dis[ftmp][node], P(ftmp, node)));
							//cout << flag<<" "<<ftmp << " "<<dis[ftmp][node]<<endl;
						}
					}
				}
				tmp /= 2;
			}
		}
		double res = INF;
		for (int i = 0; i < (1 << n); i++)
		{
			res = min(res, dis[i][b]);
		}
		res != INF ? cout << fixed << setprecision(10) << res << endl : cout << "Impossible" << endl;
	}
}



Measured memory_bytes: 3412
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	long long r, d;
	vector<long long> x(11, 0);
	cin >> r >> d >> x[0];

	for (int i = 1; i <= 10; i++) {
		x[i] = r * x[i-1] - d;
	}

	for (int i = 1; i <= 10; i++) {
		cout << x[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int main(void){
    int h,w;
    cin >> h >> w;
    int ch,cw,dh,dw;
    cin >> ch>> cw >> dh >> dw;
    ch--;cw--;dh--;dw--;
    vector<vector<char>> c(h,vector<char> (w));
    rep(i,h)rep(j,w) cin >> c[i][j];
    vector<vector<int>> seen(h,vector<int> (w,1e9));
    deque<pair<int,int>> q;
    q.push_front(make_pair(ch,cw));
    seen[ch][cw] = 0;
    while(!q.empty()){
        pair<int,int> p = q.front();
        q.pop_front();
        int d = seen[p.first][p.second];
        rep(i,4){
            int x1 = dx[i]+p.first,y1 = dy[i]+p.second;
            if(x1<0||y1<0||h<=x1||w<=y1) continue;
            if(c[x1][y1]=='#') continue;
            if(seen[x1][y1]<=d) continue;
            seen[x1][y1] = d;
            q.emplace_front(x1,y1);
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
               int x1 = p.first+i,y1=p.second+j;
               if(x1<0||y1<0||h<=x1||w<=y1) continue;
               if(c[x1][y1]=='#') continue;
               if(seen[x1][y1]<=d+1) continue;
               seen[x1][y1] = d+1;
               q.emplace_back(x1,y1);
            }
        }
    }
    if(seen[dh][dw]==1e9) cout << -1 << endl;
    else cout << seen[dh][dw] << endl;
}

Measured memory_bytes: 8564
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    X = in_n()

    if X >= 30:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 62020
<?php
list($q,$h,$s,$d) = explode(" ",trim(fgets(STDIN)));
$n = trim(fgets(STDIN));
$s = min(4*$q,2*$h,$s);

$ans = 0;
if($n%2 == 1){
    $ans = $s;
    --$n;
}
$d = min(2*$s,$d);
$q = $n/2;
echo $ans+$d*$q;
?>

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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0.0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    int n;std::cin >>n;
    VEC(dou,a,n);
    dou d=sum(a)/n;
    dou min=10000;
    int miv;
    rep(i,n){
        if(min>abs(a[i]-d)){
            miv=i;
            min=abs(a[i]-d);
        }
    }
   // std::cout <<keta(10)<< d << std::endl;
    std::cout << miv << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


void priv(vector<int> &a){
  int N = a.size();
  rep(i, N){
    cout <<a[i];
    if (i == N-1) cout <<endl;
    else cout <<" ";
  }
}

void insertionSort(vector<int> &A, int N, int g, int &cnt){
  for (int i=g; i<N; i++){
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(vector<int> &A, int N){
  int cnt = 0;

  int tmp = N;
  vector<int> G;
  while (tmp > 0){
    G.push_back(tmp);
    tmp /= 2;
  }

  int m = G.size();
  cout <<m <<endl;
  priv(G);

  for (int i=0; i<m; i++){
    insertionSort(A, N, G[i], cnt);
  }
  cout <<cnt <<endl;
}

int main() {
  int N; cin >>N;
  vector<int> A(N); rep(i, N) cin >>A[i];
  shellSort(A, N);
  rep(i, N) cout <<A[i] <<endl;
}


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


int main() {
  string t;
  
  int flag = 0;
  
  cin >> t;
  
  for(int i = 0; i<t.size(); i++){
    if(t.at(i) == '?'){
      t.at(i) = 'D';
    }
  }
  cout << t;
    
    
  }


Measured memory_bytes: 3720
//Coded by tzc_wk
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
ÍüÎÄ¼þ²Ù×÷£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int a[2],b[2];
signed main(){
	int cur=1;
	cin>>a[1]>>b[1]>>a[0]>>b[0];
	while(1){
		if(a[cur^1]-b[cur]<=0){
			if(cur==1)	puts("Yes");
			else		puts("No");
			break;
		}
		a[cur^1]-=b[cur];
		cur^=1;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,c,k; cin>>n>>c>>k;
  VI t(n); rep(i,n) cin>>t[i];
  sort(ALL(t));
  int next = t[0]+k, cnt=1;
  int ans = 1;
  rep(i,n){
    if(i==0) continue;
    if(next<t[i]||cnt==c){
      ans++; next=t[i]+k; cnt=1;
    }else{
      cnt++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool f(int x){
  int keta=0;
  while(x){
    keta++;
    x/=10;
  }
  return keta%2==1;
}
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(f(i)) ans++;
  }
  cout<<ans<<endl;
}
    


Measured memory_bytes: 3652
import scala.io.StdIn._

object Main{
  def maxSize(s : Array[String]): Int ={
    s match{
      case Array() => 0
      case _ => s.maxBy(_.size).size
    }
  }
  def main(args: Array[String]): Unit ={
    val str : String = readLine()
    val res : Array[String] = str.split("[^AGCT]")
    println(maxSize(res))
  }
}

Measured memory_bytes: 25412
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            b[a[i]-1] = i+1;
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(b[i]).append(" ");
        }
        
        System.out.println(sb);
    }
}

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

int main() {
  	string s;
  	cin >> s;
  
  	while(s.size() >= 2) {
      bool can = true;
      s.pop_back();
      s.pop_back();
  	for(int i = 0; i < s.size()  / 2;i++) {
  	
     	int back = s.size() / 2;
      
      	if(s.at(i) != s.at(i + back)) {
        	can = false;
        }
           
    }
  	if(can) {
    	cout << s.size() << endl;
      	break;
    }
   	    
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  string a;
  cin >> a;
  int n = a.size();

  map<char,ll> mp;
  rep(i,n) mp[a[i]] = 0;
  
  rep(i,n){
    mp[a[i]]++;
  }

  ll res = 0;
  for(auto& itr:mp){
    ll x = itr.second;
    res += x*(x-1)/2;
  }

  ll nn = (ll)n;

  cout << nn*(nn-1)/2+1-res << "\n";
  
  return 0;
}


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

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> field(h, vector<char>(w));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++) cin >> field[i][j];
  }
  
  int ans = 0;
  for(int i_bit = 0; i_bit < (1<<h); i_bit++){
    vector<vector<char>> sub_i = field;
    for(int i = 0; i < h; i++){
      if(i_bit & (1<<i)){
        for(int x = 0; x < w; x++) sub_i[i][x] = '&';
      }
    }
    for(int j_bit = 0; j_bit < (1<<w); j_bit++){
      vector<vector<char>> sub_j = sub_i;
      for(int j = 0; j < w; j++){
        if(j_bit & (1<<j)){
          for(int y = 0; y < h; y++) sub_j[y][j] = '&';
        }
      }
      int count = 0;
      for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
          if(sub_j[i][j] == '#') count++;
        }
      }
      if(count == k) ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628