akhauriyash/Code-Regression huggingface dataset:
from collections import Counter

def main():
    n = int(input())
    s = [input() for i in range(n)]
    ac = 0    
    wa = 0
    tle = 0
    re = 0
    for i in s:
        if i == 'AC':
            ac += 1
        elif i == 'WA':
            wa += 1
        elif i == 'TLE':
            tle += 1
        elif i == 'RE':
            re += 1
    print('AC x ', ac, sep='')
    print('WA x ', wa, sep='')
    print('TLE x ', tle, sep='')
    print('RE x ', re, sep='')

if __name__ == '__main__':
    main()

Measured memory_bytes: 16624
#include <bits/stdc++.h> 
using namespace std; 
  
// set the MAX_SIZE of the array to 10^6 
const int MAX_SIZE = 1e6; 
  
// initialize the prime array 
bool prime[MAX_SIZE + 1]; 
  
void sieve() 
{ 
  
    // set all numbers as prime for time being 
    memset(prime, true, sizeof(prime)); 
  
    for (int p = 2; p * p <= MAX_SIZE; p++) { 
  
        // if prime[p] is not changed, then it is a prime 
        if (prime[p] == true) { 
  
            // update all multiples of p 
            for (int i = p * p; i <= MAX_SIZE; i += p) 
                prime[i] = false; 
        } 
    } 
} 
// Function to find the kth prime greater than n 
int kthPrimeGreaterThanN(int n, int k) 
{ 
  
    int res = -1; 
    // looping through the numbers greater than n 
    for (int i = n + 1; i < MAX_SIZE; i++) { 
  
        // decrement k if i is prime 
        if (prime[i] == true) 
            k--; 
  
        // store the kth prime greater than n 
        if (k == 0) { 
            res = i; 
            break; 
        } 
    } 
  
    return res; 
} 
  
// Driver code 
int main() 
{ 
  
    sieve(); 
    int n;cin>>n;
  
    // Print the kth prime number greater than n 
    cout << kthPrimeGreaterThanN(n-1, 1); 
    return 0; 
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <stack>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    while(getline(cin, s), s != ".")
    {
        stack<char> st;
        bool ok = true;
        for(int i = 0; i < s.size(); i++)
        {
            if(s[i] == '(' or s[i] == '[') st.push(s[i]);
            else if(s[i] == ')')
            {
                if(st.empty() or st.top() != '(')
                {
                    ok = false;
                    break;
                }
                st.pop();
            }
            else if(s[i] == ']')
            {
                if(st.empty() or st.top() != '[')
                {
                    ok = false;
                    break;
                }
                st.pop();
            }
        }
        if(ok and st.empty()) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}




Measured memory_bytes: 3228
#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;

int main() {
    

    string s;
    cin >> s;
    for (ll i=0;i<s.length();i++){
        cout << "x";
    }
    cout << endl;
}

Measured memory_bytes: 256
using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   998244353

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};

 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                    > pq;*/


int main()
{   ll n,x,m;cin>>n>>x>>m;
   vector<ll> visited(m+1);
    ll ans=0;
     ll sum=0,a=0;
     while(n>0)
     {    visited[x]++;
         if(visited[x]==2){a++;sum+=x; }
         else if(visited[x]==3)
         {
             sum+= (n/a)*sum;ans+=sum;
             n%=a;
              while(n--)
              {
                  ans+=x;x=(x*x)%m;
              }
              break;
         }
         else ans+=x;

         x=(x*x)%m;n--;
     }
     cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 4036
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  int flag[5]={5,7,5,7,7};
  while(cin >> n,n){
    string str;
    vector<int> cnt;
    rep(i,n){
      cin >> str;
      int tmp = str.size();
      cnt.push_back(tmp);
    }
    bool finish = false;
    rep(i,n){
      //cout << "#" << endl;
      int stage = 0;
      int sum = cnt[i];
      if(sum > flag[0]) continue;
      else if(sum == flag[0]) {
        stage++;
        sum = 0;
      }
      for(int j=i+1; j<n; j++){
        //cout << stage  << " " << sum << endl;
        sum += cnt[j];
        if(sum > flag[stage]) break;
        else if(sum == flag[stage]){
          stage++;
          sum = 0;
        }
        if(stage == 5) {
          cout << i+1 << endl;
          finish  = true;
          break;
        }
      }
      if(finish == true) break;
    }
  }
  return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <map> //map<string, int> cnt; key とvalue
#include <set>//  set<int> s;
#include <cstdlib>  // abs() for integer
#include <vector>
#define rep(i,n) for(int i = 0 ; i < (n); ++i)
using namespace std;
using ll = long long;
/*
g++ -std=c++11
*/
int main(){
  int N,n;
  cin >> N;
  n = N %10;
  if(n==2||n==4||n==5||n==7||n==9) cout << "hon";
  else if(n==0||n==1||n==6||n==8) cout << "pon";
  else cout << "bon";
  return 0;
}

Measured memory_bytes: 3036
bingo = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]
]

