akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,h[110],ans;
bool check(){
	for (int i=0;i<n;i++) if (h[i]!=0) return 1;
	return 0;
}
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>h[i];
	while (check()==1){
		int i=0;
		for (;i<n;i++) if (h[i]!=0) break;
		for (;i<n;i++){
			if (h[i]==0) break;
			h[i]--;
		}
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[105];
int main() {
    int k;
    scanf("%s", s);
    scanf("%d", &k);
    int len = strlen(s);
    int f = 0, b = 0, cnt = 0;
    for (int i = 0; s[i] == s[0]; i++) f++;
    for (int i = len - 1; i > f && s[i] == s[0]; i--) b++;
    for (int i = f + 1; i < len - b; i++) {
        if (s[i] == s[i - 1]) {
            s[i] = '#';
            cnt++;
        }
    }
    // printf("\t%d %d %d\n", f, cnt, b);
    if (f == len) printf("%lld", ((long long)k * f) >> 1);
    else printf("%lld", cnt * (long long)k + (f >> 1) + (b >> 1) + ((f + b) >> 1) * ((long long)k - 1));
    return 0;
}


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;

int main() {
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << W * H / 2.0 << " ";
    if (x * 2 == W && y * 2 == H) cout << 1 << endl;
    else cout << 0 << endl;
}

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

int main()
{
  int N,K;
  cin >> N >> K;
  int ans = 1;
  for (int i = 0; i < N; ++i){
    if (ans < K) ans = ans * 2;
    else ans += K;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn str_to_ints(s: String) -> std::vec::Vec<i64> {
    let mut ret = std::vec::Vec::new();
    let ws = s.split_whitespace();
    for w in ws {
        ret.push(w.parse().unwrap());
    }
    ret
}

fn read_ints() -> std::vec::Vec<i64> {
    str_to_ints(read_line())
}

fn bp_num(n: i64) -> i64 {
    if n == 0 {
        return 1;
    } else {
        return 2 * bp_num(n - 1) + 3;
    }
}

fn p_num(n: i64) -> i64 {
    if n == 0 {
        return 1;
    } else {
        return 2 * p_num(n - 1) + 1;
    }
}

fn dfs(n: i64, x : i64) -> i64 {
    if n == 0 {
        return 1;
    }

    let bp_num_nm1 = bp_num(n - 1);
    let p_num_nm1 = p_num(n - 1);

    if x == 0 {
        return 0;
    } else if x == bp_num(n) - 1 {
        return p_num(n);
    } else if x == 1 + bp_num_nm1 {
        return p_num_nm1 + 1;
    } else if x > 1 + bp_num_nm1 {
        return p_num_nm1 + 1 + dfs(n - 1, x - bp_num_nm1 - 2);
    } else {
        return dfs(n - 1, x - 1);
    }
}
fn main() {
    let nx = read_ints();
    let n = nx[0];
    let x = nx[1];

    println!("{}", dfs(n, x - 1));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    char s; cin >> s;
    if('A'<=s && s<='Z') cout << 'A' << endl;
    else cout << 'a' << endl;
}


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

int main() {
  int64_t N, K;
  cin >> N >> K;

  if (N < K) {
    cout << min(N, K - N) << endl;
    return 0;
  }

  int64_t n = N / K;
  cout << min(N - n * K, (n + 1) * K - N) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
const long long INF = 1LL << 60;

int main() {
  int K, A, B; cin>>K>>A>>B;
  bool dekiru=0;
  for(int i=A; i<=B; i++){
    if(i%K==0){
      dekiru=1;
      break;
    }
  }
  if(dekiru) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int x,y,z;
int main()
{
	cin>>x>>y>>z;
	if(x==y && z!=x) cout<<"Yes";
	else if(x==z && y!=x) cout<<"Yes"; 
	else if(y==z && x!=y) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3128
import math
import fractions
from collections import defaultdict
def trial_division(n):
    #素因数を格納するリスト
    factor = defaultdict(int)
    factor[1] += 1
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor[num] += 1
    #リストが空ならそれは素数
    factor[n] += 1
    return factor
#%%
A,B = [int(x) for x in input().split()]
divisions = trial_division(fractions.gcd(A,B))
print(len(divisions))


Measured memory_bytes: 5048
#include <stdio.h>
#include <stdlib.h>

int main (void) {
  
  char str[64];
  char *p1 = NULL;
  char *p2 = NULL;
  
  int cnt = 0;
  
  
  fgets(str, 64, stdin);
  
  p1 = str;
  
  while(p1 != '\0') {
    int val = 0;
    cnt++;
    p2 = p1;
    p2++;
    *p2 = '\0';
    
    val = (int)strtol(p1, NULL, 10);
	if (val == 0) {
      break;
    }
    p2++;
    p1 = p2;
  }
  
  printf("%d\n", cnt);
  
 return 0; 
}

Measured memory_bytes: 1660
n, m, x = map(int, input().split())

C = []
A = []
for _ in range(n):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])
    
result = -1
for i in range(1 << n):
    t = [0] * m
    c = 0
    for j in range(n):
        if (i >> j) & 1 == 0:
            continue
        c += C[j]
        for k in range(m):
            t[k] += A[j][k]

    if all(l >= x for l in t):
        if result == -1:
            result = c
        else:
            result = min(result, c)
print(result)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, M; cin >> N >> M;
    vec A(N), B(N);
    pairs p(N);
    REP(i, N){
        cin >> A[i] >> B[i];
        p[i] = Pii(A[i], B[i]);
    }
    Sort(p);
    priority_queue<int> que;
    int i0 = 0;
    int ans = 0;
    IREP(i, M){
        while(i0 < N && p[i0].f + i <= M){
            que.push(p[i0].s);
            i0++;
        }
        if(!que.empty()){
            ans += que.top(); que.pop();
        }
    }
    Out(ans);

    return 0;
}


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

int main(){
  int H,W;
  cin >> H >> W;
  char s[60][60];
  int dx[4]={1,-1,0,0};
  int dy[4]={0,0,1,-1};
 
  for(int i=0;i<H;i++)  cin >> s[i];
   
  bool ans=true;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j]=='#'){
      bool found =false;
    
        for(int k=0;k<4;k++){
          int i2=i+dx[k];
          int j2=j+dy[k];
          if(i2>=0 && i2<H && j2>=0 && j2<W && s[i2][j2]=='#'){
            found=true;
          }
        }
        if(!found) ans=false;
      }
    }
  }
  
  cout <<(ans ? "Yes":"No")<<endl;

