akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;



//x以上の最小の素数を返すようにする
int funny(ll x){
  if(x<=1) return 0;
  for(int i=2;i*i<=x;i++){
    if(x%i==0){
      return 0;
      break;
    }
  }
  return 1;
}

int main(){
  ll x;
  cin>>x;
  ll p=x;
  while(!funny(p)){
    p++;
  }
  cout<<p<<endl;
  return 0;
}





Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	N = int(input())
	A = getlist()
	ans = 0
	for i in range(N):
		if i % 2 == 0 and A[i] % 2 == 1:
			ans += 1

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 64764
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
int w[300000];
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>();
	rep(i, 0, n-1) w[next<int>()]++;
	hrp(i, 1, n) cout<<w[i]<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 5168
N,M,Q = map(int,input().split())
lr = [[0,0] for _ in range(M)]
pq = [[0,0] for _ in range(Q)]
L = [[0]*N for _ in range(N)]
for i in range(M):
    lr[i][0], lr[i][1] = map(int,input().split())
    L[lr[i][0]-1][lr[i][1]-1] += 1
for i in range(Q):
    pq[i][0], pq[i][1] = map(int,input().split())
    pq[i][0] -= 1
    pq[i][1] -= 1
L_sum = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == 0 and j == 0:
            L_sum[i][j] = L[i][j]
        if i == 0 and j != 0:
            L_sum[i][j] = L[i][j] + L_sum[i][j-1]
        if i != 0 and j == 0:
            L_sum[i][j] = L[i][j] + L_sum[i-1][j]
        if i != 0 and j != 0:
            L_sum[i][j] = L[i][j] + L_sum[i][j-1] + L_sum[i-1][j] - L_sum[i-1][j-1]
for i in range(Q):
    if pq[i][0] == 0:
        print(L_sum[pq[i][1]][pq[i][1]])
    else:
        print(L_sum[pq[i][1]][pq[i][1]]-L_sum[pq[i][0]-1][pq[i][1]])

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];
	
	vl b;
	FOR(i,0,n) {
		ll k = upper_bound(all(b),a[i],greater<ll>()) - begin(b);;
		if (k == sz(b)) b.pb(a[i]);
		else b[k] = a[i];

	}
	cout << sz(b) << endl;
}



Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e12+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;
#define print1(x) cerr << "x = " << x << endl;
#define print2(x, y) cerr<< "x,y = "  << x << "," << y << endl;
#define print3(x, y, z) cerr << "x,y,z = " << x << "," << y << "," << z << endl;
#define print4(x, y, z, w) cerr << "x,y,z,w = " << x << "," << y << "," << z << "," << w << endl;
const ll MAX = ll(1e10) * 300 + 10;
ll dp[310][int(1e3+10)];
ll A[int(1e5) + 1];
ll S[int(1e5) + 2];
ll ANS[int(1e5) + 2];
vector<pair<ll, ll> > P;

ll N, M;
ll mod = 1000000007;
int main()
{
    ll ans = 1;
    ll x, maxa = 0;
    cin >> N;
    
    rep(i, N){
        cin >> A[i];
        A[i]++;
        maxa = max(maxa, A[i]);
    }
    rep(i, maxa + 2)ANS[i] = 1LL;
    
    S[0] = 3;
    rep(i, N){
        ll x = A[i];
        S[x]++;
        //fprintf(stderr, "ANS [%d] *= %d\n", x-1, S[x - 1]);
        (ANS[x - 1] *= S[x - 1]) %= mod;
            
        S[x - 1]--;
    }
    for (int i = 0; i < maxa; i++){
        (ans *= ANS[i]) %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int H,W,h,w;
  cin >>  H >> W >> h >> w;
  cout << H*W-h*W-w*H+h*w << endl;
  return 0;
}


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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;

bool search(vector<int> p, int x) {
	bool res = false;
	for (auto a : p) {
		if (a == x) {
			res = true;
			break;
		}
	}

	return res;
}

int main(void) {
	int X, N; cin >> X >> N;
	vector<int> p(N); rep(i, N)cin >> p[i];

	int ans = 0;
	int cnt = 0;
	while (true) {
		if (!search(p, X - cnt)) {
			ans = X - cnt;
			break;
		}
		if (!search(p, X + cnt)) {
			ans = X + cnt;
			break;
		}
		cnt++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll(i) = 0; i < (ll)(n); ++(i))
#define INF 10e12
#define MOD 1000000000 + 7
#define MX 51000
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))

using namespace std;

