akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

n = int(input())
a = []
for _ in range(n):
    a.append([[*map(int, input().split())] for _ in range(int(input()))])

ans = 0
for i in range(2**n):
    hone = set()
    unki = set()
    for j in range(n):
        if i >> j & 1:
            hone |= {j + 1}
            for k in a[j]:
                if k[1] == 1:
                    hone |= {k[0]}
                else:
                    unki |= {k[0]}
        else:
            unki |= {j + 1}
    if hone & unki == set():
        ans = max(ans, len(hone))
print(ans)


Measured memory_bytes: 74096
#include <iostream>
#include <vector>
#include <queue>

#define MAXN 100000
#define WHITE 0
#define GRAY 1
#define BLACK 2

using namespace std;

struct {
  int to, d;
} typedef node;

vector<node> V[MAXN+1];
int D[MAXN+1];
int color[MAXN+1];

bool bfs ( int root )
{
  queue<int> Q;
  D[root] = 0;
  Q.push(root);
  color[root] = GRAY;
  bool f = true;

  while(!Q.empty()) {
    int top = Q.front(); Q.pop();

    for ( int i = 0; i < V[top].size(); ++i ) {
      node tmp = V[top][i];
      if ( color[tmp.to] == WHITE ) {
        D[tmp.to] = D[top]+tmp.d;
        Q.push(tmp.to);
        color[tmp.to] = GRAY;
      } else {
       if ( D[tmp.to] != D[top]+tmp.d ) f = false;
      }
    }

    color[top] = BLACK;
  }

  return f;
}

bool judge ( int N )
{
  for ( int i = 1; i <= N; ++i ) color[i] = WHITE;
  for ( int i = 1; i <= N; ++i ) {
    if ( color[i] == WHITE ) {
      if ( !bfs(i) ) return false;
    }
  }

  return true;
}


int main()
{
  int N;
  int M;

  cin >> N >> M;

  while (M--) {
    int tmp1,tmp2,tmp3;
    scanf("%d%d%d", &tmp1, &tmp2, &tmp3);
    V[tmp1].push_back({tmp2,tmp3});
    V[tmp2].push_back({tmp1,-tmp3});
  }

  if ( judge(N) ) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 10220
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args ) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int kosu = 0;
    for (int i=0;i<N;i++){
      int x = sc.nextInt();
      int y = sc.nextInt();
      if(Math.pow(x,2)+Math.pow(y,2)<=Math.pow(D,2)) {
		kosu = kosu + 1;
      }
    }
    System.out.println(kosu);
  }
}

Measured memory_bytes: 48792
import java.util.Scanner;

class Main{

	public static void main(String[] args){

		Scanner sc =new Scanner(System.in);
		
		int count=0;

		String W =sc.next().toLowerCase();
		String T;
		count=0;
		
		while(!((T=sc.next()).equals("END_OF_TEXT")))
				if((T.toLowerCase()).equals(W)) count++;
		
		System.out.println(count);
	}
	
}


Measured memory_bytes: 26188
use std::io::Read;


fn solve(s: &str, t: &str) -> bool{
    let vs: Vec<char> = s.chars().collect();
    let vt: Vec<char> = t.chars().collect();
    let mut char_map1 = [-1; 256];
    let mut char_map2 = [-1; 256];

    for i in 0..vs.len() {
        let c1 = vs[i] as usize;
        let c2 = vt[i] as usize;
        if char_map1[c1] != -1 && char_map1[c1] != c2 as i32 {
            return false;
        }
        char_map1[c1] = c2 as i32;
        if char_map2[c2] != -1 && char_map2[c2] != c1 as i32 {
            return false;
        }
        char_map2[c2] = c1 as i32;
    }

    return true;
}

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let s = iter.next().unwrap();
    let t = iter.next().unwrap();
    println!("{}", if solve(s,t) { "Yes" } else { "No "});
}


Measured memory_bytes: 6524
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt() - 1;

        int[] move = new int[n];
        Arrays.fill(move, -1);

        int cle = 1;
        int b = 0;
        int v = 0;
        int cnt = 0;

        while (move[v] == -1) {
            move[v] = cnt++;
            v = arr[v];
        }

        cle = cnt - move[v];
        b = move[v];