return 0;
}


Measured memory_bytes: 3580
n, m = map(int, input().split())

begin = 1
end = n
for i in range(m):
    a, b = map(int, input().split())
    if begin < a:
        begin = a
    if b < end:
        end = b

if begin <= end:
    print(end - begin + 1)
else:
    print(0)

Measured memory_bytes: 45144
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <utility>
#include <map>
#include <unordered_map>
#include <string>

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)
#define all(c) begin(c),end(c)
#define vmax(c) *max_element(all(c))
#define vmin(c) *min_element(all(c))
 
template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

template<typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::map<T1, T2>& map)
{
    for (typename std::map<T1, T2>::const_iterator it = map.begin();
         it != map.end();
         ++it)
    {
        out << (*it);
    }
    return out;
}

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 

// 2次元配列を作る
// vector<vi> my_vector(n, vi(m, 0));

// 多次元配列の dump
// for (auto v : my_vector) {
//     cout << v;
// }

ll N;

auto solve() {
    int N, M, C;
    // vi b(M, 0);
    cin >> N >> M >> C;
    vi b(M, 0);

    REP(i, M) {
        cin >> b[i];
    }
    int cnt = 0;

    REP(j, N) {
        ll t = 0;
        REP(i, M) {
            int a;
            cin >> a;
            t = t + b[i] * a;
        }
        if (t + C > 0) {
            ++cnt;
        }
    }
    cout << cnt;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // cout << solve();
}

Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()                        # 破壊的。返り値はNone

# print(N, M)
# print(a)