A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

N = int(input())

B = []
for i in range(N):
    B.append(int(input()))
    
for b in B:
    for i, ai in enumerate(A):
        for j, aij in enumerate(ai):
            if b == aij:
                bingo[i][j] = 1
                break
                
if bingo[0][0] == bingo[0][1] == bingo[0][2] == 1:
    print('Yes')
elif bingo[1][0] == bingo[1][1] == bingo[1][2] == 1:
    print('Yes')
elif bingo[2][0] == bingo[2][1] == bingo[2][2] == 1:
    print('Yes')
elif bingo[0][0] == bingo[1][0] == bingo[2][0] == 1:
    print('Yes')
elif bingo[0][1] == bingo[1][1] == bingo[2][1] == 1:
    print('Yes')
elif bingo[0][2] == bingo[1][2] == bingo[2][2] == 1:
    print('Yes')
elif bingo[0][0] == bingo[1][1] == bingo[2][2] == 1:
    print('Yes')
elif bingo[0][2] == bingo[1][1] == bingo[2][0] == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = input.trim().split("\n")
while (lines.length > 1) {
    const [u, t] = lines.shift().trim().split(" ").map(Number)
    let cU = 0, cT = t, tArr = []
    while (tArr[cU] !== t) {
        if(cT > 0) {
            tArr[cU] = (tArr[cU] || 0) + 1
            cT--
        } else {
            cT = tArr[cU]
            tArr[cU] = 0
        }
        cU = (cU + 1)%u
    }
    console.log(cU)
}



Measured memory_bytes: 16116
import sys
input=sys.stdin.readline
n,c,k=map(int,input().split())
T=[int(input()) for _ in range(n)]
T.sort()
cnt=1
num=0
time=T[0]
for i in range(n):
    if num<c and T[i]<=time+k:
        num+=1
    else:
        cnt+=1
        time=T[i]
        num=1
print(cnt)

Measured memory_bytes: 7384
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	s = input()
	r=0
	rm=0
	for c in s:
		if c == 'R':
			r+=1
			rm = max(r,rm)
		else:
			r=0
	return rm
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using namespace std;

const int INF = 10000000;

int main(int argc, char *argv[])
{
  int A, B, C;
  cin >> A >> B >> C;

  if (A <= B) {
    if (A <= C && C <= B) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    if (B <= C && C <= A) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int m, f, r;

	while (cin >> m >> f >> r && m != -1 || f != -1 || r != -1) {
		if (m == -1 || f == -1)
			cout << "F" << endl;
		else if (m + f >= 80)
			cout << "A" << endl;
		else if (m + f >= 65)
			cout << "B" << endl;
		else if (m + f >= 50)
			cout << "C" << endl;
		else if (m + f >= 30) {
			if (r >= 50)
				cout << "C" << endl;
			else
				cout << "D" << endl;
		}
		else
			cout << "F" << endl;
	}
}


Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	priority_queue<pair<long long int, long long int> > qu;
	for(int i = 0; i < n; i++){
		long long int a, b;
		cin >> a >> b;
		qu.push(make_pair(a + b, a));
	}

	long long int sum_t = 0, sum_a = 0;
	for(int i = 0; i < n; i++){
		if(i % 2 == 0){
			sum_t += (qu.top()).second;
		} else {
			sum_a += (qu.top()).first - (qu.top()).second;
		}
		qu.pop();
		// cout << sum_t << " " << sum_a << endl;
	}
	cout << sum_t - sum_a << endl;
}

Measured memory_bytes: 2420
a, b, c = map(int, input().split())
i = a ** 2 + b ** 2 + c ** 2
j = 2 * (a * b + b * c + c * a)
k = i - j
if k > 0 and c - a - b >= 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <float.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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




int main() {
	string str;
	cin >> str;
	int count = 0;

	if (str.length() == 1) {
		cout << 0 << endl;
		return 0;
	}

	int ind = 0;
	bool ok = true;
	vector<char> st;
	vector<int> natural_index(str.length());
	rep(i, str.length()) {
		if (str[i] != 'x') {
			st.push_back(str[i]);
			natural_index[st.size() - 1] = i;
		}
	}

	if (st.size() == 0) {
		cout << 0 << endl;
		return 0;
	}

	while (ind <= st.size() / 2) {
		if (st[ind] != st[st.size() - 1 - ind]) {
			ok = false;
			break;
		}
		ind++;
	}
	if (!ok) {
		cout << -1 << endl;
		return 0;
	}
	if (st.size() % 2 == 0) {
		int former = natural_index[st.size() / 2 - 1];
		int latter = natural_index[st.size() / 2];
		int res = 0;
		int ind = 0;
		int rev = str.length() - 1;
		while (ind <= former && rev >= latter) {
			if (str[ind] != str[rev]) {
				res++;
				if (str[ind] == 'x')
					rev++;
				else
					ind--;
			}
			ind++;
			rev--;
		}
		cout << res << endl;
	}
	else {
		int central = natural_index[st.size() / 2];
		int res = 0;
		int ind = 0;
		int rev = str.length() - 1;
		while (ind <= central && rev >= central) {
			if (str[ind] != str[rev]) {
				res++;
				if (str[ind] == 'x')
					rev++;
				else
					ind--;
			}
			ind++;
			rev--;
		}
		cout << res << endl;
	}

}