struct nap
{
    ll w;
    ll v;
};

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N);
    vector<ll> v(N);
    for (ll i = 0; i < N; ++i)
    {
        ll a, b;
        cin >> a >> b;
        w[i] = a;
        v[i] = b;
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1));
    rep(i, W + 1)
        dp[0][i] = 0;
    rep(i, N)
    {
        rep(j, W + 1)
        {
            if (j >= w[i])
                dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }
    cout << dp[N][W] << endl;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    int n,k;
    cin>>n>>k;
    vector<int> a(n+1);
    rep(i,n) cin >> a[i+1];
    
    rep(dj,k){
        vec b(n+2);
        for(int i=1;i<=n;i++){
                int mi=max(1LL,i-a[i]);
                int ma=min(n+1,i+a[i]+1);
                b[mi]++;
                b[ma]--;
            
        }
        rep(i,n) b[i+1]+=b[i];
        int ng=0;
        rep(i,n) if(b[i+1]!=n) ng++;
        
        rep(i,n) swap(a[i+1],b[i+1]);
        if(ng==0) break;
    }
    
    rep(i,n) cout<<a[i+1]<<" ";
    cout<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 11120
#include <bitset>
#include <cstdio>
#include <iostream>
#include <string>

std::string getEquation(const int a, const int b, const int c, const int d) {
  for (int i = 0; i < 8; ++i) {
    const std::bitset<3> sign_bits(
        static_cast<unsigned long>(i));  // set: +, unset: -
    int total = a;
    if (sign_bits[0]) {
      total += b;
    } else {
      total -= b;
    }
    if (sign_bits[1]) {
      total += c;
    } else {
      total -= c;
    }
    if (sign_bits[2]) {
      total += d;
    } else {
      total -= d;
    }
    if (total == 7) {
      char result_string[100];
      std::sprintf(result_string, "%d%s%d%s%d%s%d=7", a,
                   (sign_bits[0] ? "+" : "-"), b, (sign_bits[1] ? "+" : "-"), c,
                   (sign_bits[2] ? "+" : "-"), d);
      return result_string;
    }
  }
  return "";
}

int main() {
  std::string input;
  std::cin >> input;
  std::cout << getEquation(input[0] - '0', input[1] - '0', input[2] - '0',
                           input[3] - '0')
            << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <string_view>
#include <vector>
#include <map>

#include <cmath>
#include <cctype>

int main() {
  long N;
  std::cin >> N;

  std::map<std::string, long> cnt_results;

  std::string result;
  for (long i = 0; i < N; ++i) {
    std::cin >> result;
    ++cnt_results[result];
  }

  std::cout << "AC x " << cnt_results["AC"] << '\n'
            << "WA x " << cnt_results["WA"] << '\n'
            << "TLE x " << cnt_results["TLE"] << '\n'
            << "RE x " << cnt_results["RE"] << '\n';
}


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

typedef pair<int,int> P;
int main(){
  int n,k;
  cin >> n >> k;
  vector<char> s(n);
  for(int i = 0;i < n;i++){
    cin >> s.at(i);
  }
  vector<P> seq;
  int cur = 0,x = 0;
  for(int i = 0;i < n-1;i++){
    if(s.at(i) == s.at(i+1)){
      cur++;
    }
    else{
      seq.push_back({cur,x});
      cur = 0;
      x = i+1;
    }
  }
  seq.push_back({cur,x});
  int ans = 0;
  /*for(int i = 0;i < seq.size();i++){
    ans += seq.at(i);
  }*/
  int y = seq.size();
  /*for(int i = 0;i < y;i++){
    cout << seq.at(i).first << ' ' << seq.at(i).second << endl;
  }*/
  for(int i = 1;i < y;i += 2){
    if(k == 0) break;
    for(int j = seq.at(i).second;j <= seq.at(i).second+seq.at(i).first;j++){
      //cout << j << endl;
      if(s.at(j) == 'L') s.at(j) = 'R';
      else s.at(j) = 'L';
    }
    k--;
  }
  /*for(int i = 0;i < s.size();i++){
    cout << s.at(i);
  }*/
  cur = 0;
  for(int i = 0;i < n-1;i++){
    if(s.at(i) == s.at(i+1)){
      cur++;
    }
    else{
      ans += cur;
      cur = 0;
    }
  }
  ans += cur;
  cout << ans << endl;
}

Measured memory_bytes: 1528
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] a;
    int i, j, count, tmp;

    n = sc.nextInt();
    a = new int[n];
    for(i = 0;i < n;i++){
      a[i] = sc.nextInt();
    }

    count = 0;

    for(i = 0;i < n - 1;i++){
      for(j = 0;j < n - 1 - i;j++){
        if(a[j] > a[j + 1]){
          tmp = a[j];
          a[j] = a[j + 1];
          a[j + 1] = tmp;
          count++;
        }
      }
    }

    for(i = 0;i < n - 1;i++){
      System.out.print(a[i] + " ");
    }
    System.out.println(a[n - 1]);
    System.out.println(count);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 19232
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

char ca[100];

int main(){
	int a,b,c=0;
	cin>>a;
	b=a%100,a/=100;
	if(1<=a && a<=12)c++;
	if(1<=b && b<=12)c+=2;
	if(c==0)cout<<"NA"<<endl;
	if(c==1)cout<<"MMYY"<<endl;
	if(c==2)cout<<"YYMM"<<endl;
	if(c==3)cout<<"AMBIGUOUS"<<endl;
}


Measured memory_bytes: 256
def main():
    N, K = (int(i) for i in input().split())
    if (N-1)*(N-2)//2 < K:
        return print(-1)
    need_reduce = (N-1)*(N-2)//2 - K
    M = (N-1) + need_reduce
    ans = [[1, j] for j in range(2, N+1)]
    i = 2
    while need_reduce > 0:
        j = i+1
        while j <= N and need_reduce > 0:
            ans.append([i, j])
            j += 1
            need_reduce -= 1
        i += 1
    print(M)
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43376
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n, m, x1, x2, y1, y2;
    static int[][] edge;
    public static void main(String[] args) {
        while(read()){
            solve();
        }
    }

    static boolean read(){
        if(!sc.hasNext())return false;
        n = sc.nextInt();
        m = sc.nextInt();
        edge = new int[m+1][m+1];
        for(int a[] : edge)Arrays.fill(a, 1 << 29);
        String[] input = new String[4];
        for(int i = 0; i < m; i++){
            input = sc.next().split(",");
            edge[Integer.parseInt(input[0])][Integer.parseInt(input[1])] = Integer.parseInt(input[2]);
            edge[Integer.parseInt(input[1])][Integer.parseInt(input[0])] = Integer.parseInt(input[3]);
        }
        input = sc.next().split(",");
        x1 = Integer.parseInt(input[0]);
        x2 = Integer.parseInt(input[1]);
        y1 = Integer.parseInt(input[2]);
        y2 = Integer.parseInt(input[3]);
        return true;
    }

    static void solve(){
        for(int k = 0; k < m; k++){
            for(int i = 0; i < m; i++){
                for(int j = 0; j < m; j++){
                    edge[i][j] = Math.min(edge[i][j], edge[i][k] + edge[k][j]);
                }
            }
        }
        System.out.println(y1-y2-edge[x1][x2]-edge[x2][x1]);
    }

}

