akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

LL dp[3000][3000]; // [head][tail] => max diff
bool done[3000][3000]; // true when the head-tail pair already cached
int a[3000];


LL solve(int head, int tail, int sign) 
{
    LL ret = dp[head][tail];    
    if (!done[head][tail]) {
        if (head == tail) {
            ret = sign * a[head]; 
        } else {
            LL headVer = sign * a[head] + solve(head+1, tail, 0-sign);
            LL tailVer = sign * a[tail] + solve(head, tail-1, 0-sign);
            if (sign * headVer < sign * tailVer) {
                ret = tailVer;
            } else {
                ret = headVer;
            }
            // cout << head << ", " << tail << " => " << headVer << ", " << tailVer << " => " << ret << endl;
        }
        dp[head][tail] = ret;
        done[head][tail] = true;
    }    
    return ret;
}


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

    rep(i, N) cin >> a[i];

    cout << solve(0, N-1, 1) << endl;

    return 0;
}


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

int digits(ll n){
    int digit = 0;
    while(n != 0) {
        digit++;
        n = n / 10;
    }
    return digit;
}

int func(ll a, ll b){
    return max(digits(a), digits(b));
}

int main() {
    ll n;
    cin >> n;
    ll ans = 1ll << 60;
    for(ll a = 1; a <= sqrt(n); a++) {
        ll b = n / a;
        if(a * b == n) {
            int temp = func(a, b);
            if(ans > temp) ans = temp;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

ans = 0
for i in range(k, n + 2):
    # print(i)
    smin = int(0.5 * i * (2 * 0 + (i - 1) * 1))
    smax = int(0.5 * i * (2 * (n + 1 - i) + (i - 1) * 1))
    s = smax - smin + 1
    # print("s", s)
    ans += s
    ans = ans % (7 + 10 ** 9)
print(ans)


Measured memory_bytes: 9120
N,K=map(int,input().split())

A=[0 for _ in range(N)]

for i in range(K):
    d=int(input())
    *x,=map(int,input().split())
    for j in range(len(x)):
        A[x[j]-1]+=1
    
print(len([x for x in A if x==0]))

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

#define N 2001
const int MOD = 1e9+7;

typedef long long int ll;

int dp[N][N];

int C(int n, int r) {
	if (r == 0 || r == n)
		return 1;

	if (r == 1)
		return n;

	if (dp[n][r] != -1)
		return dp[n][r];

	return dp[n][r] = ((ll)C(n-1, r-1) + (ll)C(n-1, r)) % MOD;
}

int H(int r, int n) {
	// deb(r);
	// deb(n);

	// deb(C(n+r-1,r));

	// n+r-1Cr
	return C(n+r-1,n);
}

int main() {

	IOS

	int n;
	cin >> n;

	int maxp = n/3;
	int c = 0;
	memset(dp, -1, sizeof(dp));

	for (int i = 1; i <= maxp; i++) {
		int left = n-3*i;

		if (left < 0)
			continue;

		c = ((ll)c + (ll)H(i, left)) % MOD;
	}

	cout << c;

	return 0;
}

Measured memory_bytes: 19324
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  long double N = 0,K = 0,Z = 1,ans = 0;
  cin >> N >> K;
  Z = 1 / N;
  int a = 0;
  cout << fixed << setprecision(10);
  rep(i,N){
    a = i + 1;
    long double count = 1;
    while(a < K){
      a *= 2;
      count *= 0.5;
    }
    ans += Z * count;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1<<20|3,mo=1e9+7;
inline void add(int &x,int y){x=x+y<mo?x+y:x+y-mo;}
int n,m,q,c[22],d[22],mxbit[N],f[20][N],g[N],dy[N];

int main() {
	read(n);read(m);read(q);n--;
	while(q--){
		int x,y,z;read(x);read(y);read(z);y=n-y;
		c[x]|=1<<y;if(z)d[x]|=1<<y;
	}
	int all=(1<<n)-1;
	rep(i,1,all)mxbit[i]=max((i&-i),mxbit[i^(i&-i)]);
	g[0]=1;rep(i,0,n-1)dy[1<<i]=i;
	rep(t,1,m){
		memset(f,0,sizeof(f));
		rep(i,0,all)f[n][i]=g[i];
		per(i,n,1)rep(s,0,all)if(f[i][s]){
			int bit=mxbit[s&((1<<i)-1)],now=bit?bit<<1:1;
			if(!(s&now))add(f[i][s+now-bit],f[i][s]);
			add(f[dy[bit]][s],f[i][s]);
		}
	//	rep(i,0,all)printf("%d:%d\n",i,f[0][i]);
		rep(i,0,all)g[i]=(i&c[t])==d[t]?f[0][i]:0;
	}
	int res=0;rep(i,0,all)add(res,g[i]);printf("%d",res);
	return 0;
}


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

struct rect { ll h, w; };

ll H, W;
char S[2000][2000];
ll f[2000][2000];

rect max_rectangle(ll *h, ll n) {
  struct item { ll h, p; };
  stack<item> stk;
  rect m = (rect) { 0, 0 };

  REP(i, 0, n + 1) {
    item r = (item) { i < n ? h[i] : 0, i };
    if(stk.empty()) {
      stk.push(r);
    } else {
      if(stk.top().h < r.h) stk.push(r);
      if(stk.top().h > r.h) {
        ll t = i;
        while(stk.size() && stk.top().h >= r.h) {
          item s = stk.top();
          stk.pop();
          s.h * (i - s.p);
          if(s.h * (i - s.p) > m.h * m.w) m = (rect) { s.h, i - s.p };
          t = s.p;
        }
        r.p = t;
        stk.push(r);
      }
    }
  }

  return m;
}

int main(void) {
  cin >> H >> W;
  REP(i, 0, H) REP(j, 0, W) cin >> S[i][j];

  REP(i, 0, H - 1) REP(j, 0, W - 1) {
    f[i][j] = ((S[i][j] == '#') + (S[i][j + 1] == '#') + (S[i + 1][j] == '#') + (S[i + 1][j + 1] == '#')) % 2 == 0;
  }
  for(ll i = H - 3; i >= 0; i--) REP(j, 0, W - 1) {
    if(f[i][j] > 0) f[i][j] += f[i + 1][j];
  }

  ll ans = max(H, W);
  REP(i, 0, H - 1) {
    rect m = max_rectangle(&f[i][0], W - 1);
    ans = max(ans, (m.h + 1) * (m.w + 1));
  }
  cout << ans << endl;
}


Measured memory_bytes: 35456
package main

import "fmt"

func main() {
  var S string
  fmt.Scan(&S)

  cnt := 0
  e := len(S) - 1
  for i := 0; i < len(S)/2; i++ {
    if S[i] != S[e] {
      cnt++
    }
    e--
  }
  fmt.Print(cnt)
}

Measured memory_bytes: 512
<?php
    /*
        Problem URL : http://abc057.contest.atcoder.jp/tasks/abc057_d

        Score  :
        Result :
        Time   : ms
        Memory : KB
     */

    ini_set('error_reporting', E_ALL & ~E_NOTICE);

    // define('DEBUG', true);
    define('DEBUG', false);

    // $a = 0;
    // for ($i = 1; $i <= 50; $i++) {
    //     $a += p(50, $i);
    //     // echo p(50, $i) . PHP_EOL;
    // }
    // printf("ans:%d\n", $a);
    // exit;

    if (DEBUG) {
        $start = microtime(true);
    }
    echo solve();
    if (DEBUG) {
        $t = microtime(true) - $start;
        printf ("Elapsed time: %7.3f sec\n", $t);
    }

    function p($x, $y) {
        $ret = 1;
        for ($i = $x; $i > $x - $y; $i--) {
            // echo "* {$i} / ". ($x - $i + 1) . "\n";
            $ret *= $i;
            $ret /= $x - $i + 1;
        }
        return $ret;
    }

    function solve() {
        $idx = array();
        $maxavg = 0;
        fscanf(STDIN, "%d %d %d\n", $N, $A, $B);
        $v = explode(" ", trim(fgets(STDIN)));
        foreach ($v as $vv) {
            $idx[$vv]++;
        }
        rsort($v);
        // var_dump($v);
        for ($i = $A; $i <= $B; $i++) {
            $tmp = null;
            $posi = 0;
            for ($j = 0; $j < $i; $j++) {
                if (is_null($tmp)) {
                    $tmp = $v[$j];
                }
                if ($tmp != $v[$j]) {
                    $posi = $j;
                    $tmp = $v[$j];
                }
                $total[$i] += $v[$j];
                $last[$i] = $v[$j];
            }
            $ai[$i] = $i;
            $pos[$i] = $posi;
            $avg[$i] = $total[$i] / $i;
            $maxavg = max($avg[$i], $maxavg);
            if (DEBUG) echo "PPPP {$idx[$last[$i]]} X " . ($i - $pos[$i]) . "\n";
            $toori[$i] = p($idx[$last[$i]], $i - $pos[$i]);
            if (DEBUG) echo "toori:{$toori[$i]}\n";
        }
        if (DEBUG) var_dump($total);
        $ans = 0;
        foreach ($total as $k => $v) {
            if (DEBUG) echo "ai:{$ai[$k]} t:{$total[$k]} l:{$last[$k]} a:{$avg[$k]} pos:{$pos[$k]} toori:{$toori[$k]} idx:".$idx[$last[$k]]."\n";
            if ($maxavg == $avg[$k]) {
                $ans += $toori[$k];
            }
        }
        echo $maxavg . PHP_EOL;
        printf("%d\n", $ans);
    }


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

stack<char> s;
string S;
bool fl = true;

int main(){
  cin >> S;
  rep(i, S.size()) s.push(S.at(i));
  while(!s.empty()){
    bool flag = false;
    string tmp = "";
    rep(i, 5){
      if(s.empty()) break;
      tmp += s.top();
      s.pop();
    }
    if(tmp == "maerd"||tmp == "esare"){
      flag = true;
    }
    else if(!s.empty() && (tmp == "remae"|| tmp == "resar")){
      tmp+=s.top();
      s.pop();
      if(tmp == "resare") flag = true;
      else {
        if(s.empty()) break;
        tmp+=s.top();
        s.pop();
        if(tmp == "remaerd") flag = true;
      }
    }
    if(!flag){
      fl = false;
      break;
    }
  }
  if(fl) cout << "YES" <<endl;
  else cout << "NO" <<endl;
}

Measured memory_bytes: 512
fun main(args:Array<String>){
  var s = readLine()!!.toInt()
  var a = s/100
  var b = s%100
  if(b<13 && 0<b){
    if(a<13 && 0<a){
      println("AMBIGUOUS")
    }
    else{
      println("YYMM")
    }
  }
  else{
    if(a<13 && 0<a ){
      println("MMYY")
    }
    else{
      println("NA")
    }
  }
}

Measured memory_bytes: 30044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
    int d,n;
    cin >> d >> n;
    int ans =0;
        if(d==0){
            if(n==100){
            ans =101;
            }else{
             ans=n;
            }
        }else if(d==1){
            if(n==100){
                ans=10100;
            }else{
            ans=n*100;
            }
        }else{
            if(n==100){
                ans=1010000;
            }else{
            ans=n*10000;
            }
        }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			
			int N = br.nextInt();
			
			int[] in = new int[N];
			
			for(int i = 0; i < N; i++) {
				in[i] = br.nextInt();
			}
			
			int[] dp = new int[N];
			
			dp[0] = 0;
			
			for(int i = 1; i < N; i++) {
				if(i == 1) {
					dp[i] = dp[i-1] + dist(i, i-1, in);
				}
				else {
					dp[i] = Math.min(dp[i-1] + dist(i,i-1,in), dp[i-2] + dist(i,i-2,in));
				}
			}
			
			pw.println(dp[N-1]);
			
			pw.close();
		}
		
		public static int dist(int i, int j, int[] in) {
			return Math.abs(in[i] - in[j]);
		}

	}

	//fastscanner class
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}
 



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

typedef long long ll;

int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  if(n>k){
    cout << k*x+(n-k)*y << endl;
  }else cout << n*x << endl;
  return 0;
}


