akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int q = in();
  set<int> s;
  while (q--) {
    int t = in();
    if (t == 0) {
      s.emplace(in());
      cout << s.size() << endl;
    }
    if (t == 1) cout << s.count(in()) << endl;
    if (t == 2) s.erase(in());
    if (t == 3) {
      int l, r;
      cin >> l >> r;
      for (auto it = s.lower_bound(l), end = s.upper_bound(r); it != end; it++) cout << *it << endl;
    }
  }
}



Measured memory_bytes: 12356
N, M = list(map(int, input().split()))
AL = []
for i in range(N):
	A = list(input())
	AL.append(A)

BL = []
for i in range(M):
	B = list(input())
	BL.append(B)

judge = "No"

for i in range(N - M + 1):
	for j in range(N - M + 1):
		c = "Yes"
		for k in range(M):
			for l in range(M):
				if AL[i + k][j + l] != BL[k][l]:
					c = "No"
					break
		if c == "Yes":
			judge = "Yes"

print(judge)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
public class Main {
  public static void main(String[] args) {
    Main m = new Main();
    m.run();
  }
  private void run() {
    int n = 0;
    int k = 0;
    Sushi[] sushi = new Sushi[0];
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
      String[] s = br.readLine().split("\\s+");
      n = Integer.parseInt(s[0]);
      k = Integer.parseInt(s[1]);
      sushi = new Sushi[n];
      for (int i=0;i<n;i++) {
        s = br.readLine().split("\\s+");
        sushi[i] = new Sushi(Integer.parseInt(s[0]),Long.parseLong(s[1]));
      }
      Arrays.sort(sushi,Comparator.reverseOrder());
    } catch (IOException e) {
      e.printStackTrace();
    }
    PriorityQueue<Sushi> used = new PriorityQueue<>();
    PriorityQueue<Sushi> rem = new PriorityQueue<>
      ((s1,s2) -> -Long.compare(s1.priority,s2.priority));
    Map<Integer,Integer> map = new HashMap<>();
    long m = 0;
    long[] f = new long[n];
    for (int i=0;i<k;i++) {
      used.add(sushi[i]);
      if (map.containsKey(sushi[i].t)) {
        int x = map.get(sushi[i].t);
        map.put(sushi[i].t,x+1);
      } else {
        map.put(sushi[i].t,1);
      }
      m += sushi[i].d;
      f[i] = m + (long)map.size()*(long)map.size();
    }
    for (int i=k;i<n;i++) {
      rem.add(sushi[i]);
    }
    int c = 0;
    outside: while (used.size() > 0) {
      Sushi s = used.poll();
      if (map.get(s.t) > 1) {
        while (rem.size() > 0) {
          Sushi u = rem.poll();
          if (!map.containsKey(u.t)) {
            m += u.d - s.d;
            map.put(u.t,1);
            f[k+c] = m + (long)map.size()*(long)map.size();
            c++;
            continue outside;
          }
        }
      }
    }
    m = f[k-1];
    for (int i=k;i<n;i++) {
      m = f[i] > m ? f[i] : m;
    }
    System.out.println(m);
  }
  private class Sushi implements Comparable<Sushi> {
    private int t;
    private long d;
    private long priority;
    Sushi(int t,long d) {
      this.t = t;
      this.d = d;
      priority = d;
    }
    @Override
    public int compareTo(Sushi other) {
      return Long.compare(priority,other.priority);
    }
    @Override
    public int hashCode() {
      int prime = 31;
      int result = 1;
      result = prime * result + t;
      result = prime * result + (int)(d ^ (d >>> 32));
      return result;
    }
    @Override
    public boolean equals(Object obj) {
      if (this == obj) return true;
      if (obj == null) return false;
      if (getClass() != obj.getClass()) return false;
      Sushi other = (Sushi)obj;
      return t == other.t && d == other.d;
    }
  }
}

Measured memory_bytes: 69720
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
    int a=0, b=0;
    cin >> a >> b;
    cout << (b%a?b-a:a+b) << endl;
}

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