Measured memory_bytes: 12000
N,M = map(int,input().split())
A_list = []
for i in range(N):
    A_list.append(list(map(int,input().split())))

cnt = 0    
for m in range(1,M+1):
    for n in range(N):
        if not m in A_list[n][1:]:
            break
    else:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
ll n,a,b;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>a>>b;
	if (a>b) swap(a,b);
	if ((b-a)%2==0) cout<<(b-a)/2;
	else{
		ll ans=min((b-a-1)/2+a-1+1,(b-a-1)/2+n-b+1);
		cout<<ans<<endl;
	}
	return 0; 
}

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

int main(){
	string s;
	long n;
	cin >> s >> n;
	
	bool a=false, b=false;	
	
	//multiplication-first
	stack<long> st;
	int now=0;
	long m=0;
	while(now<s.size()){
		if('0'<=s[now] && s[now]<='9') st.push(s[now++]-'0');
		else{
			if(s[now]=='*'){
				long v=st.top();
				st.pop();
				st.push(v*(s[now+1]-'0'));
				now+=2;
			}	
			else now++;
		}		
	}
	while(!st.empty()){
		m+=st.top();
		st.pop();
	}
	
	if(m==n) a=true;
	//printf(" a: m=%ld\n", m);
	
	//left-to-right
	now=0;
	m=0;
	while(now<s.size()){
		if('0'<=s[now] && s[now]<='9') st.push(s[now++]-'0');
		else{
			if(s[now]=='*'){
				long v=st.top();
				st.pop();
				st.push(v*(s[now+1]-'0'));
				now+=2;
			}
			else if(s[now]=='+'){
				long v=st.top();
				st.pop();
				st.push(v+(s[now+1]-'0'));	
				now+=2;	
			}	
		}			
	}
	while(!st.empty()){
		m+=st.top();
		st.pop();
	}
	
	if(m==n) b=true;
	//printf(" b: m=%ld\n", m);
	
	
	if(a&&b) printf("U\n");
	else if(a&&!b) printf("M\n");
	else if(!a&&b) printf("L\n");
	else if(!a&&!b) printf("I\n");
}

