akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}




int main() {
	ll A, B ,an=1;
	cin >> A >> B;
	A = gcd(A, B);


	ll i = 2;
	B = A;
	if (A == 1) {
		an--;
	}
	while (i*i<=A) {
		if (A % i == 0) {
			
			ll k = 1;
			while (A % i == 0) {
				A /= i;
				k++;
	 		}
			an++;
		}
		if (A == 1) {
			an--;
		}
		i++;
	}
	cout << an+1 << endl;

}


Measured memory_bytes: 256
n = int(input())
r = [0] * (n+1) # M1=r0*r1, M2=r1*r2, ... , Mn=rn-1*rn
m = [[100**4] * (n+1) for _ in range(n+1)] # m[i][j] = Mi...Mj の最小コスト
for i in range(n):
    r[i], r[i+1] = list(map(int, input().split()))

for i in range(1, n+1): # 1個の行列のコスト
    m[i][i] = 0
for i in range(1, n): # 2個の行列のコスト
    m[i][i+1] = r[i-1] * r[i] * r[i+1]
for j in range(2, n): # j+1 個の行列のコスト
    for i in range(1, n-j+1): # Mi...Mi+j
        for k in range(j): # Mi...Mi+k と Mi+k+1...Mi+j に分割
            # print('i=',i,' i+k=',i+k,' i+j=', i+j)
            cost = m[i][i+k] + r[i-1]*r[i+k]*r[i+j] + m[i+k+1][i+j]
            if cost < m[i][i+j]:
                m[i][i+j] = cost
print(m[1][n])



Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007


signed main(){
    fast;
    // #ifndef ONLINE_JUDGE
    //     freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
    //     freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    // #endif
    int a, b;
    cin>>a>>b;
    if(b%a){
        cout<<b-a;
    }
    else{
        cout<<a+b;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstdlib>

using namespace std;

struct S{
  int y,x,m,t;
  bool operator<(S s)const{
    return t>s.t;
  }
};

int W,H;

bool inside(int y,int x){
  return 0<=y&&y<H&&0<=x&&x<W;
}

int main(){
  cin>>W>>H;
  char g[100][101];
  for(int i=0;i<H;i++){
    cin>>g[i];
  }
  int d[100][100];
  fill(d[0],d[100],1);
  priority_queue<S> que;
  int m[100][100];
  int nm=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(g[i][j]=='S'){
	que.push({i,j,0,0});
      }else if(g[i][j]=='M'){
	m[i][j]=nm++;
      }else if(g[i][j]=='#'){
	for(int k=i-3;k<=i+3;k++){
	  for(int l=j-3;l<=j+3;l++){
	    if(inside(k,l)){
	      d[k][l]=max(d[k][l],4-max(abs(i-k),abs(j-l)));
	    }
	  }
	}
      }
    }
  }
  bool p[100][100][1<<5]={};
  for(;;){
    S cs=que.top();
    if(g[cs.y][cs.x]=='G'&&cs.m+1==1<<nm){
      cout<<cs.t<<endl;
      break;
    }
    que.pop();
    if(p[cs.y][cs.x][cs.m]++)continue;
    for(int i=0;i<4;i++){
      static int dir[]={0,1,0,-1,0};
      int ny=cs.y+dir[i];
      int nx=cs.x+dir[i+1];
      if(inside(ny,nx)&&g[ny][nx]!='#'){
	int nb=(g[ny][nx]=='M')?cs.m|1<<m[ny][nx]:cs.m;
	que.push({ny,nx,nb,cs.t+d[cs.y][cs.x]});
      }
    }
  }
}

Measured memory_bytes: 1808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=310;
char s[310];
int f[N][N][N],ans,n;
bool g[N][N][N];
void upd(int &a,int b) {
	a+=b; if (a>=mod) a-=mod;
}
int main() {
	scanf("%s",s);
	n=strlen(s);
	g[0][0][0]=1;
	for (int i=1;i<=n;i++) for (int p0=0;p0<=i;p0++) for (int p1=0;p1<=i;p1++) {
		g[i][p0][p1]=g[i-1][p0][p1];
		if (i>=2) {
			if ((s[i-1]=='0'||s[i-2]=='0')&&p0>0) g[i][p0][p1]|=g[i-2][p0-1][p1];
			if ((s[i-1]=='1'||s[i-2]=='1')&&p1>0) g[i][p0][p1]|=g[i-2][p0][p1-1];
		}
		if (s[i-1]=='0'&&p0>0) g[i][p0][p1]|=g[i-1][p0-1][p1+1];
		if (s[i-1]=='1'&&p1>0) g[i][p0][p1]|=g[i-1][p0+1][p1-1];
	}
	f[0][0][0]=1;
	for (int d=0;d<=n;d++) {
		for (int p0=0;p0<=d;p0++) for (int p1=0;p0+p1<=d;p1++) {
			int mt=d-p0-p1;
			if (g[n-mt][p0][p1]) {
				upd(ans,f[d][p0][p1]);
			}
			if (d==n) continue;
			char t=s[n-1-mt];
			if (t=='0') upd(f[d+1][p0][p1],f[d][p0][p1]);
			else upd(f[d+1][p0+1][p1],f[d][p0][p1]);
			if (t=='1') upd(f[d+1][p0][p1],f[d][p0][p1]);
			else upd(f[d+1][p0][p1+1],f[d][p0][p1]);
		}
	}
	printf("%lld\n",(ans+mod-1)%mod);
}

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