int main(void) {
  char s[201];
  char fs[101];
  char ls[101];
  int length = 0;
  int init = 1;
  scanf("%s", s);
  if(strlen(s)%2==0) init++;
  for(int i=strlen(s)-init; i>1; i-=2){
    for(int j=0; j<i/2; j++) {
      fs[j]=s[j];
    }
    fs[i/2] = '\0';

    for(int j=i/2; j<i; j++){
      ls[j-i/2] = s[j];
    }
    ls[i-i/2] = '\0';

    if(strcmp(fs, ls)==0){
      length = i;
      break;
    }
  }
  printf("%d\n",length);
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

//#define _USE_MATH_DEFINES
//#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

//struct less_key
//{
//    bool operator() (i64 p1, i64 p2)
//    {
//        return (p1.first < p2.first) || ((p1.first == p2.first) && (p1.second < p2.second));
//    }
//};
//
//struct pair_hash
//{
//    std::size_t operator()(const i64& k) const
//    {
//        return static_cast<size_t>(k.first ^ k.second);
//    }
//};

#include <random>

const i64 mod1 = 1000000007ll;
const i64 mod2 = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

template <typename T = i64, T D = 0>
class MaxOp {
public:
    static T op(const T& a, const T&b) {
        return max(a, b);
    }

    static T def() {
        return (T)D;
    }
};

template <typename T = i64, T D = inf>
class MinOp {
public:
    static T op(const T& a, const T&b) {
        return min(a, b);
    }

    static T def() {
        return (T)D;
    }
};

template <typename T = i64, T D = 0>
class SumOp {
public:
    static T op(const T& a, const T&b) {
        return a + b;
    }

    static T def() {
        return (T)D;
    }
};

template <typename D, typename T = i64>
class SegTree {
public:
    i64 n;
    vector<T> t;

private:
    void build (const i64* a, int v, int tl, int tr) {
        if (tl == tr)
            t[v] = a[tl];
        else {
            int tm = (tl + tr) / 2;
            build (a, v*2, tl, tm);
            build (a, v*2+1, tm+1, tr);
            t[v] = lca(t[v*2], t[v*2+1]);
        }
    }

    i64 get (int v, int tl, int tr, int l, int r) {
        if (l > r)
            return D().def();
        if (l == tl && r == tr)
            return t[v];
        int tm = (tl + tr) / 2;
        return D().op(get (v*2, tl, tm, l, min(r,tm)),
                      get (v*2+1, tm+1, tr, max(l,tm+1), r));
    }

public:
    void build(const vector<i64 >& a) {
        n = a.size();
        t.resize(n * 4);
        build(a.data(), 1, 0, n - 1);
    }

    void build(i64* a, i64 n) {
        this->n = n;
        t.resize(n * 4);
        build(a, 1, 0, n - 1);
    }


    i64 get(i64 l, i64 r) {
        return get(1, 0, n - 1, l, r);
    }
};


// delimeter


i64 n;


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    double T, X;
    cin >> T >> X;

    std::cout << T / X;

    return 0;
}




Measured memory_bytes: 256
package main
import . "fmt"
func main() {
  var n int
  var h []int
  Scan(&n)
  h = make([]int,n)
  for i:=0;i<n;i++ { Scanf("%d",&h[i]) }
  Println(watering(h))
}
func watering(h []int) int {
  var n int = len(h)
  switch n {
    case 0 : return 0
    case 1 : return h[0]
    case 2 : return max(h)
  }
  var m int = min(h)
  for i:=0;i<n;i++ { h[i] -= m }
  var k int = 0
  for i:=0;i<n;i++ {
    if h[i] != 0 {
      k = i
      break
    }
  }
  for i:=k+1;i<n;i++ {
    if h[i] == 0 {
      m += watering(h[k:i])
      i++
      k = i
    }
  }
  if k != n { m += watering(h[k:n]) }
  return m
}
func min(a []int) int {
  var m int = a[0]
  for i:=1;i<len(a);i++ {
    if m > a[i] { m = a[i] }
  }
  return m
}
func max(a []int) int {
  var m int = a[0]
  for i:=1;i<len(a);i++ {
    if m < a[i] { m = a[i] }
  }
  return m
}

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

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

