akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n); sll(r);
	if(n <= 10)	pll(r + 100 * (10 - n)), nl;
	else	pll(r), nl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
#define rep_one(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;


int main(){ 
    int n; cin >> n;
    int a[n], ans=0;
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        if(i%2 != 0) continue;
        if(a[i]%2 != 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
n = int(input())
t, a = map(int, input().split())
ans = 0
temperature = 1000000000000000
tmp = 0
H = list(map(int, input().split()))
for i in range(n):
    tmp = t - H[i] * 0.006
    if abs(a - tmp) < abs(a - temperature):
        temperature = tmp
        ans = i


print(ans+1)

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

int main() {
	while(1){
		int h, w{10}, cnt{}; cin >> h;
		if(!h) break;
		vector<vector<int>> f(2*h,vector<int>(5));
		for(int i=h-1; i>=0; i--)for(int j=0; j<5; j++) cin >> f.at(i).at(j);
		for(int i=h; i<2*h; i++) {
			for(int j=0; j<5; j++){
				f.at(i).at(j) = w;
				w++;
			}
		}
		vector<vector<int>> a1(h,vector<int>(5));
		for(int i=0; i<h; i++)for(int j=0; j<5; j++) a1.at(i).at(j) = i;
		bool flg{1};
		while(flg){
			auto a = a1;
			flg=0;
			for(int i=h-1; i>=0; i--){
				int f0 = f.at(a.at(i).at(0)).at(0), f1 = f.at(a.at(i).at(1)).at(1), f2 = f.at(a.at(i).at(2)).at(2), f3 = f.at(a.at(i).at(3)).at(3), f4 = f.at(a.at(i).at(4)).at(4);
				if(f2!=f1&&f2==f3){
					if(f3==f4){
						flg=1;
						cnt += f2*3;
						for(int k=i; k<h; k++) for(int l=2; l<5; l++) {
							if(k==h-1)a1.at(k).at(l)++;
							else a1.at(k).at(l) = a1.at(k+1).at(l);
						}
					}
				}
				if(f2==f1&&f2!=f3){
					if(f1==f0){
						flg=1;
						cnt += f2*3;
						for(int k=i; k<h; k++) for(int l=0; l<3; l++) {
							if(k==h-1)a1.at(k).at(l)++;
							else a1.at(k).at(l) = a1.at(k+1).at(l);
						}
					}
				}
				if(f2==f1&&f2==f3){
					flg=1;
					int b{3}, left{1}, right{3};
					if(f0==f1) {
						b++;
						left--;
					}
					if(f3==f4){
						b++;
						right++;
					}
					cnt += f2*b;
					for(int k=i; k<h; k++) for(int l=left; l<=right; l++) {
						if(k==h-1)a1.at(k).at(l)++;
						else a1.at(k).at(l) = a1.at(k+1).at(l);
					}
				}
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3152
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());scan.nextLine();
		Set<Integer> hash_set = new HashSet<Integer>();

		int a;
		int ans=0;
		for (int i = 0;i < n; ++i){
			a = Integer.parseInt(scan.next());scan.nextLine();
			if (hash_set.contains(a)){
				--ans;
				hash_set.remove(a);
			}else{
				hash_set.add(a);
				++ans;
			}

		}




		System.out.print(ans);



	}
}
//end


Measured memory_bytes: 120644
from collections import deque



# s = input()
# n = int(input())
N, K = map(int, input().split())
P = list(map(int, input().split()))

disordered_count = [0]

for i in range(N-1):
    if P[i] > P[i+1]:
        disordered_count.append(disordered_count[i]+1)
    else:
        disordered_count.append(disordered_count[i])

ordered = 0

def interval_min(a, K):
    q = deque()
    min_array = []
    for i, v in enumerate(a):
        while len(q) != 0 and a[q[len(q)-1]] > v:
            q.pop()

        q.append(i)

        if i >= K-1:
            min_array.append(q[0])
            if q[0] == len(min_array)-1:
                q.popleft()
    return min_array

def interval_max(a, K):
    return interval_min([-i for i in a], K)

res = 0
min_array = interval_min(P, K)
max_array = interval_max(P, K)

# print(N,K)
# print(P)
# print(max_array)

for i in range(N-K+1):
    if disordered_count[i] == disordered_count[i+K-1]:
        ordered = 1
    else:
        if i == 0:
            res += 1
        else:
            if not (P[i-1] == P[min_array[i-1]] and P[i+K-1] == P[max_array[i]]):
                res += 1
    # print(P[i:i+K], res)


print(res+ordered)




Measured memory_bytes: 37700
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define pi 3.141592653589 
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
int main()
{
 
 
double a,b,h,m;cin>>a>>b>>h>>m;
double total=60*h+m,a1,a2,diff,ans;
a1=(6*total);a2=(0.5*total);
if(a1>a2)
{
    diff=min(a1-a2,360-a1+a2);
    ans=sqrt(a*a+b*b-(2*a*b*cos(diff*pi/180)));
    cout<<setprecision(12)<<ans;
}else
{
    diff=min(a2-a1,360-a2+a1);
    ans=sqrt(a*a+b*b-(2*a*b*cos(diff*pi/180)));
    cout<<setprecision(12)<<ans;
}



 

 
return 0;
   
}

Measured memory_bytes: 4228
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>

bool isPrime(std::size_t a)
{
    if (a == 2) {
        return true;
    } else if (a % 2 == 0) {
        return false;
    }

    for (std::size_t i = 3; i <= (std::size_t)(sqrt(a)); i = i + 2) {
        if (a % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    std::size_t n;
    std::cin >> n;

    std::size_t count = 0;
    for (std::size_t i = 0; i < n; ++i) {
        std::size_t a;
        std::cin >> a;
        if (isPrime(a)) {
            count++;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 3084
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[3] = " \n";
int i, j, k, l, m, n;
double PI = acos(-1);


int main() {
  double x[110], y[110], d[110];
  cin >> n;
  rep(i,n) cin >> x[i];
  rep(i,n) cin >> y[i];
  rep(i,n) d[i] = fabs(x[i] - y[i]);
  // p = 0
  double z = 0.0;
  rep(i,n) z+=d[i];
  printf("%.6f\n", z);
  // p = 1
  z = 0.0;
  rep(i,n) z+=d[i]*d[i];
  printf("%.6f\n", sqrt(z));
  // p = 2
  z = 0.0;
  rep(i,n) z+=d[i]*d[i]*d[i];
  printf("%.6f\n", pow(z, 1.0/3.0));
  // p = inf
  z = 0.0;
  rep(i,n) if (d[i]>z) z=d[i];
  printf("%.6f\n", z);
  
  return 0;
}
  

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    ll k, a, b;
    cin >> k >> a >> b;
    // Hitting pocket only and getting +1 biscuit each time is best
    if (b - a <= 2) {
        cout << k + 1 << endl;
    } else {
        ll cur_b = 1;
        while (k >= 1) {
            if (cur_b >= a && k >= 2) {
                cur_b += b - a;
                k--;
            } else {
                cur_b++;
            }
            k--;
        }
        cout << cur_b << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    string s;
    cin >> s;
    int size = s.size();
    int a = s[0] - '0';
    int ans =0;
    for(int i = 1; i < size ; ++i){
        int temp = s[i] - '0';
        if(i % 2 == 0){
            if(temp != a)++ans;
        }else{
            if(temp == a)++ans;
        }
    }

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

Measured memory_bytes: 512
#include <stdio.h>

int main(){
   int n,p[20],i,m;
    
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%d",&p[i]);
   for (m=i=0;i<n-2;i++) 
      if ((p[i]<p[i+1] && p[i+1]<p[i+2]) ||
          (p[i]>p[i+1] && p[i+1]>p[i+2])) m++;
   printf("%d\n",m);
   return 0;
}


Measured memory_bytes: 128
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
x=[]
count=0
for i in range(k):
  x.append(t[i::k])

for j in range(k):
  for i in range(len(x[j])):
    if i==0:
      if x[j][i]=='r':
        count+=p
      elif x[j][i]=='s':
        count+=r
      else:
        count+=s
    elif x[j][i]==x[j][i-1]:
      x[j][i]='z'
    else:
      if x[j][i]=='r':
        count+=p
      elif x[j][i]=='s':
        count+=r
      else:
        count+=s
print(count)
    



Measured memory_bytes: 12752
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[2010][2010];

int main(){
  int n,m; cin >> n >> m;
  vector<int> s(n);
  rep(i,n) cin >> s[i];
  vector<int> t(m);
  rep(i,m) cin >> t[i];
  dp[0][0]=1;
  rep(i,n+1){
    rep(j,m+1){
      if(i<n&&j<m&&s[i]==t[j]) dp[i+1][j+1]+=dp[i][j];
      dp[i+1][j]+=dp[i][j];
      dp[i][j+1]+=dp[i][j];
      dp[i+1][j+1]-=dp[i][j];

      dp[i+1][j+1]%=mod;
      dp[i+1][j]%=mod;
      dp[i][j+1]%=mod;
    }
  }
  if(dp[n][m]<0) dp[n][m]+=mod;
  cout << dp[n][m] << endl;
}

Measured memory_bytes: 31744
#include<stdio.h>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int c[1005],a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    int count=0;
    for(int i=1;i<=100;i++){
        if(a%i==0&&b%i==0){
            c[count++]=i;
        }
    }
    sort(c,c+count,cmp);
    printf("%d\n",c[k-1]);
    return 0;
}


Measured memory_bytes: 128
#import<bits/stdc++.h>
using namespace std;main(){int n,x,a[101],ans=0;cin>>n>>x;for(int i=0;i<n;i++){cin>>a[i];}sort(a,a+n);for(int i=0;i<n-1;i++){if(a[i]>x)break;x-=a[i];ans++;}cout<<(x-a[n-1]?ans:ans+1);}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int mod=1e9+7;
int aaa[maxn];
int vis[maxn];
int dp[maxn];
int main()
{
    int n,k;scanf("%d%d",&n,&k);

    for(int i=1;i<=k;++i)
    scanf("%d",&aaa[i]),vis[aaa[i]]=1;
    dp[0]=1;
    for(int i=1;i<=n;++i)
    {
        if(i!=1)
        dp[i]=(dp[i-2]+dp[i])%mod;
        dp[i]=(dp[i-1]+dp[i])%mod;
        if(vis[i]) dp[i]=0;
    }
    printf("%d\n",dp[n]);
    return 0;
}

/*
1
11

*/


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int Mod = 1e9 + 7;
cs int N = 605;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b){ return 1ll * a * b % Mod; }
void Add(int &a, int b){ a = add(a,b); }
void Mul(int &a, int b){ a = mul(a,b); }
void Dec(int &a, int b){ a = dec(a,b); }
int k, n, tr[N];
int dp[N][N], way[N];
int cope(int l, int r, int ct){
	int as = way[ct];
	for(int i=r,t=0; i>l+1; i--) 
	t+=!tr[i], Dec(as,mul(dp[l][i-1],way[t]));
	return as;
} int chk(int l, int r){
	int ct=0;
	for(int i=l; i<=r; i++)
	if(tr[i]&&(tr[i]<l||tr[i]>r)) return -1;
	for(int i=l; i<=r; i++) ct+=!tr[i]; return ct;
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%d",&n,&k); n<<=1;
	for(int i=1,x,y; i<=k; i++)
	scanf("%d%d",&x,&y), tr[x]=y, tr[y]=x;
	int as=0; way[0]=1;
	for(int i=2; i<=n; i+=2) way[i]=mul(way[i-2],i-1);
	for(int l=n; l>=1; l--)
	for(int r=l+1; r<=n; r+=2){
		int ct=chk(l,r); if(ct==-1) continue;
		dp[l][r]=cope(l,r,ct);
		Add(as,mul(way[n-k-k-ct],dp[l][r]));
	}
	cout<<as; return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define int long long


signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, s;
    
    cin >> a >> s;
    
    int n = 0;
    
    string d;
    
    for(; a <= s; a++)
    {
        d = to_string(a);
        
        if(d[0] == d[4] && d[1] == d[3])
        {
            ++n;
        }
    }
    
    cout << n << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = sc.nextInt();
        int k = sc.nextInt();

        int ans = 0;
        if (k != 1) {
            ans = n - k;
        }
        
        System.out.println(ans);
    }

}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	LL n,m,p;
	int i,j,k;
	LL a,b,c;
	vector<LL> v1,v2;
	cin>>n>>m>>p;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	b=0;
	for(i=0;i<m;i++){
		cin>>a;
		v2.push_back(a);
		b+=a;
	}
	int s=0;
	for(i=0,j=m-1;i<=n;i++){
		for(;j>=0 && b>p;j--)b-=v2[j];
		if(b<=p)s=max(s,i+j+1);
		if(i<n)b+=v1[i];
	}
	cout<<s<<endl;
}

Measured memory_bytes: 7988
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=105;
int mod;
int Pow(int x,int y) {
    int res=1;
    while(y) {
        if(y&1) res=res*(ll)x%mod;
        x=x*(ll)x%mod,y>>=1;
    }
    return res;
}
inline void Add(int &x,int y) { x+=y; if(x>=mod) x-=mod; }
int f[N][N][2],g[N][N][2],pw[N][N*N],C[N][N];
int coe[N][N][N][2];
int n,m,L;
void getC(int n) { for(int i=0;i<=n;++i) for(int j=0;j<=i;++j) C[i][j]=j?(C[i-1][j]+C[i-1][j-1])%mod:1; }
int main() {
    rd(n),rd(m),rd(L),rd(mod);
    for(int i=0;i<=L;++i) { pw[i][0]=1; for(int j=1;j<=n*m;++j) pw[i][j]=pw[i][j-1]*(ll)i%mod; }
    for(int k=1;k<=L;++k) {
        for(int j=0;j<=m;++j)
            for(int x=0;x<=n;++x)
                coe[k][j][x][0]=Pow(pw[L-k+1][j]*(ll)(pw[k][m-j]-pw[k-1][m-j]+mod)%mod,x);
        for(int i=0;i<=n;++i)
            for(int y=0;y<=m;++y)
                coe[k][i][y][1]=Pow(pw[k][n-i]%mod*(ll)(pw[L-k+1][i]-pw[L-k][i]+mod)%mod,y);
    }

    getC(max(n,m));
    f[0][0][0]=1;
    for(int k=1;k<=L;++k) {
        for(int d=0;d<2;++d) {
            for(int i=0;i<=n;++i)
                for(int j=0;j<=m;++j) if(f[i][j][d]) {
                    if(d==0) {
                        for(int x=0;i+x<=n;++x)
                            Add(g[i+x][j][1],f[i][j][0]*(ll)C[n-i][x]%mod*coe[k][j][x][0]%mod);
                    }
                    else {
                        Add(g[i][j][0],f[i][j][1]);
                        for(int y=1;j+y<=m;++y)
                            Add(g[i][j+y][0],f[i][j][1]*(ll)C[m-j][y]%mod*coe[k][i][y][1]%mod);
                    }
                }
            memcpy(f,g,sizeof(g));
            memset(g,0,sizeof(g));
        }
        // for(int d=0;d<2;++d,puts("")) for(int i=0;i<=n;++i,puts("")) for(int j=0;j<=m;++j) printf("%d ",f[i][j][d]);
        // puts("");
    }
    printf("%d",f[n][m][0]);
    return 0;
}

Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
ll MOD=1000000007;

int main(){
  ll N;
  cin>>N;
  ll ans=1;
  ll ansa=1;
  ll ansb=1;
  for(ll i=0;i<N;i++){
    ans=(ans*10)%MOD;
    ansa=(ansa*9)%MOD;
    ansb=(ansb*8)%MOD;
  }
  cout<<(ans+ansb-2*ansa+2*MOD)%MOD<<endl;
}


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

int main() {

    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for (auto& v : a)std::cin >> v;

    bool ans = false;
    std::map<int, int> m;
    for (auto& v : a)++m[v];
    if (m.size() == 1) {
        if (m.begin()->first == 0)ans = true;
    }
    else if (m.size() == 2) {
        auto x = m.begin();
        auto y = std::next(x);
        if (x->first == 0 || y->first == 0) {
            ans = x->second*2 == y->second;
        }
    }
    else if (m.size() == 3) {
        auto x = m.begin();
        auto y = std::next(x);
        auto z = std::next(y);
        ans = ((x->first ^ y->first) == z->first && x->second == y->second && y->second == z->second);
    }

    std::cout << (ans ? "Yes" : "No") << std::endl;

}

Measured memory_bytes: 4224
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int N, Z, W;
	int a[2000];
	cin >> N >> Z >> W;
	for(int i = 0; i < N; i++) cin >> a[i];
	if(N == 1) cout << abs(a[0] - W) << endl;
	else cout << max(abs(a[N - 2] - a[N - 1]), abs(a[N - 1] - W)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int lli;

using namespace std;

int main(void){
    lli N, M;
    vector<lli> v;
    cin>>N>>M;
    v.resize(M);

    for(int i=0; i<M; i++) cin>>v[i];
    sort(v.begin(), v.end());

    vector<lli> diffs;

    for(unsigned int i=1; i<v.size(); i++) diffs.push_back(v[i] - v[i-1]);
    sort(diffs.begin(), diffs.end(), greater<lli>());

    lli ans = v.back() - v[0];

    for(unsigned int i=0; i < (min)({(lli)diffs.size(), N-1}); i++) ans -= diffs[i];

    cout << ans <<endl;

}

Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a * b) << endl; 

    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll a[110];
int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n - 1){
        if (a[i] == a[i+1]) {
            cnt++;
            a[i + 1] = 1e9 - i;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

bool are_switched(bitset<10> bit, 
		const vector<bitset<10>> &l_switch, int M, const vector<int> &p)
{
	int	mod;
	for (int j = 0; j < M; ++j) {
		mod = (bit & l_switch.at(j)).count() % 2; 
		if (mod != p.at(j))
			return false;
	}
	return true;
}

int	main()
{
	int	N, M;
	cin >> N >> M;
	vector<bitset<10>> light_switch(M);
	for (int i = 0; i < M; ++i) {
		int	k;
		cin >> k;;
		int	s;
		for (int j = 0; j < k; ++j) {
			cin >> s;
			light_switch.at(i).set(s - 1);
		}
	}
	vector<int> p(M);
	for (int i = 0; i < M; ++i)
		cin >> p.at(i);
	int	cnt = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bitset<10> bit(i);
		if (are_switched(bit, light_switch, M, p))
			++cnt;
	}
	cout << cnt << endl;
}


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

int main() {
	string S;
	cin >> S;
	static long long SUM[200010];
	map<long long, long long> mp;
	SUM[0] = 0;
	mp[0] = 1;
	for (int i = 0; i < S.size(); i++) {
		SUM[i + 1] = SUM[i] ^ (1 << (S[i] - 'a'));
	}
	if (SUM[S.size()] == 0) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 1; i <= S.size(); i++) {
		long long X = 1000000000;
		if (mp[SUM[i]] != 0) X = mp[SUM[i]];
		for (int j = 0; j < 26; j++) {
			long long Y = SUM[i] ^ (1 << j);
			if (mp[Y] != 0) X = min(X, mp[Y]);
		}
		if (mp[SUM[i]] == 0) mp[SUM[i]] = X + 1;
		else mp[SUM[i]] = min(mp[SUM[i]], X + 1);
	}
	cout << mp[SUM[S.size()]] - 1 << endl;
}

Measured memory_bytes: 273796
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch KthCommonDivisor | diff KthCommonDivisor.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address KthCommonDivisor.cpp && ./a.out

/*
 
 3/14/2019
 
 10:14-
 
 */

int A,B,K;

void solve() {
  VI X;
  FORE(i,1,min(A,B)) if(A%i==0&&B%i==0) X.push_back(i);
  reverse(ALL(X));
  assert(SZ(X)>=K);
//  dumpc(X);
  cout<<X[K-1]<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B>>K;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    REP(i,1,n-1) {
        if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
        else if(p[i+1] < p[i] && p[i] < p[i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)

using namespace std;

void solve(long long N){
    int nd=(int)log10(N)+1;
    vector<LL> digs(nd);
    rep(i,nd){
        digs[nd-i-1]=N%10;
        N/=10;
    }
    LL dp0=digs[0], dp1=max(digs[0]-1,0LL);
    for(int i=1; i<nd; i++){
        dp1=max(dp1+9,dp0+max(digs[i]-1,0LL));
        dp0 = dp0+digs[i];
    }
    cout << max(dp0, dp1) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int N, M, A[300][300];



int main(){
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    int ans = N;
    bool excluded[300] = {};
    int excluded_cnt = 0;
    while(excluded_cnt < M){
        int cnt[300] = {};
        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                if(!excluded[A[i][j]]){
                    cnt[A[i][j]]++;
                    break;
                }
            }
        }
        int tmp = 0, tmp_idx = 0;
        for(int j = 0; j < M; j++){
            if(cnt[j] > tmp){
                tmp = cnt[j];
                tmp_idx = j;
            }
        }
        ans = min(ans, tmp);
        //cout << "exclude: " << tmp_idx << endl;
        excluded[tmp_idx] = true;
        excluded_cnt++;
    }
    cout << ans << endl;
}

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


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

struct edge {int to; ll cost; };

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

ll GCD(ll a, ll b){
  if(b==0) return a;
  else return GCD(b, a%b);
}

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

int main(){
  ll k;
  cin >> k;
  ll tmp = 7;
  for(int i=0; i<k; i++){
    if(tmp%k==0){
      cout << i+1 << endl;
      return 0;
    }
    tmp *= 10;
    tmp += 7;
    tmp %= k;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
vector<int> A;
vector<int> B;
vector<int> C;
//=============================
void input()
{
    // cin>>N;
    // A.resize(N);
    // B.resize(N);
    // C.resize(N);

    // rep(i,N)cin>>A[i];
    // rep(i,N)cin>>B[i];
    // rep(i,N)cin>>C[i];
    cin >> N;
    A.resize(N);
    rep(i, N)
    {
        cin >> A[i];
    }
}
//=============================
void func() {}

// const int  NMAX=100005;
// int dp[NMAX][NMAX] = {};
//=============================
void solve()
{
    // sort(A.rbegin(),A.rend());
    // sort(B.rbegin(),B.rend());
    // sort(C.rbegin(),C.rend());
    // debugv(A);
    // debugv(B);
    // debugv(C);

    // rep(a,N){
    //     rep(b,N){

    //     }
    // }

    sort(A.rbegin(), A.rend());

    int a = 0;
    int b = 0;
    int state = 0;
    rep(i, N - 1)
    {
            if (state == 1)
            {
                state = 2;
            }
            else
        if (A[i] == A[i + 1])
        {
            if (state == 0)
            {
                a = A[i];
                state = 1;
            }
            else if (state == 2)
            {
                b = A[i];
                state == 3;
                break;
            }
            else
            {
                break;
            }
        }
    }
    cout << a * b << endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1024
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(i64);
    let mut count = 0;

    for n in 1..N + 1 {
        let mut h = 0;
        let mut x = n;
        while x > 0 {
            h += 1;
            x /= 10;
        }
        if h % 2 != 0 {
            count += 1;
        }
    }

    println!("{}", count)
}


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

int main()
{
  string s; cin >> s;
  string ans = "";
  for (auto c:s) {
    if (c=='B') {
      if (ans.size()>0)ans.pop_back();
    } else {
      ans.push_back(c);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np 

a = input()
N,K = np.array(a.split()).astype(int)

def b_sum(l,r):
    return int((l+r)/2 * (r-l+1))

res = 0
for i in range(K, N+1+1):
    l = b_sum(0,i-1)
    r = b_sum(N-i+1, N)
    res += r-l+1
mod = 10**9 + 7
print(res%mod)



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

class AtCoder {
  public static void Main() {
    //var inputs = Console.ReadLine().Trim().Split(' ');
    var X = int.Parse(Console.ReadLine().Trim());
    
    while(true) {
      if(IsPrime(X)) {
        break;
      } else {
        X++;
      }
    }
    Console.WriteLine(X);
  }
  
  private static bool IsPrime(int num)
  {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = Math.Sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
  }
}

Measured memory_bytes: 11092
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv,
       std.format,
       std.math;

void main()
{
	while(true){
		auto ip = readln.split;
		auto a = ip[0].to!int, b = ip[2].to!int;
		if(ip[1] == "?") break;
		ip[1].predSwitch(
			  "+", a + b,
			  "-", a - b,
			  "*", a * b,
			  "/", a / b).writeln;
	}
}


Measured memory_bytes: 2484
#include<stdio.h>
#define N 10000
#define M 500

int main(){

  int i, j, n, m, cnt = 0, array[N], srh_array[M];
  
  scanf("%d",&n);

  for(i = 0; i < n ; i++)scanf("%d",&array[i]);
  
  scanf("%d",&m);

  for(i = 0; i < m ; i++)scanf("%d",&srh_array[i]);
  
  for(i = 0; i < m; i++)
    {
      for(j = 0; j < n; j++)
	{
	  if(srh_array[i] == array[j])
	    {
	      cnt++;
	      break;
	    }
	}
    }
  printf("%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 2108
(* Examples *)
(*
stdin.ReadLine()
printfn "%d"
printfn "%s"
*)

(* Library *)
module Library =
  (* mod *)
  let internal moda = pown 10L 9 + 7L //任意の値

  let internal ( +% ) x y = 
    (x + y) % moda
  let internal ( *% ) x y = 
    (x * y) % moda


  let modPow x y m =
    let rec loop x y m result =
      match y with
      | 0L -> result
      | _ -> 
        loop x (y - 1L) m ((result * x) % m)
    loop x y m 1L

(* Standard Input *)
let readSplit elementFun=
  stdin.ReadLine().Split()
  |> Array.map elementFun

let read elementFun =
  stdin.ReadLine() |> elementFun

let readMap H =
  [|for i in 1..H -> stdin.ReadLine()|]
  |> Array.map(fun line ->
    line.ToCharArray()
  )
  |> array2D

(* Main *)
open Library

let N = read int64
let A = readSplit int64
let m = pown 10L 9 + 7L

[|0..62|]
|> Array.map (fun x ->
  A
  |> Array.sumBy (fun y ->  (y >>> x) % 2L)
)
|> Array.fold2 (fun sum x y ->
  sum +% ((modPow 2L x m) *% y *% (N - y))
) 0L [|0L..62L|]
|> printfn "%d"

Measured memory_bytes: 56252
//import java.io.*;
//import java.util.*;

class Main {
  public static void main (String[] args) {
    System.out.println("1x1=1");
    System.out.println("1x2=2");
    System.out.println("1x3=3");
    System.out.println("1x4=4");
    System.out.println("1x5=5");
    System.out.println("1x6=6");
    System.out.println("1x7=7");
    System.out.println("1x8=8");
    System.out.println("1x9=9");
    System.out.println("2x1=2");
    System.out.println("2x2=4");
    System.out.println("2x3=6");
    System.out.println("2x4=8");
    System.out.println("2x5=10");
    System.out.println("2x6=12");
    System.out.println("2x7=14");
    System.out.println("2x8=16");
    System.out.println("2x9=18");
    System.out.println("3x1=3");
    System.out.println("3x2=6");
    System.out.println("3x3=9");
    System.out.println("3x4=12");
    System.out.println("3x5=15");
    System.out.println("3x6=18");
    System.out.println("3x7=21");
    System.out.println("3x8=24");
    System.out.println("3x9=27");
    System.out.println("4x1=4");
    System.out.println("4x2=8");
    System.out.println("4x3=12");
    System.out.println("4x4=16");
    System.out.println("4x5=20");
    System.out.println("4x6=24");
    System.out.println("4x7=28");
    System.out.println("4x8=32");
    System.out.println("4x9=36");
    System.out.println("5x1=5");
    System.out.println("5x2=10");
    System.out.println("5x3=15");
    System.out.println("5x4=20");
    System.out.println("5x5=25");
    System.out.println("5x6=30");
    System.out.println("5x7=35");
    System.out.println("5x8=40");
    System.out.println("5x9=45");
    System.out.println("6x1=6");
    System.out.println("6x2=12");
    System.out.println("6x3=18");
    System.out.println("6x4=24");
    System.out.println("6x5=30");
    System.out.println("6x6=36");
    System.out.println("6x7=42");
    System.out.println("6x8=48");
    System.out.println("6x9=54");
    System.out.println("7x1=7");
    System.out.println("7x2=14");
    System.out.println("7x3=21");
    System.out.println("7x4=28");
    System.out.println("7x5=35");
    System.out.println("7x6=42");
    System.out.println("7x7=49");
    System.out.println("7x8=56");
    System.out.println("7x9=63");
    System.out.println("8x1=8");
    System.out.println("8x2=16");
    System.out.println("8x3=24");
    System.out.println("8x4=32");
    System.out.println("8x5=40");
    System.out.println("8x6=48");
    System.out.println("8x7=56");
    System.out.println("8x8=64");
    System.out.println("8x9=72");
    System.out.println("9x1=9");
    System.out.println("9x2=18");
    System.out.println("9x3=27");
    System.out.println("9x4=36");
    System.out.println("9x5=45");
    System.out.println("9x6=54");
    System.out.println("9x7=63");
    System.out.println("9x8=72");
    System.out.println("9x9=81");
  }
}

Measured memory_bytes: 16836
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
   ll x, y;
  cin >> x >> y;
 
  ll ans = 0;
  for (ll i = x; i <= y; i *= 2) ans++;
  cout << ans << endl;
 
  return 0;
    
}

Measured memory_bytes: 3624
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,n,a[131072],r=1,st;
    scanf("%d",&n);
    for(i=1;i<=n;i++){scanf("%d",&a[i]);}
    st=0;
    for(i=2;i<=n;i++){
        if(a[i-1]<a[i]){
            if(st==0){st=1;}
            if(st==-1){st=0;r++;}
        }
        if(a[i-1]>a[i]){
            if(st==0){st=-1;}
            if(st==1){st=0;r++;}
        }
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int n,q,a[20],m[200];


bool search(int sum,int i,int m){
    if(i >= n){
        return sum == m;
    }

    return search(sum + a[i],i + 1,m) || search(sum,i + 1,m);
}

int main(void){
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&q);
    for(int i = 0;i < q;i++){
        scanf("%d",&m[i]);
    }

    for(int i = 0;i < q;i++){
        if(search(0,0,m[i]))
            printf("yes\n");
        else
            printf("no\n");
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n;
    string s;
    cin >> n >> s;
    map<char, int> mp; 
    rep(i, n) mp[s[i]]++;
    ll ans = 1;
    for(auto e : mp) ans = ans*(e.second + 1)%MOD;

    cout << ans-1 << '\n';
    return 0;
}

Measured memory_bytes: 512
/*
* @Author: 王文宇
* @Date:   2018-03-18 23:31:38
* @Last Modified by:   王文宇
* @Last Modified time: 2018-03-18 23:38:56
*/
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=a;i<=b;i++)
const int maxn = 100007;
int fa[maxn],vis[maxn],n,m;
int main(int argc, char const *argv[])
{
	while(cin>>n>>m)
	{
		long long sum = 0;
		if(n==0&&m==0)break;	
		memset(vis,0,sizeof(vis));
		fa[1]=1;
		vis[1]=1;
		_for(i,2,n)
		{
			int x;
			cin>>x;
			fa[i]=x;
		}
		_for(i,1,m)
		{
			char s;
			int x;
			cin>>s>>x;
			if(s=='Q')
			{
				int k = x;
				while(vis[k]!=1)
				{
					k=fa[k];
				}
				sum+=k;
			}
			else vis[x]=1;
		}
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3868
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Palindromephobia solver = new Palindromephobia();
        solver.solve(1, in, out);
        out.close();
    }

    static class Palindromephobia {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int[] cnt = new int[3];
            for (int i = 0; i < s.length(); i++) {
                cnt[s.charAt(i) - 'a']++;
            }

            int N = s.length();
            if (N <= 2) {
                for (int i = 0; i < 3; i++) {
                    if (cnt[i] > 1) {
                        out.println("NO");
                        return;
                    }
                }
                out.println("YES");
                return;
            }

            boolean ans = pos(s, cnt.clone(), "abc");
            ans |= pos(s, cnt.clone(), "acb");
            ans |= pos(s, cnt.clone(), "bac");
            ans |= pos(s, cnt.clone(), "bca");
            ans |= pos(s, cnt.clone(), "cab");
            ans |= pos(s, cnt.clone(), "cba");
            out.println(ans ? "YES" : "NO");
        }

        private boolean pos(String s, int[] cnt, String pref) {
            int N = s.length();
            int[] need = new int[3];
            for (int i = 0; i < 3; i++) {
                need[pref.charAt(i) - 'a'] = ceil(N - i, 3);
            }

            for (int i = 0; i < 3; i++) {
                if (need[i] > cnt[i]) return false;
            }
            return true;
        }

        private int ceil(int n, int k) {
            return (n + k - 1) / k;
        }

    }

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

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

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

    }
}



Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 998244353
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
 
 
int main(){
    int d;
    double g;
    cin>>d>>g;
    int p[d],c[d];
    rep(i,d) cin>>p[i]>>c[i];
    int ans=INF;
    for(int bit=0;bit<(1<<d);bit++){
        int s=0,num=0,rest_max=-1;
        for(int i=0;i<d;i++){
            if(bit & 1<<i){
                s+=(i+1)*100*p[i]+c[i];
                num+=p[i];
            }
            else{
                rest_max=i;
            }
        }
        if(s<g){
            int s1=100*(rest_max+1);
            int need=(g-s+s1-1)/s1;
            if(need>=p[rest_max]){
                continue;
            }
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
}

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

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;

    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 3548