num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]


dp = [-999 for _ in range(N+1)]
dp[0] = 0
for i in range(N+1):
    n = [dp[i-num[a[j]]] for j in range(M) if i-num[a[j]] >= 0]
    if len(n) > 0:
        dp[i] = max(n) + 1

# print(dp)

i = N
ans = ""
for _ in range(dp[N]):
    # print("i", i)
    # c = [(a[j], dp[i-num[a[j]]], dp[i]) for j in range(M)]
    # print("c", c)
    if dp[i] > 1:
        b = max([a[j] for j in range(M)
                 if i - num[a[j]] >= 0 and dp[i-num[a[j]]] + 1 == dp[i]])
        ans += str(b)
    else:
        b = max([a[j] for j in range(M)
                 if i - num[a[j]] == 0 and dp[i-num[a[j]]] + 1 == dp[i]])
        ans += str(b)
        break
    # print("ans", ans)
    i = i-num[b]
    # print(i)
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	string s;
	cin >> s;
	int n = s.size();
	int b, e;
	repd(i, n) {
		if (s[i - 1] == 'A') {
			b = i;
		}
	}
	rep(i, n) {
		if (s[i] == 'Z') {
			e = i;
		}
	}
	cout << e - b + 2;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=2*min(abs(x[i]),abs(x[i]-k));
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read=lambda:sys.stdin.readline().rstrip()
readi=lambda:int(sys.stdin.readline())
writeln=lambda x:sys.stdout.write(str(x)+"\n")
write=lambda x:sys.stdout.write(x)
a=read();b=read();la,lb=len(a),len(b);r=[]
for i in range(lb):
    r.append(a[i]);r.append(b[i])
if la != lb:
    r.append(a[-1])
print(''.join(r))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

  private static final long MOD = 998244353;
  private static long FACT[];
  private static long IFACT[];

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long A = sc.nextInt();
    long B = sc.nextInt();
    long K = sc.nextLong();
    solve(N, A, B, K);
  }

  private static void solve(int N, long A, long B, long K) {
    FACT = new long[N+1];
    IFACT = new long[N+1];
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i=1; i<=N; i++) {
      FACT[i] = FACT[i-1] * i % MOD;
      IFACT[i] = inv(FACT[i]);
    }

    long ans = 0;
    for (int numA=0; numA<=N; numA++) {
      long rem = K - A*numA;
      if (rem < 0) {
        break;
      }
      int numB = (int)(rem/B);
      if (A*numA+B*numB == K && numB <= N) {
        ans = (ans + comb(N, numA) * comb(N, numB))%MOD;
      }
    }
    System.out.println(ans);
  }

  private static long comb(int n, int r) {
    if (n < 0 || r < 0 || n < r) {
      return 0;
    }
    if (r > n/2) {
      r = n - r;
    }
    return FACT[n]*IFACT[n-r]%MOD*IFACT[r]%MOD;
  }

  private static long inv(long a) {
    long b = MOD;
    long p = 1, q = 0;
    while (b > 0) {
      long c = a / b;
      long d;
      d = a;
      a = b;
      b = d % b;
      d = p;
      p = q;
      q = d - c * q;
    }
    return p < 0 ? p + MOD : p;
  }
}


Measured memory_bytes: 25812
#スペース区切りの整数の入力
N, K = map(int, input().split())

#複数の入力
input_list = input().split( )

counter = 0
for i in range(N):
  if(int(input_list[i])>=K):
    counter = counter + 1
  else:
    counter = counter
print(counter)

Measured memory_bytes: 9992
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int n=gi();
	    String[] S = new String[n];
        //String s=gs();
	    
	    int ac=0;
	    int wa=0;
	    int tle=0;
	    int re=0;
	    for (int i=0; i<n; i++) {
	    	S[i]=gs();
	    	if (S[i].equals("AC")) {
	    		ac++;
	    	} else if (S[i].equals("WA")) {
	    		wa++;
	    	} else if (S[i].equals("TLE")) {
	    		tle++;
	    	} else if (S[i].equals("RE")) {
	    		re++;
	    	}
	    }
        
	    
	    System.out.println("AC x "+ac);
	    System.out.println("WA x "+wa);
	    System.out.println("TLE x "+tle);
	    System.out.println("RE x "+re);