Node* treeMinimum(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}

Node* find(Node *u,int k){
    while(u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node* treeSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
}

void treeDelete(Node *z){
    Node *y;    //????????????????±?
    Node *x;    //y??????

    //??????????????????????±???????
    if(z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    //y??????x????±???????
    if(y->left != NIL){
        x = y->left;
    } else {
        x = y->right;
    }

    if(x != NIL) x->parent = y->parent;

    if(y->parent == NIL){
        root = x;
    } else {
        if(y == y->parent->left){
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }
    if(y != z){
        z->key = y->key;
    }

    free(y);
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root = z;
    } else {
        if(z->key < y->key){
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        cin >> com;
        if(com=="find"){
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        } else if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        } else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if(com == "delete"){
            scanf("%d",&x);
            treeDelete(find(root,x));
        }
    }

    return 0;
}

Measured memory_bytes: 21932
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int total = 0;
        for(int i = 0; i < 2; i++){
            if(a < b){
                total += b;
                b--;
            }else{
                total += a;
                a--;
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;

ll fact[11000];

int main()
{
  ll N;
  cin >> N;
  for (int i = 2; i <= N; i++) {
    int num = i;
    for (int j = 2; j*j <= num; j++) {
      while (num % j == 0) {
        fact[j]++;
        num /= j;
      }
    }
    if (num > 1) fact[num]++;
  }

  ll ans = 1;
  for (int i = 2; i <= N; i++) {
    (ans *= fact[i] + 1) %= 1000000007;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

int main(){
  int a,b,x;
  cin >> a >> b >> x;
  if(x >= a && x <= a+b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())
ans = []
for i in range(A,min(B+1,A+K),1):
    if i not in ans:
        ans.append(i)
for j in range(B,max(A-1,B-K),-1):
    if j not in ans:
        ans.append(j)
ans = sorted(ans)
for k in ans:
    print(k)


Measured memory_bytes: 3060
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String first = sc.next();
      	String last = sc.next();
      	
      	char[] fst = first.toCharArray();
      	char[] lst = last.toCharArray();
      	int count = 0;
      	for(int i = 0; i < fst.length; i++){
        	if(fst[i] != lst[i]){
            	count++;
            }
        }
      System.out.println(count);
    }
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ]
        Scanner sc = new Scanner(System.in);
        Integer countResults = sc.nextInt();
        List<String> results = new ArrayList<String>();

        for(int i= 0; i <= countResults; i++){
           results.add(sc.nextLine());
        }

        int acCount = 0;
        int waCount = 0;
        int tleCount= 0;
        int reCount = 0;

        for(String result: results){
          if(result.equals("AC")){
            acCount++;
          }
          else if(result.equals("WA")){
            waCount++;
          }
          else if(result.equals("TLE")){
            tleCount++;
          }
          else if(result.equals("RE")){
            reCount++;
          }
        }


        System.out.println("AC x " + acCount);
        System.out.println("WA x " + waCount);
        System.out.println("TLE x " + tleCount);
        System.out.println("RE x " + reCount);

	}

}


Measured memory_bytes: 65908
import java.util.*;

class Main{
   public static void main(String[] args)
   {
      Scanner scan  = new Scanner(System.in);
      int     hour  = scan.nextInt();
      int     money = scan.nextInt();
      int     bill  = scan.nextInt();

      if(hour * money >= bill){
         System.out.println(bill);
         }
      else{
          System.out.println(hour * money);
          }
   }
}


Measured memory_bytes: 21844
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

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



int main() {
	string S,an="No";
	cin >> S;
	set<char> w;
	rep(i, S.size()) {
		if (w.count(S.at(i))) {
			w.erase(S.at(i));
			
		}
		
		else {
			w.insert(S.at(i));
		}
	}
	if (w.size() == 0) {
		an = "Yes";
	}
		cout<< an<<endl;
	


	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
int main(){
    string s;
    cin>>s;
    ll a=0;
    rep(i,s.size()){
        a+=s[i]-'0';
    }
    if(a%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3716
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
    int N,M;
    long long sum = 0;
    cin >> N>>M;
    vector<int> a(M+1);
    vector<long long> s(N+3);//s.at(i)i-1段目の登り方
    a.at(M) = N + 5;
    rep(i,M){
        cin >> a.at(i);
    }
    s.at(0) = 0;//-1段目
    s.at(1) = 1;//0段目
    int m = 0;
    for (int i= 1; i< N+2; i++) {
        if (i == a.at(m)) {
            s.at(i+1) = 0;
            m++;
        }
        else {
            s.at(i+1) = (s.at(i) + s.at(i - 1))%1000000007;

        }
    }
    cout << s.at(N+1) << endl;
    

}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

const ll mod = 1e9+7;

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}



int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    map<ll, ll> ALLmp;
    REP(i, 0, n){
        map<ll, ll> vmp;
        int k = 2;
        ll c = lis[i];
        while(k * k <= c){
            if(c % k == 0){
                vmp[k]++;
                c /= k;
            }else{
                k++;
            }
        }
        vmp[c]++;
        for(auto &x: vmp){
            chmax(ALLmp[x.first], x.second);
        }
    }
    ll sum = 1;
    for(auto &x: ALLmp){
        sum *= Pow(x.first, x.second);
        sum %= mod;
    }
    ll ans = 0;
    REP(i, 0, n){
        ans += sum * modinv(lis[i], mod);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4128
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, X, T;
  cin >> N >> X >> T;

  if (N % X == 0) {
    cout << N / X * T << endl;
  } else {
    cout << ((N / X) + 1) * T << endl;
  }

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  bool ok = false;
  vector<int> ans;
  for(int i=1;i<=100000;i++){
    int p = i*0.08;
    int q = i*0.1;
    if(p==a && q==b){
      ok = true;
      ans.push_back(i);
    }
  }
  if(ok){
    cout<<ans.at(0)<<endl;
  }
  else{
    cout<<-1<<endl;
  }
  return 0;
}
      

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= 50000; i++) {
    if (int(i * 1.08) == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}


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

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

    vector<char> alphabet(26);
    alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

    int S_length = S.length();
    vector<char> ans(S_length);

    for(int i = 0; i < S_length; i++){
        char tmp = S[i];
        int bangou = 0;
        for(int i = 0; i < 26; i++){
            char now = alphabet[i];
            if(now == tmp){
                break;
            }
            else bangou++;
        }
        int x = (bangou + N) % 26;
        ans[i] = alphabet[x];
    }

    for(int i = 0; i < S_length; i++) cout << ans[i];
}

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

class Main
{
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int W=sc.nextInt();
        sc.nextLine();
        long value[][]=new long[n][2];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<2;j++)
            {
                value[i][j]=sc.nextLong();
            }
            sc.nextLine();
        }
        long dp[][]=new long[n+1][W+1];
             for(int i=1;i<=n;i++)
             {
                for(int j=1;j<=W;j++)
                {
                    if((int)value[i-1][0]<=j)
                    {
                         dp[i][j]=(long)Math.max(dp[i-1][j],value[i-1][1]+dp[i-1][j-(int)value[i-1][0]]);
                    }
                    else
                       dp[i][j]=dp[i-1][j];
                }   
             }
        System.out.println(dp[n][W]);
        sc.close();
    }
}

