akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	string s;cin>>s;inp(x)
	int n=s.size();
	int nxt[n+1];
	nxt[n]=n;
	for(int i=n-1;i>=0;i--)
	{
		nxt[i]=nxt[i+1];
		if(s[i]!='0')
			nxt[i]=i;
	}
	// fo(i,n)
	// 	cout<<nxt[i]<<' ';
	// cout<<'\n';
	int ans=0;
	if(x==3)
	{
		fo(i,n)
		{
			for(int j=i+1;j<n;j++)
			{
				for(int k=j+1;k<n;k++)
				{
					if(i)
					{
						ans+=9*9*9;
					}
					else
					{
						ans+=(max(0,s[i]-'0'-1))*9*9;
						if(s[i]=='0')
							continue;
						if(j<=nxt[i+1])
						{
							ans+=(max(0,s[j]-'0'-1))*9;
							if(s[j]=='0')
								continue;
							if(nxt[j+1]>=k)
							{
								ans+=s[k]-'0';
							}
							else
							{
								ans+=9;
							}
						}
						else
						{
							ans+=9*9;
						}
					}
				}
			}
		}
	}
	else if(x==2)
	{
		fo(i,n)
		{
			for(int j=i+1;j<n;j++)
			{
				if(i)
				{
					ans+=9*9;
				}
				else
				{
					ans+=max(s[i]-'0'-1,0)*9;
					if(s[i]=='0')
						continue;
					if(j<=nxt[i+1])
					{
						ans+=(s[j]-'0');
					}
					else
					{
						ans+=9;
					}
				}
			}
		}
	}
	else
	{
		fo(i,n)
		{
			
			if(i)
			{
				ans+=9;
			}
			else
			{
				ans+=(s[i]-'0');
			}
		}
	}
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 256
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

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

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

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

    int L = 1, R = N;
    for (int i = 0; i < M; ++i) {
        int l, r;
        cin >> l >> r;
        L = max(L, l);
        R = min(R, r);
    }

    cout << max(0, R - L + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,y,i;
    scanf("%d\n",&n);
    int cards[4][14]={{}};
    char x;
    
    for(i=0;i<n;i++){
        scanf("%c %d\n",&x,&y);
        if(x=='S')
        cards[0][y]=1;
        else if(x=='H')
        cards[1][y]=1;
        else if(x=='C')
        cards[2][y]=1;
        else if(x=='D')
        cards[3][y]=1;
    }    
    for(i=0;i<4;i++){
        for(y=1;y<14;y++){
            if(cards[i][y]==0){
                if(i==0)printf("S ");
                else if(i==1)printf("H ");
                else if(i==2)printf("C ");
                else if(i==3)printf("D ");
                printf("%d\n",y);
            }
            
        }
    }
   return 0;
}



Measured memory_bytes: 2100
from math import gcd
from itertools import product

def main():
    K = int(input())
    T = [[gcd(a, b) for b in range(K+1)] for a in range(K + 1)]

    return sum(T[T[a][b]][c] for a, b, c in product(range(1, K + 1), repeat=3))

print(main())


Measured memory_bytes: 68524
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(void){
    int h, w;
    cin >> h >> w;
    char inputmatrix[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> inputmatrix[i][j];
        }
    }
    //finish input
    
    //output
    for(int i=0;i<(w+2);i++){
        cout << '#';
    } cout << endl;
    
    for(int j=0;j<h;j++){
        cout << '#';
        //loop: show content of matrix
        for(int k=0;k<w;k++){
            cout << inputmatrix[j][k];
        }
        //finish loop
        //show last character
        cout << '#' << endl;
    }
    //last line
    for(int i=0;i<(w+2);i++){
        cout << '#';
    } cout << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int n;
int a[110];

void quit()
{
	cout << "Impossible" << endl;
	exit(0);
}

int main()
{
//	freopen("9.in", "r", stdin);
//	freopen("9.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int Max = a[n];
	int Min = (Max + 1) / 2, Maxappear = (Max & 1) ? 2 : 1, cnt = 0;
//	cout << Max << ' ' << Min << endl;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] < Min) quit();
		if (a[i] == Min)
		{
			cnt++;
			if (cnt > Maxappear) quit();
		}
	}
	if (!cnt) quit();
	int cur = 1;
	for (int val = Min + 1; val <= Max; val++)
	{
		while (a[cur] < val) cur++;
		if (a[cur] > val) quit();
		cnt = 0;
		while (a[cur] == val) cur++, cnt++;
		if (cnt < 2) quit();
	}
	cout << "Possible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// Eratosthenes's sieve