//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static int d(int n) {
		int m=0;
		while(true) {
			if(n<1) {
				break;
			}
			int l= n%10;
			m+=l;
			n= (n-l)/10;
		}
		return m;
	}
	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;
const double PAI = acos(-1);
constexpr long double eps = 1e-9;
map<ll,ll> m;
ll n,a,b,c,d;
ll more(ll r){
    if(r == 0) return 0;
    if(m.count(r)){
        if(m[r] == -1)return infl;
        return m[r];
    }
    m[r] = -1;
    
    ll ret = infl;
    if(ret > (long double)d*(long double)r)ret = d*r;
    if(r%2 ==0){
        ret = min(ret,a+more(r/2));
    }else {
        ret = min({ret,d+a+more((r+1)/2),d+a+more((r-1)/2)});
    }
    if(r%3 == 0){
        ret = min(ret,b+more(r/3));
    }else {
        ret = min({ret,(r%3)*d+b+more(r/3),(3-r%3)*d+b+more(r/3+1)});
    }
    if(r%5 == 0){
        ret = min(ret,c+more(r/5));
    }else{
        ret = min({ret,(r%5)*d+c+more(r/5),(5-r%5)*d+c+more(r/5+1)});
    }
    return m[r] = ret;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int t;
    cin>>t;
    for(int i=0;i<t;++i){
        cin>>n>>a>>b>>c>>d;
        m.clear();
        cout << (ll)more(n) << endl;
    }
    return 0;
}


Measured memory_bytes: 4428
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

void func(){
	int num_of_year,N,type;
	double base_money,rate,maximum = -1,interest,calc,fee;

	scanf("%lf",&base_money);
	scanf("%d",&num_of_year);
	scanf("%d",&N);

	for(int loop = 0; loop < N; loop++){
		scanf("%d %lf %lf",&type,&rate,&fee);

		if(type == 1){
			calc = base_money;

			for(int i = 0; i < num_of_year;i++){
				calc += floor(calc*rate);
				calc -= fee;
			}
			maximum = max(maximum,calc);
		}else{
			calc = base_money;
			interest = 0;

			for(int i = 0; i < num_of_year; i++){
				interest += floor(calc*rate);
				calc -= fee;
			}
			calc += interest;
			maximum = max(maximum,calc);
		}
	}
	printf("%.0lf\n",maximum);
}



int main(){

	int m;

	scanf("%d",&m);

	for(int i = 0; i < m; i++)func();

	return 0;
}

Measured memory_bytes: 2632
n = int(input())
numbers = []

for i in range(n):
    num = int(input())
    numbers.append(num)
max_value = -10**9
min_value = numbers[0]
for i in range(1, n):
    max_value = max(max_value, numbers[i] - min_value)
    min_value = min(min_value, numbers[i])
print(max_value)