Measured memory_bytes: 1184
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w,k = map(int,input().split())
k -= 1

dp = [[0]*w for _ in range(h+1)] # 横棒i本のときの0->jに至るくじ

dp[0][0] = 1

d = {}
M = 10**9+7
def sub(i):
    # i本棒がある区間の横棒の入れ方
    if i in d:
        return d[i]
    if i<=1:
        ans = 1
    else:
        ans = sub(i-1) + sub(i-2)
    ans %= M
    d[i] = ans
    return ans
    

for i in range(1,h+1):
    for j in range(w):
        if j>=1:
            dp[i][j] += dp[i-1][j-1]*sub(j-1)*sub(w-j-1)
        if j<=w-2:
            dp[i][j] += dp[i-1][j+1]*sub(j)*sub(w-j-2)
        dp[i][j] += dp[i-1][j]*sub(j)*sub(w-j-1)
        dp[i][j] %= M
print(dp[h][k])

Measured memory_bytes: 38640
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    long long n,mx=1ll*int(1e6)+10;
    cin>>n;
    set<long long> st;
    vector<long long> fc,nfc;
    for(long long i=1;i<=mx;i++){
        if((n-1)%i==0){
            nfc.pb(i);
            nfc.pb((n-1)/i);
        }
        if(n%i==0){
            fc.pb(i);
            fc.pb(n/i);
        }
    }

    long long tmpn=n;
    for(int i=0;i<fc.size();i++){
        tmpn=n;
        if(fc[i]<=n && fc[i]>1){
            while(tmpn%fc[i]==0){
                tmpn/=fc[i];
            }
            if(tmpn%fc[i]==1 || tmpn==1){
                st.insert(fc[i]);
            }
        }
    }  

    for(int i=0;i<nfc.size();i++){
        if(nfc[i]<=n && n%nfc[i]==1){
            if(nfc[i]>1)
                st.insert(nfc[i]);
        }
    }
    cout<<st.size()<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;

    string str1 = "GREATER";
    string str2 = "LESS";
    string str3 = "EQUAL";


    if(a.size() > b.size()){
        cout << str1 << endl;

    }else if(a.size() < b.size()){
        cout << str2 << endl;
    }else{
        for(int i =0; i <100; i++){
            if(a > b){
                cout << str1 << endl;
                break;
            }else if(a < b){
                cout << str2 << endl;
                break;
            }else{
                ;
            }
            cout << str3 << endl;
            return 0;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    int ans = 0;
    if(2*C >= A + B){
        ans = A*X + B*Y;
    }else if(X >= Y){
        if(2*C >= A){
            ans = 2*C*Y + A*(X - Y);
        }else{
            ans = 2*C*X;
        }
    }else if(X < Y){
        if(2*C >= B){
            ans = 2*C*X + B*(Y - X);
        }else{
            ans = 2*C*Y;
        }
    }
    
    cout << ans << endl;
    
    
    return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  ll ans = 0;
  rep(i,n){
    ll a;
    cin >> a;
    bool ok = i % 2 == 0 && a % 2 == 1;
    if(ok) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt(), w = in.nextInt();
		char[][] map = new char[h][w];
		in.nextLine();
		for ( int i = 0; i < h; i++ ) {
			map[i] = in.nextLine().toCharArray();
		}
		in.close();

		int[][] hmap = new int[h][w]; // 横方向
		int[][] vmap = new int[h][w]; // 縦方向
		int cnt = 0;
		
		// 横の処理
		for ( int r = 0; r < h; r++ ) {			
			for ( int c = 0; c < w; c++ ) {
				cnt = 0;
				while ( c + cnt < w && map[r][c + cnt] == '.' ) {
					cnt++;
				}
				for ( int i = c; i < c + cnt; i++ ) {
					hmap[r][i] = cnt;
				}
				c += cnt;
			}
		}

		// 縦の処理
		for ( int c = 0; c < w; c++ ) {
			for ( int r = 0; r < h; r++ ) {
				cnt = 0;
				while ( r + cnt < h && map[r + cnt][c] == '.' ) {
					cnt++;
				}
				for ( int i = r; i < r + cnt; i++ ) {
					vmap[i][c] = cnt;
				}
				r += cnt;
			}
		}

		int ans = 0;
		for ( int r = 0; r < h; r++ ) {
			for ( int c = 0; c < w; c++ ) {
				ans = Math.max(ans, hmap[r][c] + vmap[r][c] - 1);
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound
#define ub upper_bound
#define lowbit(x) x&-x

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

const int Maxn=2e5+10;

class BIT
{
	public:
		int bita[Maxn];
		void add(int pos,int x)
		{
			pos++;
			while(pos<Maxn)
			{
				bita[pos]+=x;
				pos+=lowbit(pos);
			}
		}
		int get(int pos)
		{
			pos++;
			int ans=0;
			while(pos>0)
			{
				ans+=bita[pos];
				pos-=lowbit(pos);
			}
			return ans;
		}
}bit;

int n;
ll k;
ll a[Maxn];

ll PreSum[Maxn];
vl v;

int main() 
{
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) PreSum[i]=PreSum[i-1]+a[i]-k;
    for(int i=1;i<=n;i++) v.PB(PreSum[i]);
    sort(all(v));
    v.erase(unique(all(v)),end(v));
//  for(int i=0;i<sz(v);i++) cout<<v[i]<<' ';
//  cout<<endl;
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
//    	cout<<PreSum[i]<<endl;
    	int pos=lb(all(v),PreSum[i])-begin(v);
//    	cout<<pos<<endl;
    	ans+=bit.get(pos);
    	bit.add(pos,1);
	}
	cout<<ans<<endl; 
    /* end code */
	return 0;
}

Measured memory_bytes: 5872
while True:
    a = int(input())
    if a == 0:
        break
    b = sorted(list(map(int,input().split())))
    di = -1
    for i in range(a-1):
        h = b[i+1]-b[i]
        if di == -1 or h < di:
            di = h
    print(di)


Measured memory_bytes: 5636
n = int(input())
A = [int(input()) for _ in range(n)]
A = sorted(A,reverse=True)

ans = 0
if n%2 == 1:
  i = -1
  for i in range((n-2)//2):
    ans += A[i]*2
    ans -= A[-i-1]*2    
  ans += A[i+1]
  ans += A[i+2]
  ans -= A[i+3] *2
  
  tmp = 0
  for i in range((n-2)//2):
    tmp += A[i]*2
    tmp -= A[-i-1]*2    
  tmp += A[i+1] *2
  tmp -= A[i+2]
  tmp -= A[i+3]
  ans = max(ans,tmp)
  
else:
  i = -1
  for i in range((n-2)//2):
    ans += 2*A[i]
    ans -= 2*A[-i-1]      
  ans += A[i+1]
  ans -= A[i+2]
  
print(ans)  

Measured memory_bytes: 14024
#include<stdio.h>

#include<stdlib.h>

 

struct node{

  struct node *p;

  struct node *r;

  struct node *l;

  int key;

};

 

 

typedef struct node * Node;

Node root;

 

void inorder(Node root)

{

 

  if(root != NULL){

    inorder(root->l);

    printf(" %d", root->key);

    inorder(root->r);

  }

}

 

void preorder(Node root)

{

if(root != NULL){

   printf(" %d", root->key);

   preorder(root->l);

   preorder(root->r);

 }

}

 

void insert(int k)

{

  Node y = NULL;

  Node x = root;

  Node z=malloc(sizeof(struct node));

  z->key = k;

  z->l = NULL;

  z->r = NULL;

  while(x!=NULL){

    y = x;

    if(z->key<x->key){

      x=x->l;

    }else{

      x=x->r;

    }

  }

  z->p=y;

  if(y == NULL){

    root=z;

  }else if(z->key<y->key) {

    y->l=z;

  }else{

    y->r=z;

  }

}

 

 

 

 

int main()

{

  int n,i,x;

  char option[100];

 

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%s",option);

    if(option[0]=='i'){

      scanf("%d",&x);

      insert(x);

    }

    else if(option[0]=='p'){

      inorder(root);

      printf("\n");

      preorder(root);

      printf("\n");

    }

  }

  return 0;

}

Measured memory_bytes: 24040
// Problem: D - Moving Piece
// Contest: AtCoder - AtCoder Beginner Contest 175
// URL: https://atcoder.jp/contests/abc175/tasks/abc175_d
// Parsed on: 2020-09-02 13:00:10
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);

using namespace std;
using ll = long long;

vector<ll> simulate(vector<ll> const &p, vector<ll> const &c, int n) {
    vector<ll> ans;
    int iter = p[n];
    ll lastAns = c[iter];
    ans.push_back(lastAns);
    while (iter != n) {
        iter = p[iter];
        lastAns += c[iter];
        ans.push_back(lastAns);
    }
    return ans;
}

int main() {
    ll ans = numeric_limits<ll>::min();
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n), c(n);
    for (auto &e : p) {
        int tmp;
        cin >> tmp;
        tmp--;
        e = tmp;
    }
    for (auto &e : c) cin >> e;

    for (int a = 0; a < n; a++) {
        auto sr = simulate(p, c, a);

        int tmpK = k;
        if (sr.back() <= 0) {
            if (tmpK > sr.size()) tmpK = sr.size();
            ans = max(ans, *max_element(sr.begin(), sr.begin() + tmpK));
        } else if (sr.size() >= k) {
            ans = max(ans, *max_element(sr.begin(), sr.begin() + k));
        } else {
            auto secondLastCycleSequence = ((k / sr.size()) - 1);
            ll base = secondLastCycleSequence * sr.back();

            ans = max(ans, base + *max_element(sr.begin(), sr.end()));
            if (k % sr.size())
                ans = max(ans, base + sr.back() +
                                   *max_element(sr.begin(),
                                                sr.begin() + (k % sr.size())));
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3360
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



int main() {

	int m, d;
	cin >> m >> d;
	int ans = 0;

	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= d; j++) {

			if (i == ((j % 10) * (j / 10))) {
				if (j % 10 >= 2 && j / 10 >= 2) {
					ans++;
				}
				
			}

		}
	}

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


Measured memory_bytes: 256
//二维前缀和+子矩阵和+深搜行+枚举列+注意行边界处理+注意列边界处理
#include <cstdio>
#include <algorithm>
using namespace std;
int a[12],sum[12][1010];
int H,W,K,ans=2000;
char s[12][1010];
int judge(int cnt,int la,int j){//num>K 1,num<=K 0
	int i,num;
	a[cnt+1]=H;//此句很关键，事关最后的行边界。
	for(i=1;i<=cnt+1;i++){
		num=sum[a[i]][j]-sum[a[i]][la]-sum[a[i-1]][j]+sum[a[i-1]][la];
		if(num>K) return 1;
	}
	return 0;
}
void solve(int cnt){
	int j,tot,la;
	tot=cnt,la=0;
	for(j=1;j<=W;j++)
		if(judge(cnt,la,j))tot++,la=j-1;
	if(!judge(cnt,W-1,W))ans=min(ans,tot);//此句判断关键，事关最后的列边界
}
void dfs(int step,int cnt){//step代表dfs执行步数，cnt代表对行进行切割的刀数
	if(step==H){
		solve(cnt);
		return;
	}
	//以下写法对应着C(n,0),C(n,1),C(n,2),...,C(n,n-1),C(n,n)等情况
	dfs(step+1,cnt);
	a[cnt+1]=step,dfs(step+1,cnt+1);
	
}
int main(){
	int i,j;
	scanf("%d%d%d",&H,&W,&K);
	for(i=1;i<=H;i++)scanf("%s",s[i]+1);
	for(i=1;i<=H;i++)
		for(j=1;j<=W;j++)
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+s[i][j]-'0';//二维前缀和
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
  int k;
  cin>>k;
	int h[n];
	for(int i=0;i<n;i++)
	cin>>h[i];
	
	vector<long > dp(n+1,INT_MAX);
	dp[0]=0;
	dp[1]=0;
	//dp[2]=abs(h[0]-h[1]);
	
	for(int i=2;i<=n;i++)
	{
      for(int j=1;j<=k;j++)
      {
        if(i-j<1)
          break;
		dp[i]=min(dp[i],dp[i-j]+abs(h[i-1]-h[i-j-1]));
      }
	}


cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;




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










Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    double h,high=0,low=0;
    while(scanf("%lf",&h)!=EOF){
        if(low==0) low=h;
        if(high<h) high=h;
        if(low>h) low=h;
    }
    printf("%lf\n",high-low);
    return 0;
}

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

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i=0 ; i<n ; i++)
    cin >> l.at(i);
  
  int d = 0, ans = 1;
  for (int i=0 ; i<n ; i++){
    d += l.at(i);
    if (d > x)
      break;
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0;i < n; ++i) cin >> a[i];	
	// dp[i] true only if i can gaurantee i can come here
	vector<bool> dp(k + 1);
	for(int i = 1;i <= k; ++i){
		for(int j = 0;j < n; ++j){
			// suppose i - a[j] is true then i cannot come here
			// if false then i can come here 
			if(i - a[j] >= 0){
				if(dp[i - a[j]] == false)dp[i] = true;
			}
		}
	}
	cout << (dp[k] == true ? "First":"Second");
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    // end

    return 0;
}


Measured memory_bytes: 384
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D&lang=jp
 */

import java.util.*;

class Lake {
	int rpos, lpos, area;
	Lake(int lpos, int rpos, int areaOfChilds) {
		this.rpos = rpos;
		this.lpos = lpos;
		this.area = rpos - lpos - 1 + areaOfChilds;
	}
	void print() {
		System.out.println("lpos:" + lpos + ", rpos:" + rpos + ", area:" + area);
	}
}
public class Main {

	void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
		System.out.println();
	}

	void update(LinkedList<Lake> lakes, int l, int r) {
		LinkedList<Lake> childs = new LinkedList<Lake>();
		int areaOfChilds = 0;
		int i = 0, idx = -1;
		for (Lake lake : lakes) {
			if (l < lake.lpos && lake.rpos < r) {
				childs.addLast(lake);
				areaOfChilds += lake.area;
				if (idx == -1) idx = i;
			} else if (idx == -1 && r <= lake.lpos) {
				idx = i;
			}
			i++;
		}
		lakes.removeAll(childs);
		lakes.add((idx == -1 ? lakes.size() : idx), new Lake(l, r, areaOfChilds));
	}

	void debugPrint(LinkedList<Lake> lakes) {
		for (Lake lake : lakes) {
			lake.print();
		}
		System.out.println();
	}

	void solve(int[] a, int level, int cap, LinkedList<Lake> lakes) {
		do {
			//System.out.println("solve: " + level + ", " + cap);
			for (int i = 0; i < a.length;) {
				int l = -1, r = -1;
				if (a[i] == level && i+1 < a.length && a[i+1] == (level-1)) {
					l = i;
					for (i += 2; i < a.length; i++) {
						if (a[i] == level && a[i-1] == (level-1)) {
							r = i;
							break;
						}
					}
					if (r != -1) {
						update(lakes, l, r);
					}
				}
				if (r == -1) i++;
			}
		} while (cap > level++);
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		char[] chars = line.toCharArray();
		int[] heights = new int[chars.length + 1];
		heights[0] = 0;  // 基準にする
		int bottom = 0;
		int top = 0;
		for (int i = 1; i < heights.length; i++) {
			int diff = 0;
			switch (chars[i-1]) {
			case '\\':
				diff = -1;
				break;
			case '/':
				diff = +1;
				break;
			case '_':
				diff = 0;
				break;
			}
			heights[i] = heights[i-1] + diff;
			bottom = Math.min(heights[i], bottom);
			top = Math.max(heights[i], top);
		}
		//printArray(heights);
		LinkedList<Lake> lakes = new LinkedList<Lake>();
		solve(heights, bottom+1, top, lakes);

		int sum = 0;
		for (Lake lake : lakes) {
			sum += lake.area;
		}

		System.out.println(sum);
		System.out.print(lakes.size());
		for (Lake lake : lakes) {
			System.out.print(" " + lake.area);
		}
		System.out.println();
	}

	public static void main(String[] args) {
		new Main().run();
	}

}



Measured memory_bytes: 33180
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int r;
	cin >> r;
	cout << 3 * r * r << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push (int x) {
    S[++top] = x;
}

int pop () {
    top--;
    return S[top+1];
}

int main() {
    int a, b;
    char s[100];
    top = 0;

    while ( scanf("%s", s) != EOF ) {
        if ( s[0] == '+' ) {
            a = pop();
            b = pop();
            push(a+b);
        } else if ( s[0] == '-') {
            b = pop();
            a = pop();
            push(a-b);
        } else if ( s[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        } else if ( s[0] == '/') {

        } else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());

    return 0;
}

Measured memory_bytes: 2716
n=int(input())
t,a=map(int,input().split())
hl=list(map(int,input().split()))
gap=abs(a-(t-hl[0]*0.006))
#print(gap)
city=1
for i in range(2,n+1):
    temp_gap=abs(a-(t-hl[i-1]*0.006))
    #print(i,temp_gap)
    if temp_gap<gap:
        gap=temp_gap
        city=i
print(city)





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


int main() {
  int N, K;
  cin >> N >> K;
  
  vector <int> A(N);
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  vector<int> bucket(N + 1, 0);
  for(int i = 0; i < N; ++i) {
    ++bucket[A[i]];
  }

  int count = 0;
  vector<int> bucket2;
  for(int i = 0; i < N + 1; ++i) {
    if(bucket[i]) {
      ++count;
      bucket2.push_back(bucket[i]);
    }
  }

  int diff = count - K;
  int ans = 0;

  if(diff > 0){
    sort(bucket2.begin(), bucket2.end());
    for(int i = 0; i < diff; ++i) {
      ans += bucket2[i];
    }
  }
  cout << ans << "\n";

}

Measured memory_bytes: 2936
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <map>

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	for(int i = 0; i < n; i++){
		cin>>a[i]>>b[i];
	}
	long long del = 0;
	for(int i = n-1; i >= 0; i--){
		if( ((del+a[i])%b[i]) !=0){
			
			del += b[i] - ((del+a[i])%b[i]);
			
		}
	}
	cout<<del<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;

namespace _160abc
{
    class Program
    {
        static void Main(string[] args)
        {       
            string S = Console.ReadLine();
            bool flag = true;
            if(S[2]==S[3] && S[4]==S[5]){
                flag = true;
            }else{
                flag = false;
            }
            Console.WriteLine(flag? "Yes":"No");
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int q; cin >> q;
	for (int i = 0; i < q; i ++) {
		long long a, b; cin >> a >> b;
		long long root = sqrt(a*b);
		long long ans = root + (a*b-1)/root-1;
		if ((a*b-1)/root >= a) ans --;
		if ((a*b-1)/root >= b) ans --;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();

		int H_degree = 30*H;
		int M_degree = 6*M;
		double radian = Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0);
		double cos = Math.cos(radian);
		double ans = Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos);
		System.out.println(Math.sqrt(ans));

	}
}

Measured memory_bytes: 35896
#include<iostream>
using namespace std;
using ll = long long;
int L = 1000000007;

int main() {
	int N, M; cin >> N >> M;
	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}
	ll dog = 1, mon = 1;
	for (int i = 2; i <= N; i++) {
		dog *= i;
		dog %= L;
	}
	for (int i = 2; i <= M; i++) {
		mon *= i;
		mon %= L;
	}
	ll res = dog * mon;
	res %= L;
	if (N % 2 == M % 2) {
		res *= 2;
		res %= L;
	}
	cout << res << endl;
	return 0;
}

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li sum[200200];

li l[22];
li r[22];

int main() {
    li n, k;
    cin >> n >> k;
    rep(i, k) {
        cin >> l[i] >> r[i];
    }
    sum[1] = 1;
    repp(i, 1, n) {
        rep(j, k) {
            if (l[j] > i) {
                continue;
            }
            sum[i + 1] = (sum[i + 1] + (sum[i + 1 - l[j]] - sum[max(0ll, i - r[j])])) % MOD;
        }
        sum[i + 1] = (sum[i + 1] + sum[i]) % MOD;
    }
    cout << (sum[n] - sum[n - 1] + MOD) % MOD << endl;


    return 0;
}


Measured memory_bytes: 5164
# https://atcoder.jp/contests/abc119/tasks/abc119_c
import copy
import itertools


# 長さ t の竹を L から少ないコストで作る方法を探す
def solve(t, l, c):
    min_cost = 100000
    cand = []

    ptn = 1 << len(l)
    # print(l)
    # print("ptn = {}".format(ptn))
    for i in range(1, ptn):
        answers = []
        for j in range(0, len(l)):
            if (i >> j) & 1:
                answers.append(l[j])
        temp_cost = abs(t - sum(answers)) + (10 * (len(answers) - 1) if len(answers) > 1 else 0)
        if temp_cost < min_cost:
            min_cost = temp_cost
            cand = answers

    # print("cand = {}".format(cand))
    for d in cand:
        del l[l.index(d)]
    return min_cost, l


def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    L.sort()

    answer = 1000000
    for targets in itertools.permutations([A, B, C]):
        is_done = [False] * 3
        L2 = copy.copy(L)
        total_cost = 0
        for i in range(len(targets)):
            if targets[i] in L2:
                del L2[L2.index(targets[i])]
                is_done[i] = True

        for i in range(3):
            if is_done[i]:
                continue

            cost, L2 = solve(targets[i], L2, 0)
            total_cost += cost

        answer = min(answer, total_cost)

    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
n,m=map(int,input().split())
l=[0 for _ in range(m)]
r=[0 for _ in range(m)]

for i in range(m):
  l[i],r[i] = map(int,input().split())

lmax=max(l)
rmin=min(r)
if rmin>=lmax:
  print(rmin-lmax+1)
else:
  print(0)

Measured memory_bytes: 10996
using System;
using System.Linq;

namespace AtCoderBeginnerContest152
{
	class Program
	{
		static void Main(string[] args)
		{
			var numbers = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

			Console.WriteLine(numbers[0] == numbers[1] ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 13396