Measured memory_bytes: 1024
N = int(input())
S = [int(i) for i in input()]

ans = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      Flag1 = True
      Flag2 = False
      Flag3 = False
      for x in S:
        if Flag3:
          if x == k:
            ans += 1
            break
        if Flag2:
          if x == j:
            Flag2 = False
            Flag3 = True
        if Flag1:
          if x == i:
            Flag1 = False
            Flag2 = True

print(ans)

Measured memory_bytes: 69100
class Point {
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }

  print() {
    console.log(this.x.toFixed(8) + ' ' + this.y.toFixed(8));
  }
}

(function main(){
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8').trim());
  let p1 = new Point(0, 0);
  let p2 = new Point(100, 0);
  p1.print();
  kock(n, p1, p2);
  p2.print();
})();

function kock(n, p1, p2) {
  const sin60 = Math.sin(60 * Math.PI / 180);
  const cos60 = Math.cos(60 * Math.PI / 180);
  function innerFunc(n, p1, p2) {
    if (!n) return;
    xDiff = p2.x - p1.x;
    yDiff = p2.y - p1.y;
    let s = new Point(p1.x + xDiff / 3, p1.y + yDiff / 3);
    let t = new Point(s.x + xDiff / 3, s.y + yDiff / 3);
    let u = new Point((t.x - s.x) * cos60 - (t.y - s.y) * sin60 + s.x, (t.x - s.x) * sin60 + (t.y - s.y) * cos60 + s.y);
    kock(n-1, p1, s); s.print();
    kock(n-1, s, u);  u.print();
    kock(n-1, u, t);  t.print();
    kock(n-1, t, p2);
  }
  kock = innerFunc;
  innerFunc(n, p1, p2);
}



Measured memory_bytes: 20196
n = int(input())
s = str(input())
mod = 10**9+7
d = {}
for i in range(n):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
ans = 1
for v in d.values():
    ans *= (v+1)%mod
ans -= 1
print(ans%mod)

Measured memory_bytes: 39408
# ABC092 B - Chocolate
n = int(input())
d,x = map(int, input().split())
a = []

a = [int(input()) for _ in range(n)]

ans = 0
for i in range(n):
    j = 0
    while j*a[i]+1 <= d:
        ans += 1
        j += 1
print(ans+x)


Measured memory_bytes: 3060
h, w = list(map(int, input().split()))
s = [list(input()) for _ in range(h)]
diff = [[1, 0], [0, 1], [-1, 0], [0, -1]]

def a(s, h, w, diff):
    num, cnt = 0, 0
    for i in range(h):
        for j in range(w):
            if s[i][j]=='#':
                for k in diff:
                    i += k[0]
                    j += k[1]
                    if (0<=i and i<=h-1) and (0<=j and j<=w-1):
                        num += 1
                        if s[i][j]=='.':
                            cnt += 1
                    i -= k[0]
                    j -= k[1]
                if cnt==num:
                    return print('No')
            num, cnt = 0, 0
    return print('Yes')
a(s, h, w, diff)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 210;
int n,k,mod;

inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
int fac[N],ifac[N];
inline void init(int n){
	fac[0]=1;
	For(i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=power(fac[n],mod-2);
	Dow(i,n-1,0) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
inline int C(int n,int m){
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int f[N][N],g[N];
inline void upd(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}
inline int Mod(int x){
	return x>=mod?x-mod:x;
}
inline int dp(int m,int n,int deg){
	For(i,0,n) For(j,0,m) f[i][j]=0;
	FOR(j,0,m) if (!((j&&j-1+n>deg)||m-j>deg)) f[1][j]=1;
	For(i,2,n){
		int s=0;
		FOR(j,0,m){
			f[i][j]=s=Mod(s+f[i-1][j]);
			if ((j&&j-1+(n-i+1)>deg)||m-j+i-1>deg) f[i][j]=0;
		}
	}
	int ret=0;
	FOR(i,1,m) upd(ret,f[n][i]);
	return ret;
}
inline int calc(int n,int deg){
	if (n==0) return 1;
	if (n==1) return 0;
	int ret=0;
	For(i,1,min(deg+1,n)) ret=(ret+1ll*C(n-1,i-1)*fac[n-i]%mod*fac[i-1]%mod*dp(i,n-i,deg))%mod;
	return ret;
}

int main(){
	n=read(),k=read(),mod=read();
	init(n);
	int ans=0;
	For(i,0,min(n,k+1)) ans=(ans+1ll*C(n,i)*fac[i]%mod*calc(n-i,k-i))%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 3944
import numpy as np

N = int(input())
A = list(map(int, input().split()))

cum_A = np.cumsum(A)
ans = 10 ** 18
for i in range(N):
    left = cum_A[i]
    right = cum_A[-1] - cum_A[i]
    ans = min(ans, abs(left - right))
print(ans)


Measured memory_bytes: 50032
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

#define rep(i, N) for(ll i=0; i<(N); ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

int main() {
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  
  cout << fixed << setprecision(9) <<
    ((double)(W * H) / 2) << " " <<
    (x == W / 2 && y == H / 2 && W % 2 == 0 && H % 2 == 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

const int N = 100;
const int K = 1e5;
ll dp[N+1][K+1];

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

	int n, k;
	cin >> n >> k;

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

		ll run = 0;
		for (int x = 0; x <= k; ++x) {
			run += dp[i][x];
			if (x > a) run -= dp[i][x-a-1];

			dp[i+1][x] = run % MOD;
		}
	}

	cout << dp[n][k] << '\n';
}


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

int main(){
    int a, b;
    string sa, sb;
    cin >> a >> b;
    for(int i=0; i<b; i++){
        sa += to_string(a);
    }
    for(int i=0; i<a; i++){
        sb += to_string(b);
    }
    if(sa <= sb){
        cout << sa << endl;
    }
    else{
        cout << sb << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> wcnt(n, 0);
    vector<int> ecnt(n, 0);
    repl(i, 1, n) {
        if(s[i - 1] == 'W') wcnt[i] = wcnt[i - 1] + 1;
        else wcnt[i] = wcnt[i - 1];
    }
    for(int i = n - 2; i >= 0; i--) {
        if(s[i + 1] == 'E') ecnt[i] = ecnt[i + 1] + 1;
        else ecnt[i] = ecnt[i + 1];
    }
    int ans = n;
    rep(i, n) {
        ans = min(ans, wcnt[i] + ecnt[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6160
k = gets.to_i

ans = 0
1.upto(k) do |a|
    1.upto(k) do |b|
        x = a.gcd(b)
        
        if x == 1
            ans += k
        else
            1.upto(k) {|c| ans += x.gcd(c)}
        end
    end
end

puts ans

Measured memory_bytes: 14284
N, *a = map(int, open(0).read().split())

dp = [0] * N
for i in reversed(range(N)):
    cnt = sum(dp[i::i + 1])
    if cnt % 2 == a[i]:
        dp[i] = 0
    else:
        dp[i] = 1
            
if True:
    b_bin = [i + 1 for i in range(N) if dp[i] > 0]
    print(len(b_bin))
    print(*b_bin)
else:
    print(-1)

Measured memory_bytes: 73472
#include<bits/stdc++.h>
using namespace std;
#define mx 1000000000000000000
#define ll long long int
ll a[40001000];
//ll number[20],used[20];
int main()
{
  string s;
  ll n,i,count,b;
  cin>> n >> s;
  for(i=0;i<s.size();i++)
  {
      ll c = s[i];
     // cout  << c << endl;
      if(c+n<=90)
       b=c+n;
      else
        b = c+n-90+64;

      s[i]=  (char) b;

    //  cout << s[i] << endl;
  }
  cout << s << endl;
    return 0;
}


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

class PaizaSample
{

    

    static void Main()
    {
        string input;
        while ((input = Console.ReadLine()) != null)
        {

            Int64 n = int.Parse(input);
            if (n > 2000)
            {
                n = 4000 - n;
            }

            Int64 count = 0;
            if (n >= 1000)
            {
                count = n * (n + 1) * (n + 5) / 6 + n + 1 - 2 * (n - 1000) * (n - 1000 + 1) * (n - 1000 + 2) / 3;
            }
            else
            {
                count = n * (n + 1) * (n + 5) / 6 + n + 1;

            }

            //int n = int.Parse(input);
            //int count = 0;

            //for (int i = (n > 3000 ? n - 3000 : 0); i <= (n < 1000 ? n : 1000); i++)
            //{
            //    for (int j = (n - i > 2000 ? n - i - 2000 : 0); j <= (n - i < 1000 ? n - i : 1000); j++)
            //    {
            //        for (int k = (n - i - j > 1000 ? n - i - j - 1000 : 0); k <= (n - i - j < 1000 ? n - i - j : 1000); k++)
            //        {
            //            count++;
            //        }
            //    }
            //}

            Console.WriteLine(count);

        }

        //Console.ReadKey();

    }
}

Measured memory_bytes: 9156
#include<iostream>
using namespace std;
#include<queue>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
bool b[2003];

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

int main()
{
	int min,b,a,m[101][101],n ,e,p[101],d[101],u,v; //u ?????????v????????¨
	bool color[101];
	cin>>n;
	REP(i, n) {
		REP(j, n) {
			cin>>m[i][j];
			if(m[i][j]==-1) m[i][j]=2001;
		}
		color[i]=0;
		d[i]=2001;
		p[i]=2001;
	}
	a=0;
	d[0]=0;
	while(1){
		min=2001;
		u=-1;
		REP(i,n){
			if(min>d[i]&&color[i]==0){
				min=d[i];
				u=i;
			}
		}
		if(u==-1) break;
		color[u]=1;
		REP(i,n){
			if(color[i]==0&&m[u][i]!=2001){
				if(d[i]>m[u][i]){
					d[i]=m[u][i];
					p[i]=u;
				}
			}
		}

	}
	min=0;
	REP(i,n){
		if(p[i]!=2001){
		min=min+m[i][p[i]];
		}
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
queue<int>o;
queue<int>p;
queue<int>q;
int a,b,c,x,y,z,t;
int main(){
	cin>>a>>b>>c;
	t=0;
	o.push(a);
	p.push(b);
	q.push(c);
	o.push(-1);
	p.push(-1);
	q.push(-1);
	while(1){
		int x=o.front(),y=p.front(),z=q.front();
		o.pop();p.pop();q.pop();
		if(x==-1){
			t++;
			o.push(-1);
			p.push(-1);
			q.push(-1);
			continue;
		}
		if(x==y&&y==z){
			printf("%d",t);
			break;
		}
		if(x>y){
			if(y>z){
				a=x;b=y;c=z;
			}
			else if(z>x){
				a=z;b=x;c=y;
			}
			else {
				a=x;b=z;c=y;
			}
		}
		else {
			if(y>z){
				a=y;b=x;c=z;
			}
			else if(z>x){
				a=z;b=y;c=x;
			}
			else {
				a=y;b=z;c=x;
			}
		}
		if(a-c>=2){
			o.push(a);
			p.push(b);
			q.push(c+2);
		}
		else {
			o.push(a);
			p.push(b);
			q.push(c+2);
			o.push(a);
			p.push(b+1);
			q.push(c+1);
		}
	}
	return 0;
}


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

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            if (s.Length == 1) Console.WriteLine(0);
            else Console.WriteLine(GetCount(s));
        }
    }
    public static int GetCount(string s)
    {
        var count = 0;
        while (true)
        {
            var sL = s.Length;
            var nL = new List<int>();
            for (int i = 1; i < sL; i++)
            {
                var s1 = s.Substring(0, i);
                var s2 = s.Substring(i);
                nL.Add(int.Parse(s1) * int.Parse(s2));
            }
            count++;
            var nLmax = nL.Max();
            if (nLmax < 10) return count;
            else if (s == nLmax.ToString()) return -1;
            else s = nLmax.ToString();
        }
    }
}

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

using namespace std;

int main(){
	char op;
	int a,b;
	while(cin>>a>>op>>b){
	if(op == '+')cout<<a+b<<endl;
	else if(op == '-')cout<<a-b<<endl;
	else if(op == '*')cout<<a*b<<endl;
	else if(op == '/')cout<<a/b<<endl;
	else break;}			
	return 0;
		}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double  
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((ll)x.size())

const ll N=2e5+7;
vector<ll> dp(N,0);

ll powm(ll a,ll n,ll x){
  a%=x;
  ll r=1;
  while(n>0){
    if(n&1) r=(r*a)%x;
    a=(a*a)%x;
    n>>=1;
  }
  return r;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  dp[1]=1;
  dp[2]=1;
  for(ll i=3 ; i<=2e5 ; i++){
    ll x=__builtin_popcount(i);
    ll y=i%x;
    dp[i]=dp[y]+1;
  }
  ll n; cin>>n;
  string s; cin>>s;
  vector<ll> v(n,0),w(n,0);
  ll cnt=0;
  for(ll i=0 ; i<n ; i++) cnt+=s[i]=='1'; 
  v[n-1]=w[n-1]=1;
  for(ll i=n-2 ; i>=0 ; i--){
    v[i]=(v[i+1]*2)%(cnt+1);
    if(cnt>1) w[i]=(w[i+1]*2)%(cnt-1);
  }
  ll a1=0,a2=0;
  for(ll i=0 ; i<n ; i++) a1=(a1+(s[i]-'0')*v[i])%(cnt+1);
  if(cnt>1){
    for(ll i=0 ; i<n ; i++) a2=(a2+(s[i]-'0')*w[i])%(cnt-1);
  }
  for(ll i=0 ; i<n ; i++){
    if(s[i]=='0'){
      ll e=(a1+v[i])%(cnt+1);
      cout<<dp[e]+1;LOL
    }
    else{
      if(cnt>1){
        ll e=(a2-w[i])%(cnt-1);
        if(e<0) e+=cnt-1;
        cout<<dp[e]+1;LOL
      }
      else{
        cout<<0;LOL
      }
    }
  }
  return 0;
}


Measured memory_bytes: 8332
#include <bits/stdc++.h>
#define TASK "task"

using namespace std;

void rwFile() {
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
}

void solveA() {
    int x, y, z; cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y;
}

void solveB() {
    int n, m; cin >> n >> m;
    int S = 0, arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        S += arr[i];
    }
    int t = m;
    for (int i = 0; i < n; i++) {
        if (4 * m * arr[i] >= S) t--;
    }
    if (t > 0) cout << "No";
    else cout << "Yes";
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

void solveC() {
    long long n, k; cin >> n >> k;
    cout << gcd(n, k) % k;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    solveB();
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

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

typedef long long ll;

int main() {
	//入力;
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;

	REP(i, n) {
		cout << s[i] << t[i];
	}
	cout << endl;


	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int a, b, c, k;
   cin>>a>>b>>c>>k;
   int ans=0;

   ans+=min(a, k);
   k=max(0, k-a);

   k=max(0, k-b);

   ans-=k;

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


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    vector<int> x(5);
    for(int in=0;in<5;in++) {
        cin >> x.at(in);
    }
    for(int in=0;in<5;in++) {
        if(x.at(in)==0) { 
            cout << in+1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <map>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    map<int,int> mp;
    for(int i = 0;i<n;i++){
        cin >> a[i];
        mp[a[i]]=i;
    }
    int streak,cnt;
    streak = 1;
    cnt = 0;
    for(int i = 2;i<=n;i++){
        if(mp[i]>mp[i-1]) streak++;
        else{
            cnt = max(streak,cnt);
            streak = 1;
        }
    }
    cnt = max(streak,cnt);
    cout << n - cnt << endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<endl;
#define PI 2*acos(0.0)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define yes cout<<"Yes"<<endl
#define no cout<<"-1"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///

int main()
{
    FIO;
    int n,i,j;
    cin>>n;
    vi v(n);
    read(v,0,n);
    vi dp(n);
    dp[1] = abs(v[1]-v[0]);
    for(i=2; i<n; i++)
    {
        dp[i] = min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 3948
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <complex>
#include <vector>
#include <utility>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
#define EPS (1e-9)
typedef complex<double> P;

const double g = 9.8;

int N, V, X, Y, L[60], B[60], R[60], T[60];
double f;

void calc_push(vector<P>& vs, double v, double x, double y) {
    if(x==0) return ;
    const double a = g*g/4, b = g*y-v*v, c = x*x+y*y;
    const double k[2] = {(-b+sqrt(b*b-4*a*c))/2/a, (-b-sqrt(b*b-4*a*c))/2/a};
    rep(i, 2) if(k[i]>0) {
        const double t = sqrt(k[i]);
        vs.push_back(P(x/t, y/t+g*t/2));
    }
}

double yof(double vy, double t) { return vy*t-g*t*t/2; }

bool can(double vx, double vy) {
    const double gy = yof(vy, X/vx);
    if(gy < Y-EPS || gy > f+EPS) return false;
    const double tt = vy/g, tx = vx*tt, ty = yof(vy, tt);
    rep(i, N) {
        double l = yof(vy, L[i]/vx), r = yof(vy, R[i]/vx);
        if(l>r) swap(l, r);
        if(B[i]+EPS<l && l<T[i]-EPS) return false;
        if(B[i]+EPS<r && r<T[i]-EPS) return false;
        if(l<B[i]-EPS && r>B[i]+EPS) return false;
        if(l<T[i]-EPS && r>T[i]+EPS) return false;
        if(l<B[i]-EPS && r<B[i]-EPS) {
            if(L[i]+EPS<tx && tx<R[i]-EPS && ty>B[i]+EPS) return false;
        }
        const double m = yof(vy, (L[i]+R[i])/2/vx);
        if(B[i]+EPS < m && m < T[i]-EPS) return false;
    }
    return true;
}

int main() {
    const double pi = atan2(0.0, -1.0);
    scanf("%d%d%d%d", &N, &V, &X, &Y);
    rep(i, N) scanf("%d%d%d%d", L+i, B+i, R+i, T+i);
    int k = 0;
    rep(i, N) if(L[i]<=X) {
        L[k] = L[i]; B[k] = B[i]; T[k] = T[i]; R[k] = min(R[i], X);
        k++;
    }
    N = k;
    f = 1e100;
    rep(i, N) if(L[i]<=X && X<=R[i] && T[i]>=Y) f = min(f, (double)B[i]);
    vector<P> vs;
    calc_push(vs, V, X, Y);
    rep(i, N) {
        calc_push(vs, V, L[i], T[i]);
        calc_push(vs, V, R[i], T[i]);
    }
    bool ans = false;
    rep(k, vs.size()) {
        if(can(real(vs[k]), imag(vs[k]))) ans = true;
    }
    puts(ans ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
	int a,b, c[3];
	scanf("%d %d", &a, &b);
	c[0] = a + b;
	c[1] = a - b;
	c[2] = a*b;
	if (c[0]<c[1]){
		if (c[1] < c[2]){
			printf("%d", c[2]);
		}
		else{
			printf("%d", c[1]);
		}
	}
	else {
		if (c[0] < c[2]){
			printf("%d", c[2]);
		}
		else{
			printf("%d", c[0]);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<stdio.h>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	bool flag = true;

	int time = 0, cnt = 0;
	rep(i,100){
		if(time <= c && c <= time + a){
			cout << 60*cnt + c << endl;
			flag = false;
			break;
		}
		time += a + b;
		if(time > 60){
			cnt++, time -= 60;
		}
	}
	if(flag)cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstring>
#define M 1000000
using namespace std;
char list[M][13];
void Init()
{
    for(int i=0;i<M;i++)
        list[i][0] = '\0';
}
int getch(char a)
{
    if(a=='A')
        return 1;
    else if(a=='C')
        return 2;
    else if(a=='G')
        return 3;
    else
        return 4;
}
long long getkey(char a[])
{
    long long sum=0,p=1;
    for(int i=0;a[i]!='\0';i++)
    {
        sum += getch(a[i])*p;
        p *= 5;
    }
    return sum;
}
int h1(long long key)
{
    return key%M;
}
int h2(long long key)
{
    return 1+key%(M-1);
}
int h(long long key,int i)
{
    return (h1(key)+i*h2(key))%M;
}
bool insert(char a[])
{
    long long key = getkey(a);
    int i,index;
    for(i=0;i<M;i++)
    {
        index = h(key,i);
        if(list[index][0]=='\0')
        {
            strcpy(list[index],a);
            return 1;
        }
        else if(strcmp(list[index],a)==0)
            return 1;
        else
            continue;
    }
    return 0;
}
bool find(char a[])
{
    long long key = getkey(a);
    int i,index;
    for(i=0;i<M;i++)
    {
        index = h(key,i);
        if(list[index][0]=='\0')
            return 0;
        else if(strcmp(list[index],a)==0)
            return 1;
        else
            continue;
    }
    return 0;
}
int main()
{
    int n;
    char s1[7],s2[13];
    Init();
    cin>>n;
    while(n--)
    {
        cin>>s1>>s2;
        if(s1[0]=='i')
        {
            insert(s2);
        }
        else
        {
            if(find(s2))
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 15776
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();

    let mut count: usize = 0;
    for i in 1..n + 1 {
        if i % 2 == 1 {
            count += 1;
        }
    }
    let ans: f64 = count as f64 / n as f64;
    println!("{}", ans);
}


Measured memory_bytes: 4352
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
import std.typecons;

void main() {
    auto s = read();
    const string t = "CODEFESTIVAL2016";
    int ret = 0;
    foreach(i; 0..t.length) {
        if (s[i] != t[i]) ret++;
    }
    writeln(ret);
}

string read() {
    static string[] ss;
    while (!ss.length) ss = readln.chomp.split;
    auto res = ss[0];
    ss.popFront;
    return res;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll a, b; cin >> a >> b;
	ll s = 100;
	string m[100];
	rep(i, 0, s)m[i] = string(s, ((i < 50) ? '.' : '#'));
	b--, a--;

	rep(i, 0, s) {
		if (!b)break;
		rep(j, 0, s) {
			if (!b)break;
			if (!(i & 1) && j & 1) {
				m[i][j] = '#';
				b--;
			}
		}
	}

	rep(i, s / 2 + 1, s) {
		if (!a)break;
		rep(j, 0, s) {
			if (!a)break;
			if (!(i & 1) && j & 1) {
				m[i][j] = '.';
				a--;
			}
		}
	}

	cout << 100 << " " << 100 << endl;
	rep(i, 0, s) {
		rep(j, 0, s)cout << m[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    # input = sys.stdin.readline
    n = int(input())
    pin = input()

    count = 0

    for i in range(1000):
        password = '00' + str(i)
        password = password[-3:]

        v1 = password[0]
        v2 = password[1]
        v3 = password[2]

        if v1 in pin:
            p1 = pin.index(v1)
            pin2 = pin[p1+1:]
        else:
            continue
        if v2 in pin2:
            p2 = pin2.index(v2)
            pin3 = pin2[p2+1:]
        else:
            continue
        if v3 in pin3:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


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

int main() {
    int A,B;
    cin>>A>>B;
    int ans=1;
    int sum=A;
    if(B==1){
        cout<<0<<endl;
        return 0;
    }
    while(sum<B){
        sum+=A-1;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 200005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0, M, K;
ll ret = 0;

ll fact[ARRAY];
ll inv_fact[ARRAY];
ll inv[ARRAY];

void combiInit() {
  fact[0] = fact[1] = 1;
  inv_fact[0] = inv_fact[1] = 1;
  inv[1] = 1;
  FOR(i, 2, ARRAY) {
    fact[i] = fact[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    inv_fact[i] = inv_fact[i-1] * inv[i] % MOD;
  }
}

ll combi(ll n, ll r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fact[n] * (inv_fact[r] * inv_fact[n-r] % MOD) % MOD;
}

int main(void){
  
  I(N);
  I(M);
  I(K);
  combiInit();

  ll dx = 0;
  FOR(i, 1, N) {
    dx += (i * (N - i)) % MOD;
    dx %= MOD;
  }
  dx *= (M * M) % MOD;
  dx %= MOD;

  ll dy = 0;
  FOR(j, 1, M) {
    dy += (j * (M - j)) % MOD;
    dy %= MOD;
  }
  dy *= (N * N) % MOD;
  dy %= MOD;

  ll dist = (dx + dy) % MOD;
  D(dist);

  ret = (dist * combi(N*M-2, K-2)) % MOD;

  P(ret);

}


Measured memory_bytes: 4992
char s[102];
A(){
	char a[101],b[101],t,t2;
	return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);
}
B(){
	short*q;
	char*p=s,l=0;
	if(*(q=p++)=='^>'){
		for(;*++p=='Q';l++)
			if(*++p!='=')
				return 0;
		if(l>0&&*p=='~'&&*++p=='~'&&*++p==0)
			return 1;
	}
	return 0;
}
main(){
	scanf("%*d\n");
	for(;~scanf("%[^\n]\n",s);){
		if(A())
			puts("A");
		else if(B())
			puts("B");
		else
			puts("NA");
	}
}

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

int main(){
  long n,W,inf = 100000000000000;
  cin >> n >> W;
  long w[n],v[n];
  for(int i = 0;i < n;i++){
    cin >> w[i] >> v[i];
  }
  long dp[n+1][1000*n+1];
  for(int i = 0;i <= 1000*n;i++){
    dp[0][i] = inf;
  }
  dp[0][0] = 0;
  for(int i = 0;i < n;i++){
    for(int j = 0;j <= 1000*n;j++){
      if(j < v[i]){
        dp[i+1][j] = dp[i][j];
      }
      else{
        dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]] + w[i]);
      }
    }
  }
  long kekka;
  for(int i = 0;i <= 1000*n;i++){
    if(dp[n][i] <= W){
      kekka = i;
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

    int N; cin >> N;
    string S; cin >> S;

    int alp[26];
    memset(alp, 0, sizeof(alp));

    REP(i, N)
    {
        int num = S[i] - 'a';
        alp[num]++;
    }
    LL ans = 1;

    REP(i,26)
    {
        ans *= alp[i] + 1;
        ans = ans % MOD;
    }
    cout << ans - 1 << endl;


}


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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"yes":"no")
#define YN(f) ((f)?"YES":"NO")

#define MAX 20
#define NUM 6

bool solve(int card[], int T){
	bool flag = true, flag2 = false, flag3 = false;
	bool temp;
	// cout<<"T "<<T<<" "<<endl;
	
	for(int i = 1; i <= 13; i++){
		if(card[i] != 0){
			flag = false;
			// break;
		}
		if(card[i] == 1) flag2 = true;
		if(card[i] == 0) flag3 = true;
		// cout<<card[i]<<" ";
	}
	// cout<<endl;
	// if(flag) return true;
	
	
	if(T%2){
		bool f1 = false;
		if(!flag2) return true;
		for(int i = 2; i < 13; i++){
			if(card[i] == 2 && card[i-1] == 1){
				card[i-1] = 2;
				temp  = solve(card,T+1);
				card[i-1] = 1;
				if(temp == true) return true;
			
				f1 = true;
			} 
			if(card[i] == 2 && card[i+1] == 1){
				card[i+1] = 2;
				temp  = solve(card,T+1);
				card[i+1] = 1;
				if(temp == true) return true;
				f1 = true;
			}
		}
		if(f1 == false && solve(card,T+1) == true) return true;
		return false;
	} else {
		bool f2 = false;
		if(!flag3) return false;
		for(int i = 2; i < 13; i++){
			if(card[i] == 2 && card[i-1] == 0){
				card[i-1] = 2;
				temp  = solve(card,T+1);
				card[i-1] = 0;
				if(temp == false) return false;
				card[i-1] = 0;
				f2 = true;
			} 
			if(card[i] == 2 && card[i+1] == 0){
				card[i+1] = 2;
				temp  = solve(card,T+1);
				card[i+1] = 0;
				if(temp == false) return false;
				card[i+1] = 0;
				
				f2 = true;
			}
		}
		if(f2 == false && solve(card,T+1) == false) return false;
		return true;
	}
}

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		int card[MAX] = {}, t;
		card[7] = 2;
		for(int j = 0; j < NUM; j++){
			cin>>t;
			card[t] = 1;
		}
		cout<<yn(solve(card,1))<<endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 3056
# -*- coding: utf-8 -*-
N = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(N):
    if p[i] == i+1:
        ans += 1
        tmp = p[i]
        if i+1 < N:
            p[i] = p[i+1]
            p[i+1] = tmp
        else:
            p[i] = p[i-1]
            p[i-1] = tmp

print(ans)


Measured memory_bytes: 54316