Measured memory_bytes: 256
import math

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


x, y = map(int, input().split())
if ((x + y) % 3 != 0):
	print("0")
elif (x > 2*y or y > 2*x):
	print("0")
else:
	n_x = (2 * x - y) // 3
	n_y = (2 * y - x) // 3
	n_xy = (x + y) // 3
	print(cmb(n_xy,n_x)%1000000007)


Measured memory_bytes: 45840
#include<bits/stdc++.h>
using namespace std;
#define ioS            ios::sync_with_stdio(false);cin.tie(0);
#define li             long int
#define ll            long li
#define ull            unsigned ll
#define pi             pair<int,int>
#define vi             vector<int>
#define vli            vector<li>
#define vll           vector<ll>
#define vvi            vector<vector<int>>
#define pb             push_back
#define mp             make_pair
#define forn(i,s,n)    for(auto i=s;i<n;++i)               
#define forr(i,s,n)    for(auto i=s;i>=n;--i) 

void solve() 
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int op1 = 0;
    while(b<=a)
    {
        b = b*2;
        op1++;
    }
    int op2 = 0;
    while(c<=b)
    {
        c*=2;
        op2++;
    }
    if(op1 + op2 <= k)
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
}
int main() {
    int t;
    // cin>>t;
    // while(t--)
        solve();
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end

template<typename M,typename N=M>
struct LazySegmentTree{
    using F=function<M(M,M)>; using G=function<M(M,N)>; using H=function<N(N,N)>;
    int sz,height; vector<M> data; vector<N> lazy;
    const F f;const G g; const H h; const M m1; const N n1;
    LazySegmentTree(int n,const F f,const G g,const H h,const M &m1,const N n1):f(f),g(g),h(h),m1(m1),n1(n1){
        sz=1,height=0; while(sz<n)sz<<=1,height++;
        data.assign(2*sz,m1); lazy.assign(2*sz,n1);
    }
    void build(vector<M> v){
        rep(i,0,v.size())data[i+sz]=v[i];
        rrep(k,sz-1,0)data[k]=f(data[2*k],data[2*k+1]);
    }
    M ref(int k){return lazy[k]==n1?data[k]:g(data[k],lazy[k]);}
    void recalc(int k){while(k>>=1)data[k]=f(ref(2*k),ref(2*k+1));}
    void thrust(int k){rrep(i,height,0)eval(k>>i);}
    void eval(int k){
        if(lazy[k]!=n1){
            lazy[2*k]=h(lazy[2*k],lazy[k]); lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
            data[k]=ref(k); lazy[k]=n1;
        }
    }
    void update(int a,int b,N x){
        thrust(a+=sz); thrust(b+=sz-1);
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1)lazy[l]=h(lazy[l],x),++l;
            if(r&1)--r,lazy[r]=h(lazy[r],x);
        }
        recalc(a); recalc(b);
    }
    M query(int a,int b){
        thrust(a+=sz); thrust(b+=sz-1);
        M L=m1,R=m1;
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1)L=f(L,ref(l++)); if(r&1)R=f(ref(--r),R);
        } return f(L,R);
    }
};