// create list of prime numbers in O(N)
// check if the given number is prime in O(1)

struct Sieve {
    vector<bool> isPrime;
    Sieve(size_t max) : isPrime(max + 1, true) {
        isPrime[0] = false;
        isPrime[1] = false;

        for (size_t i = 2; i * i <= max; ++i)         // 0からsqrt(max)まで調べる
            if (isPrime[i])                           // iが素数ならば
                for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
                    isPrime[i * j] = false;           // 素数ではない
    }
    bool operator()(size_t n) { return isPrime[n]; }
};

int main() {
    int n;
    cin >> n;
    Sieve isPrime(55555);
    vi primes;
    for (int i = 2; i <= 55555; ++i) {
        if (isPrime(i) && i % 5 == 1) {
            primes.push_back(i);
            if (primes.size() == n)
                break;
        }
    }
    print(primes);
    return 0;
}

Measured memory_bytes: 256
N,P = map(int,raw_input().split());
A = map(int,raw_input().split());
odd = sum(map(lambda x:x%2,A));
even = N - odd;
ans = 1 << even;

if P:
    if odd == 0: ans = 0;
    else:
        ans *= (1 << odd) >> 1;
else:
    if odd != 0: ans *= (1 << odd) >> 1;

print(ans);

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

int main()
{
    long long n;
    cin >> n;
    long long a = 0, b = 0;
    for (long long i = int(sqrt(n)); i > 0; i--)
    {
        if (n % i == 0)
        {
            a = i;
            b = n / i;
            break;
        }
    }
    cout << a + b - 2 << endl;
}

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

int n, num, ans;

int main() {
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        scanf("%d", &num);
        mp[num]++;
    }
	for (auto p: mp) {
	    int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val p= readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    var c=0
    for (i in 0..p.lastIndex-1){
        if(p[i]==i+1){
            val tmp=p[i]
            p[i]=p[i+1]
            p[i+1]=tmp
            c++
        }
    }
    if(p[n-1]==n)c++
    println(c)

}

