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




namespace contest
{

    class contest
    {


        static void Main(string[] args)
        {


            
            int n = int.Parse(Console.ReadLine());

            

            int mx = 0;
            for(int i =1; i<= n; i++)
            {
                if((i*(i+1))/2 >=n)
                {
                    mx = i;
                    break;
                }
            }


            var list = new List<int>();
            
            for (int i = mx; i >=1; i--)
            {
                if(i<=n)
                {
                    list.Add(i);
                    n -= i;
                }
            }

            list.Sort();
            foreach(int num in list)
            {
                Console.WriteLine(num);
            }
           


        }

        

    }


    

    
}









































Measured memory_bytes: 2904
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
sum1=0
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(m):
        sum1+=a[j]*b[j]
    if sum1+c>0:
        ans+=1
    a=[]
    sum1=0
print(ans)

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

int main(void){
  int s[31];
  int w,n;

  for(int i = 0;i<31;i++) s[i] = i;

  cin >> w;
  cin >> n;

  for(int i=0;i<n;i++){
    int a, b, buff;
    scanf("%d,%d",&a,&b);
    // swap(s[a-1], s[b-1]);
    buff = s[a];
    s[a] = s[b];
    s[b] = buff;
  }

  for(int i = 1;i<=w;i++) cout << s[i] << endl;

  return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<cstdlib>
#include<cmath>

using namespace std;

int dfs(long long n, int n_max)
{
    int ret = 0;

    if (n > n_max) {
        return 0;
    }

    if (to_string(n).find('3') != string::npos
            && to_string(n).find('5') != string::npos
            && to_string(n).find('7') != string::npos
       ) {
        ret = 1;
    }

    ret += dfs(n * 10 + 3, n_max);
    ret += dfs(n * 10 + 5, n_max);
    ret += dfs(n * 10 + 7, n_max);

    return ret;
}


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

    cout << dfs(0, n) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main()
{
    int n;
    char s[50][101];
    int t[50];
    char x[101];

    int i,j,sum = 0;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%s %d",s[i],&t[i]);
        sum += t[i];
    }
    scanf("%s",x);

    for (i = 0; i < n; i++)
    {
        sum -= t[i];
        if(strcmp(s[i],x) == 0)
        {
            break;
        }
    }
    printf("%d",sum);
}

Measured memory_bytes: 128
import           Control.Monad
import           Data.List

main :: IO ()
main = do
    [n, c, k] <- map read .words <$> getLine
    ts <- sort <$> replicateM n readLn
    print $ solve c k ts

solve :: Int -> Int -> [Int] -> Int
solve c k [] = 0
solve c k ts@(t:ts0) = 1 + solve c k (us2 ++ ts2)
    where
        (ts1, ts2) = span (<= t + k) ts
        (us1, us2) = splitAt c ts1

Measured memory_bytes: 61436
import sys
from typing import Iterator


def solve(x: int) -> Iterator[int]:
    global cum_prev, cum
    end = 0
    it = iter(cum).__next__
    nxt = it() - x
    for start, c in enumerate(cum_prev):
        while (nxt <= c):
            nxt = it() - x
            end += 1
        yield end - start