typedef pair<int,pair<int,int>> T;

int main(){
    int n,k; scanf("%d%d",&n,&k);
    string s; cin>>s;
    LazySegmentTree<T> seg(n+2,
    [](T a,T b){return min(a,b);},
    [](T a,T b){return b;},
    [](T a,T b){return b;},{inf,{inf,inf}},{inf,{inf,inf}});
    seg.update(0,1,{0,{0,0}});
    rep(i,1,n+1){
        if(s[i]=='1')continue;
        int lb=max(i-k,0);
        T t=seg.query(lb,i);
        int d=t.first,last=t.second.first,v=t.second.second;
        if(d==inf){printf("-1\n"); return 0;}
        d++; last=v; v=i;
        seg.update(i,i+1,T{d,{last,v}});
    }
    vector<int> cur; int now=n;
    while(now){
        cur.push_back(now);
        T t=seg.query(now,now+1);
        now=t.second.first;
    }cur.push_back(0);
    reverse(ALL(cur));
    vector<int> ans;
    rep(i,0,cur.size()-1)ans.push_back(cur[i+1]-cur[i]);
    rep(i,0,ans.size())printf("%d\n",ans[i]);
    return 0;
}

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



int main() {
    ll n; cin >> n;
    ll a,b,sum = 0;
    string ans = "Yes";
    vector<pair<ll,ll>> mp(n);
    rep(i,n){
        cin >> a >> b;
        mp[i] = make_pair(b,a);
    }
    sort(mp.begin(),mp.end());

    rep(i,n){

        sum += mp[i].second;
        if(sum > mp[i].first) {
            ans = "No";
            break;
        }


    }

    cout << ans;
    return 0;
}