Measured memory_bytes: 51656
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n;
int a[10000001],tot,num[10000001],ans;
inline void operate(){
	int x=sqrt(n);
	LL tmp=n;
	for(int i=2;i<=x;i++){
		if(n%i==0){
			a[++tot]=i;
			while(n%i==0)n/=i,num[tot]++;
			int now=tmp/i;
			if(now==0||n%now)continue;
			a[++tot]=now;
			while(n%now==0)n/=now,num[tot]++;
		}
	}
	if(n!=1)a[++tot]=n,num[tot]=1;
}
int main(){
	cin>>n;
	operate();
	for(int i=1;i<=tot;i++){
		//cout<<a[i]<<" "<<num[i]<<endl;
		int tmp=sqrt(num[i]*2);
		if(1ll*tmp*(tmp+1)/2>num[i])tmp--;
		ans+=tmp; //cout<<tmp<<endl;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 3532
from fractions import gcd
def lcm(x,y):
  return (x*y)//gcd(x,y)
  
n,m=map(int,input().split())
s=input()
t=input()
c=0
a=lcm(n,m)//n
b=lcm(n,m)//m


for i in range(n):
  if int(i*a)%b==0:
    if s[i]==t[int(i*a/b)]:c+=1
    else:
      break
if c==(int(lcm(n,m)/lcm(a,b))):print(lcm(n,m))
else:print(-1)

Measured memory_bytes: 5988
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 998244353;
const double eps = DBL_EPSILON;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL_DEBUG
    freopen("input.txt", "r", stdin);
#endif
    string s;
    cin >> s;
    puts(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define PB emplace_back

using namespace std;

const int N = 1e6+100;

bool b[12][1010];

long long int wop(long long int x, long long int y) {
    long long int ret=1;
    for(;y>=1;y/=2) {
        if(y&1)ret*=x;
        x*=x;
    }
    return ret;
}

bool PA(string s) {
    for(int i = 0 ; i < s.size() ; i++ ) {
        if(s[i]!=s[s.size()-i-1])return 0;
    }
    return 1;
}

int main () {
    ios::sync_with_stdio(0);
    long long int x, y, mx;
    cin >> x >> y >> mx;
    for(int i = 0 ; i < x ; i++ ) {
        for(int j = 0 ; j < y ; j++ ) {
            char c;
            cin >>c ;
            b[i][j]=((c=='0')?0:1);
        }
    }
    long long int ans = 1e9, hal = wop(2,x-1);
    for(int i = 0 ; i < hal ; i++ ) {
        long long int t[20], r[20], mas;
        mas=__builtin_popcount(i);
        memset(t,0,sizeof(t));
       // cout << '\t' << i << '\n';
        for(int j = 0 ; j < x ; j++ ) {
            if(j==0)r[j]=0;
            else {
                r[j]=r[j-1];
                r[j]+=(i>>(j-1))&1;
            }
           // cout << r[j]<< '\n';
        }
        for(int j = 0 ; j < y ; j++ ) {
            bool va=0;
            for(int k = 0 ; k < x ; k++ ) {
                //cout << i << ' ' << j << ' ' << k  << ' ' << r[k] << ' ' <<t[r[k]] << ' ' <<b[k][j] << '\n';
                t[r[k]]+=b[k][j];
                if(t[r[k]]>mx) {
                    if(va==1) {
                        mas=1e9;
                        break;
                    }
            //        cout << "NO" << '\n';
                    va=1;
                    mas++;
                    for(; k>=0 ; k--) {
                        t[r[k]]-=b[k][j];
                    }
                    k=-1;
                    memset(t,0,sizeof(t));
                }
            }
        }
        ans=min(ans,mas);
    }
    cout << ans;
}


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

typedef long long ll;

#define M 1000000007

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll tozero = x / d;
	ll left = x % d;
	if (tozero > k) {
		cout << x - k * d;
		return 0;
	}
	if ((tozero - k) & 1) {
		cout << abs(left - d);
	}
	else {
		cout << left;
	}

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int a[200002], b[200002], d[200002];
int c[30];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (ll t = 0; t <= 28; t++) {
		for (int i = 0; i < n; i++) d[i] = a[i] % (1LL << (t + 1));
		sort(d, d + n);
		for (int i = 0; i < n; i++) {
			int bi = b[i] % (1LL << (t + 1));
			int lo = -1, hi = n;
			while (hi - lo > 1) {
				int mid = lo + (hi - lo) / 2;
				if (d[mid] >= 2 * (1 << t) - bi) hi = mid;
				else lo = mid;
			}
			c[t] += lo;
			lo = -1, hi = n;
			while (hi - lo > 1) {
				int mid = lo + (hi - lo) / 2;
				if (d[mid] >= (1 << t) - bi) hi = mid;
				else lo = mid;
			}
			c[t] -= lo;

			lo = -1, hi = n;
			while (hi - lo > 1) {
				int mid = lo + (hi - lo) / 2;
				if (d[mid] >= 4 * (1 << t) - bi) hi = mid;
				else lo = mid;
			}
			c[t] += lo;
			lo = -1, hi = n;
			while (hi - lo > 1) {
				int mid = lo + (hi - lo) / 2;
				if (d[mid] >= 3 * (1 << t) - bi) hi = mid;
				else lo = mid;
			}
			c[t] -= lo;
			c[t] %= 2;
		}
	}
	ll ans = 0;
	for (int i = 0; i < 30; i++) ans += c[i] * (1 << i);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int time = Integer.parseInt(tmpArray[0]);
			int teamNum = Integer.parseInt(tmpArray[1]);
			int probNum = Integer.parseInt(tmpArray[2]);
			int recNum = Integer.parseInt(tmpArray[3]);
			
			if(time == 0){
				break;
			}
			
			String[] records = new String[recNum];
			for(int i = 0; i < recNum; i++){
				records[i] = br.readLine();
			}
			
			solve(time, teamNum, probNum, records);
		}
		
	}
	
	static void solve(int time, int teamNum, int probNum, String[] records){
		Team[] teams = new Team[teamNum];
		
		for(int i = 0; i < teamNum; i++){
			teams[i] = new Team(i + 1, probNum);
		}
		
		for(int i = 0; i < records.length ; i++){
			String[] tmpArray = records[i].split(" ");
			int m = Integer.parseInt(tmpArray[0]);
			int t = Integer.parseInt(tmpArray[1]) - 1;
			int p = Integer.parseInt(tmpArray[2]);
			
			if(tmpArray[3].equals("0")){
				teams[t].AC(p, m);
			}
			else {
				teams[t].WA(p);
			}
		}
		
		//debug
//		for(int i = 0; i < teams.length ; i++){
//			System.out.println(teams[i].toString());
//		}
		Arrays.sort(teams);
		System.out.print(teams[0].id);
		for(int i = 1; i < teams.length ; i++){
			if(teams[i-1].equals(teams[i])){
				System.out.print("=");
			}
			else {
				System.out.print(",");
			}
			System.out.print(teams[i].id);
		}
		System.out.println();
		
	}

}

