akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(bool a) {
  return a ? "T" : "F";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

const int N = 2e5 + 10, B = 1e9 + 7;

ll mypw(ll a, int b) {
  ll ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % B;
    b >>= 1;
    a = a * a % B;
  }
  return ret;
}

struct Modint {
  ll x;

  Modint(ll a = 0) {
    x = a % B;
    if (x < 0) x += B;
  }

  Modint inv() {
    return Modint(mypw(x, B - 2));
  }

  Modint operator+(Modint b) {
    return Modint(x + b.x);
  }

  Modint operator-(Modint b) {
    return Modint(x - b.x);
  }

  Modint operator*(Modint b) {
    return Modint(x * b.x);
  }

  Modint operator/(Modint b) {
    return (*this) * b.inv();
  }

};

string to_string(Modint a) {
  return to_string(a.x);
}

array <Modint, 3> go_dp(array <Modint, 3> &a, array <Modint, 3> &b) {
  array <Modint, 3> c = {};
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      c[min(2, i + j)] = c[min(2, i + j)] + a[i] * b[j];
    }
  }
  return c;
}

void run() {
  int n;
  cin >> n;
  vector <int> p(n + 1);
  vector < vector <int> > e(n + 1);
  p[0] = -1;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    e[p[i]].push_back(i);
  }

  function < deque < array <Modint, 3> >(int) > go = [&](int u) {
    deque < array <Modint, 3> > cur;

    int mx_2 = 0;
    for (auto v : e[u]) {
      auto t = go(v);
      if (cur.size() < t.size()) swap(t, cur);
      for (int i = 0; i < (int)t.size(); ++i) {
        cur[i] = go_dp(cur[i], t[i]);
      }
      maxi(mx_2, (int)t.size());
    }

    for (int i = 0; i < mx_2; ++i) {
      cur[i][0] = cur[i][2] + cur[i][0];
      cur[i][2] = 0;
    }

    cur.emplace_front(array <Modint, 3>{Modint(2).inv(), Modint(2).inv(), 0});

    return cur;
  };

  auto t = go(0);

  Modint ans = 0;

  for (int i = 0; i < (int)t.size(); ++i) {
    ans = ans + t[i][1] * mypw(2, n + 1);
  }
  
  cout << ans.x << endl;

}

int main() {
  run();
  return 0;
}


Measured memory_bytes: 174464
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

vector<vector<int>> v;
vector<int> base;
int N,M;
int ans = 0;

