akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a, b;
    cin >> a >> b;
    if((a * b)% 2 == 1){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

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

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll a, b, x; cin >> a >> b >> x;

  ll left = (a - 1) / x, right = b / x;
  if (a == 0) left = 0, ++right;

  cout << right - left << endl;
  
  return (0);
}

Measured memory_bytes: 3676
n = int(input())
lis = []
for i in range(n):
    lis.append(list(map(int, input().split())))
lis = sorted(lis, key=lambda x:x[1])
ans = 'Yes'
cnt = 0
for i in range(n):
    cnt += lis[i][0]
    if lis[i][1] < cnt:
        ans = 'No'
print(ans)

Measured memory_bytes: 55256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<(a+b)*c/2<<endl;
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


const int MAXN=200005,MOD=2019;

int n;
char a[MAXN];
int f[MAXN],cnt[MAXN];

int main(){
	scanf("%s",a+1);
	n=strlen(a+1);
	
	ll ans=0;
	
	int cur=1;
	++cnt[0];
	
	for(int i=n;i;--i){
		f[i]=(f[i+1]+(a[i]-'0')*cur)%MOD;
		cur=cur*10%MOD;
		ans+=cnt[f[i]];
		++cnt[f[i]];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4628
#include <iostream>
#include <vector>

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

const int SIZE = 101;
const int INF = 1 << 21;
int d[SIZE], p[SIZE], state[SIZE];

void dijkstra(int s, int n, int **a) {
  rep(i, n) {
    d[i] = INF;
    p[i] = -1;
  }
  d[s] = 0;

  while (1) {
    int u = -1, minv = INF;
    rep(i, n) {
      if (d[i] < minv && state[i] != 1) {
        u = i;
        minv = d[i];
      }
    }

    if (u == -1) break;

    state[u] = 1;

    rep(i, n) {
      if (a[u][i] != INF) {
        int v = i, w = a[u][i];
        if (state[v] == 1) continue;
        if (d[v] > d[u] + w) { d[v] = d[u] + w; }
      }
    }
  }
}

int main() {
  int n;
  std::cin >> n;
  int **a = new int *[n];
  rep(i, n) a[i] = new int[n];

  rep(i, n) rep(j, n) a[i][j] = INF;

  rep(i, n) {
    int u, k, v, c;
    std::cin >> u >> k;
    rep(j, k) {
      std::cin >> v >> c;
      a[u][v] = c;
    }
  }

  dijkstra(0, n, a);
  rep(i, n) { std::cout << i << ' ' << d[i] << '\n'; }

  return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int n,m;
vector<int> used,cmp,vs;
vector<vector<int>> v,rv;

void addedge(int x,int y){
    v[x].push_back(y);
    rv[y].push_back(x);
}
void dfs(int x){
   used[x]=true;
   for(auto to:v[x])if(!used[to])dfs(to);
   vs.push_back(x);
}

void rdfs(int x,int k){
   used[x]=true;
   cmp[x]=k;
   for(auto to:rv[x])if(!used[to])rdfs(to,k);
}

int scc(){
   used.resize(n);
   cmp.resize(n);
   rep(i,n)if(!used[i])dfs(i);
   rep(i,n)used[i]=0;
   reverse(vs.begin(),vs.end());
   int k=0;
   for(auto x:vs)if(!used[x])rdfs(x,k++);
   return k;
}
int main(){
    cin>>n>>m;
    string s;
    cin>>s;
    v.resize(2*n);
    rv.resize(2*n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        --x;--y;
        if(s[x]==s[y]){
            addedge(x,y+n);
            addedge(y,x+n);
        }
        else {
            addedge(x+n,y);
            addedge(y+n,x);
        }
    }
    n*=2;

    cout<<(scc()==n?"No":"Yes")<<endl;
    return 0;
}

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

main(){
  int *a;
  int n,i,j,tmp,flag;
  int kokan=0;

  scanf("%d", &n);
  a = (int*)malloc(n*sizeof(int));

  for(i=0; i<n; i++) scanf("%d", a+i);

  //bubbleSort
  for(i=0; i<n; i++){
    for(j=n-1; j>i; j--){
      if(a[j]<a[j-1]){
	kokan++;
	//swap
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }
  //print
  for(i=0; i<n-1; i++) printf("%d ", a[i]);
  printf("%d\n%d\n", a[i], kokan);

  return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;
int par[200010],sz[200010];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i; sz[i] = 1;
	}
}

int find(int x){
	if(par[x]==x) return x;
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x); y = find(y);
	if(x==y) return;
	if(sz[x]>sz[y]) swap(x,y);
	par[x] = y;
	sz[y] += sz[x];
}

bool same(int x, int y){
	return find(x)==find(y);
}

int main(){
    int i,n,m; cin >> n >> m;
    init(n);
    for(i=0;i<m;i++){
        int a,b; cin >> a >> b; a--; b--;
        unite(a,b);
    }
    int mx = 0;
    for(i=0;i<n;i++){
        mx = max(mx,sz[find(i)]);
    }
    cout << mx << endl;
}

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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007

#define TIME chrono::system_clock::now
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int m,n;

string s;

int main(){
    int i,j,k,l;
    
    cin>>s;
    cin>>m;
    n = s.size();
    
    for (i=0;0<m && i<n;i++){
        if (s[i]=='a') continue;
        l = 'z'+1-s[i];
        if (m>=l){
            m-=l;
            s[i]='a';
        }else{
        }
    }
    
    s[n-1] = (m + s[n-1] - 'a')%('z'-'a'+1)+'a';
    
    
    cout << s<<endl;
    
    return 0;
}

Measured memory_bytes: 512
str = input()
times = int(input())
revers = 0
head = ""
tail = ""
for i in range(times):
    com = input().split()
    if com[0] == "1":
        if revers == 0:
            revers = 1
        else :
            revers = 0
        
    else :
        if com[1] == "1":
            if revers == 0:
                head = com[2]+head
            else :
                tail = tail + com[2]
        else : 
            if revers == 1:
                head = com[2]+head
            else :
                tail = tail + com[2]          
str = head + str + tail
if revers == 1:
    str = str[::-1]
                
print(str)

Measured memory_bytes: 4428
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static long n = 0;




	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int	x = sc.nextInt();
		for(int i = x;i <= 999;i++){
			if(i == 111 || i == 222 || i == 333 || i== 444 || i == 555 || i == 666|| i == 777 || i== 888 || i == 999){
				System.out.println(i);
				return;
				

			}
		}

	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 21972
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int dp[3010][3010]={};string s,t;bool bt[3010][3010]={};
int rs(int l,int r)
{
	if (l<1||r<1) {return 0;}
	if (!bt[l][r])
	{
		bt[l][r] = 1;
		dp[l][r] = max(rs(l-1,r),rs(l,r-1));
		if (s[l-1]==t[r-1]) {dp[l][r] = max(rs(l-1,r-1)+1,dp[l][r]);}
	}
	return dp[l][r];
}
string lcs(int l,int r)
{
	if (l<1||r<1) {return "";}
	if (s[l-1]==t[r-1]&&dp[l-1][r-1]+1==dp[l][r]) {return lcs(l-1,r-1)+s[l-1];}
	else if (dp[l][r-1]==dp[l][r]) {return lcs(l,r-1);}
	else {return lcs(l-1,r);}
}
int main()
{
	for (int i=0;i<3010;i++) {memset(dp[i],0,3010);}
	cin>>s>>t;
	rs(s.size(),t.size());
	cout<<lcs(s.size(),t.size())<<"\n";
	return 0;
}

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

const int N = 1000006;

long long n;
bool prim[N];
vector<long long> prims;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	prim[0] = prim[1] = true;
	for(int i=4;i<N;i+=2){
		prim[i] = true;
	}
	prims.push_back(2);
	for(int i=3;i<N;i+=2){
		if(!prim[i]){
			prims.push_back(i);
			for(int j=2*i;j < N;j+=i){
				prim[j] = true;
			}
		}
	}
	
	cin>>n;
	int ans = 0;
	for(long long x:prims){
		int cnt = 0;
		while(n % x == 0){
			cnt++;
			n /= x;
		}
		int hn = 1;
		while(cnt >= hn){
			ans++;
			cnt -= hn;
			hn++;
		}
	}
	
	if(n > 1)ans++;
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 5244
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

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

  int bucket[101] = {0};
  for (int i = 0; i < k; i++) {
    int tmp1;
    cin >> tmp1;

    for (int j = 0; j < tmp1; j++) {
      int tmp2;
      cin >> tmp2;
      bucket[tmp2]++;
    }
  }

  int ans = 0;
  for (int i = 1; i < n + 1; i++) {
    if (bucket[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <math.h>
#define Aa 1000
int main(){
  int A[Aa];
  int n=0,i=0,j=0,v=0,k=0,x,y,r;
  scanf("%d%d",&x,&y);
  if( x < y){
    r = x;
    x = y;
    y = r;
  }
  while(y > 0){
    r = x%y;
    x = y;
    y = r;
  }
  printf("%d\n",x);
  return 0;
}



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

int main() {
  
  bitset<1000000> DivL;
  
  int N;
  cin >> N ;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int n = A.at(0);
  
  for (int i = 1; i < N; i++) {
    n = gcd(n,A.at(i));
  }
  if (n > 1) {
    cout << "not coprime" << endl;
    goto end;
  }
  

  for (int i = 0; i < N; i++) {
    if (A.at(i) != 1 && DivL.test(A.at(i)-1)) {
      cout << "setwise coprime" << endl;
      goto end;
    }
    DivL.set(A.at(i)-1);
    for (int j = 2; j*j < A.at(i); j++) {
      if (A.at(i) % j == 0) {
        if (DivL.test(j-1)) {
          cout << "setwise coprime" << endl;
          goto end;
        }
        if (DivL.test(A.at(i)/j-1)) {
          cout << "setwise coprime" << endl;
          goto end;
        }
        DivL.set(j-1);
        DivL.set(A.at(i)/j-1);
      }
    }
  }
  
  cout << "pairwise coprime" << endl;
  
  end:
  return 0;
}

Measured memory_bytes: 7200
n = int(input())

points= [0, 0]
for _ in range(n):
    s, t = input().lower().split()
    if s > t:
        points[0] += 3
    elif s < t:
        points[1] += 3
    else:
        points[0] += 1
        points[1] += 1

print(*points)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//const double pi=acos(-1.0);
#define mod 1000000007
#define forn(i,k,n) for(ll i=k;i<n;i++)
#define fornr(i,k,k1) for(ll i=k;i>=k1;i--)
#define v(ll) vector<ll>
#define vl(a,n,ll,k) vector<ll> a(n,k)
#define vli(a,n) vector<ll> a(n)
#define init(a,n) vector<ll> a(n);forn(i,0,n)cin>>a[i]
#define vll(a,n,m,ll,k) vector<vector<ll>> a(n,vector<ll>(m,k))
#define mp(a,ll,ll1) map<ll,ll1> a
#define st(a,ll) set<ll> a
#define mpa make_pair
#define pr pair<ll,ll>
#define pb push_back
#define MAX 1000000
#define ed '\n'
#define fileTake ifstream cin("input.txt");ofstream cout("output.txt");
#define sortv(a) sort(a.begin(),a.end())
#define sorta(a,n) sort(a,a+n)
#define yeah "YES"
#define nil "NO"
#define All(x) x.begin(),x.end()
#define remDup(a) a.erase(unique(All(a)),a.end())
void swap(ll &x,ll &y) 
{ 
	x=x^y;
	y=x^y;
	x=x^y;
} 

template<typename T>
void print(T a){for(auto i=a.begin();i!=a.end();i++)cout<<*i<<" ";cout<<endl;}
bool isVowel(char c)
{
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')return true;
	return false;
}

void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
ll cal(ll p)
{
	return (ll)(p+p*1/100);
}
int main(){
	sync();
	ll k;
	cin>>k;
	ll i=1;
	ll p1=100;
	while(true)
	{
		ll p=cal(p1);
		if(p>=k)
		{
			cout<<i<<endl;
			break;
		}
		p1=p;
		i++;
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
const int maxn=1e6+7;
typedef long long ll;
const int mod=1e9+7;
#define pi acos(-1)
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()
/* keep hungry and keep calm! */

char s[maxn];
int Sheryang(){
    int n=read,k=read;

    if(k<=(n+1)/2){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    sort(all(v));
    double ans = (v[0]+v[1])/2;
    rep2(i,2,n) {
        ans = (ans+v[i])/2;
    }
    printf("%.8f",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int n,a=1,b,c=0,d=0;
    char op[30];
    scanf("%lld",&n);
    b=n;
    while((n-c)>0)
    {
        a*=26;
        c+=a;
        d++;
    }
    n=n-c+a-1;
    for(a=0; a<d; a++)
        op[a]='a';
    c=0;
    while(n)
    {
            op[c]=n%26+'a';
        c++;
        n/=26;
    }
    for(d--; d>=0; d--)
        printf("%c",op[d]);

    return 0;
}



Measured memory_bytes: 2068
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG // checks for container overflows
#pragma GCC optimize "trapv" // to chcek for int overflow
#pragma -Wduplicated-cond // dupilcate conditions
#endif

#include "bits/stdc++.h"
using namespace std;
using namespace chrono;
typedef unsigned long long int ull;
typedef long long ll;
int main()
{
#ifndef ONLINE_JUDGE
    auto start = high_resolution_clock::now();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    register int test;
    int r, g, b, k, t;

    cin >> r >> g >> b;

    cin >> k;

    int k1 = 0, k2 = 0;


    while (g <= r)
    {
        k2++;
        g *= 2;
    }

    while (b <= g || b <= g)
    {
        k1++;
        b *= 2;
    }
    if (k >= k1 + k2)
        cout << "Yes\n";
    else
        cout << "No\n";


#ifndef ONLINE_JUDGE
    auto end = high_resolution_clock::now();
    double time_taken = duration_cast<nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nTime : " << fixed << time_taken << setprecision(9);
#endif
    return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int a;
  cin >> a;
  a %= 10;
  if (a == 3) {
    cout << "bon";
  } else if (a == 0 or a == 1 or a == 6 or a == 8) {
    cout << "pon";
  } else {
    cout << "hon";
  }
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
 
using namespace std;
 
int main()
{
	fast
	int n,m;
	cin>>n>>m;
	int total=0, arr[n], cnt=0;
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
		total+=arr[i];
	}
	sort(arr,arr+n);
	int k=ceil(total/(4*m));
  	if(total%(4*m)==0)
    {
    	if(arr[n-m]>=k)
			cout<<"Yes";
		else
			cout<<"No";  
    }
	else if(arr[n-m]>k)
		cout<<"Yes";
	else
		cout<<"No";	
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){
    double x=0,y=0;
    double angle=90;
    while(true){
        double a,b;
        char c;
        cin>>a>>c>>b;
        
        if(a==0&&b==0)break;
        if(b<0){b=360+b;}
        x+=a*cos(angle*M_PI/180);
        y+=a*sin(angle*M_PI/180);
        angle-=b;
        
        
    }
    cout<<(int)x<<endl;
    cout<<(int)y<<endl;
    
    return 0;
}



Measured memory_bytes: 3448
#include <stdio.h>
#include <math.h>
static double g_cos_pi_3, g_sin_pi_3;
static int g_flag = 1;

void koch_curve(double x1, double y1, double x2, double y2, int n) {
	double x, y, ax, ay, bx, by, cx, cy;

	if (!n) {
		if (g_flag) {
			printf("%.8lf %.8lf\n", x1, y1);
			g_flag = 0;
		}
		printf("%.8lf %.8lf\n", x2, y2);
		return;
	}
	x = (x2-x1) / 3.0;
	y = (y2-y1) / 3.0;
	ax = x1 + x;
	ay = y1 + y;
	bx = x*g_cos_pi_3 - y*g_sin_pi_3 + ax;
	by = x*g_sin_pi_3 + y*g_cos_pi_3 + ay;
	cx = x2 - x;
	cy = y2 - y;

	koch_curve(x1, y1, ax, ay, n-1);
	koch_curve(ax, ay, bx, by, n-1);
	koch_curve(bx, by, cx, cy, n-1);
	koch_curve(cx, cy, x2, y2, n-1);
}

int main(void) {
	int n;

	g_cos_pi_3 = cos(M_PI / 3.0);
	g_sin_pi_3 = sin(M_PI / 3.0);
	scanf("%d", &n);
	koch_curve(0.0, 0.0, 100.0, 0.0, n);
	return 0;
}



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

using namespace std;

int main(int argc, char const *argv[]) {
	int N,temp;
	std::cin >> N;
	std::vector<int> A,B,C;
	for (size_t i = 0; i < N; i++) {
		std::cin >> temp;
		A.push_back(temp);
	}
	for (size_t i = 0; i < N; i++) {
		std::cin >> temp;
		B.push_back(temp);
	}
	for (size_t i = 0; i < N; i++) {
		std::cin >> temp;
		C.push_back(temp);
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());

	unsigned long ans = 0;

	for (size_t i = 0; i < N; i++) {
		std::vector<int>::iterator a = lower_bound(A.begin(), A.end(), B[i]);
		std::vector<int>::iterator c = upper_bound(C.begin(), C.end(), B[i]);

		ans = ans + (a - A.begin()) * (C.end() - c);
	}

	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n ;
  int ans = 1;
  int counter =0;
  for(int i=1;i<=n;i++){
    int j =i;
    int counter2=0;
    while(j%2==0){
      j /= 2;
      counter2++;
    }
    if(counter2>counter){
      counter = counter2;
      ans = i;
    }
  }
  cout <<ans;
}

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

int main(){
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  while(1){
    //takahshi
    c-=b;
    if(c<=0){
      cout << "Yes";
      return 0;
    }
    //aoki
    a-=d;
    if(a<=0){
      cout << "No";
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	string S;
	cin>>S;
	if(S.length()==1){
		cout<<S<<endl;
		return 0;
	}
	bool flag=0;
	for(int i=1;i<S.length();i++){
		if(S[i]!='9')
			flag=1;
	}
	cout<<(S.length()-1)*9+(S[0]-'0'-1)+!flag<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <climits>
#include <numeric>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef long long int lli;

int memo[1000010] = {0,0,1};
double PI = 3.14159265359;
const lli MOD = pow(10,9)+7;



int main(void){
    
    lli N;
    cin >> N;

    map<int,int> m;
    
    for(int k = 2; k <= N; k++){
    lli tmp = k;
    for(int i = 2; i <= (lli)sqrt(k)+1; i++){
        while( tmp % i == 0 ){
            tmp /= i;
            m[i]++;
        }
    }
    
    if(tmp > 1) m[tmp]++;
    
    }
    
    lli res = 1;
    for(auto itr = m.begin(); itr != m.end(); itr++){
        //cout << itr->first << endl;
        res = (res*(itr->second+1)) % MOD;
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int n;
int aa[100005];
int ton[100005];
int zd1=0,cd1=0,zdi1=0,zd2=0,cd2=0,zdi2,ans;
void tes(int ii,int &zd,int &cd,int &zdid){
	rep(i,1,100000)ton[i]=0;
	for(int i=ii;i<=n;i+=2)ton[aa[i]]++;
	rep(i,1,100000){
		if(ton[i]>=zd){
			cd=zd;zd=ton[i];zdid=i;
		}
		else if(ton[i]>cd)cd=ton[i];
	}
}
int main(){
	scanf("%d",&n);
	assert(n%2==0);
	rep(i,1,n)scanf("%d",aa+i);
	tes(1,zd1,cd1,zdi1);
	tes(2,zd2,cd2,zdi2);
	if(zdi1!=zdi2)ans=zd1+zd2;
	else ans=max(zd1+cd2,zd2+cd1);
	cout<<n-ans<<endl;
	return 0; 
} 

Measured memory_bytes: 1024
a = int(input())
b = list(map(int,input().split()))
cave = []
for i in range(a):
    cat = b[i]
    if cat > 0:
        if cat in cave:
            print(i+1)
            break
        else:
            cave.append(cat)
    else:
        if -(cat) in cave:
            if -(cat) == cave[-1]:
                cave.remove(-(cat))
            else:
                print(i+1)
                break
        else:
            print(i+1)
            break
    if i + 1 == a:
        print("OK")


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    vector<map<char, int>> mp(n);
    vector<string> vs;
    string s;
    for (int i = 0; i < n; i++){
        cin >> s;
        vs.push_back(s);
    }
    for (int i = 1; i < n; i++){
        for (int j = 0; j < vs[i].size(); j++){
            ++mp[i][vs[i][j]];
        }
    }
    bool check;
    sort(vs[0].begin(), vs[0].end());
    for (int i = 0; i < vs[0].size(); i++){
        check = true;
        for (int j = 1; j < n; j++){
            if (mp[j].find(vs[0][i]) != mp[j].end() && mp[j][vs[0][i]] != 0){
                mp[j][vs[0][i]] -= 1;
            } else check = false;
        }
        if (check) cout << vs[0][i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int main(){
        char s[105],t[105];
        scanf("%s%s",&s,&t);
        printf("%s%s\n",t,s);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int x,y;
int a[505][505],vis[505][505];
int main(){
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		vis[x][y]++;
	}//cout<<endl;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+vis[i][j];
	    }
	}
	for(int i=1;i<=q;i++){
		scanf("%d%d",&x,&y);
		printf("%d\n",a[y][y]-a[x-1][y]-a[y][x-1]+a[x-1][x-1]);
	}
//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long ll;
ll d[100004];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
  int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<=n;i++) d[i]=9999999;
  d[0]=0;
  d[1] = abs(a[1]-a[0]);
  for(int i=2;i<n;i++){
    d[i] = min(d[i-2]+abs(a[i]-a[i-2]),d[i-1]+abs(a[i]-a[i-1]));
  }
  cout<<d[n-1];
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>

using namespace std ;

typedef long long LL ;
const int N=2e3+10 ;
const LL P=1e9+7 ;

int a[N] ;
int n ;
LL k ;

int main ()
{
	int i , j ;
	scanf("%d%lld",&n,&k);
	for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
	LL res=0 ;
	for ( i=1 ; i<=n ; i++ )
	{
		LL s=0 , t=0 ;
		for ( j=1 ; j<i ; j++ )
			if ( a[j]>a[i] ) s++;
		for ( j=1 ; j<=n ; j++ )
			if ( a[j]>a[i] ) t++;
		res=(res+k*(k-1)/2ll%P*t%P+k*s%P)%P;
	}
	printf("%lld\n",res);
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 29996224275833
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
// vector<vector<int>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1},{1,1},{1,-1},{-1,1},{-1,-1}};



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    if(t.substr(0,s.size())==s){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}
    


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int d = scan.nextInt();
		int x = scan.nextInt();
		int chocolate = x;
		int i = 0;
		int j = 0;
		for(i = 0; i < n; i++) {
			int a = scan.nextInt();
			int count = 0;
			for(j = 0; (j * a) + 1 <= d; j++) {
				count++;
			}
			chocolate = chocolate + count;
		}
		System.out.println(chocolate);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

//------------------------------------------------------
const ll MAX_N = limit;
ll fact[MAX_N];
ll fact_inv[MAX_N];

ll pow_mod(ll x, ll y, ll m = MOD) { //x^y mod m
    if (x == 0) return 0;
    ll prod = 1;
    while (y > 0) {
        if (y % 2 == 1) prod = (prod * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return prod % m;
}

void init_fact() {
    fact[0] = fact_inv[0] = 1;

    REP(i, 1, MAX_N) {
        fact[i] = (fact[i - 1] * i) % MOD;
        fact_inv[i] = pow_mod(fact[i], MOD - 2);
    }
}

ll C_mod(ll n, ll r) {
    if (n < r) return 0;
    else return ((fact[n] * fact_inv[n - r]) % MOD * fact_inv[r]) % MOD;
}

inline ll H_mod(ll n, ll r) {
    return C_mod(n + r - 1, r);
}

inline ll P_mod(ll n, ll r) {
    return C_mod(n, r) * fact[r];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    ll ans = 0;
    init_fact();
    for (ll i = b; i <= w - 1; ++i) {
        ans += C_mod(h - a - 1 + i, i) * C_mod((a - 1) + (w - 1 - i), a - 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
set<pair<int,pair<int,int>>> tup;
int32_t main()
{
	int n=in();
	int ans=0;
	for(int c=1;c<n;c++)
	{
		int rem=n-c;int cur=0;
	//	cout<<rem<<" ";
		vector<int> fc;
		while(rem%2==0){rem/=2;cur++;}
		if(cur>0)fc.push_back(cur);
		cur=0;
		for(int i=3;i*i<=rem;i+=2)
		{
			while(rem%i==0){cur++;rem/=i;}
			if(cur>0)fc.push_back(cur);
			cur=0;
		}
		if(rem>2)fc.push_back(1);
		
		int div=1;
		for(int i:fc)div*=(i+1);
		//cout<<div<<"\n";
		int sq=sqrt(n-c);
		ans+=div;
		//if(sq*sq==(n-c))ans--;
		
	}
	cout<<ans;
	
	
	
}


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

#define MAX 101

int N, T, H, L, V;
int t[MAX], h[MAX];

bool noMoney(int x){
  if(t[x] == 0 && h[x] == 0)return true;
  else return false;
}

bool overStrage(int x){
  if(T > L) return true;
  else return false;
}

bool buyJuice(int x){
  int change = V - 90;
  while(change > 0){
    if(T > 0){
      t[x]++;
      T--, change -= 10;
    }
    else return true;
  }
  return false;
}

int main(){
  cin >> N >> T >> H >> L;
  for(int i = 1 ; i <= N ; i++){
    cin >> t[i] >> h[i];
  }
  
  bool flag = false;

  while(!flag){
    for(int i = 1 ; i <= N ; i++){
      if(noMoney(i)){
	cout << i << endl;
	flag = true;
	break;
      }
      
      if(t[i] > 0){
	T++;
	V += 10;
	t[i]--;
      }
      else if(h[i] > 0){
	V += 100;
	h[i]--;
      }
      
      if(overStrage(i)){
	cout << i << endl;
	flag = true;
	break;
      }
      
      if(V >= 90){
	if(buyJuice(i)){
	  cout << i << endl;
	  flag = true;
	  break;
	}
	V = 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>

int main(void){
   int N,M,i;
   int data[M];
   int days=0;
   scanf("%d %d",&N,&M);
   for(i=0;i<M;i++){
      scanf("%d",&data[i]);
      days+=data[i];
   }
   if(N-days>=0){
      printf("%d\n",N-days);
   }else{
      printf("-1\n");
   }
   return 0; 
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)

using namespace std;

const int INF = 100000000;

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

  string s;
  cin >> s;

  vector<int> l(q);
  vector<int> r(q);

  REP(i,q){
    cin >> l[i] >> r[i];
  }

  vector<int> dp(n,0);

  REP(i,n-1){
    if (s[i] == 'A' && s[i+1] == 'C') {
      dp[i+1] = dp[i] + 1;
    }else{
      dp[i+1] = dp[i];
    }
  }

  REP(i,q){
    int ans = dp[r[i] - 1] - dp[l[i] - 1];
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2176
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)1e5 + 228;
const int MOD = (int)1e9 + 7;

using namespace std;

ll binpow(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if (b & 1)	
			res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

ll f[N], rf[N], koef[N], pref[N];
int a[N], n;

ll C(int x, int y)
{
	return f[x] * rf[y] % MOD * rf[x - y] % MOD;
}

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~precalc
	f[0] = rf[0] = 1;
	forn(i, N - 1)
	{
		f[i] = f[i - 1] * i % MOD;
		rf[i] = binpow(f[i], MOD - 2);
	}
	//~read
	scanf("%d", &n);
	forn(i, n)
		scanf("%d", &a[i]);
	//~precalc_koef
	forn(i, n)
	{
		koef[i] = C(n, i) * f[n - i] % MOD * f[i - 1] % MOD;
	}
	koef[1] = 0;
	forn(i, n)
		pref[i] = (pref[i - 1] + koef[i]) % MOD;
	//~solve
	ll ans = 0;
	forn(i, n)
	{	
		ans = (ans + a[i] * f[n]) % MOD;
		ans = (ans + a[i] * pref[i]) % MOD;
		ans = (ans + a[i] * pref[n - i + 1]) % MOD;
	}
	cout << ans << endl;

	return 0;
}



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

int main(){
    int i,n;
    cin>> n;
    i = n;
    cin.ignore();
    unordered_map<string,int> mp;
    while(n--){
        string s;
        getline(cin,s);
        mp[s] = 1;
    }
    unordered_map<string,int> :: iterator it ;
    int c = 0;
    for(it = mp.begin();it != mp.end();it++){
        //cout<< it->first<<" "<<it->second<<endl;
        c++;
    }
    cout<< c << endl;
}

Measured memory_bytes: 17692
# coding: utf-8
from collections import deque
H, W = map(int, input().split())
maze = []
for i in range(H):
    tmp = list(input())
    maze.append(tmp[:])

def bfs(sx, sy):
    visited = [[-1 for _ in range(W)] for _ in range(H)]
    q = deque([[sx, sy]])
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    visited[sx][sy] = 0
    while q:
        p = q.popleft()
        for i in range(len(dx)):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < H and 0 <= ny < W and visited[nx][ny] == -1\
                and maze[nx][ny] == ".":
                    visited[nx][ny] = visited[p[0]][p[1]] + 1
                    q.append([nx, ny])
    dist = -1
    for i in range(H):
        dist = max(dist, max(visited[i]))
    return dist
ans = -1
for x in range(H):
    for y in range(W):
        if maze[x][y] == "#":
            continue
        ans = max(ans, bfs(x,y))
print(ans)

Measured memory_bytes: 3316
use std::cmp::min;
use std::io;
use std::io::prelude::*;

fn main() {
    let mut stdin = io::stdin();
    let mut buf = String::new();
    let _ = stdin.read_to_string(&mut buf);
    let mut iter = buf.split_whitespace();

    let h: usize = iter.next().unwrap().parse().unwrap();
    let w: usize = iter.next().unwrap().parse().unwrap();
    let a: Vec<Vec<usize>> = (0..h)
        .map(|_| iter.by_ref().take(w).map(|s| s.parse().unwrap()).collect())
        .collect();

    println!("{}",
        (0..h).map::<usize, _>(|ri| {
            (0..w).map(|rj| {
                (0..h).map::<usize, _>(|i| {
                    let di = if ri > i { ri - i } else { i - ri };
                    (0..w).map(|j| {
                        let dj = if rj > j { rj - j } else { j - rj };
                        let d = min(di, dj);
                        a[i][j] * d
                    }).sum()
                }).sum()
            }).min().unwrap()
        }).min().unwrap());
}



Measured memory_bytes: 5028
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
#define EPS (5.0e-4)

double t;
double a,b,c,d,e,f;

void swap(double *a,double *b){
	double t=*a;
	*a=*b;
	*b=t;
}

int main(){
	cout<<setprecision(3)<<setiosflags(ios::fixed);
	while(cin>>a>>b>>c>>d>>e>>f){
		if(a==0){
			swap(a,d);
			swap(b,e);
			swap(c,f);
		}
		b/=a; c/=a; a=1;
		e-=d*b; f-=d*c; d=0;
		f/=e; e=1;
		c-=f*b; b=0;
		if(abs(c)<EPS) c=0;
		if(abs(f)<EPS) f=0;
		cout<<c<<" "<<f<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main() {
  int a, b, i, j;
  while(1) {
    scanf("%d%d", &a, &b);
    if(a == 0 && b == 0) break;
    for(i=0; i < a; i++) {
      for(j=0; j < b; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


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

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

  int A, B, K;
  cin >> K;
  cin >> A >> B;
  for (int i = A; i <= B; ++i) {
    if (i % K == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");

  return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	long long l = 2, l1 = 1 , temp;
	for(int i = 0; i < n; i++){
		temp = l1;
		l1 += l;
		l = temp;
	}
		
	cout << l << endl;
	

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=1000000;



main(){
    ll n=lin();
    ll l=0,r=1e9;
    while(l<r-1){
        ll mid=(l+r)/2;
        ll now=mid*(mid+1)/2;
        if(now<n)l=mid;
        else r=mid;
    }
    cout<<r<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100000
#define INFTY (1 << 21) //10^21
//int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printDimention(DVector& dv);

int dis_F[N];
int dis_S[N];
int dis = -1;
DVector Neighbor_list;

void dfs_visit(int u, bool flg){
    int v;
    dis++;
    //探索中、未探索の辺を持つ
    color[u] = GRAY;
    if(flg){
        dis_F[u] = dis;
    }else{
        dis_S[u] = dis;
    }
    
    
    rep(v, Neighbor_list[u].size()){
        //初探索の状態
        if(color[Neighbor_list[u][v]] == WHITE){
            dfs_visit(Neighbor_list[u][v], flg);
            dis--;
        }
    }
    color[u] = BLACK;
}

void dfs(){
    int u;
    //初期化
    rep(u, n)   color[u] = WHITE;
    /*
    rep(u, n){
        //未訪問のuを始点として深さ優先探索
        if(color[u] == WHITE)   dfs_visit(u);
    }*/
    dfs_visit(0, true);
    dis = -1;
    rep(u, n)   color[u] = WHITE;
    dfs_visit(n - 1, false);
    
    //出力(略)
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    cin >> n;
    
    Neighbor_list.resize(n);
    rep(i, n - 1){
        cin >> a >> b;
        Neighbor_list[a - 1].push_back(b - 1);
        Neighbor_list[b - 1].push_back(a - 1);
    }
    //printDimention(Neighbor_list);
    //cout << "dfs start" << endl;
    dfs();
    //printArray(dis_F, n);
    //printArray(dis_S, n);
    int black = 0, white = 0;
    rep(i, n){
        if(dis_F[i] <= dis_S[i]){
            black++;
        }else{
            white++;
        }
    }
    if(black > white){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector& dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 11648