#define rep(loop, N) for (int loop = 0; loop < N; loop++)
using namespace std;

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Transfer(void) {

	int A, B, C; cin >> A >> B >> C;

	cout << max(-A + B + C, 0) << flush;
	return;
}

int main(void) {

	A_Transfer();
	return 0;
}


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

using namespace std;

int main()
{
    int x;
    cin>>x;
    int counter1000=0,counter5=0;
    if(x>=500)
    {
        counter1000=x/(int)500;
        x=x%500;
    }
    if(x>=5)
    {
        counter5=x/(int)5;
        x=x%5;
    }
    cout<<counter1000*1000+counter5*5;
}


Measured memory_bytes: 256
#include <stdio.h>
int abs(int);
int main(){
  long n;
  scanf("%ld",&n);
  int h[n],dp[n];
  for (long i=0;i<n;i++){
    scanf("%ld",&h[i]);
  }
  for (long i=0;i<n;i++){
    if (i==0){
      dp[i]=0;
//      printf("%ld\n",dp[i]);
    }
    if (i==1){
      dp[i]=abs(h[1]-h[0]);
//      printf("%ld\n",dp[i]);
    }
    if (i>1){
      if (dp[i-2]+abs(h[i]-h[i-2])<dp[i-1]+abs(h[i]-h[i-1])){
        dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
//        printf("%ld\n",dp[i]);
      }
      else {
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
//        printf("%ld\n",dp[i]);
      }
    }
  }
  printf("%ld\n",dp[n-1]);
  return 0;
}
int abs(int x){
  if (x<0){
    x=-x;
  }
  return x;
}


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

using namespace std;

int main()
{    
    int a;
    cin >> a;
    int i = 1;
    while(1)
    {
        int x = i;
        if(x % 3 == 0)
        {
            cout << " " << i;
        }
        else
        {
            while(1)
            {
                if(x % 10 == 3)
                {
                    cout << " " << i;
                    break;
                }
                else
                {
                    x /= 10;
                    if(!x)
                    {
                        break;
                    }
                }
            }
        }

        if(++i > a)
        {
            break;
        }
    }
    cout << endl;

     return 0;
}

Measured memory_bytes: 1164
#include<iostream>

int a = 0  , b = 0 , c = 0 , i = 0 ;

int main()
{
	std::cin >> a >> b >> c ;
	for(;a <= b ;)
	{
		if(c % a == 0)
		{
			i ++ ;
		}
		a ++ ;
	}
	std::cout << i << std::endl ;
}