Measured memory_bytes: 6436
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

constexpr long long MOD = 1000000007;

int main()
{
  int x, y, z, k;
  std::cin >> x >> y >> z >> k;
  std::vector<long long> a(x);
  for (auto& val: a)
    std::cin >> val;
  std::vector<long long> b(y);
  for (auto& val: b)
    std::cin >> val;
  
  std::vector<long long> d;
  d.reserve(x * y);
  for (auto& va: a)
  {
    for (auto& vb: b)
    {
      d.push_back(va + vb);
    }
  }
  std::sort(begin(d), end(d), std::greater<long long>{});

  std::vector<long long> c(y);
  for (auto& val: c)
    std::cin >> val;
  std::sort(begin(c), end(c), std::greater<long long>{});

  int limit = std::min(k, x * y);
  std::vector<long long> ans;
  ans.reserve(limit * z);
  for (int i = 0; i < limit; ++i)
  {
    for (int j = 0; j < c.size(); ++j)
    {
      ans.push_back(d[i] + c[j]);
    }
  }
  std::sort(begin(ans), end(ans), std::greater<long long>{});
  for (int i = 0; i < k; ++i)
    std::cout << ans[i] << "\n";
  std::cout << std::flush;

  return 0;
}



Measured memory_bytes: 31616
#include <stdio.h>
#include <stdlib.h>