int main()
{
    cin >> N >> M;
    v.resize(N);
    
    for (int i = 0;i < N;i++){
        base.push_back(i);
    }
    
    int a,b;
    for (int i = 0;i < M;i++){
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    for (int i = 0;i < N;i++){
        sort(v[i].begin(),v[i].end());
    }

    do{
        for (int i = 0;i < N-1;i++){
            if (binary_search(v[base[i]].begin(),v[base[i]].end(),base[i+1])){
                ;
            }
            else{
                goto EXIT;
            }
        }
        ans++;
        EXIT:
        ;
    } while ( next_permutation(base.begin()+1,base.end()));
    
    cout << ans << endl;
}


Measured memory_bytes: 3656
// https://atcoder.jp/contests/abc091/tasks/arc092_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, x, y, r;

vector<bool> v;
vector<set<ll>> n;
vector<pll> ab;
set<pll> g;

stack<pll> ss(stack<pll> m, set<ll> c, ll i, bool f, ll l = -1)
{
  if (!v[i] && 2 < m.size() && m.size() % 2 == 1)
    return m;

  c.insert(i);
  for (auto &p : n[i])
  {
    if (p <= l)
      continue;

    pll nn = i < p ? (pll){i, p} : (pll){p, i};

    if (c.find(p) == c.end() && (g.find(nn) == g.end()) == f)
    {
      m.push(nn);
      return ss(m, c, p, !f);
    }
  }

  if (m.empty())
    return m;

  pll t = m.top();
  ll lt = t.first == i ? t.second : t.first;
  m.pop();
  c.erase(lt);
  return ss(m, c, lt, !f, i);
}

bool bb(ll i)
{
  stack<pll> est;
  set<ll> ese;
  stack<pll> t = ss(est, ese, i, true);

  if (0 < t.size())
  {
    while (!t.empty())
    {
      pll p = t.top();
      t.pop();
      auto itr = g.find(p);
      if (itr == g.end())
        g.insert(p);
      else
        g.erase(itr);
    }

    return true;
  }
  else
    return false;
}

void calc()
{
  REP(i, 2 * N)
  {
    v[i] = false;
  }
  for (auto &p : g)
    v[p.first] = v[p.second] = true;

  REP(i, 2 * N)
  {
    if (!v[i] && bb(i))
      return calc();
  }
  return;
}

int main()
{
  cin >> N;
  REP(i, 2 * N)
  {
    v.push_back(false);
  }
  REP(i, N)
  {
    set<ll> t;
    cin >> x >> y;
    ab.push_back(make_pair(x, y));
    n.push_back(t);
  }
  REP(i, N)
  {
    set<ll> t;
    cin >> x >> y;
    REP(j, N)
    {
      if (ab[j].first < x && ab[j].second < y)
      {
        n[j].insert(N + i);
        t.insert(j);
      }
    }
    n.push_back(t);
  }

  REP(i, 2 * N)
  {
    for (auto &j : n[i])
    {
      if (v[i] || v[j])
        continue;

      g.insert(i < j ? (pll){i, j} : (pll){j, i});
      v[i] = v[j] = true;
    };
  }

  calc();

  cout << g.size() << '\n';

  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    string a,b;
    cin >> a >> b;
    if(a.size() > b.size()){
        cout << "GREATER" << endl;
        return 0;
    }
    else if(a.size() < b.size()){
        cout << "LESS" << endl;
        return 0;
    }
    else{
        for(int i=0;i<a.size();i++){
            if(a.at(i) > b.at(i)){
                cout << "GREATER" << endl;
                return 0;
            }
            else if(a.at(i) < b.at(i)){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <climits>
#include <numeric>
#include <algorithm>

using namespace std;

struct magic_t{
    int pow = 0;
    int mp = 0;
};



int min_mp(vector<int>& minmps, const vector<magic_t>& magics, int hp){
    if(minmps[hp] != INT_MAX) return minmps[hp];
    int minmp = INT_MAX;
    for(size_t i = 0; i < magics.size(); ++i){
        const int nexthp = hp - magics[i].pow;
        int mp = magics[i].mp;
        if(nexthp > 0)
        {
            mp += min_mp(minmps, magics, nexthp);
        }
        minmp = min(minmp, mp);
    }
    return minmps[hp] = minmp;
}

int main()
{
    int H,N;
    cin >> H >> N;
    vector<magic_t> magics(N);
    for(auto& m : magics) cin >> m.pow >> m.mp;
    vector<int> minmps(H + 1, INT_MAX);
    cout << min_mp(minmps, magics, H) << '\n';
}


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

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	    cin>>arr[i];
	int cnt=1;
	int maxi=arr[0];
	for(int i=1;i<n;i++)
	{
		if(arr[i]>=maxi){cnt++;maxi=arr[i];}
		
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
import kotlin.math.max
//

fun main() {
    abc178b()
}

fun abc178b() {
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toLong() }
    var ans = a * c
    ans = max(ans, a * d)
    ans = max (ans, b * c)
    ans = max(ans, b * d)
    println(ans)
}


Measured memory_bytes: 36492
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n;
    if(s=="SAT")
        n=6;
    if(s=="SUN")
        n=7;
    if(s=="MON")
        n=1;
    if(s=="TUE")
        n=2;
    if(s=="WED")
        n=3;
    if(s=="THU")
        n=4;
    if(s=="FRI")
        n=5;
    n=7-n;
    if(n==0)
        n=7;
    cout<<n;
}


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

#define big ((long long)(1e9)+7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  // cout << n << endl;
  char a = 'A';
  char c = 'C';
  char g = 'G';
  char t = 'T';
  vector<int> count;
  int co = 0;
  for(int i = 0;i < n;i++){
    if(s.at(i) == a || s.at(i) == c || s.at(i) == g || s.at(i) == t){
      co++;
    }
    else{
      count.push_back(co);
      co = 0;
    }
  }
  count.push_back(co);
  // for(int i = 0;i < count.size();i++){
  //   cout << count[i] << endl;
  // }
  sort(count.rbegin(),count.rend());
  cout << count[0] << endl;
}


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

int main() {
  int l[10];
  int v[2];
  int s[11];
  int r;
  double x;

  while (1) {
    for (int i=0; i<10; i++) {
      scanf("%d,", &l[i]);
    }
    r = scanf("%d,%d", &v[0], &v[1]);
    if (r == EOF) break;

    s[0] = 0;
    for (int i=0; i<10; i++) {
      s[i+1] = s[i]+l[i];
    }
    x = (double)s[10] * v[0] / (v[0] + v[1]);
    for (int i=0; i<=10; i++) {
      if (s[i] >= x) {
        r = i;
        break;
      }
    }
    printf("%d\n", r);
  }

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	ll n, m,sum = 0;
	cin >> n >> m;
	vector<long long> a(n+1,0);
	repz(i, n) {
		cin >> a[i];
		sum += a[i];
	}

	sort(a.rbegin(), a.rend());

	int count = 0;
	repz(i, n) {
		if (a[i] * (4 * m) >= sum)count++;
	}
	if (count >= m)cout << "Yes" << endl;
	else cout << "No" << endl;

	system("pause");
	return 0;
}


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

int main() { 
    long long n, ans = 1e13;
    cin >> n;
    for(long long i = 1; i*i <= n; ++i) {
        if(n%i == 0) {
            ans = min(ans, (n/i) + i - 2);
        }
    }
    cout << ans << '\n';
    return 0;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

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











Measured memory_bytes: 256
import           Control.Applicative
import           Control.Monad
import           Text.Printf         (printf)

swap :: [Int] -> [Int]
swap c@[a, b]
    | a > b = [b, a]
    | otherwise = c

main :: IO ()
main = do
    xss <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
    forM_ (takeWhile (/= [0, 0]) xss) $ \xs -> do
        let [a, b] = swap xs
        printf "%d %d\n" a b



Measured memory_bytes: 4664
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;


int main() {

	int n = 0;
	cin >> n;
	int a[100] = {};
	rep(i, n) {
		cin >> a[i];
	}

	int count = 0, ans = 0;

	rep(i, n) {

		if (a[i] == 1) {
			count++;
		}
		else {
			count = 0;
		}
		ans = std::max(ans, count);
	}

	cout << ans + 1 << endl;

}


Measured memory_bytes: 3076
#include <cstdio>
#define max_n 200000
using namespace std;
int a[max_n+1];
int main(){
	long long ans=0;
	int n;
	scanf("%d",&n);
	for(int i=0; ++i<=n; scanf("%d",a+i));
	for(int l=0,r=1,x=0; ++l<=n; x^=a[l],ans+=r-l)
		for(; r<=n&&!(x&a[r]); ++r){
//			if(r==n){
//				printf("%lld\n",ans+(n-l+1)*(n-l+2)/2);
//				return 0;
//			}
			x|=a[r];
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2500
T_HP,T_AT,A_HP,A_AT = list(map(int, input().split()))
for i in range(102):
    A_HP = A_HP - T_AT
    if A_HP <= 0:
        print('Yes')
        break
    T_HP = T_HP - A_AT
    if T_HP <= 0:
        print('No')
        break

    

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli N=1e5+5;
vector<lli> v[N];
lli ans[N],dp[N],M;

void dfs1(lli x, lli par)
{
    dp[x]=1LL;
    for(auto j : v[x])
    {
        if(j==par) continue;
        
        dfs1(j, x);
        dp[x]*=dp[j];
        dp[x]%=M;
    }
    dp[x]++;
    dp[x]%=M;
}

void dfs2(lli x, lli par, lli uper)
{
    vector<lli> p,s;
    
    p.push_back(1LL);
    for(auto j : v[x])
    {
        if(j==par) continue;
        
        p.push_back(dp[j]);
        s.push_back(dp[j]);
    }
    s.push_back(1LL);
    
    for(int i=1;i<p.size();i++)    p[i]=(p[i]*p[i-1])%M;
    for(int i=s.size()-2;i>=0;i--) s[i]=(s[i]*s[i+1])%M;
    
    ans[x]=(p.back()*uper)%M;
    
    int i=0;
    for(auto j : v[x])
    {
        if(j==par) continue;
        
        dfs2(j, x, ((p[i]*s[i+1])%M *uper+1)%M);
        i++;
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n>>M;
    lli i,x,y;
    
    for(i=0;i<n-1;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    dfs1(1,1);   //bottom-up
    dfs2(1,1,1); //top-down
    
    for(i=1;i<=n;i++) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 25600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    vector<int> plus(N);
    for (int i = 0; i < N; i++) {
        plus[p[i] - 1] = 2*i+1;
    }
    vector<int> a(N), b(N);
    a[0] = plus[0];
    b[N-1] = plus[N-1];
    for (int i = 1; i < N; i++) {
        a[i] = a[i-1] + plus[i];
    }
    for (int i = N-2; i >= 0; i--) {
        b[i] = b[i+1] + plus[i];
    }
    for (int i = 0; i < N; i++) {
        printf("%d ", a[i]);
    }
    cout << endl;
    for (int i = 0; i < N; i++) {
        printf("%d ", b[i]);
    }
    cout << endl;


}

Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <bitset>

using ll = long long;

using namespace std;

#define amax(a, b) a = max(a, b)

int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    int jump[n], rjump[n];
    int prev = n;
    bool work[n];
    for (int i=n-1; i>=0; i--) {
        work[i] = (s[i] == 'o');
        if (s[i] == 'o') {
            prev = i;
            jump[i] = i;
        } else {
            jump[i] = prev;
        }
    }
    prev = -1;
    for (int i=0; i<n; i++) {
        if (work[i]) {
            rjump[i] = i;
            prev = i;
        } else {
            rjump[i] = prev;
        }
        // cerr << rjump[i] << '\n';
    }
    int left[n+1], right[n+1];
    fill(left, left+n+1, 0);
    fill(right, right+n+1, 0);
    for (int i=0; i<n-1; i++) {
        if (work[i]) {
            amax(left[i], 1); // 最初対策
            if (i+c+1 < n && jump[i+c+1] < n)
                amax(left[jump[i+c+1]], left[i] + 1);
        }
        amax(left[i+1], left[i]);
    }
    for (int i=n-1; i>=1; i--) {
        if (work[i]) {
            amax(right[i], 1); // 最初対策
            if (i-c-1 >= 0 && rjump[i-c-1] >= 0)
                amax(right[rjump[i-c-1]], right[i] + 1);
        }
        amax(right[i-1], right[i]);
    }
    for (int i=0; i<n; i++) {
        // cerr << (i > 0 ? left[i-1] : 0) << ' ' << right[i+1] << '\n';
        if (work[i] && (i > 0 ? left[i-1] : 0) + right[i+1] < k) {
            cout << i + 1 << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 5124
from collections import Counter
from itertools import permutations

N, C = map(int, input().split())
D = [[int(x) for x in input().split()] for _ in range(C)]

cnt = [Counter() for _ in range(3)]

for i in range(N):
    c = [int(x)-1 for x in input().split()]
    for j in range(3):
        cnt[j].update(c[(3-(i+2)+j)%3::3])

ans = 1000*500*500+5
for p in permutations(range(C), 3):
    s = 0
    for j in range(3):
        for k, v in cnt[j].items():
            s += D[k][p[j]] * v
    ans = min(ans, s)

print(ans)

Measured memory_bytes: 3436
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int32_t N, T;
	cin >> N >> T;

	vector<int32_t> t(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> t[i];
	}

	int64_t res = 0;
	for (int32_t i = 0; i < N - 1; i++) {
		if (t[i + 1] - t[i] < T)
			res += t[i + 1] - t[i];
		else
			res += T;
	}
	res += T;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    char grid[1005][1005];
    const int MOD = 1e9 + 7;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> grid[i][j];
        }
    }
    vector<vector<int>> dp(h, vector<int>(w, 0));
    for(int j = 0; j < w; ++j) {
        if(grid[0][j] == '#') break;
        dp[0][j] = 1;
    }
    for(int i = 0; i < h; ++i) {
        if(grid[i][0] == '#') break;
        dp[i][0] = 1;
    }
    for(int i = 1; i < h; ++i) {
        for(int j = 1; j < w; ++j) {
            if(grid[i][j] == '.') {
                dp[i][j] = ((long long) dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
    return 0;

}



Measured memory_bytes: 5248
import math

S = int(input())
if S>= 3600:
    h = math.floor(S/3600)
    m = math.floor((S%3600)/60)
    s = math.floor((S%3600)%60)
elif S < 3600 and S >= 60:
    h = 0
    m = math.floor(S/60)
    s = math.floor(S%60)
else:
    h = 0
    m = 0
    s = S
a= str(h)+":"+str(m)+":"+str(s)
print(a)



Measured memory_bytes: 5656
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll w[101],v[101];
ll dp[100001];
int main(){
    int n,W;
    cin>>n>>W;
    rep(i,n) cin>>w[i]>>v[i];
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    ll ans=0;
    rep(i,n)for(int j=100000;j>=v[i];--j){
        if(dp[j-v[i]]!=-1){
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
            if(dp[j]<=W)ans=max(ans,(ll)j);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        long x = sc.nextInt();
        long a = sc.nextInt();
        long b = sc.nextInt();

        if (a >= b) {
            _out.println("delicious");
        } else if (b - a <= x) {
            _out.println("safe");
        } else {
            _out.println("dangerous");
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

int main() {
  
  int n;
  cin>>n;
  // 100要素の配列で初期化
  vector<int> vec(n);

  // 100個の入力を受け取る
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  // 100要素の配列で初期化
  vector<int> a(n);

  // 100個の入力を受け取る
  for (int j = 0; j < n; j++) {
    cin >> a.at(j);
  }
  
  int s=0;
  
  for (int k = 0; k < n; k++) {
  if(vec.at(k)>a.at(k)){
   s=s+vec.at(k)-a.at(k);
    }    
  }

   cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N,M,Q;
vector<ll>a,b,c,d;

int dfs(vector<int> q){
    //全部決めたら評価
    if(q.size()==N){
        int sum =0;
        for(int i=0;i<Q;i++){
            if(q[b[i]]-q[a[i]] == c[i]){
                sum += d[i];
            }
        }
        return sum;
    }
    //以降で最大の値を求める。
    int retVal =0;
    for(int i=q[q.size()-1];i<=M;i++){
        vector<int> qn(q.size());
        copy(q.begin(),q.end(),qn.begin()); 
        qn.push_back(i);
        retVal = max(retVal, dfs(qn));
    }
    return retVal;

}



int main(){
    scanf("%lld",&N);
    scanf("%lld",&M);
    scanf("%lld",&Q);
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    for(int i = 0 ; i < Q ; i++){
       int e,f,g,h;
       cin >> e >> f>>g>>h;
       --e;--f;
       a[i] = e;
       b[i] = f;
       c[i] =g;
       d[i] =h;
    }
    vector<int> q;
    q.push_back(1);
    cout << dfs(q) << endl;
    return 0;
}


Measured memory_bytes: 3696
#pragma region Macros
 
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;
 
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}
 
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif
 
#pragma endregion
 
void Main() {
    int D;
    cin >> D;
 
    vi c(26);
    REP(i, 26) {
        cin >> c[i];
    }
    vvi s(D, vi(26));
    REP(i, D) {
        REP(j, 26) {
            cin >> s[i][j];
        }
    }
 
    int count = 0;
    REP(i, D) {
        set<int> set26;
        REP(j, 26) {
            set26.insert(j + 1);
        }
        while (!set26.empty()) {
            int a = rand() % 26 + 1;
            if (set26.count(a)) {
                cout << a << "\n";
                set26.erase(a);
                debug(a);
                count++;
                if (count >= D) {
                    return;
                }
            }
        }
    }
}
 
#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion

Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;


int main() {
	
	ll x;
	cin >> x;
	
	ll num = 100;
	ll cnt = 0;
	while (1) {
		num = num * 1.01;
		cnt++;
		if (num >= x) {
			cout << cnt << endl;
			break;
		}
	}
	
	return 0;
	
}



Measured memory_bytes: 3632
import sys
import numpy as np
from itertools import combinations_with_replacement,product
def input(): return sys.stdin.readline().rstrip()

def culc(array,k,count):
    array=array.T
    cuts=np.zeros(array.shape[1])
    for i in range(array.shape[0]):
        if any(array[i]>k):
            return 10**6
        elif any(array[i]+cuts>k):
            cuts=array[i]
            count+=1
        else:
            cuts+=array[i]
    return count


def main():
    h,w,k=map(int, input().split())
    choco=np.zeros((h,w))
    for i in range(h):
        choco[i]=list(input())
    ans=10**6
    choco=choco.astype(np.int64)
    for bit in product([0,1],repeat=h-1):
        if sum(bit)>=ans:
            break
        chocos=choco.copy()
        cut=chocos[0].reshape([1,w])
        for i in range(h-1):
            if bit[i]==1:
                cut=np.concatenate([cut,chocos[i+1].reshape([1,w])])
            else:
                cut[-1]+=chocos[i+1]
        ans=min(ans,culc(cut,k,sum(bit)))
    print(ans)


if __name__=='__main__':
    main()

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	ll res = a * b / ll(__gcd(a, b));
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3596
// input
function main(input) {
    const args = input.split('\n')[0];
    const char = args.split('');
    if (char[2] == char[3] && char[4] === char[5]) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}

// output
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22076
#include <iostream>

using namespace std;
int ans = 700;
string s;
int main()
{
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if( s[i] == 'o'){
            ans += 100;
        }
    }
    cout << ans;
//    if(s == "ooo"){
//        cout << "1000";
//    }
//    else if (s == "oox" || s == "oxo" || s == "xoo"){
//        cout << "900";
//    }
//    else if (s == "oxx" || s == "xox" || s == "xxo"){
//        cout << "800";
//    }
//    else if (s == "xxx") {
//        cout << "700";
//    }
    return 0;
}




//#include <iostream>
//
//using namespace std;
//string s;
//int main()
//{
//    cin >> s;
//    if(s == "ooo"){
//        cout << "1000";
//    }
//    else if (s == "oox" || s == "oxo" || s == "xoo"){
//        cout << "900";
//    }
//    else if (s == "oxx" || s == "xox" || s == "xxo"){
//        cout << "800";
//    }
//    else if (s == "xxx") {
//        cout << "700";
//    }
//    return 0;
//}


Measured memory_bytes: 256
N=int(input())

C=[0]*5
for i in range(N):
  s=list(input())
  if s[0]=="M":
    C[0]+=1
  elif s[0]=="R":
    C[1]+=1
  elif s[0]=="A":
    C[2]+=1
  elif s[0]=="C":
    C[3]+=1
  elif s[0]=="H":
    C[4]+=1
    
ans=0
for i,j,k in [[0,1,2],[0,1,3],[0,1,4],[0,2,3],[0,2,4],[0,3,4],[1,2,3],[1,2,4],[1,3,4],[2,3,4]]:
  ans+=C[i]*C[j]*C[k]
  
print(ans)    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;


int main()
{


    ll n,k; cin >> n >> k;
    int arr[n]{};
    for(int i = 0 ; i<n ; i++)cin >> arr[i];
    map<int,int> mem;
    for(int i = 0 ; i<n  ;i++)mem[arr[i]]++;

    ll sum = 0;
    vector<int> v;
    for(auto x : mem)
        {v.push_back(x.second); sum+=x.second;}

    ll cnt = 0 ;
    sort(v.rbegin() , v.rend());
    for(int i = 0; i<v.size() ; i++)
    {
        sum-=v[i];
        cnt++;
        if(cnt == k)break;
    }
    cout << sum << endl;


    return 0;
}


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

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

    vector<int> right(N);
    vector<int> left(N);

    int count_W = 0;
    int count_E=0;

    for(int i=0;i<s.size();i++){
        if(s[i] == 'W'){
            count_W++;
        }
        left[i]=count_W;
    }

    for(int i=s.size()-1;i>=0;i--){
        if(s[i] == 'E'){
            count_E++;
        }
        right[i] = count_E-1;
    }
    int ans = 1e9;
    for(int i=0;i<s.size();i++){
        ans = min(ans,right[i]+left[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
ll sum1,sum2;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    string s; cin>>s;
    for(int i=0;i<(1<<(s.size()-1));i++){ //0000,1111は除く
        for(int b=0;b<s.size();b++){
            sum1=sum1*10+(int)(s[b]-'0');
            if(i>>b&1||b==s.size()-1){
                sum2+=sum1; sum1=0;
            }
        }

    }
    cout<<sum2<<"\n";
    
    
    
    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C, X = map(int, read().split())

    ans = 0
    for i in range(A + 1):
        for j in range(B + 1):
            for k in range(C + 1):
                if 500 * i + 100 * j + 50 * k == X:
                    ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
class Dice      
    @face = nil         
                        
    def initialize ary   
        @face = ary        
    end                     

    def top
        @face[0]
    end

    def rotate news     
        f = @face.dup
        case news
        when "N"
            @face = [f[1],f[5],f[2],f[3],f[0],f[4]]
        when "E"
            @face = [f[3],f[1],f[0],f[5],f[4],f[2]]
        when "W"
            @face = [f[2],f[1],f[5],f[0],f[4],f[3]]
        when "S"
            @face = [f[4],f[0],f[2],f[3],f[5],f[1]]
        end
    end

    def right top,front
        "SWSWS".each_char do |c|
            if @face[0] == top
                break 
            end
            rotate c
        end
        rotate "N"
        "WWW".each_char do |c|
            if @face[0] == front
                break 
            end
            rotate c
        end
    @face[2]
    end

    def same? face2
        return true if @face == face2
        "WWWWSWWWWSWWWWSWWWWSWWWWSWWW".each_char { |c|
            rotate c
            return true if @face == face2
        }
        return false
    end
end

lines = []
n = gets.to_i
n.times {lines << gets.chomp.split}

differ = true
for i in 0..n-2
    for j in i + 1..n-1
        if Dice.new(lines[i]).same?(lines[j])
            differ = false
            break
        end
    end
end
puts differ ? "Yes" : "No"


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

signed main(){
	int N, val = 0, fl = 1; 
	cin>>N;
	char c[N+1];
	c[0] = '.';
	for(int i=1; i<=N; i++){
		cin>>c[i];
		if(c[i] == c[i-1] && fl == 1){
			fl = 0;
		}
		else if(c[i] != c[i-1]){
			val++; fl = 1;
		}
	}
	cout<<val;
}

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

const int mod = 1e9 + 7;
int main(){
    int h, w, K;
    cin >> h >> w >> K;
    vector<int> c;
    rep(i, 1 << w - 1){
        int flag = 1;
        rep(j, w - 2){
            if ((i >> j & 1) && (i >> j + 1 & 1))
                flag = 0;
        }
        if (flag) c.pb(i);
    }
    vector<vector<ll>> dp(h + 1, vector<ll>(w));
    rep(i, w) dp[0][0] = 1;
    rep(i, h){
        rep(j, w){
            int p = 0;
            int q = 0;
            int r = 0;
            rep(k, c.size()){
                if (j && (c[k] >> j - 1 & 1)) p++;
                else if (j < w - 1 && (c[k] >> j & 1)) q++;
                else r++;
            }
            dp[i + 1][j] = r * dp[i][j];
            if (j) dp[i + 1][j] += p * dp[i][j - 1];
            if (j < w - 1) dp[i + 1][j] += q * dp[i][j + 1];
            dp[i + 1][j] %= mod;
        }
    }
    cout << dp[h][K - 1] << endl;
}

Measured memory_bytes: 3644
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define endl            "\n"
#define pb              push_back
#define ppb              pop_back
#define mp              make_pair
#define pii             pair<int, int>
#define vi              vector<int>
#define all(x)          (x).begin(), (x).end()
#define mii             map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed << setprecision(y) << x
#define mk(arr,n,type)  type *arr = new type[n];
#define w(x)            int x; cin >> x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
inline int ceili(int x, int y) { return (x + y - 1) / y; }
 
void solve()
{
    string s, t; cin >> s >> t;
    int mn = INT_MAX, cnt;

    for(int i = 0; i < s.size() - t.size() + 1; ++i) {
        cnt = 0;
        for(int j = 0, k = i; j < t.size(); ++j, ++k) {
            if(s[k] != t[j]) ++cnt;
        }
        mn = min(cnt, mn);
    }
    cout << mn << endl;
}
 
int32_t main()
{
    FIO;
 
    solve();
 
    return 0;
}

Measured memory_bytes: 3572
import java.util.*;

public class Main {
static class UnionFind {
    List<Integer> Parent;
    UnionFind(int N) {
        Parent = new ArrayList<Integer>();
        Integer[] values = new Integer[N];
        Arrays.fill(values, -1);
        Parent.addAll(Arrays.asList(values));
    }
    int root(int A) {
        if (Parent.get(A) < 0)
            return A;
        int root = root(Parent.get(A));
        Parent.set(A, root);
        return root;
    }
    int size(int A) {
        return -Parent.get(root(A));
    }

    boolean connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) {
            return false;
        }

        if (size(A) < size(B)) {
            int temp = A;
            A = B;
            B = temp;
        }

        Parent.set(A, Parent.get(A) + Parent.get(B));
        Parent.set(B, A);

        return true;
    }
}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Comparator<int[]> comparator = new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return Integer.compare(o1[0], o2[0]);
            }
        };
        ArrayList<int[]> X = new ArrayList<int[]>();
        ArrayList<int[]> Y = new ArrayList<int[]>();
        int[] x = new int[N];
        int[] y = new int[N];
        for (int i=0;i<N;i++) {
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
            int[] add_x = {x[i], i};
            int[] add_y = {y[i], i};
            X.add(add_x);
            Y.add(add_y);
        }
        Collections.sort(X, comparator);
        Collections.sort(Y, comparator);
        ArrayList<int[]> X_Y = new ArrayList<int[]>();
        for (int i=1;i<N;i++) {
            int[] add_x = {X.get(i)[0]-X.get(i-1)[0], X.get(i-1)[1], X.get(i)[1]};
            int[] add_y = {Y.get(i)[0]-Y.get(i-1)[0], Y.get(i-1)[1], Y.get(i)[1]};
            X_Y.add(add_x);
            X_Y.add(add_y);
        }
        Collections.sort(X_Y, comparator);
        long ans = 0L;
        // HashSet<Integer> set = new HashSet<Integer>();
        UnionFind uf = new UnionFind(N);
        for (int i=0;i<X_Y.size();i++) {
            int dist = X_Y.get(i)[0];
            int xx = X_Y.get(i)[1];
            int yy = X_Y.get(i)[2];
            // if (set.contains(xx) && set.contains(yy)) continue;
            if (!uf.connect(xx, yy)) continue;
            ans += (long)dist;
            // set.add(xx);
            // set.add(yy);
        }
        System.out.println(ans);
    }
}

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

int main(){
  int N;
  cin >> N;
  if(N<10){
    cout << N << endl;
  }
  else if(N<100){
    cout << 9 << endl;
  }
  else if(N<1000){
    cout << N-90 << endl;
  }
  else if(N<10000){
    cout << 909 << endl;
  }
  else if(N<100000){
    cout << 90909-100000+N+1 << endl;
  }
  else{
    cout << 90909 << endl;
  }
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CReplacingInteger solver = new CReplacingInteger();
        solver.solve(1, in, out);
        out.close();
    }

    static class CReplacingInteger {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = Long.parseLong(in.next());
            long k = Long.parseLong(in.next());

            n = n % k;

            long m;
            boolean flg = true;

            while (flg) {
                m = Math.abs(n - k);
                if (m < n) {
                    n = m;
                } else {
                    flg = false;
                }
            }
            out.println(n);
        }

    }
}



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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

const long long maxprime = 1e6 + 5;
bitset <maxprime> is_prime;
vector <long long> primes;
vector <long long>  factors;


//Gera uma lista de números primos até maxprime
//Funciona bem até 10^7
//Complexidade O(N log log N)
void SieveOfEratosthenes(){
  is_prime.set();
  is_prime[0] = is_prime[1] = 0;

  for(long long i = 2;i<=maxprime;i++){
    if(is_prime[i]){
      primes.push_back(i);
      for(long long j = i*i;j<=maxprime;j+=i){
        is_prime[j] = 0;
      }
    }
  }
}

//Gera uma lista dos fatores primos de N
//Complexidade O(sqrt(N)/ln sqrt(N))
set<ll> primeFactors(long long N){
  int idx = 0;
  long long pf = primes[idx];
  set<ll> f;
  while(pf*pf <= N){
    while(N%pf == 0){
      N /= pf;
      f.insert(pf);
    }
    pf = primes[++idx];
  }

  if(N != 1){
    f.insert(N);
  }
    return f;
}


void solve(){
    SieveOfEratosthenes();
    int n; cin >> n;
    vector<ll> a(n);
    for (auto &b: a) cin >> b;
    map<ll, ll> cnt;
    for (auto x : a){
        auto f = primeFactors(x);
        for (auto y : f) cnt[y]++;
    }
    bool pw = true;
    for (auto k : cnt){
        if (k.s > 1) {
            pw = false;
            break;
        }
    }
    if (pw){
        cout << "pairwise coprime\n";
        return;
    }
    ll gcd = a[0];
    for (int i = 0; i < n; ++i){
        gcd = __gcd(gcd, a[i]);
    }
    if (gcd != 1){
        cout << "not coprime\n";
    }
    else cout << "setwise coprime\n";
}

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n;
	int t = 1; //cin >> t;
	while(t--) solve();
	return 0;
}



Measured memory_bytes: 16772
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  n--;
  ll ans=n*(n+1)/2;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

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

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

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

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

vector<ll> enum_div(ll n){
	vector<ll> ret;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0){
			ret.push_back(i);
			if(i*i!=n){
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

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

	int A=in();
	auto V=enum_div(A);
	bool flag = false;
	for(auto& x:V){
		if(x>9) continue;
		if(A/x>9) continue;
		flag = true;
		break;
	}
	
	out(flag?"Yes":"No");
	return 0;
}

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

int N;
vector<long long> val;

int main() {
    int num = 0;
    cin >> N;
    val.resize(N);
    for (int i = 0; i < N; ++i) cin >> val[i];
    sort(val.begin(), val.end(), greater<int>());
    for (int i = 0; i < N-2; ++i) {
        for (int j = 0; j < N-2-i; ++j) {
            for (int k = 0; k < N-2-i-j; ++k) {
                if (val[i] >= val[i+1+j] + val[i+2+j+k]) {
                    break;
                }
                else {
                    num += 1;
                }
            }
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256