akhauriyash/Code-Regression huggingface dataset:
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

V<ll> X, ans;
VV<ll> edges;

void dfs(ll cur, ll pre, ll sum = 0) {
    sum += X[cur];
    ans[cur] = sum;
    for(auto &&nxt : edges[cur]) {
        if(pre == nxt) continue;
        dfs(nxt, cur, sum);
    }
}

int main() {
    ll N, Q;
    cin >> N >> Q;
    X.resize(N);
    ans.resize(N);
    edges.resize(N);
    for(ll i = 1; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    while(Q--) {
        ll p, x;
        cin >> p >> x;
        p--;
        X[p] += x;
    }
    dfs(0, -1);
    for(auto &&ele : ans) cout << ele << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 25856
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,Y;cin>>N>>Y;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      int k=N-i-j;
      if(k<0)continue;
      if(i*10000+j*5000+k*1000==Y){
        cout<<i<<" "<<j<<" "<<k<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
#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>;


int main(){
	string A, B;
	cin >> A >> B;
	string S;
	S = A + B;
	int N = S.size();
	int tmp = 0;
	rep(i,N){
		tmp *= 10;
		tmp += S[i] - '0';
	}
	rep(i,330){
		if(i * i == tmp) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" <<endl;
	
}












Measured memory_bytes: 3600
N = int(input())
a = list(map(int, input().split()))
print(' '.join(str(x) for x in a))
for i in range(1, N):
    j = i - 1
    b = a[i]
    while j >= 0 and b < a[j]:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = b
    print(' '.join(str(x) for x in a))



Measured memory_bytes: 5604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        in.nextLine();
        Set<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(in.nextLine());
        }
        System.out.println(set.size());
    }
}


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

int main() {
	int n; scanf("%d", &n);
	double ans = 0;
	for (int i = 0; i < n; ++i) {
		int k; scanf("%d", &k);
		ans += 1.0 / k;
	}
	printf("%f\n", 1.0 / ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
   public static void main(String [] args){
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      int a,b,c;
      String[] arange=null;
     try{ 
      arange = in.readLine().split(" ", 0);
     }catch (Exception e){
     }
      a = Integer.parseInt(arange[0]);
      b = Integer.parseInt(arange[1]);
      c = Integer.parseInt(arange[2]);
      if(a<=b&&a<=c){
        if(b<c)
          System.out.println(a+" "+b+" "+c);
        else
           System.out.println(a+" "+c+" "+b);
      }else  if(b<=a&&b<=c){
        if(a<c)
          System.out.println(b+" "+a+" "+c);
        else
          System.out.println(b+" "+c+" "+a);
      }else{
        if(a<b)
          System.out.println(c+" "+a+" "+b);
        else
          System.out.println(c+" "+b+" "+a);
      }

   }
}


Measured memory_bytes: 24352
#include "bits/stdc++.h"
using namespace std;
int N, W; long long dp[100002];
int main(){
    scanf("%d %d", &N, &W);
    for(int i=1, w, v; i<=N; i++){
        scanf("%d %d", &w, &v);
        for(int j=W; j>=w; j--){
            dp[j] = max(dp[j], dp[j-w] + v);
        }
    }
    printf("%lld\n", dp[W]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t;
    t = 1;
    for(int i=0;i<t;i++)
    {
        ll a;
        double b;
        cin>>a>>b;
        ll z = a * int(b*100+0.1)/100;
        cout<<z;
    }
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int a, b;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A') {
            a = i - 1;
            break;
        } 
    }
    for (int i = s.size()-1; i >= 0; i--)
    {
        if (s[i] == 'Z') {
            b = i;
            break;
        }
    }
    
    cout << b - a << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<int> common(26, INT_MAX);

    for (int i = 0; i < N; i++) {
        vector<int> cur(26, 0);
        string s;
        cin >> s;
        for (int j = 0; j < s.size(); j++) {
            char c = s[j];
            cur[c - 'a'] += 1;
        }

        for (int k = 0; k < 26; k++) {
            common[k] = min(common[k], cur[k]);
        }
    }

    string ans;
    for (int l = 0; l < 26; l++) {
        if (common[l] > 0) {
            ans += string(common[l], 'a' + l);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
e,s=gets
h=Hash[gets.split.map(&:to_i).sort.chunk{|e|e}.map{|k,v|s||=k;[e=k,v.size]}]
 
puts h[s]<3&&h[s]==s*2+1-e && (s+1..e).all?{|e|h[e]&&h[e]>=2} ? "Possible" : "Impossible"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll n,maxa=-INF,mina=INF,sum=0;cin>>n;
    rep(i,n){
        ll p;cin>>p;
        maxa=max(maxa,p),mina=min(mina,p),sum+=p;
    }
    cout<<mina<<" "<<maxa<<" "<<sum<<endl;
    return 0;
}


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

int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> s(M), c(M);
  rep(i, M){
    cin >> s.at(i) >> c.at(i);
  }
  vector<ll> cond(N+1, -1);
  rep(i, M){
    if(cond.at(s.at(i)) == -1){
      cond.at(s.at(i)) = c.at(i);
    }
    else{
      if(cond.at(s.at(i)) != c.at(i)){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  string ans = "";
  if(N == 1 && (cond.at(1) == -1 || cond.at(1) == 0)){
    cout << 0 << endl;
    return 0;
  }
  if(N == 1){
    cout << cond.at(1) << endl;
    return 0;
  }
  rep(i, N){
    if(i == 0 && cond.at(i+1) == 0){
      cout << -1 << endl;
      return 0;
    }
    else if(i == 0 && cond.at(i+1) == -1){
      ans += 1 + '0';
    }
    else if(cond.at(i+1) == -1 || cond.at(i+1) == 0){
      ans += 0 + '0';
    }
    else{
      ans += cond.at(i+1) + '0';
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//    .------------------------------------------------------------.
//    |   _  __   ___    ___    ___   _  _    ___     _     _  _   |
//    |  | |/ /  / _ \  |   \  |_ _| | \| |  / __|   /_\   | \| |  |
//    |  | ' <  | (_) | | |) |  | |  | .` | | (_ |  / _ \  | .` |  |
//    |  |_|\_\  \___/  |___/  |___| |_|\_|  \___| /_/ \_\ |_|\_|  |
//    |             ___    ___     _     _  _    ___               |
//    |            / _ \  | _ \   /_\   | \| |  / __|              |
//    |           | (_) | |   /  / _ \  | .` | | (_ |              |
//    |            \___/  |_|_\ /_/ \_\ |_|\_|  \___|              |
//    |                 ___   ___    ___    ___                    |
//    |                | _ ) | __|  / __|  / _ \                   |
//    |                | _ \ | _|  | (_ | | (_) |                  |
//    |                |___/ |___|  \___|  \___/                   |
//    |                                                            |
//    |------------------------------------------------------------|
//    |                      .------------.                        |
//    |                      | KerakTelor |                        |
//    |                      |------------|                        |
//    |                      | 2019-10-08 |                        |
//    |                      '------------'                        |
//    '------------------------------------------------------------'

#include <bits/stdc++.h>

#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("tune=native")

#define vec vector
#define prq priority_queue
#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

//    .-----------------------------------------.
//    |        ___   _   _    ___   ___         | 
//    |       | _ ) | | | |  / __| / __|        | 
//    |       | _ \ | |_| | | (_ | \__ \        | 
//    |       |___/  \___/   \___| |___/        | 
//    |  ___   ___    ___    ___    _  _   ___  | 
//    | | _ ) | __|  / __|  / _ \  | \| | | __| |
//    | | _ \ | _|  | (_ | | (_) | | .` | | _|  | 
//    | |___/ |___|  \___|  \___/  |_|\_| |___| |
//    |                                         | 
//    '-----------------------------------------'

int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    vec<vec<int>> dp(n+1,vec<int>(m+1));
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    int y=n,x=m;
    string ans;
    while(y>0&&x>0)
    {
        if(s[y-1]==t[x-1])
        {
            ans+=s[y-1];
            --y,--x;
        }
        else if(dp[y-1][x]>=dp[y][x-1])
            --y;
        else
            --x;
    }
    for(int i=dp[n][m]-1;i>=0;--i)
        putchar(ans[i]);
    putchar('\n');
}



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

using namespace std;

int main()
{

	long long int k, n;
	cin >> k >> n;
	long long int arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	long long int min1 = 10e8;

	for (int i = 1; i < n - 1; i++)
	{
		arr[i] = min(k - arr[i + 1] + arr[i], k - arr[i] + arr[i - 1]);
		min1 = min(arr[i], min1);
	}
	min1=min(min1,arr[n-1]-arr[0]);
	cout << min1;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;


int main() {
	int a,b,c,d,n,count;

	while (cin >> n) {
		count = 0;

		for (a = 0; a <= 9; a++) {
			for (b = 0; b <= 9; b++) {
				for (c = 0; c <= 9; c++) {
					for (d = 0; d <= 9; d++) {
						if ((a + b + c + d) == n) count++;
					}
				}
			}
		}

		cout << count << endl;
	}
}

Measured memory_bytes: 1160
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let ass =
    Array.init n @@ fun _ ->
      Array.to_list @@ Array.init m @@ fun _ ->
        Scanf.scanf "%d " @@ fun a -> a - 1 in
  let rec solve s =
    if IntSet.is_empty s then max_int
    else begin
      let count = Array.make m 0 in
      Array.iter (fun as_ ->
        let a = List.find (fun a -> IntSet.mem a s) as_ in
        count.(a) <- 1 + count.(a)) ass;
      let n, a = IntSet.fold (fun a -> max (count.(a), a)) s (min_int, 0) in
      min n @@ solve @@ IntSet.remove a s
    end in
  Printf.printf "%d\n" @@
    solve @@
    IntSet.of_list @@
    Array.to_list @@
    Array.init m @@ fun i -> i


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll rgb[3][4252];
char col[3]={'R', 'G', 'B'};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  string s;
  cin>>n>>s;
  REP(i, n){
    REP(j, 3){
      rgb[j][i+1]=rgb[j][i];
    }
    if(s[i]=='R'){
      ++rgb[0][i+1];
    }
    else if(s[i]=='G'){
      ++rgb[1][i+1];
    }
    else{
      ++rgb[2][i+1];
    }
  }
  ll ans=0;
  REP(i, n){
    FOR(j, i+1, n){
      if(s[i]==s[j]){
        continue;
      }
      bool used[3];
      REP(k, 3){
        used[k]=false;
      }
      int idx=0;
      REP(k, 3){
        if(col[k]==s[i]){
          used[k]=true;
        }
        if(col[k]==s[j]){
          used[k]=true;
        }
        if(!used[k]){
          idx=k;
        }
      }
      ans+=rgb[idx][n]-rgb[idx][j+1];
      if(j+(j-i)<n){
        int jj=j+(j-i);
        if(s[i]!=s[jj] && s[j]!=s[jj]){
          --ans;
        }
      }
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 3680
n,m=map(int,input().split())
paths=[]

for i in range(n):
    paths.append([0]*n)

for i in range(m):
    a,b=map(int,input().split())
    paths[a-1][b-1]=1
    paths[b-1][a-1]=1
visited=[0]*n

def dfs(now,depth):
    if visited[now]==1:
        return 0
    elif depth==n-1:
        return 1
    else:
        visited[now]=1
        total=0
        for i in range(n):
            if paths[now][i]==1:
                total+=dfs(i,depth+1)
        visited[now]=0
        return total
print(dfs(0,0))

Measured memory_bytes: 3064
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())

    A_ = sorted(A)
    m = max(A)

    for a in A:
        if a == m:
            print(A_[-2])
        else:
            print(m)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25036
n=int(input())
a=[['7', '5', '3']]*9
for i in range(8):
    for j in range(len(a[i])):
        a[i+1].append(a[i][j]+'7')
        a[i + 1].append(a[i][j] + '5')
        a[i + 1].append(a[i][j] + '3')
ans=[]
for num in a[0]:
    if int(num) <= n and num.count('3')>0 and num.count('5') >0 and num.count('7')>0 :
        ans.append(num)
print(len(set(ans)))


Measured memory_bytes: 19872
import java.util.*;

class Node{
	int id;
	int parent, left, right, sibling, depth, height;

	public Node(int id){
		this.id = id;
		this.parent = -1;
		this.left = -1;
		this.right = -1;
		this.sibling = -1;
		this.depth = -1;
		this.height = -1;
	}
}

class Nodes{
	Node[] nodes;

	public void setDepth(int id, int d){
		int l = nodes[id].left;
		int r = nodes[id].right;
		if(l != -1)
			setDepth(l, d+1);
		if(r != -1)
			setDepth(r, d+1);
		nodes[id].depth = d;
	}

	public int setHeight(int id){
		if(id == -1)
			return -1;
		int l = nodes[id].left;
		int r = nodes[id].right;
		nodes[id].height = Math.max(setHeight(l), setHeight(r)) + 1;
		return nodes[id].height;
	}

	public void printNode(int id){
		StringBuffer sb = new StringBuffer();
		int degree = 0;
		if(nodes[id].left != -1) degree++;
		if(nodes[id].right != -1) degree++;
		sb.append("node " + id + ": parent = " + nodes[id].parent 
					+ ", sibling = " + nodes[id].sibling + ", degree = " + degree 
					+ ", depth = " + nodes[id].depth 
					+ ", height = " + nodes[id].height + ", ");
		if(nodes[id].parent == -1) sb.append("root\n");
		else if(degree == 0) sb.append("leaf\n");
		else sb.append("internal node\n");
		System.out.print(sb);
	}
}

public class Main{

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

		Nodes mynodes = new Nodes();
		Node[] nodes = new Node[n];
		mynodes.nodes = nodes;
		for(int i = 0; i < n; i++)
			nodes[i] = new Node(i);
		for(int i = 0; i < n; i++){
			int id = scan.nextInt();
			int left = scan.nextInt();
			int right = scan.nextInt();
			if(left != -1) nodes[left].parent = id;
			if(right != -1) nodes[right].parent = id;
			nodes[id].left = left;
			nodes[id].right = right;
			if(left != -1 && right != -1){
				nodes[left].sibling = right;
				nodes[right].sibling = left;
			}
		}
		int root = 0;
		while(nodes[root].parent != -1)
			root = nodes[root].parent;
		mynodes.setDepth(root, 0);
		nodes[root].height = mynodes.setHeight(root);
		
		for(int i = 0; i < n; i++)
			mynodes.printNode(i);
	}
}

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

int main() {
  char a; cin >> a;
  string ans = "a";
  if (isupper(a)) ans = "A";
  //if ((int)a < 97) ans = "A";
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for(int i=L;i<R;i++)
#define FE(i,L,R) for(int i=L;i<=R;i++)
#define RF(i,l,r) for(int i=r;i>l;i--)
#define RFE(i,l,r) for(int i=r;i>=l;i--)
#define getI(i) scanf("%d",&i)
#define getII(i,j) scanf("%d%d",&i,&j)
#define getIII(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define VgetI(i) int (i);scanf("%d",&(i));
#define VgetII(i,j) int (i),(j);scanf("%d%d",&(i),&(j));
#define VgetIII(i,j,k) int (i),(j),(k);scanf("%d",&(i),&(j),&(k));
#define EoF(n) int(n);while(~getI(n))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(n) (n>0?n:(-n))
#define INF 2147483647
#define nINF -2147483648
int main(){
	int a,b;
	while(~getII(a,b)){
		printf("%s\n",(a*b)%2==1?"Odd":"Even");
	}
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n; cin >> n;
  int m = 0;
  for(int i = 0;i < 26; ++i){
    for(int j = 0; j < 15; ++j){
      if(4*i + 7*j == n ) ++m;
    }
  }
  if(m == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
#show_flg=True

class Bit:
    def __init__(self,n):
        self.size=n
        self.m=len(bin(self.size))-2
        self.arr=[0]*(2**self.m+1)

    def __str__(self):
        return str(self.arr)

    def add(self,i,x):
        k=0
        while i<=self.size:
            k+=1
            self.arr[i]+=x
            i+=i&(-i)
        return

    def sum(self,i):
        rt=0
        while i>0:
            rt+=self.arr[i]
            i-=i&(-i)
        return rt

    def l_bound(self,w):
        if w<=0:
            return 0
        x=0
        k=2**self.m
        while k>0:
            if x+k<self.size and self.arr[x+k]<w:
                w-=self.arr[x+k]
                x+=k
            k//=2
        return x+1


class Bit0(Bit):
    def add(self,j,x):
        super().add(j+1,x)
    def l_bound(self,w):
        return max(super().l_bound(w)-1,0)

n,k=LI()
a=[0]
for _ in range(n):
    a.append(a[-1]+I()-k)

ans=0
show(a)
b=[(j,i) for i,j in enumerate(sorted(a[:]))]
d=dict(b)
b=[d[i] for i in a[:]]
show(b)

bt=Bit0(n+1)
for i in b:
    ans+=bt.sum(i+1)
    bt.add(i,1)

print(ans)




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

int main() {
  vector<vector<int> > c(4, vector<int>(4));
  vector<int> a(4), b(4);
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) cin >> c[i][j];
  }
  for (a[1] = -100; a[1] <= 100; a[1]++) {
    b[1] = c[1][1] - a[1];
    b[2] = c[1][2] - a[1];
    b[3] = c[1][3] - a[1];
    a[2] = c[2][1] - b[1];
    a[3] = c[3][1] - b[1];
    if (a[2] + b[2] == c[2][2] && a[2] + b[3] == c[2][3] &&
        a[3] + b[2] == c[3][2] && a[3] + b[3] == c[3][3]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int a[] = {0,
               1,
               3,
               1,
               2,
               1,
               2,
               1,
               1,
               2,
               1,
               2,
               1};
    int x,
        y;
    cin >> x >> y;
    cout << ((a[x] == a[y]) ? "Yes\n" : "No\n");
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

ll MOD = 1000000007;

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

    int H, W;
    cin >> H >> W;

    vll dprow(W+1, 0);
    vvll dp(H+1, dprow);
    vvll grid(H, dprow);

    for(int y=0;y<H;y++) {
        string gridrow;
        cin >> gridrow;
        for(int x=0;x<W;x++){
            if (gridrow[x] == '#') grid[y][x] = 1;
        }
    }

    dp[1][1] = 1;
    for(int y=1;y<=H;y++) {
        for(int x=1;x<=W;x++) {
            if (x==1 && y==1) continue;
            if (grid[y-1][x-1] == 0) {
                dp[y][x] = dp[y-1][x] + dp[y][x-1];
                dp[y][x] %= MOD;
            }
        }
    }

    cout << dp[H][W] << endl;

    return 0;
}

Measured memory_bytes: 16000
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int a = cin.nextInt();
        int b = cin.nextInt();
        int c = cin.nextInt();
        int k = cin.nextInt();
        int sum = 0;
        int m = Math.min(a, k);
        sum+=m;
        k-=m;
        m = Math.min(b, k);
        k-=m;
        if(k==0)
            System.out.println(sum);
        else
            System.out.println(sum-k);

    }
}


Measured memory_bytes: 35760
#[allow(dead_code)]
fn primes(num: i64) -> Vec<i64> {
    let mut ans = vec![1];
    let mut cur = num;
    for i in 2.. {
        if i * i > num { break; }
        if cur % i == 0 {
            while cur % i == 0 {
                ans.push(i);
                cur /= i;
            }
        }
    }
    if cur > 1 {
        ans.push(cur);
    }
    return ans;
}

#[test]
fn test_primes() {
    assert_eq!(primes(1), vec![1]);
    assert_eq!(primes(140), vec![1, 2, 2, 5, 7])
}

// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
test! {
r"BBW
" => r"2",

r"BWBWBW
" => r"6",
}

use proconio::{input, fastout};
use proconio::source::auto::AutoSource;

fn solve(src: &str) -> String {
    let source = AutoSource::from(src);
    input! {
       from source,
       s:String,
    }
    let s: String = s;


    let mut a = 0;
    let mut b = 0;
    let mut bs = 0;
    let len = s.len() - 1;
    for (index, chr) in s.chars().enumerate() {
        if chr == 'B' {
            a += index;
            b += len - bs;
            bs += 1;
        }
    }

    let ans = b - a;

    format!("{}", ans)
}


#[fastout]
fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&*s));
}


Measured memory_bytes: 2660
#include <stdio.h>

int main(void)
{
	int tmp;
	int a,b,c;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a > b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	if(b > c)
	{
		tmp = b;
		b = c;
		c = tmp;
	}
	if(a > b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}

	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

Measured memory_bytes: 2664
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main()
{
	int n, y;
	cin >> n >> y;

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			int k = n - (i + j);
			if (k >= 0 && i + j + k == n)
			{
				if (1000 * i + 5000 * j + 10000 * k == y)
				{
					cout << k << " " << j << " " << i << endl;
					return 0;
				}
			}
		}
	}


	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
    using namespace std;
     
    int main() {
     
    #ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
     
    //write code hare
     
    	int k;
    	int a, b;
    	int f = 0;
    	cin >> k >> a >> b;
     
     
     
    	for (int i = a; i <= b; i++) {
    		if (i % k == 0) {
    			f = 1;
    			break;
    		}
    	}
     
     
    	if (f == 1) {
    		cout << "OK";
    	}
    	else {
    		cout << "NG";
    	}
    }

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

int main()
{
	int n = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> b(n);
	int index = 0;
	if (n % 2 == 1) {
		for (int i = n - 1; i >= 0; i -= 2) {
			b[index] = a[i];
			index++;
		}
		for (int i = 1; i <= n - 2; i+=2) {
			b[index] = a[i];
			index++;
		}
	}
	else {
		for (int i = n - 1; i >= 1; i-=2) {
			b[index] = a[i];
			index++;
		}
		for (int i = 0; i <= n - 2; i+=2) {
			b[index] = a[i];
			index++;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << b[i] << " ";
	}
	cout << endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const double PI = acos(-1);

int main2() {
  double a, b, x; cin >> a >> b >> x;

  double ans;
  if (a*a*b/2 <= x) {
    double hi = 90;
    double lo = 0;
    REP(step, 200) {
      double t = (hi + lo) / 2;
      double v = a*a*b - a*a*a*tan(t * PI / 180.0)/2;
      if (v < x) {
        hi = t;
      } else {
        lo = t;
      }
    }
    ans = lo;
  } else {
    double r = atan2(a*b*b, 2*x) / PI * 180;
    ans = r;
  }
  printf("%.10f\n", ans);

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

const int N = 1000001;

int a, b;
int p[N];
bool used[N];

main(){
  while(cin >> a >> b && (a | b)){
    fill(used, used+N, false);
    for(int i=1;;i++){
      if(!used[a]){
        used[a] = true;
        p[a] = i;
      }else{
        cout << p[a]-1 << ' ' << i - p[a] << endl;
        break;
      }
      if(a % b == 0){
        cout << i-1 << ' ' << 0 << endl;
        break;
      }
      a = a*10 % b;
    }
  }
  return 0;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define print(x) cout << to_string(x) << '\n'
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 1e9+7;

string to_string(char &c) {string x(1, c); return x;}
string to_string(const char s[]) {return (string)s;}
string to_string(string &s) {return s;}
string to_string(vb &v) {string res; for (const bool &x : v) res += to_string(x) + ' '; return res;}
template <class C> string to_string(C &v) {string res; for (auto &x : v) res += to_string(x) + ' '; return res;}
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    REP(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

vvi nodes, par;
void precalc(int x, int u, int p=-1) {
    for (int v : nodes[u]) if (v != p) {
        par[v][x] = u;
        precalc(x, v, u);
    }
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n;
    cin >> n;
    vi c(n);
    cin >> c;
    sort(c.rbegin(), c.rend());

    vi tk(2*n, 1);
    REP(i, 1, tk.size()) tk[i] = 2*tk[i-1] % MOD;

    int res = 0;
    REP(k, 0, n) {
        res = (res + c[k]*tk[2*n-2]%MOD*(k+2) % MOD) % MOD;
    }
    print(res);
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int check(int n, int i){
	if(i==1) return 0;
	while(n%i==0) n/=i;
	n%=i;
	return n==1;
}

int32_t main(){
	fastio();
	int n;
	cin>>n;
	if(n==2){
		cout<<1;
		return 0;
	}
	
	int k = n-1;
	set<int>s;
	for(int i=2;i*i<=k;i++){
		if(k%i==0){
			s.insert(i);
			s.insert(k/i);
		}
	}
	s.insert(k);
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(check(n,i)) s.insert(i);
			if(check(n,n/i)) s.insert(n/i);
		}
	}
	s.erase(1);
	cout<<s.size();
}

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


struct low_link {
public :
	vector<int> articulation;
	vector<pair<int, int>> bridge;
private :
	int n;
	vector<vector<int>> g;
	vector<int> order, low;
	vector<bool> seen;

	int dfs (int v, int p, int ord) {
		seen[v] = true;
		order[v] = ord++;
		low[v] = order[v];
		int child = 0;
		bool isart = false;
		for (int u : g[v]) if (u != p) {
			if (seen[u]) {
				low[v] = min(low[v], order[u]);
			} else {
				child++;
				ord = dfs(u, v, ord);
				low[v] = min(low[v], low[u]);
				if (p != -1) isart |= (order[v] <= low[u]);
				if (order[v] < low[u]) bridge.push_back(minmax(v, u));
			}
		}
		isart |= (p == -1 and child >= 2);
		if (isart) articulation.push_back(v);
		return ord;
	}

public :
	low_link (int n) : n(n), g(n), order(n), low(n), seen(n) { }

	void add_edge (int v, int u) {
		g[v].push_back(u);
		g[u].push_back(v);
	}

	void build (int r = 0) {
		bridge.clear();
		articulation.clear();
		fill(seen.begin(), seen.end(), false);
		for (int s = 0; s < g.size(); s++) {
			if (not seen[s]) dfs(s, -1, 0);
		}
	}

};



int main() {
	int n, m;
	cin >> n >> m;
	low_link g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g.add_edge(a, b);
	}
	
	g.build();
	
	cout << g.bridge.size() << endl;
	
	return 0;
}

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

const ll mod = 1e9+7;

//べき乗高速化
ll mpow(ll x, ll n){
	ll ans = 1;
	while(n != 0){
		if (n&1) ans = ans * x % mod;
		x = x*x % mod;
		n  = n >> 1;
	}
	return ans;
}


int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll sum = 0;
	ll sum2 = 0;
	rep(i,n) {
		sum += a[i] % mod;
		sum2 += (a[i] % mod) * (a[i] % mod);
		sum2 %= mod;
	}
	sum %= mod;
	ll ans = sum * sum - sum2;
	ans %= mod;
	ans *= mpow(2, mod - 2);
	ans %= mod;
	if(ans < 0){
		cout << ans + mod << endl;
	}else{
		cout << ans << endl;
	}
    return 0;
}



Measured memory_bytes: 4840
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


H,W,K = map(int,readline().split())
C = [readline().strip() for _ in range(H)]

ans = 0
for i in range(2**H):
    for j in range(2**W):
        cnt = 0
        for s in range(H):
            for t in range(W):
                if (i >> s) & 1 and (j >> t) & 1 and C[s][t] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for(int i = 0; i < N; i++){
    if(ans * 2 > ans + K)
      ans = ans + K;
    else
      ans = ans * 2;
  }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#include <cmath>
using namespace std;

int main(){
  int A,B,C,X,Y;
  cin >> A>>B>>C>>X>>Y;
  int ans = 1e9;
  for(int i  =0;i<=max(X,Y);i++){
    int num =0;
    num += i*2*C;
    num += max(X-i,0)*A;
    num += max(Y-i,0)*B;
    ans = min(ans,num);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
#define all(x) x.begin(),x.end()
ll mob=1000000007;
using namespace std;
int main()
{ 
int n,p;
cin>>n>>p;
string h;
cin>>h;
int u=h.length();
int dp[u+1];
dp[u]=0;
int ten =1;
 if (10%p == 0) { // 2,5
    ll ans = 0;
    FOR(r,u) {
      if ((h[r]-'0') % p == 0) {
        ans += r+1;
      }
    }
    cout << ans << endl;
    return 0;
  }
for(int i=u-1;i>=0;i--)
{
  int a=(h[i]-'0')*ten%p;
  dp[i]=(dp[i+1]+a)%p;
  ten*=10;ten=ten%p;
}
vector<int> cnt(p,0);
ll ans =0;
for(int i=u;i>=0;i--)
{
  ans+=cnt[dp[i]];
  cnt[dp[i]]++;
}
cout<<ans;




return 0;
}











Measured memory_bytes: 1284
N,K = map(int,input().split())
A = [0]+list(map(int,input().split()))

num = [0]*(N+1)
inv = []

p = 1
count = 1
while num[p] == 0:
    num[p] = count
    inv.append(p)
    p = A[p]
    count += 1

m = max(num)

###
#print(p)
#print(num)
#print(inv)
#print((K-(num[p]-1))%(m-(num[p]-1))+num[p])
###

if K >= num[p]:
    print(inv[(K-(num[p]-1))%(m-(num[p]-1))+num[p]-1])
else:
    print(inv[K])


Measured memory_bytes: 103928
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();
		int x, y;

		List<String> inputline = stdIn.getLineString();
		Deque<Integer> stack = new LinkedList<>();

		for (int i = 0; i < inputline.size(); i++) {
			switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			}
		}
		System.out.println(stack.peek());
	}
}
class Input {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	Input() {
		super();
	}

	public Integer getValue() {
		try {
			String[] s = br.readLine().trim().split(" ");
			return Integer.parseInt(s[0]);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public List<Integer> getLine(int n) {
		List<Integer> values = new ArrayList<>();
		try {
			String[] s = br.readLine().trim().split(" ");
			for(int i = 0; i < n; i++) {
				values.add(Integer.parseInt(s[i]));
			}
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	public List<String> getLineString() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<String> values = Arrays.asList(s);
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 1e9+7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int suma = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        suma = add(suma, a[i]);
    }
    int sol = 0;
    for(int i = n - 1; i > 0; i--){
        suma = sub(suma, a[i]);
        sol = add(sol, mul(a[i], suma));
    }
    cout << sol % mod;
}



Measured memory_bytes: 4016
#include <iostream>
#include <stdio.h>
#include <vector>

typedef long long ll;

#define rep(i,n) for(int i = 0; i < n; i++)
#define debug(x) cerr << #x << ": " << x << "\n";

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  double R;
  cin >> R;
  printf("%12.5f", 2*PI*R);
}


Measured memory_bytes: 3784
#include<stdio.h>

#define N 100
int G[N][N];

int main()
{
  int i, j, n, u, k, v;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d %d", &u, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      G[i][v-1] = 1;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if (j == n - 1) {
         printf("%d", G[i][j]);
         break;
      }
      printf("%d ", G[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  int n, m;
  while(cin>>n>>m){
    int ans;
    ans=m*2-n;
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    [h, w] = [int(input_raw[0]), int(input_raw[1])]
    print (H - h) * (W - w)

if __name__ == '__main__':
    main()



Measured memory_bytes: 2932
#include <cstdio>
#include <cmath>
#define MOD 1000000007

int powermod(int num,int exp){
  if(exp == 0) return 1;
  int ret  = 1;
  for(int i = 1;i <= exp;i++){
    ret *= num;
    if(ret >= MOD) ret %= MOD;
  }
  return ret;  
}
int main(){
  int cnt[100002] = {};
  int N;
  scanf("%d",&N);
  int a;
  for(int i = 0;i < N;i++){
    scanf("%d",&a);
    cnt[a]++;
  }
  int long long ans = powermod(2,N / 2);
  bool flag  = false;
  for(int i = 1;i < N;i++){
    if( cnt[i] != 2 && cnt[i] != 0){
      flag = true;
    }
  }
  if(flag){
    puts("0");
  }
  else{
    printf("%lld\n",ans % MOD);
  }
  return 0;
}


Measured memory_bytes: 512
N=int(input())
xyh=[]
for i in range(N):
    a=[int(i) for i in input().split()]
    xyh.append(a)
xyh.sort(key=lambda x:x[2],reverse=True)
flag2=True
for i in range(0,101):
    for j in range(0,101):
        flag=True
        H=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for k in range(1,N):
            if xyh[k][2]!=max(0,H-abs(xyh[k][0]-i)-abs(xyh[k][1]-j)):
                flag=False
                break
        if flag==True:
            print("{} {} {}".format(i,j,H))
            flag2=False
            break
    if flag2==False:
        break

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(int.Parse(Console.ReadLine()) * 2 * Math.PI);
        }
    }
}


Measured memory_bytes: 27456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;

const ll INF=1LL << 60;

template<class T> inline bool chmin(T& a, T b){
  if(a>b){
    a=b;
    return true;
  }
  else return false;
}

template<class T> inline bool chmax(T& a, T b){
  if(a<b){
    a=b;
    return true;
  }
  else return false;
}

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

  int n;
  cin >> n;
  ll h[100010], dp[100010];
  rep(i, n)cin >> h[i];
  rep(i, n)dp[i]=INF;
  dp[0]=0;

  rep(i, n){
    chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1)chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
  }

  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 5144
n,k=map(int,input().split())
mod=1000000007
Fact=[1]
for i in range(1,n+1):
    Fact.append(Fact[i-1]*i%mod)
Finv=[0]*(n+1)
Finv[-1]=pow(Fact[-1],mod-2,mod)
for i in range(n-1,-1,-1):
    Finv[i]=Finv[i+1]*(i+1)%mod
def comb(n,r):
    if n<0 or r<0:
        return 0
    if n<r:
        return 0
    return Fact[n]*Finv[r]*Finv[n-r]%mod
for i in range(1,k+1):
    print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

Measured memory_bytes: 42736