Measured memory_bytes: 1160
#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)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
int N;
set<string> x;
void dfs(string s, int mx){
    if((int)s.size() == N){
        x.insert(s);
        return;
    }
    for(int i = 0; i <= mx; i++){
        string ns = s + char(i + 'a');
        if(i == mx){
            dfs(ns, mx+1);
        }
        else{
            dfs(ns, mx);
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> N;
    dfs("", 0);
    for(auto y: x){
        cout << y << endl;
    }
}

Measured memory_bytes: 12416
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

long long int gcd(long long int a, long long int b) {
  long long int x = min(a,b);
  long long int y = max(a,b);
  
  if (y%x == 0) { return x; }
  
  return gcd(x, y%x);
}

vector<long long int> primes(long long int n) {
  vector<bool> p(n+1, true);
  vector<long long int> result;
  p[0] = false;
  p[1] = false;
  
  for (long long int i = 2; i <= n; i++) {
    if (p[i] == false) { continue; }
    
    result.emplace_back(i);
    for (long long int j = i*2; j <= n; j+=i) {
      p[j] = false;
    }
  }
  
  return result;
}

vector<long long int> get_divisors(long long int n) {
  vector<long long int> result;
  
  long long int sq = floor(sqrt(n));
  const auto& ps = primes(sq);
  
  long long int nn = n;
  for (const auto& p : ps) {
    if (nn % p == 0) {
      result.emplace_back(p);

      while (nn%p == 0) {
        nn/=p;
      }
    }
  }
  
  if (nn>1) {
    result.emplace_back(nn);
  }
  
  return result;
}

int main() {
  long long int a,b;
  cin >> a >> b;
  
  long long int g = gcd(a,b);
  
  int result = 0;
  
  cout << (1ll+get_divisors(g).size()) << endl;
}


Measured memory_bytes: 1528
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

namespace seg_f {
    using S = int;
    S op(S a, S b) {
        return max(a, b);
    }
    S e() {
        return 0;
    }

    using seg_t = segtree<S, op, e>;
}

int main() {
    int N, K; scanf("%d%d", &N, &K);
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }

    seg_f::seg_t seg(300010);
    for(int i=0; i<N; i++) {
        int l = max(0, A[i] - K), r = min(300000, A[i] + K) + 1;
        seg.set(A[i], seg.prod(l, r) + 1);
    }
    cout << seg.prod(0, 300010) << endl;
    return 0;
}


Measured memory_bytes: 9624
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
aa = [0] 
bb = [0]
for i in range(m):
    bb.append(bb[-1]+B[i])
for i in range(n):
    aa.append(aa[-1]+A[i])
aa.append(aa[-1]+1)
bb.append(bb[-1]+1)

#print(aa)

ans = 0

for i in range(n+1):
    temp = k-aa[i]
    if temp<0:
        break
    s = 0
    l = m+1
    mid = l//2
    while l-s>1:
        if temp>bb[mid]:
            s = mid
            mid = (s+l)//2
        elif temp==bb[mid]:
            s = mid
            break
        else:
            l = mid
            mid = (s+l)//2
    #print(s)
    #print(ans, s+i)
    ans = max(ans, s+i)
print(ans)

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

 using namespace std;
 int main() {
   string S, T;
   int out, i;

   cin >> S;

   T = "CODEFESTIVAL2016";

   out = 0;
   for (i = 0; i < 16; i++) {
     if (S.at(i) != T.at(i)) out++;
   }

   cout << out << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "AC" << endl; exit(0); }
void no() { cout << "WA" << endl; exit(0); }

int main() {
    string s; cin >> s;
    int ccnt = 0;
    int bcnt = 0;
    rep(i, s.size()) {
        if(i == 0) {
            if(s[i] != 'A') no();
        }
        if(2 <= i && i < s.size() - 1) {
            if(s[i] == 'C') ccnt++;
        }
        if('a' <= s[i] && s[i] <= 'z') {
            bcnt++;
        }
    }
    if(ccnt != 1) no();
    if(bcnt != s.size()-2) no();
    yes();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define sci(x) int x; scanf("%d", &x);
#define TC(x) sci(x); while(x--)
typedef long long ll;
using namespace std;
int main()
{
    ll a;
    double b;
    cin>>a>>b;
    int d = round(b*100);
    ll c= a*d/100;
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long D = sc.nextLong();
        int counter = 0;
        for (int i = 0; i < N; i++) {
            long X = sc.nextLong();
            long Y = sc.nextLong();
            long dist = X * X + Y * Y;
            if (dist <= D * D) {
                counter++;
            }
        }
        System.out.println(counter);
        sc.close();
    }
}

Measured memory_bytes: 60880
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main(void){
	int a, b;
	cin >> a >> b;
	int ans = 2 * a - 1;
	ans = max(ans, 2 * b - 1);
	ans = max(ans, a + b);
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<double>p(N);
  for(int i=0;i<N;i++)cin>>p[i];
  vector<vector<double>>dp(N+1,vector<double>(N+1,0));
  dp[0][0]=1;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(j-1>=0)dp[i][j]+=dp[i-1][j-1]*p[i-1];
      dp[i][j]+=dp[i-1][j]*(1-p[i-1]);
    }
  }
  double ans=0;
  for(int i=0;i<=N;i++){
    if(i>N/2)ans+=dp[N][i];
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 2e5 + 10;

int n, a[N];

bool check(int mid)
{
	for (int i = 1; i <= n - 1; ++i)
	{
		if ((a[n + i - 1] >= mid) == (a[n + i] >= mid)) return a[n + i] >= mid;
		if ((a[n - i + 1] >= mid) == (a[n - i] >= mid)) return a[n - i] >= mid;
	}
	return a[1] >= mid;
}

int main()
{
	gi(n);
	for (int i = 1; i <= 2 * n - 1; ++i) gi(a[i]);
	int x = 1, v = 2 * n - 1;
	for (int i = 19; ~i; --i)
		if (x + (1 << i) <= v && check(x + (1 << i)))
			x += 1 << i;
	printf("%d\n", x);
}

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

int main() {
    int N; cin >> N;
    vector<int> dp(N + 1, INT32_MAX);
    dp[0] = 0;

    REP(i, 0, N + 1) {
        for(int j = 1; i + j <= N; j *= 6) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
        for(int j = 1; i + j <= N; j *= 9) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 640
a=int(input())
l=list(map(int,input().split()))
t=[]
b=[]
for x in range(1,a+1):
    t.append(x)
for x in range(a):
    b.append( l[x]==t[x])
if b.count(True)==a:print("YES")
elif b.count(False)!=2:print("NO")
else:
    fi=b.index(False)
    li=b.index(False,fi+1)
    tmp=l[fi]
    l[fi]=l[li]
    l[li]=tmp
    b.clear()
    for x in range(a):
        b.append( l[x]==t[x])
    if b.count(True)==a:print("YES")
    else:print("NO")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int N;
  cin>>N;
  for(int h=1;h<=3500;h++) {
    for(int n=1;n<=3500;n++) {
      if((4*h*n-N*n-N*h)==0) continue;
      if((N*h*n)%(4*h*n-N*n-N*h)==0) {
        if(0<=(N*h*n)/(4*h*n-N*n-N*h)) {
          cout<<h<<" "<<n<<" ";
          cout<<(N*h*n)/(4*h*n-N*n-N*h)<<endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
using ll=long long;
int main(){
    while(1){
   int n;
   cin >> n;
   if(n==0){
       break;
   }
   vector<ll> vec(n);
   for(int i=0;i<n;i++){
       int x;
       cin >> x;
       vec[i]=x;
   }
   
   ll MIN=1e9;
   for(int i=0;i<n;i++){
       for(int j=i+1;j<n;j++){
           MIN = min(abs(vec[i]-vec[j]),MIN);
       }
   }
   cout << MIN <<endl;
    }
}



Measured memory_bytes: 3092
from collections import deque
R,C = map(int,input().split())
sy,sx = 1,1  #スタートの座標
gy,gx = R,C  #ゴールの座標
L = []
for i in range(R):
  L.append(list(input()))   #迷路の情報を受け取る
dy_dx = [[1,0],[-1,0],[0,1],[0,-1]]   #移動
black = 0
for i in range(R):
  for j in range(C):
    if L[i][j] == '#':
      black += 1
que = deque([[sy-1,sx-1]])   #queには次に見るべき座標が入る。括弧が二重になっていることに留意
L[sy-1][sx-1] = 0  #スタートの座標（迷路上）の情報を0に
while len(que) > 0:  #queが空でないときは
  cur = que.popleft()   #queの一番左を見る
  for i in range(4):  #現在見ているマスの上下左右をチェック
    if 0 <= cur[0]+dy_dx[i][0] <= R-1 and 0 <= cur[1]+dy_dx[i][1] <= C-1:  #移動した後も迷路内にあるかの確認
      if L[cur[0]+dy_dx[i][0]][cur[1]+dy_dx[i][1]] == '.':  #まだ見ていない通路であれば
        L[cur[0]+dy_dx[i][0]][cur[1]+dy_dx[i][1]] = L[cur[0]][cur[1]]+1  #現在見ているマスの手数+1を入れる
        que.append([cur[0]+dy_dx[i][0],cur[1]+dy_dx[i][1]])   #queの末尾に今チェックした座標を入れる
if L[gy-1][gx-1] == '#':
  print(-1)
elif L[gy-1][gx-1] == '.':
  print(-1)
else:
  print(R*C-L[gy-1][gx-1]-1-black)

Measured memory_bytes: 3316
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
inline void Fail(){printf("0");exit(0);}
inline void debug(int x){cerr<<"debug: "<<x<<"\n";}
inline void debug(int n,int x[]){cerr<<"debug "<<"\n";rep(i,n)cerr<<x[i]<<" ";cerr<<"\n";}
inline void debug(string x){cerr<<"debug: "<<x<<"\n";}

int n,a,b; 
int main(){
	cin>>n>>a>>b;
	if((b-a)&1)printf("Borys");
	else printf("Alice");
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
const int MAXN = 100000;
int SendQuery(int n);

struct _query
{
    int result;
    int query;
    _query(){};
    _query(int qu)
    {
        result = SendQuery(qu);
        query = qu;
    }
};

string str;

int N;

int SendQuery(int n)
{
    cout << n << endl << flush ;

    cin >> str ;
    if(str == "Vacant")
        exit(0);
    if(str == "Male")
        return 0;
    return 1;
}

int getExpAns(int curpos, _query prevQuery)
{
    if((curpos - prevQuery.query) & 1)
        return !(prevQuery.result);
    return prevQuery.result;
}

void binaryQuery()
{
    int l = 0, r = N;

    _query leftQuery, rightQuery;
    leftQuery.query = 0, leftQuery.result = SendQuery(0);
    rightQuery.query = N-1, rightQuery.result = SendQuery(N-1);

    while(r-l > 1)      // [l, r)
    {
        int mid = (l+r) >> 1;
        //cerr << "Expected Answer :" << getExpAns(mid, leftQuery) << endl ;
        _query MidQuery(mid);
        if(MidQuery.result == getExpAns(mid, leftQuery))
        {
            l = mid;
            leftQuery = MidQuery;
        }
        else
        {
            r = mid;
            rightQuery = MidQuery;
        }

    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> N;
    binaryQuery();
    return 0;
}


Measured memory_bytes: 852
#include<iostream>
#include<iostream>
#include<math.h>
#include<string>
#include<bits/stdc++.h>
#include<cstdio>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define bll __builtin_popcountll
#define bufclr while((getchar())!='\n')
#define bufcl int ws=cin.get()
#define bl "\n"
#define mp make_pair
#define pb push_back
#define ll long long int
#define UI unsigned int
#define mod  1000000007 /*998244353*/ 
//#define fs first
//#define sc second
#define fora(i,a,x) for(int i=a; i<x; ++i)
#define fors(i,x,a) for(int i=x; i>a; --i)
using namespace std;
void op(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
	#endif
}
int C(pair<int,int> &a ,pair<int,int> &b){
	return a.first<b.first;
}
int main() { 
    	op();
			long long  ans=0,sum=0;
		
			long long  n;
			cin>>n;
		for(int i=0; i<n; ++i){
			long long  a;
			cin>>a;
			ans = (ans + (sum*a)%mod)%mod;
			sum= (sum + a)%mod;
		}
		cout<<ans;
		}
		//cout<<ans;





            

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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

//累積和？
//各駅間の時間をメモ、また総和もメモ


int main(){
    int N;
    cin>>N;
    vector<int> C(N),S(N),F(N),ANS(N,0);
    rep(i,N-1)cin>>C[i]>>S[i]>>F[i];


    for(int j=0;j<N-1;j++){
        ll time=0;
        REP(i,j,N-1){
        if(time<S[i]){
            time=S[i]+C[i];
        }else{
            int a=time%F[i];
            if(a==0)time+=C[i];
            else{
                time-=a;
                time+=F[i]+C[i];
            }
        }
        }
        cout<<time<<endl;
    }
    cout<<0<<endl;


    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
from math import factorial
Q = 10**9+7
def primes(n):
    primfac = [0]
    d = 2
    while d*d <= n:
        while n%d == 0:
            primfac[-1] += 1
            n //= d
        d += 1
        if primfac[-1] != 0:
            primfac.append(0)
    if n > 1:
        if primfac[-1] == 0:
            primfac[-1] += 1
        else:
            primfac.append(1)
    return primfac
N, M = map( int, input().split())
C = primes(M)
ans = 1
if N == 1:
    print(1)
else:
    for x in C:
        for i in range(x):
            ans *= N+i
        ans //= factorial(x)
        ans = ans%Q
    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  int s=a.size();
  int t=b.size();
  if((a.at(s-1)==b.at(0))&&(b.at(t-1)==c.at(0))){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int y = scn.nextInt();
      	int k = -1;
      	int k5 = -1;
      	int k10 = -1;
      	int num = 0;
      	for(int i=0; i<=n; i++){
          for(int j=0; j<=n-i; j++){
            num = 1000*i + 5000*j + 10000*(n-j-i);
            if(num==y){
              k=i;
              k5=j;
              k10=n-j-i;
            }
          }
        }
      	System.out.println(k10 + " " + k5 + " " + k);
	}
}


Measured memory_bytes: 39460
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
ll sc[1 << 16], dp[1 << 16][17], A[16][16];
ll fun(int mask, int k){
	if(mask == 0)
		return 0;
	if(dp[mask][k] != -1)
		return dp[mask][k];
	ll maxi = -1e18;
	for(int i = mask; i; i = (i - 1) & mask){
		maxi = max(maxi, sc[i] + fun(mask ^ i, k + 1));
	}
	return dp[mask][k] = maxi;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> A[i][j];
	for(int i = 0; i < (1 << n); i++){
		vector<int> df;
		for(int j = 0; j < n; j++){
			if(i & (1 << j))
				df.pb(j);
		}
		for(int p = 0; p < df.size(); p++)
		for(int q = p + 1; q < df.size(); q++){
			sc[i] += A[df[p]][df[q]];
		}
	}
	memset(dp, -1, sizeof(dp));
	cout << fun((1 << n) - 1, 0) << '\n';

}

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

namespace ConsoleApp89 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int ans = A[0];

            for (int i = 0; i < N - 1; i++) {
                ans = Math.Min(ans, GCD(A[i], A[i + 1]));

                if (ans == 1) {
                    break;
                }
            }

            Console.WriteLine(ans);
        }

        static int GCD(int a, int b) {
            if (a < b) {
                return GCDRecursive(b, a);
            } else {
                return GCDRecursive(a, b);
            }
        }

        static int GCDRecursive(int a, int b) {
            if (b == 0) {
                return a;
            } else {
                return GCDRecursive(b, a % b);
            }
        }
    }
}


Measured memory_bytes: 21728
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

struct eve{int len,ddl;}ev[200005];
bool cmp(eve a, eve b)
{
	return a.ddl < b.ddl;
}
int main()
{
	int n; cin>>n;
	for (int i=1; i<=n; i++) cin>>ev[i].len>>ev[i].ddl;
	sort(ev+1,ev+1+n,cmp);
	
	ll time=0;
	for (int i=1; i<=n; i++)
	{
		time+=ev[i].len;
		if (time>ev[i].ddl)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class DCandyDistribution {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n, m;
    cin >> n >> m;
    vector<int64_t> A(n);
    for (auto &a: A) cin >> a;
    vector<int64_t> acc(n + 1);
    acc[0] = 0;
    partial_sum(A.begin(), A.end(), acc.begin() + 1);

    int64_t ans = 0;
    map<int64_t, int64_t> C;

    for (const auto &a: acc)
        C[a % m]++;

    for (const auto& c: C)
        ans += c.second * (c.second - 1) / 2LL;

    cout << ans << endl;

}
};

int main() {
	DCandyDistribution solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

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

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N) cin >> d[i];
    
    ll ans = 0;
    rep(i,N)
    {
        for(int j = i+1; j < N; j++)
        {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
            

}


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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	long double a, b, x;
	long double ans, PI = acos(-1);
	long double Z = 0;
	cin>>a>>b>>x;
	// cout<<PI<<endl;
	long double l = 0, h = 90, m;
	
	// cout<<atan(b/a)*180/PI<<endl;
	
	Z  = atan(b/a)*180/PI;
	
	for(int i = 0; i < 200; i++){
		m = (l+h)/2;
		
		long double area, y;
		
		y = tan(m * PI / 180.0) * a;
		
		// cout<<"tam "<<tan(m * PI / 180.0)<<" "<<m*PI/180<<endl;
		
		if(Z < m) {
			area = tan((90-m) * PI / 180) * b * b/ 2;
			
			// cout<<"Z "<<" "<<endl;
		} else {
		
			area = a * (b - y);
		
			area += a * y / 2 ;
		}
		// cout<<"area = "<<area<<" "<<y<<" m = "<<m<<endl;
		
		if(area*a < x){
			h = m;
		} else {
			l = m;
		}
	}
	
	cout<<m<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
#include <queue>
#include <assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

struct perm{
private:
	int sz;
	vector<ll> p,invp;
public:
	perm(int n){
		sz=n+1;
		p.resize(sz),invp.resize(sz);
		p[0]=1;
		for(int i=1;i<=sz-1;i++){
			p[i]=p[i-1]*i%mod;
		}
		invp[sz-1]=mod_pow(p[sz-1],mod-2);
		for(int i=sz-2;i>=0;i--){
			invp[i]=invp[i+1]*(i+1)%mod;
		}
	}
	ll comb(ll x,ll y){
		if(x<y||y<0)return 0;
		return (p[x]*invp[x-y]%mod)*invp[y]%mod;
	}
};
perm p(1<<21);


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    string s; cin >> s;
    int n=s.size();
    ll a=mod_pow(26,k+n)%mod;
    ll b=0;
    for(int i=0;i<=n-1;i++){
    	ll pp=p.comb(n+k,i)*mod_pow(25,n+k-i)%mod;
    	(b+=pp)%=mod;
    }
    cout << ((a-b)%mod+mod)%mod << endl;
}




Measured memory_bytes: 37040
use proconio::{input, fastout, marker::*};

#[fastout]
fn main() {
  input!{
    n:usize,
    s:Chars,
    k:usize
  }

  for i in 0..n {
      print!("{}",if s[i] != s[k-1] {'*'} else {s[i]});
  }
  println!("");
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    #endif // _DEBUG

    long long a, b, n;
    cin >> a >> b >> n;
    long long x = min(b-1, n);
    long long ans = (a*x)/b - a*(x/b);
    cout << ans;

    return 0;
}


Measured memory_bytes: 3580
V, E, r = map(int, input().split())
paths = []

for i in range(E) :
    paths.append(list(map(int, input().split())))
    
INF = 10**20

cost = [INF for x in range(V)]
cost[r] = 0

inf_flg = False 

for i in range(V*2) :
    for p in paths :
        f, t, c = p[0], p[1], p[2]

        if cost[t] > cost[f] + c and not(cost[t] == cost[f] == INF):
            cost[t] = cost[f] + c
            
            if i >= V :
                inf_flg = True 
                
if inf_flg == True :
    print("NEGATIVE CYCLE")
else :
    for c in cost :
        if c == INF :
            print("INF")
        else :
            print(c)


Measured memory_bytes: 6120
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	READ(n);
	READARR(a, n);
	int sum = 0;
	bitset <2000*2000> dp("1");
	FOR (i, 1, n)
        dp = dp | (dp << a[i]), sum += a[i];
	
	FOR (i, (sum + 1)/2, 2000*2000)
	    if (dp[i]) 
	        {cout << i; return 0;}
}

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

int CalcSum(int n){
  int sum;
  while(n>0){
   sum = sum +(n % 10);  
   n /= 10; 
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  
  int sum = CalcSum(N);
  
  if(N % sum == 0){
     cout << "Yes" << endl;
  }else{
     cout << "No" << endl;
  }
 

}

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

int main()
{
	ios_base::sync_with_stdio(false);
	int a[5],k;
	for(int i=0;i<5;i++)
		cin>>a[i];
	cin>>k;
	bool poss=false;
	for(int i=0;i<5;i++)
	{
		for(int j=i+1;j<5;j++)
		{
			if(a[j]-a[i]>k)
			{
				poss=true;
				break;
			}
		}
	}
	if(poss)
		cout<<":(";
	else
		cout<<"Yay!";
}

Measured memory_bytes: 256
public class Main {
	static java.util.Scanner scan = new java.util.Scanner(System.in);
	public static void main(String[] args) {
		int input = 0;
		while (scan.hasNextInt()) {
			input = scan.nextInt();
			int total = 0;
			for (int h = 0; h < 10; ++h)
				for (int i = 0; i < 10; ++i)
					for (int j = 0; j < 10; ++j)
						for (int k = 0; k < 10; ++k)
							if (h + i + j + k == input)
								++total;
			print(total);
			
		}
	}
	
	public static void print(Object out) {
		System.out.println(out);
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[N-1] - a[0] << endl;
}

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

using namespace std;

#define DIM 1009
#define INF 1e18+9
#define MODULO 1000000007
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<int,int>
#define fi first
#define se second
#define ld long double

long long i,j,k,l,n,m,cnt;

long long a[DIM][DIM],b[DIM][DIM];

long long res[DIM][DIM];

int main()
{
    cin>>n>>m;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            cin>>a[i][j];
            b[i][i]=1;
        }
    }

    while(m>0)
    {
        if(m&1)
        {
            for(i=1; i<=n; i++)
                for(j=1; j<=n; j++)
                {
                    res[i][j]=0;
                    for(k=1; k<=n; k++)
                    {
                        res[i][j]=(res[i][j]+(a[i][k]*b[k][j])%MODULO)%MODULO;
                    }
                }
            for(i=1; i<=n; i++)
                for(j=1; j<=n; j++)
                    b[i][j]=res[i][j];
        }

        for(i=1; i<=n; i++)
            for(j=1; j<=n; j++)
            {
                res[i][j]=0;
                for(k=1; k<=n; k++)
                {
                    res[i][j]=(res[i][j]+(a[i][k]*a[k][j])%MODULO)%MODULO;
                }
            }
        for(i=1; i<=n; i++)
            for(j=1; j<=n; j++)
                a[i][j]=res[i][j];

        m/=2;
    }

    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            cnt+=b[i][j];
            cnt%=MODULO;
        }
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll d, t; cin >> d;
    vector<ll> c(26);
    vector<ll> las(26,0);
    vec2(s,d,26,0);
    REP(i,26) cin >> c[i];
    REP(i,d)REP(j,26) cin >> s[i][j];
    ll con = 0;
    FOR(i,1,d){
        cin >> t;t--;
        las[t]=i;
        con+=s[i-1][t];
        REP(j,26){
            con-=c[j]*(i-las[j]);
        }
        cout << con << endl;
    }
}

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

#define N 21

int main(void){
	
	int field[N][N];
	char dir[2];
	int j_x,j_y;
	int vec;
	int x=10,y=10;
	int num,n;
	int count=0;

	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			field[i][j]=0;
		}
	}

	while(1){
		count=0;
		x=10;
		y=10;
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				field[i][j]=0;
			}
		}
		scanf("%d",&num);
		if(num==0){
			break;
		}
		for(int i=0;i<num;i++){
			scanf("%d %d",&j_x,&j_y);
			field[j_x][j_y]=1;
		}
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%s %d",dir,&vec);
			if(strcmp(dir,"N")==0){
				for(int j=0;j<vec;j++){
					y++;
					if(field[x][y]==1){
						count++;
						field[x][y]=0;
					}
				}
			}
			if(strcmp(dir,"E")==0){
				for(int j=0;j<vec;j++){
					x++;
					if(field[x][y]==1){
						count++;
						field[x][y]=0;
					}
				}
			}
			if(strcmp(dir,"S")==0){
				for(int j=0;j<vec;j++){
					y--;
					if(field[x][y]==1){
						count++;
						field[x][y]=0;
					}
				}
			}
			if(strcmp(dir,"W")==0){
				for(int j=0;j<vec;j++){
					x--;
					if(field[x][y]==1){
						count++;
						field[x][y]=0;
					}
				}
			}
		}
		if(count==num){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}

    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define iii tuple<int, int, int>
#define iiii tuple<int, int, int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define eb emplace_back

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int M = 1e9 + 7;

int fpow(int x, int y) {
    int res = 1;
    while (y) {
        if (y & 1) res = (1LL * res * x) % M;
        y >>= 1;
        x = (1LL * x * x) % M;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    for (auto& i : a) cin >> i;

    int N = 1e6 + 1;
    vi chk(N), factl(N);
    vvi fact(N, vi(10));
    for (int i = 2; i < N; ++i) {
        if (!chk[i]) {
            int j = i;
            while (j < N) {
                chk[j] = 1;
                fact[j][factl[j]++] = i;
                j += i;
            }
        }
    }

    chk.assign(N, 0);
    for (auto& i : a) {
        for (int j = 0; j < factl[i]; ++j) {
            int cnt = 0, x = i, fi = fact[i][j];
            while (x % fi == 0) {
                x /= fi;
                cnt++;
            }
            chk[fi] = max(chk[fi], cnt);
        }
    }

    // for (int i = 2; i < N; ++i)
    //     if (chk[i]) cout << i << ' ' << chk[i] << '\n';

    int x = 1;
    for (int i = 2; i < N; ++i)
        if (chk[i]) x = (1LL * x * fpow(i, chk[i])) % M;
    int res = 0;
    for (auto& i : a) res = (res + (1LL * x * fpow(i, M - 2)) % M) % M;
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

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

mod = 998244353
class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size
        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % mod
            self.inv[i] = -self.inv[mod % i] * (mod // i) % mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % mod) % mod

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

ans = 0
m = M
comb = Combination(N)
for k in reversed(range(N)):
    now = m
    now *= comb.ncr(N - 1, k)
    now %= mod
    if k <= K:
        ans += now
        ans %= mod
    m *= M - 1
    m %= mod

print(ans)


Measured memory_bytes: 88048
// 解説 1
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    vector<vector<int> > a(n, vector<int> (n-1));
    rep(i, n) {
        rep(j, n-1) {
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(a[i].begin(), a[i].end());
    }
    vector<P> que;
    auto check = [&](int i) {
        if(a[i].size() == 0) return;
        int j = a[i].back();
        if(a[j].size() == 0) return;
        if(a[j].back() == i) {
            P p(i, j);
            if(p.second < p.first) swap(p.first, p.second);
            que.push_back(p);
        }
    };
    rep(i, n) {
        check(i);
    }
    int ans = 0;
    while(que.size() > 0) {
        ans++;
        sort(que.begin(), que.end());
        que.erase(unique(que.begin(), que.end()), que.end());
        vector<P> prevQ;
        swap(prevQ, que);
        for(P p : prevQ) {
            int i = p.first, j = p.second;
            a[i].pop_back();
            a[j].pop_back();
        }
        for(P p : prevQ) {
            int i = p.first, j = p.second;
            check(i);
            check(j);
        } 
    }
    rep(i, n) {
        if(a[i].size() != 0) {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4224