akhauriyash/Code-Regression huggingface dataset:
ac=0;wa=0;re=0;tle=0
for _ in range(int(input())):
    n=input()
    if n=='AC': ac+=1
    elif n=='WA': wa+=1
    elif n=='TLE': tle+=1
    else: re+=1
print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")

Measured memory_bytes: 9092
#include <cstdio>
#define MOD 1000000007
int dp[4005][2005], pre[4005][2005];
int main()
{
	// freopen("AGC009-E.in", "r", stdin);
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	dp[0][0] = 1;
	for (int i = 1; i < n + m; i++)
	{
		for (int j = 0; j <= m; j++)
		{
			pre[i][j] = ((j ? pre[i][j - 1] : 0) + dp[i - 1][j]) % MOD;
			dp[i][j] = (pre[i][j] - (j >= k ? pre[i][j - k] : 0) + MOD) % MOD;
		}
	}
	int ans = 0;
	while (m > 0)
	{
		(ans += dp[(n + m - 1) / (k - 1)][m]) %= MOD;
		m -= k - 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 62848
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 10000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void allcout(auto V) {
    for(auto x : V) cout << x << ' ';
    cout << endl;
}

signed main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include <wchar.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*

*/

ll n,h[100010],dp[100010];

int main(void){
	cin>>n;
	reg(i,2,n)dp[i]=1e18;
	dp[1]=0;
	reg(i,1,n)cin>>h[i];
	reg(i,2,n){
		if(i==2){
			dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		}else{
			dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
x = list(map(int, input().split()))
d = 10 ** 9
for i in range(k-1, n):
    if x[i] * x[i-k+1] < 0:
        d = min(d, min(abs(x[i]), abs(x[i-k+1])) + abs(x[i] - x[i-k+1]))
    else:
        d = min(d, max(abs(x[i]), abs(x[i-k+1])))
print(d)


Measured memory_bytes: 14252
n, m = map(int, input().split())

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

b = [1]*(n + 1)

for i in a:
    b[i] = 0

for i in range(2, n + 1):
    if b[i] != 0:
        b[i] = (b[i - 2] + b[i - 1])%(10**9 + 7)

print(b[-1])

Measured memory_bytes: 7824
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    ll h,n,sum = 0;
    cin >> h >> n;
    rep0(i, n){
        ll a;
        cin >> a;
        sum += a;
    }
    if(sum < h)pf("No")
        else pf("Yes")
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val map = Array(h + 2) { CharArray(w + 2) { '#' } }
    (1..h).forEach {
        val s = readLine()!!
        for (i in 0 until w) {
            map[it][i + 1] = s[i]
        }
    }

    val minCost = Array(h * w + 1) { LongArray(h * w + 1) { Long.MAX_VALUE / 10 } }
    for (i in 0..(h * w)) {
        minCost[i][i] = 0
    }
    for (i in 1..h) {
        for (j in 1..w) {
            val cur = map[i][j]
            val right = map[i][j + 1]
            val down = map[i + 1][j]
            val curNum = (i - 1) * w + j
            if (cur == '.' && right == '.') {
                val rightNum = (i - 1) * w + j + 1
                minCost[curNum][rightNum] = 1
                minCost[rightNum][curNum] = 1
            }
            if (cur == '.' && down == '.') {
                val downNum = (i - 1) * w + j + w
                minCost[curNum][downNum] = 1
                minCost[downNum][curNum] = 1
            }
        }
    }
    for (j in 1..(h * w))
        for (i in 1..(h * w))
            for (k in 1..(h * w))
                minCost[i][k] = Math.min(minCost[i][k], minCost[i][j] + minCost[j][k])
    val max = minCost.map { it.filter { it < 10000 }.max() ?: 0 }.max()!!
    println(max)
}

Measured memory_bytes: 42716
#include<iostream>
#include<vector>

using namespace std;
int dp[100050]={};
int num(int a){
    if(a<0)return -a;
    else return a;
}
int min1(int a,int b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n+5);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=num(h[2]-h[1]);
    int tmp;
    for(int i=3;i<=n;i++){
        int min=1000000000;
        for(int j=1;j<=k;j++){
            if(j==i)break;
            tmp=dp[i-j]+num(h[i]-h[i-j]);
            if(min>tmp)min=tmp;
        }
        dp[i]=min;
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n == 1)
    {
        if (m == 1)
        {
            ans = 1;
        }
        else
        {
            ans = m - 2;
        }
    }
    else if (m == 1)
    {
        ans = n - 2;
    }
    else
    {
        ans = (n - 2) * (m - 2);
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
//2019年12月8日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElms(&a[0], a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}



#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


int nx[4] = {1,0,-1,0};
int ny[4] = {0,1,0,-1};

int a[200005];
string maze[25];

bool donelist[25][25];
int main(){
    int h,w;
    cin >> h >> w;

    rep(i,h) cin >> maze[i];

    int ans = 0;
    rep(i,h){rep(j,w){
        if(maze[i][j] == '#') continue;
        rep(a,25)rep(b,25)donelist[a][b] = false;
        queue<array<int,3>> q;
        // prints("i j is ", i,j);

        q.push({i,j,0});
        donelist[i][j] = true;
        while(!q.empty()){
            array<int,3> tmp;
            tmp = q.front();
            q.pop();
            // prints(i,j,tmp[0],tmp[1],tmp[2]);
            ans = max(ans,tmp[2]);
            rep(t,4){
                int xn = tmp[0] + nx[t];
                int yn = tmp[1] + ny[t];
                // prints("xn,yn",xn,yn,"done",donelist[xn][yn]);
                if(xn != h && xn != -1 && yn != w && yn != -1 && maze[xn][yn] == '.' && donelist[xn][yn] == false){
//                                    prints("add", xn,yn);

                    q.push({xn,yn,tmp[2]+1});
                    donelist[xn][yn] = true;
                }
            }
        }}
    }

    prints(ans);

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val mod = 1000000007
    val n = readInt()
    println(n*n/4)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

int main()
{
 int n;
 cin>>n;
 ll sum=0;
 int i=1;
while(i<=n)
{


    if(i%3==0 ||  i%5==0)
    {

    }
    else
    {
      //cout<<i<<endl;
      sum +=i;
    }

    i++;
 }

cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 3636
//package solution;

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    void run() throws Exception {
        int n = ni(), m = ni();
        long[][] map = new long[n][m];
        for(int i=0; i<n; i++) {
            String s = nt();
            for(int j=0; j<m; j++) {
                map[i][j] = (s.charAt(j) == '.') ? 0 : Integer.MAX_VALUE;
            }
        }
        map[0][0] = 1;
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
                if(map[i][j] == Integer.MAX_VALUE) continue;
                try {
                    if(map[i-1][j] != Integer.MAX_VALUE) {
                        map[i][j] += map[i-1][j];
                    }
                } catch(Exception ex) {}
                try {
                    if(map[i][j-1] != Integer.MAX_VALUE) {
                        map[i][j] += map[i][j-1];
                    }
                } catch(Exception ex) {}
                map[i][j] %= 1000000007L;
            }
        }
        
        pl(map[n-1][m-1] % 1000000007L);
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
    
    void selector() {
        Random rd = new Random();
        String[] s = new String[] {"Strings", "Sorting", "Search"
                , "Graph theory", "Greedy", "Dynamic programming"
                , "Constructive algos", "Bit manipulation", "Recursion"};
        pl(s[rd.nextInt(s.length)] + " " + (rd.nextInt(5)+1));
    }
}

Measured memory_bytes: 36692
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int s,w;
    R(s,w);
    W(s<=w?"unsafe":"safe");
    return 0;
}


Measured memory_bytes: 3748
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int INF = 100000000;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

typedef pair< int, int > point;
int h,w,n;
char map[1002][1002];
int x[10],y[10];
int ans = 0;

int main(){
  scanf("%d %d %d",&h,&w,&n);
  for(int i=0;i<=h+1;i++){
    for(int j=0;j<=w+1;j++){
      if(i==0||j==0||i==h+1||j==w+1) map[i][j] = 'X';
      else scanf(" %c ",&map[i][j]);
      if(map[i][j]=='S'){
        x[0] = i;
        y[0] = j;
        map[i][j] = '.';
      }else if(map[i][j]!='.'&&map[i][j]!='X'){
        x[map[i][j]-48] = i;
        y[map[i][j]-48] = j;
        map[i][j] = '.';
      }
    }
  }
  for(int i=0;i<n;i++){
    queue<point> q;
    int d[1002][1002];
    fill(d[0],d[0]+1002*1002,INF);
    d[x[i]][y[i]] = 0;
    q.push(point(x[i],y[i]));
    while(true){
      point np = q.front();
      q.pop();
      int nx = np.first;
      int ny = np.second;
      if(nx==x[i+1]&&ny==y[i+1]){
        ans+=d[nx][ny];
        break;
      }
      for(int j=0;j<4;j++){
        if(map[nx+dx[j]][ny+dy[j]]=='.'){
          if(d[nx+dx[j]][ny+dy[j]]>d[nx][ny]+1){
            d[nx+dx[j]][ny+dy[j]] = d[nx][ny]+1;
            q.push(point(nx+dx[j],ny+dy[j]));
          }
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 5952
import java.util.Scanner;

class Main{	
	
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int a=sc.nextInt();
			int b=sc.nextInt();
			int n = a+b;
			
			String st = String.valueOf(n);
			
			
			System.out.println(st.length());
			
		}
		
	}
}

Measured memory_bytes: 12000
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void)
{

	int i;
	int len;
	char s[200001];
	char t[200001];
	int s_n[200001] = {0};
	int t_n[200001] = {0};
	int s_a[26] = {0};
	int t_a[26] = {0};

	scanf("%s%s", s, t);

	len = strlen(s);

	for (int i = 0; i < len; i++)
	{
		s_a[s[i] - 'a']++;
		s_n[i]=s_a[s[i] - 'a'];
	 
	}

	for (int i = 0; i < len; i++)
	{
		t_a[t[i] - 'a']++;
		t_n[i]=t_a[t[i] - 'a'];
	}

	for (int i = 0;i < len ; i ++)
	{
      if (t_n[i]!=s_n[i])
      {
        printf("No");
		return 0;
	  }
	}

	printf("Yes");
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
char s[2002][2002];
int dp[2002][2002][4];
int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    for(int i=1;i<=h;i++) scanf("%s", s[i]+1);   
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j] == '#') continue;
            dp[i][j][0] = dp[i][j-1][0] + 1;
            dp[i][j][1] = dp[i-1][j][1] + 1;
        }
    }
    for(int i=h;i>=1;i--){
        for(int j=w;j>=1;j--){
            if(s[i][j] == '#') continue;
            dp[i][j][2] = dp[i][j+1][2] + 1;
            dp[i][j][3] = dp[i+1][j][3] + 1;
        }
    }
    int ans = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j] == '#') continue;
            ans = max(ans, dp[i][j][0] + dp[i][j][1] + dp[i][j][2] + dp[i][j][3] - 3);
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 66816
import java.util.*;

public class Main{
	public static void main(String[] $$) throws Exception {
		Scanner $ = new Scanner(System.in);
		int X = $.nextInt(), A = $.nextInt();
		if (X < A)  System.out.println(0);
		else System.out.println(10);
		/*
		3 5 -> 0
		7 5 -> 10
		6 6 -> 10
		*/
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 22
using namespace std;

int main() {
	int N, ans = 0, i;
	vector<int> V, C;
	cin >> N;
	V.resize(N);
	C.resize(N);
	for (i = 1; i <= N; i++)
	{
		cin >> V[i];
	}
	for (i = 1; i <= N; i++)
	{
		cin >> C[i];
	}
	for (i = 1; i <= N; i++)
	{
		if (V[i] > C[i])
			ans += V[i] - C[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
	
		
		String s;
		while ((s = reader.readLine()) != null) {
			int count = 0;
			int a = Integer.parseInt(s);
			for (int i = 0; i < 10; i++)
				for (int j = 0; j < 10; j++)
					for (int k = 0; k < 10; k++)
						for (int l = 0; l < 10; l++)
							if (i + j + k + l == a)
								count++;
			System.out.println(count);
		}

	}

}

Measured memory_bytes: 18504
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
	fastIO
	int n;
	long ans;
	cin>>n;
	ans=n+(n*n)+(n*n*n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=1e5+5;

int f[maxn], finv[maxn], inv[maxn];

void init(){           //mod为质数，预处理时间复杂度O(n)
    inv[1]=1;
    for(int i=2; i<maxn; ++i){
        inv[i]=(mod-mod/i)*1ll*inv[mod%i]%mod;
    }
    f[0]=finv[0]=1;
    for (int i=1; i<maxn; ++i) {
        f[i] = f[i-1] * 1ll * i % mod;
        finv[i] = finv[i-1] * 1ll * inv[i] % mod;
    }
}

LL Cmod(int n, int k)  {       //C (n, k) % MOD
    if (k < 0 || k > n) return 0;
    return f[n] * 1ll * finv[n-k] % mod * finv[k] % mod;
}

int n;
int data[maxn], vis[maxn];

int main() {
    init();
    while(~scanf("%d", &n)){
        int d=0;
        memset(vis, 0);
        for(int i=1;i<=n+1;i++){
            scanf("%d", &data[i]);
            if(vis[data[i]])d=n+1-(i-vis[data[i]]+1);
            else vis[data[i]]=i;
        }
        for(int i=1;i<=n+1;i++){
            LL ans=Cmod(n+1, i)-Cmod(d, i-1);
            if(ans<0)ans+=mod;
            printf("%d\n", ans);
        }
    }
}


Measured memory_bytes: 3200
n,m=map(int,input().split())
num=[1]*n 
r=[1]+[0]*(n-1)
for _ in range(m):
    x,y=map(int, input().split())
    x,y=x-1, y-1
    num[x]-=1
    num[y]+=1
    if r[x]: r[y] = 1
    if num[x] == 0: r[x] = 0
print(sum(r))

Measured memory_bytes: 5364
n,m = map(int,input().split())
x_lis = list(map(int,input().split()))
x_lis.sort()
diff = []
for i in range(m-1):
	diff.append((x_lis[i+1]-x_lis[i]))
a_diff=sorted(diff, reverse=True)

print(sum(a_diff[n-1:]))

Measured memory_bytes: 13964
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


string S, T;
char m[30];
char im[30];


bool solve(){
	rep(i, 0, SIZE(S))
		if(!m[S[i]-'a']){
			if(im[T[i]-'a'] && im[T[i]-'a'] != S[i]) return false;
			m[S[i]-'a'] = T[i];
			im[T[i]-'a'] = S[i];
		}
		else if(S[i] != T[i] && im[T[i]-'a'] != S[i]) return false;
	return true;
}


signed main(){
	cin >> S >> T;

	if(solve()) Yes;
	else No;

	return 0;
}

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

using namespace std;

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b == c || b+c == a || c+a == b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    string s;
    cin >> s;
    int cnt = 0;int maxi = 0;
    for(int i = 0;i<s.length();i++){
        if(s[i]=='R') {cnt++;maxi = max(maxi,cnt);}
        else cnt = 0;
    }
    cout << maxi;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
a_list = []
max_v = -1
sec = -1
tmp = 0
drop = False
max_ind = []
for i in range(N):
    a_list.append(int(input()))
    if a_list[-1]>max_v:
        tmp = max_v
        max_v = a_list[-1]
        max_ind = [i]
    elif a_list[-1]<max_v:
        if a_list[-1]>sec:
            drop = True
            sec = a_list[-1]
    else:
        max_ind.append(i)
if len(max_ind)>1:
    for i in range(N):
        print(max_v)
elif drop:
    for i in range(N):
        if i in max_ind:
            print(sec)
        else:
            print(max_v)
else:
    for i in range(N):
        if i in max_ind:
            print(tmp)
        else:
            print(max_v)

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=9;++i){
        for(int j=1;j<=9;++j){
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0])-1] == 0:
      pen[int(ps[i][0])-1]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if ( c > b && c > a ){
    if ( b > a ){
       cout << "Yes" << endl;
    }else{
       cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<stdlib.h>
#include<cstdio>
#include<math.h>
#include<algorithm>
#define Max 500001
using namespace std;

int A[Max];
int n;
void maxHeap(int i)
{
	int l = 2 * i;
	int r = 2 * i + 1;
	int largest = i;
	if (l <= n&&A[l] > A[largest])
		largest = l;
	if (r <= n&&A[r] > A[largest])
		largest = r;
	if (largest != i)
	{
		swap(A[largest], A[i]);
		maxHeap(largest);
	}

}



int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> A[i];
	}
	for (int i = n / 2; i >=1; i--)
	{
		maxHeap(i);
	}
	for (int i = 1; i <= n; i++)
	{
		cout << ' ' << A[i];
	}
	cout << endl;
	return 0;

}


Measured memory_bytes: 5040
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR(i,0,n)
using ll = long long;
using namespace std;
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n, k;
    cin >> n;
    cin >> k;
 
    int ans = 1;
    for(int i=0; i<n; i++){
        if(ans * 2 <= ans + k){
            ans *= 2;
        } else {
            ans += k;
        }
    }
 
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef pair<int, pair<int, pair<int, int>>> PP;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const long long INF = 1LL << 60;
const int inf = 1e9;
const long long MOD = 1e9+7;



int main() {
	string S;
	cin >> S;
	int a = S.size() - 1;
	if (S[a] == 's')S += 'e';
	S += 's';
	cout << S << endl;
	return 0;
}

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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    vector<int> s, t, e;

    int _s, _t, _e;

    while(cin >> _s >> _t >> _e && _s)
    {
        _s--; _t--;
        s.push_back(_s);
        t.push_back(_t);
        e.push_back(_e);
    }

    int L;
    cin >> L;

    vector<int> c(N), b(M);

    rep(i, L)
    {
        rep(j, N) c[j] = 0;

        rep(j, M) cin >> b[j];

        rep(j, s.size())
        {
            c[s[j]] += b[t[j]] * e[j];
        }

        rep(j, N) cout << (j != 0 ? " " : "") << c[j];

        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3784
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	int m = min(min(a, b), c);
	int M = max(max(a, b), c);
	printf("%d %d %d\n", m, (a + b + c) - (m + M), M);
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define int long long
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int n,i,d=1,s;
int f(int p)
{
	for(s=0;p>=1;p/=10)s+=p%10;
	return s;
}
signed main()
{
	n=read();
	while(n--)
    {
		if((i+d)*f(i+d*2)>(i+d*2)*f(i+d))d*=10;
		i+=d;
		printf("%lld\n",i);
	}
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main(){
  Sieve sieve(1000000);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  map<int, int> mp;
  rep(i, N){
   vector<P> f = sieve.factor(A.at(i));
    for(auto p : f){
      mp[p.first] = max(p.second, mp[p.first]);
    }
  }
  mint lcm = 1;
  for(auto p : mp){
    lcm *= pow(p.first, p.second);
  }
  mint ans = 0;
  rep(i, N){
    ans += lcm / A.at(i);
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 4984
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
  int key;
  Node *next , *prev;
};

Node *nil;

Node *listSearch(int key){
  Node *cur = nil->next; 
  while ( cur != nil && cur->key != key){
      cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if ( cur == nil ) break;
    if ( isf++ > 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if ( t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deletekey(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	deletekey(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1 && b == 2 || a == 2 && b == 1) cout << 3 << endl;
  if (a == 1 && b == 3 || a == 3 && b == 1) cout << 2 << endl;
  if (a == 2 && b == 3 || a == 3 && b == 2) cout << 1 << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h,w = LI()
s = [list(input()) for _ in range(h)]
W = [[0]*w for _ in range(h)]
H = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        else:
            if j > 0:
                W[i][j] = W[i][j-1] + 1
            else:
                W[i][j] = 1
            if i > 0:
                H[i][j]  = H[i-1][j] + 1
            else:
                H[i][j] = 1
y = [[0]*w for _ in range(h)]
x = [[0]*w for _ in range(h)]
for i in range(h)[::-1]:
    for j in range(w)[::-1]:
        if j == w-1:
            x[i][j] = W[i][j]
        if j > 0:
            if s[i][j-1] != '#':
                if s[i][j] == '#':
                    x[i][j-1] = W[i][j-1]
                else:
                    x[i][j-1] = max(x[i][j],W[i][j])
        if i == h-1:
            y[i][j] = H[i][j]
        if i > 0:
            if s[i-1][j] != '#':
                if s[i][j] == '#':
                    y[i-1][j] = H[i-1][j]
                else:
                    y[i-1][j] = max(y[i][j],H[i][j])
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] != '#':
            ans = max(ans,x[i][j] + y[i][j]-1)
print(ans)

Measured memory_bytes: 312584
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int i = 2;
    boolean flag = false;
    int cnt = 0;
    int ans = 0;

    while(flag == false && cnt <= s.length()){
      String s1 = s.substring(0, (s.length()-i)/2);
      String s2 = s.substring((s.length()-i)/2, s.length()-i);
      //System.out.println(s1);
      //System.out.println(s2);
      if(s1.equals(s2)){
        flag = true;
        ans = s1.length() * 2;
        break;
      }
      i+=2;
      cnt+=2;
    }

      System.out.println(ans);
    }
  }

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAXN = 2005;
const int mod = 1e9 + 7;

int n, k;
int dp[MAXN][MAXN];
int sum[MAXN];

int main(){
	cin >> n >> k;
	for(int i=2; i<=n+1; i++) dp[k-1][i] = 1;
	for(int i=k-2; i>=0;i--){
		for(int j=1; j<=n+1; j++) sum[j] = (sum[j-1] + dp[i+1][j]) % mod;
		for(int j=1; j<=n+1; j++){
			lint ret = sum[j - 1];
			if(i + j != n + 1) ret += dp[i+1][j];
			dp[i][j] = ret % mod;
		}
	}
	lint ans = dp[0][n+1];
	for(int i=k+2; i<=n; i++) ans = (ans << 1) % mod;
	cout << ans << endl;
}



Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(((a+b)%3==0)||a%3==0||b%3==0){
        printf("Possible\n");
    }
    else{
            printf("Impossible\n");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n == 0){
      System.out.println(2);
      return;
    }
    if(n == 1){
      System.out.println(1);
      return;
    }
    long ans0 = 2,ans1 = 1,ans2 = 0;
    for(int i = 2;i<=n;i++){
      ans2 = ans1 + ans0;
      ans0 = ans1;
      ans1 = ans2;
    }
    System.out.println(ans2);
  }
}


Measured memory_bytes: 23760
from collections import Counter


def solve():
    S = raw_input()
    C = Counter(S)
    if len(S) == 1:
        return True

    A = sorted(C.items(), key=lambda x: -x[1])

    if len(A) == 2:
        return len(S) == 2

    if len(A) == 1:
        return False

    top1 = A[0][1]
    others = sum(a[1] for a in A[1:])
    return others >= (top1-1)*2

print 'YES' if solve() else 'NO'


Measured memory_bytes: 32284
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int k, x;
	cin >> k >> x;
	for(int i = x - k + 1; i <= x + k - 1; i++)
		cout << i << " ";
	return 0;
}

Measured memory_bytes: 256
import math
import sys


n = int(input())

if n >= 400 and n < 600:
    print(8)

elif n >= 600 and n < 800:
    print(7)

elif n >= 800 and n < 1000:
    print(6)

elif n >= 1000 and n < 1200:
    print(5)

elif n >= 1200 and n < 1400:
    print(4)

elif n >= 1400 and n < 1600:
    print(3)

elif n >= 1600 and n < 1800:
    print(2)

else:
    print(1)


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

const int maxn=400000+10;

int tmp[maxn];

int main()
{
	int n;cin>>n;int l=200000,r=199999;

	for(int i=1,x;i<=n;++i)
	{
		scanf("%d",&x);
		if(i&1) tmp[++r]=x;
		else tmp[--l]=x;
	}
	if(n&1) for(int i=r;i>=l;--i) printf("%d ",tmp[i]);
	else for(int i=l;i<=r;++i) printf("%d ",tmp[i]);
	return 0;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

class Task {
  public:
    int cost;
    int deadline;
    Task() {}
    Task(int _cost, int _deadline) {
      cost = _cost;
      deadline = _deadline;
    }
};

bool has_earlier_deadline(const Task& a, const Task& b)
{
  return a.deadline < b.deadline;
}

bool can_make_it(const vector<Task>& task)
{
  int ts = 0;
  for (const auto& t : task) {
    ts += t.cost;
    if (t.deadline < ts) {
      return false;
    }
  }
  return true;
}

int main()
{
  int n;
  cin >> n;
  vector<Task> task(n);
  for (int i = 0; i < n; i++) {
    cin >> task.at(i).cost >> task.at(i).deadline;
  }
  sort(task.begin(), task.end(), has_earlier_deadline);
  if (can_make_it(task)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int n,m,a,sum=0,goukei;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a;sum=sum+a;
  }
  goukei=n-sum;
  if(goukei<0)cout<<-1;
  else cout<<goukei;
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    rep(i, n) {
        int a;
        cin >> a;
        pq.push(a);
    }

    rep(i, m) {
        int now = pq.top();
        pq.pop();
        now >>= 1;
        pq.push(now);
    }

    ll ans = 0;
    while(!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int y = y2 - y1;
    int x = x2 - x1;
    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
uno = a.count(1)
dos = a.count(2)
tres = n - uno - dos
dp = [[[.0]*(n+1) for _ in range(dos+tres+1)] for j in range(tres+1)]
for k in range(tres+1):
  for j in range(dos+tres-k+1):
    for i in range(n+1-j-k):
      if i+j+k == 0: continue
      v = i+j+k
      res = n
      if i: res += i * dp[k][j][i-1]
      if j: res += j * dp[k][j-1][i+1]
      if k: res += k * dp[k-1][j+1][i]
      dp[k][j][i] = res / v
print(dp[tres][dos][uno]) 


Measured memory_bytes: 253960
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, P):
    M = 30000
    a = []
    b = []
    for i in range(1, N+1):
        a.append(i*M+1)
        b.append((N-i+1)*M + 1)
    for i, p in enumerate(P):
        a[p-1] += i

    return '\n'.join([' '.join(map(str, a)), ' '.join(map(str, b))])


def main():
    N = read_int()
    P = read_int_n()
    print(slv(N, P))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9680