akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max();
const ll INFLL = numeric_limits<ll>::max();

signed main() {
    int L;
    cin >> L;
    vector<ll> A(L + 1);
    for (int i = 1; i <= L; i++) cin >> A[i];
    vector<vector<ll>> dp(L + 1, vector<ll>(5, INFLL));
    dp[0][0] = 0;
    auto transition = [&](int now) {
        for (int i = 0; i < 5; i++) {
            ll temp = A[now];
            if (i == 1 || i == 3) {
                temp = (A[now] % 2 == 1);
                if (A[now] == 0) temp = 2;
            }
            if (i == 2) temp = (A[now] % 2 == 0);
            for (int j = 0; j <= i; j++) {
                if (dp[now - 1][j] == INFLL) continue;
                dp[now][i] = min(dp[now][i], dp[now - 1][j] + temp);
            }
        }
    };
    for (int i = 1; i <= L; i++) transition(i);
    /*
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j <= L; j++) {
            cout << (dp[j][i] == INFLL ? -1 : dp[j][i]) << " ";
        }
        cout << endl;
    }
     */
    ll ans = INFLL;
    for (int i = 0; i < 5; i++) ans = min(ans, dp[L][i]);
    cout << ans << endl;
}


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

int main() {
    string S;
    cin >> S;
    int ans = 0;
    if(S[0] == '2') {
        ans++;
    } 
    if(S[1] == '2') {
        ans++;
    }
    if(S[2] == '2') {
        ans++;
    }
    if(S[3] == '2') {
        ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
  Main() {
    try (Scanner sc = new Scanner(System.in)) {
      int N = sc.nextInt();
      ArrayList<HashMap<Integer, TreeSet<Integer>>> list = new ArrayList<>(16);
      for (int i = 0;i < 16;++ i) list.add(new HashMap<>(N));
      final int[] dx = {1, 1, 0, -1, -1, -1, 0, 1}, dy = {0, 1, 1, 1, 0, -1, -1, -1};
      int ans = Integer.MAX_VALUE;
      while(N --> 0) {
        int X = sc.nextInt(), Y = sc.nextInt();
        int d = getDirection(sc.next().charAt(0));
        for (int i = -1;i <= 1;++ i) {
          final int addLine = (d + i + 12) % 8;
          final int addKey = X * dy[addLine] - Y * dx[addLine], addValue = X * dx[addLine] + Y * dy[addLine];
          list.get((i * d & 2) * 4 + addLine).compute(addKey, (k, v) -> {
            if (v == null) v = new TreeSet<>();
            v.add(addValue);
            return v;
          });
          final int getLine = (d + i + 8) % 8;
          final int getKey = X * dy[getLine] - Y * dx[getLine], getValue = X * dx[getLine] + Y * dy[getLine];
          TreeSet<Integer> set = list.get((i * (d + 2) & 2) * 4 + getLine).get(getKey);
          if (set == null) continue;
          Integer dist = set.higher(getValue);
          if (dist != null) ans = Math.min(ans, (dist - getValue) * 5);
        }
      }
      if (ans == Integer.MAX_VALUE) System.out.println("SAFE");
      else System.out.println(ans);
    }
  }
  private static int getDirection(char U) {
    return U == 'R' ? 0 : U == 'U' ? 2 : U == 'L' ? 4 : 6;
  }
  public static void main(String[] args) {
    new Main();
  }
}


Measured memory_bytes: 210120
N, X, Y = map(int, input().split())
Graph = [[] for _ in range(N)]
for i in range(N):
    if i < N - 1:
        Graph[i].append(i + 1)
        Graph[i + 1].append(i)
    if X == i:
        Graph[X - 1].append(Y - 1)
        Graph[Y - 1].append(X - 1)
# print(Graph)
ans = [0] * (N - 1)
from collections import deque, Counter

for i in range(N):
    dist = [-1] * N
    que = deque([i])
    dist[i] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in Graph[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)
    # print(dist)
    dist_Counter = Counter(dist)
    for key, val in dist_Counter.items():
        if key != 0:
            ans[key - 1] += val

for a in ans:
    print(a // 2)


Measured memory_bytes: 74332
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}
//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h,w,n;
    cin>>h>>w>>n;
    
    ll maxi=max(h,w),total=0,c=0;
    rep(i,min(h,w)){
        total+=maxi;
        c++;
        if(total>=n) break;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
bool app[1000005];
int s;
int f(int x){
	if(x & 1) return 3 * x + 1;
	return x >> 1;
}
int main(){
	scanf("%d",&s);
	app[s] = true;
	int n = 1;
	app[s] = true;
	while(true){
		n++;
		s = f(s);
		if(app[s]){
			printf("%d\n",n);
			return 0;
		}
		app[s] = true;
	}
	return 0;
}


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

std::string S;
int d1 = 5;
int d2 = 7;
int e1 = 5;
int e2 = 6;
int len = 0;

bool parse(int i) {
    if(i >= len) return true;

    if(S[i] == 'd') {
        if(S.substr(i, d1) == "dream") {
            bool r1 = parse(i + d1);
            if(r1) {
                return true;
            } else if(S.substr(i, d2) == "dreamer") {
                bool r2 = parse(i + d2);
                if(r2) {
                    return true;
                }
            }
        }
    } else if(S[i] == 'e') {
        if(S.substr(i, e1) == "erase") {
            bool r3 = parse(i + e1);
            if(r3) {
                return true;
            } else if(S.substr(i, e2) == "eraser") {
                bool r4 = parse(i + e2);
                if(r4) {
                    return true;
                }
            }
        }
    }
    return false;
}

int main() {
    std::cin >> S;
    len = S.length();

    bool res = parse(0);
    if(res) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

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

int n;
string s;
long long f(int state) {
  vector<char> red, blue;
  for (int i=0; i<n; i++) {
    if ((state >> i) & 1) {
      red.push_back(s[i]);
    } else {
      blue.push_back(s[i]);
    }
  }
  int rest_red = n - red.size();
  int rest_blue = n - blue.size();
  long long dp[rest_red+1][rest_blue+1];
  for (int i=0; i<rest_red+1; i++) {
    for (int j=0; j<rest_blue+1; j++) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for (int i=2*n-1; i>=n; i--) {
    int num = 2*n - i;
    for (int j=max(num-rest_blue,1); j<=min(rest_red, num); j++) {
      if (s[i] == blue[j-1]) {
        dp[j][num-j] += dp[j-1][num-j];
      }
    }
    for (int j=max(num-rest_red, 1); j<=min(rest_blue, num); j++) {
      if (s[i] == red[j-1]) {
        dp[num-j][j] += dp[num-j][j-1];
      }
    }
  }
  return dp[rest_red][rest_blue];
}
int main() {
  cin>>n>>s;
  long long ans = 0;
  for (int i=0; i<(1<<n); i++) {
    ans += f(i);
  }
  cout<<ans<<endl;
}

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

template<typename T>
T mid(T a, T b, T c){
    return (a + b + c - max({a, b, c}) - min({a, b, c}));
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(mid(a, b, c) == c)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		long a = Long.parseLong(sc.get());
		long b = Long.parseLong(sc.get());
		long c = Long.parseLong(sc.get());
		long d = Long.parseLong(sc.get());
		var max = Math.max(a * c, Math.max(a * d, Math.max(b * c, b * d)));
		if (a * b < 0 || c * d < 0) max = Math.max(max, 0);
		System.out.println(max);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 32688
let () =
  let is_nonzero = function
      1|2|3|4|5|6|7|8|9 -> true
      | _ -> false in
  let is_digit = function
      0 -> true
    | i when is_nonzero i -> true
    | _ -> false in
  let get_num s =
    let maxlen = String.length s in
    let rec loop idx len n = function
        i when i = maxlen -> if len <> 0 then (int_of_string (String.sub s idx len))::n else n
      | i ->
         let c = Char.code(s.[i])-48 in
         if len = 0 then
           if is_nonzero(c) then
             loop i 1 n (i+1)
           else
             loop idx len n (i+1)
         else
           if is_digit(c) then
             loop idx (len+1) n (i+1)
           else
             loop 0 0 ((int_of_string (String.sub s idx len))::n) (i+1)
    in loop 0 0 [] 0
  in
  let rec read sum =
    try let line = read_line () in
        let n = get_num line in
        if List.length n > 0 then
          read (sum + (List.fold_left (+) 0 n))
        else
          read sum
    with End_of_file ->
      Printf.printf "%d\n" sum
  in read 0
;;

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

int main(){
  int n, m, p;
  while(cin >> n >> m >> p, n || m || p){
    m--;
    vector<int> v(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
      cin >> v[i];
      sum += v[i]; 
    }
    sum *= 100 - p;
    
    if(v[m] == 0)cout << 0 << endl;
    else cout << sum / v[m] << endl;
  }
}

Measured memory_bytes: 3052
N, K = map(int, input().split())
A = list(map(int, input().split()))

MAX_DIGIT_LENGTH=50

dp=[[-1 for _ in range(2)] for _ in range(100)]
dp[0][0]=0

for d in range(MAX_DIGIT_LENGTH):
  mask=1<<((MAX_DIGIT_LENGTH-1)-d)
  
  tmp=0
  for a in A:
    if a&mask == mask:
      tmp+=1
      
  cost0=mask*tmp
  cost1=mask*(N-tmp)
    
  if dp[d][1]!=-1:
    dp[d+1][1]=max(dp[d][1]+max(cost0, cost1), dp[d+1][1])
  
  if dp[d][0]!=-1:
    if K&mask == mask:
      dp[d+1][1]=max(dp[d][0]+cost0, dp[d+1][1])
      dp[d+1][0]=max(dp[d][0]+cost1, dp[d+1][0])
    else:
      dp[d+1][0]=max(dp[d][0]+cost0, dp[d+1][0])
      
print(max(dp[MAX_DIGIT_LENGTH][0], dp[MAX_DIGIT_LENGTH][1]))

Measured memory_bytes: 14620
#include <bits/stdc++.h>
using namespace std;
int pd[410],u[110000],v[110000],n,m;
bitset<410>A[410],x[110000],ans,y[110000];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i = 1; i <= m; i ++) scanf("%d%d",&u[i],&v[i]);
	for (int i = 1; i <= n; i ++) A[i][i]=1;
	for (int i = m; i; i --)
	{
		x[i] = A[u[i]];
		y[i] = A[v[i]];
		A[u[i]] |= A[v[i]];
		A[v[i]] = A[u[i]];
	}
	int num = 0;
	for (int i = 1; i <= m; i ++)
		for (int j = 1; j <= n; j ++)
			if (x[i][j] && y[i][j]) pd[j]=1;
	for (int i = 1; i <= n; i ++)
	{
		ans = 0; 
		if (pd[i]) continue;
		for (int j = 1; j <= m; j ++)
		{
			if (x[j][i]) ans |= y[j];
			if (y[j][i]) ans |= x[j];
		}
		for (int j = i + 1; j <= n; j ++) 
			if (!ans[j] && !pd[j]) num ++;
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 13056
import java.util.Scanner;

public class Main {
    public int operateNot(int x) {
        if (x == 0) return 1;
        else return 0;
    }

    public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();

        int answer = solution.operateNot(x);
        System.out.println(answer);
    }
}


Measured memory_bytes: 35604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string s;
    cin >> s;
    int len = s.size() - 2;
    for(int i = len; i > 0; i-=2){
        if(s.substr(0, i/2) == s.substr(i/2, i/2)){
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);  //递归求最大公约数
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);    //递归求最小公倍数
}
int main()
{
    ll a,b;
    while(cin >> a >> b)
    {
        cout << gcd(a,b)<< " "<<lcm(a,b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstring>

int main(){
    int n, m;
    while(std::cin >> n >> m, n || m){
        
        int vote[100];
        memset(vote, 0, 100*sizeof(int));
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                int ans;
                std::cin >> ans;
                vote[j] += ans;
            }
        }

        int rank[100];
        for(int i=0; i<m; i++){
            int max_i = 0;
            for(int j=0; j<m; j++){
                if(vote[j] > vote[max_i]){
                    max_i = j;
                }
            }
            rank[i] = max_i+1;
            vote[max_i] = -1;
        }
        
        for(int i=0; i<m; i++){
            std::cout << rank[i];
            if(i == m-1){
                std::cout << std::endl;
            }
            else{
                std::cout << ' ';
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()
n = len(s)
ans = 0

dp1 = [999999999999999999] * (n+1)
dp2 = [999999999999999999] * (n+1)

# dp1[i] = 上からi桁目までピッタリ払った最小コスト
# dp2[i] = 上からi桁目を1多く払った最小コスト

dp1[0] = 0
dp2[0] = 1

for i,c in enumerate(s):
    a = int(c)

    dp1[i+1] = min(dp1[i]+a, dp2[i]+a+1)
    dp2[i+1] = min(dp1[i]+a+1, dp2[i]+(10-a-1), dp2[i]+a+2)

print(min(dp1[n], dp2[n]+1))


Measured memory_bytes: 69356
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[200010];
int main(){
    int n, x,y, m, k;
    while(cin>>n){
        int ans=0, mn=200010;
        for(int i=0; i<n; ++i){
            cin>>a[i];
            if(a[i]<mn){
                ++ans;
            }
            mn=min(mn, a[i]);
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 1024
N = int(input())
P = []
for i in range(N):
  P.append(int(input()))
Sum = 0
k = 0
for i in range(N):
  if max(P) == P[i] and k==0:
    Sum += P[i]/2
    k+=1
  else:
    Sum += P[i]
print(int(Sum))


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;
const ll MOD = 1e9+7;

ll modpow(ll n, int m){
	ll ret=1;
	if( m < 0 ) m = MOD-1 + m;
	for(int i=1; i<=m; i<<=1){
		if( m&i ) ret = ret * n % MOD;
		n = n*n % MOD;
	}
	return ret;
}

struct pl3{
	ll x, y, z;
	pl3(ll i){
		x = y = z = i;
	}
	pl3(ll _x, ll _y, ll _z){
		x = _x;
		y = _y;
		z = _z;
	}
};

vector<int> child[200005];
vector<pl3> dfs(int n){
	vector<pl3> ret;
	int mx = 0;
	for(auto t: child[n]){
		auto v = dfs(t);
		if(v.size() > ret.size()) swap(v, ret);
		int rn = ret.size() - v.size();
		rep(i,(int)v.size()){
			auto cur = ret[rn+i];
			ret[rn+i].x = (cur.x * v[i].x)%MOD;
			ret[rn+i].y = ( (cur.x * v[i].y)%MOD + (cur.y * v[i].x)%MOD )%MOD;
			ret[rn+i].z = ( (cur.y * v[i].y)%MOD
					+ (cur.z * v[i].x)%MOD + (cur.z * v[i].y)%MOD
					+ (cur.x * v[i].z)%MOD + (cur.y * v[i].z)%MOD + (cur.z * v[i].z)%MOD )%MOD;
		}
		chmax<int>(mx, v.size());
	}
	rep(i,mx){
		int pos = ret.size() - i - 1;
		auto &t = ret[pos];
		t.x = (t.x + t.z)%MOD;
		t.z = 0;
	}
	ret.emplace_back(1, 1, 0);
	return ret;
}


ll d[200005];
void count(int n, int p){
	d[p]++;
	for(auto t: child[n]){
		count(t, p+1);
	}
}

int main(){
	//ios_base::sync_with_stdio(false);
	int N;
	int p[200005];

	cin >> N;
	rep(i,N){
		cin >> p[i+1];
		child[p[i+1]].push_back(i+1);
	}

	count(0,0);

	auto ret = dfs(0);
	reverse(all(ret));

	ll ans = 0;
	rep(i, (int)ret.size()){
		auto &t = ret[i];
		ll sum = modpow(2, N+1-d[i]);
		ans = (ans + (t.y * sum)%MOD) % MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 45424
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <cmath>
#include <bitset>
#include <queue>
#define enter putchar('\n')
#define space putchar(' ')
//#define ivorysi
#define pb push_back
#define mo 974711
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define MAXN 200005
#define eps 1e-12
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 - '0' + c;
	c = getchar();
    }
    res = res * f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
char s[MAXN];
int N,K,p = 1,num[MAXN],cnt,st;
void Solve() {
    read(N);read(K);
    scanf("%s",s + 1);
    for(int i = 1 ; i <= N ; ++i) num[i] = s[i] - 'A';
    st = num[1];
    while(K--) {
	if(st == 0) {st ^= 1;num[p] ^= 1;}
	else {
	    ++p;++cnt;
	    st = num[p];
	    st ^= (cnt & 1);
	}
	if(p > N) break;
    }
    if(p <= N) {
	for(int i = p ; i <= N ; ++i) putchar('A' + (num[i] ^ (cnt & 1)));
	int t = N - (N - p + 1),c = (cnt - 1) & 1;
	while(t--) {
	    putchar('A' + c);
	    c ^= 1;
	}
    }
    else {
	if((cnt - 1) & 1) {
	    for(int i = 1 ; i <= N ; ++i) putchar('A' + (i & 1));
	}
	else {
	    putchar('A' + (K & 1));
	    for(int i = 1 ; i < N ; ++i) putchar('A' + (i & 1));
	}
    }
    enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 1408
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int w=sc.nextInt();
        int n=sc.nextInt();
        int[] values=new int[w];
        for(int i=0;i<values.length;i++){
            values[i]=i+1;
        }
        for(int i=0;i<n;i++){
            String str=sc.next();
            String[] ab=str.split(",");
            int a=Integer.parseInt(ab[0])-1;
            int b=Integer.parseInt(ab[1])-1;
            int c=values[a];
            values[a]=values[b];
            values[b]=c;
        }
        for(int i=0;i<values.length;i++){
            System.out.println(values[i]);
        }
    }
}


Measured memory_bytes: 26064
r,g,b,n=map(int,input().split())
s = [r,g,b]
s.sort(reverse=True)
r,g,b=s[0],s[1],s[2]
"""
if r==1 and g == 1 and b==1:
    print(4504501)
    exit()
"""
cnt=0
for i in range(0,n//r+1):
    m = n - i*r
    for j in range(0,m//g+1):
        l = m - j*g
        if l%b==0:
            cnt+=1
print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  string s;
  cin >> s;
  rep(i,sz(s)) {
    s[i] = 'x';
  }
  cout << s << endl;
  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		List<Integer> rows = new ArrayList<>();
		List<Integer> columns = new ArrayList<>();
		boolean flag = true;

		while (true) {
			int hor = scanner.nextInt();
			int ver = scanner.nextInt();
			if (hor == 0 && ver == 0) {
				break;
			}
			if (hor >= 1 && ver >= 1 && hor <= 300 && ver <= 300) {
				rows.add(hor);
				columns.add(ver);
			} else {
				flag = false;
				break;
			}
		}
		if (flag == true) {
			for (int i = 0; i < rows.size(); i++) {
				for (int r = 0; r < rows.get(i); r++) {
					for (int c = 0; c < columns.get(i); c++) {
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}
		}
	}
}

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

ll nibun_tansaku(ll x){
  ll left = 0;
  ll right = 45000;
  ll key = x;
  while(right - left > 1){
    ll mid = (left + right) / 2;
    ll mid_num = mid * (mid + 1) / 2;
    ll right_num = right * (right + 1) / 2;
    ll left_num = left * (left + 1) / 2;
    if(mid_num <= key ){
      left = mid;
    }else{
      right = mid;
    }
  }
  return left+1;
}

int main() {
  ll x;
  cin >> x;
  ll time = nibun_tansaku(x);
  ll ans = time;
  if(time * (time-1) / 2 == x){
    cout << time - 1 << endl;
    return 0;
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x;
    int n;
    cin >> x >> n;
    vector<ll> h(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
        sum += h[i];
    }

    cout << (sum >= x ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 1024
#define MOD 1000000007
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int N;
unordered_map<int, queue<int>> A;
vector<bool> history;
vector<int> day_list;

int day(int i, int enemy) {
    if (history[enemy]) return true;
    history[enemy] = true;
    int enemy2 = A[enemy].front();
    while (enemy2 != i) {
        if (day(enemy, enemy2)) return true;
        A[enemy].pop();
        enemy2 = A[enemy].front();
    }
    A[enemy].pop();
    history[enemy] = false;
    int ans = max(day_list[i], day_list[enemy]) + 1;
    day_list[i] = day_list[enemy] = ans;
    return false;
}

int main() {
    cin >> N;
    history = vector<bool>(N + 1, false);
    day_list = vector<int>(N + 1);
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N - 1; j++) {
            int a; cin >> a;
            A[i].push(a);
        }
    }
    int ans;
    for (auto p : A) {
        int i = p.first;
        queue<int> &enemy = p.second;
        history[i] = true;
        while (enemy.size()) {
            if (day(i, enemy.front())) {
                cout << -1 << endl;
                return 0;
            }
            enemy.pop();
        }
    }
    cout << *max_element(day_list.begin(), day_list.end()) << endl;
}


Measured memory_bytes: 4608
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    a,b,c = map(int, readline().split())

    if c > a + b:
        if c**2 + a**2 + b**2 - 2*a*c - 2*b*c + 2*a*b > 4*a*b:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

long solve(int n)
{
  std::vector<long> counts(n + 1, 1);

  for (int i = 2; i <= n; ++i) {
    for (int j = i; j <= n; j += i) {
      ++counts[j];
    }
  }

  long result = 0;
  for (int i = 1; i <= n; ++i) {
    result += i * counts[i];
  }
  return result;
}

int main()
{
  int n;
  std::cin >> n;

  std::cout << std::setprecision(20);
  std::cout << solve(n) << std::endl;
}


Measured memory_bytes: 81340
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	aa := make([]int64, n*3)
	var hl, hr IntHeap
	var suml, sumr int64
	heap.Init(&hl)
	heap.Init(&hr)
	for i := 0; i < n*3; i++ {
		aa[i] = getNextInt64(scanner)
	}

	sum := make([]int64, n+1)
	for i := 0; i < n; i++ {
		suml += aa[i]
		heap.Push(&hl, aa[i])
		sumr += -aa[i+n*2]
		heap.Push(&hr, -aa[i+n*2])
	}

	sum[0] = suml
	sum[n] = sumr
	for i := 0; i < n; i++ {
		heap.Push(&hl, aa[i+n])
		pl := heap.Pop(&hl).(int64)
		suml = suml + aa[i+n] - pl
		sum[i+1] += suml
		heap.Push(&hr, -aa[n*2-1-i])
		pr := heap.Pop(&hr).(int64)
		sumr = sumr - aa[n*2-1-i] - pr
		sum[n-i-1] += sumr
	}

	var ans int64
	ans = int64(1e15+1) * -1
	for i := 0; i < n+1; i++ {
		if ans < sum[i] {
			ans = sum[i]
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

// An IntHeap is a min-heap of ints.
type IntHeap []int64

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int64))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 11136
// #7393210

#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;
static const int MAX = 100005;


int N;
vector<int> S;


void printvec(vector<int> V) {
  rep(i, V.size()) {
    cout << V[i] << " ";
  }
  cout << endl;
}

int main(){
  cin >> N;
  int M = (1 << N );

  rep(i, M) {
    int s; cin >> s;
    S.push_back(s);
  }
  sort(S.begin(), S.end(), greater<lli>());
  // vector<int>::iterator itr = S.begin();
  // int root = *itr; S.erase(itr);
  vector<int> V(N+1,0); V[0] = 1;
  rep(i,N-1) V[i+1] = 0;
  rep(i,N) {
    for(int j = N; j > 0; j--) {
      V[j] += V[j-1];
    }
  }
  vector<lli> nm(M,0);
  vector<bool> used(M, false), usn(M,false);
  used[0] = true;
  rep(i, N) {
    lli nx = 0;
    rep(j, M) {
      if (used[j]) {
        while(nx >= M || S[nx] >= S[j] || used[nx]) {
          nx++;
          if (nx >= M ) {
            cout << "No" << endl;
            return 0;
          }
        }
        usn[nx] = true;
        usn[j] = true;
        nx++;
      }
    }
    swap(usn, used);
  }
  // printvec(V);
  // cout << "\n S : ";
  // printvec(S);

  // int sum = 0;
  // rep(i,N) sum += V[i+1];
  // cout << "Kakunin:" << sum << endl;

  // int idx = -1;
  // for(int i = N; i > 0; i-- ){
  //   idx += V[i];
  //   // cout << root - S[idx] << endl;
  //   if ( root - S[idx] < i ) {
  //     cout << "No" << endl;
  //     return 0;
  //   }
  // }
  // int idx = -1;
  // rep(i, N) {
  //   idx += V[i];
  //   if (S[idx] > root - (i+1)) {
  //     cout << "No" << endl;
  //     return 0;
  //   }
  // }
  cout << "Yes" << endl;
}

/*
3
5 6 1 2 1000000 999999 8 999999

*/


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;


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

bool ori(int x){
  if(x>2&&x%2==0){
    return false;
  }
  for(int i=2;i<=sqrt(x);i++){
    if(x%i==0){
      return false;
    }
  }
  return true;
}

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


Measured memory_bytes: 3056
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


// 
int n;
vector<string> w;

bool check()
{
	char last = ' ';
	map<string, string> m;

	rep(i, n)
	{
		if ( last != ' ' )
		{
			if ( last != w[i][0] ) return false;
		}

		last = w[i][w[i].length() - 1];

		if ( m.count(w[i]) != 0 ) return false;

		m.insert(make_pair(w[i], w[i]));
	}

	return true;
}

int main()
{
	cin >> n;

	rep(i, n)
	{
		string s;
		cin >> s;
		w.pb(s);
	}

	if ( check() )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    bool flag[4] = {};
    for(int i = 0;i < 4;i++)
    {
        int n;
        cin >> n;
        if(n == 1)
        {
            flag[0] = true;
        }
        else if(n == 9)
        {
            flag[1] = true;
        }
        else if(n == 7)
        {
            flag[2] = true;
        }
        else if(n == 4)
        {
            flag [3] = true;
        }
    }
    for(int i = 0;i < 4;i++)
    {
        if(!flag[i])
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";

    return 0;
}

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

int main(){
 string S;
  cin >> S;
  int n=4;
  for(int i=0;i<4;i++){
    if(S[i]=='-'){
      n -=2;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<ll> a(n);
    REP(i,n) cin>>a[i];
    map<ll, ll> nums;
    ll sum=0;
    nums[sum]++;
    REP(i,n){
        sum += a[i];
        nums[sum%m]++;
    }
    ll res = 0;
    for(auto x : nums){
        res += x.second * (x.second-1)/2;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,ans=0,pr=1;
    cin>>n;
    while(n>0)
    {
        n/=2;
        ans+=pr;
        pr*=2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

void solve (int n)
{
    int c, k;
    cin >> c >> k;
    vi t(n);
    forn (i, n)
        cin >> t[i];
    sort(all(t));

    int ans = 0;
    for (int i = 0; i < n; )
    {
        ans++;
        int j = i;
        int curc = c;
        while (j < n && curc > 0 && t[j] <= t[i] + k)
            j++, curc--;
        i = j;
    }

    cout << ans << endl;
}

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

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 640
def solve():
	from collections import deque
	n,*t=map(int,open(0).read().split())
	con=[[] for _ in range(n)]
	dist_f_k=[0]*n
	l1,l2=t[:3*n-3],t[3*n-1:]

	for a,b,c in zip(*[iter(l1)]*3):
		con[a-1].append((b-1,c))
		con[b-1].append((a-1,c))

	k=t[3*n-2]
	que=deque([k-1])
	while que:
		cur=que.popleft()
		for nxt,dd in con[cur]:
			if dist_f_k[nxt]==0 and nxt!=k-1:
				que.append(nxt)
				dist_f_k[nxt]=dist_f_k[cur]+dd

	for x,y in zip(*[iter(l2)]*2):
		print(dist_f_k[x-1]+dist_f_k[y-1])
		
if __name__=="__main__":
	solve()

Measured memory_bytes: 64180
S = input().split()
A = int(S[0])
B = int(S[1])
R = -1
for i in range(1009):
  #print(i+1)
  j = i + 1
  AMTA = int(j * 0.08)
  AMTB = int(j * 0.1)
  if AMTA == A and AMTB == B:
    R = j
    break
  if AMTA > A and AMTB > B:
    break
print(R)

Measured memory_bytes: 3060
import numpy as np

N, M, C = map(int,input().split(" "))

B = list(map(int,input().split(" ")))

ans_cnt = 0

for i in range(N):
  A = np.asarray(list(map(int,input().split(" "))))
  if np.dot(A,B)+C > 0:
    ans_cnt += 1

print(ans_cnt)

Measured memory_bytes: 13328
# coding: utf-8
import itertools
N = int(input())
ans = 0

for i in range(3, len(str(N))+1):
    for ptn in itertools.product((3,5,7), repeat=i):
        if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
            continue
        a = int("".join(list(map(str, ptn))))
        if a <= N:
            ans += 1
print(ans)

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    vint a(3); rep(i,3) cin>>a[i];
    ll k; cin>>k;

    rep(i,k+1){
        rep(j,k+1){
            rep(l,k+1){
                if(i+j+l>k){ continue;}
                vint b = a;
                rep(m,i)b[0] *= 2;
                rep(m,j)b[1] *= 2;
                rep(m,l)b[2] *= 2;
                if(b[1] > b[0] and b[2] > b[1]){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    puts("No");

    return 0;

}

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

using namespace std;

int main()
{
	string str;
	int enu,length;
	int x = 0;
	int t = 0;
	cin >> enu>>str;
	length = str.length();

	if (length >= 1 && length <= 100&&length==enu) {
		for (int i = 0; i < str.length(); i++) {
			if (str[i] == 'I' || str[i] == 'D') {
				if (str[i] == 'I') {
					x += 1;
					if (x > t) {
						t = x;
					}
				}
				if (str[i] == 'D') {
					x -= 1;
					if (x > t) {
						t = x;
					}
				}
			}
			else {
				break;
			}
		}
		cout << t;
	}
	
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


void solve(){
	
	string s,p;
	int w; cin>>s>>w;
	for(int i=0;i<s.size();i+=w) p.pub(s[i]);
	cout<<p<<'\n';
	
	return;
}

void input(){
	
	
	
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	input();
	solve();
	
	return 0;
}





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

int main()
{
	int n;
	int arr[100];
	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		std::cin >> arr[i];
	}
	for (int i = 0; i < n - 1; ++i) {
		std::cout << arr[n - 1 - i] << " ";
	}
	std::cout << arr[0] << std::endl;

    
}




Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
     
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;							\
											 c>0?i<b:							\
											 i>b;								\
											 i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
     
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
     
//.....................
const int MAX = (int)2e5 + 5;
     
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
     
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

void solve();

signed main() {
	cout << fixed << setprecision(20);
	solve();
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

int A, B, C;

void solve() {
	cin >> A >> B >> C;
	int cur = A;
	rep(i, 100000) {
		if (cur % B == C) {
			cout << "YES" << endl;
			return;
		}
		cur += A;
	}
	cout << "NO" << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;

int main()
{
    string s,t; cin >> s >> t;
    for(int i=0;i<s.size();++i)
    {
        string temp = "";
        for(int j=0;j<s.size();j++)
        {
            temp += t[(j+i)%s.size()];
        }
        if(s==temp)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int H, W,i,o,t;

	for(i=0;i<300;i++)
	{
		cin>>H>>W;

		if(H==0 && W==0)
		{
			break;
		}

		for(i=0;i<H/2;i++)
		{
			for(o=0;o<W/2;o++)
			{
				cout<<"#.";
			}
			if(W%2==1)
			{
				cout<<"#";
			}
			cout<<endl;

			for(t=0;t<W/2;t++)
			{
				cout<<".#";
			}
			if(W%2==1)
			{
				cout<<".";
			}
			cout<<endl;
		}
			if(H%2==1)
			{
				for(t=0;t<W/2;t++)
				{
					cout<<"#.";
				}
				if(W%2==1)
				{
					cout<<"#";
				}

				cout<<endl;
			}
			
		
		cout<<endl;
	}



	return 0;
}



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

int main(){
  int n, x;
  vector<int> v;

  cin >> n >> x;

  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    v.push_back(a);
  }

  if (sum == x) {
    cout << n << endl;
    return 0;
  }

  sort(v.begin(), v.end());

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x >= v[i]) {
      ans++;
      x -= v[i];
    }
  }

  if (ans == n) {
    ans -= 1;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

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

    long long ans = INT64_MAX;
    for (int i = 0; i + k - 1 < n; ++i) {
        ans = min({ans,
                   abs(a[i]) + abs(a[i] - a[i + k - 1]),
                   abs(a[i + k - 1]) + abs(a[i] - a[i + k - 1])});
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
/**
*    author:  yuya1234
*    created: 22.08.2020 20:59:30
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int n,x,t;
  cin>>n>>x>>t;

  if(n%x==0)cout<<(n/x)*t<<endl;
  else cout<<(n/x)*t+t<<endl;

  return 0;
}

Measured memory_bytes: 3636
import math

a, b, x = map(int, input().split())

if x > a * a * b / 2:
    theta = math.degrees(math.atan(2 * (b - x / (a ** 2)) / a))
else:
    theta = 90 - math.degrees(math.atan((2 * x) / (a * b * b)))
    
print(theta)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}


void oneCase () {
    int h, n;
    cin >> h >> n;
    vector<pair<int, int>> s(n);
    for (auto& p : s) {
        cin >> p.first;
        cin >> p.second;
    }
    vector<int> res(h + 1, 0);
    for (int hp = 1; hp <= h; ++hp) {
        auto best = INT32_MAX;
        for (auto p: s) {
            auto spell = p.first;
            auto cost = p.second;
            if (spell >= hp) {
                best = min(best, cost);
            } else {
                best = min(best, cost + res[hp - spell]);
            }
        }
        res[hp] = best;
    }
    cout << res.back() << "\n";

}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256