//        System.out.println(cle);
//        System.out.println(b);

        if (k < b) {
            int u = 0;
            for (int i=0; i<k; i++) {
                u = arr[u];
            }
            System.out.println(u + 1);
        } else {
            long rem = (k - b) % cle;
            int u = 0;
            for (int i=0; i<b+rem; i++) {
                u = arr[u];
            }
            System.out.println(u + 1);
        }


    }


}


Measured memory_bytes: 59804
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <random>
#include <algorithm>
using namespace std;
int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int n,e,count=0;
    cin>>n;
    vector<int>a;
    for(int i=0;i<n;i++){
        cin>>e;
        a.push_back(e);
    }
    for(int i=0;i<n;i++){
        if((i+1)%2!=0 && a[i]%2!=0) count++;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 3576
N,M = list(map(int,input().split()))
p = []
for i in range(M):
    x,y = list(map(str, input().split()))
    p.append([int(x),y])
count = [[0,0]for i in range(N)]
ansac = 0
answa = 0
for i in range(M):
    if count[p[i][0]-1][1] != 0:
        pass
    else:
        if p[i][1] == 'AC':
            count[p[i][0]-1][1] += 1
        else:
            count[p[i][0]-1][0] += 1
for i in range(N):
    if count[i][1] > 0:
        answa += count[i][0]
    ansac += count[i][1]
print(str(ansac) + ' ' + str(answa))

Measured memory_bytes: 81496
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 Twinkle Twinkle Little Star
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        IrohaAndHaikuABCEdition solver = new IrohaAndHaikuABCEdition();
        solver.solve(1, in, out);
        out.close();
    }

    static class IrohaAndHaikuABCEdition {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int array[] = {a, b, c};
            Arrays.sort(array);
            if (array[0] == 5 && array[1] == 5 && array[2] == 7)
                out.println("YES");
            else out.println("NO");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 22740
import java.util.*;

public class Main {

   public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        String seq = sc.next();
        int depth = 0;
        for (int i = 0; i < seq.length(); i++){
            if (seq.charAt(i) == '('){
                depth ++;
            }
            else{
                depth --;
            }
          if (depth < 0){
            seq =  String.valueOf('(').concat(seq);
            depth ++;
            i++;
          }
        }
      
        if (depth > 0){
            for (int i = 0; i < depth; i++){
                seq = seq.concat(String.valueOf(')'));
            }
        }
        
        System.out.println(seq);   
        
        sc.close();
	}
}

Measured memory_bytes: 21716
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    string S; cin >> S;
    char prev = S.at(0);
    lint ans = 1;
    range(i, 1, N) {
        char c = S.at(i);
        if (c != prev) {
            prev = c;
            ans += 1;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>



using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)


map<string, int> mp;
#define ll long long



int main() {
    int k, s;
    cin >> k >> s;
    int c = 0;
    for(int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            int z = s - i - j;
            if (0<=z&&z<=k) {
                c++;
            }
        }
    }
    cout << c << endl;
    return 0;
}

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

using namespace std;

int main(){
        string w;
        cin>>w;
        int cnt[26]={0};
        for(int i=0;i<(int)w.length();i++){
                cnt[w[i]-'a']++;
        }
        bool res=true;
        for(int i=0;i<26;i++){
                if(cnt[i]%2!=0){
                        res=false;
                        break;
                }
        }
        if(res){
                cout<<"Yes"<<endl;
        }
        else{
                cout<<"No"<<endl;
        }
        return 0;
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

void die() {
	puts("No");
	exit(0);
}

bool good(const vector<int> &v, bool original) {
	int n = v.size();
	return (original && v[0] == n - 1) || 2 * v[0] <= n;
}

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

	int n;
	cin >> n;
	vector<int> v(n);
	set<int> all;
	fori(i, 0, n) {
		cin >> v[i];
		all.insert(v[i]);
	}

	if(*max_element(v.begin(), v.end()) - *min_element(v.begin(), v.end()) > 1) {
		die();
	}
	
	int colors = 0;
	vector<int> fv = v;
	bool original = true;
	if((int) all.size() > 1) {
		for(auto &each : v) {
			if(each == *all.begin()) {
				colors++;
			}
		}
		int at_least = colors + (colors < n);
		if(at_least > *all.begin() + 1) {
			die();
		}
		fv.clear();
		for(auto &each : v) {
			if(each != *all.begin()) {
				fv.push_back(each - colors);
			}
		}
		original = false;
	}

	puts(good(fv, original) ? "Yes" : "No");

	return 0;
}