class Team implements Comparable<Team>{
	int id;
	boolean[] ac;
	int numOfAC;
	int time;
	int[] wa;
	
	public Team(int id, int probNum) {
		this.id = id;
		this.ac = new boolean[probNum + 1];
		this.time = 0;
		this.numOfAC = 0;
		this.wa = new int[probNum + 1];
	}
	
	public void AC(int pid, int time){
		ac[pid] = true;
		numOfAC++;
		this.time += time + 20*wa[pid];
	}
	
	public void WA(int pid){
		wa[pid]++;
	}

	@Override
	//AC??°????????§???????????????????????£??????????????§?????????
	//?????????????????????id??§??????
	public int compareTo(Team t) {
		return this.numOfAC == t.numOfAC ?
				(this.time == t.time ? t.id - this.id : this.time - t.time) :
					t.numOfAC - this.numOfAC;
	}
	
	public boolean equals(Team t) {
		return this.numOfAC == t.numOfAC && this.time == t.time;
	}
	
	public String toString(){
		return "ID "+id+"AC "+numOfAC+" time "+time;
	}
}

Measured memory_bytes: 37596
#include <stdio.h>

int BinarySearch(int,int *,int);

int main()
{
  int S[100000],T[50000],S_num,T_num,cnt = 0,key;
  scanf("%d",&S_num);
  for(int i = 0; i < S_num;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&T_num);
  for(int i = 0; i < T_num; i++){
    scanf("%d",&T[i]);
  }
  for(int i = 0;i < T_num;i++){
    key = T[i];
    if(BinarySearch(S_num,S,key) == 1) cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

int BinarySearch(int n,int *A,int key){
  int right,left,mid;
  left = 0;
  right = n;
  while(left < right){
    mid = (left + right)/2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid + 1;
    else if(A[mid] > key) right = mid;
  }
  return 0;
}



Measured memory_bytes: 2352
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll N, K;
  cin >> N >> K;

  ll tmp = N-(N/K)*K;
  
  if(abs(K-tmp)<=tmp){
    cout << abs(K-tmp) << endl;
  }else{
    cout << tmp << endl;
  }
}

Measured memory_bytes: 256
n,k= map(int, input().split())
h= list(map(int, input().split()))
dp=[2000000000]*n
dp[0]=0
for i in range(1,min(n,k+1)):
    for j in range(0,i):
        dp[i]=min(abs(h[i]-h[0])+dp[j],dp[i])
if n>k:
    for i in range(k+1,n):
        for j in range(1,k+1):
            dp[i]=min(abs(h[i]-h[i-j])+dp[i-j],dp[i])
#print(dp)
print(dp[n-1])


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



// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int r,D,x;

    cin >> r >> D >> x;

    for (int i = 1 ; i <= 10; ++i) {
      x = r * x - D;
      cout << x << endl;
    }
    
    // Failed to predict input format
    return 0;
}


Measured memory_bytes: 768
var
 n,i,max,s:longint;
 a:string;
begin
 readln(n);
 read(a);
 for i:=1 to n do 
  begin
   if a[i]='I' then inc(s);
   if a[i]='D' then dec(s);
   if s>max then max:=s;
  end;
 writeln(max);
end.

Measured memory_bytes: 128
H,W=map(int,input().split())
s="#"*W+"".join("#"+input()for _ in range(H))
f=-~W*-~H
d=[[0]*f for _ in range(f)]
for i in range(W,f-1):
 d[i][i-1]=s[i]==s[i-1]=="."
 d[i][i-W-1]=s[i]==s[i-W-1]=="."
from scipy.sparse.csgraph import csgraph_from_dense as C,floyd_warshall as F
import numpy as p
Q=F(C(d),directed=False)
print(int(max(Q[Q!=p.inf])))