Measured memory_bytes: 140476
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
vector<string> P3 = {
    ".aa",
    "b..",
    "b..",
};
vector<string> P4 = {
    "aabc",
    "kkbc",
    "deoo",
    "depp",
};
vector<string> P5 = {
    "aabbc",
    "de..c",
    "de.ff",
    "g.hhi",
    "gjj.i",
};
vector<string> P6 = {
    "abcc..",
    "abdd..",
    "..efgg",
    "..efhh",
    "ii..jk",
    "ll..jk",
};
vector<string> P7 = {
    "abc....",
    "abc....",
    "cde....",
    "cde....",
    "f..gghh",
    "f..iijj",
    ".kkllmm",
};
void paste(vector<string> &S, int n, vector<string> &tmpl) {
    for (int i = 0; i < tmpl.size(); i++) {
        for (int j = 0; j < tmpl.size(); j++) {
            if (tmpl[i][j] != '.') {
                S[n+i][n+j] = tmpl[i][j];
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<string> S(N, string(N, '.'));
    if (N == 2) {
        cout << -1 << endl;
        exit(0);
    }
    else if (N == 3) paste(S, 0, P3);
    else {
        int n = N / 4;
        int r = N % 4;
        int t = 0;
        for (int i = 0; i < n - 1; i++) {
            paste(S, t, P4);
            t += 4;
        }
        if (r == 0) paste(S, t, P4);
        if (r == 1) paste(S, t, P5);
        if (r == 2) paste(S, t, P6);
        if (r == 3) paste(S, t, P7);
    }
    for (auto &s : S) cout << s << '\n';
    return 0;
}


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

int n;
int ans = 0;

void func(ll x, bool three, bool five, bool seven)
{
    if (x > n)
        return;
    if (three && five && seven)
        ans++;

    func(x * 10 + 7, three, five, true);
    func(x * 10 + 5, three, true, seven);
    func(x * 10 + 3, true, five, seven);

    return;
}

int main()
{
    cin >> n;

    func(0, false, false, false);

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

Measured memory_bytes: 3632
// Aizu 1105: Unable Count
// 2017.9.12 bal4u@uu

#include <stdio.h>
#include <string.h>
#define min(a,b) ((a)<=(b)?(a):(b))

char f[2000003];

int main()
{
	int n, a, b, k, s;

	while (scanf("%d%d%d", &n, &a, &b) && n) {
		memset(f, 0, n+1); f[0] = f[a] = f[b] = 1, s = min(a, b);
		for (k = s; k <= n; k++) if (f[k]) f[a+k] = 1, f[b+k] = 1;
		for (k = s, s = 0; k <= n; k++) s += f[k];
		printf("%d\n", n-s);
	}
	return 0;
}

Measured memory_bytes: 2736
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>

using namespace std;


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

	cin >> a;
	if (a == 1)
	{
		cout << "Hello World" << endl;
	}
	else
	{
		cin >> b >> c;
		cout << b+c << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    T = S;
    reverse(ALL(T));
    if (S == T)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  int count[4] = {};
  for (int i = 0; i < 6; ++i) {
    int x;
    std::cin >> x;
    ++count[x - 1];
  }
  int x = 0;
  for (int i = 0; i < 4; ++i) {
    if (count[i] != 2) ++x;
  }
  std::cout << (x == 2 ? "YES" : "NO") << std::endl;
  return 0;
}

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

int main()
{
	long long int n;
	cin >> n;
	long long int ans = (1ll<<60);
	for (long long int i = 1; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			ans = min(ans, (n / i - 1) + (i - 1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define MAXN 10005
#define MAXM 40005
#define INF 0x3fffffff
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define clr(x,y) memset(x,y,sizeof(x));
using namespace std;
typedef long long LL;
int i,j,k,n,m,x,y,T,ans,big,cas,num,len;
bool flag;

int edge,head[MAXN];
struct node
{
	int x,y,w;
}p[10005];

bool cmp(node a,node b)
{
	return a.w<b.w;
}

int pre[10005];   //??根?点，起始??pre[i]=i
int find(int u)   //?找u?点??集合的根?点
{
	int r=u;
	while (pre[r]!=r) r=pre[r];  //沿着?向上不断找father，直到找到根?点root (存入r中)
	int i=u,j;
	while (i!=r)   //路径??，即把向上找???的?个?点（重新沿?点向上找一遍），他?的father都??root
	{
		j=pre[i];
		pre[i]=r;
		i=j;
	}
	return r;  //返回根?点的?号
}

int main()
{
	while (scanf("%d%d",&n,&m),n+m)
	{
		memset(head,-1,sizeof(head));
		edge=0;
		for (i=0;i<m;i++)
		{
			scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].w);
		}
		sort(p,p+m,cmp);
		for (i=1;i<=n;i++) pre[i]=i;
		int t=n/2;num=0;
		for (i=0;i<m;i++)
		{
			int fx=find(p[i].x);
			int fy=find(p[i].y);
			if (fx!=fy)
			{
				pre[fx]=fy;
				num++;
				if (num==t)
				{
					printf("%d\n",p[i].w);
					break;
				}
			}
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    double t, x;cin>>t>>x;
    cout<<t/x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int arr[200010];
int32_t main()
{

    int n;
    cin >> n;
    for(int i=1; i<n; i++)
    {
        int tmp;
        cin >> tmp;
        arr[tmp]++;
    }

    for(int i=1; i<=n; i++)
    {
        cout << arr[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5180
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    s=input()
    print(s[0]+str(len(s)-2)+s[-1])
main()

Measured memory_bytes: 3060
from itertools import accumulate
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = sum(abs(A[i+1] - A[i]) for i in range(N+1))
for i in range(1, N+1):
    print(cost + abs(A[i+1] - A[i-1]) - abs(A[i-1] - A[i]) - abs(A[i] - A[i+1]))


Measured memory_bytes: 20532
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n, Y; cin >> n >> Y;
    rep(x, n+1) {
        rep(y, n+1-x) {
            int z = n - x - y;
            if(z < 0) continue;
            if(10000 * x + 5000 * y + 1000 * z == Y) {
                printf("%d %d %d\n", x, y, z);
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
	unsigned int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
	NodePointer cur = nil->next;
	while(1){
		if ( cur == nil ) break;
		if (cur->key == key) return cur;
		cur = cur->next;
	}
	return nil;
}

void init(){
	nil = (NodePointer) malloc(sizeof(struct node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	NodePointer cur = nil->next;
	int isf = 1;
	while(1){
		if ( cur == nil ) break;
		if ( isf == 0)	printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}

void deleteNode(NodePointer t){
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	NodePointer t = nil->next;
	if ( t == nil ) return;
	deleteNode(t);
}

void deleteLast(){
	NodePointer t = nil->prev;
	if ( t == nil ) return;
	deleteNode(t);
}

void delete(int key){
	NodePointer t = listSearch(key);
	deleteNode(t);
}


void insert(int key){
	NodePointer x;
	x = malloc(sizeof(struct node));
	x->key = key;
	x->next = nil->next;
	x->prev = nil;
	if (nil->prev == nil) {
		nil->prev = x;
	}

	nil->next->prev = x;
	nil->next = x;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for ( i = 0; i < n; i++ ){
		scanf("%s%d", com, &key);
		if ( com[0] == 'i' ) {insert(key); np++; size++;}
		else if ( com[0] == 'd' ) {
			if (strlen(com) > 6){
				if ( com[6] == 'F' ) deleteFirst();
				else if ( com[6] == 'L' ) deleteLast();
			} else {
				delete(key); nd++; 
			}
			size--;
		}
	}
	printList();
	return 0;
}

Measured memory_bytes: 31788
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int n;
ll K;

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=8 && b <= 8){
		printf("Yay!\n");
	}else{
		printf(":(\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<vector<int>> G(N);
    vector<pair<int,int>> info;
    rep(i,N-1){
        int a, b;
        cin>>a>>b;a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        info.emplace_back(a,b);
    }
    int K=0;
    map<pair<int,int>,int> I;
    vector<int> cs(N,0);
    vector<int> used(N,0);
    used[0]=1;
    queue<int> que;
    que.emplace(0);
    while(!que.empty()){
        int v = que.front();que.pop();
        if(K<(int)G[v].size()) K=G[v].size();
        int cur=1;
        for (int nv:G[v]) {
            if (used[nv]) continue;
            if(cur==cs[v])cur++;
            cs[nv]=I[make_pair(v,nv)]=I[make_pair(nv,v)]=cur++;
            used[nv]=1;
            que.emplace(nv);
        }
    }
    cout<<K<<endl;
    for(auto p:info)cout<<I[p]<<endl;
    return 0;
}

Measured memory_bytes: 20084
N = int(input())

CSF = [list(map(int, input().strip().split())) for _ in range(N-1)]

for i in range(N):  # 出発駅
  time = 0
  for j in range(i, N-1):
    if time < CSF[j][1]:  # 開通まで待つ
      time = CSF[j][1]
    elif time % CSF[j][2] == 0:
      pass
    else:
      time += CSF[j][2]-time%CSF[j][2]
    time += CSF[j][0]
  print(time)


Measured memory_bytes: 3188
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val x = sc.nextInt()
    x
  }


  def parfectPowerList(base: Int, upperBound: Int): List[Int] = {
    if (base == 1) {
      return List(1)
    }
    val buf: ArrayBuffer[Int] = ArrayBuffer.empty

    // 2乗から
    var num = base * base
    while (num <= upperBound) {
      buf.append(num)
      num = num * base
    }
    buf.toList
  }

  def main(args: Array[String]): Unit = {
    val x: Int = read()
    val parfectPowers = (1 to x).flatMap(i => parfectPowerList(i, x))
    val result = parfectPowers.max
    println(result)
  }
}

Measured memory_bytes: 25816
#include<atcoder/all>
#define M 300100
using namespace std;int A,K,C;int o(int a,int b){return max(a,b);}int e(){return 0;}main(){cin>>A>>K;atcoder::segtree<int,o,e>S(M);for(;cin>>A;){C=S.prod(max(0,A-K),min(M,A+K+1))+1;if(S.get(A)<C)S.set(A,C);}cout<<S.all_prod();}

Measured memory_bytes: 8572
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;

    if(A+B>=24){
        cout <<A+B-24<<endl;
    }else{
        cout<<A+B<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		for(int i = 1; i <= n; i++) {
			if(i % 3 == 0) System.out.print(" " + i);
			else {
				String s = String.valueOf(i);
				for(int j = 0; j < s.length(); j++) {
					char three = s.charAt(j);
					if(three == '3') {
						System.out.print(" " + i);
						break;
					}
				}
			}
		}
		System.out.println("");
	}

}



Measured memory_bytes: 29436
from bisect import bisect_left, bisect_right

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

a.sort()
b.sort()
c.sort()

# print(a, b, c)

ans = 0

for i in range(n):
    idx_a = bisect_left(a, b[i])
    select_b = idx_a

    idx_c = bisect_right(c, b[i])
    select_c = n - idx_c
    ans += select_b * select_c

# for i in range(n):
#     idx_b = bisect_right(b, a[i])
#     # select_b = n - idx_b
#     for j in range(idx_b, n):
#         idx_c = bisect_right(c, b[j])
#         select_c = n - idx_c
#         ans += select_c
print(ans)



Measured memory_bytes: 23360
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    bool is_prime[1000000];
    memset(is_prime, true, sizeof(is_prime));
    is_prime[0] = is_prime[1] = false;
    for(int i=0; i<1000000; i++){
        if(is_prime[i]){
            for(int j=2*i; j<1000000; j+=i)
                is_prime[j] = false;
        }
    }
    
    int a, d, n;
    while(cin>>a>>d>>n, a|d|n){
        for(int i=0; i<n; i++){
            while(!is_prime[a]){
                a += d;
            }
            a += d;
        }
        cout << a-d << endl;
    }
    
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S.size() == 1) { std::cout << NO << endl; return;}
    if(S.size() % 2 != 0) { std::cout << NO << endl; return;}

    string hi = "hi";
    for(int i = 0; i < S.size(); i+=2) {
        if(S[i] != hi[0]) {
            std::cout << NO << endl;
            return;
        }
        if(S[i+1] != hi[1]) {
            std::cout << NO << endl;
            return;
        }
    }

    std::cout << YES << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  if (n%1110<10) {
    cout << "Yes" << endl;
  }
  else if ((n%1000)%111==0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;
#define MOD 1000003
typedef long long ll;

bool csort(pair<int,int> a, pair<int,int> b)
{
    return a.first > b.first;
}

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

    char s[n];
    for(int i=0; i<n; i++)
        cin >> s[i];

    pair<int,int> query[q];
    for(int i=0; i<q; i++)
    {
        int a,b;
        cin >> a >> b;
        query[i] = make_pair(a,b);
    }

    int ans[q];
    int cnt[n];
    bool mem[n] = {false};

    for(int j = 1; j < n; j++)
    {
        if(s[j-1] == 'A' && s[j] == 'C')
            mem[j] = true;
    }

    cnt[0] = 0;

    for(int i=1; i<n; i++)
    {
        if(mem[i])  cnt[i] = cnt[i-1] + 1;
        else    cnt[i] = cnt[i-1];
    }

    for(int i=0; i<q; i++)
    {
        ans[i] = cnt[query[i].second-1] - cnt[query[i].first-1];
    }

    for(int i=0; i<q; i++)
        cout << ans[i] << "\n";

    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int X, N;
	cin >> X >> N;
	vector<bool> USED(10000, false);
	rep(i, 0, N)
	{
		int A;
		cin >> A;
		USED[A] = true;
	}

	pii ans = mp(-INF, INF);
	rep(i, -1000, 1000)
	{
		if (i < 0)
		{
			if (chmin(ans.second, abs(X - i)))
			{
				ans.first = i;
			}
		}
		else
		{
			if (USED[i])continue;
			if (chmin(ans.second, abs(X - i)))
			{
				ans.first = i;
			}
		}
	}

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

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {


	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int x = 0;
		boolean istax = false;
		int i = 1;
		for (; i < 1009 ; i++) {
			int x8 = (int)(i * 0.08);
			int x10 =(int)(i* 0.1);
			if(x8 == a && x10 == b) {
				istax = true;
				break;
			}
		}

		System.out.println(istax ? i : -1);

	}

}


Measured memory_bytes: 22996
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.StringTokenizer;

import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int a1=a/100;
    int a2=(a-a1*100)/10;
    int a3=a - a1*100 -a2*10;
   
    if (a3==a1) {
    	System.out.println("Yes");
    } else {
    	System.out.println("No");
    }
     
                    
    
    }
}

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

int main(){
    int n, sum=0, maxl=0; cin >> n;
    for(int i = 0; i < n; i++){
        int l; cin >> l;
        sum += l;
        if(maxl<l) maxl = l;
    }
    cout << ((sum - 2*maxl > 0)? "Yes" : "No") << endl;
    return 0;
}


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

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

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,a[310],one,two,three;
double dp[310][310][310];

void input(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==1)one++;
		if(a[i]==2)two++;
		if(a[i]==3)three++;
	}
	return;
}

void solve(){
	for(int i=0;i<=n;i++){
		for(int j=0;i+j<=n;j++){
			for(int k=0;i+j+k<=n;k++){
				if((!i)&&(!j)&&(!k))continue;
				double &r=dp[k][j][i];
				r=n;
				if(k)r+=dp[k-1][j][i]*k;
				if(j)r+=dp[k+1][j-1][i]*j;
				if(i)r+=dp[k][j+1][i-1]*i;
				r/=(i+j+k);
			}
		}
	}
	cout<<setprecision(20)<<dp[one][two][three]<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 225536
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

        List<Long> divisor = divisor(n);
        long min = 1000000000001L;
        for (Long elm : divisor) {
            min = Math.min(min, elm + (n / elm));
        }

        long ans = min - 2;
        System.out.println(ans);
    }

    static List<Long> divisor(long n) {
        Set<Long> ret = new HashSet<>();
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                ret.add(i);
                if (i != n / i)
                    ret.add(n / i);
            }
        }
        return ret.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
    }
}


Measured memory_bytes: 28368