if __name__ == "__main__":
    N, Q = map(lambda x: int(x), input().split())
    a = list(map(lambda x: int(x), input().split()))
    x = list(map(lambda x: int(x), input().split()))

    cum_prev = [0]
    cum = []
    v = 0
    for elem in a:
        v += elem
        cum_prev.append(v)
        cum.append(v)
    cum_prev.pop()
    cum.append(sys.maxsize)

    print("\n".join(map((lambda t: str(sum(t))), map(solve, x))))



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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int n;
  cin >> n;

  vector<ll> v;
  repi(i, 1, 10) { v.push_back(i); }

  while (1) {
    if (n <= v.size()) {
      cout << v[n - 1] << endl;
      return 0;
    }

    n -= v.size();

    vector<ll> vo;
    swap(vo, v);

    for (ll x : vo) {
      repi(i, -1, 2) {
        int d = x % 10 + i;
        if (d < 0 || d > 9) continue;
        ll xx = x * 10 + d;
        v.push_back(xx);
      }
    }
  }

  return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  ll d;
  for(ll i=sqrt(n+1);i>0;i--){
    if(n%i==0){
      d = n/i;
      break;
    }
  }
  ll ans = log(d)/log(10) + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<n*800-floor(n/15.0)*200;
}


Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize, b: usize, c: usize,
    }
    println!("{}", if a + b >= c { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N = 500;
char ch[200];
struct Edge
{
	int from,to,cap,flow;
	Edge(int u,int v,int c,int f):from(u),to(v),cap(c),flow(f){}
};
struct Dinic
{
	int n,m,s,t;
	vector<Edge>edges;
	vector<int>G[N];
	bool vis[N];
	int d[N];
	int cur[N];
	void addedge(int from,int to,int cap)
	{
		edges.push_back(Edge(from,to,cap,0));
		edges.push_back(Edge(to,from,0,0));
		int m=edges.size();
		G[from].push_back(m-2);
		G[to].push_back(m-1);
	}
	bool bfs()
	{
		memset(vis,0,sizeof(vis));
		queue<int>Q;
		Q.push(s);
		d[s]=0;
		vis[s]=1;
		while(!Q.empty())
		{
			int x=Q.front();
			Q.pop();
			for(int i=0;i<G[x].size();i++)
			{
				Edge&e=edges[G[x][i]];
				if(!vis[e.to]&&e.cap>e.flow)
				{
					vis[e.to]=1;
					d[e.to]=d[x]+1;
					Q.push(e.to);
				}
			}
		}
		return vis[t];
	}
	int dfs(int x,int a)
	{
		if(x==t||a==0)return a;
		int flow=0,f;
		for(int&i=cur[x];i<G[x].size();i++)
		{
			Edge&e=edges[G[x][i]];
			if(d[x]+1==d[e.to]&&(f=dfs(e.to,min(a,e.cap-e.flow)))>0)
			{
				e.flow+=f;
				edges[G[x][i]^1].flow-=f;
				flow+=f;
				a-=f;
				if(!a)break;
			}
		}
		return flow;
	}
	int Maxflow(int s,int t)
	{
		this->s=s,this->t=t;
		int flow=0;
		while(bfs())
		{
			memset(cur,0,sizeof(cur));
			flow+=dfs(s,0x3f3f3f3f);
		}
		return flow;
	}
}; 
int main()
{
	Dinic dinic;
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",ch);
		for(int j=0;j<m;j++)
		{
			if(ch[j]!='.')
			{
				dinic.addedge(i,j+1+n,1);
				dinic.addedge(j+1+n,i,1);
				if(ch[j]=='S') dinic.addedge(0,i,0x3f3f3f3f),dinic.addedge(0,j+1+n,0x3f3f3f3f);
				else if(ch[j]=='T') dinic.addedge(i,n+m+1,0x3f3f3f3f),dinic.addedge(j+1+n,n+m+1,0x3f3f3f3f);
			}
		}
	}
	int ans = dinic.Maxflow(0,n+m+1);
	if(ans>=0x3f3f3f3f) printf("%d\n",-1);
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1528
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main()
{
    int x;
    cin >> x;
    int ans = 0;
    for(int i = x;i <= 100100;i++){
        for(int j = 2; j <= i; j++){
            if(i % j == 0 && j != i) break;
            if(i == j) ans = j;
        }

        if(ans != 0) break;
    }

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

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;

int n;
ll a[maxn];


ll dp[70][2][2]; // build first i bits of answer, carry0, carry1

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

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

    
    ll t=0;
    for (int i=2; i<n; i++) {
	t ^= a[i];
    }

    ll a0=a[0];
    ll a1=a[1];

    memset(dp,-1,sizeof(dp));

    dp[0][0][0] = 0;
    
    for (int i=0; i<60; i++) {
	ll d0=a0>>i&1;
	ll d1=a1>>i&1;
	ll ti=t>>i&1;

	for (int s0=0; s0<=1; s0++) {
	    for (int s1=0; s1<=1; s1++) {
		if (dp[i][s0][s1]==-1) continue;
		if ((d0^s0^d1^s1) != ti) continue;
		for (ll xi=0; xi<=1; xi++) {
		    ll nd0 = d0;
		    ll nd1 = d1;
		    ll c0 = 0, c1 = 0; // i+1 carry values

		    //subtract
		    if (s0) {
			if (d0==0) {
			    c0 = 1;
			}
			nd0 ^= 1;
		    }

		    //add
		    if (s1) {
			if (d1==1) {
			    c1 = 1;
			}
			nd1 ^= 1;
		    }

		    if (xi) {
			//subtract
			if (nd0==0) {
			    c0 = 1;
			}
			nd0 ^= 1;

			//add
			if (nd1==1) {
			    c1 = 1;
			}
			nd1 ^= 1;
		    }

		    ll cur = dp[i][s0][s1] | (xi<<i);
		    //transition to i+1
		    if (dp[i+1][c0][c1] == -1 || cur < dp[i+1][c0][c1]) {
			dp[i+1][c0][c1] = cur;
		    }
		}
	    }
	}
	
    }



    ll res = dp[60][0][0];
    if (res>-1 && res<a0) {
	out(res);
    }
    out(-1);    
    
    return 0;
}


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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime 1000000007

using namespace std;

#define INF 1000000000

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	ld a, b;
	cin >> a >> b;
	cout << fixed << setprecision(10) << a/b;	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var S string

func main() {
	sc.Split(bufio.ScanWords)

	S = nextStr()
	if string(S[0]) != "A" {
		fmt.Println("WA")
		return
	}
	indC := strings.Index(S, "C")
	if indC == -1 || indC < 2 || indC > len(S)-2 || indC != strings.LastIndex(S, "C") {
		fmt.Println("WA")
		return
	}
	//fmt.Println(indC, string(S[1:indC]+S[indC+1:]))
	ls := string(S[1:indC] + S[indC+1:])
	if ls != strings.ToLower(ls) {
		fmt.Println("WA")
		return
	}

	fmt.Println("AC")
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static System.Console;

namespace C_D2019
{
    class MainClass
    {

        static int[] s;


        public static void Main(string[] args)
        {

            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int ans = 0;
            int lst1 = 0;
            int lst2 = 0;
            int lst3 = 0;

            for(int i=0;i<s[0];i++){
                string str = ReadLine();
                char sfst = str[0];
                char slst = str[str.Length-1];
                if(sfst!='B'&&slst!='A'){
                }else{
                    if(sfst=='B'&&slst=='A') lst2++;
                    else if(sfst=='B')lst3++;
                    else if(slst=='A')lst1++;
                }
                int index = str.IndexOf ("AB", 0);
                 while (index != -1) {
                    ans++;
                    index = str.IndexOf ("AB", index + 2);
                }
            }

            if(lst2>=2){
                ans+=(lst2-1);
                if(lst1>0){
                    ans++;
                    lst1--;
                }
                if(lst3>0){
                    ans++;
                    lst3--;
                }
                ans+=Min(lst1,lst3);
            }else if(lst2==1){
                if(lst1>0){
                    ans++;
                    lst1--;
                }
                if(lst3>0){
                    ans++;
                    lst3--;
                }
                ans+=Min(lst1,lst3);
            }else{
                ans+=Min(lst1,lst3);
            }



            WriteLine(ans);


        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = W*H/2;
    cout << ans << ' ';
    if(W == 2*x && H == 2*y){
        cout << 1 <<endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cstdio>
using namespace std;
int N, M, mx;
string S[105], T;
map<string, int> mp;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int i;
  cin >> N;
  for(i=0; i<N; i++) cin >> S[i], mp[S[i]]++;
  cin >> M;
  while(M--) cin >> T, mp[T]--;
  for(i=0; i<N; i++) mx = max(mx, mp[S[i]]);
  cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P =pair<int,int>;
int main(){
	//int A,B,C,D;
	//cin>>A>>B>>C>>D;
	string S;
	cin>>S;
	int A=int(S.at(0))-48;
	int B=int(S.at(1))-48;
	int C=int(S.at(2))-48;
	int D=int(S.at(3))-48;
	//cout<<A<<B<<C<<D;

	int sum=A;
	for(int i=0;i<=1;i++){
		for(int j=0;j<=1;j++){
			for(int k=0;k<=1;k++){
				if(i==0){
					sum+=B;
				}else{
					sum-=B;
				}
				if(j==0){
					sum+=C;
				}else{
					sum-=C;
				}
				if(k==0){
					sum+=D;
				}else{
					sum-=D;
				}	
				if(sum==7){
					cout<<A;
					if(i==0){
						cout<<'+';
					}else{
						cout<<'-';
					}
					cout<<B;
					if(j==0){
						cout<<'+';
					}else{
						cout<<'-';
					}
					cout<<C;
					if(k==0){
						cout<<'+';
					}else{
						cout<<'-';
					}
					cout<<D<<"=7";
					return 0;
				}
				sum=A;
			}
		}	
	}
return 0;}

/*compile
g++ code.cpp
./a.out
run*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void A(){
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
void B(){
    ll n,d;
    cin>>n>>d;
    int res=0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d) res++;
    }
    cout<<res<<endl;
}
void C(){

}
void D(){

}
void E(){

}
void F(){

}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    B();
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    vector<int> b(n);
    for (auto &bi: b) cin >> bi;
    auto check = [&](long long s) {
        for (int i = 0; i < n; i++) {
            vector<int> dp(50 + 1);
            dp[a[i]] = true;
            for (int k = 50; k >= 1; k--) if (s >> k & 1) {
                for (int x = 1; x <= 50; x++) dp[x % k] |= dp[x];
            }
            if (!dp[b[i]]) return false;
        }
        return true;
    };
    long long ans = (1LL << 51) - 1 - (1LL << 0);
    if (!check(ans)) return !(cout << -1 << endl);
    for (int k = 50; k >= 1; k--) {
        ans ^= 1LL << k;
        if (!check(ans)) ans ^= 1LL << k;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  ll k, s; cin >> k >> s;
  ll way = 0;
  for(int i = 0; i <= k; i++) {
    for(int j = 0; j <= k; j++) {
      if(i + j > s) continue;
      if(s - (i + j) > k) continue;
      way++;
    }
  }
  cout << way << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  int n;cin>>n;
  int ans;
  ans=(n-2)*180;
  cout<<ans<<endl;

}


Measured memory_bytes: 764
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    for i in range(1,3501):
        for j in range(i,3501):
            p = i*j
            s = 4*p-n*(i+j)
            if s <= 0:
                continue
            m = n*p
            if m%s:
                continue
            k = m//s
            q = j*k
            r = k*i
            if (p+q+r)*n == 4*i*j*k:
                print(i,j,k)
                return
    return


#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39408
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i].first >> d[i].second;
  }
  sort(all(d));
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (d[i].second >= m) {
      ans += d[i].first * m;
      break;
    }
    ans += d[i].first * d[i].second;
    m -= d[i].second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4784
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for (int i = 0; i < 10000; i++) {
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();
			if (op.equals("?")) {
				break;
			} else if (op.equals("+")) {
				System.out.println(a + b);
			} else if (op.equals("-")) {
				System.out.println(a - b);
			} else if (op.equals("*")) {
				System.out.println(a * b);
			} else if (op.equals("/")) {
				System.out.println(a / b);
			}
		}
	}

}

Measured memory_bytes: 26248
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin); i < (end); i++)
#define _irep3(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);

  ll N;
  cin >> N;
  vector<vector<ll>> abc(3, vector<ll>(N));
  rep(i, N) cin >> abc[0][i] >> abc[1][i] >> abc[2][i];

  vector<vector<ll>> dp(3, vector<ll>(N, 0));

  rep(j, 3) {
    dp[j][0] = abc[j][0];
  }
  rep(i, 1, N) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k) continue;
        dp[j][i] = max(dp[k][i - 1] + abc[j][i], dp[j][i]);
      }
    }
  }
  out(max(dp[0][N - 1], max(dp[1][N - 1], dp[2][N - 1])));
}


Measured memory_bytes: 5752
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = LONG_LONG_MAX;

ll extgcd(ll a, ll b, ll &x, ll &y)
{ //extended Euclidean algorithm, used for modular multiplicative inverse
    ll d = a;
    if (b != 0)
    {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d; //return gcd(a,b)
}

ll mod_inv(ll a, ll m = MOD)
{ //return inv(a) mod m, ax+my=gcd(a,m)=1, m is prime int, ax-1=mq equiv. ax-mq=1
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m; //From (possibly) negative x to positive x
}

vector<ll> fact, invfact;
void calc_fact(int n, ll m = MOD)
{ //Calculate factorial up to n
    fact.resize(n + 1);
    invfact.resize(n + 1);
    fact[0] = invfact[0] = 1;
    REP(i, n)
    {
        fact[i + 1] = fact[i] * (i + 1) % m;
        invfact[i + 1] = invfact[i] * mod_inv(i + 1) % m;
    }
}
ll perm(int n, int k, ll m = MOD)
{
    if (n < 0 || k < 0 || k > n)
        return 0;
    return fact[n] * invfact[n - k] % m;
}
ll comb(int n, int k, ll m = MOD)
{
    if (n < 0 || k < 0 || k > n)
        return 0;
    return (fact[n] * invfact[n - k] % m) * invfact[k] % m;
}

int main()
{
    ciosup;
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i, n) { cin >> s[i]; }
    map<string, int> ma;
    REP(i,n){
        sort(s[i].begin(), s[i].end());
        ++ma[s[i]];
    }
    ll ans = 0;
    //calc_fact(n);
    for (auto ite = ma.begin(); ite != ma.end(); ++ite)
    {
        //cout << ite->SE << endl;
        ll kazu = ite->SE;
        if (kazu > 1)
            ans += kazu * (kazu - 1) / 2;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

const int N = 1010;
int h, w;
char a[N][N];
ll dp[N][N];
const ll MOD = 1e9 + 7;

ll solve(int x, int y) {
    if (x == 1 && y == 1) return 1;
    if (a[x][y] != '.') return dp[x][y] = 0;
    if (dp[x][y] != -1) return dp[x][y];
    dp[x][y] = 0;
    if (x - 1 > 0 && a[x - 1][y] == '.') dp[x][y] += solve(x - 1, y);
    dp[x][y] = dp[x][y] % MOD;
    if (y - 1 > 0 && a[x][y - 1] == '.') dp[x][y] += solve(x, y - 1);
    dp[x][y] = dp[x][y] % MOD;
    return dp[x][y];
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> h >> w;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    ll ans = solve(h, w);
    cout << ans;

	return 0;
}


Measured memory_bytes: 9344
#include <iostream>
#include<string>
#define Karem file();
using namespace std;
void file(){
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    #else
//    #endif
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cout.tie(NULL);
}
int main(){
    Karem
    string day ;
    cin >> day;
string arr[]={"s","SAT","FRI","THU","WED","TUE","MON","SUN"};
for (int i = 0 ; i < 8 ; ++ i){
    if(arr[i]==day)return cout <<i , 0;
}
}


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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> h(n);
    for(int i=0; i<n; i++){
        cin >> x.at(i);
        cin >> y.at(i);
        cin >> h.at(i);
    }
    int real_x=0,real_y=0,real_h=0;
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            int check=0;
            bool ok=true;
            for(int k=0; k<n; k++){
                if(h.at(k)>0){
                    check = h.at(k) + abs(i-x.at(k)) + abs(j-y.at(k));
                }
            }
            //cout << check << endl;
            for(int k=0; k<n; k++){
                int calc;
                calc = max(0, check-abs(i-x.at(k))-abs(j-y.at(k)));
                if(calc != h.at(k)){
                    ok =false;
                    break;
                }
            }
            if(ok){
                real_x = i;
                real_y = j;
                real_h = check;
            }
        }
    }
    cout << real_x << " " << real_y << " " << real_h << endl;
}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	int n,k;
	cin >> n >> k;
	if (k * 2<=n+1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

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

int main()
  {
    int n;
    int c=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n-2;i++)
      {
        if(s[i]=='A' && s[i+1]=='B' &&s[i+2]=='C')
        c++;
      }
      cout<<c;

  }


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int r;cin>>r;

    cout<<r*r<<endl;

    return 0;
}

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

int main() {
	long long h, w, m;
	std::cin >> h >> w >> m;
	std::vector<long long> r(h, 0), c(w, 0);
	std::vector<long long> x(m), y(m);
	for (int i = 0; i < m; i++) {
		std::cin >> x[i] >> y[i];
		r[--x[i]]++; c[--y[i]]++;
	}
	
	std::vector<long long> cnt(m + 1, 0);
	for (const auto &e : r) cnt[e]++;
	
	long long rmax = *std::max_element(r.begin(), r.end());
	long long cmax = *std::max_element(c.begin(), c.end());
	long long smax = rmax + cmax;
	
	auto f = [&] (long long k) -> bool {
		long long sum = 0;
		for (int i = 0; i < w; i++) {
			long long s = k - c[i];
			if (s < 0) continue;
			sum += cnt[s];
		}
		for (int i = 0; i < m; i++) {
			long long s = r[x[i]] + c[y[i]];
			if (s == k + 1) sum++;
			if (s == k) sum--;
		}
		return (sum > 0);
	};
	
	if (f(smax)) std::cout << smax << '\n';
	else std::cout << smax - 1 << '\n';
	
	return 0;
}

Measured memory_bytes: 14828
import java.util.Scanner;

//AtCoder Beginner Contest 148
//A - Round One
public class Main {

	static final int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());

		if (A == 1 && B == 2) {
			System.out.println(3);
		} else if (A == 1 && B == 3) {
			System.out.println(2);
		} else if (A == 2 && B == 3) {
			System.out.println(1);
		} else if (A == 2 && B == 1) {
			System.out.println(3);
		} else if (A == 3 && B == 1) {
			System.out.println(2);
		} else if (A == 3 && B == 2) {
			System.out.println(1);
		}
	}
}


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

int main(){
  int n,p[200010],q[200010],m=1;
  cin>>n;
  fr(i,n){
    cin>>p[i];
    q[--p[i]]=i;
  }
  int a=0,c=1,d=q[0];
  fr(i,n-1){
    if(q[i+1]>q[i]) c++;
    else c=1;
    m=max(m,c);
  }
  cout<<n-m<<endl;
}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;

//Faster Coding
#define ED return 0
#define GET(a) int a;cin >> a
#define PRINT(a) cout << a << endl
#define ANS(a,b) int a;cin >> a;cout << b << endl
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//Difficult Syntax
#define DOUBLECHANGE(count) cout << setprecision(count)

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK" << endl

const long long INF = 999999999;
const long long mod = 1000000007;

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      int A, B;
      cin >> A >> B;
      ANS(C,max(C-A+B,0));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  ll k; cin >> k;
  int n = s.size();
  rep(i, n) {
    int d = (26-(s[i]-'a')) % 26;
    if(d <= k) {
      k -= d;
      s[i] = 'a';
    }
  }
  k %= 26;
  if(k) s[n-1] = 'a' + ((s[n-1]-'a')+k) % 26;
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n; cin>>n;
    int p=n/100;
    int x=p*100+p*10+p;
    if(x== n )
        cout<<n;
    else if(x> n)
        cout<<p<<p<<p<<endl;
    else
    {
        p++;
        cout<<p<<p<<p<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <utility>
#include<stack>
#include<queue>
#include<map>
#include <fstream>
#include<set>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long

int inf=1000000000;
int d[1010][1010];
/// 18 36

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

        int h,w;
        queue<pair<int,int>> q;

        char tmp;
        cin>>h>>w;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                    d[i][j]=inf;
                cin>>tmp;
                if( tmp=='#' ) {
                        q.push( mp(i,j) );
                        d[i][j]=0;
                }
            }
        }
        while( !q.empty() ){
            int x = q.front().first;
            int y = q.front().second;
            q.pop();
            if( x+1<h&&d[x+1][y]==inf ) {
                    d[x+1][y]=d[x][y]+1;
                    q.push( mp( x+1,y ) );
            }
            if( x-1>=0&&d[x-1][y]==inf  ) {
                    d[x-1][y]=d[x][y]+1;
                    q.push( mp( x-1,y ) );
            }
            if( y+1<w&&d[x][y+1]==inf  ) {
                    d[x][y+1]=d[x][y]+1;
                    q.push( mp(x,y+1) );
            }
            if( y-1>=0&&d[x][y-1]==inf  ){
                    d[x][y-1]=d[x][y]+1;
                    q.push( mp(x,y-1) );
            }
        }
        int res=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++)res=max( res, d[i][j] );
        }
        cout<<res<<endl;
      return 0;
    }





















Measured memory_bytes: 12432
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(i) cout<<i<<endl;
const int mod=1e9 +7;
int main(){
IOS;
int n,i;
cin>>n;
int l;
cin>>l;
int a[n+1];
a[0]=0;
for(i=1;i<=n;i++){
    a[i]=l+i-1;
}
int sum=0;
for(i=1;i<=n;i++){
    sum+=a[i];
}
int mini=inf,index=0;
for(i=1;i<=n;i++){
    if(abs(a[i])<mini){
    mini=min(abs(a[i]),mini);
    index=i;
    }
}
cout<<sum-a[index]<<endl;
}


Measured memory_bytes: 256
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
INF = 10**9

def main():
    S1 = list(input())
    S2 = list(input())
    min_ans = INF
    for i in range(len(S1) - len(S2) + 1):
        temp_ans = 0
        for j in range(len(S2)):
            if S1[i+j] != S2[j]:
                temp_ans += 1
        #print(temp_ans)
        if min_ans > temp_ans:
            min_ans = temp_ans
    print(min_ans)

    #print(S1, S2)
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 27180
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		List<Integer>[] g = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
		}

		for (int i = 0; i < n - 1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			g[a].add(b);
			g[b].add(a);
		}

		int[] d1 = new int[n];
		int[] dn = new int[n];

		Queue<int[]> q = new LinkedList<>();
		q.add(new int[]{0, 1});
		while (!q.isEmpty()) {
			int[] x = q.poll();
			if (d1[x[0]] > 0) continue;
			d1[x[0]] = x[1];
			for (int i = 0; i < g[x[0]].size(); i++) {
				q.offer(new int[]{g[x[0]].get(i), x[1] + 1});
			}
		}

		q.add(new int[]{n - 1, 1});
		while (!q.isEmpty()) {
			int[] x = q.poll();
			if (dn[x[0]] > 0) continue;
			dn[x[0]] = x[1];
			for (int i = 0; i < g[x[0]].size(); i++) {
				q.offer(new int[]{g[x[0]].get(i), x[1] + 1});
			}
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (d1[i] <= dn[i]) count++;
		}

		if (count > n / 2) {
			System.out.println("Fennec");
		} else {
			System.out.println("Snuke");
		}
	}
}


Measured memory_bytes: 104532
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int t=5;
    int i=1,idx;
    while(t--)
    {
        int x;
        cin>>x;
        if(x==0)
            idx=i;
        i++;

    }
    cout<<idx<<endl;
}



























Measured memory_bytes: 3612
N=int(input())
A=list(map(int,input().split()))
 
import numpy as np

def getNearestValue(list, num):
  idx = np.abs(np.asarray(list) - num).argmin()
  return list[idx]

a=(np.cumsum(A))
l=getNearestValue(a, sum(A)/2)

ans=abs(sum(A)-2*l)
print(ans)

Measured memory_bytes: 26868
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,M,i,a[100],k,j,l,x,y;
    cin>>N>>M;
    for(i=0;i<N;i++){
        cin>>a[i];
    }
    for(k=1;k<=M;k++){
        for(l=0;l<N-1;l++){
            x=a[l]%k;
            y=a[l+1]%k;
            if(x>y){
                swap(a[l],a[l+1]);
            }
        }
    }
    for(j=0;j<N;j++){
        cout<<a[j]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3100
#include<cstdio>
#include<cstring>
const int mod=1e9+7;
#define max(a,b) (a>b?a:b)
int matmod(long long v,long long k){
	long long ans=1ll;
	for(;k;k>>=1){
		if(k&1) ans=(ans*v)%mod;
		v=(v*v)%mod;
	}
	return (int) ans;
}
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
char num[5005];
int f[5005][5005],n;
int main(){
	n=read();
	scanf("%s",num);
	int len=strlen(num);
	int pu=1;
	for(int i=1;i<=len;i++) pu=(pu*2)%mod;
	pu=matmod(pu*1ll,mod-2);
	f[0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=i;j++){
			f[i+1][j+1]=(f[i+1][j+1]+2*f[i][j]%mod)%mod;
			f[i+1][max(j-1,0)]=(f[i+1][max(j-1,0)]+f[i][j])%mod;
		}
	long long ans=((long long) pu)*((long long) f[n][len])%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 96384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    int ans = 1;
    while(ans <= n) ans *= 2;
    cout << ans / 2;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<time.h>


int main()
{
	int mon, day;
	char *wday[] = { "Sunday","Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
	struct tm ptime = { 0 };


	while (1)
	{
		scanf("%d %d",&mon,&day);
		if (mon == 0 && day == 0)
		{
			break;
		}
		ptime.tm_year = 2004 - 1900;
		ptime.tm_mon = mon - 1;
		ptime.tm_mday = day;
		time_t i = mktime(&ptime);
		if (i)
		{
			printf("%s\n", wday[ptime.tm_wday]);
		}
		
	}
	return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];

    /**
     * できるだけ/2は少なくしたい。
     * 全てのaに対し、/2が出来る回数をかぞえる、
     */

    i32 Cnt = 0;
    rep(i,n) {
        i32 A = a[i];
        while(A%2==0) {
            ++Cnt;
            A/=2;
        }
    }

    cout << Cnt << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
  int flag=1;
  int i,j;
  int n,a[100];
  int co=0;
  int x;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  while(flag){
    flag=0;
    for(j=n-1;j>0;j--){
      if(a[j]<a[j-1]){
	x=a[j-1];
	a[j-1]=a[j];
	a[j]=x;
	flag=1;
	co++;
      }
    } 
  }
  printf("%d",a[0]);
  for(i=1;i<n;i++) printf(" %d",a[i]);
  printf("\n");
  printf("%d\n",co);
  return(0);
}



Measured memory_bytes: 2072
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int N;
    int T,A;
    cin >> N;
    cin >> T >> A;
    int h[N];
    for (int i = 0;i<N;i++){
        cin >> h[i];
    }
    double temin = abs(A - (T - 0.006*h[0]));
    int p = 0;
    double n;
    for (int i = 0;i<N;i++){
        n = abs(A - (T - 0.006*h[i]));
        if (n < temin){
            p = i;
            temin = n;
        }
    }
    cout << p + 1 <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll k; cin>>k;
	string s;
	cin>>s;
	if(s.size()<=k){
		cout<<s<<endl;
	}else{
		REP(i,k)cout<<s[i];
		cout<<"..."<<endl;
	}
	return 0;
}


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

using namespace std;

int main(){
	int n;
	int x[100][100]={};
	int a[100]={};
	char y;
	cin >> n;
	string s;
	for(int i=0;i<n;i++){
		cin >> s;
		sort(s.begin(),s.end());
		for(int j=0;j<s.size();j++){
			x[i][s[j]-'a']+=1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<100;j++){
			if(i==0){
				a[j]=x[i][j];
			}else{
				if(a[j]>x[i][j]){
					a[j]=x[i][j];
				}
			}
		}
	}
	for(int i=0;i<50;i++){
		if(a[i]!=0){
			y = 'a'+i;
			for(int j=0;j<a[i];j++){
				cout << y;
			}
		}
	}
	cout << endl;
	return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    string st;

    cin >> st;


    ll len = st.length();


    int z = 0 , one = 0;

    for(int i=0; i<len; i++)
    {
        if(st[i]=='0')
        {
            z++;
        }else
        {
            one++;
        }
    }

    cout << min(z,one)*2 << endl;

//    int count = 0;
//
//    int pos = 0;
//
//
//
//
//    for(int i=pos;  i<len;)
//    {
//
//        cout << i << " " << i+1 << endl;
//
//        if(st[i]=='0' && st[i+1]=='1')
//        {
//            count+=2;
//            st.erase(i,1);
//            st.erase(i+1,1);
//            len-=2;
//            i = 0;
//        }
//        else if(st[i]=='1' || st[i+1]=='0')
//        {
//            count+=2;
//            st.erase(i,1);
//            st.erase(i+1,1);
//            len-=2;
//            i = 0;
//
//        }
//        else
//        {
//            i++;
//        }
//    }
//
//    cout << count << endl;





    return 0;
}



Measured memory_bytes: 512