Measured memory_bytes: 5376
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

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

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int N;
  cin >> N;
  int count = 0;
  bool success = false;
  for (int i = 0; i < N; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) {
      count++;
      if (count >= 3) {
        success = true;
      }
    } else {
      count = 0;
    }
  }
  if (success) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    bool f=1;
    for(int i=n-2;i>=0;i--)
    {//cout<<"came"<<endl;
        if(v[i]>v[i+1])
            v[i]--;
        if(v[i]>v[i+1])
        {
            f=0;
            break;
        }
    }
    if(!f)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    
    
    return 0;   
}


 
 


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

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

    if( -1 < (int)N.find("111") ||
        -1 < (int)N.find("222") ||
        -1 < (int)N.find("333") ||
        -1 < (int)N.find("444") ||
        -1 < (int)N.find("555") ||
        -1 < (int)N.find("666") ||
        -1 < (int)N.find("777") ||
        -1 < (int)N.find("888") ||
        -1 < (int)N.find("999") ||
        -1 < (int)N.find("000") ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3.6
n = int(input())
a = [int(item) for item in input().split()]
awid = []
for i, item in enumerate(a):
    awid.append((item, i))
awid.sort(reverse=True)

bit = [0] * (n + 1) 
cnt = [0] * (n + 1) 
# Add w to ax 
def bit_add(bit, x, w):
    while x <= n:
        bit[x] += w
        x += x & -x

# Sum a1 to ax 
def bit_sum(bit, x):
    ret = 0
    while x > 0:
        ret += bit[x]
        x -= x & -x
    return ret

min_as = [-1] * n
min_a = 0
for i, item in enumerate(a):
    if item > min_a:
        min_as[i] = min_a
        min_a = item

ans = [0] * n
itr = 0
subbed = 0
for i, item in enumerate(min_as[::-1]):
    place = n - 1 - i
    if item != -1:
        while itr < n and awid[itr][0] > item:
            val, index = awid[itr]
            bit_add(bit, index + 1, val)
            bit_add(cnt, index + 1, 1)
            itr += 1
        ret = bit_sum(bit, n) - bit_sum(bit, place) - (bit_sum(cnt, n) - bit_sum(cnt, place)) * item - subbed
        ans[place] = ret
        subbed += ret
for item in ans:
    print(item)

Measured memory_bytes: 28464
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define Pll pair<ll,ll>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
int n,q;
hei(ll) seg, lazy;

void aaa(int k) {
	if (lazy[k] == 0)return ;
	if (k < n - 1) {
		lazy[k * 2 + 1] += lazy[k];
		lazy[k * 2 + 2] += lazy[k];
	}
	seg[k] += lazy[k];
	lazy[k] = 0;
}

void update(int a, int b, ll x,int k,int l,int r) {
	aaa(k);
	if (a<=l && b>=r) {
		lazy[k] += x;
		aaa(k);
	}
	else if(a<r&&l<b){
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		seg[k] = seg[k * 2 + 1]+seg[k * 2 + 2];
	}
}

ll query(int a,int b,int k,int l,int r){
	aaa(k);
	if (l >= b || r <= a)return 0;
	if (a <=l  && b >= r) {
		return seg[k];
	}
	ll v1 = query(a, b, k*2+1, l, (l + r) / 2);
	ll v2 = query(a, b, k*2+2, (l + r) / 2, r);
	return v1 + v2;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	ll n, x;
	cin >> n >> x;
	hei(ll) a(n);
	rep(i, 0, n) {
		ll s;
		cin >> s;
		a[i] = abs(s - x);
	}
	ll ans = a[0];
	rep(i, 1, n)ans = gcd(ans, a[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()

mod = 10**9 + 7
ans = 0

g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, 300000):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


# 以下のcom関数を用いて組み合わせを計算
def com(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

#max
for i in range(n):
    if i >= k-1:
        c = com(i, k-1, mod)
        ans += (a[i] * c) % mod

#min
a.reverse()
for i in range(n):
    if i >= k-1:
        c = com(i, k-1, mod)
        ans -= (a[i] * c) % mod

print(ans%mod)

Measured memory_bytes: 44068
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
 
bool isPrime(ll x)
{
    if (x < 2) {
        return false;
    }
    if (x == 2) {
        return true;
    }
    if (x % 2 == 0) {
        return false;
    }
    for (int i = 3; i * i <= x; i += 2) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

vi v;

int main() {
    cin >> n;
    FOR(i,1, 55555) {
        if (isPrime(i)&&i%5==1) {
            v.push_back(i);
        }
    }
    REP(i,n) {
        cout << v[i] << " ";
    }
    cout << Endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int a[100001],x[100001],y[100001],t[100001]={};
void quicksort(int s,int t){
  if(s<t){
    int i=s,j=t,p=y[a[(s+t)/2]];
    while(1){
      while(y[a[i]]<p)i++;
      while(p<y[a[j]])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(s,i-1);quicksort(j+1,t);
  }
}
int main(){
  int i,j,n,m;
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++)a[i]=i;
  for(i=0;i<m;i++)scanf("%d%d",&x[i],&y[i]);
  quicksort(0,m-1);
  for(i=0;i<m;i++){if(t[x[a[i]]-1]==t[y[a[i]]-1])for(j=y[a[i]]-1;j<=n;j++)t[j]++;}
  printf("%d",t[n]);
}


Measured memory_bytes: 3296
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
int n;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    REP(i, n) cin >> v[i];
    REP(i, n) cin >> c[i];
    REP(i, n) v[i] = max(v[i] - c[i], 0);
    sort(ALL(v));
    int ans = 0;
    REP(i, n) ans += v[i];
    cout << ans << endl;
}


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

int main(){
  int n; cin>>n;
  int buf,a[n];
  
  for(int i=0;i<n;i++){
    cin>>buf; a[buf-1]=i+1;
  }
  
  for(int i=0;i<n;i++){
    cout<<a[i];
    if(i<n-1){cout<<' ';}
  }
  
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

bool pairCompare(const pair<int, int>& firstElof, const pair<int, int>& secondElof) {
    return firstElof.first > secondElof.first;
}

int main(void) {
    ll H;
    cin >> H;

    ll cnt=0, n=H;
    while(n>=2) {
        n /= 2;
        cnt++;
    }

    ll ans=1;
    for(ll i=0;i<(cnt+1);i++) {
        ans *= 2;
    }
    ans -= 1;

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


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int i,j;
  int data[10];
  int tmp;

  for(i=0;i<10;i++){
    scanf("%d",&data[i]);
  }

  for(i=0;i<10;i++){
    for(j=9;j>i;j--){
      if(data[j]>data[j-1]){
	tmp=data[j];
	data[j]=data[j-1];
	data[j-1]=tmp;
      }
    }
  }

  for(i=0;i<3;i++){
    printf("%d\n",data[i]);
  }

  return(0);
}

Measured memory_bytes: 600
import sys

input = sys.stdin.readline


def dot(a, b):
    c = [[0] * n for _ in range(n)]
    for i, ai in enumerate(a):
        for j, bj in enumerate(zip(*b)):
            c[i][j] = sum(ak * bk for ak, bk in zip(ai, bj)) % md
    return c


def pwr(a, k):
    c = None
    while c == None:
        if k & 1:
            c = a
        a = dot(a, a)
        k >>= 1

    while k:
        if k & 1:
            c = dot(a, c)
        a = dot(a, a)
        k >>= 1
    return c


md = 10 ** 9 + 7
n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
print(sum([sum(pk) % md for pk in pwr(a, k)]) % md)


Measured memory_bytes: 72796
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, double> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };

int main() {

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);

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

	rep(i, n - 1) {
		if (a.at(i) == a.at(i + 1)) {
			cout << "NO" << endl;
			break;
		}
		if (i == (n - 2)) {
			cout << "YES" << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
#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>
using namespace std;
long long MOD = 1e9 + 7;

long long A, B;

int main() {
	cin >> A >> B;
	if (A <= 8 && B <= 8)cout << "Yay!" << endl;

	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 1400
#define offset 8010
using namespace std;
typedef long long  ll;
typedef pair<double,int> ii;
typedef pair<double,double> iib;
typedef pair<ll,ii> iii;
typedef pair<map<ll,ll> ,ll> mi;
typedef pair<ii,ii> iiii;
typedef vector<ll> vi;
const ll MOD=1e9+7;
iib puntos[tam];
double radios[tam];
double dist[tam][tam];
double pesos[tam];
int  main()
{
    //ios::sync_with_stdio(false);cin.tie(0);
    int xo,yo,xf,yf;
    cin>>xo>>yo>>xf>>yf;
    int n;
    cin>>n;
    forr(i,1,n+1)
    {
        cin>>puntos[i].fi>>puntos[i].se;
        cin>>radios[i];
    }
    puntos[0]=mp(xo,yo);
    radios[0]=radios[n+1]=0;
    puntos[n+1]=mp(xf,yf);
    n++;
    forr(i,0,n+1){
        forr(j,0,n+1)
        {
            dist[i][j]=hypot(puntos[i].fi-puntos[j].fi,puntos[i].se-puntos[j].se);
            dist[i][j]=max(dist[i][j]-radios[i]-radios[j],0.0);
         //   printf("%.6lf ",dist[i][j]);
            
        }
        //cout<<endl;
    }
    set<ii> s;
    s.insert(ii(0,0));
    int num;
    double auxpes;
    forr(i,0,tam)
    pesos[i]=1e15;
    while(!s.empty())
    {
        set<ii>::iterator ite=s.begin();
        num=(*ite).se;
        auxpes=(*ite).fi;
        s.erase(ite);
        if (auxpes>pesos[num])continue;
        pesos[num]=auxpes;
        forr(i,0,n+1)
        {
            if (auxpes+dist[num][i]<pesos[i])
            {
                s.insert(ii(auxpes+dist[num][i],i));
            }
        }
    }
    printf("%.9lf",pesos[n]);
}

Measured memory_bytes: 43520
#we love abc
s=input()
mod=10**9+7
dpa=[[0,0] for i in range(len(s)+1)]
dpc=[[0,0] for i in range(len(s)+1)]
power3=[1 for i in range(10**5+100)]
for i in range(10**5+3):
    power3[i+1]=(power3[i]*3)%mod
for i in range(len(s)):
    if s[i]=="A":
        dpa[i+1][0]=(dpa[i][0]+power3[dpa[i][1]])%mod
        dpa[i+1][1]=dpa[i][1]  
    elif s[i]=="?":
        dpa[i+1][0]=(3*dpa[i][0]+power3[dpa[i][1]])%mod
        dpa[i+1][1]=dpa[i][1]+1   
    else:
        dpa[i+1]=dpa[i]
for i in range(len(s)):
    if s[len(s)-1-i]=="C":
        dpc[i+1][0]=(dpc[i][0]+power3[dpc[i][1]])%mod
        dpc[i+1][1]=dpc[i][1]  
    elif s[len(s)-1-i]=="?":
        dpc[i+1][0]=(3*dpc[i][0]+power3[dpc[i][1]])%mod
        dpc[i+1][1]=dpc[i][1]+1   
    else:
        dpc[i+1]=dpc[i]    
ans=0
for i in range(1,len(s)-1):
    if s[i]=="B" or s[i]=="?":
        ans+=dpa[i][0]*dpc[len(s)-1-i][0]
        ans=ans%mod
print(ans)

Measured memory_bytes: 40364
n=int(input())
A=list(map(int, input().split()))

def selectsort(A,n):
    count=0
    for i in range(len(A)):
        minj=i
        flag=0
        for j in range(i,len(A)):
            if A[j]<A[minj]:
                minj=j
                flag=1
        if flag==1:
            tmp=A[minj]
            A[minj]=A[i]
            A[i]=tmp
            count+=1
    return(A,count)

result,count=selectsort(A,n)
print(" ".join([str(i) for i in result]))
print(count)



Measured memory_bytes: 5608
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{

    int cx, cy,ansh;

    int n;
    cin >> n;

    int data[100][3];
    for (int i = 0; i < n; i++) {
        cin >> data[i][0] >> data[i][1] >> data[i][2];
    }
    bool ok ;
    for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
            int h;
            ok = true;
            for (int i = 0; i < n; i++) {
                if (data[i][2] > 0) {
                    h = data[i][2] + abs(data[i][0] - x) + abs(data[i][1] - y);
                    break;
                }
            }
         //   cout << h << endl;
            for (int i = 0; i < n; i++) {
                if (max(h - abs(data[i][0] - x) - abs(data[i][1] - y), 0) != data[i][2]) {
                    ok = false;
                    break;
                }
            }

            if (ok) {
                cx = x;
                cy = y;
                ansh = h;
                break;
            }


        }
        if (ok) {
            break;
        }
    }

    cout << cx << " " << cy << " " << ansh << endl;


    return 0;
    
}



Measured memory_bytes: 3652
import sys
def input():
	return sys.stdin.readline().strip()

s = input()

if s[0] == s[-1]:
	if len(s) % 2 == 0:
		print("First")
	else:
		print("Second")
else:
	if len(s) % 2 == 0:
		print("Second")
	else:
		print("First")

Measured memory_bytes: 39152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>

std::vector<int> a;
int main(){
    int n,dum,i,j;
    scanf(" %d",&n);
    for(i = 0;i<n;i++){
        scanf(" %d",&dum);
        a.push_back(dum);
    }
    std::sort(a.begin(),a.end());
    printf(" %d",a[n/2]-a[n/2-1]);
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <string>

std::vector<int> num_pairs;
int N, X, Y;

int main() {
  std::cin >> N >> X >> Y;
  --X;
  --Y;
  num_pairs.assign(N, 0);
  for (int i = 0; i < N-1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (j <= X || i >= Y) {
        ++num_pairs[j-i];
      } else if (i >= X && j <= Y) {
        ++num_pairs[std::min(Y-X+1-(j-i), j-i)];
      } else if (i < X && j > Y) {
        ++num_pairs[X-i+j-Y+1];
      } else {
        if (i < X) {
          ++num_pairs[std::min(Y-X+1-(j-X), j-X) + X - i];
        } else if (j > Y) {
          ++num_pairs[std::min(Y-X+1-(Y-i), Y-i) + j - Y];
        }
      }
    }
  }
  for (int k = 1; k < N; ++k) {
    std::cout << num_pairs[k] << std::endl;
  }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
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 mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARangeProduct solver = new ARangeProduct();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARangeProduct {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            long a = in.longs(), b = in.longs();
            if (a * b <= 0) {
                out.println("Zero");
            } else if (a > 0 || (b - a) % 2 == 1) {
                out.println("Positive");
            } else {
                out.println("Negative");
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public long longs() {
            return Long.parseLong(string());
        }

    }
}



Measured memory_bytes: 22356
#include <iostream>

using namespace std;

int main()
{
	int h, w;
	while(cin >> h >> w, (h|w))
	{
		int r = h*h + w*w;
		int res_h, res_w, res_r;
		res_r = 10000000;
		for(int p=1; p*p*2<r; p++)
		{
			int q = 1;
			while(p*p+q*q<r || (p*p+q*q==r && p<=h)) q++;
			if(p*p+q*q<res_r)
			{
				res_h = p;
				res_w = q;
				res_r = p*p+q*q;
			}
		}
		cout << res_h << " " << res_w << endl;

	}
}


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

int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	int d[501][501] = {};

	for (int i = 0; i < m; i++)
	{
		int l, r;
		cin >> l >> r;
		for (int j = r; j < 501; j++)
		{
			d[l][j]++;
		}
	}
	for (int i = 0; i < q; i++)
	{
		int x, y;
		cin >> x >> y;
		int ans = 0;
		for (int j = x; j <= y; j++)
		{
			ans += d[j][y];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
 */
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[500005], y[500005], z[500005];
char s[400004];

int main(){
    cin >> n;
    cin >> s;
    m = strlen(s);
    for(int i=0;i<m;i++){
        if(s[i] + n > 'Z'){
            s[i] -= 26;
        }
        pu((char)(s[i] + (char)n));
    }
    el;
   

    return 0;
    
}


















Measured memory_bytes: 14976
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  int n;
  long a, b;
  cin >> n >> a >> b;

  vector<long> x(n);
  fillLong(x, n);

  long res = 0;
  rep(i, n-1) {
    long walk = (x[i+1] - x[i]) * a;
    if (walk > b) {
      res += b;
    } else {
      res += walk;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................

static long rec(long[][] dp, int i, int j,long[] pre){
	if(i>=j){return 0;}
	if(dp[i][j]!=0){return dp[i][j];}
	long res=pre[j]-pre[i-1],tmp=Long.MAX_VALUE;
	for(int k=i;k<j;k++){
		tmp=Math.min(tmp,rec(dp,i,k,pre)+rec(dp,k+1,j,pre));
	}
	 return dp[i][j]=(res+tmp);
}
   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  int n=int_v(read());
	        		  int[] a=int_arr();
	        		  long[] pre=new long[n+1];
	        		  for(int i=1;i<=n;i++){pre[i]=a[i-1]+pre[i-1];}
	        		  long[][] dp=new long[n+1][n+1];
	        		  out.write(rec(dp,1,n,pre)+"");
                      out.flush();
	        		 
	}
}
	       
	          



	
  





Measured memory_bytes: 24148
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return ans;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

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

template <typename T>
void greater_sort(vector<T>& vec) {
	sort(all(vec), greater<T>());
	return;
}

int k, a, b;
signed main() {
	cin >> k >> a >> b;
	if (a >= b || k < a - 1) {
		cout << 1 + k << endl;
	}
	else {
		k -= a - 1;
		cout << max(k + a, k / 2 * (b - a) + a + k % 2) << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
int main(){
	cin>>s;
	bool a=0,b=0;
	for(int i=0;i<s.size();i++)if(s[i]=='A')a=1; else b=1;
	if(a&&b)cout<<"Yes";
	else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//a÷b以上の最小の整数
ll CEIL(ll a, ll b) {
	return (a + b - 1) / b;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

int N, A, B;
int h[100010], x[100010];

bool isOK(ll K) {
	ll cnt = 0;
	REP(i, N) {
		if (B*K < h[i]) {
			cnt += CEIL(h[i] - B * K, A - B);
		}
	}
	if (cnt <= K)return true;
	else return false;
}

int binary_search() {
	int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll ok = 1000000001; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

						/* ok と ng のどちらが大きいかわからないことを考慮 */
	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;

		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main() {
	cin >> N >> A >> B;
	REP(i, N) {
		cin >> h[i];
	}

	ll ans = binary_search();
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))

const int mod = 998244353;
typedef unsigned long long lu;
typedef long long li;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (lu)x * y % mod; }
inline int Mul(int x, int y, int z) { return (lu)x * y % mod * z % mod; }

inline int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

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

const int maxn = 2e5;

int n;
char str[maxn + 1];

int main(void) {
  scanf("%s", str);
  n = strlen(str);
  int mode = 0, cnt = 0;
  li ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (str[i] == 'A') {
      if (mode == 0) {
        ans += cnt;
      } else {
        cnt = 0;
        mode = 0;
      }
    } else if (str[i] == 'B') {
      if (mode == 1) {
        mode = 0;
        ++cnt;
      } else {
        mode = 0;
        cnt = 0;
      }
    } else {
      if (mode == 0) {
        mode = 1;
      } else {
        cnt = 0;
        mode = 1;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int a = tmp[0], p = tmp[1];
        int ans = (a*3 + p) / 2;
        WriteLine(ans);
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std; 
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 200000
long long int MOD=998244353;
long long int INF=1e18;
                                                 /*:-]*/
 
int main()
{
         ios_base::sync_with_stdio(false); 
         cin.tie(NULL);
         cout.tie(NULL);
         long long int i,j,k=0,l=0,r=0,m=0,n,c,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t,x1,y1;
       cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>x;
        if(x>=k)
            cnt++;
    }
    cout<<cnt<<endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<stdio.h>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109311;
const long double pi = 3.1415926535897932384626433;
typedef pair<int, int> P;
struct edge { int to, cost; };

signed main() {
	int n; cin >> n;
	int sn = 0;
	rep(i, n) {
		int a; cin >> a;
		if (a % 2 == 0)sn++;
	}cout << sn << endl;
}


Measured memory_bytes: 3088