akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long h[100010];
int main()
{
    long long n,a,b,i,c;
    long long l,r,m,cnt,q;
    cin>>n>>a>>b;
    for(i=1;i<=n;i++)
        scanf("%lld",&h[i]);
    sort(h+1,h+1+n);
    l=h[n]/a;if (h[n]%a==0) l--;
    r=h[n]/b;if (h[n]%b!=0) r++;
    c=a-b;
    while(l+1<r)
    {
        m=(l+r)/2;cnt=0;
        for(i=1;i<=n;i++)
        {
            q=h[i]-m*b;
            if (q>0)
            {
                cnt+=q/c;
                if (q%c!=0) cnt++;
            }
        }
        if (cnt<=m) r=m;
        else l=m;
    }
    cout<<r<<endl;
    return 0;
}

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

int main() {
int cnt=0;
  int N;
	string S;
  cin>>N>>S;
  for(int i=0; i<S.size()-2; i++){
    if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C'){cnt++;}}
  cout<<cnt<<endl;}


Measured memory_bytes: 256
a = [[0 for i in range(100)] for j in range(100)]
b = [[0 for i in range(100)] for j in range(100)]
n, m, l = map(int, input().split())
for i in range(n):
    a[i][:m] = map(int, input().split())
for i in range(m):
    b[i][:l] = map(int, input().split())
for i in range(n):
    for j in range(l):
        c = 0
        for k in range(m):
            c += a[i][k] * b[k][j]
        print(c, end='')
        if j < l - 1:
            print(' ', end='')
        else:
            print()

Measured memory_bytes: 8664
import java.util.Scanner;

class Main {

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

        boolean diff = false;
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i) < t.charAt(j)){
                    System.out.println("Yes");
                    return;
                }
                if (s.charAt(i) != t.charAt(j)) diff = true;
            }
        }

        if (s.length() < t.length() && !diff) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 23252
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

/*
 * ref. http://drken1215.hatenablog.com/entry/2018/06/08/210000
 *
 * usage:
 *
 * Combination *c;
 * 
 * const int MOD = 1000000007;
 * const int MAX_N = 100000;
 * 
 * int main(void) {
 *     int n, k;
 *     cin >> n >> k;
 *     c = new Combination(2 * MAX_N, MOD);
 *     cout << c->com(n + k - 1, k) << endl;
 *     delete(c);
 *     return 0;
 * }
 */
class Combination {
    public:
        const int max;
        const int mod;
        vector<ll> fac, finv, inv;

        Combination(int max, int mod) : max(max), mod(mod), fac(max), finv(max), inv(max) {
            init();
        }

        ll com(int n, int k) {
            if (n < k) return 0LL;
            if (n < 0 || k < 0) return 0LL;
            // return (fac[n] * ((finv[k] * finv[n - k]) % mod)) % mod;
            return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
        }

    private:
        void init() {
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < max; i++){
                fac[i] = fac[i - 1] * i % mod;
                inv[i] = mod - inv[mod%i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        }
};

Combination *c;

const int MOD = 1000000007;
const int MAX_N = 1000000;

// ref. https://abc021.contest.atcoder.jp/tasks/abc021_d
int main(void) {
    ll X, Y;
    cin >> X >> Y;

    if ((X + Y) % 3 != 0) {
        cout << "0" << endl;
        return 0;
    }

    ll walk_count = (X + Y) / 3;
    if (max(X, Y) > walk_count * 2) {
        cout << "0" << endl;
        return 0;
    }

    c = new Combination(3 * MAX_N, MOD);

    ll ans = c->fac[(X + Y) / 3];
    ans = (ans * c->finv[(2 * X - Y) / 3]) % MOD;
    ans = (ans * c->finv[(2 * Y - X) / 3]) % MOD;
    cout << ans << endl;

    delete(c);
    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define  pb push_back
#define nl "\n"
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);
#define int long long int
using namespace std;
int dp[123456];
int h[123456];
signed main()
{
	fastScan;
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
		dp[i]=(int)(1e18);
	}
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		for(int j=i-1;j>=i-k && j>=1;j--)
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	}
	cout<<dp[n]<<nl;
}


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