int main(void){
  long N;
  scanf("%ld",&N);

  long x,y,t;
  long px = 0,py = 0,pt = 0;

  for(int i = 0;i < N;i++){
    scanf("%ld%ld%ld",&t,&x,&y);
    long distance = abs(x-px)+abs(y-py);
    if(distance <= t-pt){
      distance -= (t-pt);
      if(distance%2 != 0){
        printf("No\n");
        return 0;
      }
    }else{
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");
  return 0;
}

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

int n, s;
// sum <= 10 * 9 + 9 * 8 + 8 * 7 ...
int memo[10][1 << 10][400];

int dfs(int now, int bit, int sum) {
  if (now >= n) return sum == s;
  if (sum > s) return 0;
  if (memo[now][bit][sum] != -1) return memo[now][bit][sum];

  int ret = 0;
  for (int i = 0; i < 10; ++i) {
    if (!(bit & (1 << i))) {
      ret += dfs(now + 1, bit | (1 << i), sum + i * (now + 1));
    }
  }
  return memo[now][bit][sum] = ret;
}

int main() {
  while (cin >> n >> s) {
    memset(memo, -1, sizeof(memo));
    cout << dfs(0, 0, 0) << endl;
  }
}

Measured memory_bytes: 19084
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;
int ex[1000];

int main(void){
    string s;
    cin>>s;
    for(int i=0;i<1000;i++)ex[i]=0;
    for(auto x:s){
        ex[(int)x]++;
    }
    for(int i=0;i<1000;i++){
        if(ex[i] != 0 && ex[i] != 2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

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

  vector<int64_t> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());

  vector<int64_t> sum(N);
  sum[0] = A[0];
  for (int i = 1; i < N; ++i) sum[i] = sum[i-1] + A[i];

  reverse(A.begin(), A.end());
  reverse(sum.begin(), sum.end());

  int64_t ans = 1;
  for (int i = 1; i < N; ++i) {
    if (2 * sum[i] >= A[i - 1]) {
      ans++;
    } else break;
  }

  cout << ans << endl;
}


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

int main(){
  int A, B, x=0;
  cin >> A >>B;
  for(int i = A;i <= B;i++){
    int a, b, c, d;
    a = A / 10000;
    b = A / 1000 % 10;
    c = A / 10 % 10;
    d = A % 10;
    if(a == d && b == c){
      x++;
    }
    A++;
  }
  cout << x <<endl;
}

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    VI cost(5);
    REP(i, 5) {
        cin >> cost[i];
    }
    sort(ALL(cost));
    int ans = 1012345678;
    do {
        int tempans = 0;
        REP(i, 5) {
            while (tempans % 10) tempans++;
            tempans += cost[i];
        }
        ans = min(ans, tempans);
    } while (next_permutation(ALL(cost)));

    cout << ans << ln;

    return 0;
}


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

int main(){
  long long int N;
  cin>>N;
  
  if(N==1){
    cout<<1<<endl;
  }

  else{
  
  for(long long int i=2;i<=N;i++){
    
    if(i*i>N){
      cout<<(i-1)*(i-1)<<endl;
      break;
    }
  }
  }

}
  


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

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            var count = 0;
            while((count = int.Parse(Console.ReadLine())) != 0) {
                var value = Console.ReadLine();
                var temp = new StringBuilder(200);
                while(--count >= 0) {
                    var list = new List<string>();
                    list.Add(value[0].ToString());
                    for(int i = 1; i < value.Length; i++) {
                        if(list[list.Count - 1][0] == value[i]) {
                            list[list.Count - 1] += value[i];
                        }
                        else {
                            list.Add(value[i].ToString());
                        }
                    }
                    for(int i=0; i < list.Count; ++i) {
                        temp.Append(list[i].Length);
                        temp.Append(list[i][0]);
                    }
                    value = temp.ToString();
                    temp.Length = 0;
                }
                Console.WriteLine(value);
            }
        }
    }
}

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

const int mod = 1e9+7;

int64_t modstr(const string &s, int64_t mod) {
  int64_t a = 0;
  for (auto &c : s) {
      a = (c - '0' + a * 10) % mod;
  }
  return a;
}

signed main() {
	int n;
	cin >> n;
  printf("ABC%03d\n", n);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        int s[n];
        int sum = 0;
        rep(i, 0, n) {
            cin >> s[i];
            sum += s[i];
        }
        double ave = 1.0 * sum / n;
        double v = 0;
        rep(i, 0, n) {
            v += (s[i] - ave) * (s[i] - ave);
        }
        v /= n;
        cout << fixed << setprecision(10);
        cout << sqrt(v) << endl;
    }
    return 0;
}



Measured memory_bytes: 3228
#include <cstdio>

int pi[233333],pp[444444][2],pk[233333],pz[233333],pl[233333];

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	for(int i=1,j=0; i<=m; i++)
	{
		int a,b; scanf("%d%d",&a,&b);
		pp[++j][0]=b; pp[j][1]=pi[a]; pi[a]=j;
		pp[++j][0]=a; pp[j][1]=pi[b]; pi[b]=j;
	}
	for(int i=2; i<=n; i++) pk[i]=233333;
	pl[++pl[0]]=1;
	int k=1;
	while(k<=pl[0])
	{
		int p=pl[k]; k++;
		int i=pi[p];
		while(i!=0)
		{
			if(pk[pp[i][0]]>pk[p]+1)
			{
				pk[pp[i][0]]=pk[p]+1;
				pl[++pl[0]]=pp[i][0];
				pz[pp[i][0]]=p;
			}
			i=pp[i][1];
		}
	}
	for(int i=2; i<=n; i++) if(pz[i]==0)
	{
		printf("No"); return 0;
	}
	printf("Yes\n");
	for(int i=2; i<=n; i++) printf("%d\n",pz[i]);
	return 0;
}

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