Measured memory_bytes: 13592
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() { 
    int a,b;
    cin>>a>>b;
    int d[3]={};
    d[a-1]++;
    d[b-1]++;
    rep(i,3){
      if(d[i]==0) cout<<i+1<<endl;
    }
    

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n, m, v, res;
  char str[16];
  while(scanf("%d%d", &n, &m) && n){
    vector< pair< string, int> >elect(n);
    vector<string>b(m);
    rep(i, n){
      scanf("%s %d", str, &v);
      elect[i] = make_pair(string(str), v);
    }
    rep(i, m){
      scanf("%s", str);
      b[i] = string(str);
    }
    res = 0;
    rep(i, n) rep(j, m){
      bool f = true;
      rep(k, 8){
	if(elect[i].first[k] == '*') continue;
	if(elect[i].first[k] != b[j][k]) f = false;
      }
      if(f) res += elect[i].second;
      //      if(f) printf("%s %s\n", elect[i].first.c_str(), b[j].c_str());
    }
    printf("%d\n", res);
  }
  return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec a(N);
  rep(i, N)cin >> a[i];
  ll ans = 0;
  rep(i, N){
    if(i%2==0 and a[i]%2==1)ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int H, W, K;
	cin >> H >> W >> K;
	VVLL map;
	map.resize(H, VLL(W, 0));
	for (int y = 0; y < H; y++) {
		string S;
		cin >> S;
		for (int x = 0; x < W; x++) {
			if (S[x] == '1')map[y][x] = 1;
		}
	}
	int ans = 10 * 10000;
	for (int code = 0; code < (1 << H); code++) {
		VI rec(10, 0);
		VI ass(H, 0);
		VI c(H, 0);
		for (int i = 0; i < H; i++) {
			if (code & (1 << i))c[i] = 1;
			else c[i] = 0;
		}
		int cur = 0;
		int temp = 0;
		for (int i = 1; i < H; i++) {
			if (c[i] != c[i - 1]) {
				ass[i] = ++cur;
				temp++;
			}
			else ass[i] = ass[i - 1];
		}
		for (int x = 0; x < W; x++) {
			for (int y = 0; y < H; y++) {
				rec[ass[y]] += map[y][x];
			}
			bool flag = false;
			for (int y = 0; y < 10; y++) {
				if (rec[y] > K)flag = true;
			}
			if (flag) {
				temp++;
				for (int y = 0; y < 10; y++)rec[y] = 0;
				for (int y = 0; y < H; y++) {
					rec[ass[y]] += map[y][x];
				}
				flag = false;
				for (int y = 0; y < 10; y++) {
					if (rec[y] > K)flag = true;
				}
				if (flag) {
					temp = -1;
					break;
				}
			}
		}
		if(temp != -1)ans = min(ans, temp);
	}
	cout << ans << "\n";
	return 0;
}


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

int main() {
  int N, s;
  cin >> N;
  vector<int> v(N);
  s = 1;
  
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    a = v.at(i);
    b = v.at(i + 1);
    
    if (a != b) {
      s++;
    }
    
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
vector<long long> A,sum;
int indices[MAX];
int main()
{
    int m;
    long long i,x,n,ans=0;
    scanf("%lld %lld %d",&n,&x,&m);
    A.push_back(x);
    indices[(int)x]=1;
    ans=ans+x;
    for(i=1;i<n;i++)
    {
        x=x*x;
        x=x%m;
        //printf("x=%lld\n",x);
        if(indices[(int) x]) break;
        A.push_back(x);
        indices[(int)x]=i+1;
        ans=ans+x;
    }
    if(i==n)
    {
        printf("%lld",ans);
        return 0;
    }
    long long rem=n-i;
    for(i=indices[(int) x]-1;i<A.size();i++)
    {
        sum.push_back(A[i]);
    }
    for(i=1;i<sum.size();i++)
    {
        sum[i]=sum[i]+sum[i-1];
    }
    long long dd=sum.size();
    dd=rem/dd;
    ans=ans+dd*sum[sum.size()-1];
    dd=sum.size();
    dd=rem%dd;
    if(dd>0)
    {
        ans=ans+sum[(int)(dd-1)];
    }
    printf("%lld",ans);
    return 0;
}


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

int n, a = 0, b = 0, c = 0, d = 0;
string s;
int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s;
        if(s[0] == 'A') a++;
        else if(s[0] == 'W') b++;
        else if(s[0] == 'T') c++;
        else d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

Measured memory_bytes: 3632
import heapq

def func(x):
    return -x

def main():
    N, M = map(int, input().split())
    A = list(map(func, map(int, input().split())))
    heapq.heapify(A)

    for _ in range(M):
        tmp = heapq.heappop(A)
        heapq.heappush(A, -(-tmp//2))

    print(-sum(A))



if __name__ == "__main__":
    main()

Measured memory_bytes: 72216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int K;
    cin >> K;
    vector<int> vec(K);
    for(int i = 0;i < K;i++) {
        cin >> vec.at(i);
    }
    reverse(vec.begin(),vec.end());
    ll Min = 2;
    ll Max = 2;
    bool ret = true;
    if(vec.at(0) != 2) {
        ret = false;
    }
    for(int i = 0;i < K;i++) {
        if(Max / vec.at(i) - (Min - 1) / vec.at(i) == 0) {
            ret = false;
            break;
        }
        else {
            Min = (Min + vec.at(i) - 1) / vec.at(i) * vec.at(i);
            Max = Max / vec.at(i) * vec.at(i) + vec.at(i) - 1;
        }
    }
    if(ret == false) {
        cout << -1 << endl;
    }
    else {
        cout << Min << " " << Max << endl;
    }
}

Measured memory_bytes: 640
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#define LLU long long unsigned int
#define LLD long long double
#define FOR(i,N) for(int i=0;i<(N);i++)
#define Vec vector<int>
#define Vit vector<int>::iterator

using namespace std;


int main()
{

    int cases;
    cin>>cases;

    while(cases--){
    int a,b,c;
    cin>>a>>b>>c;
    int flag=0;
    if((a*a+b*b)==c*c)flag=1;
    else if((b*b+c*c)==a*a)flag=1;
    else if((a*a+c*c)==b*b)flag=1;
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  ll ans = 0;
  ll n = sz(s);
  rep(i, n){
    if(s[i]!='A'&&s[i]!='C'&&s[i]!='G'&&s[i]!='T'){
      continue;
    }
    ll count = 1;
    for (ll j = 1; i + j < n; j++){
      if(s[i+j]=='A'||s[i+j]=='C'||s[i+j]=='G'||s[i+j]=='T'){
        count++;
      }
      else{
        break;
      }
    }
    chmax(ans, count);
  }
  print(ans);
}

Measured memory_bytes: 256
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int n;
  cin >> n;
  int ans;
  if (n & 1) {
    ans = ((n + 1) / 2) * n;
  } else {
    ans = (n / 2) * (n + 1);
  }
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(b/a>c){
			System.out.println(c);
		}else{
			System.out.println(b/a);
		}
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long arr[60];
long long res;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>arr[i];
    }
    for(long long i=1;i<=100000;i++){
        for(long long j=1;j<=n;j++){
            if(arr[j]>=n){
                res += arr[j]/n;
                
                for(long long k=1;k<=n;k++){
                    if(k == j){
                        continue;
                    }
                    arr[k]+=(arr[j]/n);
                }
                arr[j]-=(arr[j]/n)*n;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
// Devarshi

#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

int main(){

sync
int n,m,x,y,xm=INT_MIN,ym=INT_MAX;

cin>>n>>m>>x>>y;
while(n--){
    int a;
    cin>>a;
    xm=max(xm,a);

}
while(m--){
    int a;
    cin>>a;
    ym=min(ym,a);

}
fore(i,xm+1,ym){
if(i>x&&i<=y){
    cout<<"No War";
    return 0;
}
}
cout<<"War";
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
int main()
{	int x,y; cin>>x>>y;
	cout<<(y<=(x+1)/2?"YES":"NO");
	return 0;
}



Measured memory_bytes: 764
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	
	int dp[21000];
	for(int i = 0 ; i < 21000 ; i++) dp[i] = 0;
	
	for(int i = 0 ; i <= A ; i++){
		for(int j = 0 ; j <= B ; j++){
			for(int k = 0 ; k <= C ; k++){
				int n = i*500 + j*100 + k*50;
				if(n > 20000) continue;
				dp[n]++;
			}
		}
	}
	
	cout << dp[X] << endl;

	return 0;
}


Measured memory_bytes: 384
n,a,b = map(int,input().split())
if a == b:
    print(0)
    exit()
if abs(a-b)%2 == 0:
    print(abs(a-b)//2)
    exit()
if a < b:
    l,r = b-1,n-a
    ans = min(l,r)
    if ans == l:
        b = b-(a-1)
        if b%2==1:
            print(a-1+(b-1)//2)
        else:
            print(a-1+(b-1)//2+1)
    else:
        a = a+(n-b)
        if abs(n-a)%2==0:
            print(n-b+abs(n-a)//2)
        else:
            print(n-b+abs(n-a)//2+1)
else:
    l,r = a-1,n-b
    ans = min(l,r)
    if ans == l:
        a = a-(b-1)
        if a%2==1:
            print(b-1+(a-1)//2)
        else:
            print(b-1+(a-1)//2+1)
    else:
        b = b+(n-a)
        if abs(n-b)%2==0:
            print(n-a+abs(n-b)//2)
        else:
            print(n-a+abs(n-b)//2+1)

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

void Main()
{
    long n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<long> b(n+1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++)
    {
        b[i+1] = b[i] + a[i];
    }
    
    int ok = 1, ng = 200002;
    while (abs(ok - ng) > 1) { // ok: 幸福度がok以上の、握手の回数がm回未満
        int mid = (ok + ng)/2;
        long hand = 0;
        for (int i = 0; i < n; i++)
        {
            hand += lower_bound(a.begin(), a.end(), mid-a[i]-1) - a.begin();
        }
        if (n*n - hand >= m) ok = mid;
        else ng = mid;
        // cout << "ok:" << ok << " ng: " << ng << " hand: " << n*n - hand << endl;
    }
    long ans = 0;
    long sum = 0;
    for (int i = 0; i < n; i++)
    {
        long ind = lower_bound(a.begin(), a.end(), ok-a[i]-1) - a.begin();
        sum += n - ind;
        // cout << n-ind << endl;
        ans += b[n]-b[ind]+a[i]*(n-ind);
    }
    // cout << sum << endl;
    if (sum != 0) ans -= (ok-1)*(sum-m);
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 4492
import Data.List

distance::(Int,Int)->(Int,Int)-> Int
distance (x,y)(a,b)= (abs (x-a))+(abs (y-b))

ord::(Int,Int)->(Int,Int)->Ordering
ord (_,x)(_,y) = if x == y then  EQ else if x <= y then LT else GT

one_solver::(Int,Int)->[(Int,(Int,Int))]->Int
one_solver x chs = let id_dist = map (\(i,c)->(i,distance x c)) chs in
                   let (this,_) = head (sortBy ord id_dist) in
                   this

solver::[(Int,Int)]->[(Int,Int)]->[Int]
solver stu chs = let id_with = zip [1..] chs in
                 map (\x -> one_solver x id_with) stu

printer::[Int]->IO()
printer []= return ()
printer (x:xs)= do
  print x
  printer xs

getter::Int->IO([(Int,Int)])
getter 0 = return []
getter n = do
  xyc<-getLine
  let x:y:[]=map read (words xyc)
  rest<-getter (n-1)
  return ((x,y):rest)

main::IO()
main=do
  nmc<-getLine
  let n:m:[]= map read (words nmc)
  stu<-getter n
  chs<-getter m
  printer (solver stu chs)

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char s[110];
  int a = 1;
  
  cin >> n >> s;
  if(n%2 == 0) {
    for(int i=0; i<n/2; i++) {
      if(s[i] != s[n/2 + i]) {
        a = 0;
      }
    }
  }
  else {
    a = 0;
  }
  if (a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n, k, pos, sum = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> pos;
        if(pos < k - pos){
            sum += pos * 2;
        }else{
            sum += (k - pos) * 2;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int N;
char T[200000+2];
int main(){
  int i;
  N = rd(T);
  for(i=(0);i<(N);i++){
    if(T[i]=='?'){
      if(i && T[i-1] == 'P'){
        T[i] = 'D';
        continue;
      }
      if(T[i+1]=='?' || T[i+1]=='D'){
        T[i] = 'P';
        continue;
      }
      T[i] = 'D';
    }
  }
  wt_L(T);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N;
// char T[2d5+2];
// {
//   rd(T@N);
//   rep(i,N) if(T[i]=='?'){
//     if(i && T[i-1] == 'P'){
//       T[i] = 'D';
//       continue;
//     }
//     if(T[i+1]=='?' || T[i+1]=='D'){
//       T[i] = 'P';
//       continue;
//     }
//     T[i] = 'D';
//   }
//   wt(T);
// }


Measured memory_bytes: 4212
#include<iostream>
using namespace std;
int main()
{
	int H, A;
	cin >> H >> A;
	if ((H > 0 && H <= 10000) && (A > 0 && A <= 10000))
	{
		if (H % A == 0)
			cout << H / A << endl;
		else
			cout << H / A + 1 << endl;
	}
	else
		cout << "Wrong inputs" << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool possible = false;
  for (int i = 1; i <= 9; ++i) {
    if (n % i == 0 && n / i <= 9)
      possible = true;
  }
  cout << (possible ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
using var = long long;
#define rep(i,n) for(var i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<var> a(n);rep(i,n){cin>>a[i];}
#define in(a) var a;cin>>a;
#define out(a) cout<<a;

int main()
{
	in(a);
	in(b);
	out(max({ a + b,a - b,a * b }));
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Mirio
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FReader in = new FReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int     n;
        int[][] g;
        int[][] dp;

        public void solve(int testNumber, FReader in, PrintWriter out) {
            n = in.nextInt();
            g = new int[2][n];
            dp = new int[2][n];

            for(int i = 0; i < 2; ++i) {
                for(int j = 0; j < n; ++j)
                    g[i][j] = in.nextInt();

                Arrays.fill(dp[i], -1);
            }

            out.println(solve(0, 0));
        }

        private int solve(int i, int j) {
            if(j == n - 1 && i == 1)
                return g[i][j];
            if(dp[i][j] >= 0)
                return dp[i][j];

            int ans = 0;
            if(i + 1 < 2) ans = Math.max(ans, solve(i + 1, j));
            if(j + 1 < n) ans = Math.max(ans, solve(i, j + 1));

            return dp[i][j] = ans + g[i][j];
        }

    }

    static class FReader {
        private BufferedReader  r;
        private String          line;
        private StringTokenizer st;
        private String          token;

        public FReader() {
            this(System.in);
        }

        public FReader(InputStream i) {
            r = new BufferedReader(new InputStreamReader(i));
        }

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

        private String peekToken() {
            if(token == null)
                try {
                    while(st == null || !st.hasMoreTokens()) {
                        line = r.readLine();
                        if(line == null) return null;
                        st = new StringTokenizer(line);
                    }
                    token = st.nextToken();
                } catch(IOException e) { }
            return token;
        }

        private String nextToken() {
            String ans = peekToken();
            token = null;
            return ans;
        }

    }
}



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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, m; cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    vector<bool> is(n, true);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--, b--;
        if (h[a] >= h[b]) is[b] = false;
        if (h[a] <= h[b]) is[a] = false;
    }
    cout << count(is.begin(), is.end(), true) << endl;
    return 0;
}


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

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

  string S; cin >> S;
  ll d = S.size();
  int K; cin >> K;

  vector<vector<ll>> eq(d, vector<ll>(5, 0));
  vector<vector<ll>> lt(d, vector<ll>(5, 0));

  eq[0][1] = 1;
  lt[0][1] = S[0] - '0' - 1;
  lt[0][0] = 1;

  for (ll i = 1; i < d; i++) {
    int temp = S[i] - '0';
    if (temp == 0) {
      for (ll k = 0; k < 4; k++) {
        eq[i][k] += eq[i - 1][k];
      }
    } else {
      for (ll k = 0; k < 4; k++) {
        eq[i][k + 1] += eq[i - 1][k];
        lt[i][k + 1] += eq[i - 1][k] * max(0, temp - 1);
      }
      for (ll k = 0; k < 4; k++) {
        lt[i][k] += eq[i - 1][k];
      }
    }

    for (ll k = 0; k < 4; k++) {
      lt[i][k + 1] += lt[i - 1][k] * 9;
      lt[i][k] += lt[i - 1][k];
    }
  }

  
  cout << (eq[d - 1][K] + lt[d - 1][K]) << '\n';
  return 0;
}

Measured memory_bytes: 256