Measured memory_bytes: 21868
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int h,w;cin>>h>>w;
	string s;
	rep(i,h)rep(j,w){
	    cin>>s;
	    if(s=="snuke")cout<<(char)('A'+j)<<i+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n;
int a[21];
int cnt[(1<<21)];
int dp[(1<<21)];
void builtin_popcount(){
	for(int i=1;i<(1<<21);++i){
		cnt[i]=cnt[i&(i-1)]+1;
	}
}
int main(){
	builtin_popcount();
	cin>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			int x;
			cin>>x;
			a[i]|=(x<<j);
		}
	}
	int N=(1<<n)-1;
	dp[0]=1;
	for(int i=0;i<n;++i){
		for(int j=0;j<(1<<n);++j){
			if(cnt[j]!=i){
				continue;
			}
			int k=(j^N)&a[i];
			for(int l=k;l;l&=(l-1)){
				int now=l&(-l);
				dp[j|now]+=dp[j];
				if(dp[j|now]>mod){
					dp[j|now]-=mod;
				}
			}
		}
	}
	cout<<dp[N]<<'\n';
	return 0;
}

Measured memory_bytes: 16640
#Forestの
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -10 ** 30
for i in range(1, 2 ** 10):
    cnt = [0] * n
    calc = 0
    #print(cnt)
    for j in range(10):
        if i >> j & 1:
            for k in range(n):
                if f[k][j] == 1:
                    cnt[k] += 1
    
                
    for k in range(n):
        calc += p[k][cnt[k]] 
    
    ans = max(ans, calc)

print(ans)

Measured memory_bytes: 3064
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif



int main() {
    ll N, K;
    cin >> N >> K;
    V<ll> A(N);
    for(auto &&ele : A) cin >> ele;
    ll cur_sum = 0;
    ll ans = 0;
    map<ll, ll> cnt;
    cnt[0]++;
    V<ll> history(N + 1);
    for(ll i = 0; i < N; i++) {
        cur_sum += A[i] % K;
        cur_sum %= K;
        ll len = i + 1;
        if(0 <= i - K + 1) cnt[history[i - K + 1]]--;
        ll over = (cur_sum - len % K + K) % K;
        ans += cnt[over];
        ll key = over;
        cnt[key]++;
        history[i + 1] = key;
    }

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


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

#define DECIMAL 10

int h, w, ch, cw, dh, dw;
vector<vector<char>> mazeBoard;

vector< vector<int> > nWarp;

int mazeBFS(int startH, int startW){
    priority_queue< tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>> > searchCoor;
    nWarp.assign( h+4, vector<int>(w+4, -1) );

    searchCoor.push( make_tuple(0, startH, startW) );
    nWarp.at(startH).at(startW) = 0;
    auto now = searchCoor.top();
    while ( searchCoor.size() > 0 && ( get<1>(now) != dh+1 || get<2>(now) != dw+1 ) ) {                            // 条件式がTrueになる条件でループ回るんやで
        int tmp = searchCoor.size();
        now = searchCoor.top(); searchCoor.pop();
        for (int i = -1; i < 3; i++){                           // sin, cos内部の値が大きいと誤差で正確な値がでない...
            int nextH = get<1>(now) + sin(0.5*i*M_PI);
            int nextW = get<2>(now) + cos(0.5*i*M_PI);
            if ( mazeBoard.at(nextH).at(nextW) == '.' && nWarp.at(nextH).at(nextW) != nWarp.at(get<1>(now)).at(get<2>(now)) ){
                nWarp.at(nextH).at(nextW) = nWarp.at( get<1>(now) ).at( get<2>(now) );
                searchCoor.push( make_tuple(get<0>(now), nextH, nextW) );
            }
        }

        for (int i = -2; i <= 2; i++){
            for (int j = -2; j <= 2; j++){
                int aroundH = get<1>(now) + i;
                int aroundW = get<2>(now) + j;
                char around = mazeBoard.at(aroundH).at(aroundW);
                int nWarpAround = nWarp.at(aroundH).at(aroundW);
                if( around == '.' && nWarpAround == -1){
                    nWarp.at(aroundH).at(aroundW) = nWarp.at(get<1>(now)).at(get<2>(now)) + 1;
                    searchCoor.push( make_tuple(nWarp.at(aroundH).at(aroundW), aroundH, aroundW) );
                }
            }
        }
    }
    return 0;
}

int main(void){
    cin >> h >> w;
    cin >> ch >> cw;
    cin >> dh >> dw;
    mazeBoard.assign( h+4, vector<char>( w+4, '#' ) );                  // ここで再定義しないと、1*1 の行列になってしまう
    for (int i = 2; i <= h+1; i++){
        for (int j = 2; j <= w+1; j++){
            char c;
            cin >> c;
            mazeBoard.at(i).at(j) = c;
        }
    }
    
    mazeBFS(ch+1, cw+1);

    cout << nWarp.at(dh+1).at(dw+1) << endl;

    return 0;
}


Measured memory_bytes: 8932
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int n, dp[3][100010], a[100010], b[100010], c[100010], ans=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
    dp[0][i+1]=0;
    dp[1][i+1]=0;
    dp[2][i+1]=0;
  }
  dp[0][0]=0;
  dp[1][0]=0;
  dp[2][0]=0;

  for(int i=1;i<=n;i++){
    dp[0][i]=max(dp[1][i-1]+a[i-1],dp[2][i-1]+a[i-1]);
    dp[1][i]=max(dp[0][i-1]+b[i-1],dp[2][i-1]+b[i-1]);
    dp[2][i]=max(dp[0][i-1]+c[i-1],dp[1][i-1]+c[i-1]);
  }
  for(int i=0;i<3;i++)ans=max(ans,dp[i][n]);
  cout << ans << endl;
  return 0;
}


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

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

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}