int main() {
    ll X;
    cin >> X;
    for (ll x=X;; ++x) {
        ll tmp = sqrt(x);
        bool ok = true;
        for (ll s=2; s<=tmp; ++s) {
            if (x%s == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }
}


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

int main() {
    int x, y;
    cin >> x >> y;
    bool ans = false;
    for (int i = 0; i <= x; i++) {
        if (i * 4 + (x - i) * 2 == y) {
            ans = true;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3636
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.next()
    val b = sc.next()
    val c = sc.next()
    if (a.last() == b.first() && b.last() == c.first()) {
        println("YES")
    } else {
        println("NO")
    }
}

Measured memory_bytes: 31392
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;

int main(){
lint N,ans=0;
cin >>N; lint M[N];
rep(i,N)cin >> M[i];
rep(i,N){
  repp(j,i+1,N){
  ans+=M[j]*M[i];
  }
}
cout<<ans;
}

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) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String s = reader.readLine();
			String t = reader.readLine();
			int n = Integer.parseInt(s);
			int[] a = new int[n];
			String[] b = t.split(" ");

			long sum = 0;
			for (int i = 0; i < n; i++) {
				a[i] = Integer.parseInt(b[i]);
				sum += a[i];
			}
			int max = a[0];
			for (int j = 1; j < n; j++) {
				if (max < a[j]) {
					max = a[j];
				}
			}
			
			int min = a[0];
			for (int k = 1; k < n; k++) {
				if (min > a[k]) {
					min = a[k];
				}
			}
			
			System.out.println(min + " " + max + " " + sum);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 28600
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    int a[10000];
    int cnt,i,turn,n;
    while(cin>>n&&n){
        turn=0,cnt=31;
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        cout<<"31"<<endl;
        while(cnt>=a[turn%n]){
            cnt-=a[turn%n];
            turn++;
            if(cnt==0) break;
            cout<<cnt<<endl;
            cnt-=(cnt+4)%5;
            cout<<cnt<<endl;
        }
        cout<<"0"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

main(){
    int tcase, m; cin >> tcase;
    string s1, s2, s3;
    for ( int i = 0; i < tcase; i++ ){
	cin >> s1 >> s2; s3 = "";
	m = max(s1.size(), s2.size());
	while( s1.size() < m ) s1 = '0' + s1;
	while( s2.size() < m ) s2 = '0' + s2;
	int c = 0;
	for ( int i = m-1; i >= 0; i-- ){
	    char ch = ((s1[i]-'0')+(s2[i]-'0')+c)%10 + '0';
	    c = ((s1[i]-'0')+(s2[i]-'0')+c)/10;
	    s3 += ch;
	}
	if ( c ) s3 += c+'0';
	reverse(s3.begin(), s3.end());
	while( s3.size() > 1 && s3[0] == '0' ) s3.erase(s3.begin());
	if ( s3.size() > 80 ) cout << "overflow" << endl;
	else cout << s3 << endl;
    }
}

Measured memory_bytes: 0
n = gets.to_i
ss = gets.chomp.chars
ans = ss.count("R") * ss.count("G") * ss.count("B")

0.upto(n) do |i|
  # j = 1

  1.upto(n / 2) do |d|
    j = i + d
    k = i + d * 2
    next unless k < n
    # end
    # while i + 2 * j < n
    #   k = i + 2 * j

    a = ss[i]
    b = ss[j]
    c = ss[k]
    ans -= 1 if a != b && b != c && c != a

    j += 1
  end
end

puts ans


Measured memory_bytes: 14316
from collections import Counter

mod = 10**9 + 7

N = int(input())

c = Counter()

import math
def factoring(n):
    sup = math.floor(pow(n,1/2))
    for i in range(2,sup + 1):
        while n % i == 0:
            n //= i
            c[i] += 1
    if n != 1:
        c[n] += 1

    
for i in range(1,N+1):
    factoring(i)

c = c.values()

ans = 1
for i in c:
    ans *= i+1
    ans %= mod

print(ans)

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

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

    sort(a, a+N);

    int ans = 1;

    for(int i = 0; i < N-1; i++){
        if(a[i+1]-a[i] != 0) ans++;
    }

    cout << ans << endl;
}

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

int main(){
	int N;
    cin>>N;
  vector<int> vec(N);

  for(int i=0;i<N;i++)
    cin>>vec.at(i);
  
  sort(vec.begin(),vec.end());
  cout<<vec.at(N-1)-vec.at(0)<<endl;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, K, Q;
int A[2000];

int z[2000];

signed main(){
    cin >> N >> K >> Q;
    rep(i, N){
        cin >> A[i];
        z[i] = A[i];
    }
    sort(z, z+N);

    int ans = INT_MAX;
    rep(i, N){
        int g[2000];
        int siz[2000] ={};
        int k = 0;
        priority_queue<pair<int, int>> pq;
        rep(j, N){
            if(A[j] < z[i]){
                k++;
            }
            else{
                g[j] = k;
                siz[k]++;
                pq.push({ -A[j],j });
            }
        }
        int tmp = 0;
        rep(j, Q){
            while(pq.size() > 0 && siz[g[pq.top().second]] < K) pq.pop();
            if(pq.empty()){
                tmp = INT_MAX;
                break;
            }
            tmp = max(tmp, -pq.top().first);
            siz[g[pq.top().second]]--;
            pq.pop();
        }
        ans = min(ans, tmp-z[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <stack>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
    int n,a,b,count=0,ans=0;
    
    scanf("%d%d",&n,&count);
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        
        count+=a-b;
        
        if(count<0){
            puts("0");
            return 0;
        }
        
        ans=max(ans,count);
    }
    
    printf("%d\n",ans);
    
    return 0;
}
    

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

signed main() {
  int W, H, N;
  cin >> W >> H >> N;
  
  vector<int> yoko(W, 1);
  vector<int> tate(H, 1);
  
  int X, Y, A;
  for( int i = 0; i < N; i++ ){
    cin >> X >> Y >> A;
    if( A == 1 ){
      for( int i = 0; i < min( W, X ); i++ ){
        yoko.at(i) = 0;
      }
    }else if( A == 2 ){
      for( int i = X; i < W; i++ ){
        yoko.at(i) = 0;
      }
    }else if( A == 3 ){
      for( int i = 0; i < min( H, Y ); i++ ){
        tate.at(i) = 0;
      }
    }else if( A == 4 ){
      for( int i = Y; i < H; i++ ){
        tate.at(i) = 0;
      }
    }
  }
  
  int ans = 0;
  for( int i = 0; i < H; i++ ){
    for( int j = 0; j < W; j++ ){
      ans += tate.at(i)*yoko.at(j);
    }
  }
  cout << ans << endl;
      
  
      
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	string s; cin >> s;
	FOR_LT(i, 0, s.size()) {
		char c = s[i];
		c += n;
		if ('Z' < c) c -= 26;
		s[i] = c;
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
using ll = long long;

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

class FenwickTree {
public:
	FenwickTree(int _n) : n(_n) { v.resize(_n + 1, 0); }

	void add(int pos, long long val) {
		pos++;
		for (int i = pos; i <= n; i += i & (-i))
			v[i] += val;
	}

	// sum [l, r]
	long long sum(int l, int r) { return sum(r) - sum(l - 1); }

	// sum [0,pos]
	long long sum(int pos) {
		pos++;
		long long ret = 0;
		for (int i = pos; i > 0; i -= i & (-i))
			ret += v[i];
		return ret;
	}

private:
	int n;
	std::vector<long long> v;
};

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> cnt(26);
	REP(i, n) cnt[s[i] - 'a']++;
	int k = -1;
	{
		int tmp = 0;
		REP(i, 26) {
			if (cnt[i] % 2 == 1) {
				tmp++;
				k = i;
			}
		}
		if (tmp != n % 2) {
			cout << -1 << endl;
			return 0;
		}
	}
	vector<int> l, r;
	vector<int> cnt2(26, 0);
	int kp = -1;
	REP(i, n) {
		if (cnt2[s[i] - 'a'] < cnt[s[i] - 'a'] / 2) {
			l.push_back(i);
		}
		else {
			if (n % 2 == 1 && k == s[i] - 'a' && cnt2[k] == cnt[k] / 2)kp = i;
			else r.push_back(i);
		}
		cnt2[s[i] - 'a']++;
	}

	ll ans = 0;
	REP(i, n / 2) { ans += l[i] - i; }
	REP(i, n / 2)if (r[i] < kp)ans++;
	vector<vector<int>> pos(26);
	REP(i, n / 2) { pos[s[l[i]] - 'a'].push_back(i); }
	FenwickTree bit(n / 2);
	vector<int> ind(26);
	REP(i, n / 2) {
		char c = s[r[n / 2 - 1 - i]];
		int p = pos[c - 'a'][ind[c - 'a']];
		ind[c - 'a']++;
		ans += -bit.sum(p) + p;
		bit.add(p, 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
int main(){
   int k,t,c=0;
   cin >> k >> t;
   for(int i=0;i<t;i++){
       int a;
       cin >> a;
       c = max(a,c);
   }
   if(t!=1) cout << max(c-1-(k-c),0) << endl;
   else cout << c-1 << endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	while(cin>>N){
		int num=0;
		for(int a=0,ea=min(9,N);a<=ea;a++){
			for(int b=0,eb=min(9,N);b<=eb;b++){
				for(int c=0,ec=min(9,N);c<=ec;c++){
					int d=N-a-b-c;
					if(0<=d && d<=9) num++;
				}
			}
		}
		out(num);
	}

	return 0;
}


Measured memory_bytes: 3096
/**
 *      ABC 86 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-01 04:52:53
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b; cin >> a >> b;

    string s;
    s = to_string(a) + to_string(b);
    //cout << s << endl;
    int ss = atoi(s.c_str());

    int square = sqrt((double)ss);
    square * square == ss ? cout << "Yes" : cout << "No";

    return 0;
}

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

long long X, Y;

int main(){
  cin >> X >> Y;
  if(X%Y==0){
    cout << -1 << endl;
    return 0;
  }
  int i = 1;
  while(1){
    if(X*i % Y != 0){
      cout << X*i << endl;
      return 0;
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
int main(){
	int a,i,s,ma=0,mi=1000;
	for(i=0;i<6;i++){
		scanf("%d", &a);
		if(a>ma)
		ma=a;
		if(a<mi)
		mi=a;
	}
	if(ma-mi<=a)
	printf("Yay!");
	else
	printf(":(");
	
	
	
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

//10進数をbit文字列に変換する。 7→"111"
string to_binString(unsigned int val){
    if( !val )
        return std::string("0");
    std::string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  // val は偶数か？
            str.insert(str.begin(), '0');  //  偶数の場合
        else
            str.insert(str.begin(), '1');  //  奇数の場合
        val >>= 1;
    }
    return str;
}

//2進数(文字列)を10進数(ll)に
ll strbin2i (const string &s) {
    ll out = 0;
    for (int i = 0, size = s.size() ; i < size ; ++i ) {
        out *= 2;
        out += ((ll)s[i] == 49) ? 1 : 0;
    }
    return out;
}

// nビットにするために0を先頭に加える 111→0111
string bit0(int n, string &str){
    if(str.size() < n){
        string t(n-str.size(),'0');
        str = t + str;
    }
    return str;
}


// g++ -std=c++11 prac.cpp 
int main(){
    ll x,y,z,n,m=0,k,h,w,sum=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u,v;
    bool ok=false;
    cin >> n;
    VL a(1234567);
    m = 1;
    while(sum < n){
        sum += m;
        a[m-1] = m;
        m++;
    }
    rep(i,m-1){
        if(a[i] != sum-n){
            cout << a[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
  
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int a,b,c,d;cin>>a>>b>>c>>d;
        while(1){
            c=c-b;
            if(c<=0){
                cout<<"Yes";return 0;
            }
            a=a-d;    
            if(a<=0){
                cout<<"No";return 0;
            }
        }
    }   
    timecalculater();
    return 0;   
} 

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

int bubbleSort(vector<pair<char,int>> &A,int N){
  
  bool flag = 1;
  for(int i=0; flag;i++){
    flag = 0;
    for(int j = N-1;j>=i+1;j--){
      if(A[j].second < A[j-1].second){
        //隣接要素を交換する
        swap(A[j],A[j-1]);
        flag = 1;
      }
    }
  }
} 


int selectionSort(vector<pair<char,int>> &a,int n){
  int i,j,minj;
  
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(a[j].second < a[minj].second){
        minj = j;
      }
    }
    swap(a[i],a[minj]);
  }
}

bool isStable(vector<pair<char,int>> a,vector<pair<char,int>> b,int n){
  rep(i,n) if(a[i].first != b[i].first) return false;
  return true;
}

int main(){
  int n;
  cin >> n;
  vector<pair<char,int>> a(n),b(n);
  rep(i,n){
    cin >> a[i].first >> a[i].second;
    b[i] = a[i];
  }
  
  bubbleSort(a,n);
  selectionSort(b,n);
  
  rep(i,n){
    if(i!=n-1){
      cout << a[i].first <<a[i].second<< " ";
    }else{
      cout << a[i].first <<a[i].second<< endl;
    }
  }
  
  cout << "Stable" << endl;
  
  rep(i,n){
    if(i!=n-1){
      cout << b[i].first <<b[i].second<< " ";
    }else{
      cout << b[i].first <<b[i].second<< endl;
    }
  }
  
  if(isStable(a,b,n)){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3112
# -*- coding: utf-8 -*-
"""
B - 0 or 1 Swap
https://atcoder.jp/contests/abc135/tasks/abc135_b

"""
import sys


def solve(N, arr):
    res = sum(a != b for a, b in zip(arr, sorted(arr)))
    return 'YES' if res <= 2 else 'NO'


def main(args):
    N = int(input())
    arr = [int(p) for p in input().split()]
    ans = solve(N, arr)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060