akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int N;
int a[100010];
int c[100010];
int d[100010];
LL ans[100010];
LL s;
int m;

bool comp(const int x , const int y){
	return a[x] == a[y] ? x > y : a[x] < a[y];
}

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		scanf("%d" , a + i);
		c[i] = i;
	}
	sort(c,c+N,comp);
	int z = 0;
	int p = 0;
	LL s = a[c[0]];
	repp(i,0,N){
		if(i > 0 && a[c[z]] >= a[i]){
			printf("0\n");
			continue;
		}
		while(c[z] != i){
			++z;
			s += a[c[z]] - p;
		}
		printf("%lld\n" , s + (LL)(N-z-1) * (a[i]-p));
		p = a[i];
		s = 0;
	}
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
    public void solve(){
        int t,y,men,syu;
        Scanner sc=new Scanner(System.in);
        t=sc.nextInt();
        y=sc.nextInt();
        men=t*y;
        syu=t*2+y*2;
        System.out.println(men+" "+syu);
    }
	public static void main(String[]args){
		Main obj =new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;


int main(){
    int a,b,c;cin>>a>>b>>c;
    int f=a-b;
    cout<<max(0,c-f)<<endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
//#define LOCAL



int main(int argc, char * argv[]) 
{
	#ifdef LOCAL
	freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.in", "r", stdin);
	//freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.out", "w", stdout);
	#endif

	int w, n, a[50], f, s;

	while (~scanf("%d", &w))
	{
		for (int i = 1; i <= w; i++)
			a[i] = i;
		scanf("%d", &n);
		while(n--)
		{
			scanf("%d,%d", &f, &s);
			swap(a[f], a[s]);
		}
		for (int i = 1; i <= w; i++)
			printf("%d\n", a[i]);
	}

    return 0;
}

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

int main(int argc, char const *argv[])
{
    int i, j, d, x, n, k;
    int *sunuke;

    scanf("%d", &n);
    scanf("%d", &k);
    sunuke = (int*)malloc(sizeof(int) * n);
    for(i = 0; i < n; ++i) sunuke[i] = 0;
    
    for(i = 0; i < k; ++i) {
        scanf("%d", &d);
        for(j = 0; j < d; ++j) {
            scanf("%d", &x);
            sunuke[x-1] = 1;
        }
    }

    int noOkashi = 0;

    for(i = 0; i < n; ++i) {
        if(!sunuke[i]) noOkashi++;
    }
    printf("%d", noOkashi);
    return 0;
}


Measured memory_bytes: 1732
#include<stdio.h>

int main(void)
{
	int a, b, n;
	scanf("%d %d %d", &n, &a, &b);



	if ((b - a) % 2 == 1)
	{
		printf("Borys");
	}


	else
	{
		printf("Alice");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 2003;

int n, k, d;
vi adj[N];
int f[N], t[N];

int dfs(int cur, int par = -1, int len = 0) {
	if (len == d)
		return 1;
	int res = 1;
	for (auto to : adj[cur]) {
		if (to == par)
			continue;
		res += dfs(to, cur, len + 1);
	}
	return res;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> k;
	d = k / 2;
	for (int i = 0; i < n - 1; i++) {
		cin >> f[i] >> t[i];
		f[i]--, t[i]--;
		adj[f[i]].pb(t[i]);
		adj[t[i]].pb(f[i]);
	}
	int res = OO;
	if (k & 1) {
		for (int i = 0; i < n - 1; i++)
			res = min(res, n - (dfs(f[i], t[i]) + dfs(t[i], f[i])));
	} else {
		for (int i = 0; i < n; i++)
			res = min(res, n - dfs(i));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
while True:
    i = input().split()
    if i[1] == "?":
        break
    if i[1] == "+":
        print(int(i[0])+int(i[2]))
    if i[1] == "-":
        print(int(i[0])-int(i[2]))
    if i[1] == "*":
        print(int(i[0])*int(i[2]))
    if i[1] == "/":
        print(int(int(i[0])/int(i[2])))
    pass

Measured memory_bytes: 7668
#include<stdio.h>
int main()
{
  int h,w,i,j;
  while(scanf("%d%d",&h,&w) != EOF)
    {
     if((h==0)&&(w==0)) break;
      for(i=0; i<h; i++)
	{
	  for(j=0; j<w; j++)
	    {
	      if((i==0)||(i==h-1)||(j==0)||(j==w-1)) printf("#");
	      else printf(".");
	    }
	  printf("\n");
	}
      printf("\n");
    }
   return 0;
}

Measured memory_bytes: 572
#include <vector>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <list>
#include <map>
#include <istream>
#include <bitset>
#include <sstream>
#include <unordered_map>
#include <stack>
#include <set>
#include <cmath>
#include <random>
#include <iostream>
#include <bitset>
#include <iomanip>
#include <queue>
#include <string>

#define int long long
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rr return 0
#define xx first
#define yy second
#define pii pair<int,int>

using namespace std;
typedef long long ll;
typedef long double ld;

string s, t;
vector<vector<int>> p;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> t;
    map<char, int> mp;
    p.resize(40);
    for(int i = 0;i < s.size();i++){
        mp[s[i]]++;
        p[s[i] - 'a'].push_back(i);
    }
    for(int i = 0;i < t.size();i++){
        if(mp[t[i]] == 0){
            cout << -1;
            rr;
        }
    }
    int ans = p[t[0] - 'a'][0];
    for(int i = 1;i < t.size();i++){
        int l, r, m;
        l = 0;
        r = p[t[i] - 'a'].size() - 1;
        //cout << t[i] - 'a' << endl;
        int ind = ans % s.size();
        while(r - l > 1){
            m = (r + l) / 2;
            if(p[t[i] - 'a'][m] > ind){
                r = m;
            }else{
                l = m;
            }
        }
        if(p[t[i] - 'a'][l] > ind){
            ans += (p[t[i] - 'a'][l] - ind);
        }else if(p[t[i] - 'a'][r] > ind){
            ans += (p[t[i] - 'a'][r] - ind);
        }else{
            ans += s.size() - (ind - p[t[i] - 'a'][0]);
        }
    }
    cout << ans + 1;
    rr;
}



Measured memory_bytes: 1736
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

ll ans[2*100000];
VVI edge(2*100000);
vector<int> score(2*100000,0);
int done[2*100000];

void dfs(int node, ll prev_score){
    done[node] = 1;
    ans[node] = prev_score + score[node];
    for(int n : edge[node]){
        if(done[n] == 0) dfs(n, ans[node]);
    }
}

int main(void){
    int N, Q;
    cin >> N >> Q;
    REP(i,N) done[i] = 0;
    REP(i,N-1){
        int a,b;
        cin >> a >> b;
        edge[a-1].push_back(b-1);
        edge[b-1].push_back(a-1);
    }
    REP(i,Q){
        int p,x;
        cin >> p >> x;
        score[p-1] += x;
    }
    dfs(0,0);
    REP(i,N){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 22656
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set> 
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define inf 2001
#define INF (int)2e9 
#define mod (ll)(1e9+7)
#define pi acos(-1)
#define mxbit 30
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;
//#define int long long

int Qpow2(int k){
	if (k==-1){
		return 1;
	}
	ll x=2,ans=1LL;
	while (k){
		if (k&1){
			ans=(ans*x)%mod;
		}
		x=(x*x)%mod;
		k/=2;
	}
	return (int)ans;
}

int dp[inf][inf];

main(){
	int n,k;
	rd(n) rd(k)
	dp[0][n+1]=1;
	for (int i=1;i<=k;i++){
		int sum=dp[i-1][n+1];
		for (int j=n;j>=1;j--){
			sum=(sum+dp[i-1][j])%mod;
			if (j<=n-i+1){
				dp[i][j]=sum;
			}
		}
	}
	ll ans=(dp[k][1]-dp[k-1][1]+mod)%mod*Qpow2(n-k-1)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15360
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
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 (a > b) { a = b; return true; } return false; }


signed main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> table(H, vector<int>(W));
    for (int i =0; i< H; i++) {
        string str;
        cin >> str;
        for (int j = 0; j < W; j++) {
            table[i][j] = str[j] - '0';
        }
    }

    int mn = INF;

    for (int mask = 0; mask < (1 << (H-1)); mask++) {
        vector<vector<int>> table2(W);
        for (int j = 0; j < W; j++) {
            int val = 0;
            for (int i = 0; i < H; i++) {
                val += table[i][j];
                if ((mask >> i) & 1) {
                    table2[j].push_back(val);
                    val = 0;
                }
            }
            table2[j].push_back(val);
        }
        int h = table2.size();
        int w = table2[0].size();

        vector<int> buffer(w, 0);
        int cnt = 0;
        bool valid = true;
        for (int i =0; i < h; i++) {
            bool update = false;
            for (int j =0; j < w; j++) {
                if (table2[i][j] + buffer[j] > K) update = true;
            }
            if (update) {
                cnt++;
                for (int j = 0; j < w; j++) {
                    buffer[j] = table2[i][j];
                    if (buffer[j] > K) {
                        valid = false;
                    }
                }
            } else {
                for (int j = 0; j < w; j++) buffer[j] += table2[i][j];
            }
        }
        if (valid) mn = min(mn, cnt + __builtin_popcount(mask));
    }

    cout << mn << endl;
}

Measured memory_bytes: 544
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
	string s;
	cin>>s;
	ll cnt=0,final=-1;
	for(ll i=0;i<s.length();i++)
	{
		if(s[i]=='R')
		{
			cnt++;
		}
		else
		{
			final=max(final,cnt);
			cnt=0;
		}
	}
	final=max(final,cnt);
	cout<<final;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

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

int main(void){
    int n;
    std::cin >> n;
    bool flag = false;
    for(int i = 0; i < 3; i++){
        if(n % 10 == 7){
            flag = true;
            break;
        }
        n = n / 10;
    }
    if(flag){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3588
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int r, D, x2000;
    private void solve() {
        r = nextInt();
        D = nextInt();
        x2000 = nextInt();

        int sum = x2000;
        for(int i = 0;i < 10;i++) {
            sum = sum * r - D;
            out.println(sum);
        }
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22868
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H == 0&&W == 0){
            break;
        }
        for(int i=0;i<H;i++){
            for(int n=0;n<W;n++)cout<<"#";
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>
int main()
{
  size_t size{},sizeR{},sizeB{};
  std::string input;
  std::cin>>size>>input;
  for(size_t i{};i<size;++i)
    if (input[i]=='R')
      ++sizeR;
    else
      ++sizeB;
  if (sizeB<sizeR)
    std::cout<<"Yes";
  else
    std::cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


long N, K;
long check(long i){
    long cnt = 0;
    while(i < K){
        cnt++;
        i *= 2;
    }
    return cnt;
}

int main(){
cin >> N >> K;
double ans = 0;
// ans = check(1);
erep(i, N){
    ans += pow(0.5000000000000000, (double)check(i));
// show(pow(0.5000000000000000, (double)check(i)));
}
// show(ans);

ans = ans / (double)N;

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

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer A[] = new Integer[N];
        for(int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }
        while(true) {
            Arrays.sort(A);
            int min = 0;
            boolean f = false;
            for (int i = 0; i < N; i++) {
                if(A[i] == 0) continue;
                if(min==0) {
                    min=A[i];
                    continue;
                }

                A[i] = A[i] % min;
                if (A[i] != 0) f = true;
            }
            if (!f) {
                System.out.println(min);
                return;
            }
        }

//        System.out.println(B - A);
    }
}


Measured memory_bytes: 61044
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll a, b;
	
	return YesNo(a % 2 == 1 && b % 2 == 1);
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; 
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)           


void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

class DSU
{
	public : 
	vector < int >  parent, sz;
	DSU(int n)
	{
		parent = vector < int > (n + 1); 
		sz = vector < int > (n + 1, 1); 
		iota(parent.begin(), parent.end(), 0);  
	}

	int find_set(int i)
	{
		if(i == parent[i])
			return i; 
		else return parent[i] = find_set(parent[i]); 
	}

	void union_sets(int i, int j)
	{ 
		i = find_set(i); 
		j = find_set(j);

		if(i  == j)
			return; 

		if(sz[i] > sz[j])
			swap(i, j);  
		
		parent[i] = j; 
		sz[j] += sz[i]; 
	}
}; 

int32_t main()
{
	fastIO
	inp_out();
	int n; 
	cin >> n; 
	vi a(n); 
	
	int gd = 0; 
	for(int i = 0; i < n; ++ i)
	{
		cin >> a[i]; 
		gd = __gcd(gd, a[i]); 
	}

	if(gd != 1)
	{
		cout << "not coprime"; 
		return 0; 
	}

	mii mp; 
	for(int i = 0; i < n; ++ i)
	{
		for(int j = 2; j  * j <= a[i]; ++ j)
		{
			if(a[i] % j == 0)
			{
				mp[j]++ ; 
				while(a[i] % j == 0)
					a[i] /= j; 
			}
		}

		if(a[i] >= 2)
			mp[a[i]]++ ; 
	}

	for(auto i : mp)
	{
		if(i.se > 1)
		{
			cout << "setwise coprime"; 
			return 0; 
		}
	}


	cout << "pairwise coprime"; 
	return 0;
}

Measured memory_bytes: 15780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string S; cin >> S;
    ll ans = 0, num = 0;
    rep(i, len(S)) {
        if (S[i] == 'W') ans += num;
        else ++num;
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

inline int vp(int n,int x)
{
    int a=0;
    while(n)
    {
        n/=x;
        a+=n;
    }
    return a;
}

int n,v[105];

vector<int>divi[105];

inline bool isp(int x)
{
    if(divi[x].size()==2)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

vector<int>a;

ll ans=0LL;

inline void go(int last,int need)
{
  ///  cout<<last<<" "<<need<<"\n";
    if(need==1)
    {
        ans++;
        return;
    }
    if(last==a.size())
    {
        return;
    }
    for(auto &x:divi[need])
    {
        int cnt=x-1;
        if(cnt>a[last])
        {
            break;
        }
        go(last+1,need/x);
    }
}

int main()
{
   /// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=i;j++)
        {
            if(i%j==0)
            {
                divi[i].push_back(j);
            }
        }
    }
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(isp(i))
        {
            v[i]=vp(n,i);
            a.push_back(v[i]);
            continue;
            cout<<i<<" - > "<<v[i]<<"\n";
        }
    }
    go(0,75);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}


int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, d, a;
P p[200000];
int ans;
int cnt;
queue<P> que;

signed main() {
	cin >> n >> d >> a;
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
		p[i].second = (p[i].second - 1) / a + 1;
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		while (que.size()) {
			P x = que.front();
			if (x.first < p[i].first) {
				cnt -= x.second;
				que.pop();
			}
			else break;
		}
		if (cnt < p[i].second) {
			ans += p[i].second - cnt;
			que.push({ p[i].first + d * 2,p[i].second - cnt });
			cnt += p[i].second - cnt;
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int n;
    int a[100];
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >>a[i];
    for(int i = n - 1; i > 0; i--,cout << " ")
        cout << a[i];
    cout << a[0];
    cout << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	xi := readMultiple(5)
	tens := 0
	ones := 10
	for _, v := range xi {
		if v%10 == 0 {
			tens += v / 10
		} else {
			if v%10 < ones {
				ones = v % 10
			}
			tens += v/10 + 1
		}
	}
	fmt.Println((tens-1)*10 + ones)
}

func readMultiple(n int) []int {
	xi := []int{}
	for i := 0; i < n; i++ {
		j := 0
		fmt.Scan(&j)
		xi = append(xi, j)
	}
	return xi
}


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

typedef pair<int, int> pr;

#define N 100005

int n, m;

bitset<N> vis;

array<int, N> fa;

array<int, N> ans;

array<vector<int>, N> to;

array<vector<pr>, N> qry;

int find(int u)
{
	return fa[u] == u ? u : fa[u] = find(fa[u]);
}

void tarjan(int u, int f)
{
	vis.set(u);
	
	for (auto e : qry[u])
	{
		int v = e.first;
		int id = e.second;
		
		if (vis[v])
			ans[id] = find(v);
	}
	
	for (auto v : to[u])
		if (v != f)
			tarjan(v, u);
			
	if (u)fa[u] = find(f);
}

signed main(void)
{
	cin >> n;
	
	for (int u = 0; u < n; ++u)
	{
		int k; cin >> k;
		
		for (int v; k--; )
		{
			cin >> v;
			
			to[u].push_back(v);
			to[v].push_back(u);
		}
	}
	
	cin >> m;
	
	for (int i = 0; i < m; ++i)
	{
		int x, y; cin >> x >> y;
		
		qry[x].push_back(make_pair(y, i));
		qry[y].push_back(make_pair(x, i));
	}
	
	for (int i = 0; i < n; ++i)
		fa[i] = i;
		
	vis.reset();
	
	tarjan(0, -1);
	
	for (int i = 0; i < m; ++i)
		cout << ans[i] << endl;
}

Measured memory_bytes: 19816
N, K = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
fs = gets.split.map(&:to_i)

sorted_as = as.sort
sorted_fs = fs.sort_by { |n| -n }
zipped = sorted_as.zip(sorted_fs).to_a

def is_ok(zipped, k, n)
  rest = K
  zipped.each do |(a, f)|
    x = a * f
    next if x <= n
    count = (x - n + f - 1) / f
    return false if count > rest
    rest -= count
  end
  return true
end

l = 0
r = 10 ** 12
ans = -1
while l <= r
  mid = (l + r) / 2
  if is_ok(zipped, K, mid)
    ans = mid
    r = mid - 1
  else
    l = mid + 1
  end
end
puts ans


Measured memory_bytes: 38684
'use strict';
(function(stdin) {
  //declare function

  //declare variable
  var inputs = stdin.toString().trim().split('\n');
  var cols = inputs[0].split(' ').map(Number);
  var count = 0;
  //main
  for (var i = cols[0]; i <= cols[1]; i++) {
    if (cols[2] % i === 0) {
      count++;
    }
  }
  //display
  console.log(count);
})(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int n;

int res = 0;

void dfs(string pos)
{
  if(stoll(pos) > n) return;
  bool three = false, five = false, seven = false;
  for (int i = 0; i < int(pos.size()); i++)
  {
    if(pos[i] == '3') three = true;
    if(pos[i] == '5') five = true;
    if(pos[i] == '7') seven = true;
  }
  if(three && five && seven) res++;
  dfs(pos + "3");
  dfs(pos + "5");
  dfs(pos + "7");
}

int main(){
  cin >> n;
  dfs("3");
  dfs("5");
  dfs("7");
  cout << res << endl;
}


Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
a,b = map(int,input().split())

if b >= a:
    a,b = b,a

ans = a + max(a-1,b)

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
import java.util.*;


public class Main{ 


    public static void main(String args[]) {
    Scanner s=new Scanner(System.in);
	int n=s.nextInt();
	int k=s.nextInt();
	int arr[]=new int[n];
	for(int i=0;i<n;i++) {
		arr[i]=s.nextInt();
	}
	int dp[]=new int[k+1];
	for(int i=1;i<=k;i++) {
		for(int j=0;j<n;j++) {
			if(i<arr[j]) {
				continue;
			}
			if(dp[i-arr[j]]==0) {
				dp[i]=1;
				break;
			}
		}
	}
	if(dp[k]==1)
		System.out.print("First");
	else
		System.out.println("Second");
	 
	 
   }
}

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

const int N = 10;
const int D = 10*9*8*7*6*5*4*3*2;
const int INF = 1 << 29;

struct state{
  vector<int> v;
  int cnt;
  state(vector<int> v=vector<int>(), int cnt=0):v(v),cnt(cnt){}
};

int n, d[N], wd[2][D];
vector<int> v;

int hash(const vector<int> &vec){
  int res = 0;
  bool f[N];
  fill(f, f+n, false);

  for(int i=0;i<n-1;i++){
    int cnt = 0;
    for(int j=0;j<vec[i]-1;j++){
      if(f[j]) cnt++;
    }
    res += d[n-2-i] * (vec[i] - cnt - 1);
    f[vec[i]-1] = true;
  }
  
  return res;
}

int bfs(const vector<int> &vec, int memo[], bool is_first){
  int res = INF;
  queue<state> q;
  state u, u2;

  fill(memo, memo+D, INF);
  memo[hash(vec)] = 0;

  for(q.push(state(vec, 0)); !q.empty();){
    u = q.front();
    q.pop();

    if(!is_first) res = min(res, wd[0][hash(u.v)] + u.cnt);
    if(is_first && u.cnt >= 4 || u.cnt >= 5 || res == 9) continue;

    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        int hs;
        u2 = state(u.v, u.cnt + 1);
        reverse(u2.v.begin()+i, u2.v.begin()+j+1);
        hs = hash(u2.v);
        if(memo[hs] > u2.cnt){
          memo[hs] = u2.cnt;
          q.push(u2);
        }
      }
    }
  }

  return res;
}

int solve(){
  vector<int> w = v;

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

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v[i] == w[j]) {
        v[i] = j + 1;
        break;
      }
    }
  }

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

  bfs(w, wd[0], true);
  return bfs(v, wd[1], false);
}

int main(){
  d[0] = 1;
  for(int i=1;i<N;i++) d[i] = d[i-1] * (i + 1);
  
  while(cin >> n){
    v.clear();
    for(int i=0;i<n;i++){
      int x;
      cin >> x;
      v.push_back(x);
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 110480
import sys
sys.setrecursionlimit(10**7)
def dfs(p,v,c):
    ans[v]=c
    for i in E[v]:
        if i[0]==p:
            continue
        if i[1]%2==1:
            dfs(v,i[0],1-c)
        else:
            dfs(v,i[0],c)
N= int(input())
ans = [100]*(N+1)
memo = {i:False for i in range(1,N+1)}
E = {i: []for i in range(1,N+1)}
for i in range(N-1):
    u,v,w = list(map(int,input().split()))
    E[v].append((u,w))
    E[u].append([v,w])
dfs(-1,1,1)
for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 156772
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

int main() {
  ll N=0,M=0;
  cin >> N >> M;
  if(N == 0 || M < 2){
    cout << "0";
    return 0;
  }
  while(1){
    if(N * 2 >= M){
      cout << M/2;
      return 0;
    }
    if(M > 1000000000){
      N += 5000; M -= 10000;
      continue;
    }
    N++; M -= 2;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m,x,y;
int maxx = -200,miny = 200;
cin >> n >> m >> x >> y;
vector<int> vecx(n);
vector<int> vecy(m);
for(int i=0;i<n;i++)
cin >> vecx.at(i);
for(int i=0;i<m;i++)
cin >> vecy.at(i);
for(int i=0;i<n;i++)
{
    if(maxx<vecx.at(i))
    maxx = vecx.at(i);
}
for(int i=0;i<m;i++)
{
    if(miny>vecy.at(i))
    miny = vecy.at(i);
}
if(maxx<miny && maxx < y && miny > x)
cout << "No War" << endl;
else
cout << "War" << endl;
}

Measured memory_bytes: 256
n = int(input())
a_s = [int(item) for item in input().split()]

a_sorted = sorted(a_s)

cnt = 0
for std, a in zip(a_sorted, a_s):
    if std != a:
        cnt += 1

if cnt == 0 or cnt == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> ruisekiW(N + 1);
    vector<ll> ruisekiE(N + 1);
    for (int i = 0; i < N; i++)
    {
        ruisekiW.at(i + 1) = ruisekiW.at(i);
        ruisekiE.at(i + 1) = ruisekiE.at(i);
        if (S.at(i) == 'E')
        {
            ruisekiE.at(i + 1)++;
        }
        else
        {
            ruisekiW.at(i + 1)++;
        }
    }
    ll answer = 1e12;
    for (int i = 0; i < N; i++)
    {
        answer = min(answer, ruisekiW.at(i) + ruisekiE.at(N) - ruisekiE.at(i + 1));
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 5396
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll x, y;
    cin >> x >> y;

    if ( abs(x-y) <= 1 ) {
        cout << "Brown" << endl;
    }
    else {
        cout << "Alice" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
const ull MOD = 1000000007;
const int MAX_N = 100000;
ull fact[MAX_N + 1];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ull ans;
    fact[0] = 0;
    fact[1] = 1;
    for (int i = 2; i < MAX_N + 1; i++){
        fact[i] = (fact[i - 1] * i) % MOD;
    }
    while (1){
        int N, R;
        cin >> N;
        if (N == 0) break;
        vector<int> word(N);
        for (int i = 0; i < N; i++) word[i] = i;
        word.push_back(0);
        ans = 0;
        cin >> R;
        vector<int> s(2*R+2, 0);
        s[2 * R + 1] = N;
        for (int i = 0; i < R; i++){
            cin >> s[i] >> s[i+R];
            s[i]--; s[i+R]--;
            s.push_back(s[i] + 1);
            s.push_back(s[i+R] + 1);
            swap(word[s[i]], word[s[i+R]]);
        }
        sort(s.begin(), s.end());
        s.erase(unique(s.begin(), s.end()), s.end());
        for (int i = 0, R = s.size() - 1; i < R; i++){
            ull tmp = 0;
            int si = s[i], sip = s[i+1];
            for (int j = si; j < sip; j++){
                tmp = (tmp + fact[N - j - 1]) % MOD;
            }
            tmp = (tmp * word[si]) % MOD;
            ans =(ans + tmp) % MOD;
            int dif = sip - si;
            for (int j = i + 1; j < R; j++){
                word[s[j]] -= (word[s[j]] > word[si] ? dif : 0);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2788
#include <bits/stdc++.h>
using namespace std;
int main(){
    int Q,l,r;
    cin >> Q;
    vector<bool> p(100001);
  	p[1] = true;
    vector<int> cnt(100001);
    for(int i = 2;i <= 100000;i ++)if(!p[i])for(int j=i+i;j<=100000;j += i)
        p[j] = true;
    for(int i = 3;i <= 100000;i++){
        cnt[i] += cnt[i-1];
        if(!p[i]&&!p[(i+1)/2]) cnt[i]++;
    }
    for(int i = 0;i < Q;i ++){
        cin >> l >> r;
        if(!p[l]&&!p[(l+1)/2]) cout << cnt[r]-cnt[l]+1 << endl;
        else cout << cnt[r] - cnt[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int K = sc.nextInt();
			int Q = sc.nextInt();
			int[] win = new int[N];
			for (int i = 0; i < Q; i++) win[sc.nextInt() - 1]++;
			for (int i = 0; i < N; i++) System.out.println(K - Q + win[i] > 0 ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 53708
//
// Created by 中野誠大 on 2019-02-16.
//
#include<iostream>

#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
    int N;
    cin >> N;
    int a[N];
    for (int i=0;i<N;i++){
        cin >> a[i];
    }
    int dp[N+1];

    int large,small,medium;

    sort(a,a+N);

    /*
    for (int i=0;i<N;i++){
        cout << a[i] << endl;
    }*/



    large = a[1];
    small=a[0];
    while(large!=small){
        large = large-small;
        if (small>large) swap(small,large);
    }

    dp[0]=small;




    for (int i=1;i<N;i++){
        large=a[i];
        small=dp[i-1];
        while(large%small!=0){
            large = large%small;
            if (small>large){
                medium = large;
                large = small;
                small = medium;

            }
        }

        dp[i] = small;
    }

    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void){
	int n, len, a, b, i, j, k;
	char str[1001], order[8], str_rep[1001], str_rev[1001];
	
	scanf("%s\n", str);
	len = strlen(str);
	scanf("%d\n", &n);
	for(i = 0; i < n; i++){
		scanf("%s %d %d", order, &a, &b);
		if(strncmp(order, "print", 5) == 0){
			scanf("\n");
			for(j = a; j <= b; j++){
				printf("%c", str[j]);
			}
			printf("\n");
		}else if(strncmp(order, "replace", 7) == 0){
			scanf("%s\n", str_rep);
			for(j = a, k = 0; j <= b; j++, k++){
				str[j] = str_rep[k];
			}
		}else if(strncmp(order, "reverse", 7) == 0){
			scanf("\n");
			strncpy(str_rev, str, 1000);
			for(j = a, k = b; j <= b; j++, k--){
				str[j] = str_rev[k];
			}
		}
	}
	
	return 0;
}



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

int main() {
    int s;
    int num;
    int sum = 0;
    cin >> s;
    num = s % 10;
    sum += num;
    num = s / 10;
    sum += num % 10;
    num = s / 10 / 10;
    sum += num % 10;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int N;
   cin>>N;
   int x=111;
   
   while(N>x){
       
       x+=111;
   }
   cout<<x<<endl;
   
}

Measured memory_bytes: 3584
n = int(input())
L = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    #print(i)
    for j in range(i+1,n-1):
        if L[i] == L[j]:continue
        for k in range(j+1,n):
            #print(L[i], L[j], L[k], "*")
            if ((L[i] != L[k]) and (L[j] != L[k])) and ((L[i]+L[j]>L[k]) and (L[i]+L[k]>L[j]) and (L[j]+L[k]>L[i])):
              #print(L[i], L[j], L[k])
              cnt += 1
print(cnt)

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

#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

template <typename T> bool next_combination(T first, T last, int k){
    T subset = first + k;
    if (first==last || first==subset || last==subset){
        return false;
    }
    T src = subset;
    while(first != src){
        src--;
        if(*src < *(last-1)){
            T dest = subset;
            while(*src >= *dest){
                dest++;
            }
            iter_swap(src, dest);
            rotate(src+1, dest+1, last);
            rotate(subset, subset+(last-dest)-1, last);
            return true;
        }
    }
    rotate(first, subset, last);
    return false;
}

int main() {
    int N,M,Q;
    cin >> N >> M >> Q;
    vector<int> A(M+N-1);
    REP(i,M+N-1){
        A[i] = i+1;
    }

    vector<vector<int>> itr(Q,vector<int>(4));
    REP(i,Q){
        REP(j,4){
            cin >> itr[i][j];
        }
    }

    int ans = 0;

    do{
        int count = 0;
        vector<int> arr(N);
        REP(n,N){
            arr[n] = A[n] - n;
        }
        REP(i,Q){
            if (arr[itr[i][1]-1] - arr[itr[i][0]-1] == itr[i][2]){
                count += itr[i][3];
            }
        }
        ans = max(ans, count);
    } while(next_combination(ALL(A), N));

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

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

using namespace::std;

int N, A, B,l[1001],r[1001],a[1001];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
		A += r[i] - l[i] + 1;
	}

	cout << A << endl;
	return 0;
		}


	


Measured memory_bytes: 256
N,Q = map(int, input().split())
S   = input()
Query = []
for _ in range(Q):
    l,r = map(int, input().split())
    Query.append([l, r])

A = [0]*N
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        A[i] = 1
s = [0]*(N+1)
for i in range(N):
    s[i+1] = s[i] + A[i]

for l,r in Query:
    print(s[r-1]-s[l-1])

Measured memory_bytes: 25228
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << ((n == 7 || n == 5 || n==3) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256