const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 2e5 + 9;
const ll mod = 1000000007LL;
ll ksm(ll b, ll k)
{
    ll ans = 1;
    while (k)
    {
        if (k & 1)
            ans = ans * b % mod;
        b = b * b % mod;
        k /= 2;
    }
    return ans % mod;
}

signed main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //std::cout.tie(0);
    ll n;
    cin >> n;
    if (n <= 1)
        cout << 0 << endl;
    else
    {
        ll ans = ksm(10, n) - ksm(9, n) + ksm(8, n) - ksm(9, n);
        ans %= mod;
        ans = (ans + mod) % mod;
        cout << ans << endl;
    }
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

Measured memory_bytes: 3600
import java.io.IOException;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner in = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		
		System.out.println(Math.max(0,A-2*B));
	}
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    vector<string>vs(n); REP(i, n)cin >> vs[i];

    ll ans = 0;
    ll nb_a = 0;
    ll b_na = 0;
    ll b_a = 0;
    REPC(s, vs) {
        REP(i, s.length() - 1) {
            if (s[i] == 'A' && s[i + 1] == 'B')++ans;
        }
        if (s.front() != 'B' && s.back() == 'A')++nb_a;
        else if (s.front() == 'B' && s.back() != 'A')++b_na;
        else if (s.front() == 'B' && s.back() == 'A')++b_a;
    }
    if (b_a > 0) {
        ans += b_a - 1;
        if (nb_a > 0) { ans += 1; --nb_a; }
        if (b_na > 0) { ans += 1; --b_na; }
    }
    ans += min(nb_a, b_na);
    cout << ans << endl;
}

Measured memory_bytes: 768
import string

count = {x: 0 for x in string.ascii_lowercase}
lines = ""

while True:
    try:
        lines += input().lower()
    except EOFError:
        break

for c in lines:
    if 'a' <= c <= 'z':
            count[c] += 1

for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))

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