int main() {
  string a,b;
  cin >> a >> b;
  int n = stoi(a+b);
  for(int i = 0; i <= 1000; i++){
    if(i*i == n){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist

n, m = [ int(v) for v in input().split() ]
n_list_0 = [ int(v) % m for v in input().split() ]
n_list = cumsum(n_list_0)
n_list = [ i % m for i in n_list ]
b_dic = {}

for i in n_list:
    if i not in b_dic:
        if i == 0:
            b_dic[i] = 1
        else:
            b_dic[i] = 0
    else:
        b_dic[i] += 1

ans = 0
for i in b_dic.values():
    ans += i*(i+1)//2
print(ans)

Measured memory_bytes: 63768
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

	public static Boolean[][] adj;

	void run() {
		Scanner sc = new Scanner(System.in);

		//隣接行列の受け取り

		int N = sc.nextInt();
		int M = sc.nextInt();

		adj=new Boolean[N][N];

		for(Boolean[] B:adj) {
			Arrays.fill(B, false);
		}

		for (int i = 0; i < M; i++) {
			int A = sc.nextInt();
			int B = sc.nextInt();

			adj[A-1][B-1]=adj[B-1][A-1]=true;
		}

		boolean visited[]=new boolean[N];

		Arrays.fill(visited, false);

		visited[0]=true;

		pln(dfs(0,N,visited));


	}

	public static int dfs(int v,int N,boolean[] visited) {

		boolean allvisited=true;

		for (int i = 0; i < N; i++) {
			if(visited[i]==false) {
				allvisited=false;
			}
		}

		if(allvisited) {
			return 1;
		}

		int ret=0;

		for (int i = 0; i < N; i++) {
			if(adj[v][i]==false)continue;
			if(visited[i]==true)continue;

			visited[i]=true;
			ret+=dfs(i,N,visited);
			visited[i]=false;
		}

		return ret;


	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


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

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

  const int donuts = n / 7;
  for(int i = 0; i <= donuts; ++i){
    const int left = n - i * 7;
    if(left % 4 == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


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

int main() {
	unsigned long a, b, mod, big, small;
	while (cin >> a >> b) {
		if (a > b) {
			int stock = a;
			a = b;
			b = stock;
		}
		big = a;
		small = b;
		while (a % b != 0) {
			mod = a % b;
			a = b;
			b = mod;
		}
		cout << b << " " << big / b * small << endl;
	}
}

Measured memory_bytes: 1156
N = int(input())
rob = []
for i in range(N):
  x, l = map(int, input().split())
  rob.append((x-l, x+l))
rob.sort(key=lambda x: x[1])
t = rob[0][0]
ans = 0
for l, r in rob:
  if t <= l:
    ans += 1
    t = r
print(ans)

Measured memory_bytes: 18260
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(long long i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = numeric_limits<ll>::max();

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

    ll sum = 0;
    REP(i, K, N + 2){
        sum += i * ((N - i + 1) + N) / 2 - i * (0 + (i - 1)) / 2 + 1;
    }
    cout << sum % int(7 + 1e9) << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int n , k , w;
ll dp[105][100005];
ll a[105] , b[105] , c[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    cin >> w;
    for (int i=0;i<=n;i++)
        for (int j=0;j<=100000;j++)dp[i][j] = 1e18;
    for (int i=1;i<=n;i++)cin >> b[i] >> a[i];
    dp[0][0] = 0;
    ll ans = 0;
    for (int i=1;i<=n;i++)
    {
        for (int j=0;j<=100000;j++)
        {
            if (j >= a[i])dp[i][j] = min(dp[i][j] ,b[i] + dp[i - 1][j - a[i]]);
            dp[i][j] = min(dp[i][j] , dp[i - 1][j]);
            if (dp[i][j] <= w)ans = max(ans , (ll)j);
        }
    }
    cout << ans << endl;
    //cout << "Hello world!" << endl;
    return 0;
}


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

int main() {
    string n;
    cin >> n;
    if (n[0]==n[1] && n[1]==n[2] || n[1]==n[2] && n[2]==n[3]) {
        cout << "Yes" <<endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N , c1 , c2 = 0;
  cin >> N;
  for(int i = 1 ; i <= N ; i++)
  {
    if(i % 2 == 1)
    {
      c1 = 0;
      for(int j = 1 ; j <= i ; j++)
      {
        if(i % j == 0)
        {
          c1++;
        }
      }
      if(c1 == 8)
      {
        c2++;
      }
    }
  }
  cout << c2 << endl;
}

Measured memory_bytes: 3588
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int x,n;
	cin >> x >> n;
	set<int> st;
	int a;
	for(int i = 0; i < n; ++i){
		cin >> a;
		st.insert(a);
	}
	for(int i = 0; i <= n; ++i){
		int tt = x - i;
		if(st.find(tt) == st.end()){
			cout << tt << endl;
			break;
		}
		tt = x + i;
		if(st.find(tt) == st.end()){
			cout << tt << endl;
			break;
		}
	}
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3632
//
//  main.cpp
//  A
//
//  Created by Yoshinao Itakura on 2020/08/02.
//  Copyright © 2020 Yoshinao Itakura. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
using namespace std;

int main(int argc, const char * argv[]) {
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<< "No" << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll a, b; cin >> a >> b;

	ll n = a;
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		n = n * 2;
		if (n <= b) {
			ans++;
		}
		else {
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100005;
struct ii {
	ll a, b;
	bool operator < (ii o) const {
		return tie(a, b) < tie(o.a, o.b);
	}
};

ll N;
ii arr[2*MAXN], pos[MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	ll a = 0, b = 0;
	for (int i = 0; i < N; i++) {
		cin >> arr[2*i].a >> arr[2*i|1].a;
		pos[i] = {arr[2*i].a, arr[2*i|1].a};
		a += arr[2*i].a;
		b += arr[2*i|1].a;
		arr[2*i].b = arr[2*i|1].b = i;
	}
	sort(arr, arr+2*N);
	
	ll pasti = 0;
	for (int i = 0; i < N-2; i++) pasti += arr[i].a;
	
	ll ans = min(a, b);
	for (int i = 0;i < N; i++) {
		ll cur = 0, idx = N-2;
		if (arr[idx].a >= pos[i].a) {
			cur += arr[idx++].a;
		} else {
			cur += pos[i].a;
		}
		if (arr[idx].a >= pos[i].b) {
			cur += arr[idx++].a;
		} else {
			cur += pos[i].b;
		}
		ans = min(ans, pasti+cur);
	}
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __DJKIM613
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    cin >> N;
    for(int i = 1 ; i <= 9 ; i++) {
        for(int j = 1 ; j <= 9 ; j++) if(i * j == N) return cout << "Yes\n", 0;
    }

    cout << "No\n";
    return 0;
}

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

using namespace std;

int P, N, L, a[100009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &L);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
for (int i=1; i<N; i++)
    if (a[i] + a[i + 1] >= L) P = i;
if (P)
{
    printf ("Possible\n");
    for (int i=1; i<P; i++)
        printf ("%d\n", i);
    for (int i=N - 1; i>P; i--)
        printf ("%d\n", i);
    printf ("%d\n", P);
}
else printf ("Impossible");

return 0;
}


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

using namespace std;
int main()
{
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a <=k){
        cout<<"Yay!";
    }
    else{
        cout<<":(";
    }

    return 0;
}

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

int main(){
    ll i,j,n,sum,without1;
    cin >> n;
    sum = 0;
    ll a[n],b[n],c[n];
    for(i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    without1 = 0;

    for(i = 1; i < n; i += 2){
        without1 += 2 * a[i];
    }
    b[0] = sum - without1;

    for(i = 1; i < n; i++){
        b[i] = 2 * a[i-1] - b[i-1];
    }

    for(i = 0; i < n; i++){
        cout << b[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2816
s=input()
n=len(s)
ans=[]
for i in range(n):
        if s[i]=='0':
                ans.append('0')
        elif s[i]=='1':
                ans.append('1')
        else:
                if ans==[]:
                        continue
                else:
                        ans.pop(-1)
for i in range(len(ans)):
        print(ans[i],end='')

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
using LL = long long;

int main() {

    int N, T;
    cin >> N >> T;

    LL X = 0, stop_at = 0;

    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        if (t >= stop_at) {
            X += T;
        } else {
            X += T - (stop_at - t);
        }
        stop_at = t + T;
    }

    cout << X << endl;
}

Measured memory_bytes: 256
n = int(input())
P = [0] + [int(i) for i in input().split()]
Q = [0] + [int(i) for i in input().split()]
L = [0, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]

Pth = 1
for i in range(1, n+1):
    cnt = 0
    for j in range(i+1, n+1):
        if P[i] > P[j]:
            cnt += 1
    Pth += cnt * L[n - i]
# print(Pth)

Qth = 1
for i in range(1, n+1):
    cnt = 0
    for j in range(i+1, n+1):
        if Q[i] > Q[j]:
            cnt += 1
    Qth += cnt * L[n - i]
# print(Qth)

print(abs(Pth-Qth))


Measured memory_bytes: 3064
from collections import deque
N, Q = map(int, input().split())

tree = [[] for _ in range(N+1)]

for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

c = [0] * (N+1)

for _ in range(Q):
    p, x = map(int, input().split())
    c[p] += x


ans = [0] * (N+1)

go = deque([1])
went = [False] * (N+1)
went[1] = True
ans[1] = c[1]
while len(go) > 0:
    now = go.popleft()
    for child in tree[now]:
        if went[child]:
            continue
        go.append(child)
        ans[child] = ans[now] + c[child]
        went[child] = True

print(*ans[1:])


Measured memory_bytes: 63568
N = int(input())
L = [input() for _ in range(N)]

before = L[0]
words = set([before])
for i in range(1, N):
    if before[-1] is not L[i][0] or L[i] in words:
        print("No")
        exit()
    before = L[i]
    words.add(before)

print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc170_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N = 5;
  
  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  rep(i, N) {
    if (c[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}

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

int main(){
    int n,sv=0,sc=0;
    cin >> n;
    vector<int> v(n),c(n);
    for(int i=0;i<n;i++) cin >> v.at(i);
    for(int i=0;i<n;i++) cin >> c.at(i);
    for(int i=0;i<n;i++){
        if(v.at(i)>c.at(i)){
            sv=sv+v.at(i);
            sc=sc+c.at(i);
        }
    }
    cout << sv-sc << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using ll = long long;
using ull = unsigned long long;
const static unsigned MOD = 1000000007;

ull RepeatSquaring(ull N, ull P){
	if(P == 0) return 1;
	if(!(P & 1)){
		ull t = RepeatSquaring(N, P >> 1);
		return t*t % MOD;
	}
	//Pが偶数のときN^(P/2)を求めてからそれの2乗を返す
	return N*RepeatSquaring(N, P - 1) % MOD;
	//Pが奇数のときN^((P - 1)/2)を求めてからそれの2乗を返す
}

int main(){
	unsigned N, K;
	scanf("%u %u", &N, &K);
	ull ans = N - K + 1;
	for (ull i = 1; i <= K; ++i){
		if(i > N - K + 1){
			for (int j = 0; j < K - i + 1; ++j) printf("0\n");
			return 0;
		}
		if(i > 1){
			(ans *= N - K + 2 - i) %= MOD;
			(ans *= RepeatSquaring(i, MOD - 2)) %= MOD;
			(ans *= K - i + 1) %= MOD;
			(ans *= RepeatSquaring(i - 1, MOD - 2)) %= MOD;
		}
		printf("%llu\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	cin >> n;
	REPO(i, n) {
		if (i * 108 / 100 == n) {
			cout << i << endl;
				return 0;
		}
	}
	cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
typedef unsigned long long ull;
typedef long long ll;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
char s[10];
int main(){
	 cin>>s;
	 if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])o("Bad");
	 else o("Good");
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef   long long int ll;
int main () 
{ ll x;
  long double y=1.01,i,a=100.0;cin>>x;
  ll count=0,e=1,u;
  while (e!=0) {
       count++;
       i=a*y;
       u=(long long)(i);
      // cout<<u<<endl;
      if (u>=x) {e=0;break;}
      else a=u;
  }
  cout<<count<<endl;
}

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

using namespace std;


int main(){
    int coin[6]={1,5,10,50,100,500},in,ans;
    

 while(1){
    ans=0;
    scanf("%d",&in);
    
    if(in==0)
      break;

    in=1000-in;
    
    for(int i=5;i>=0;i--){
        ans+=in/coin[i];
        in%=coin[i];
    }
    
    printf("%d\n",ans);
    
  }
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int MOD = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
      int arr[3];
      cin>>arr[0]>>arr[1]>>arr[2];
      sort(arr,arr+3);
      if((arr[0]==arr[1]&&arr[1]!=arr[2])||(arr[2]==arr[1]&&arr[1]!=arr[0]))
        cout<<"Yes"<<el;
      else
        cout<<"No"<<el;
    }
   return 0;
}


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

int main () {
  string s;
  cin>>s;
  int l=s.size();
  int cnt=0;
  int cnt_inv=0;
  for (int i=0;i<l/2;++i) {
    if (s[2*i]=='0') {
      cnt+=1;
    } else {
      cnt_inv+=1;
    }
    if (s[2*i+1]=='1') {
      cnt+=1;
    } else {
      cnt_inv+=1;
    }
  }
  if (l%2==1) {
    if (s[l-1]=='0') {
      cnt+=1;
    } else {
      cnt_inv+=1;
    }
  }
  int ans=min(cnt,cnt_inv);
  cout<<ans<<endl;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
T = set()

for x in A: T.add(x)

maxi = max(A)

for x in sorted(A):
    i = 2
    while x * i <= maxi:
        if x * i in T:
            T.remove(x*i)
        i += 1
ans = 0

def counter(array):
    from collections import Counter
    return Counter(array)
c = counter(A)
for x in T:
    if c[x] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 117732
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<string>s(n);
    map<string,int>mp;
    rep(i,n){
        cin>>s[i];
        if(mp.count(s[i])==0){
            mp.insert(make_pair(s[i],1));
        }
        else{
            mp[s[i]]++;
        }
    }
    int m;
    cin>>m;
    vector<string>t(m);
    rep(i,m){
        cin>>t[i];
        if(mp.count(t[i])!=0){
            mp[t[i]]--;
        }
    }
    int ans=0;
    rep(i,n){
        ans=max(ans,mp[s[i]]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char a[3];
    scanf("%s",a);
    if(strcmp(a,"SUN")==0)
    {
        printf("7\n");
    }
    else if(strcmp(a,"SAT")==0)
    {
        printf("1\n");
    }
     else if(strcmp(a,"MON")==0)
    {
        printf("6\n");
    }
   else if(strcmp(a,"TUE")==0)
    {
        printf("5\n");
    }
   else if(strcmp(a,"WED")==0)
    {
        printf("4\n");
    }
    else if(strcmp(a,"THU")==0)
    {
        printf("3\n");
    }
    else if(strcmp(a,"FRI")==0)
    {
        printf("2\n");
    }
}


Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<string> a(n),b(m);
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
  }
  for (int i = 0; i < m; ++i)
  {
    cin>>b[i];
  }
  for (int x = 0; x <= n-m; ++x)
  {
    for (int y = 0; y <= n-m; ++y)
    {
      bool flag=true;
      for (int i = 0; i < m; ++i)
      {
        for (int j = 0; j < m; ++j)
        {
          if(b[i][j]!=a[x+i][y+j]) flag=false;
        }
      }
      if(flag){
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int n;int t[100005], x[100005], y[100005];
int main()
{
  cin >> n;
  for (int i = 0; i < n;i++)
  {
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }
  bool flag = true;
  for (int i = 0; i < n;i++)
  {
    int dt = t[i + 1] - t[i];
    
    int distance = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if(dt<distance)
      flag = false;
    if(dt%2!=distance%2)
      flag = false;
  }
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

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


Measured memory_bytes: 256
n, m = gets.split.map &:to_i

like = Array.new(m, 0)

n.times{
	as = (gets.split.map &:to_i)[1..-1]
	as.each{ |a|
		like[a-1] += 1
	}
}

puts like.select{ |x| x == n}.size


Measured memory_bytes: 1788
using System;
using System.Linq;

namespace ABC092B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] dx = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                int a = int.Parse(Console.ReadLine());
                for (int j = 0; j < dx[0]; j += a)
                {
                    ans += 1;
                }
            }
            ans += dx[1];
            Console.WriteLine(ans);

        }
    }
}

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

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

const ll INF = 1LL<<58;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,w;
    cin >> n >> w;
    vector<vector<ll>> dp(n+1,vector<ll>(100010,INF));
    dp[0][0] = 0;
    for (int i = 0;i < n;++i) {
        int u,v;
        cin >> u >> v;
        dp[i+1] = dp[i];
        for (int j = 0;j <= 100010-v;++j) dp[i+1][j+v] = min(dp[i+1][j+v],dp[i][j]+u);
    }
    ll ans = 0;
    for (int i = 0;i < 100010;++i) if (dp[n][i] <= w) ans = i;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;

		for(int i=0; i<N; i++){
			sum += i+1;
        }
		System.out.println(sum);
	}
}


Measured memory_bytes: 23764
/*
author: orthodoxparadox
01-Sep-2018
17:32:16
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ") 
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}
#else
#define dbg(...)
#endif

int __gcd(int a, int b)
{
	return b ? __gcd(b, a%b) : a;
}

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int k;
	cin >> k;
	cout << (k/2)*((k+1)/2);

	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}

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

int main() {
	int N;
	int p;
	int a[60010];

	cin >> N;

	for (int i = 1; i < 100; i++) {
    	for (int j = 1; j < 100; j++) {
			p=i*i+j*j+i*j;
			if(p>10000) break;
			for (int k = 1; k < 100; k++) {
				p+=k+k-1+i+j;
				if(p>10000) break;
				a[p]++;
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
struct st
{
	int p,b,c;
};
bool operator<(st a,st b)
{
	return a.c>b.c;
}
vector<int>G[100000];
unordered_map<int,int>d[100000];
unordered_map<int,vector<int>>E[100000];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int p,q,c;
		scanf("%d%d%d",&p,&q,&c);
		p--;
		q--;
		E[p][c].push_back(q);
		E[q][c].push_back(p);
		G[p].push_back(c);
		G[q].push_back(c);
	}
	priority_queue<st>que;
	d[0][0]=0;
	que.push({0,0,0});
	while(!que.empty())
	{
		st p=que.top();
		que.pop();
		if(d[p.p][p.b]!=p.c)
			continue;
		if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c)
		{
			d[p.p][0]=p.c;
			que.push({p.p,0,p.c});
		}
		if(p.b==0)
		{
			for(int v:G[p.p])
			{
				if(d[p.p].find(v)==d[p.p].end()||d[p.p][v]>p.c+1)
				{
					d[p.p][v]=p.c+1;
					que.push({p.p,v,p.c+1});
				}
			}
			continue;
		}
		for(int v:E[p.p][p.b])
		{
			if(d[v].find(p.b)==d[v].end()||d[v][p.b]>p.c)
			{
				d[v][p.b]=p.c;
				que.push({v,p.b,p.c});
			}
		}
	}
	int Min=INT_MAX;
	for(auto p:d[n-1])
		Min=min(Min,p.second);
	if(Min==INT_MAX)
		puts("-1");
	else
		printf("%d\n",Min);
	return 0;
}


Measured memory_bytes: 80020
#include<stdio.h>
int bubblesort(int A[100],int n);
int A[100],out=0;

int main()
{
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  bubblesort(A,n);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
    printf("%d\n",A[n-1]);
  printf("%d\n",out);
  return 0;
}

int bubblesort(int A[],int n)
{
  int i,j,temp;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(A[j]<A[j-1])
      {
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
   out++;
    }
    }
  }
}

Measured memory_bytes: 600
<?php

$nums = explode(' ',trim(fgets(STDIN)));

$a = $nums[0];

$b = $nums[1];

$c = $nums[2];
$count = 0;
for($i=$a;$i<=$b;$i++){
	
	if( ($c % $i) === 0){
	   $count++; 
	}
}

echo $count,PHP_EOL;

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






int main(){
	int x , y, z;
	cin>>x>>y>>z;
	 x = x%y, z  = z%y;
	if(x == z){
		cout<<"YES";
		return 0;
	}
	if(x == 0 && z != 0 ){
	 cout<<"NO"<<endl;
	 return 0;
	}
	if(x != 0 && z == 0 ){
	 cout<<"NO"<<endl;
	 return 0;
	}
     bool flag = false;
     for(int i = 1 ; i<= 100000;i++){
     	if(i*x%y == z) flag = true;
     }
     flag ? cout<<"YES" : cout<<"NO";
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
sm = []
sm.append(a[0])
for i in range(1,n):
    sm.append(sm[-1]+a[i])
num = 0
for i in range(1,n):
    if sm[i-1] * 2 < a[i]:
        num = i
        
print(n - num)


Measured memory_bytes: 14308
# include <bits/stdc++.h>
typedef long long lint;
using namespace std;

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

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

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}


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

  vector<lint> a(n,(s+1)%1000000000);
  for(lint i=0;i<k;i++) { a[i] = s; }


  for(lint i=0;i<n;i++) { cout << a[i] << " "; }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    int N = s.size();
    long ans = 0;
    long cnta = 0;
    if(s[0] == 'A') cnta = 1;
    for(int i = 1; i < N; i++){
        //cout << cnta << endl;
        if(s[i] == 'C' && s[i-1] == 'B') ans += cnta;
        if(s[i] == 'B' && s[i-1] == 'B') cnta = 0;
        if(s[i] == 'C' && s[i-1] == 'C') cnta = 0;
        if(s[i] == 'A' && s[i-1] == 'B') cnta = 0;
        if(s[i] == 'C' && s[i-1] == 'A') cnta = 0;
        if(s[i] == 'A') cnta++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

#print(S, T)
S_set = set(S)
#print(S_set)

max_cnt = -100
for checker in S_set:
  cnt = 0
  for s in S:
    if s == checker:
      cnt += 1
  for t in T:
    if t == checker:
      cnt -= 1
  if cnt > max_cnt:
    max_cnt = cnt
if max_cnt < 0:
  print(0)
else:
  print(max_cnt)
  

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

int main(){
    int L, R, d;
    std::cin >> L >> R >> d;
    
    int ans = 0;
    for(int i=L; i<=R; i++){
        if(i % d == 0){
            ans++;
        }
    }
    std::cout << ans << std::endl;
    
    return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <set>

using namespace std;

int main()
{
    int n, q;
    string s;

    cin >> n >> s;
    cin >> q;

    set<int> idx[26];
    for (int i = 0;i < s.size();i++)
    {
        idx[s[i] - 'a'].insert(i);
    }
    
    for (int i = 0;i < 26;i++)
    {
        idx[i].insert(s.size());
    }

    while(q--)
    {
        int qi;
        cin >> qi;
        if (qi == 1)
        {  
            int i;
            char c;
            cin >> i >> c;
            i --;
            idx[s[i] - 'a'].erase(i);
            idx[c - 'a'].insert(i);
            s[i] = c;
        }else
        {
            int l, r;
            cin >> l >> r;
            l --;
            r --;
            int cnt = 0;
            for (int i = 0;i < 26;i++)
            {
                set<int>::iterator it = idx[i].lower_bound(l);
                if (*it <= r) cnt ++;
            }
            cout << cnt << endl;
        }
    }
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int a_cnt = 0;
	int b_cnt = 0;
    int ab_cnt = 0;
	int ans = 0;
	REP(i,n){
		string s;
		cin >> s;
        if(s[0]=='B' && s.back()=='A') ab_cnt++;
		else if(s[0]=='B') b_cnt++;
		else if(s.back()=='A') a_cnt++;
		REP(k, s.size()-1){
			if(s[k]=='A' && s[k+1]=='B') ans++;
		}
	}
	if(ab_cnt>0 && (a_cnt + b_cnt)==0) ans += ab_cnt - 1;
    else ans += ab_cnt + min(a_cnt, b_cnt);
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);
    int ans=1;
    int old=1, older=1;
    for(int i=2; i<=n; i++){
        older=old;
        old=ans;
        ans=(old+older);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2696
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int vfind(vector<ll> v, ll num) {
    auto itr = find(v.begin(), v.end(), num);
    size_t index = distance( v.begin(), itr );
    if (index != v.size()) { // 発見できたとき
        return 1;
    }
    else { // 発見できなかったとき
        return 0;
    }
}

int main(){
    ll a,b;
    cin >> a >> b;
    if (a+b<10){
        cout << a+b << endl;
    }else{
        cout << "error" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	string s1, s2, s;
	cin >> s1 >> s2;
	s = s1 + s2;
	stringstream ss;
	ss << s;
	int num;
	ss >> num;

	int ret = sqrt(num);
	if(ret*ret == num || (ret+1)*(ret+1) == num) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> a(N+1);
  for(int i = 1; i <= N; ++i) cin >> a[i];
  vector<int> b(N+1);
  for(int i = N; i >= 1; --i) {
    int sum = 0;
    for(int j = i+i; j <= N; j += i) {
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }
  vector<int> ans;
  for(int i = 1; i <= N; ++i) {
    if(b[i]) ans.push_back(i);
  }
  std::cout << ans.size() << std::endl;
  for(int i = 0; i < ans.size(); ++i) {
    std::cout << ans[i];
    if(i+1 == ans.size()) std::cout << std::endl;
    else std::cout << ' ';
  }
}


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, k, x;
	long long ans = 0;
	vector<long long> h;
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		cin >> x;
		h.push_back(x);
	}
	sort(h.begin(), h.end(), greater<int>());

	for (int i = k; i < n; i++) ans += h[i];

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


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String answer = "APPROVED";
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            if ((num % 2) != 0) {
                continue;
            }
            if (((num % 3) == 0) || ((num % 5) == 0)) {
                continue;
            } else {
                answer = "DENIED";
                break;
            }
        }
        System.out.println(answer);
        sc.close();
    }
}


Measured memory_bytes: 35724
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: isize,
        a: [isize; n],
    }

    let mut r = 0;
    for elem in &a {
        r ^= elem;
    }

    for elem in a {
        print!("{} ", elem ^ r);
    }
}


Measured memory_bytes: 6328
def lcm(a,b):
    ab = a*b
    while b != 0:
        a, b = b, a%b
    return ab //a

def su(n,c,d):
    return n - n//c - n//d + n//lcm(c,d)
    
def main():
    a,b,c,d = map(int,input().split())
    print(su(b,c,d) - su(a-1,c,d))
    
if __name__ == '__main__':
    main()

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

bool match(string s, string t, int index) {
  for (int i = index; i < index + t.size(); i++) {
    if (s[i] != t[i - index] && s[i] != '?') return false;
  }
  return true;
}

int main() {
  string s, t;
  cin >> s >> t;
  if (s.size() < t.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  vector<string> v;
  for (int i = 0; i + t.size() <= s.size(); i++) {
    if (match(s, t, i)) {
      string res = s;
      res.replace(i, t.size(), t);
      for (int j = 0; j < res.size(); j++) {
        if (res[j] == '?') {
          res.replace(j, 1, "a");
        }
      }
      v.push_back(res);
    }
  }
  sort(v.begin(), v.end());
  if (v.size()) cout << v[0] << endl;
  else cout << "UNRESTORABLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define fr(i,a,b) for(int i=a;i<=b;i++)
int f[]={0,1,2,4,7,12,20,29,38,52,73},n;
int main()
{
	std::cin>>n;
	long d[11][11]={0},p=1;
	fr(i,2,n){fr(j,1,i-1)d[i][j]=d[j][i]=p*f[j];p+=d[i][i-1]+d[i][i-2]-d[i-1][i-2];}
	fr(i,1,n)fr(j,1,n)std::cout<<d[i][j]<<" \n"[j==n];
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<queue>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define reps(i,n) for(int i=1;i<=int(n);i++)

#define f first
#define s second

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0)break;
		
		int hon[111];
		rep(i,m){
			cin>>hon[i];
		}
		
		double left=0;
		double right=15000001;
		
		while(1){
			double h=(left+right)/2;
			
			int dan=1;
			int now=0;
			rep(i,m){
				if(now+hon[i]>h){
					now=0;
					i--;
					dan++;
				}else{
					now+=hon[i];
				}
				if(dan>n)break;
			}
			
			if(dan>n){
				left=h;
			}else{
				right=h;
			}
			
			if(right-left<0.0001){
				printf("%d\n",(int)(right+0.001));
				break;
			}
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if (v[i] == v[j] || v[j] == v[k])
                    continue;
                if (v[i] + v[j] > v[k])
                    ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628