akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Odds of Oddness
            int N = int.Parse(Console.ReadLine());
            double odds = 0;

            for(int i = 1; i <= N; i++)
            {
                if (i % 2 == 1)
                {
                    odds++;
                }
            }

            Console.WriteLine(odds / N);
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll a, b;
  cin >> a >> b;
  cout << max(0ll, a - 2 * b) << endl;
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll N;

int main(){
	cin>>N;
	cout<<N*(N-1)/2<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll p, q, r;
    cin >> p >> q >> r;
    cout << min(p + q, min(p + r, q + r)) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		double W = GetDouble();
		double H = GetDouble();
		double x = GetDouble();
		double y = GetDouble();

		Console.WriteLine($"{W * H / 2.0:F12} {(((2.0 * x == W) && (2.0 * y == H)) ? 1 : 0)}");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11220
#include<stdio.h>
int main(){
  int a[100][100],b[100][100],i,j,k,n,m,l,x; /* n???i l???k */ 
  long long int c[100][100]={0};
  scanf("%d%d%d",&n,&m,&l);
  
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&x);
      a[i][j]=x;
    }
  }
  

  for(j=0;j<m;j++){
    for(k=0;k<l;k++){
      scanf("%d",&x);
      b[j][k]=x;
    }
  }

  for(i=0;i<n;i++){
    for(k=0;k<l;k++){
      for(j=0;j<m;j++){
	c[i][k]+=a[i][j]*b[j][k];
      }
    }
  }
  
  for(i=0;i<n;i++){
    for(k=0;k<l;k++){
      printf("%lld",c[i][k]);
      if(k!=l-1)printf(" ");
}
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 768
N,X = map(int, input().split())
def myabs(i):
    return abs(i-X)
xlis = list(map(myabs, map(int, input().split())))


def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

res = xlis[0]
for i in xlis:
    if i%res == 0:
        continue
    res = gcd(i,res)

print(res)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
  ll N;
  ll A;
  ll B;
  cin >>N>>A>>B;
  ll a=A+B;
  ll b=N%a;
  ll c=N/a;
  if(b==0) {
    cout<<c*A<<endl;
  }
else if(b!=0) {
if(b<=A) {
  cout<<c*A+b<<endl;
}
else if(b>A) {
cout<<c*A+A<<endl;
}
}
  
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
const int MAX_N = 5000;
using namespace std;

int main(void) {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    int dp[MAX_N];
    cin >> dp[0];

    int max_num = dp[0];
    for (int i = 1; i < n; i++) {
      int tmp;
      cin >> tmp;
      dp[i] = max(dp[i-1]+tmp, tmp);
      max_num = max(max_num, dp[i]);
    }

    cout << max_num << endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int turn=0;//0 represents Takahashi's turn while 1 represent Aoki's turn
    while(true)
    {
        if(turn==0)
        {
            c-=b;
            if(c<=0)
            {
                cout<<"Yes";
                break;
            }
            turn=1;
        }
        if(turn==1)
        {
            a-=d;
            if(a<=0)
            {
                cout<<"No";
                break;
            }
            turn=0;
        }
    }
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pi acos(-1.0)

int main()
{
    ll n, i, j, half = 0;
    string s;
    cin >> n >> s;
    if(n % 2 != 0)
        cout << "No\n";
    else{
        half = n / 2;

        if(s.substr(0, half) == s.substr(half, n))
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define VVI        vector<vector<int>>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);
int cnt=0;
VVI ans;

void f(VVI &a, int i, int j, int ni, int nj){
  if(a[i][j]%2==1){
    a[i][j]-=1;
    a[ni][nj]+=1;
    cnt++;
    VI tmp = {i,j,ni,nj};
    ans.emplace_back(tmp);
  }
}

int main(){
  int h,w;
  cin >> h >> w;

  if(h==1 && w==1){cout << 0 << endl; return 0;}
  
  VVI a(h, VI(w,0));

  REP(i,h)REP(j,w)cin >> a[i][j];

  int i=0;
  int j=0;

  do{
    if(i%2==0){
      if(j==w-1){
        f(a, i,j,i+1,j);
        i++;
      }else{
        f(a, i,j,i,j+1);
        j++;
      }
    }else{
      if(j==0){
        f(a, i,j,i+1,j);
        i++;
      }else{
        f(a, i,j,i,j-1);
        j--;
      }
    }
  }while(!(i==h-1 && (i%2==0 && j==w-1 || i%2==1 && j==0)));

  cout << cnt << endl;
  for(auto v : ans){
    REP(i,4){
      cout << v[i]+1 << (i==3 ? "\n" : " ");
    }
  }
}


Measured memory_bytes: 9904
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define add(a,b) a=(a+b)%mod;
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 3010
ll f[N][N],g[N][N],n,m;
int main(){
    lol(i,N)lol(j,N)f[i][j]=g[i][j]=0;
    cin>>n>>m;
    if(n==1){
	ll ans=2;
	lol(i,m)ans=ans*2%mod;
	cout<<ans<<endl;
	return 0;
    }
    for(ll i=1;i<=n;i++)f[0][i]=1; g[0][0]=1;
    for(ll i=0;i<m;i++){
	for(ll j=0;j<=n;j++){
	    for(ll k=j-1;k<=j+1;k++){
		if(k<0||k>n)continue;
		ll vf=((k==j&&j!=1&&j!=n)?2:1);
		ll vg=((k==j&&j!=0&&j!=n)?2:1);
		if(k>=1)add(f[i+1][k],f[i][j]*vf);
		if(k==0){
		    add(g[i+1][0],f[i][j]);
		    add(g[i+1][1],f[i][j]);
		}
		add(g[i+1][k],g[i][j]*vg);
	    }
	}
    }
    ll ans=0;
    for(ll i=0;i<=n;i++)add(ans,g[m][i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 141824
def com(n, k)
  return Array.new(n).combination(k).to_a.length
end

def power(a, k)
  return a ** k
end

#i桁目以降に0以外がk個含まれるか
def rec(i, k, isFixed)
  if i == @n.length
    return k == 0 ? 1 : 0 
  end
  return 1 if k == 0
  if isFixed
    return com(@n.length-i, k) * power(9, k)
  end

  if @n[i] == '0'
    return rec(i+1, k, false)
  else
    #0か1~(x-1)かxに場合分けをする
    zero = rec(i+1, k, true)
    middle = rec(i+1, k-1, true) * (@n[i].to_i - 1)
    top = rec(i+1, k-1, false) #まだ確定しない
    return zero + middle + top
  end
end

def main
  @n = gets.chomp.chars
  k = gets.chomp.to_i
  puts rec(0, k, false) 
end

main

Measured memory_bytes: 10108
#include<stdio.h>
#define MAX 101
#define INF 2001

int n;
int a[MAX][MAX];
int d[MAX];
int co[MAX];

int Spani();

int main(){
  int i,j;
  int k=0,t=0;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    
    for(j=1;j<=n;j++){
      scanf("%d",&a[i][j]);
      if(a[i][j]==-1) a[i][j]=INF;
    }
    co[i]=0;
    d[i]=INF;
  }
  k=Spani();

  printf("%d\n",k);
  
  return 0;
}

int Spani(){
  int i,min;
  int s=0,c=0,u=1;
  
  d[1]=0;
  co[1]=1;
  c++;

  while(c<=n){

    for(i=1;i<=n;i++){
      if(a[u][i]<d[i]) d[i]=a[u][i];
    }

    min=INF;
    
    for(i=1;i<=n;i++){
      
      if(d[i]<min && co[i]!=1){
	min=d[i];
	u=i;

      }
      
    }

    if(min!=INF) s+=min;
    co[u]=1;
    c++;
  }
  
  return s;
}




Measured memory_bytes: 2108
#define MAX(x,y) x>y?x:y
typedef long long int ll;

ll N,C,x[100002],v[100002];

ll Solve(){
	ll lg=0,tem=0;
        ll max[100001];
        max[0]=0;
	for(ll i=0;i<N;i++)
	{
		lg+=v[i+1]+x[i]-x[i+1];
		max[i+1]=MAX(max[i],lg);
	}
	ll ans=max[N];
	for(ll i=N;i>1;i--)
	{
		tem+=v[i]+x[i]-x[i+1];
		ans=MAX(tem+x[i]-C+max[i-1],ans);
	}
	return ans;
}

void swap(ll* v1,ll* v2){
        ll sw = *v1;
        *v1=*v2;
        *v2=sw;
}
       
int main(){
	scanf("%lld %lld",&N,&C);
	for(ll i=0;i<N;i++) scanf("%lld %lld",&x[i+1],&v[i+1]);
	x[N+1]=C;
        x[0]=0;
	ll Ans1=Solve();
        for(ll i=1;i<=N/2;i++) {
            x[i]=C-x[i];
            x[N+1-i]=C-x[N+1-i];
            swap(&x[i],&x[N+1-i]);
            swap(&v[i],&v[N+1-i]);
        }
	ll Ans2=Solve();
	printf("%lld",MAX(Ans1,Ans2));
	return 0;
}


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

typedef long long LL;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)

#define INT(n) int n;scanf("%d",&n)
#define VI(v,n) vector<int> v(n);REP(i,n){scanf("%d",&v[i]);}
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

int main(){
  INT(n); VI(as, n);
  LL ans[n]; MSET(ans, 0);
  map<int, int> cnt, idx;
  cnt[0] = 0;
  REP(i, n){
    int a = as[i];
    if(cnt.count(a)){
      cnt[a]++;
      idx[a] = min(i, idx[a]);
    }
    else{
      cnt[a] = 1;
      idx[a] = i;
    }
  }
  int tmp = n, a, c, i;
  LL s = 0;
  ROF(it, cnt){
    if(it != cnt.rbegin()){
      ans[tmp] += (a - it->first) * s;
    }
    a = it->first, c = it->second, i = idx[a];
    tmp = min(i, tmp);
    s += c;
  }
  
  REP(i, n){printf("%ld\n", ans[i]);}
  return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
int n, ans = 1e9;
int cnt1[maxn], cnt2[maxn];
char s[maxn];
int main() {
	scanf("%d%s", &n, s + 1);
	for(int i = 1; i <= n; ++i) {
		cnt1[i] = cnt1[i - 1] + (s[i] == 'E');
		cnt2[i] = cnt2[i - 1] + (s[i] == 'W');
	}
	for(int i = 1; i <= n; ++i) {
		ans = min(ans, cnt2[i - 1] + cnt1[n] - cnt1[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
ll arr[N],n,a,b,ans=1E9;;

bool poss(ll mid) {
	ll cnt=0;
	FOR(i, 0, n) {
		if(arr[i]-mid*b > 0) {
			ll tmp = arr[i] - mid *  b;
			cnt += tmp / (a - b);
			if(tmp % (a - b)) {
				cnt++;
			}
		}
	}

	return cnt <= mid;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>a>>b;
    FOR(i, 0, n) cin>>arr[i];

    ll lo = 1, hi  = 1e9;
    while(lo <= hi) {
    	ll mid = (lo + hi) / 2;
    	if(poss(mid)) {
    		ans = min(ans, mid);
    		hi = mid - 1;
    	} else {
    		lo = mid + 1;
    	}
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    int N,M;
    cin >> N >> M;
    pair<int,int> p[N];
    rep(i,N){
        int x,y;
        cin >> x >> y;
        p[i]={x,y};
    }
    sort(p,p+N);
    long long ans=0;
    rep(i,N){
        int d=min(M,p[i].second);
        ans+=(long long) d*p[i].first;
        if(M==0) break;
        M-=d;

    }
    cout << ans << endl;

}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A, B, K; cin >> A >> B >> K;

    set<int> ans;
    for(int i = A; i <= min(B, A+K-1); i++){
        ans.insert(i);
    }

    for(int i = B; i >= max(A, B-K+1); i--){
        ans.insert(i);
    }

    for(auto i : ans) cout << i << endl;


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var X = vals[0];
        var Y = vals[1];

        // a+b=X
        // 2a+4b=Y
        // -> 2b = Y - 2X
        // -> b = Y/2 -X
        if (Y % 2 != 0)
        {
            Console.WriteLine("No");
            return;
        }

        var b = Y / 2 - X;
        var a = X - b;
        if (b < 0 || a < 0)
        {
            Console.WriteLine("No");
            return;
        }

        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 28296
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int sum[100001];
 int main()
 {  int n;
    while(scanf("%d",&n)!=EOF)
    {int a;
     memset(sum,0,sizeof(sum));
     for(int i=1;i<=n;i++)
     {scanf("%d",&a);
      sum[a+1]++;
      sum[a-1]++;
      sum[a]++;
	 }
	 sort(sum,sum+100001);
	 printf("%d\n",sum[100000]);
	}return 0;
 }

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k < a + b)cout << min(k, a) << endl;
	else cout << a - (k - a - b) << endl;
	
	return 0;
}


Measured memory_bytes: 3616
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String data = sc.nextLine();
    String dataR = "";
    int notCount = 0;
    for (int i = data.length()-1 ; i >= 0 ; i--) {
      dataR += data.substring(i,i+1);
    }
    for (int i = 0 ; i < data.length() ; i++) {
      if (!data.substring(i,i+1).equals(dataR.substring(i,i+1))) {
        notCount++;
      }
    }
    
    System.out.println(notCount/2);
    
  }
}

Measured memory_bytes: 21844
dn = gets.chomp.split
d = dn[0].to_i
n = dn[1].to_i

result = 0
if d == 0
    if n == 100
        result = 101
    else
        result = n
    end
else
    if n == 100
        result = 100 ** d * (n + 1)
    else
        result = 100 ** d * n
    end
end

puts result

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

# badX[n] == 条件を満たさない長さnのACGT列のうち接尾辞がXであるものの個数
bad   = [0]
badA  = [0]
badG  = [0]
badAC = [0]

def nall(n):
    """長さnのACGT列の総数"""
    return 4 ** n if n >= 0 else 0

def good(n):
    """条件を満たす長さnのACGT列の個数"""
    return nall(n) - bad[n] if n >= 0 else 0
def goodG(n):
    """条件を満たす長さnのACGT列のうち接尾辞がGであるものの個数"""
    return nall(n - 1) - badG[n] if n >= 0 else 0
def goodAC(n):
    """条件を満たす長さnのACGT列のうち接尾辞がACであるものの個数"""
    return nall(n - 2) - badAC[n] if n >= 0 else 0

for n in range(1, N + 1):
    b  = bad [n - 1] * 4              # 前半(n-1)文字が条件を満たさない
    b += good(n - 3)                  # 末尾が AGC
    b += good(n - 3) - goodG (n - 3)  # 末尾が ACG
    b += good(n - 3) - goodAC(n - 3)  # 末尾が GAC
    b += good(n - 4) * 3              # 末尾が ATGC, AGGC, AGTC
    bad.append(b)
    bA   = bad [n - 1]  # 前半(n-1)文字が条件を満たさない (+ 末尾A)
    bG   = bad [n - 1]  # 前半(n-1)文字が条件を満たさない (+ 末尾G)
    bAC  = badA[n - 1]  # 前半(n-1)文字が条件を満たさず末尾がA (+ 末尾C)
    bG  += good(n - 3) - goodG (n - 3)  # 末尾がACG
    bAC += good(n - 3) - goodAC(n - 3)  # 末尾がGAC
    badA.append(bA)
    badG.append(bG)
    badAC.append(bAC)

print(good(N) % (10 ** 9 + 7))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;

int main(){
    int n;
    string s;
    cin >> n >> s;
    //int ans = INF;
    //int count = 0;

    // O(N^2)
    /*for(int i = 0; i < n; i++){
        count = 0;
        for(int j = 0; j < i - 1; j++){
            if(s[j] == 'W'){
                count++;
            }
        }

        for(int j = i + 1; j < n; j++){
            if(s[j] == 'E'){
                count++;
            }
        }
        ans = min(ans,count);
    }

    cout << ans << endl;
    */


    
    vector<int> countW(n);
    vector<int> countE(n);

    int ans = INF;
    int count = 0;

    if(s[0]=='W') countW[0]=1;
    if(s[0]=='E') countE[0]=1;

    for(int i=1;i<n;i++){
        if(s[i]=='W') countW[i]=countW[i-1]+1;
        else countW[i]=countW[i-1];
        if(s[i]=='E') countE[i]=countE[i-1]+1;
        else countE[i]=countE[i-1];
    }

    for(int i=0;i<n;i++){
        count = 0;
        if(i==0) count = countE[n-1];
        else count = countW[i-1] + countE[n-1] - countE[i];
        ans = min(count,ans);
        
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define MOD 1000000007
#define MAX 5000005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int m, d;

    cin>>m>>d;

    int cnt = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 10; j <= d; j++){
            if(j % 10  >= 2 && (j / 10) >= 2){
                int ans = (j % 10) * (j / 10);
                if(ans == i)
                    cnt++;
            }
        }
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
using ll = long long int;

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> p(N);
    for(int i=0;i<N;i++) cin>>p[i];
    
    double p_sum=0;
    for(int i=0;i<K;i++){
        p_sum+=(1+p[i])/2.0;
    }
    
    double max_p=p_sum;
    
    for(int i=1;i+K-1<N;i++){
        p_sum-=(1+p[i-1])/2.0;
        p_sum+=(1+p[i+K-1])/2.0;
        if(p_sum>max_p) max_p=p_sum;
    }
    
    printf("%lf\n",max_p);
    
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int calc(int x,int y){
  int a,t,k =0;
  t = x+y;
  while(t){
    t = t/10;
    k += 1;
  }
  return k;
}
int main(void){
  int a,b;
  while(scanf("%d %d",&a,&b) != EOF){
    printf("%d\n",calc(a,b));
  }
}

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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	bool flag = false;
	rep(i, 2) {
		if (s[i] != s[i + 1]) {
			flag = true;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}


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

void solve(){
    int n,d; cin>>n>>d;
    vector<vector<int>> x(n, vector<int>(d,0));
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }

    int ans = 0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int distance =0;
            rep(k,d){
                distance+= ( abs(x[j][k] - x[i][k]) * abs(x[j][k] - x[i][k]) );
            }
            double sr = sqrt(distance);

            if((sr - floor(sr) == 0)) ans++;
        }
    }

    cout << ans;




}


int main(){
   solve();
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 10000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll cnt[maxn],ans;

int main()
{
	ll x; cin>>x;
	for(int i=1;i<=x;i++)
	{
		for(int j=i;j<=x;j+=i) cnt[j]++;
	}
	rep(i,1,x) ans+=i*cnt[i]; cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 81744
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> a >> b;
  ans = n / (a + b) * a;
  ll amari = n % (a + b);
  ans += min(a, amari);
  Cout(ans);
  return 0;
}

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

#define PI 3.14159265359
#define MODULO 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while (a>0 || b>0){
		c-=b;
		if(c <=0) {
			cout<< "Yes";
			break;
		}
		a-=d;
		if (a<=0){
			cout<<"No";
			break;
		}
	}
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	int l = 0, r = n - 1;
	while (l < r) {
		if (s[l] == 'W') {
			while (r>=0 && s[r] != 'R') {
				r--;
			}
			if (r <= l)break;
			s[l] = 'R';
			s[r--] = 'W';
			ans++;
		}
		l++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3700
n,m=map(int,input().split())
ans = [-1] * 4

for _ in range(m):
    s,c=map(int,input().split())
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        exit()
    
if n == 1:
    print(ans[1] if ans[1]!=-1 else 0)
else:
    if ans[1] == 0:
        print(-1)
        exit()
    if ans[1] == -1:
        ans[1] = 1
    for i in range(2,n+1):
        if ans[i] == -1:
            ans[i] = 0
    res = 0
    for i in range(1,n+1):
        res*=10
        res += ans[i]
    print(res)

Measured memory_bytes: 38384
num_problems = int(input())
t = [int(n) for n in input().split()]
total = sum(t)
num_drinks = int(input())

for i in range(num_drinks):
  m_id, m_val = [int(n) for n in input().split()]
  ans = total - t[m_id-1] + m_val
  print(ans)
  

Measured memory_bytes: 8988
import itertools
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M,Q=mi()
    X = []
    for i in range(Q):
        a,b,c,d = mi()
        X.append((a,b,c,d))

    ans = 0
    num_list = list(range(1,M+1))
    for _nums in itertools.combinations_with_replacement(num_list, N):
        nums = list(_nums)
        D = 0
        for j in range(Q):
            a,b,c,d = X[j]
            if nums[b-1] - nums[a-1] == c: 
                D += d
        
        ans = max(ans,D)

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 73756
package main

import "fmt"

func main() {
	var b string
	fmt.Scan(&b)
	switch b {
	case "A":
		fmt.Println("T")
	case "T":
		fmt.Println("A")
	case "C":
		fmt.Println("G")
	case "G":
		fmt.Println("C")
	}
}


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

using namespace std;

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

  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h);
  for (int i = 0; i < h; ++i) {
    s[i].resize(w);
    for (int j = 0; j < w; ++j) {
      cin >> s[i][j];
    }
  }

  for (int y = 0; y < h; ++y) {
    for (int x = 0; x < w; ++x) {
      if (s[y][x] == '.')
        continue;
      bool black = false;
      for (int dx = -1; dx <= 1; ++dx) {
          if (x + dx < 0 || w <= x + dx || dx == 0)
            continue;
          black |= s[y][x+dx] == '#';
      }
      for (int dy = -1; dy <= 1; ++dy) {
          if (y + dy < 0 || h <= y + dy || dy == 0)
            continue;
          black |= s[y+dy][x] == '#';
      }
      if (!black) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    set<int> s;
    int ans = 1;
    while(1){
        if(s.find(n) == s.end()){
            s.insert(n);
        }else{
            break;
        }
        if(n % 2 == 0){
            n /= 2;
        }else{
            n = n * 3 + 1;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int a, b, c, min, mid, max;

	scanf("%d %d %d", &a, &b, &c);

	if(a <= b && a <= c)
	{
		printf("%d ", a);
		if (b <= c)
			printf("%d %d\n", b, c);
		else
			printf("%d %d\n", c, b);
	}
	
	else if(b <= a && b <= c)
	{
		printf("%d ", b);
		if (a <= c)
			printf("%d %d\n", a, c);
		else
			printf("%d %d\n", c, a);
	}
	
	else if (c <= a && c <= b)
	{
		printf("%d ", c);
		if (a <= b)
			printf("%d %d\n", a, b);
		else
			printf("%d %d\n", b, a);
	}

	return 0;
}

Measured memory_bytes: 1800
class Heap
  attr_accessor :data, :size

  def initialize
    @data=[]
  end

  def push(e)
    @data.push(e)

    cur = @data.size-1
    return if cur.zero?
    parent_i = parent(cur)

    while cur > 0 && @data[cur] < @data[parent_i]
      parent = @data[parent_i]
      @data[parent_i] = e
      @data[cur] = parent
      cur = parent_i
      parent_i = parent(cur)
    end
  end

  def pop
    ret = @data.first
    last = data.last

    cur = 0
    while left_i(cur)<data.size
      li = left_i(cur)
      ri = right_i(cur)
      l=data[li]
      r=data[ri]
      ni=li
      ni=ri if r && r < l

      break if @data[ni] >= last

      @data[cur] = @data[ni]
      cur = ni
    end

    data[cur]=last
    data.pop

    ret
  end

  def left_i(i)
    2*i+1
  end

  def right_i(i)
    2*i+2
  end

  def parent(i)
    return 0 if i.zero?
    (i-1)/2
  end
end

class BH < Heap
  def push(e)
    @data.push(e)

    cur = @data.size-1
    return if cur.zero?
    parent_i = parent(cur)

    while cur > 0 && @data[cur] > @data[parent_i]
      parent = @data[parent_i]
      @data[parent_i] = e
      @data[cur] = parent
      cur = parent_i
      parent_i = parent(cur)
    end
  end

  def pop
    ret = @data.first
    last = data.last

    cur = 0
    while left_i(cur)<data.size
      li = left_i(cur)
      ri = right_i(cur)
      l=data[li]
      r=data[ri]
      ni=li
      ni=ri if r && r > l

      break if @data[ni] <= last

      @data[cur] = @data[ni]
      cur = ni
    end

    data[cur]=last
    data.pop

    ret
  end

end


n = gets.strip.to_i
aa = gets.strip.split.map(&:to_i)

left_h = Heap.new
right_h = BH.new
n.times do |i|
  left_h.push(aa[i])
  right_h.push(aa[2*n+i])
end

left_score = left_h.data.inject(:+)
left_scores = [left_score]
right_score = right_h.data.inject(:+)
right_scores = [right_score]

n.times do |i|
  c_l = aa[n+i]
  if c_l >= left_h.data.first
    left_h.push(c_l)
    left_score += c_l
    left_score -= left_h.pop
  end
  left_scores.push(left_score)

  c_r = aa[2*n-1-i]
  if c_r <= right_h.data.first
    right_h.push(c_r)
    right_score += c_r
    right_score -= right_h.pop
  end
  right_scores.unshift(right_score)

end

#p left_scores.zip(right_scores)
#p left_scores.zip(right_scores).map {|l, r| l-r }
p left_scores.zip(right_scores).map {|l, r| l-r }.max



Measured memory_bytes: 34820
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
    if a[i]+1==a[i+1]:
        cnt += c[a[i]-1]
bb = sum(b)

print(bb+cnt)

Measured memory_bytes: 3064
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Mar 25 21:07:39 2018
//
package main

import (
	"fmt"
)

var N int

func diff(a, b int) int {
	if a < b {
		return b - a
	}
	return a - b
}

func main() {
	fmt.Scan(&N)

	arr := make([]int, N+2)

	prev := 0
	total := 0
	for i := 1; i <= N; i++ {
		fmt.Scan(&arr[i])
		total += diff(prev, arr[i])
		prev = arr[i]
	}
	total += diff(0, prev)

	prev = 0
	for i := 1; i <= N; i++ {
		var d int
		if prev < arr[i] {
			if arr[i] < arr[i+1] {
				d = 0
			} else {
				d = -diff(arr[i], arr[i+1]) - diff(prev, arr[i]) + diff(prev, arr[i+1])
			}
		} else {
			if arr[i] < arr[i+1] {
				d = -diff(arr[i], arr[i+1]) - diff(prev, arr[i]) + diff(prev, arr[i+1])
			} else {
				d = 0
			}
		}
		fmt.Println(total + d)
		prev = arr[i]
	}
}


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

using namespace std;

int fact(int n){
  if (n == 0)
    return 1;
  else
    return n * fact(n-1);
}

int hoge(vector<int> a, int n){
  vector<int> bit(n, 0);

  int s = 0;
  for (int i = 0; i < n; i++){
    int c = 0;
    for (int j = i + 1; j < n; j++){
      c += ((a[j] < a[i]) ? 1 : 0);
    }
    s += c * fact(n - i - 1);

  }

  return s;
}

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

  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++)
    cin >> b[i];




  cout << abs(hoge(a, n) - hoge(b, n)) << endl;
  

  return 0;
}


Measured memory_bytes: 256
// 2014/07/28 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	if(a<b){
		cout << "a < b\n";
	}
	else if(a>b){
		cout << "a > b\n";
	}
	else{
		cout << "a == b\n";
	}

	return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

ll gcd(ll a, ll b) {
  while(a^=b^=a^=b%=a);
  return b;
}

void solve() {
  ll A, B, C, D;
  in(A, B, C, D);
  ll ans = B - A + 1;
  A--;
  ans -= (B / C) - (A / C);
  ans -= (B / D) - (A / D);
  ll l = C * D / gcd(C, D);
  ans += (B / l) - (A / l);
  print(ans);
}


Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
        DecimalFormat df = new DecimalFormat("0.00000000");
        
        double x1 = Double.parseDouble(sc.next());
        double y1 = Double.parseDouble(sc.next());
        double x2 = Double.parseDouble(sc.next());
        double y2 = Double.parseDouble(sc.next());
        double distance = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
        out.println(df.format(distance));
        out.flush();
    }
}


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

#define N 100010

/*
展望台iから一本の道を使ってたどり着けるどんな展望台よりも展望台iの方が標高が高い
＝
展望台iから一本の道を使ってたどり着ける展望台の標高の最大値よりも展望台iの標高が高い

そんなiはいくつあるか
*/

int main(){
    int n,m,h[N],ma[N];
    cin >> n >> m;
    //展望台の標高の入力
    //展望台は1からだから
    for(int i=1;i<=n;i++){
        cin >> h[i];
        ma[i]=0;
    }
    for(int i=0;i<m;i++){
        int a,b;
        //aが展望台の番号
        //bが一本の道を使ってたどり着ける展望台の番号
        cin >> a >> b;
        //maにその展望台の標高の最大値
        /*
        たどり着ける展望台最大値：ma
        自分の標高:h
        を比べている
        */
        ma[a] = max(ma[a],h[b]);
        //上と同様に
        ma[b] = max(ma[b],h[a]);
    }
    int ans = 0;
    /*
    hがその展望台の標高
    maが一本の道で行ける展望台の最大値
    行ける展望台のどれよりも、自分の方が大きい
    */
    //ma[a]=max(ma[a],h[b])でh[b]を代入すれば
    //h[i] > ma[i] になる

    //h[i]の方がma[i]より大きければ+1
    for(int i=1;i<=n;i++){
        ans += h[i]>ma[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool isPalin(string s)
{
	for(int i=0; i<s.length(); i++)
	{
		if(s[i]!=s[s.length()-i-1])
			return false;
	}
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,s1,s2;
	cin>>s;
	int n=s.length();
	s1 = s.substr(0,n/2);
	s2 = s.substr((n+1)/2,n/2);
	if(isPalin(s)&&isPalin(s1)&&isPalin(s2))
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
ll M = 1000000007;

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

  int ans = K;
  for(int i=0;i<N-1;i++) ans *= (K-1);

  cout << ans <<endl;
  

  return 0;
}

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

typedef long long ll;
const ll MOD = ll(1e9 + 7);
const int MAX_N = int(3e5) + 5;
#define REP(i, n) for (int i = 0; i < n; i++)

ll factrial[MAX_N], inverse[MAX_N];

ll power(ll x, ll n) {
    ll ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ans;
}

void init(ll n) {
    factrial[0] = 1;
    inverse[0] = 1;
    for (ll i = 1; i <= n; i++) {
        factrial[i] = (factrial[i - 1] * i) % MOD;
        inverse[i] = power(factrial[i], MOD - 2) % MOD;
    }
}

ll nCk(ll n, ll k) {
    if (n<0 || k<0 || n-k<0)return 0;
    return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

bool ck[MAX_N]{};
ll num[MAX_N];

int main() {
    ll n, a, x, y;
    cin >> n;
    n++;
    REP(i,n){
        cin >> a;
        if(!ck[a]){
            ck[a] = true;
            num[a] = i;
        }
        else{
            x = num[a];
            y = n-i-1;
        }
    }
    init(n);
    ll ans;
    for(ll k = 1;k<=n;k++){
        ans = 0;
        //0
        ans += nCk(n-2,k);
        ans %= MOD;
        //1
        ans += nCk(n-2,k-1)*2 - nCk(x+y,k-1) + MOD;
        ans %= MOD;
        //2
        ans += nCk(n-2,k-2);
        cout << ans%MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 6144
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};


int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n;
    ll a,b;
    ll k,t;
    string str;
    ll h,w;
    char c,ko;
    cin>>n>>str;
    n=str.length();
    a=0;k=0;
    rep(i,n){
        if(str[i]=='.') a++;
        else k++;
    }
    ll sum=min(a,k);
    reverse(all(str));
    b=0;w=0;
    rep(i,n){
        if(str[i]=='#') b++;
        else w++;
        sum=min(sum,k-b+w);
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll n;
vi v;

int main(){
	cinit();
	cin>>n;
	int ai;
	rep(i,n){
		cin>>ai;
		v.pb(ai);
	}
	Sort(v);
	ll ans = 0;
	rep(i,n){
		if(i%2==0)ans+=v[i];
		else ans-=v[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

ll n,a,b,c,d;
string s;
int flag = 0;
bool stat = true;

bool solve(){
    while(true) {
//        cout << a << " " << b << endl;
        if (a == c and b == d) {
            return true;
        }
        if (flag == 0) {
            if (a == c) {
                flag = 1;
                if (stat == false) {
                    return false;
                }
                stat = false;
            } else if (s[a] == '.' and a + 1 != b) {
                a = a + 1;
                stat = true;
            } else if (s[a + 1] == '.' and a + 2 != b) {
                a = a + 2;
                stat = true;
            } else {
                flag = 1;
                if (stat == false) {
                    return false;
                }
                stat = false;
            }
        } else {
            if (b == d) {
                flag = 0;
                if (stat = false) {
                    return false;
                }
                stat = false;
            } else if (s[b] == '.' and b + 1 != a) {
                b = b + 1;
                stat = true;
                flag = 0;
            } else if (s[b + 1] == '.' and b + 2 != a) {
                b = b + 2;
                stat = true;
                flag = 0;
            } else {
                flag = 0;
                if (stat == false) {
                    return false;
                }
                stat = false;
            }
        }
    }
}


int main() {
    


    cin >> n >> a >> b >> c >> d >> s;
    if(c < d){
        swap(a,b);
        swap(c,d);
    }

    bool ans = solve();
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
from sys import stdin

if __name__ == "__main__":
  N, M = [int(i) for i in input().split()]
  K = []
  S = []
  for i in range(M):
    line = input().split()
    K.append(int(line[0]))
    S.append(set(int(item) for item in line[1:]))
    
  P = [int(i) for i in input().split()]
  
  cnt = 0
  for i in range(2**N):
    on_switches = set()
    for j in range(N):
      if i >> j & 1:
        on_switches.add(j+1)
    
    is_light_on = []
    for m, light_switches in enumerate(S):
      total_switch = len(light_switches & on_switches)
      is_light_on.append(total_switch % 2 == P[m])
    if all(is_light_on):
      cnt += 1
  
  print(cnt)  
  
  


Measured memory_bytes: 3064