int main() {
    int N,K,Q;
    cin >> N >> K >> Q;
    int A[Q] = {};
    for (int i = 0;i < Q;i++){
        cin >> A[i];
    }
    int B[N] = {};
    for (int i = 0;i < N;i++){
        B[i] = K - Q;
    }
    for (int i = 0;i < Q;i++){
        B[A[i] - 1] += 1;
    }
    for (int i = 0;i < N;i++){
        if(B[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

#define ll long long
#define repeat(i, x) for(register ll i = 0; i < x; i++)

using namespace std;

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

  for (int i = 0; i <= S.size() - 3; i++) {
    if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 3568
a_yen , b_yen, c_yen , a_count,b_count = map(int,input().split())

abmax = max(a_count, b_count)
c_count = 0
kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count

while c_count <= 2*abmax:
    if kouhopiza > a_yen * a_count + b_yen * b_count + c_yen * c_count and a_count > -1 and b_count > -1:
        kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count
    elif a_count > -1 and b_count < 0:
        if kouhopiza > a_yen * a_count + c_yen * c_count:
            kouhopiza = a_yen * a_count + c_yen * c_count
    elif a_count < 0 and b_count > -1:
        if kouhopiza > b_yen * b_count + c_yen * c_count:
            kouhopiza = b_yen * b_count + c_yen * c_count
        
    c_count = c_count + 2
    a_count = a_count - 1
    b_count = b_count - 1
print(kouhopiza)




Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int k = stdIn.nextInt();
        int count = 0;
        int min;
        int[] num = new int[100];

        if(a>b) min = b;
        else min = a;
        for(int i=1;i<min+1;i++){
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        }
        System.out.println(num[count-k]);
    }
}

Measured memory_bytes: 23252
from collections import deque
H,W,K=map(int,input().split())
A=[list(input())for _ in range(H)]
for i,a in enumerate(A):
	if"S"in a:y,x=(i,a.index("S"))
d=1e9
Q=deque([(0,y,x)])
while Q:
	c,i,j=Q.popleft()
	d=min(d,i,j,H-i-1,W-j-1)
	if c>=K:continue
	for ni,nj in((i+1,j),(i,j+1),(i-1,j),(i,j-1)):
		if 0<=ni<H and 0<=nj<W and A[ni][nj]==".":
			A[ni][nj]=""
			Q+=[(c+1,ni,nj)]
print(1-(-d//K))

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

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

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

#define pb push_back
using namespace std;

using ll = long long;

constexpr int N = 200111;

int n, t, m, x, sum;

int main(){
    cin >> n >> m;
    for(int i = 0 ; i < m ; ++i){
        cin >> x;
        sum += x;
    }

    cout << max(n - sum, -1) << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int a, b, c, d, n, p;
    
    while (scanf("%d", &n) != EOF) {
        p = 0;
	    for (a = 0; a <= 9; a++) {
		    for (b = 0; b <= 9; b++) {
                for (c = 0; c <= 9; c++) {
                    for (d = 0; d <= 9; d++) {
                        if (a + b + c + d == n)
                            p++;
                    }
                }
            }
        }
    printf("%d\n", p);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define vsort(v) sort(v.begin(),v.end)
using namespace std;
signed main() {
	int n, memo[100], ans=0, cnt=0;
	cin >> n;
	rep(i, n) {
		int in;
		cin >> in;
		ans += in;
		if (in % 2 == 1) {
			memo[cnt] = in;
			cnt++;
		}
	}
	sort(memo, memo + cnt);
	if (ans % 2 == 1)cout << (ans - memo[0])/2 << endl;
	else cout << ans/2 << endl;
}


Measured memory_bytes: 3132
# -*- coding: utf-8 -*-

import sys

i_str = input().split(' ')
k = int(i_str[0])
a = int(i_str[1])
b = int(i_str[2])

#print(k, a, b)

if b <= a + 2:
    print(1 + k)
else:
    bis = 1
    if bis < a:
        k -= (a - 1)
        bis += (a - 1)
    
    bis = bis + (- a + b) * (k // 2)
    bis += k % 2
    print(bis)

Measured memory_bytes: 3060
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

ll a[100], dp[55][5010];
signed main(void)
{
  int n, p;
  cin >> n >> p;
  REP(i, n) cin >> a[i];

  dp[0][0] = 1;
  FOR(i, 1, n+1) {
  //  cout << a[i-1] << endl;
    for(int j=5000; j>=a[i-1]; --j) {
      if(dp[i-1][j-a[i-1]]) {
        dp[i][j] = (dp[i][j] + dp[i-1][j-a[i-1]]);
        dp[i][j-a[i-1]] = (dp[i][j-a[i-1]] + dp[i-1][j-a[i-1]]);
        //cout << i << " " << j << endl;
      }
    }
  }

  ll ret = 0;
  REP(i, 5001) {
    if(i%2 == p) ret = (ret + dp[n][i]);
  }
  cout << ret << endl;

  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	int64 N;
	vector<int64> a(5);
	cin >> N;
	REP(i, 5) cin >> a[i];
	int64 take = (N+a[0]-1)/a[0];
	int64 mini = a[0];
	FOR(i, 1, 5) {
		if (a[i] >= mini) {
			continue;
		} else {
			take += (N-take*a[i]+a[i]-1)/a[i];
		}
		mini = min(mini, a[i]);
	}
	cout << take+4 << endl;
}


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

using namespace std;

typedef long long ll;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while(true){
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			return 0;
		}

		a -= d;
		if(a <= 0){
			cout << "No" << endl;
			return 0;
		}
	}
}


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


int main(){
  int64_t N;
  cin >> N;
  if (N % 2 == 1){
    cout << 0 << endl;
    return 0;
  }

  int64_t ans = 0;
  int64_t div = 10;
  while(N >= div){
    ans += N / div;
    div *= 5;
  }

  cout << ans << endl;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    rep(i, 3) {
      cin >> s;
      t += s[0] - 'a' + 'A';
    }
    cout << t << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
bool num[1<<15]={};
int main(){
	for(int i=2;i<(1<<15);i++){
		for(int j=2;j*j<=i;j++){
			if(i%j==0){
				num[i]=true;
				break;
			}
		}
	}
	int n;
	while(scanf("%d",&n) && n){
		int ans=0;
		for(int i=2;i*2<=n;i++){
			if(!num[i] && !num[n-i]){
				ans++;
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1056
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll N;
	cin >> N;
	vector<ll> A(N);
	ll M = 0, Mnum = 0;
	for(int i = 0; i < N; i ++){
		cin >> A[i];
		if(A[i] == M){
			Mnum ++;
		}
		else if(A[i] > M){
			M = A[i];
			Mnum = 1;
		}
	}
	for(int i = 0; i < N; i ++){
		if(A[i] == M && Mnum == 1){
			ll K = 0;
			for(int j = 0; j < N; j ++){
				if(K < A[j] && A[j] != M){
					K = A[j];
				}
			}
			cout << K << endl;
		}
		else cout << M << endl;
	}

	return 0;
}


Measured memory_bytes: 3200
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = INF;
	int tmp;
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> a(m);
	REP(i, m) cin >> a[i];
	int l = 0, r = 0;
	REP(i, m) if(a[i] < x) l ++; else r++;
	cout << min(l, r) << endl;
}

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

int main() {

  int S;
  cin >> S;
  
  int A = S / 1000;
  S -= (S / 1000) * 1000;
  int B = S / 100;
  S -= (S / 100) * 100;
  int C = S / 10;
  S -= (S / 10) * 10;
  int D = S;

  bool res = false;

  if (((A + B + C + D) == 7) && !(res)) { res = true; cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl; }
  if (((A - B + C + D) == 7) && !(res)) { res = true; cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl; }
  if (((A + B - C + D) == 7) && !(res)) { res = true; cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl; }
  if (((A + B + C - D) == 7) && !(res)) { res = true; cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl; }
  if (((A - B - C + D) == 7) && !(res)) { res = true; cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl; }
  if (((A - B + C - D) == 7) && !(res)) { res = true; cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl; }
  if (((A + B - C - D) == 7) && !(res)) { res = true; cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl; }
  if (((A - B - C - D) == 7) && !(res)) { res = true; cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl; }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    cout << n / 3 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

#define ch() getchar()
#define pc(x) putchar(x)
template<typename T>inline void read(T&x){
	int f;char c;
	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;
	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;
}

int main() {
    int x[MAX_N] = {}, y[MAX_N] = {};
    int n, q;
    // scanf("%d%d", &n,&q);
    read(n); read(q);
    ll ans = (ll)(n-2)*(n-2);
    srep(i,2,n){
        x[i] = n;
        y[i] = n;
    }
    int xx = n;
    int yy = n;
    while(q--){
        int t, z;
        // scanf("%d%d", &t,&z);
        read(t), read(z);
        if(t == 1){
            if(z < xx){
                ans -= yy - 2;
                srep(i,z+1,xx) x[i] = yy;
                xx = z;
            }else{
                ans -= x[z] - 2;
            }
        }else{
            if(z < yy){
                ans -= xx - 2;
                srep(i,z+1,yy) y[i] = xx;
                yy = z;
            }else{
                ans -= y[z] - 2;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}




Measured memory_bytes: 5316
import math

def main():
    A,B,H,M = [int(x) for x in input().split()]
    degH = (0.5*H*60 + 0.5*M)
    degM = 6*M
    theta = abs(degH-degM)
    print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta))))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9512